gpiolib: acpi: Move non-critical code outside of critical section
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 11 Nov 2020 18:01:52 +0000 (20:01 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 16 Nov 2020 12:14:35 +0000 (14:14 +0200)
Mika noticed that some code is run under mutex when it doesn't require
the lock, like an error code assignment.

Move non-critical code outside of critical section.

Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/gpio/gpiolib-acpi.c

index a9254de964cc772079754c51cc6464075bd6915f..b00171d2aaf570254572840d7324b3f68738f19c 100644 (file)
@@ -1063,8 +1063,8 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
                                                         GPIO_ACTIVE_HIGH,
                                                         flags);
                        if (IS_ERR(desc)) {
-                               status = AE_ERROR;
                                mutex_unlock(&achip->conn_lock);
+                               status = AE_ERROR;
                                goto out;
                        }
 
@@ -1078,9 +1078,9 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 
                        conn = kzalloc(sizeof(*conn), GFP_KERNEL);
                        if (!conn) {
-                               status = AE_NO_MEMORY;
                                gpiochip_free_own_desc(desc);
                                mutex_unlock(&achip->conn_lock);
+                               status = AE_NO_MEMORY;
                                goto out;
                        }