aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/gpio/driver.txt3
-rw-r--r--drivers/gpio/gpiolib-acpi.c20
-rw-r--r--drivers/gpio/gpiolib.c18
-rw-r--r--include/linux/gpio/driver.h3
4 files changed, 21 insertions, 23 deletions
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt
index 18790c237977..23b751a10d7b 100644
--- a/Documentation/gpio/driver.txt
+++ b/Documentation/gpio/driver.txt
@@ -178,7 +178,8 @@ does not help since it pins the module to the kernel forever (it calls
178try_module_get()). A GPIO driver can use the following functions instead 178try_module_get()). A GPIO driver can use the following functions instead
179to request and free descriptors without being pinned to the kernel forever. 179to request and free descriptors without being pinned to the kernel forever.
180 180
181 int gpiochip_request_own_desc(struct gpio_desc *desc, const char *label) 181 struct gpio_desc *gpiochip_request_own_desc(struct gpio_desc *desc,
182 const char *label)
182 183
183 void gpiochip_free_own_desc(struct gpio_desc *desc) 184 void gpiochip_free_own_desc(struct gpio_desc *desc)
184 185
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 84540025aa08..f9103e72e2a4 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -145,14 +145,8 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
145 if (!handler) 145 if (!handler)
146 return AE_BAD_PARAMETER; 146 return AE_BAD_PARAMETER;
147 147
148 desc = gpiochip_get_desc(chip, pin); 148 desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event");
149 if (IS_ERR(desc)) { 149 if (IS_ERR(desc)) {
150 dev_err(chip->dev, "Failed to get GPIO descriptor\n");
151 return AE_ERROR;
152 }
153
154 ret = gpiochip_request_own_desc(desc, "ACPI:Event");
155 if (ret) {
156 dev_err(chip->dev, "Failed to request GPIO\n"); 150 dev_err(chip->dev, "Failed to request GPIO\n");
157 return AE_ERROR; 151 return AE_ERROR;
158 } 152 }
@@ -420,22 +414,14 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
420 } 414 }
421 } 415 }
422 if (!found) { 416 if (!found) {
423 int ret; 417 desc = gpiochip_request_own_desc(chip, pin,
424 418 "ACPI:OpRegion");
425 desc = gpiochip_get_desc(chip, pin);
426 if (IS_ERR(desc)) { 419 if (IS_ERR(desc)) {
427 status = AE_ERROR; 420 status = AE_ERROR;
428 mutex_unlock(&achip->conn_lock); 421 mutex_unlock(&achip->conn_lock);
429 goto out; 422 goto out;
430 } 423 }
431 424
432 ret = gpiochip_request_own_desc(desc, "ACPI:OpRegion");
433 if (ret) {
434 status = AE_ERROR;
435 mutex_unlock(&achip->conn_lock);
436 goto out;
437 }
438
439 switch (agpio->io_restriction) { 425 switch (agpio->io_restriction) {
440 case ACPI_IO_RESTRICT_INPUT: 426 case ACPI_IO_RESTRICT_INPUT:
441 gpiod_direction_input(desc); 427 gpiod_direction_input(desc);
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 15cc0bb65dda..a5831d6a9b91 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -895,12 +895,22 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested);
895 * allows the GPIO chip module to be unloaded as needed (we assume that the 895 * allows the GPIO chip module to be unloaded as needed (we assume that the
896 * GPIO chip driver handles freeing the GPIOs it has requested). 896 * GPIO chip driver handles freeing the GPIOs it has requested).
897 */ 897 */
898int gpiochip_request_own_desc(struct gpio_desc *desc, const char *label) 898struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
899 const char *label)
899{ 900{
900 if (!desc || !desc->chip) 901 struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum);
901 return -EINVAL; 902 int err;
903
904 if (IS_ERR(desc)) {
905 chip_err(chip, "failed to get GPIO descriptor\n");
906 return desc;
907 }
908
909 err = __gpiod_request(desc, label);
910 if (err < 0)
911 return ERR_PTR(err);
902 912
903 return __gpiod_request(desc, label); 913 return desc;
904} 914}
905EXPORT_SYMBOL_GPL(gpiochip_request_own_desc); 915EXPORT_SYMBOL_GPL(gpiochip_request_own_desc);
906 916
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index e78a2373e374..a2de58fffd19 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -166,7 +166,8 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
166 166
167#endif /* CONFIG_GPIO_IRQCHIP */ 167#endif /* CONFIG_GPIO_IRQCHIP */
168 168
169int gpiochip_request_own_desc(struct gpio_desc *desc, const char *label); 169struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
170 const char *label);
170void gpiochip_free_own_desc(struct gpio_desc *desc); 171void gpiochip_free_own_desc(struct gpio_desc *desc);
171 172
172#else /* CONFIG_GPIOLIB */ 173#else /* CONFIG_GPIOLIB */