From patchwork Wed Jul 5 02:54:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Colberg, Peter" X-Patchwork-Id: 115917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1592451vqx; Tue, 4 Jul 2023 20:05:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlHp/w6qaFzObQoPuVWuBMIZu0BcAWMKvfeuGChgROwIypI4+iOgvNVoPLyNsKvHQUuSuKQ+ X-Received: by 2002:a17:90a:d48e:b0:261:49b:d65 with SMTP id s14-20020a17090ad48e00b00261049b0d65mr16424997pju.28.1688526318381; Tue, 04 Jul 2023 20:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688526318; cv=none; d=google.com; s=arc-20160816; b=Yvd+h1dLVklrYwXsryEdWTM5YoiPbSFKHjLT1PwxEOJgRTjexPSBiLy5+GO6AEmDEw oa2E6xYC8ubT4Q9RC8zNmHXNXv2TfN4cqgxg4OZ3zG2N4gECNQuI4sPmZ7x8R5+Ss5A4 A2vg1cBd8ugcFiyklO9Nv1CFPxb4c7BBHEt6i9Qp78ttX51qIm/FIHDsxY70d5GsK70K 9OeY15hXziKggqDbqd2LfZ3y2Rhwg1sC40jV56f3rty/AFnVRwe2eCf0OeUifEh/HAjE 4MgOmDBGUNYZ8XsfoEp0unH1skKtdPOIEOOHbcfNXb6O4JDesyoJQxPl0hrAqF4RTJaR 5uTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+66Ef82VfbJho/IL147DDe+JvfmNZxkvYN8FDYaAw/A=; fh=EfGfCvONN/iD38dbDQNrJIeZsDkYD/SurJ3mZhpSxv8=; b=TV/EIfp8H+Ie6h6PHPc8TfKqTZ+3pJ6xuFCjXB+MqXHTHsnIzXjlTXqn4kuGFG/n0M z2uxW4pLujgDpMLLghO+ONoKaiXrcapzWguWUFyIOyq9OEDtoY8WcR6ppKF5E+PB9jHK 6++/5lyteylBR2LQgIKmVovJ7gnWZHFopDCwfuGopzAJAtWmnVP8za0fcKiwLyW9Gq+V sN9NP6S7H9qDjNDepGyzv+bJoF7aWDhlVKnt/Jj6Vkf8bvlELys3NikrVi9dvH8pyjwI oxN+52CTtTd0RjCvWubXbjGabGOhmDAcGYr9YSvwR6PT0wcdIjapn/BFV+v+M/QM2UAA bBxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="d/EnqWuD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a17090a899800b00262e1adb2c7si660404pjn.51.2023.07.04.20.05.03; Tue, 04 Jul 2023 20:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="d/EnqWuD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbjGECzP (ORCPT + 99 others); Tue, 4 Jul 2023 22:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbjGECzN (ORCPT ); Tue, 4 Jul 2023 22:55:13 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3351910F8; Tue, 4 Jul 2023 19:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688525712; x=1720061712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5WC8P8GcGa8BS4IN/OSHf+dk5rOPXZjdNP6PUxd+4rk=; b=d/EnqWuDgfLGnvnBAsx1N78FvmMVPmyGZS4L8ngFcJHFb1IJw5y9lpCQ IUAbN+7mycpurwKTYl1Ud2QTBjYzSEyy16VJoQchYwv2MSRE9JwcYleP0 18ad0Jcl9+zrw5gK9H+Gn4M2bxstu1KRgc/YHqKHvOt50LObVOY6lrJdj PnvZrDF4g3m7wfbud05WiN2CvPaxIiFPLjZXdsVAv9hArI5ESGdpzyT0f H80JK71h28fpRAHEfiRNCoPFf9ysSzDsWARzlTtcYIqgUYvb2lhg4i5xm PqKZ+n4/hg5I5FGqqTJ4tMltU8DDuH4/e2JN5XnawLc71rsSeRa5X79q2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="343567176" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="343567176" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 19:55:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="754206077" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="754206077" Received: from scc823097.zsc7.intel.com ([10.148.153.229]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 19:55:11 -0700 From: Peter Colberg To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , tianfei.zhang@intel.com, russell.h.weight@intel.com, matthew.gerlach@linux.intel.com, marpagan@redhat.com, lgoncalv@redhat.com, Peter Colberg Subject: [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values Date: Tue, 4 Jul 2023 22:54:50 -0400 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770548172687078314?= X-GMAIL-MSGID: =?utf-8?q?1770548172687078314?= Use sysfs_emit() to format sysfs values, which wraps vscnprintf() for a PAGE_SIZE buffer. Remove explicit casts in favour of using the printk() format specifier corresponding to the type of the formatted value. These changes are cosmetic only; no functional changes. Suggested-by: Andy Shevchenko Signed-off-by: Peter Colberg Reviewed-by: Andy Shevchenko --- drivers/fpga/dfl-afu-error.c | 7 +++---- drivers/fpga/dfl-afu-main.c | 17 ++++++++--------- drivers/fpga/dfl-fme-error.c | 19 ++++++++----------- drivers/fpga/dfl-fme-main.c | 26 ++++++++++---------------- drivers/fpga/dfl-fme-perf.c | 16 +++++++--------- drivers/fpga/dfl.c | 4 ++-- drivers/fpga/fpga-bridge.c | 2 +- drivers/fpga/fpga-mgr.c | 4 ++-- drivers/fpga/fpga-region.c | 5 ++--- 9 files changed, 43 insertions(+), 57 deletions(-) diff --git a/drivers/fpga/dfl-afu-error.c b/drivers/fpga/dfl-afu-error.c index ab7be6217368..6d113d606560 100644 --- a/drivers/fpga/dfl-afu-error.c +++ b/drivers/fpga/dfl-afu-error.c @@ -125,7 +125,7 @@ static ssize_t errors_show(struct device *dev, struct device_attribute *attr, error = readq(base + PORT_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)error); + return sysfs_emit(buf, "0x%llx\n", error); } static ssize_t errors_store(struct device *dev, struct device_attribute *attr, @@ -156,7 +156,7 @@ static ssize_t first_error_show(struct device *dev, error = readq(base + PORT_FIRST_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)error); + return sysfs_emit(buf, "0x%llx\n", error); } static DEVICE_ATTR_RO(first_error); @@ -175,8 +175,7 @@ static ssize_t first_malformed_req_show(struct device *dev, req1 = readq(base + PORT_MALFORMED_REQ1); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%016llx%016llx\n", - (unsigned long long)req1, (unsigned long long)req0); + return sysfs_emit(buf, "0x%016llx%016llx\n", req1, req0); } static DEVICE_ATTR_RO(first_malformed_req); diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c index 7f621e96d3b8..51fdbe8a2f26 100644 --- a/drivers/fpga/dfl-afu-main.c +++ b/drivers/fpga/dfl-afu-main.c @@ -155,7 +155,7 @@ id_show(struct device *dev, struct device_attribute *attr, char *buf) { int id = port_get_id(to_platform_device(dev)); - return scnprintf(buf, PAGE_SIZE, "%d\n", id); + return sysfs_emit(buf, "%d\n", id); } static DEVICE_ATTR_RO(id); @@ -172,7 +172,7 @@ ltr_show(struct device *dev, struct device_attribute *attr, char *buf) v = readq(base + PORT_HDR_CTRL); mutex_unlock(&pdata->lock); - return sprintf(buf, "%x\n", (u8)FIELD_GET(PORT_CTRL_LATENCY, v)); + return sysfs_emit(buf, "%llx\n", FIELD_GET(PORT_CTRL_LATENCY, v)); } static ssize_t @@ -213,7 +213,7 @@ ap1_event_show(struct device *dev, struct device_attribute *attr, char *buf) v = readq(base + PORT_HDR_STS); mutex_unlock(&pdata->lock); - return sprintf(buf, "%x\n", (u8)FIELD_GET(PORT_STS_AP1_EVT, v)); + return sysfs_emit(buf, "%llx\n", FIELD_GET(PORT_STS_AP1_EVT, v)); } static ssize_t @@ -251,7 +251,7 @@ ap2_event_show(struct device *dev, struct device_attribute *attr, v = readq(base + PORT_HDR_STS); mutex_unlock(&pdata->lock); - return sprintf(buf, "%x\n", (u8)FIELD_GET(PORT_STS_AP2_EVT, v)); + return sysfs_emit(buf, "%llx\n", FIELD_GET(PORT_STS_AP2_EVT, v)); } static ssize_t @@ -288,7 +288,7 @@ power_state_show(struct device *dev, struct device_attribute *attr, char *buf) v = readq(base + PORT_HDR_STS); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%x\n", (u8)FIELD_GET(PORT_STS_PWR_STATE, v)); + return sysfs_emit(buf, "0x%llx\n", FIELD_GET(PORT_STS_PWR_STATE, v)); } static DEVICE_ATTR_RO(power_state); @@ -348,7 +348,7 @@ userclk_freqsts_show(struct device *dev, struct device_attribute *attr, userclk_freqsts = readq(base + PORT_HDR_USRCLK_STS0); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)userclk_freqsts); + return sysfs_emit(buf, "0x%llx\n", userclk_freqsts); } static DEVICE_ATTR_RO(userclk_freqsts); @@ -366,8 +366,7 @@ userclk_freqcntrsts_show(struct device *dev, struct device_attribute *attr, userclk_freqcntrsts = readq(base + PORT_HDR_USRCLK_STS1); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", - (unsigned long long)userclk_freqcntrsts); + return sysfs_emit(buf, "0x%llx\n", userclk_freqcntrsts); } static DEVICE_ATTR_RO(userclk_freqcntrsts); @@ -472,7 +471,7 @@ afu_id_show(struct device *dev, struct device_attribute *attr, char *buf) guidh = readq(base + GUID_H); mutex_unlock(&pdata->lock); - return scnprintf(buf, PAGE_SIZE, "%016llx%016llx\n", guidh, guidl); + return sysfs_emit(buf, "%016llx%016llx\n", guidh, guidl); } static DEVICE_ATTR_RO(afu_id); diff --git a/drivers/fpga/dfl-fme-error.c b/drivers/fpga/dfl-fme-error.c index 51c2892ec06d..a570f294ad82 100644 --- a/drivers/fpga/dfl-fme-error.c +++ b/drivers/fpga/dfl-fme-error.c @@ -52,7 +52,7 @@ static ssize_t pcie0_errors_show(struct device *dev, value = readq(base + PCIE0_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)value); + return sysfs_emit(buf, "0x%llx\n", value); } static ssize_t pcie0_errors_store(struct device *dev, @@ -97,7 +97,7 @@ static ssize_t pcie1_errors_show(struct device *dev, value = readq(base + PCIE1_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)value); + return sysfs_emit(buf, "0x%llx\n", value); } static ssize_t pcie1_errors_store(struct device *dev, @@ -136,8 +136,7 @@ static ssize_t nonfatal_errors_show(struct device *dev, base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_GLOBAL_ERR); - return sprintf(buf, "0x%llx\n", - (unsigned long long)readq(base + RAS_NONFAT_ERROR)); + return sysfs_emit(buf, "0x%llx\n", readq(base + RAS_NONFAT_ERROR)); } static DEVICE_ATTR_RO(nonfatal_errors); @@ -148,8 +147,7 @@ static ssize_t catfatal_errors_show(struct device *dev, base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_GLOBAL_ERR); - return sprintf(buf, "0x%llx\n", - (unsigned long long)readq(base + RAS_CATFAT_ERROR)); + return sysfs_emit(buf, "0x%llx\n", readq(base + RAS_CATFAT_ERROR)); } static DEVICE_ATTR_RO(catfatal_errors); @@ -166,8 +164,7 @@ static ssize_t inject_errors_show(struct device *dev, v = readq(base + RAS_ERROR_INJECT); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", - (unsigned long long)FIELD_GET(INJECT_ERROR_MASK, v)); + return sysfs_emit(buf, "0x%llx\n", FIELD_GET(INJECT_ERROR_MASK, v)); } static ssize_t inject_errors_store(struct device *dev, @@ -211,7 +208,7 @@ static ssize_t fme_errors_show(struct device *dev, value = readq(base + FME_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)value); + return sysfs_emit(buf, "0x%llx\n", value); } static ssize_t fme_errors_store(struct device *dev, @@ -258,7 +255,7 @@ static ssize_t first_error_show(struct device *dev, value = readq(base + FME_FIRST_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)value); + return sysfs_emit(buf, "0x%llx\n", value); } static DEVICE_ATTR_RO(first_error); @@ -275,7 +272,7 @@ static ssize_t next_error_show(struct device *dev, value = readq(base + FME_NEXT_ERROR); mutex_unlock(&pdata->lock); - return sprintf(buf, "0x%llx\n", (unsigned long long)value); + return sysfs_emit(buf, "0x%llx\n", value); } static DEVICE_ATTR_RO(next_error); diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c index bcb5d34b3b82..3b2ad31edf87 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -34,8 +34,7 @@ static ssize_t ports_num_show(struct device *dev, v = readq(base + FME_HDR_CAP); - return scnprintf(buf, PAGE_SIZE, "%u\n", - (unsigned int)FIELD_GET(FME_CAP_NUM_PORTS, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(FME_CAP_NUM_PORTS, v)); } static DEVICE_ATTR_RO(ports_num); @@ -53,7 +52,7 @@ static ssize_t bitstream_id_show(struct device *dev, v = readq(base + FME_HDR_BITSTREAM_ID); - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); + return sysfs_emit(buf, "0x%llx\n", v); } static DEVICE_ATTR_RO(bitstream_id); @@ -71,7 +70,7 @@ static ssize_t bitstream_metadata_show(struct device *dev, v = readq(base + FME_HDR_BITSTREAM_MD); - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); + return sysfs_emit(buf, "0x%llx\n", v); } static DEVICE_ATTR_RO(bitstream_metadata); @@ -85,8 +84,7 @@ static ssize_t cache_size_show(struct device *dev, v = readq(base + FME_HDR_CAP); - return sprintf(buf, "%u\n", - (unsigned int)FIELD_GET(FME_CAP_CACHE_SIZE, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(FME_CAP_CACHE_SIZE, v)); } static DEVICE_ATTR_RO(cache_size); @@ -100,8 +98,7 @@ static ssize_t fabric_version_show(struct device *dev, v = readq(base + FME_HDR_CAP); - return sprintf(buf, "%u\n", - (unsigned int)FIELD_GET(FME_CAP_FABRIC_VERID, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(FME_CAP_FABRIC_VERID, v)); } static DEVICE_ATTR_RO(fabric_version); @@ -115,8 +112,7 @@ static ssize_t socket_id_show(struct device *dev, v = readq(base + FME_HDR_CAP); - return sprintf(buf, "%u\n", - (unsigned int)FIELD_GET(FME_CAP_SOCKET_ID, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(FME_CAP_SOCKET_ID, v)); } static DEVICE_ATTR_RO(socket_id); @@ -285,8 +281,7 @@ static ssize_t temp1_max_policy_show(struct device *dev, v = readq(feature->ioaddr + FME_THERM_THRESHOLD); - return sprintf(buf, "%u\n", - (unsigned int)FIELD_GET(TEMP_THRESHOLD1_POLICY, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(TEMP_THRESHOLD1_POLICY, v)); } static DEVICE_ATTR_RO(temp1_max_policy); @@ -489,7 +484,7 @@ static ssize_t power1_xeon_limit_show(struct device *dev, if (FIELD_GET(XEON_PWR_EN, v)) xeon_limit = FIELD_GET(XEON_PWR_LIMIT, v); - return sprintf(buf, "%u\n", xeon_limit * 100000); + return sysfs_emit(buf, "%u\n", xeon_limit * 100000); } static ssize_t power1_fpga_limit_show(struct device *dev, @@ -504,7 +499,7 @@ static ssize_t power1_fpga_limit_show(struct device *dev, if (FIELD_GET(FPGA_PWR_EN, v)) fpga_limit = FIELD_GET(FPGA_PWR_LIMIT, v); - return sprintf(buf, "%u\n", fpga_limit * 100000); + return sysfs_emit(buf, "%u\n", fpga_limit * 100000); } static ssize_t power1_ltr_show(struct device *dev, @@ -515,8 +510,7 @@ static ssize_t power1_ltr_show(struct device *dev, v = readq(feature->ioaddr + FME_PWR_STATUS); - return sprintf(buf, "%u\n", - (unsigned int)FIELD_GET(FME_LATENCY_TOLERANCE, v)); + return sysfs_emit(buf, "%llu\n", FIELD_GET(FME_LATENCY_TOLERANCE, v)); } static DEVICE_ATTR_RO(power1_xeon_limit); diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c index 7422d2bc6f37..1b072416069b 100644 --- a/drivers/fpga/dfl-fme-perf.c +++ b/drivers/fpga/dfl-fme-perf.c @@ -524,20 +524,18 @@ static ssize_t fme_perf_event_show(struct device *dev, { struct dev_ext_attribute *eattr; unsigned long config; - char *ptr = buf; eattr = container_of(attr, struct dev_ext_attribute, attr); config = (unsigned long)eattr->var; - ptr += sprintf(ptr, "event=0x%02x", (unsigned int)get_event(config)); - ptr += sprintf(ptr, ",evtype=0x%02x", (unsigned int)get_evtype(config)); + if (!is_portid_root(get_portid(config))) + return sysfs_emit(buf, + "event=0x%02llx,evtype=0x%02llx,portid=?\n", + get_event(config), get_evtype(config)); - if (is_portid_root(get_portid(config))) - ptr += sprintf(ptr, ",portid=0x%02x\n", FME_PORTID_ROOT); - else - ptr += sprintf(ptr, ",portid=?\n"); - - return (ssize_t)(ptr - buf); + return sysfs_emit(buf, "event=0x%02llx,evtype=0x%02llx,portid=0x%02x\n", + get_event(config), get_evtype(config), + FME_PORTID_ROOT); } #define FME_EVENT_ATTR(_name) \ diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index dd7a783d53b5..db8141b68f79 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -307,7 +307,7 @@ type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dfl_device *ddev = to_dfl_dev(dev); - return sprintf(buf, "0x%x\n", ddev->type); + return sysfs_emit(buf, "0x%x\n", ddev->type); } static DEVICE_ATTR_RO(type); @@ -316,7 +316,7 @@ feature_id_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dfl_device *ddev = to_dfl_dev(dev); - return sprintf(buf, "0x%x\n", ddev->feature_id); + return sysfs_emit(buf, "0x%x\n", ddev->feature_id); } static DEVICE_ATTR_RO(feature_id); diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index a6c25dee9cc1..9b88c18cc126 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -286,7 +286,7 @@ static ssize_t name_show(struct device *dev, { struct fpga_bridge *bridge = to_fpga_bridge(dev); - return sprintf(buf, "%s\n", bridge->name); + return sysfs_emit(buf, "%s\n", bridge->name); } static ssize_t state_show(struct device *dev, diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index eb583f86a0b9..b3991f921312 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -618,7 +618,7 @@ static ssize_t name_show(struct device *dev, { struct fpga_manager *mgr = to_fpga_manager(dev); - return sprintf(buf, "%s\n", mgr->name); + return sysfs_emit(buf, "%s\n", mgr->name); } static ssize_t state_show(struct device *dev, @@ -626,7 +626,7 @@ static ssize_t state_show(struct device *dev, { struct fpga_manager *mgr = to_fpga_manager(dev); - return sprintf(buf, "%s\n", state_str[mgr->state]); + return sysfs_emit(buf, "%s\n", state_str[mgr->state]); } static ssize_t status_show(struct device *dev, diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index ccf6fdab1360..7a3572b78f50 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -166,9 +166,8 @@ static ssize_t compat_id_show(struct device *dev, if (!region->compat_id) return -ENOENT; - return sprintf(buf, "%016llx%016llx\n", - (unsigned long long)region->compat_id->id_h, - (unsigned long long)region->compat_id->id_l); + return sysfs_emit(buf, "%016llx%016llx\n", region->compat_id->id_h, + region->compat_id->id_l); } static DEVICE_ATTR_RO(compat_id); From patchwork Wed Jul 5 02:54:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Colberg, Peter" X-Patchwork-Id: 115921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1593961vqx; Tue, 4 Jul 2023 20:09:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlHu1W8LKQJKI8CmhgjPvpPi6COB5rZ4B2ttBZr2gWg1dL85lLVMT0uPj0h1PoBDghGz+SkE X-Received: by 2002:a81:93c7:0:b0:56f:fbc6:3b0 with SMTP id k190-20020a8193c7000000b0056ffbc603b0mr15366035ywg.14.1688526558744; Tue, 04 Jul 2023 20:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688526558; cv=none; d=google.com; s=arc-20160816; b=dI2144xG9UxSMZvxTtMuVQ952h5HBePiCpy+gkj2tNkzcBL8C5qe5HoBtxjaTpULYp e/eH7NRr+hutWopdpkjkdHLNEOeRrlrR/pL0T9DwbvIolXysUFIH5po9c99H9fVumhFZ Xy93cu22uJh1IQuLtqLmHmu7xVcNG0AvmjlyrSWTHHk6GrjPYUGQv69MnP4pJcqx3yTG Kfv7TNYhrhI7imRzo6VWKN4fzFO+bUE6s/mO3TTOaxuZhFqV5RIGBuBc5Syy40Ol31fR T3XE6GyDmm7+Bf+NdvwyDY7LVI2C3JNwVuGihK9j35TknhtYF5dwIufWc71aC+HUGyXs 8QKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HKuzvg8COCbZsJNTWKxSgPS3wjxSAf7rNu/6t53D2mo=; fh=GHzV6gjveynZvs7pDNWyXWBvpts/SKuvny2fbnydznQ=; b=HBfWdmuTQwhLM9lyaP5lEI1afB36VJFdscn3tx8vPeisygnZbiyTnJigKZ62xXI5o7 V0Ar3Sd5adW5MsoS2HrtGwKxob0D85DbazEgX0WJmJCpXHKlrNd6i7K2Jw9qxeubxtAA EHMbFTApGsldo/VrCqr1hFWzmr4hO9UlOuuV4a5ojBvyUqaVk93sKHV1jf3ACRlzTw8t j2fpZkEts1BfvOxiCPkbz7rkG33GPgRqSvotwNoMqPoQ/PcNnjZQPp5iEdTpWbqHPAT/ vXqO0gI8YNbEpUQhV5KnU3jc7UJ749Bcz46Jq+qOlc5mkSvztx/3pAIARTPcC8wj9wEz 6nLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mOc+cH68; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x34-20020a634a22000000b0054ff42d3833si22503579pga.336.2023.07.04.20.09.05; Tue, 04 Jul 2023 20:09:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mOc+cH68; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230417AbjGECzS (ORCPT + 99 others); Tue, 4 Jul 2023 22:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjGECzO (ORCPT ); Tue, 4 Jul 2023 22:55:14 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60BC10FB; Tue, 4 Jul 2023 19:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688525713; x=1720061713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Jl+5/3iICde90mhWtlEKUB3c1yzRXMoUe/SxfyPzYs=; b=mOc+cH68RubjJh9mCFEEGGpJCoP2Rr7Wl04dqEEOss+9194Z2Pc10OsH oM/8DI8Nb7ac80DvzlkJKUUrMPppTvhhLeqniPg11vLp8I+tXwvXXWjEb IMjPR3nQ2PRu0gVI3WAnm3RRR43zVYNp1S1NxGGMrIWOIkR1KGrFAy682 lL0iGBk11of+fmaGYYxvvjVutLuhzbo8hU+ixSeeWtwQQOXdiVYztj6rG dOwbYl/weQerRLY3p0vOBCKH7O4hRft/Bvk89PLvAOn2a9XeurfGeaFsL Zjpk628N/x5VRQ/PAPT/37jfIfO1sVaeu3oa/RgmleYMELiSRZ1pq0nhz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="343567180" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="343567180" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 19:55:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="754206085" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="754206085" Received: from scc823097.zsc7.intel.com ([10.148.153.229]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 19:55:13 -0700 From: Peter Colberg To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , tianfei.zhang@intel.com, russell.h.weight@intel.com, matthew.gerlach@linux.intel.com, marpagan@redhat.com, lgoncalv@redhat.com, Peter Colberg Subject: [PATCH 2/2] fpga: dfl: omit unneeded casts of u64 values for dev_dbg() Date: Tue, 4 Jul 2023 22:54:51 -0400 Message-Id: <0cffb04a207a98148c61f512aa4dc90880e51251.1687301688.git.peter.colberg@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770548424812740109?= X-GMAIL-MSGID: =?utf-8?q?1770548424812740109?= Omit unneeded casts of u64 values to unsigned long long for use with printk() format specifier %llx. Unlike user space, the kernel defines u64 as unsigned long long for all architectures; see commit 2a7930bd77fe ("Documentation/printk-formats.txt: No casts needed for u64/s64"). These changes are cosmetic only; no functional changes. Suggested-by: Andy Shevchenko Signed-off-by: Peter Colberg Reviewed-by: Andy Shevchenko --- drivers/fpga/dfl-afu-dma-region.c | 14 ++++++-------- drivers/fpga/dfl-afu-main.c | 4 +--- drivers/fpga/dfl-fme-mgr.c | 5 ++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c index 02b60fde0430..71ed9d394d07 100644 --- a/drivers/fpga/dfl-afu-dma-region.c +++ b/drivers/fpga/dfl-afu-dma-region.c @@ -146,8 +146,7 @@ static int afu_dma_region_add(struct dfl_feature_platform_data *pdata, struct dfl_afu *afu = dfl_fpga_pdata_get_private(pdata); struct rb_node **new, *parent = NULL; - dev_dbg(&pdata->dev->dev, "add region (iova = %llx)\n", - (unsigned long long)region->iova); + dev_dbg(&pdata->dev->dev, "add region (iova = %llx)\n", region->iova); new = &afu->dma_regions.rb_node; @@ -187,8 +186,7 @@ static void afu_dma_region_remove(struct dfl_feature_platform_data *pdata, { struct dfl_afu *afu; - dev_dbg(&pdata->dev->dev, "del region (iova = %llx)\n", - (unsigned long long)region->iova); + dev_dbg(&pdata->dev->dev, "del region (iova = %llx)\n", region->iova); afu = dfl_fpga_pdata_get_private(pdata); rb_erase(®ion->node, &afu->dma_regions); @@ -210,7 +208,7 @@ void afu_dma_region_destroy(struct dfl_feature_platform_data *pdata) region = container_of(node, struct dfl_afu_dma_region, node); dev_dbg(&pdata->dev->dev, "del region (iova = %llx)\n", - (unsigned long long)region->iova); + region->iova); rb_erase(node, &afu->dma_regions); @@ -255,7 +253,7 @@ afu_dma_region_find(struct dfl_feature_platform_data *pdata, u64 iova, u64 size) if (dma_region_check_iova(region, iova, size)) { dev_dbg(dev, "find region (iova = %llx)\n", - (unsigned long long)region->iova); + region->iova); return region; } @@ -268,8 +266,8 @@ afu_dma_region_find(struct dfl_feature_platform_data *pdata, u64 iova, u64 size) break; } - dev_dbg(dev, "region with iova %llx and size %llx is not found\n", - (unsigned long long)iova, (unsigned long long)size); + dev_dbg(dev, "region with iova %llx and size %llx is not found\n", iova, + size); return NULL; } diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c index 51fdbe8a2f26..f81b44767c31 100644 --- a/drivers/fpga/dfl-afu-main.c +++ b/drivers/fpga/dfl-afu-main.c @@ -729,9 +729,7 @@ afu_ioctl_dma_map(struct dfl_feature_platform_data *pdata, void __user *arg) } dev_dbg(&pdata->dev->dev, "dma map: ua=%llx, len=%llx, iova=%llx\n", - (unsigned long long)map.user_addr, - (unsigned long long)map.length, - (unsigned long long)map.iova); + map.user_addr, map.length, map.iova); return 0; } diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index af0785783b52..7fb7a0aca1dc 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -150,7 +150,7 @@ static int fme_mgr_write_init(struct fpga_manager *mgr, priv->pr_error = fme_mgr_pr_error_handle(fme_pr); if (priv->pr_error) dev_dbg(dev, "previous PR error detected %llx\n", - (unsigned long long)priv->pr_error); + priv->pr_error); dev_dbg(dev, "set PR port ID\n"); @@ -242,8 +242,7 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr, dev_dbg(dev, "PR operation complete, checking status\n"); priv->pr_error = fme_mgr_pr_error_handle(fme_pr); if (priv->pr_error) { - dev_dbg(dev, "PR error detected %llx\n", - (unsigned long long)priv->pr_error); + dev_dbg(dev, "PR error detected %llx\n", priv->pr_error); return -EIO; }