Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283705
b: refs/heads/master
c: 9db16e4
h: refs/heads/master
i:
  283703: 9cc041e
v: v3
  • Loading branch information
Mark Brown committed Nov 9, 2011
1 parent 871a3d8 commit cba5c94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: abda5dfdd56e548a7c569a40c404d8679c4f35f1
refs/heads/master: 9db16e4c1b21abe5bfc15b6a14824acc0ce0d594
52 changes: 25 additions & 27 deletions trunk/sound/soc/codecs/wm5100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2352,24 +2352,22 @@ static inline struct wm5100_priv *gpio_to_wm5100(struct gpio_chip *chip)
static void wm5100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
struct snd_soc_codec *codec = wm5100->codec;

snd_soc_update_bits(codec, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT);
regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT);
}

static int wm5100_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value)
{
struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
struct snd_soc_codec *codec = wm5100->codec;
int val, ret;

val = (1 << WM5100_GP1_FN_SHIFT) | (!!value << WM5100_GP1_LVL_SHIFT);

ret = snd_soc_update_bits(codec, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_FN_MASK | WM5100_GP1_DIR |
WM5100_GP1_LVL, val);
ret = regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_FN_MASK | WM5100_GP1_DIR |
WM5100_GP1_LVL, val);
if (ret < 0)
return ret;
else
Expand All @@ -2379,25 +2377,24 @@ static int wm5100_gpio_direction_out(struct gpio_chip *chip,
static int wm5100_gpio_get(struct gpio_chip *chip, unsigned offset)
{
struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
struct snd_soc_codec *codec = wm5100->codec;
unsigned int reg;
int ret;

ret = snd_soc_read(codec, WM5100_GPIO_CTRL_1 + offset);
ret = regmap_read(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, &reg);
if (ret < 0)
return ret;

return (ret & WM5100_GP1_LVL) != 0;
return (reg & WM5100_GP1_LVL) != 0;
}

static int wm5100_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{
struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
struct snd_soc_codec *codec = wm5100->codec;

return snd_soc_update_bits(codec, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_FN_MASK | WM5100_GP1_DIR,
(1 << WM5100_GP1_FN_SHIFT) |
(1 << WM5100_GP1_DIR_SHIFT));
return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
WM5100_GP1_FN_MASK | WM5100_GP1_DIR,
(1 << WM5100_GP1_FN_SHIFT) |
(1 << WM5100_GP1_DIR_SHIFT));
}

static struct gpio_chip wm5100_template_chip = {
Expand All @@ -2410,14 +2407,14 @@ static struct gpio_chip wm5100_template_chip = {
.can_sleep = 1,
};

static void wm5100_init_gpio(struct snd_soc_codec *codec)
static void wm5100_init_gpio(struct i2c_client *i2c)
{
struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec);
struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c);
int ret;

wm5100->gpio_chip = wm5100_template_chip;
wm5100->gpio_chip.ngpio = 6;
wm5100->gpio_chip.dev = codec->dev;
wm5100->gpio_chip.dev = &i2c->dev;

if (wm5100->pdata.gpio_base)
wm5100->gpio_chip.base = wm5100->pdata.gpio_base;
Expand All @@ -2426,24 +2423,24 @@ static void wm5100_init_gpio(struct snd_soc_codec *codec)

ret = gpiochip_add(&wm5100->gpio_chip);
if (ret != 0)
dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret);
dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
}

static void wm5100_free_gpio(struct snd_soc_codec *codec)
static void wm5100_free_gpio(struct i2c_client *i2c)
{
struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec);
struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c);
int ret;

ret = gpiochip_remove(&wm5100->gpio_chip);
if (ret != 0)
dev_err(codec->dev, "Failed to remove GPIOs: %d\n", ret);
dev_err(&i2c->dev, "Failed to remove GPIOs: %d\n", ret);
}
#else
static void wm5100_init_gpio(struct snd_soc_codec *codec)
static void wm5100_init_gpio(struct i2c_client *i2c)
{
}

static void wm5100_free_gpio(struct snd_soc_codec *codec)
static void wm5100_free_gpio(struct i2c_client *i2c)
{
}
#endif
Expand All @@ -2465,7 +2462,6 @@ static int wm5100_probe(struct snd_soc_codec *codec)

regcache_cache_only(wm5100->regmap, true);

wm5100_init_gpio(codec);

for (i = 0; i < ARRAY_SIZE(wm5100_dig_vu); i++)
snd_soc_update_bits(codec, wm5100_dig_vu[i], WM5100_OUT_VU,
Expand Down Expand Up @@ -2573,7 +2569,6 @@ static int wm5100_probe(struct snd_soc_codec *codec)
err_gpio:
if (i2c->irq)
free_irq(i2c->irq, codec);
wm5100_free_gpio(codec);

return ret;
}
Expand All @@ -2589,7 +2584,6 @@ static int wm5100_remove(struct snd_soc_codec *codec)
}
if (i2c->irq)
free_irq(i2c->irq, codec);
wm5100_free_gpio(codec);
return 0;
}

Expand Down Expand Up @@ -2743,6 +2737,8 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
goto err_reset;
}

wm5100_init_gpio(i2c);

ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_wm5100, wm5100_dai,
ARRAY_SIZE(wm5100_dai));
Expand All @@ -2754,6 +2750,7 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
return ret;

err_reset:
wm5100_free_gpio(i2c);
if (wm5100->pdata.reset) {
gpio_set_value_cansleep(wm5100->pdata.reset, 1);
gpio_free(wm5100->pdata.reset);
Expand Down Expand Up @@ -2787,6 +2784,7 @@ static __devexit int wm5100_i2c_remove(struct i2c_client *client)
struct wm5100_priv *wm5100 = i2c_get_clientdata(client);

snd_soc_unregister_codec(&client->dev);
wm5100_free_gpio(client);
if (wm5100->pdata.reset) {
gpio_set_value_cansleep(wm5100->pdata.reset, 1);
gpio_free(wm5100->pdata.reset);
Expand Down

0 comments on commit cba5c94

Please sign in to comment.