From: "Krzysztof Wilczyński" <kw@linux.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Logan Gunthorpe <logang@deltatee.com>,
Joe Perches <joe@perches.com>,
"Oliver O'Halloran" <oohall@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Tyrel Datwyler <tyreld@linux.ibm.com>,
Russell Currey <ruscur@russell.cc>,
Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Vidya Sagar <vidyas@nvidia.com>,
Xiongfeng Wang <wangxiongfeng2@huawei.com>,
linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 08/14] PCI: switchtec: Use sysfs_emit() and sysfs_emit_at() in "show" functions
Date: Sat, 15 May 2021 05:24:28 +0000 [thread overview]
Message-ID: <20210515052434.1413236-8-kw@linux.com> (raw)
In-Reply-To: <20210515052434.1413236-1-kw@linux.com>
The sysfs_emit() and sysfs_emit_at() functions were introduced to make
it less ambiguous which function is preferred when writing to the output
buffer in a device attribute's "show" callback [1].
Convert the PCI sysfs object "show" functions from sprintf(), snprintf()
and scnprintf() to sysfs_emit() and sysfs_emit_at() accordingly, as the
latter is aware of the PAGE_SIZE buffer and correctly returns the number
of bytes written into the buffer.
No functional change intended.
[1] Documentation/filesystems/sysfs.rst
Related to:
commit ad025f8e46f3 ("PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions")
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
drivers/pci/switch/switchtec.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index ba52459928f7..0b301f8be9ed 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -280,7 +280,7 @@ static ssize_t device_version_show(struct device *dev,
ver = ioread32(&stdev->mmio_sys_info->device_version);
- return sprintf(buf, "%x\n", ver);
+ return sysfs_emit(buf, "%x\n", ver);
}
static DEVICE_ATTR_RO(device_version);
@@ -292,7 +292,7 @@ static ssize_t fw_version_show(struct device *dev,
ver = ioread32(&stdev->mmio_sys_info->firmware_version);
- return sprintf(buf, "%08x\n", ver);
+ return sysfs_emit(buf, "%08x\n", ver);
}
static DEVICE_ATTR_RO(fw_version);
@@ -344,7 +344,7 @@ static ssize_t component_vendor_show(struct device *dev,
/* component_vendor field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "none\n");
+ return sysfs_emit(buf, "none\n");
return io_string_show(buf, &si->gen3.component_vendor,
sizeof(si->gen3.component_vendor));
@@ -359,9 +359,9 @@ static ssize_t component_id_show(struct device *dev,
/* component_id field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "none\n");
+ return sysfs_emit(buf, "none\n");
- return sprintf(buf, "PM%04X\n", id);
+ return sysfs_emit(buf, "PM%04X\n", id);
}
static DEVICE_ATTR_RO(component_id);
@@ -373,9 +373,9 @@ static ssize_t component_revision_show(struct device *dev,
/* component_revision field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "255\n");
+ return sysfs_emit(buf, "255\n");
- return sprintf(buf, "%d\n", rev);
+ return sysfs_emit(buf, "%d\n", rev);
}
static DEVICE_ATTR_RO(component_revision);
@@ -384,7 +384,7 @@ static ssize_t partition_show(struct device *dev,
{
struct switchtec_dev *stdev = to_stdev(dev);
- return sprintf(buf, "%d\n", stdev->partition);
+ return sysfs_emit(buf, "%d\n", stdev->partition);
}
static DEVICE_ATTR_RO(partition);
@@ -393,7 +393,7 @@ static ssize_t partition_count_show(struct device *dev,
{
struct switchtec_dev *stdev = to_stdev(dev);
- return sprintf(buf, "%d\n", stdev->partition_count);
+ return sysfs_emit(buf, "%d\n", stdev->partition_count);
}
static DEVICE_ATTR_RO(partition_count);
--
2.31.1
WARNING: multiple messages have this Message-ID (diff)
From: "Krzysztof Wilczyński" <kw@linux.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Tyrel Datwyler <tyreld@linux.ibm.com>,
linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Vidya Sagar <vidyas@nvidia.com>,
Oliver O'Halloran <oohall@gmail.com>,
Joe Perches <joe@perches.com>, Paul Mackerras <paulus@samba.org>,
Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Logan Gunthorpe <logang@deltatee.com>,
Xiongfeng Wang <wangxiongfeng2@huawei.com>
Subject: [PATCH v2 08/14] PCI: switchtec: Use sysfs_emit() and sysfs_emit_at() in "show" functions
Date: Sat, 15 May 2021 05:24:28 +0000 [thread overview]
Message-ID: <20210515052434.1413236-8-kw@linux.com> (raw)
In-Reply-To: <20210515052434.1413236-1-kw@linux.com>
The sysfs_emit() and sysfs_emit_at() functions were introduced to make
it less ambiguous which function is preferred when writing to the output
buffer in a device attribute's "show" callback [1].
Convert the PCI sysfs object "show" functions from sprintf(), snprintf()
and scnprintf() to sysfs_emit() and sysfs_emit_at() accordingly, as the
latter is aware of the PAGE_SIZE buffer and correctly returns the number
of bytes written into the buffer.
No functional change intended.
[1] Documentation/filesystems/sysfs.rst
Related to:
commit ad025f8e46f3 ("PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions")
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
drivers/pci/switch/switchtec.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index ba52459928f7..0b301f8be9ed 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -280,7 +280,7 @@ static ssize_t device_version_show(struct device *dev,
ver = ioread32(&stdev->mmio_sys_info->device_version);
- return sprintf(buf, "%x\n", ver);
+ return sysfs_emit(buf, "%x\n", ver);
}
static DEVICE_ATTR_RO(device_version);
@@ -292,7 +292,7 @@ static ssize_t fw_version_show(struct device *dev,
ver = ioread32(&stdev->mmio_sys_info->firmware_version);
- return sprintf(buf, "%08x\n", ver);
+ return sysfs_emit(buf, "%08x\n", ver);
}
static DEVICE_ATTR_RO(fw_version);
@@ -344,7 +344,7 @@ static ssize_t component_vendor_show(struct device *dev,
/* component_vendor field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "none\n");
+ return sysfs_emit(buf, "none\n");
return io_string_show(buf, &si->gen3.component_vendor,
sizeof(si->gen3.component_vendor));
@@ -359,9 +359,9 @@ static ssize_t component_id_show(struct device *dev,
/* component_id field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "none\n");
+ return sysfs_emit(buf, "none\n");
- return sprintf(buf, "PM%04X\n", id);
+ return sysfs_emit(buf, "PM%04X\n", id);
}
static DEVICE_ATTR_RO(component_id);
@@ -373,9 +373,9 @@ static ssize_t component_revision_show(struct device *dev,
/* component_revision field not supported after gen3 */
if (stdev->gen != SWITCHTEC_GEN3)
- return sprintf(buf, "255\n");
+ return sysfs_emit(buf, "255\n");
- return sprintf(buf, "%d\n", rev);
+ return sysfs_emit(buf, "%d\n", rev);
}
static DEVICE_ATTR_RO(component_revision);
@@ -384,7 +384,7 @@ static ssize_t partition_show(struct device *dev,
{
struct switchtec_dev *stdev = to_stdev(dev);
- return sprintf(buf, "%d\n", stdev->partition);
+ return sysfs_emit(buf, "%d\n", stdev->partition);
}
static DEVICE_ATTR_RO(partition);
@@ -393,7 +393,7 @@ static ssize_t partition_count_show(struct device *dev,
{
struct switchtec_dev *stdev = to_stdev(dev);
- return sprintf(buf, "%d\n", stdev->partition_count);
+ return sysfs_emit(buf, "%d\n", stdev->partition_count);
}
static DEVICE_ATTR_RO(partition_count);
--
2.31.1
next prev parent reply other threads:[~2021-05-15 5:24 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 5:24 [PATCH v2 01/14] PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 02/14] PCI/AER: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 03/14] PCI: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 04/14] PCI/MSI: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:46 ` Joe Perches
2021-05-15 5:46 ` Joe Perches
2021-05-15 6:01 ` Krzysztof Wilczyński
2021-05-15 6:01 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 05/14] PCI/IOV: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 06/14] PCI/P2PDMA: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 07/14] PCI/ASPM: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński [this message]
2021-05-15 5:24 ` [PATCH v2 08/14] PCI: switchtec: " Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 09/14] PCI: rpadlpar: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 10/14] PCI: hotplug: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 11/14] PCI: shpchp: " Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 12/14] PCI: Fix trailing newline handling of resource_alignment_param Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 13/14] PCI/sysfs: Add missing trailing newline to devspec_show() Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:24 ` [PATCH v2 14/14] PCI/sysfs: Only show value when driver_override is not NULL Krzysztof Wilczyński
2021-05-15 5:24 ` Krzysztof Wilczyński
2021-05-15 5:36 ` [PATCH v2 01/14] PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions Krzysztof Wilczyński
2021-05-15 5:36 ` Krzysztof Wilczyński
2021-05-15 5:43 ` Joe Perches
2021-05-15 5:43 ` Joe Perches
2021-05-15 5:59 ` Krzysztof Wilczyński
2021-05-15 5:59 ` Krzysztof Wilczyński
2021-05-17 15:48 ` Logan Gunthorpe
2021-05-17 15:48 ` Logan Gunthorpe
2021-05-17 17:44 ` Krzysztof Wilczyński
2021-05-17 17:44 ` Krzysztof Wilczyński
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210515052434.1413236-8-kw@linux.com \
--to=kw@linux.com \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=joe@perches.com \
--cc=kurt.schwemmer@microsemi.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=logang@deltatee.com \
--cc=mpe@ellerman.id.au \
--cc=oohall@gmail.com \
--cc=paulus@samba.org \
--cc=ruscur@russell.cc \
--cc=tyreld@linux.ibm.com \
--cc=vidyas@nvidia.com \
--cc=wangxiongfeng2@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.