Platform-driver-x86 archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: yunshui <jiangyunshui@kylinos.cn>, linux-kernel@vger.kernel.org
Cc: platform-driver-x86@vger.kernel.org, hmh@hmh.eng.br,
	ilpo.jarvinen@linux.intel.com, Ai Chao <aichao@kylinos.cn>
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: change sprintf() to sysfs_emit()
Date: Mon, 22 Apr 2024 15:39:16 +0200	[thread overview]
Message-ID: <49263c2d-4fb8-49be-b74e-9f432e8a5994@redhat.com> (raw)
In-Reply-To: <20240417092055.1170586-1-jiangyunshui@kylinos.cn>

Hi,

On 4/17/24 11:20 AM, yunshui wrote:
> As Documentation/filesystems/sysfs.rst suggested,
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
> 
> Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
> ---
>  drivers/platform/x86/thinkpad_acpi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 82429e59999d..1ed27fc21a7d 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -817,7 +817,7 @@ static int __init setup_acpi_notify(struct ibm_struct *ibm)
>  	}
>  
>  	ibm->acpi->device->driver_data = ibm;
> -	sprintf(acpi_device_class(ibm->acpi->device), "%s/%s",
> +	sysfs_emit(acpi_device_class(ibm->acpi->device), "%s/%s",
>  		TPACPI_ACPI_EVENT_PREFIX,
>  		ibm->name);
> 

This is not a sysfs show() function.

 
> @@ -857,7 +857,7 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
>  		return -ENOMEM;
>  	}
>  
> -	sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name);
> +	sysfs_emit(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name);
>  	ibm->acpi->driver->ids = ibm->acpi->hid;
>  
>  	ibm->acpi->driver->ops.add = &tpacpi_device_add;

This also is not a sysfs show() function.

I've dropped these 2 parts of the patch while applying it:

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




> @@ -2679,7 +2679,7 @@ static ssize_t hotkey_bios_enabled_show(struct device *dev,
>  			   struct device_attribute *attr,
>  			   char *buf)
>  {
> -	return sprintf(buf, "0\n");
> +	return sysfs_emit(buf, "0\n");
>  }
>  
>  static DEVICE_ATTR_RO(hotkey_bios_enabled);
> @@ -9789,7 +9789,7 @@ static ssize_t tpacpi_battery_show(int what,
>  		battery = BAT_PRIMARY;
>  	if (tpacpi_battery_get(what, battery, &ret))
>  		return -ENODEV;
> -	return sprintf(buf, "%d\n", ret);
> +	return sysfs_emit(buf, "%d\n", ret);
>  }
>  
>  static ssize_t charge_control_start_threshold_show(struct device *device,


      reply	other threads:[~2024-04-22 13:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17  9:20 [PATCH] platform/x86: thinkpad_acpi: change sprintf() to sysfs_emit() yunshui
2024-04-22 13:39 ` 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=49263c2d-4fb8-49be-b74e-9f432e8a5994@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=aichao@kylinos.cn \
    --cc=hmh@hmh.eng.br \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jiangyunshui@kylinos.cn \
    --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).