summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-07 15:11:34 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 11:21:18 +0100
commit9b3c817b529e0bbe0d5a0a45e86e8647a729640c (patch)
tree1f7aa752029827a98c360dae842433a6f88dd564 /drivers/gpio
parent9355879ea42b84914ab27064df6760b2a7db0883 (diff)
downloadop-kernel-dev-9b3c817b529e0bbe0d5a0a45e86e8647a729640c.zip
op-kernel-dev-9b3c817b529e0bbe0d5a0a45e86e8647a729640c.tar.gz
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>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-wm831x.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c
index 2e73e4b..9839007 100644
--- a/drivers/gpio/gpio-wm831x.c
+++ b/drivers/gpio/gpio-wm831x.c
@@ -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;
OpenPOWER on IntegriCloud