Linux Input/HID development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: linux-kernel@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v4 2/4] HID: hid-sensor-custom: Convert sprintf() family to sysfs_emit() family
Date: Sun, 24 Mar 2024 12:16:08 +0000	[thread overview]
Message-ID: <20240324121608.30b2217b@jic23-huawei> (raw)
In-Reply-To: <20240319054527.1581299-2-lizhijian@fujitsu.com>

On Tue, 19 Mar 2024 13:45:25 +0800
Li Zhijian <lizhijian@fujitsu.com> wrote:

> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
> 
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
> 
> sprintf() and scnprintf() will be converted as well if they have.
> 
> Generally, this patch is generated by
> make coccicheck M=<path/to/file> MODE=patch \
> COCCI=scripts/coccinelle/api/device_attr_show.cocci
> 
> No functional change intended
> 
> CC: Jiri Kosina <jikos@kernel.org>
> CC: Jonathan Cameron <jic23@kernel.org>
> CC: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> CC: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> CC: linux-input@vger.kernel.org
> CC: linux-iio@vger.kernel.org

As a general rule, don't have cc's of lists up here. It makes
a mess of the logs. Also once you have another tag drop CC of
same person (even if it's a different email address).

We don't want to fill the git log with useless information.

I think git is fine picking up CC's from below the --- so you
can add them there if it simplifies how you send your patch
sets out.


> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> V3:
>    rewrap the line as will be under 80 chars and add Reviewed-by # Jonathan
> This is a part of the work "Fix coccicheck device_attr_show warnings"[1]
> Split them per subsystem so that the maintainer can review it easily
> [1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/
> ---
>  drivers/hid/hid-sensor-custom.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
> index d85398721659..ac214777d7d9 100644
> --- a/drivers/hid/hid-sensor-custom.c
> +++ b/drivers/hid/hid-sensor-custom.c
> @@ -155,7 +155,7 @@ static ssize_t enable_sensor_show(struct device *dev,
>  {
>  	struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
>  
> -	return sprintf(buf, "%d\n", sensor_inst->enable);
> +	return sysfs_emit(buf, "%d\n", sensor_inst->enable);
>  }
>  
>  static int set_power_report_state(struct hid_sensor_custom *sensor_inst,
> @@ -372,14 +372,13 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
>  				     sizeof(struct hid_custom_usage_desc),
>  				     usage_id_cmp);
>  		if (usage_desc)
> -			return snprintf(buf, PAGE_SIZE, "%s\n",
> -					usage_desc->desc);
> +			return sysfs_emit(buf, "%s\n", usage_desc->desc);
>  		else
> -			return sprintf(buf, "not-specified\n");
> +			return sysfs_emit(buf, "not-specified\n");
>  	 } else
>  		return -EINVAL;
>  
> -	return sprintf(buf, "%d\n", value);
> +	return sysfs_emit(buf, "%d\n", value);
>  }
>  
>  static ssize_t store_value(struct device *dev, struct device_attribute *attr,


  reply	other threads:[~2024-03-24 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19  5:45 [PATCH v4 1/4] HID: hid-picolcd*: Convert sprintf() family to sysfs_emit() family Li Zhijian
2024-03-19  5:45 ` [PATCH v4 2/4] HID: hid-sensor-custom: " Li Zhijian
2024-03-24 12:16   ` Jonathan Cameron [this message]
2024-03-25  9:50     ` Zhijian Li (Fujitsu)
2024-03-19  5:45 ` [PATCH v4 3/4] HID: roccat: " Li Zhijian
2024-03-19  5:45 ` [PATCH v4 4/4] HID: corsair,lenovo: " Li Zhijian
2024-04-03 11:43 ` [PATCH v4 1/4] HID: hid-picolcd*: " Jiri Kosina

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=20240324121608.30b2217b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=srinivas.pandruvada@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox