diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2020-03-15 17:34:34 +0100 |
---|---|---|
committer | Bartosz Golaszewski <bgolaszewski@baylibre.com> | 2020-03-25 09:50:46 +0100 |
commit | ee203bbd63c0ae75c7672f30ae09f74abfcf6f5c (patch) | |
tree | eee819127e918b8a57e6b5677037e5a005bd08a0 /drivers/gpio | |
parent | 55f17e2ae916e4443e5f0acf067a3b6e9180f1cd (diff) | |
download | lwn-ee203bbd63c0ae75c7672f30ae09f74abfcf6f5c.tar.gz lwn-ee203bbd63c0ae75c7672f30ae09f74abfcf6f5c.zip |
gpiolib: gpio_name_to_desc: factor out !name check
Since name == NULL can't ever match, move the check out of
IRQ-disabled region.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 00890f38f95f..c7ee224bcb86 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -301,6 +301,9 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name) struct gpio_device *gdev; unsigned long flags; + if (!name) + return NULL; + spin_lock_irqsave(&gpio_lock, flags); list_for_each_entry(gdev, &gpio_devices, list) { @@ -309,7 +312,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name) for (i = 0; i != gdev->ngpio; ++i) { struct gpio_desc *desc = &gdev->descs[i]; - if (!desc->name || !name) + if (!desc->name) continue; if (!strcmp(desc->name, name)) { |