Skip to content

Commit

Permalink
gpiolib: acpi: Convert type for pin to be unsigned
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko committed Apr 8, 2022
1 parent 213d266 commit 0c2cae0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 10 additions & 8 deletions drivers/gpio/gpiolib-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
* controller does not have GPIO chip registered at the moment. This is to
* support probe deferral.
*/
static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin)
{
struct gpio_chip *chip;
acpi_handle handle;
Expand Down Expand Up @@ -136,7 +136,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
* as it is intended for use outside of the GPIO layer (in a similar fashion to
* gpiod_get_index() for example) it also holds a reference to the GPIO device.
*/
struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label)
struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label)
{
struct gpio_desc *gpio;
int ret;
Expand Down Expand Up @@ -317,11 +317,12 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
return desc;
}

static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
static bool acpi_gpio_in_ignore_list(const char *controller_in, unsigned int pin_in)
{
const char *controller, *pin_str;
int len, pin;
unsigned int pin;
char *endp;
int len;

controller = ignore_wake;
while (controller) {
Expand Down Expand Up @@ -354,13 +355,13 @@ static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
static bool acpi_gpio_irq_is_wake(struct device *parent,
struct acpi_resource_gpio *agpio)
{
int pin = agpio->pin_table[0];
unsigned int pin = agpio->pin_table[0];

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

if (acpi_gpio_in_ignore_list(dev_name(parent), pin)) {
dev_info(parent, "Ignoring wakeup on pin %d\n", pin);
dev_info(parent, "Ignoring wakeup on pin %u\n", pin);
return false;
}

Expand All @@ -378,7 +379,8 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
struct acpi_gpio_event *event;
irq_handler_t handler = NULL;
struct gpio_desc *desc;
int ret, pin, irq;
unsigned int pin;
int ret, irq;

if (!acpi_gpio_get_irq_resource(ares, &agpio))
return AE_OK;
Expand Down Expand Up @@ -1098,7 +1100,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,

length = min_t(u16, agpio->pin_table_length, pin_index + bits);
for (i = pin_index; i < length; ++i) {
int pin = agpio->pin_table[i];
unsigned int pin = agpio->pin_table[i];
struct acpi_gpio_connection *conn;
struct gpio_desc *desc;
bool found;
Expand Down
8 changes: 7 additions & 1 deletion include/linux/gpio/consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ void acpi_dev_remove_driver_gpios(struct acpi_device *adev);
int devm_acpi_dev_add_driver_gpios(struct device *dev,
const struct acpi_gpio_mapping *gpios);

struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label);
struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label);

#else /* CONFIG_GPIOLIB && CONFIG_ACPI */

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

static inline struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin,
char *label)
{
return ERR_PTR(-ENOSYS);
}

#endif /* CONFIG_GPIOLIB && CONFIG_ACPI */


Expand Down

0 comments on commit 0c2cae0

Please sign in to comment.