linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH] gpio: mockup: use simple_read_from_buffer() in debugfs read callback
Date: Thu, 28 Mar 2019 18:41:50 +0530	[thread overview]
Message-ID: <c3ecb2d9-55eb-fc74-a08a-bbd5c5018cb8@codeaurora.org> (raw)
In-Reply-To: <20190328110043.13391-1-brgl@bgdev.pl>


On 3/28/2019 4:30 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Calling read() for a single byte read will return 2 currently. Use
> simple_read_from_buffer() which correctly handles all sizes.
>
> Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>   drivers/gpio/gpio-mockup.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 74ba8b1d71d8..859585dce5c9 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -219,12 +219,7 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
>   	val = gpio_mockup_get(gc, priv->offset);
>   	cnt = snprintf(buf, sizeof(buf), "%d\n", val);


why \n is inserted in the buf..

rv variable is unused now.

>   
> -	rv = copy_to_user(usr_buf, buf, cnt);
> -	if (rv)
> -		return rv;
> -
> -	*ppos += cnt;
> -	return cnt;
> +	return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);



Looks good to me.
Remove the unused variable.

Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

-Mukesh

>   }
>   
>   static ssize_t gpio_mockup_debugfs_write(struct file *file,

  reply	other threads:[~2019-03-28 13:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28 11:00 [PATCH] gpio: mockup: use simple_read_from_buffer() in debugfs read callback Bartosz Golaszewski
2019-03-28 13:11 ` Mukesh Ojha [this message]
2019-03-28 13:42   ` Bartosz Golaszewski

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=c3ecb2d9-55eb-fc74-a08a-bbd5c5018cb8@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@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 NNTP newsgroup(s).