Commit ba4a7448 authored by Linus Walleij's avatar Linus Walleij

gpio: bcm-kona: 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: Markus Mayer <markus.mayer@linaro.org>
Cc: Tim Kryger <tim.kryger@linaro.org>
Cc: Matt Porter <matt.porter@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent b4e97a61
...@@ -78,11 +78,6 @@ struct bcm_kona_gpio_bank { ...@@ -78,11 +78,6 @@ struct bcm_kona_gpio_bank {
struct bcm_kona_gpio *kona_gpio; struct bcm_kona_gpio *kona_gpio;
}; };
static inline struct bcm_kona_gpio *to_kona_gpio(struct gpio_chip *chip)
{
return container_of(chip, struct bcm_kona_gpio, gpio_chip);
}
static inline void bcm_kona_gpio_write_lock_regs(void __iomem *reg_base, static inline void bcm_kona_gpio_write_lock_regs(void __iomem *reg_base,
int bank_id, u32 lockcode) int bank_id, u32 lockcode)
{ {
...@@ -124,7 +119,7 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, ...@@ -124,7 +119,7 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio,
static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
{ {
struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip);
void __iomem *reg_base = kona_gpio->reg_base; void __iomem *reg_base = kona_gpio->reg_base;
u32 val; u32 val;
...@@ -141,7 +136,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) ...@@ -141,7 +136,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
u32 val, reg_offset; u32 val, reg_offset;
unsigned long flags; unsigned long flags;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
reg_base = kona_gpio->reg_base; reg_base = kona_gpio->reg_base;
spin_lock_irqsave(&kona_gpio->lock, flags); spin_lock_irqsave(&kona_gpio->lock, flags);
...@@ -168,7 +163,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) ...@@ -168,7 +163,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
u32 val, reg_offset; u32 val, reg_offset;
unsigned long flags; unsigned long flags;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
reg_base = kona_gpio->reg_base; reg_base = kona_gpio->reg_base;
spin_lock_irqsave(&kona_gpio->lock, flags); spin_lock_irqsave(&kona_gpio->lock, flags);
...@@ -188,7 +183,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) ...@@ -188,7 +183,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio)
{ {
struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip);
bcm_kona_gpio_unlock_gpio(kona_gpio, gpio); bcm_kona_gpio_unlock_gpio(kona_gpio, gpio);
return 0; return 0;
...@@ -196,7 +191,7 @@ static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) ...@@ -196,7 +191,7 @@ static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio)
static void bcm_kona_gpio_free(struct gpio_chip *chip, unsigned gpio) static void bcm_kona_gpio_free(struct gpio_chip *chip, unsigned gpio)
{ {
struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip);
bcm_kona_gpio_lock_gpio(kona_gpio, gpio); bcm_kona_gpio_lock_gpio(kona_gpio, gpio);
} }
...@@ -208,7 +203,7 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) ...@@ -208,7 +203,7 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
u32 val; u32 val;
unsigned long flags; unsigned long flags;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
reg_base = kona_gpio->reg_base; reg_base = kona_gpio->reg_base;
spin_lock_irqsave(&kona_gpio->lock, flags); spin_lock_irqsave(&kona_gpio->lock, flags);
...@@ -232,7 +227,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, ...@@ -232,7 +227,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip,
u32 val, reg_offset; u32 val, reg_offset;
unsigned long flags; unsigned long flags;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
reg_base = kona_gpio->reg_base; reg_base = kona_gpio->reg_base;
spin_lock_irqsave(&kona_gpio->lock, flags); spin_lock_irqsave(&kona_gpio->lock, flags);
...@@ -255,7 +250,7 @@ static int bcm_kona_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) ...@@ -255,7 +250,7 @@ static int bcm_kona_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
{ {
struct bcm_kona_gpio *kona_gpio; struct bcm_kona_gpio *kona_gpio;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
if (gpio >= kona_gpio->gpio_chip.ngpio) if (gpio >= kona_gpio->gpio_chip.ngpio)
return -ENXIO; return -ENXIO;
return irq_create_mapping(kona_gpio->irq_domain, gpio); return irq_create_mapping(kona_gpio->irq_domain, gpio);
...@@ -269,7 +264,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, ...@@ -269,7 +264,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio,
u32 val, res; u32 val, res;
unsigned long flags; unsigned long flags;
kona_gpio = to_kona_gpio(chip); kona_gpio = gpiochip_get_data(chip);
reg_base = kona_gpio->reg_base; reg_base = kona_gpio->reg_base;
/* debounce must be 1-128ms (or 0) */ /* debounce must be 1-128ms (or 0) */
if ((debounce > 0 && debounce < 1000) || debounce > 128000) { if ((debounce > 0 && debounce < 1000) || debounce > 128000) {
...@@ -635,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) ...@@ -635,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
bcm_kona_gpio_reset(kona_gpio); bcm_kona_gpio_reset(kona_gpio);
ret = gpiochip_add(chip); ret = gpiochip_add_data(chip, kona_gpio);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret); dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret);
goto err_irq_domain; goto err_irq_domain;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment