From: Guenter Roeck <linux@roeck-us.net>
To: Jay Fang <f.fangjian@huawei.com>
Cc: linux-hwmon@vger.kernel.org, tangzihao1@hisilicon.com,
huangdaode@huawei.com
Subject: Re: [PATCH V2] hwmon: (ina2xx) Convert sysfs sprintf/snprintf family to sysfs_emit
Date: Thu, 18 Mar 2021 12:10:47 -0700 [thread overview]
Message-ID: <20210318191047.GA214727@roeck-us.net> (raw)
In-Reply-To: <1615892457-35501-1-git-send-email-f.fangjian@huawei.com>
On Tue, Mar 16, 2021 at 07:00:57PM +0800, Jay Fang wrote:
> From: Zihao Tang <tangzihao1@hisilicon.com>
>
> Fix the following coccicheck warning:
>
> drivers/hwmon/ina2xx.c:313:8-16: WARNING: use scnprintf or sprintf
> drivers/hwmon/ina2xx.c:453:8-16: WARNING: use scnprintf or sprintf
> drivers/hwmon/ina2xx.c:484:8-16: WARNING: use scnprintf or sprintf
> drivers/hwmon/ina2xx.c:540:8-16: WARNING: use scnprintf or sprintf
>
> Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com>
> Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/ina2xx.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
> index ca97f9e..8acb2db 100644
> --- a/drivers/hwmon/ina2xx.c
> +++ b/drivers/hwmon/ina2xx.c
> @@ -310,8 +310,7 @@ static ssize_t ina2xx_value_show(struct device *dev,
> if (err < 0)
> return err;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> - ina2xx_get_value(data, attr->index, regval));
> + return sysfs_emit(buf, "%d\n", ina2xx_get_value(data, attr->index, regval));
> }
>
> static int ina226_reg_to_alert(struct ina2xx_data *data, u8 bit, u16 regval)
> @@ -450,7 +449,7 @@ static ssize_t ina226_alarm_show(struct device *dev,
>
> alarm = (regval & BIT(attr->index)) &&
> (regval & INA226_ALERT_FUNCTION_FLAG);
> - return snprintf(buf, PAGE_SIZE, "%d\n", alarm);
> + return sysfs_emit(buf, "%d\n", alarm);
> }
>
> /*
> @@ -481,7 +480,7 @@ static ssize_t ina2xx_shunt_show(struct device *dev,
> {
> struct ina2xx_data *data = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt);
> + return sysfs_emit(buf, "%li\n", data->rshunt);
> }
>
> static ssize_t ina2xx_shunt_store(struct device *dev,
> @@ -537,7 +536,7 @@ static ssize_t ina226_interval_show(struct device *dev,
> if (status)
> return status;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", ina226_reg_to_interval(regval));
> + return sysfs_emit(buf, "%d\n", ina226_reg_to_interval(regval));
> }
>
> /* shunt voltage */
prev parent reply other threads:[~2021-03-18 19:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 11:00 [PATCH V2] hwmon: (ina2xx) Convert sysfs sprintf/snprintf family to sysfs_emit Jay Fang
2021-03-18 19:10 ` Guenter Roeck [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=20210318191047.GA214727@roeck-us.net \
--to=linux@roeck-us.net \
--cc=f.fangjian@huawei.com \
--cc=huangdaode@huawei.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=tangzihao1@hisilicon.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