diff mbox

[179/182] ASoC: wm8962: use gpiochip data pointer

Message ID 1449669107-7264-1-git-send-email-linus.walleij@linaro.org
State Accepted
Commit f42b6f5800b6d06442c193d4beb423b0186e7b6a
Headers show

Commit Message

Linus Walleij Dec. 9, 2015, 1:51 p.m. UTC
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: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
Liam/Mark: please ACK this so I can merge it into the GPIO tree.
---
 sound/soc/codecs/wm8962.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Charles Keepax Dec. 10, 2015, 11:05 a.m. UTC | #1
On Wed, Dec 09, 2015 at 02:51:47PM +0100, Linus Walleij wrote:
> 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: Mark Brown <broonie@kernel.org>

> Cc: alsa-devel@alsa-project.org

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

> Liam/Mark: please ACK this so I can merge it into the GPIO tree.

> ---


Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>


Thanks,
Charles
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Dec. 12, 2015, 10:53 p.m. UTC | #2
On Wed, Dec 09, 2015 at 02:51:47PM +0100, Linus Walleij wrote:
> 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().


Acked-by: Mark Brown <broonie@kernel.org>
diff mbox

Patch

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index b563d6746ac4..1577d2e62e76 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -18,7 +18,7 @@ 
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/gcd.h>
-#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/pm_runtime.h>
@@ -3308,14 +3308,9 @@  static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio)
 }
 
 #ifdef CONFIG_GPIOLIB
-static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
-{
-	return container_of(chip, struct wm8962_priv, gpio_chip);
-}
-
 static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
-	struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+	struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
 
 	/* The WM8962 GPIOs aren't linearly numbered.  For simplicity
 	 * we export linear numbers and error out if the unsupported
@@ -3338,7 +3333,7 @@  static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
 
 static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-	struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+	struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
 	struct snd_soc_codec *codec = wm8962->codec;
 
 	snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
@@ -3348,7 +3343,7 @@  static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 static int wm8962_gpio_direction_out(struct gpio_chip *chip,
 				     unsigned offset, int value)
 {
-	struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+	struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
 	struct snd_soc_codec *codec = wm8962->codec;
 	int ret, val;
 
@@ -3387,7 +3382,7 @@  static void wm8962_init_gpio(struct snd_soc_codec *codec)
 	else
 		wm8962->gpio_chip.base = -1;
 
-	ret = gpiochip_add(&wm8962->gpio_chip);
+	ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962);
 	if (ret != 0)
 		dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret);
 }