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);
}
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
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++) {
* of the @descs array.
* @base: GPIO base in the DEPRECATED global Linux GPIO numberspace, assigned
* at device creation time.
+ * @data: per-instance data assigned by the driver
* @list: links gpio_device:s together for traversal
*
* This state container holds most of the runtime variable data
struct gpio_desc *descs;
int base;
u16 ngpio;
+ void *data;
struct list_head list;
#ifdef CONFIG_PINCTRL
* @gpiodev: the internal state holder, opaque struct
* @parent: optional parent device providing the GPIOs
* @owner: helps prevent removal of modules exporting active GPIOs
- * @data: per-instance data assigned by the driver
* @request: optional hook for chip-specific activation, such as
* enabling module power and clock; may sleep
* @free: optional hook for chip-specific deactivation, such as
struct gpio_device *gpiodev;
struct device *parent;
struct module *owner;
- void *data;
int (*request)(struct gpio_chip *chip,
unsigned offset);
bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
/* get driver data */
-static inline void *gpiochip_get_data(struct gpio_chip *chip)
-{
- return chip->data;
-}
+void *gpiochip_get_data(struct gpio_chip *chip);
struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);