summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2023-04-11 10:28:06 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-04-11 21:13:34 +0200
commit8a4adcf67a39b3f308bb8cf686e41c0e26aa12e8 (patch)
tree0a631c23cb7631b750447334608c1a47019e7c7c
parentf09673770e767f862bd992b612f14018d0ab3857 (diff)
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>
-rw-r--r--drivers/gpio/gpiolib.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 88dcf40aca90..04fb05df805b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -702,7 +702,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
struct lock_class_key *lock_key,
struct lock_class_key *request_key)
{
- struct fwnode_handle *fwnode = NULL;
struct gpio_device *gdev;
unsigned long flags;
unsigned int i;
@@ -710,12 +709,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
int base = 0;
int ret = 0;
- /* If the calling driver did not initialize firmware node, do it here */
- if (gc->fwnode)
- fwnode = gc->fwnode;
- else if (gc->parent)
- fwnode = dev_fwnode(gc->parent);
- gc->fwnode = fwnode;
+ /*
+ * If the calling driver did not initialize firmware node, do it here
+ * using the parent device, if any.
+ */
+ if (!gc->fwnode && gc->parent)
+ gc->fwnode = dev_fwnode(gc->parent);
/*
* First: allocate and populate the internal stat container, and