Skip to content

Commit 0c2cae0

Browse files
committed
gpiolib: acpi: Convert type for pin to be unsigned
A pin that comes from ACPI tables is of unsigned type. This also applies to the internal APIs which use unsigned int to store the pin. Convert type for pin to be unsigned in the places where it's not yet true. While at it, add a stub for acpi_get_and_request_gpiod() for the sake of consistency in the APIs. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 213d266 commit 0c2cae0

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

drivers/gpio/gpiolib-acpi.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
108108
* controller does not have GPIO chip registered at the moment. This is to
109109
* support probe deferral.
110110
*/
111-
static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
111+
static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin)
112112
{
113113
struct gpio_chip *chip;
114114
acpi_handle handle;
@@ -136,7 +136,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
136136
* as it is intended for use outside of the GPIO layer (in a similar fashion to
137137
* gpiod_get_index() for example) it also holds a reference to the GPIO device.
138138
*/
139-
struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label)
139+
struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label)
140140
{
141141
struct gpio_desc *gpio;
142142
int ret;
@@ -317,11 +317,12 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
317317
return desc;
318318
}
319319

320-
static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
320+
static bool acpi_gpio_in_ignore_list(const char *controller_in, unsigned int pin_in)
321321
{
322322
const char *controller, *pin_str;
323-
int len, pin;
323+
unsigned int pin;
324324
char *endp;
325+
int len;
325326

326327
controller = ignore_wake;
327328
while (controller) {
@@ -354,13 +355,13 @@ static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
354355
static bool acpi_gpio_irq_is_wake(struct device *parent,
355356
struct acpi_resource_gpio *agpio)
356357
{
357-
int pin = agpio->pin_table[0];
358+
unsigned int pin = agpio->pin_table[0];
358359

359360
if (agpio->wake_capable != ACPI_WAKE_CAPABLE)
360361
return false;
361362

362363
if (acpi_gpio_in_ignore_list(dev_name(parent), pin)) {
363-
dev_info(parent, "Ignoring wakeup on pin %d\n", pin);
364+
dev_info(parent, "Ignoring wakeup on pin %u\n", pin);
364365
return false;
365366
}
366367

@@ -378,7 +379,8 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
378379
struct acpi_gpio_event *event;
379380
irq_handler_t handler = NULL;
380381
struct gpio_desc *desc;
381-
int ret, pin, irq;
382+
unsigned int pin;
383+
int ret, irq;
382384

383385
if (!acpi_gpio_get_irq_resource(ares, &agpio))
384386
return AE_OK;
@@ -1098,7 +1100,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
10981100

10991101
length = min_t(u16, agpio->pin_table_length, pin_index + bits);
11001102
for (i = pin_index; i < length; ++i) {
1101-
int pin = agpio->pin_table[i];
1103+
unsigned int pin = agpio->pin_table[i];
11021104
struct acpi_gpio_connection *conn;
11031105
struct gpio_desc *desc;
11041106
bool found;

include/linux/gpio/consumer.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ void acpi_dev_remove_driver_gpios(struct acpi_device *adev);
688688
int devm_acpi_dev_add_driver_gpios(struct device *dev,
689689
const struct acpi_gpio_mapping *gpios);
690690

691-
struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label);
691+
struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label);
692692

693693
#else /* CONFIG_GPIOLIB && CONFIG_ACPI */
694694

@@ -705,6 +705,12 @@ static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
705705
return -ENXIO;
706706
}
707707

708+
static inline struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin,
709+
char *label)
710+
{
711+
return ERR_PTR(-ENOSYS);
712+
}
713+
708714
#endif /* CONFIG_GPIOLIB && CONFIG_ACPI */
709715

710716

0 commit comments

Comments
 (0)