Skip to content

Commit 2b6bce8

Browse files
dtorBartosz Golaszewski
authored andcommitted
gpiolib: acpi: change acpi_find_gpio() to accept firmware node
In preparation of switching all ACPI-based GPIO lookups to go through acpi_find_gpio() let's change it to accept device node as its argument as we do not always have access to device structure. Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 07445ae commit 2b6bce8

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,18 +906,22 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
906906
return con_id == NULL;
907907
}
908908

909-
struct gpio_desc *acpi_find_gpio(struct device *dev,
909+
struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
910910
const char *con_id,
911911
unsigned int idx,
912912
enum gpiod_flags *dflags,
913913
unsigned long *lookupflags)
914914
{
915-
struct acpi_device *adev = ACPI_COMPANION(dev);
915+
struct acpi_device *adev;
916916
struct acpi_gpio_info info;
917917
struct gpio_desc *desc;
918918
char propname[32];
919919
int i;
920920

921+
adev = to_acpi_device_node(fwnode);
922+
if (!adev)
923+
return ERR_PTR(-ENODEV);
924+
921925
/* Try first from _DSD */
922926
for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
923927
if (con_id) {

drivers/gpio/gpiolib-acpi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
4848
int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
4949
struct acpi_gpio_info *info);
5050

51-
struct gpio_desc *acpi_find_gpio(struct device *dev,
51+
struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
5252
const char *con_id,
5353
unsigned int idx,
5454
enum gpiod_flags *dflags,
@@ -83,7 +83,7 @@ acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
8383
}
8484

8585
static inline struct gpio_desc *
86-
acpi_find_gpio(struct device *dev, const char *con_id,
86+
acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
8787
unsigned int idx, enum gpiod_flags *dflags,
8888
unsigned long *lookupflags)
8989
{

drivers/gpio/gpiolib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4133,7 +4133,8 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
41334133
con_id, idx, &lookupflags);
41344134
} else if (is_acpi_node(fwnode)) {
41354135
dev_dbg(dev, "using ACPI for GPIO lookup\n");
4136-
desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags);
4136+
desc = acpi_find_gpio(fwnode,
4137+
con_id, idx, &flags, &lookupflags);
41374138
}
41384139

41394140
/*

0 commit comments

Comments
 (0)