Skip to content

Commit 8a4adcf

Browse files
Linus WalleijBartosz Golaszewski
authored andcommitted
gpio: gpiolib: Simplify gpiochip_add_data_with_key() fwnode
The code defaulting to the parents fwnode if no fwnode was assigned is unnecessarily convoluted, probably due to refactoring. Simplify it and make it more human-readable. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent f096737 commit 8a4adcf

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,20 +702,19 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
702702
struct lock_class_key *lock_key,
703703
struct lock_class_key *request_key)
704704
{
705-
struct fwnode_handle *fwnode = NULL;
706705
struct gpio_device *gdev;
707706
unsigned long flags;
708707
unsigned int i;
709708
u32 ngpios = 0;
710709
int base = 0;
711710
int ret = 0;
712711

713-
/* If the calling driver did not initialize firmware node, do it here */
714-
if (gc->fwnode)
715-
fwnode = gc->fwnode;
716-
else if (gc->parent)
717-
fwnode = dev_fwnode(gc->parent);
718-
gc->fwnode = fwnode;
712+
/*
713+
* If the calling driver did not initialize firmware node, do it here
714+
* using the parent device, if any.
715+
*/
716+
if (!gc->fwnode && gc->parent)
717+
gc->fwnode = dev_fwnode(gc->parent);
719718

720719
/*
721720
* First: allocate and populate the internal stat container, and

0 commit comments

Comments
 (0)