From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: chen zhang <chenzhang@kylinos.cn>
Cc: Hans de Goede <hdegoede@redhat.com>,
cascardo@holoscopio.com, platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
chenzhang_0901@163.com
Subject: Re: [PATCH v2] platform/x86: classmate-laptop: use sysfs_emit() instead of sprintf()
Date: Wed, 23 Oct 2024 15:39:59 +0300 (EEST) [thread overview]
Message-ID: <8aad63f7-9d38-034f-3857-02aabffa4738@linux.intel.com> (raw)
In-Reply-To: <20241023014201.16359-1-chenzhang@kylinos.cn>
On Wed, 23 Oct 2024, chen zhang 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: chen zhang <chenzhang@kylinos.cn>
> ---
> v2: add #include <linux/sysfs.h>
> ---
> drivers/platform/x86/classmate-laptop.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
> index cb6fce655e35..6b1b8e444e24 100644
> --- a/drivers/platform/x86/classmate-laptop.c
> +++ b/drivers/platform/x86/classmate-laptop.c
> @@ -12,6 +12,7 @@
> #include <linux/backlight.h>
> #include <linux/input.h>
> #include <linux/rfkill.h>
> +#include <linux/sysfs.h>
>
> struct cmpc_accel {
> int sensitivity;
> @@ -208,7 +209,7 @@ static ssize_t cmpc_accel_sensitivity_show_v4(struct device *dev,
> inputdev = dev_get_drvdata(&acpi->dev);
> accel = dev_get_drvdata(&inputdev->dev);
>
> - return sprintf(buf, "%d\n", accel->sensitivity);
> + return sysfs_emit(buf, "%d\n", accel->sensitivity);
> }
>
> static ssize_t cmpc_accel_sensitivity_store_v4(struct device *dev,
> @@ -257,7 +258,7 @@ static ssize_t cmpc_accel_g_select_show_v4(struct device *dev,
> inputdev = dev_get_drvdata(&acpi->dev);
> accel = dev_get_drvdata(&inputdev->dev);
>
> - return sprintf(buf, "%d\n", accel->g_select);
> + return sysfs_emit(buf, "%d\n", accel->g_select);
> }
>
> static ssize_t cmpc_accel_g_select_store_v4(struct device *dev,
> @@ -550,7 +551,7 @@ static ssize_t cmpc_accel_sensitivity_show(struct device *dev,
> inputdev = dev_get_drvdata(&acpi->dev);
> accel = dev_get_drvdata(&inputdev->dev);
>
> - return sprintf(buf, "%d\n", accel->sensitivity);
> + return sysfs_emit(buf, "%d\n", accel->sensitivity);
> }
>
> static ssize_t cmpc_accel_sensitivity_store(struct device *dev,
>
Hi,
Thank you for your patch, however, a similar patch (from somebody else)
has been already applied so I dropped this one.
--
i.
prev parent reply other threads:[~2024-10-23 12:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 1:42 [PATCH v2] platform/x86: classmate-laptop: use sysfs_emit() instead of sprintf() chen zhang
2024-10-23 12:39 ` Ilpo Järvinen [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=8aad63f7-9d38-034f-3857-02aabffa4738@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=cascardo@holoscopio.com \
--cc=chenzhang@kylinos.cn \
--cc=chenzhang_0901@163.com \
--cc=hdegoede@redhat.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