提交 a14a2d48 编写于 作者: L Linus Walleij

powerpc: cpm_common: 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: Anatolij Gustschin <agust@denx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 e65078f1
...@@ -80,15 +80,9 @@ struct cpm2_gpio32_chip { ...@@ -80,15 +80,9 @@ struct cpm2_gpio32_chip {
u32 cpdata; u32 cpdata;
}; };
static inline struct cpm2_gpio32_chip *
to_cpm2_gpio32_chip(struct of_mm_gpio_chip *mm_gc)
{
return container_of(mm_gc, struct cpm2_gpio32_chip, mm_gc);
}
static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc)
{ {
struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc);
struct cpm2_ioports __iomem *iop = mm_gc->regs; struct cpm2_ioports __iomem *iop = mm_gc->regs;
cpm2_gc->cpdata = in_be32(&iop->dat); cpm2_gc->cpdata = in_be32(&iop->dat);
...@@ -108,7 +102,7 @@ static int cpm2_gpio32_get(struct gpio_chip *gc, unsigned int gpio) ...@@ -108,7 +102,7 @@ static int cpm2_gpio32_get(struct gpio_chip *gc, unsigned int gpio)
static void __cpm2_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask, static void __cpm2_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask,
int value) int value)
{ {
struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc);
struct cpm2_ioports __iomem *iop = mm_gc->regs; struct cpm2_ioports __iomem *iop = mm_gc->regs;
if (value) if (value)
...@@ -122,7 +116,7 @@ static void __cpm2_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask, ...@@ -122,7 +116,7 @@ static void __cpm2_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask,
static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value)
{ {
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc);
unsigned long flags; unsigned long flags;
u32 pin_mask = 1 << (31 - gpio); u32 pin_mask = 1 << (31 - gpio);
...@@ -136,7 +130,7 @@ static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) ...@@ -136,7 +130,7 @@ static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value)
static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{ {
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc);
struct cpm2_ioports __iomem *iop = mm_gc->regs; struct cpm2_ioports __iomem *iop = mm_gc->regs;
unsigned long flags; unsigned long flags;
u32 pin_mask = 1 << (31 - gpio); u32 pin_mask = 1 << (31 - gpio);
...@@ -154,7 +148,7 @@ static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) ...@@ -154,7 +148,7 @@ static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
{ {
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc);
struct cpm2_ioports __iomem *iop = mm_gc->regs; struct cpm2_ioports __iomem *iop = mm_gc->regs;
unsigned long flags; unsigned long flags;
u32 pin_mask = 1 << (31 - gpio); u32 pin_mask = 1 << (31 - gpio);
...@@ -190,6 +184,6 @@ int cpm2_gpiochip_add32(struct device_node *np) ...@@ -190,6 +184,6 @@ int cpm2_gpiochip_add32(struct device_node *np)
gc->get = cpm2_gpio32_get; gc->get = cpm2_gpio32_get;
gc->set = cpm2_gpio32_set; gc->set = cpm2_gpio32_set;
return of_mm_gpiochip_add(np, mm_gc); return of_mm_gpiochip_add_data(np, mm_gc, cpm2_gc);
} }
#endif /* CONFIG_CPM2 || CONFIG_8xx_GPIO */ #endif /* CONFIG_CPM2 || CONFIG_8xx_GPIO */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册