gpio: dln2: use gpiochip data pointer

This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().

Cc: Octavian Purdila <octavian.purdila@intel.com>
Cc: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Linus Walleij 2015-12-06 00:32:16 +01:00
Родитель 72a1ca2cb9
Коммит 1880657a15
1 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -153,7 +153,7 @@ static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
struct dln2_gpio_pin req = { struct dln2_gpio_pin req = {
.pin = cpu_to_le16(offset), .pin = cpu_to_le16(offset),
}; };
@ -194,14 +194,14 @@ out_disable:
static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset) static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset); dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset);
} }
static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
if (test_bit(offset, dln2->output_enabled)) if (test_bit(offset, dln2->output_enabled))
return GPIOF_DIR_OUT; return GPIOF_DIR_OUT;
@ -211,7 +211,7 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
int dir; int dir;
dir = dln2_gpio_get_direction(chip, offset); dir = dln2_gpio_get_direction(chip, offset);
@ -226,7 +226,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
dln2_gpio_pin_set_out_val(dln2, offset, value); dln2_gpio_pin_set_out_val(dln2, offset, value);
} }
@ -234,7 +234,7 @@ static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset,
unsigned dir) unsigned dir)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
struct dln2_gpio_pin_val req = { struct dln2_gpio_pin_val req = {
.pin = cpu_to_le16(offset), .pin = cpu_to_le16(offset),
.value = dir, .value = dir,
@ -262,7 +262,7 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
int value) int value)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
int ret; int ret;
ret = dln2_gpio_pin_set_out_val(dln2, offset, value); ret = dln2_gpio_pin_set_out_val(dln2, offset, value);
@ -275,7 +275,7 @@ static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
unsigned debounce) unsigned debounce)
{ {
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(chip);
__le32 duration = cpu_to_le32(debounce); __le32 duration = cpu_to_le32(debounce);
return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE, return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE,
@ -302,7 +302,7 @@ static int dln2_gpio_set_event_cfg(struct dln2_gpio *dln2, unsigned pin,
static void dln2_irq_unmask(struct irq_data *irqd) static void dln2_irq_unmask(struct irq_data *irqd)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(gc);
int pin = irqd_to_hwirq(irqd); int pin = irqd_to_hwirq(irqd);
set_bit(pin, dln2->unmasked_irqs); set_bit(pin, dln2->unmasked_irqs);
@ -311,7 +311,7 @@ static void dln2_irq_unmask(struct irq_data *irqd)
static void dln2_irq_mask(struct irq_data *irqd) static void dln2_irq_mask(struct irq_data *irqd)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(gc);
int pin = irqd_to_hwirq(irqd); int pin = irqd_to_hwirq(irqd);
clear_bit(pin, dln2->unmasked_irqs); clear_bit(pin, dln2->unmasked_irqs);
@ -320,7 +320,7 @@ static void dln2_irq_mask(struct irq_data *irqd)
static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) static int dln2_irq_set_type(struct irq_data *irqd, unsigned type)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(gc);
int pin = irqd_to_hwirq(irqd); int pin = irqd_to_hwirq(irqd);
switch (type) { switch (type) {
@ -349,7 +349,7 @@ static int dln2_irq_set_type(struct irq_data *irqd, unsigned type)
static void dln2_irq_bus_lock(struct irq_data *irqd) static void dln2_irq_bus_lock(struct irq_data *irqd)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(gc);
mutex_lock(&dln2->irq_lock); mutex_lock(&dln2->irq_lock);
} }
@ -357,7 +357,7 @@ static void dln2_irq_bus_lock(struct irq_data *irqd)
static void dln2_irq_bus_unlock(struct irq_data *irqd) static void dln2_irq_bus_unlock(struct irq_data *irqd)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); struct dln2_gpio *dln2 = gpiochip_get_data(gc);
int pin = irqd_to_hwirq(irqd); int pin = irqd_to_hwirq(irqd);
int enabled, unmasked; int enabled, unmasked;
unsigned type; unsigned type;
@ -479,7 +479,7 @@ static int dln2_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dln2); platform_set_drvdata(pdev, dln2);
ret = gpiochip_add(&dln2->gpio); ret = gpiochip_add_data(&dln2->gpio, dln2);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to add gpio chip: %d\n", ret); dev_err(dev, "failed to add gpio chip: %d\n", ret);
goto out; goto out;