ASoC: wm8903: 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>
This commit is contained in:
Родитель
db1d127053
Коммит
8f4160661f
|
@ -20,7 +20,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/completion.h>
|
#include <linux/completion.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/pm.h>
|
#include <linux/pm.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
@ -1766,11 +1766,6 @@ static int wm8903_resume(struct snd_soc_codec *codec)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_GPIOLIB
|
#ifdef CONFIG_GPIOLIB
|
||||||
static inline struct wm8903_priv *gpio_to_wm8903(struct gpio_chip *chip)
|
|
||||||
{
|
|
||||||
return container_of(chip, struct wm8903_priv, gpio_chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int wm8903_gpio_request(struct gpio_chip *chip, unsigned offset)
|
static int wm8903_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
if (offset >= WM8903_NUM_GPIO)
|
if (offset >= WM8903_NUM_GPIO)
|
||||||
|
@ -1781,7 +1776,7 @@ static int wm8903_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||||
|
|
||||||
static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
|
struct wm8903_priv *wm8903 = gpiochip_get_data(chip);
|
||||||
unsigned int mask, val;
|
unsigned int mask, val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1799,7 +1794,7 @@ static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||||
|
|
||||||
static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset)
|
static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
|
struct wm8903_priv *wm8903 = gpiochip_get_data(chip);
|
||||||
unsigned int reg;
|
unsigned int reg;
|
||||||
|
|
||||||
regmap_read(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, ®);
|
regmap_read(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, ®);
|
||||||
|
@ -1810,7 +1805,7 @@ static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||||
static int wm8903_gpio_direction_out(struct gpio_chip *chip,
|
static int wm8903_gpio_direction_out(struct gpio_chip *chip,
|
||||||
unsigned offset, int value)
|
unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
|
struct wm8903_priv *wm8903 = gpiochip_get_data(chip);
|
||||||
unsigned int mask, val;
|
unsigned int mask, val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1828,7 +1823,7 @@ static int wm8903_gpio_direction_out(struct gpio_chip *chip,
|
||||||
|
|
||||||
static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
|
struct wm8903_priv *wm8903 = gpiochip_get_data(chip);
|
||||||
|
|
||||||
regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset,
|
regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset,
|
||||||
WM8903_GP1_LVL_MASK,
|
WM8903_GP1_LVL_MASK,
|
||||||
|
@ -1860,7 +1855,7 @@ static void wm8903_init_gpio(struct wm8903_priv *wm8903)
|
||||||
else
|
else
|
||||||
wm8903->gpio_chip.base = -1;
|
wm8903->gpio_chip.base = -1;
|
||||||
|
|
||||||
ret = gpiochip_add(&wm8903->gpio_chip);
|
ret = gpiochip_add_data(&wm8903->gpio_chip, wm8903);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
dev_err(wm8903->dev, "Failed to add GPIOs: %d\n", ret);
|
dev_err(wm8903->dev, "Failed to add GPIOs: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче