Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: wm8962: 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: Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+5 -10
+5 -10
sound/soc/codecs/wm8962.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/pm.h> 20 20 #include <linux/gcd.h> 21 - #include <linux/gpio.h> 21 + #include <linux/gpio/driver.h> 22 22 #include <linux/i2c.h> 23 23 #include <linux/input.h> 24 24 #include <linux/pm_runtime.h> ··· 3307 3307 } 3308 3308 3309 3309 #ifdef CONFIG_GPIOLIB 3310 - static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) 3311 - { 3312 - return container_of(chip, struct wm8962_priv, gpio_chip); 3313 - } 3314 - 3315 3310 static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) 3316 3311 { 3317 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3312 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3318 3313 3319 3314 /* The WM8962 GPIOs aren't linearly numbered. For simplicity 3320 3315 * we export linear numbers and error out if the unsupported ··· 3332 3337 3333 3338 static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 3334 3339 { 3335 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3340 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3336 3341 struct snd_soc_codec *codec = wm8962->codec; 3337 3342 3338 3343 snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, ··· 3342 3347 static int wm8962_gpio_direction_out(struct gpio_chip *chip, 3343 3348 unsigned offset, int value) 3344 3349 { 3345 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3350 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3346 3351 struct snd_soc_codec *codec = wm8962->codec; 3347 3352 int ret, val; 3348 3353 ··· 3381 3386 else 3382 3387 wm8962->gpio_chip.base = -1; 3383 3388 3384 - ret = gpiochip_add(&wm8962->gpio_chip); 3389 + ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); 3385 3390 if (ret != 0) 3386 3391 dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); 3387 3392 }