mirror of https://gitee.com/openkylin/linux.git
gpiolib: use gpiochip_get_desc() in lineevent_create()
Unduplicate the ngpio check by simply calling gpiochip_get_desc() and checking its return value. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
0f41dabe45
commit
45e2360480
|
@ -1009,8 +1009,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
|
||||||
lflags = eventreq.handleflags;
|
lflags = eventreq.handleflags;
|
||||||
eflags = eventreq.eventflags;
|
eflags = eventreq.eventflags;
|
||||||
|
|
||||||
if (offset >= gdev->ngpio)
|
desc = gpiochip_get_desc(gdev->chip, offset);
|
||||||
return -EINVAL;
|
if (IS_ERR(desc))
|
||||||
|
return PTR_ERR(desc);
|
||||||
|
|
||||||
/* Return an error if a unknown flag is set */
|
/* Return an error if a unknown flag is set */
|
||||||
if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
|
if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
|
||||||
|
@ -1048,7 +1049,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
desc = &gdev->descs[offset];
|
|
||||||
ret = gpiod_request(desc, le->label);
|
ret = gpiod_request(desc, le->label);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free_label;
|
goto out_free_label;
|
||||||
|
|
Loading…
Reference in New Issue