diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-02-11 05:37:48 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-02-15 18:20:02 -0500 |
commit | 43c54ecade400cf6ca8203f960b525fbe5b73a13 (patch) | |
tree | a21d68b83a3629237c790a69a3d9d461972f07ae | |
parent | 20ec3e39fc12cf3a331ee73eb01d52bddcdd2fa4 (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>
-rw-r--r-- | drivers/gpio/gpiolib.c | 17 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.h | 2 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 7 |
3 files changed, 18 insertions, 8 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) | |||
480 | goto err_free_gdev; | 480 | goto err_free_gdev; |
481 | } | 481 | } |
482 | gdev->ngpio = chip->ngpio; | 482 | gdev->ngpio = chip->ngpio; |
483 | /* FIXME: move driver data into gpio_device dev_set_drvdata() */ | 483 | gdev->data = data; |
484 | chip->data = data; | ||
485 | 484 | ||
486 | spin_lock_irqsave(&gpio_lock, flags); | 485 | spin_lock_irqsave(&gpio_lock, flags); |
487 | 486 | ||
@@ -603,6 +602,15 @@ err_free_gdev: | |||
603 | EXPORT_SYMBOL_GPL(gpiochip_add_data); | 602 | EXPORT_SYMBOL_GPL(gpiochip_add_data); |
604 | 603 | ||
605 | /** | 604 | /** |
605 | * gpiochip_get_data() - get per-subdriver data for the chip | ||
606 | */ | ||
607 | void *gpiochip_get_data(struct gpio_chip *chip) | ||
608 | { | ||
609 | return chip->gpiodev->data; | ||
610 | } | ||
611 | EXPORT_SYMBOL_GPL(gpiochip_get_data); | ||
612 | |||
613 | /** | ||
606 | * gpiochip_remove() - unregister a gpio_chip | 614 | * gpiochip_remove() - unregister a gpio_chip |
607 | * @chip: the chip to unregister | 615 | * @chip: the chip to unregister |
608 | * | 616 | * |
@@ -626,6 +634,11 @@ void gpiochip_remove(struct gpio_chip *chip) | |||
626 | gpiochip_remove_pin_ranges(chip); | 634 | gpiochip_remove_pin_ranges(chip); |
627 | gpiochip_free_hogs(chip); | 635 | gpiochip_free_hogs(chip); |
628 | of_gpiochip_remove(chip); | 636 | of_gpiochip_remove(chip); |
637 | /* | ||
638 | * We accept no more calls into the driver from this point, so | ||
639 | * NULL the driver data pointer | ||
640 | */ | ||
641 | gdev->data = NULL; | ||
629 | 642 | ||
630 | spin_lock_irqsave(&gpio_lock, flags); | 643 | spin_lock_irqsave(&gpio_lock, flags); |
631 | for (i = 0; i < gdev->ngpio; i++) { | 644 | for (i = 0; i < gdev->ngpio; i++) { |
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 5a36908fd39d..ddbe409ad48f 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -37,6 +37,7 @@ struct acpi_device; | |||
37 | * of the @descs array. | 37 | * of the @descs array. |
38 | * @base: GPIO base in the DEPRECATED global Linux GPIO numberspace, assigned | 38 | * @base: GPIO base in the DEPRECATED global Linux GPIO numberspace, assigned |
39 | * at device creation time. | 39 | * at device creation time. |
40 | * @data: per-instance data assigned by the driver | ||
40 | * @list: links gpio_device:s together for traversal | 41 | * @list: links gpio_device:s together for traversal |
41 | * | 42 | * |
42 | * This state container holds most of the runtime variable data | 43 | * This state container holds most of the runtime variable data |
@@ -54,6 +55,7 @@ struct gpio_device { | |||
54 | struct gpio_desc *descs; | 55 | struct gpio_desc *descs; |
55 | int base; | 56 | int base; |
56 | u16 ngpio; | 57 | u16 ngpio; |
58 | void *data; | ||
57 | struct list_head list; | 59 | struct list_head list; |
58 | 60 | ||
59 | #ifdef CONFIG_PINCTRL | 61 | #ifdef CONFIG_PINCTRL |
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index e2a934ce3e64..b92ab9efdb69 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -25,7 +25,6 @@ struct gpio_device; | |||
25 | * @gpiodev: the internal state holder, opaque struct | 25 | * @gpiodev: the internal state holder, opaque struct |
26 | * @parent: optional parent device providing the GPIOs | 26 | * @parent: optional parent device providing the GPIOs |
27 | * @owner: helps prevent removal of modules exporting active GPIOs | 27 | * @owner: helps prevent removal of modules exporting active GPIOs |
28 | * @data: per-instance data assigned by the driver | ||
29 | * @request: optional hook for chip-specific activation, such as | 28 | * @request: optional hook for chip-specific activation, such as |
30 | * enabling module power and clock; may sleep | 29 | * enabling module power and clock; may sleep |
31 | * @free: optional hook for chip-specific deactivation, such as | 30 | * @free: optional hook for chip-specific deactivation, such as |
@@ -109,7 +108,6 @@ struct gpio_chip { | |||
109 | struct gpio_device *gpiodev; | 108 | struct gpio_device *gpiodev; |
110 | struct device *parent; | 109 | struct device *parent; |
111 | struct module *owner; | 110 | struct module *owner; |
112 | void *data; | ||
113 | 111 | ||
114 | int (*request)(struct gpio_chip *chip, | 112 | int (*request)(struct gpio_chip *chip, |
115 | unsigned offset); | 113 | unsigned offset); |
@@ -202,10 +200,7 @@ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); | |||
202 | bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset); | 200 | bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset); |
203 | 201 | ||
204 | /* get driver data */ | 202 | /* get driver data */ |
205 | static inline void *gpiochip_get_data(struct gpio_chip *chip) | 203 | void *gpiochip_get_data(struct gpio_chip *chip); |
206 | { | ||
207 | return chip->data; | ||
208 | } | ||
209 | 204 | ||
210 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); | 205 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); |
211 | 206 | ||