Commit 6c82e737 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpio: reduce the functionality of validate_desc()

Checking desc->gdev->chip for NULL without holding it in place with some
serializing mechanism is pointless. Remove this check. Also don't check
desc->gdev for NULL as it can never happen. We'll be protecting
gdev->chip with SRCU soon but we will provide a dedicated, automatic
class for that.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 7fe595b3
...@@ -2257,19 +2257,12 @@ static int validate_desc(const struct gpio_desc *desc, const char *func) ...@@ -2257,19 +2257,12 @@ static int validate_desc(const struct gpio_desc *desc, const char *func)
{ {
if (!desc) if (!desc)
return 0; return 0;
if (IS_ERR(desc)) { if (IS_ERR(desc)) {
pr_warn("%s: invalid GPIO (errorpointer)\n", func); pr_warn("%s: invalid GPIO (errorpointer)\n", func);
return PTR_ERR(desc); return PTR_ERR(desc);
} }
if (!desc->gdev) {
pr_warn("%s: invalid GPIO (no device)\n", func);
return -EINVAL;
}
if (!desc->gdev->chip) {
dev_warn(&desc->gdev->dev,
"%s: backing chip is gone\n", func);
return 0;
}
return 1; return 1;
} }
...@@ -2345,12 +2338,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc) ...@@ -2345,12 +2338,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
void gpiod_free(struct gpio_desc *desc) void gpiod_free(struct gpio_desc *desc)
{ {
/* VALIDATE_DESC_VOID(desc);
* We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip
* may already be NULL but we still want to put the references.
*/
if (!desc)
return;
if (!gpiod_free_commit(desc)) if (!gpiod_free_commit(desc))
WARN_ON(1); WARN_ON(1);
......
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