Commit 2a2cabd8 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpiolib: use gpiochip_get_desc() in gpio_ioctl()

Unduplicate the offset check by simply calling gpiochip_get_desc() and
checking its return value.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 45e23604
...@@ -1175,10 +1175,11 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -1175,10 +1175,11 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) if (copy_from_user(&lineinfo, ip, sizeof(lineinfo)))
return -EFAULT; return -EFAULT;
if (lineinfo.line_offset >= gdev->ngpio)
return -EINVAL;
desc = &gdev->descs[lineinfo.line_offset]; desc = gpiochip_get_desc(chip, lineinfo.line_offset);
if (IS_ERR(desc))
return PTR_ERR(desc);
if (desc->name) { if (desc->name) {
strncpy(lineinfo.name, desc->name, strncpy(lineinfo.name, desc->name,
sizeof(lineinfo.name)); sizeof(lineinfo.name));
......
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