mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 14:14:01 +08:00
powerpc: ppc4xx: 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: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
a14a2d484b
commit
0d36fe65f5
@ -27,7 +27,7 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/of_gpio.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
@ -67,12 +67,6 @@ struct ppc4xx_gpio_chip {
|
|||||||
* There are a maximum of 32 gpios in each gpio controller.
|
* There are a maximum of 32 gpios in each gpio controller.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline struct ppc4xx_gpio_chip *
|
|
||||||
to_ppc4xx_gpiochip(struct of_mm_gpio_chip *mm_gc)
|
|
||||||
{
|
|
||||||
return container_of(mm_gc, struct ppc4xx_gpio_chip, mm_gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ppc4xx_gpio_get(struct gpio_chip *gc, unsigned int gpio)
|
static int ppc4xx_gpio_get(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);
|
||||||
@ -97,7 +91,7 @@ static void
|
|||||||
ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
ppc4xx_gpio_set(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 ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc);
|
struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&chip->lock, flags);
|
spin_lock_irqsave(&chip->lock, flags);
|
||||||
@ -112,7 +106,7 @@ ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
|||||||
static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
|
static int ppc4xx_gpio_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 ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc);
|
struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
|
||||||
struct ppc4xx_gpio __iomem *regs = mm_gc->regs;
|
struct ppc4xx_gpio __iomem *regs = mm_gc->regs;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
@ -142,7 +136,7 @@ static int
|
|||||||
ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
ppc4xx_gpio_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 ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc);
|
struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
|
||||||
struct ppc4xx_gpio __iomem *regs = mm_gc->regs;
|
struct ppc4xx_gpio __iomem *regs = mm_gc->regs;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
@ -200,7 +194,7 @@ static int __init ppc4xx_add_gpiochips(void)
|
|||||||
gc->get = ppc4xx_gpio_get;
|
gc->get = ppc4xx_gpio_get;
|
||||||
gc->set = ppc4xx_gpio_set;
|
gc->set = ppc4xx_gpio_set;
|
||||||
|
|
||||||
ret = of_mm_gpiochip_add(np, mm_gc);
|
ret = of_mm_gpiochip_add_data(np, mm_gc, ppc4xx_gc);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user