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

ASoC: wm8996: 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>

+6 -10
+6 -10
sound/soc/codecs/wm8996.c
··· 17 17 #include <linux/delay.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/gcd.h> 20 + #include <linux/gpio/driver.h> 20 21 #include <linux/gpio.h> 21 22 #include <linux/i2c.h> 22 23 #include <linux/regmap.h> ··· 2140 2139 } 2141 2140 2142 2141 #ifdef CONFIG_GPIOLIB 2143 - static inline struct wm8996_priv *gpio_to_wm8996(struct gpio_chip *chip) 2144 - { 2145 - return container_of(chip, struct wm8996_priv, gpio_chip); 2146 - } 2147 - 2148 2142 static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 2149 2143 { 2150 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2144 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2151 2145 2152 2146 regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2153 2147 WM8996_GP1_LVL, !!value << WM8996_GP1_LVL_SHIFT); ··· 2151 2155 static int wm8996_gpio_direction_out(struct gpio_chip *chip, 2152 2156 unsigned offset, int value) 2153 2157 { 2154 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2158 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2155 2159 int val; 2156 2160 2157 2161 val = (1 << WM8996_GP1_FN_SHIFT) | (!!value << WM8996_GP1_LVL_SHIFT); ··· 2163 2167 2164 2168 static int wm8996_gpio_get(struct gpio_chip *chip, unsigned offset) 2165 2169 { 2166 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2170 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2167 2171 unsigned int reg; 2168 2172 int ret; 2169 2173 ··· 2176 2180 2177 2181 static int wm8996_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 2178 2182 { 2179 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2183 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2180 2184 2181 2185 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2182 2186 WM8996_GP1_FN_MASK | WM8996_GP1_DIR, ··· 2207 2211 else 2208 2212 wm8996->gpio_chip.base = -1; 2209 2213 2210 - ret = gpiochip_add(&wm8996->gpio_chip); 2214 + ret = gpiochip_add_data(&wm8996->gpio_chip, wm8996); 2211 2215 if (ret != 0) 2212 2216 dev_err(wm8996->dev, "Failed to add GPIOs: %d\n", ret); 2213 2217 }