summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-02-11 11:37:48 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-02-16 00:20:02 +0100
commit43c54ecade400cf6ca8203f960b525fbe5b73a13 (patch)
treea21d68b83a3629237c790a69a3d9d461972f07ae /drivers/gpio/gpiolib.c
parent20ec3e39fc12cf3a331ee73eb01d52bddcdd2fa4 (diff)
gpio: move the subdriver data pointer into gpio_device
We move to manage this pointer under gpiolib control rather than leave it in the subdevice's gpio_chip. We can not NULL it after gpiochip_remove so at to keep things tight. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 28984bbc079c..aa4a60e19339 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -480,8 +480,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
goto err_free_gdev;
}
gdev->ngpio = chip->ngpio;
- /* FIXME: move driver data into gpio_device dev_set_drvdata() */
- chip->data = data;
+ gdev->data = data;
spin_lock_irqsave(&gpio_lock, flags);
@@ -603,6 +602,15 @@ err_free_gdev:
EXPORT_SYMBOL_GPL(gpiochip_add_data);
/**
+ * gpiochip_get_data() - get per-subdriver data for the chip
+ */
+void *gpiochip_get_data(struct gpio_chip *chip)
+{
+ return chip->gpiodev->data;
+}
+EXPORT_SYMBOL_GPL(gpiochip_get_data);
+
+/**
* gpiochip_remove() - unregister a gpio_chip
* @chip: the chip to unregister
*
@@ -626,6 +634,11 @@ void gpiochip_remove(struct gpio_chip *chip)
gpiochip_remove_pin_ranges(chip);
gpiochip_free_hogs(chip);
of_gpiochip_remove(chip);
+ /*
+ * We accept no more calls into the driver from this point, so
+ * NULL the driver data pointer
+ */
+ gdev->data = NULL;
spin_lock_irqsave(&gpio_lock, flags);
for (i = 0; i < gdev->ngpio; i++) {