mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
gpio: wm831x: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown <broonie@kernel.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
9355879ea4
commit
9b3c817b52
@ -30,14 +30,9 @@ struct wm831x_gpio {
|
||||
struct gpio_chip gpio_chip;
|
||||
};
|
||||
|
||||
static inline struct wm831x_gpio *to_wm831x_gpio(struct gpio_chip *chip)
|
||||
{
|
||||
return container_of(chip, struct wm831x_gpio, gpio_chip);
|
||||
}
|
||||
|
||||
static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
int val = WM831X_GPN_DIR;
|
||||
|
||||
@ -51,7 +46,7 @@ static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||
|
||||
static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
int ret;
|
||||
|
||||
@ -67,7 +62,7 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||
|
||||
static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
|
||||
wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
|
||||
@ -77,7 +72,7 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int wm831x_gpio_direction_out(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
int val = 0;
|
||||
int ret;
|
||||
@ -99,7 +94,7 @@ static int wm831x_gpio_direction_out(struct gpio_chip *chip,
|
||||
|
||||
static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
|
||||
return irq_create_mapping(wm831x->irq_domain,
|
||||
@ -109,7 +104,7 @@ static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
|
||||
static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
|
||||
unsigned debounce)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
int reg = WM831X_GPIO1_CONTROL + offset;
|
||||
int ret, fn;
|
||||
@ -140,7 +135,7 @@ static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
||||
{
|
||||
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
|
||||
struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip);
|
||||
struct wm831x *wm831x = wm831x_gpio->wm831x;
|
||||
int i, tristated;
|
||||
|
||||
@ -264,7 +259,7 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
|
||||
else
|
||||
wm831x_gpio->gpio_chip.base = -1;
|
||||
|
||||
ret = gpiochip_add(&wm831x_gpio->gpio_chip);
|
||||
ret = gpiochip_add_data(&wm831x_gpio->gpio_chip, wm831x_gpio);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user