diff mbox series

[v7,11/18] gpiolib: acpi: Move non-critical code outside of critical section

Message ID 20201111222008.39993-12-andriy.shevchenko@linux.intel.com
State New
Headers show
Series gpiolib: acpi: pin configuration fixes | expand

Commit Message

Andy Shevchenko Nov. 11, 2020, 10:20 p.m. UTC
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>
---
 drivers/gpio/gpiolib-acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mika Westerberg Nov. 12, 2020, 8:17 a.m. UTC | #1
On Thu, Nov 12, 2020 at 12:20:01AM +0200, Andy Shevchenko wrote:
> 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>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index a9254de964cc..b00171d2aaf5 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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;
 			}