gpiolib: acpi: Move ACPI device NULL check to acpi_can_fallback_to_crs()
authorLaura Nao <laura.nao@collabora.com>
Mon, 13 May 2024 09:56:10 +0000 (11:56 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 21 May 2024 15:33:44 +0000 (18:33 +0300)
Following the relocation of the function call outside of
__acpi_find_gpio(), move the ACPI device NULL check to
acpi_can_fallback_to_crs().

Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: kernelci.org bot <bot@kernelci.org>
Closes: https://lore.kernel.org/all/20240426154208.81894-1-laura.nao@collabora.com/
Fixes: 49c02f6e901c ("gpiolib: acpi: Move acpi_can_fallback_to_crs() out of __acpi_find_gpio()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/gpio/gpiolib-acpi.c

index 553a5f94c00a8c6f3a11cf75311176af2a25c686..8fb59864b58f05e932743bb3113c24d204da2659 100644 (file)
@@ -938,6 +938,10 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
 static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
                                     const char *con_id)
 {
+       /* If there is no ACPI device, there is no _CRS to fall back to */
+       if (!adev)
+               return false;
+
        /* Never allow fallback if the device has properties */
        if (acpi_dev_has_props(adev) || adev->driver_gpios)
                return false;
@@ -978,10 +982,10 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int
        }
 
        /* Then from plain _CRS GPIOs */
-       if (!adev || !can_fallback)
-               return ERR_PTR(-ENOENT);
+       if (can_fallback)
+               return acpi_get_gpiod_by_index(adev, NULL, idx, info);
 
-       return acpi_get_gpiod_by_index(adev, NULL, idx, info);
+       return ERR_PTR(-ENOENT);
 }
 
 struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,