Commit dfcdf721 authored by Linus Walleij's avatar Linus Walleij

gpio: wm8350: 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: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9b3c817b
...@@ -28,14 +28,9 @@ struct wm8350_gpio_data { ...@@ -28,14 +28,9 @@ struct wm8350_gpio_data {
struct gpio_chip gpio_chip; struct gpio_chip gpio_chip;
}; };
static inline struct wm8350_gpio_data *to_wm8350_gpio(struct gpio_chip *chip)
{
return container_of(chip, struct wm8350_gpio_data, gpio_chip);
}
static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{ {
struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip);
struct wm8350 *wm8350 = wm8350_gpio->wm8350; struct wm8350 *wm8350 = wm8350_gpio->wm8350;
return wm8350_set_bits(wm8350, WM8350_GPIO_CONFIGURATION_I_O, return wm8350_set_bits(wm8350, WM8350_GPIO_CONFIGURATION_I_O,
...@@ -44,7 +39,7 @@ static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset) ...@@ -44,7 +39,7 @@ static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset) static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset)
{ {
struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip);
struct wm8350 *wm8350 = wm8350_gpio->wm8350; struct wm8350 *wm8350 = wm8350_gpio->wm8350;
int ret; int ret;
...@@ -60,7 +55,7 @@ static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -60,7 +55,7 @@ static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset)
static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ {
struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip);
struct wm8350 *wm8350 = wm8350_gpio->wm8350; struct wm8350 *wm8350 = wm8350_gpio->wm8350;
if (value) if (value)
...@@ -72,7 +67,7 @@ static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value) ...@@ -72,7 +67,7 @@ static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
static int wm8350_gpio_direction_out(struct gpio_chip *chip, static int wm8350_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip);
struct wm8350 *wm8350 = wm8350_gpio->wm8350; struct wm8350 *wm8350 = wm8350_gpio->wm8350;
int ret; int ret;
...@@ -89,7 +84,7 @@ static int wm8350_gpio_direction_out(struct gpio_chip *chip, ...@@ -89,7 +84,7 @@ static int wm8350_gpio_direction_out(struct gpio_chip *chip,
static int wm8350_gpio_to_irq(struct gpio_chip *chip, unsigned offset) static int wm8350_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
{ {
struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip);
struct wm8350 *wm8350 = wm8350_gpio->wm8350; struct wm8350 *wm8350 = wm8350_gpio->wm8350;
if (!wm8350->irq_base) if (!wm8350->irq_base)
...@@ -130,7 +125,7 @@ static int wm8350_gpio_probe(struct platform_device *pdev) ...@@ -130,7 +125,7 @@ static int wm8350_gpio_probe(struct platform_device *pdev)
else else
wm8350_gpio->gpio_chip.base = -1; wm8350_gpio->gpio_chip.base = -1;
ret = gpiochip_add(&wm8350_gpio->gpio_chip); ret = gpiochip_add_data(&wm8350_gpio->gpio_chip, wm8350_gpio);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret; return ret;
......
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