summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2019-03-28 11:38:06 +0100
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2019-03-28 18:04:53 +0100
commitce9fb53c72834646f26ecb2213e40e6876048f87 (patch)
tree495c2e6fcc3c0f681257936101b19479f2ab91d0
parent2583303debb7acc77295b77901916d08a4c743c2 (diff)
gpio: mockup: use simple_read_from_buffer() in debugfs read callback
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") Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
-rw-r--r--drivers/gpio/gpio-mockup.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 74ba8b1d71d8..b6a4efce7c92 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -204,10 +204,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
struct gpio_mockup_chip *chip;
struct seq_file *sfile;
struct gpio_chip *gc;
- int val, rv, cnt;
+ int val, cnt;
char buf[3];
-
if (*ppos != 0)
return 0;
@@ -219,12 +218,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);
- 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);
}
static ssize_t gpio_mockup_debugfs_write(struct file *file,