Skip to content

Commit af3b462

Browse files
committed
gpiolib: acpi: Move ACPI device NULL check to acpi_get_driver_gpio_data()
It's logical to check ACPI device for NULL inside acpi_get_driver_gpio_data() instead of requiring that in each caller. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 5062e4c commit af3b462

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

drivers/gpio/gpiolib-acpi.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
645645
{
646646
const struct acpi_gpio_mapping *gm;
647647

648-
if (!adev->driver_gpios)
648+
if (!adev || !adev->driver_gpios)
649649
return false;
650650

651651
for (gm = adev->driver_gpios; gm->name; gm++)
@@ -839,13 +839,10 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
839839
ret = __acpi_node_get_property_reference(fwnode, propname, index, 3,
840840
&args);
841841
if (ret) {
842-
struct acpi_device *adev = to_acpi_device_node(fwnode);
842+
struct acpi_device *adev;
843843

844-
if (!adev)
845-
return ret;
846-
847-
if (!acpi_get_driver_gpio_data(adev, propname, index, &args,
848-
&quirks))
844+
adev = to_acpi_device_node(fwnode);
845+
if (!acpi_get_driver_gpio_data(adev, propname, index, &args, &quirks))
849846
return ret;
850847
}
851848
/*

0 commit comments

Comments
 (0)