Skip to content

Commit 8122c7c

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpio: acpi: Make acpi_gpio_count() take firmware node as a parameter
Make acpi_gpio_count() take firmware node as a parameter in order to be aligned with other functions and decouple from unused device pointer. The latter helps to create a common fwnode_gpio_count() in the future. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent adcad53 commit 8122c7c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,17 +1402,17 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data)
14021402
}
14031403

14041404
/**
1405-
* acpi_gpio_count - count the GPIOs associated with a device / function
1406-
* @dev: GPIO consumer, can be %NULL for system-global GPIOs
1405+
* acpi_gpio_count - count the GPIOs associated with a firmware node / function
1406+
* @fwnode: firmware node of the GPIO consumer
14071407
* @con_id: function within the GPIO consumer
14081408
*
14091409
* Return:
1410-
* The number of GPIOs associated with a device / function or %-ENOENT,
1410+
* The number of GPIOs associated with a firmware node / function or %-ENOENT,
14111411
* if no GPIO has been assigned to the requested function.
14121412
*/
1413-
int acpi_gpio_count(struct device *dev, const char *con_id)
1413+
int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
14141414
{
1415-
struct acpi_device *adev = ACPI_COMPANION(dev);
1415+
struct acpi_device *adev = to_acpi_device_node(fwnode);
14161416
const union acpi_object *obj;
14171417
const struct acpi_gpio_mapping *gm;
14181418
int count = -ENOENT;
@@ -1429,8 +1429,7 @@ int acpi_gpio_count(struct device *dev, const char *con_id)
14291429
snprintf(propname, sizeof(propname), "%s",
14301430
gpio_suffixes[i]);
14311431

1432-
ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY,
1433-
&obj);
1432+
ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, &obj);
14341433
if (ret == 0) {
14351434
if (obj->type == ACPI_TYPE_LOCAL_REFERENCE)
14361435
count = 1;

drivers/gpio/gpiolib-acpi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
3333
enum gpiod_flags *dflags,
3434
unsigned long *lookupflags);
3535

36-
int acpi_gpio_count(struct device *dev, const char *con_id);
36+
int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id);
3737
#else
3838
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
3939
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
@@ -51,7 +51,8 @@ acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
5151
{
5252
return ERR_PTR(-ENOENT);
5353
}
54-
static inline int acpi_gpio_count(struct device *dev, const char *con_id)
54+
static inline int acpi_gpio_count(const struct fwnode_handle *fwnode,
55+
const char *con_id)
5556
{
5657
return -ENODEV;
5758
}

drivers/gpio/gpiolib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,7 @@ int gpiod_count(struct device *dev, const char *con_id)
42874287
if (is_of_node(fwnode))
42884288
count = of_gpio_count(fwnode, con_id);
42894289
else if (is_acpi_node(fwnode))
4290-
count = acpi_gpio_count(dev, con_id);
4290+
count = acpi_gpio_count(fwnode, con_id);
42914291
else if (is_software_node(fwnode))
42924292
count = swnode_gpio_count(fwnode, con_id);
42934293

0 commit comments

Comments
 (0)