提交 0f41dabe 编写于 作者: B Bartosz Golaszewski

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: NBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
上级 06863620
......@@ -678,14 +678,13 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
/* Request each GPIO */
for (i = 0; i < handlereq.lines; i++) {
u32 offset = handlereq.lineoffsets[i];
struct gpio_desc *desc;
struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset);
if (offset >= gdev->ngpio) {
ret = -EINVAL;
if (IS_ERR(desc)) {
ret = PTR_ERR(desc);
goto out_free_descs;
}
desc = &gdev->descs[offset];
ret = gpiod_request(desc, lh->label);
if (ret)
goto out_free_descs;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册