Commit e730a595 authored by Linus Walleij's avatar Linus Walleij

gpio: xlp: 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: Kamlakant Patel <kamlakant.patel@broadcom.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 097d88e9
...@@ -100,11 +100,6 @@ struct xlp_gpio_priv { ...@@ -100,11 +100,6 @@ struct xlp_gpio_priv {
spinlock_t lock; spinlock_t lock;
}; };
static struct xlp_gpio_priv *gpio_chip_to_xlp_priv(struct gpio_chip *gc)
{
return container_of(gc, struct xlp_gpio_priv, chip);
}
static int xlp_gpio_get_reg(void __iomem *addr, unsigned gpio) static int xlp_gpio_get_reg(void __iomem *addr, unsigned gpio)
{ {
u32 pos, regset; u32 pos, regset;
...@@ -133,7 +128,7 @@ static void xlp_gpio_set_reg(void __iomem *addr, unsigned gpio, int state) ...@@ -133,7 +128,7 @@ static void xlp_gpio_set_reg(void __iomem *addr, unsigned gpio, int state)
static void xlp_gpio_irq_disable(struct irq_data *d) static void xlp_gpio_irq_disable(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -145,7 +140,7 @@ static void xlp_gpio_irq_disable(struct irq_data *d) ...@@ -145,7 +140,7 @@ static void xlp_gpio_irq_disable(struct irq_data *d)
static void xlp_gpio_irq_mask_ack(struct irq_data *d) static void xlp_gpio_irq_mask_ack(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -158,7 +153,7 @@ static void xlp_gpio_irq_mask_ack(struct irq_data *d) ...@@ -158,7 +153,7 @@ static void xlp_gpio_irq_mask_ack(struct irq_data *d)
static void xlp_gpio_irq_unmask(struct irq_data *d) static void xlp_gpio_irq_unmask(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -170,7 +165,7 @@ static void xlp_gpio_irq_unmask(struct irq_data *d) ...@@ -170,7 +165,7 @@ static void xlp_gpio_irq_unmask(struct irq_data *d)
static int xlp_gpio_set_irq_type(struct irq_data *d, unsigned int type) static int xlp_gpio_set_irq_type(struct irq_data *d, unsigned int type)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
int pol, irq_type; int pol, irq_type;
switch (type) { switch (type) {
...@@ -235,7 +230,7 @@ static void xlp_gpio_generic_handler(struct irq_desc *desc) ...@@ -235,7 +230,7 @@ static void xlp_gpio_generic_handler(struct irq_desc *desc)
static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state)
{ {
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
BUG_ON(gpio >= gc->ngpio); BUG_ON(gpio >= gc->ngpio);
xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x1); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x1);
...@@ -245,7 +240,7 @@ static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) ...@@ -245,7 +240,7 @@ static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state)
static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio)
{ {
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
BUG_ON(gpio >= gc->ngpio); BUG_ON(gpio >= gc->ngpio);
xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x0); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x0);
...@@ -255,7 +250,7 @@ static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) ...@@ -255,7 +250,7 @@ static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio)
static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio)
{ {
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
BUG_ON(gpio >= gc->ngpio); BUG_ON(gpio >= gc->ngpio);
return xlp_gpio_get_reg(priv->gpio_paddrv, gpio); return xlp_gpio_get_reg(priv->gpio_paddrv, gpio);
...@@ -263,7 +258,7 @@ static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) ...@@ -263,7 +258,7 @@ static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio)
static void xlp_gpio_set(struct gpio_chip *gc, unsigned gpio, int state) static void xlp_gpio_set(struct gpio_chip *gc, unsigned gpio, int state)
{ {
struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); struct xlp_gpio_priv *priv = gpiochip_get_data(gc);
BUG_ON(gpio >= gc->ngpio); BUG_ON(gpio >= gc->ngpio);
xlp_gpio_set_reg(priv->gpio_paddrv, gpio, state); xlp_gpio_set_reg(priv->gpio_paddrv, gpio, state);
...@@ -388,7 +383,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) ...@@ -388,7 +383,7 @@ static int xlp_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
err = gpiochip_add(gc); err = gpiochip_add_data(gc, priv);
if (err < 0) if (err < 0)
goto out_free_desc; goto out_free_desc;
......
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