Skip to content

Commit c5cf334

Browse files
author
Bartosz Golaszewski
committed
gpio: remove unnecessary checks from gpiod_to_chip()
We don't need to check the gdev pointer in struct gpio_desc - it's always assigned and never cleared. It's also pointless to check gdev->chip before we actually serialize access to it. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Acked-by: Andy Shevchenko <[email protected]>
1 parent 6c82e73 commit c5cf334

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpio/gpiolib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ EXPORT_SYMBOL_GPL(desc_to_gpio);
214214
*/
215215
struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
216216
{
217-
if (!desc || !desc->gdev)
217+
if (!desc)
218218
return NULL;
219219
return desc->gdev->chip;
220220
}
@@ -3505,7 +3505,7 @@ int gpiod_to_irq(const struct gpio_desc *desc)
35053505
* requires this function to not return zero on an invalid descriptor
35063506
* but rather a negative error number.
35073507
*/
3508-
if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip)
3508+
if (!desc || IS_ERR(desc))
35093509
return -EINVAL;
35103510

35113511
gc = desc->gdev->chip;

0 commit comments

Comments
 (0)