From: Hans de Goede <hdegoede@redhat.com>
To: Ai Chao <aichao@kylinos.cn>,
justin.ernst@hpe.com, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] platform/x86: uv_sysfs: use sysfs_emit() instead of sprintf()
Date: Mon, 25 Mar 2024 15:42:55 +0100 [thread overview]
Message-ID: <61bc04d2-1a0f-4a8c-9ec7-88bcc0bde169@redhat.com> (raw)
In-Reply-To: <20240319070038.309683-1-aichao@kylinos.cn>
Hi,
On 3/19/24 8:00 AM, Ai Chao wrote:
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/uv_sysfs.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c
> index 38d1b692d3c0..3f6d52dea5c9 100644
> --- a/drivers/platform/x86/uv_sysfs.c
> +++ b/drivers/platform/x86/uv_sysfs.c
> @@ -129,22 +129,22 @@ static ssize_t hub_location_show(struct uv_bios_hub_info *hub_info, char *buf)
>
> static ssize_t hub_partition_show(struct uv_bios_hub_info *hub_info, char *buf)
> {
> - return sprintf(buf, "%d\n", hub_info->f.fields.this_part);
> + return sysfs_emit(buf, "%d\n", hub_info->f.fields.this_part);
> }
>
> static ssize_t hub_shared_show(struct uv_bios_hub_info *hub_info, char *buf)
> {
> - return sprintf(buf, "%d\n", hub_info->f.fields.is_shared);
> + return sysfs_emit(buf, "%d\n", hub_info->f.fields.is_shared);
> }
> static ssize_t hub_nasid_show(struct uv_bios_hub_info *hub_info, char *buf)
> {
> int cnode = get_obj_to_cnode(hub_info->id);
>
> - return sprintf(buf, "%d\n", ordinal_to_nasid(cnode));
> + return sysfs_emit(buf, "%d\n", ordinal_to_nasid(cnode));
> }
> static ssize_t hub_cnode_show(struct uv_bios_hub_info *hub_info, char *buf)
> {
> - return sprintf(buf, "%d\n", get_obj_to_cnode(hub_info->id));
> + return sysfs_emit(buf, "%d\n", get_obj_to_cnode(hub_info->id));
> }
>
> struct hub_sysfs_entry {
> @@ -304,12 +304,12 @@ struct uv_port {
>
> static ssize_t uv_port_conn_hub_show(struct uv_bios_port_info *port, char *buf)
> {
> - return sprintf(buf, "%d\n", port->conn_id);
> + return sysfs_emit(buf, "%d\n", port->conn_id);
> }
>
> static ssize_t uv_port_conn_port_show(struct uv_bios_port_info *port, char *buf)
> {
> - return sprintf(buf, "%d\n", port->conn_port);
> + return sysfs_emit(buf, "%d\n", port->conn_port);
> }
>
> struct uv_port_sysfs_entry {
> @@ -470,7 +470,7 @@ static ssize_t uv_pci_location_show(struct uv_pci_top_obj *top_obj, char *buf)
>
> static ssize_t uv_pci_iio_stack_show(struct uv_pci_top_obj *top_obj, char *buf)
> {
> - return sprintf(buf, "%d\n", top_obj->iio_stack);
> + return sysfs_emit(buf, "%d\n", top_obj->iio_stack);
> }
>
> static ssize_t uv_pci_ppb_addr_show(struct uv_pci_top_obj *top_obj, char *buf)
> @@ -480,7 +480,7 @@ static ssize_t uv_pci_ppb_addr_show(struct uv_pci_top_obj *top_obj, char *buf)
>
> static ssize_t uv_pci_slot_show(struct uv_pci_top_obj *top_obj, char *buf)
> {
> - return sprintf(buf, "%d\n", top_obj->slot);
> + return sysfs_emit(buf, "%d\n", top_obj->slot);
> }
>
> struct uv_pci_top_sysfs_entry {
> @@ -725,13 +725,13 @@ static void pci_topology_exit(void)
> static ssize_t partition_id_show(struct kobject *kobj,
> struct kobj_attribute *attr, char *buf)
> {
> - return sprintf(buf, "%ld\n", sn_partition_id);
> + return sysfs_emit(buf, "%ld\n", sn_partition_id);
> }
>
> static ssize_t coherence_id_show(struct kobject *kobj,
> struct kobj_attribute *attr, char *buf)
> {
> - return sprintf(buf, "%ld\n", sn_coherency_id);
> + return sysfs_emit(buf, "%ld\n", sn_coherency_id);
> }
>
> static ssize_t uv_type_show(struct kobject *kobj,
prev parent reply other threads:[~2024-03-25 14:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-19 7:00 [PATCH v1] platform/x86: uv_sysfs: use sysfs_emit() instead of sprintf() Ai Chao
2024-03-25 14:42 ` Hans de Goede [this message]
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=61bc04d2-1a0f-4a8c-9ec7-88bcc0bde169@redhat.com \
--to=hdegoede@redhat.com \
--cc=aichao@kylinos.cn \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=justin.ernst@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).