summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 0738f9a..646dea4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1205,6 +1205,8 @@ int gpiod_request(struct gpio_desc *desc, const char *label)
status = __gpiod_request(desc, label);
if (status < 0)
module_put(gdev->owner);
+ else
+ get_device(&gdev->dev);
}
if (status)
@@ -1248,10 +1250,12 @@ static bool __gpiod_free(struct gpio_desc *desc)
void gpiod_free(struct gpio_desc *desc)
{
- if (desc && __gpiod_free(desc))
+ if (desc && desc->gdev && __gpiod_free(desc)) {
module_put(desc->gdev->owner);
- else
+ put_device(&desc->gdev->dev);
+ } else {
WARN_ON(extra_checks);
+ }
}
/**
OpenPOWER on IntegriCloud