Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Tomasz Duszynski <tomasz.duszynski@octakon.com>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH v1 1/1] iio: chemical: scd30_core: use sysfs_emit() to instead of scnprintf()
Date: Sat, 14 Jan 2023 16:17:48 +0000	[thread overview]
Message-ID: <20230114161748.1b316bb4@jic23-huawei> (raw)
In-Reply-To: <20230113141117.23353-1-andriy.shevchenko@linux.intel.com>

On Fri, 13 Jan 2023 16:11:17 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied

Thanks,

> ---
>  drivers/iio/chemical/scd30_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
> index 682fca39d14d..e0bb1dd5e790 100644
> --- a/drivers/iio/chemical/scd30_core.c
> +++ b/drivers/iio/chemical/scd30_core.c
> @@ -354,7 +354,7 @@ static ssize_t sampling_frequency_available_show(struct device *dev, struct devi
>  	ssize_t len = 0;
>  
>  	do {
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ", 1000000000 / i);
> +		len += sysfs_emit_at(buf, len, "0.%09u ", 1000000000 / i);
>  		/*
>  		 * Not all values fit PAGE_SIZE buffer hence print every 6th
>  		 * (each frequency differs by 6s in time domain from the
> @@ -380,7 +380,7 @@ static ssize_t calibration_auto_enable_show(struct device *dev, struct device_at
>  	ret = scd30_command_read(state, CMD_ASC, &val);
>  	mutex_unlock(&state->lock);
>  
> -	return ret ?: sprintf(buf, "%d\n", val);
> +	return ret ?: sysfs_emit(buf, "%d\n", val);
>  }
>  
>  static ssize_t calibration_auto_enable_store(struct device *dev, struct device_attribute *attr,
> @@ -414,7 +414,7 @@ static ssize_t calibration_forced_value_show(struct device *dev, struct device_a
>  	ret = scd30_command_read(state, CMD_FRC, &val);
>  	mutex_unlock(&state->lock);
>  
> -	return ret ?: sprintf(buf, "%d\n", val);
> +	return ret ?: sysfs_emit(buf, "%d\n", val);
>  }
>  
>  static ssize_t calibration_forced_value_store(struct device *dev, struct device_attribute *attr,


      reply	other threads:[~2023-01-14 16:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 14:11 [PATCH v1 1/1] iio: chemical: scd30_core: use sysfs_emit() to instead of scnprintf() Andy Shevchenko
2023-01-14 16:17 ` Jonathan Cameron [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=20230114161748.1b316bb4@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomasz.duszynski@octakon.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