From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:25:08
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 <redacted>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
---
drivers/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:25:29
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 <redacted>
---
drivers/pci/pcie/aer.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:25:47
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.
Modify the function dsm_label_utf16s_to_utf8s() to directly return the
number of bytes written into the buffer so that the strlen() used later
to calculate the length of the buffer can be removed as it would no
longer be needed.
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 <redacted>
---
drivers/pci/pci-label.c | 18 ++++++++++--------
drivers/pci/slot.c | 16 ++++++++--------
2 files changed, 18 insertions(+), 16 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:26:07
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 <redacted>
---
drivers/pci/msi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:26:25
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 <redacted>
---
drivers/pci/iov.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:26:43
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 <redacted>
---
drivers/pci/p2pdma.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:27:01
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 <redacted>
---
drivers/pci/pcie/aspm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:27:20
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 <redacted>
---
drivers/pci/switch/switchtec.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:27:38
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 <redacted>
---
drivers/pci/hotplug/rpadlpar_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:28:03
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 <redacted>
---
drivers/pci/hotplug/pci_hotplug_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:28:21
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 <redacted>
---
drivers/pci/hotplug/shpchp_sysfs.c | 38 +++++++++++++++++-------------
1 file changed, 21 insertions(+), 17 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:28:40
The value of the "resource_alignment" can be specified using a kernel
command-line argument (using the "pci=resource_alignment=") or through
the corresponding sysfs object under the /sys/bus/pci path.
Currently, when the value is set via the kernel command-line argument,
and then subsequently accessed through sysfs object, the value read back
will not be correct, as per:
# grep -oE 'pci=resource_alignment.+' /proc/cmdline
pci=resource_alignment=20@00:1f.2
# cat /sys/bus/pci/resource_alignment
20@00:1f.
This is also true when the value is set through the sysfs object, but
the trailing newline has not been included, as per:
# echo -n 20@00:1f.2 > /sys/bus/pci/resource_alignment
# cat /sys/bus/pci/resource_alignment
20@00:1f.
When the value set through the sysfs object includes the trailing
newline, then reading it back will work as intended, as per:
# echo 20@00:1f.2 > /sys/bus/pci/resource_alignment
# cat /sys/bus/pci/resource_alignment
20@00:1f.2
To fix this inconsistency, append a trailing newline in the show()
function and strip the trailing line in the store() function if one is
present.
Also, allow for the value previously set using either a command-line
argument or through the sysfs object to be cleared at run-time.
Fixes: e499081da1a2 ("PCI: Force trailing new line to resource_alignment_param in sysfs")
Signed-off-by: Krzysztof Wilczyński <redacted>
---
drivers/pci/pci.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:28:57
At the moment, when the value of the "devspec" sysfs object is read from
the user space there will be no newline present, and the utilities such
as the "cat" command won't display the result of the read correctly in
a shell, as the trailing newline is currently missing.
To fix this, append a newline character in the show() function.
Signed-off-by: Krzysztof Wilczyński <redacted>
---
drivers/pci/pci-sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:29:23
Only expose the value of the "driver_override" variable through the
corresponding sysfs object when a value is actually set.
Signed-off-by: Krzysztof Wilczyński <redacted>
---
drivers/pci/pci-sysfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Please disregard this "Reviewed-by" from Logan for this version, as I've
forgotten to remove it before sending v2 after pulling patches using b4.
Apologies.
Krzysztof
From: Joe Perches <joe@perches.com> Date: 2021-05-15 05:44:11
On Sat, 2021-05-15 at 05:24 +0000, Krzysztof Wilczyński wrote:
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.
Ideally, the additional newline check below this would use sysfs_emit_at
drivers/pci/pci.c- /*
drivers/pci/pci.c: * When set by the command line, resource_alignment_param will not
drivers/pci/pci.c- * have a trailing line feed, which is ugly. So conditionally add
drivers/pci/pci.c- * it here.
drivers/pci/pci.c- */
drivers/pci/pci.c- if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) {
drivers/pci/pci.c- buf[count - 1] = '\n';
drivers/pci/pci.c- buf[count++] = 0;
drivers/pci/pci.c- }
drivers/pci/pci.c-
drivers/pci/pci.c- return count;
From: Joe Perches <joe@perches.com> Date: 2021-05-15 05:47:17
On Sat, 2021-05-15 at 05:24 +0000, Krzysztof Wilczyński wrote:
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.
From: Krzysztof Wilczyński <hidden> Date: 2021-05-15 05:59:56
Hi Joe,
[...]
Ideally, the additional newline check below this would use sysfs_emit_at
drivers/pci/pci.c- /*
drivers/pci/pci.c: * When set by the command line, resource_alignment_param will not
drivers/pci/pci.c- * have a trailing line feed, which is ugly. So conditionally add
drivers/pci/pci.c- * it here.
drivers/pci/pci.c- */
drivers/pci/pci.c- if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) {
drivers/pci/pci.c- buf[count - 1] = '\n';
drivers/pci/pci.c- buf[count++] = 0;
drivers/pci/pci.c- }
drivers/pci/pci.c-
drivers/pci/pci.c- return count;
On 2021-05-14 11:24 p.m., Krzysztof Wilczyński wrote:
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 <redacted>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
I re-reviewed the whole series. It still looks good to me.
Very nice solution in patch 12 to the new line issue.
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Thanks,
Logan
From: Krzysztof Wilczyński <hidden> Date: 2021-05-17 17:45:08
Hi Logan,
quoted
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")
I re-reviewed the whole series. It still looks good to me.
Very nice solution in patch 12 to the new line issue.
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Thanks,
Thank you!
I will send v3 incorporating the style change as per Joe's suggestion
and carry-over your "Reviewed-by", if you don't mind, as it will be
a trivial change.
Krzysztof