gpiolib: use gpiochip_get_desc() in linehandle_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:
@ -678,14 +678,13 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
|
|||||||
/* Request each GPIO */
|
/* Request each GPIO */
|
||||||
for (i = 0; i < handlereq.lines; i++) {
|
for (i = 0; i < handlereq.lines; i++) {
|
||||||
u32 offset = handlereq.lineoffsets[i];
|
u32 offset = handlereq.lineoffsets[i];
|
||||||
struct gpio_desc *desc;
|
struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset);
|
||||||
|
|
||||||
if (offset >= gdev->ngpio) {
|
if (IS_ERR(desc)) {
|
||||||
ret = -EINVAL;
|
ret = PTR_ERR(desc);
|
||||||
goto out_free_descs;
|
goto out_free_descs;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc = &gdev->descs[offset];
|
|
||||||
ret = gpiod_request(desc, lh->label);
|
ret = gpiod_request(desc, lh->label);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free_descs;
|
goto out_free_descs;
|
||||||
|
Reference in New Issue
Block a user