summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-pistachio.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-08 09:37:00 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 14:14:55 +0100
commit3d18fb5c87576493a00fe51f09b6e82a17168177 (patch)
treed6b355aef9b4f6df6b4b698e0d173f1c84252031 /drivers/pinctrl/pinctrl-pistachio.c
parentpinctrl: digicolor: use gpiochip data pointer (diff)
downloadlinux-3d18fb5c87576493a00fe51f09b6e82a17168177.tar.xz
linux-3d18fb5c87576493a00fe51f09b6e82a17168177.zip
pinctrl: pistachio: 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(). Acked-by: Andrew Bresticker <abrestic@chromium.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-pistachio.c')
-rw-r--r--drivers/pinctrl/pinctrl-pistachio.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index fd5148d106a3..856f736cb1a6 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -842,14 +842,9 @@ static inline void pctl_writel(struct pistachio_pinctrl *pctl, u32 val, u32 reg)
writel(val, pctl->base + reg);
}
-static inline struct pistachio_gpio_bank *gc_to_bank(struct gpio_chip *gc)
-{
- return container_of(gc, struct pistachio_gpio_bank, gpio_chip);
-}
-
static inline struct pistachio_gpio_bank *irqd_to_bank(struct irq_data *d)
{
- return gc_to_bank(irq_data_get_irq_chip_data(d));
+ return gpiochip_get_data(irq_data_get_irq_chip_data(d));
}
static inline u32 gpio_readl(struct pistachio_gpio_bank *bank, u32 reg)
@@ -992,7 +987,7 @@ static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev,
range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, pg->pin);
if (range)
- gpio_disable(gc_to_bank(range->gc), pg->pin - range->pin_base);
+ gpio_disable(gpiochip_get_data(range->gc), pg->pin - range->pin_base);
return 0;
}
@@ -1173,14 +1168,14 @@ static struct pinctrl_desc pistachio_pinctrl_desc = {
static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
{
- struct pistachio_gpio_bank *bank = gc_to_bank(chip);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
return !(gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset));
}
static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset)
{
- struct pistachio_gpio_bank *bank = gc_to_bank(chip);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
u32 reg;
if (gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset))
@@ -1194,7 +1189,7 @@ static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset)
static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset,
int value)
{
- struct pistachio_gpio_bank *bank = gc_to_bank(chip);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
gpio_mask_writel(bank, GPIO_OUTPUT, offset, !!value);
}
@@ -1202,7 +1197,7 @@ static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset,
static int pistachio_gpio_direction_input(struct gpio_chip *chip,
unsigned offset)
{
- struct pistachio_gpio_bank *bank = gc_to_bank(chip);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 0);
gpio_enable(bank, offset);
@@ -1213,7 +1208,7 @@ static int pistachio_gpio_direction_input(struct gpio_chip *chip,
static int pistachio_gpio_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
- struct pistachio_gpio_bank *bank = gc_to_bank(chip);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
pistachio_gpio_set(chip, offset, value);
gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 1);
@@ -1303,7 +1298,7 @@ static int pistachio_gpio_irq_set_type(struct irq_data *data, unsigned int type)
static void pistachio_gpio_irq_handler(struct irq_desc *desc)
{
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
- struct pistachio_gpio_bank *bank = gc_to_bank(gc);
+ struct pistachio_gpio_bank *bank = gpiochip_get_data(gc);
struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned long pending;
unsigned int pin;
@@ -1390,7 +1385,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
bank->gpio_chip.parent = pctl->dev;
bank->gpio_chip.of_node = child;
- ret = gpiochip_add(&bank->gpio_chip);
+ ret = gpiochip_add_data(&bank->gpio_chip, bank);
if (ret < 0) {
dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
i, ret);