Commit ce9fb53c authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

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: 2a9e2740 ("gpio: mockup: rework debugfs interface")
Reviewed-by: default avatarMukesh Ojha <mojha@codeaurora.org>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 2583303d
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment