diff options
| author | Arun Shamanna Lakshmi <aruns@nvidia.com> | 2014-01-14 18:31:54 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-01-15 06:43:27 -0500 |
| commit | f7d3c17096f6cbca8f0113d5a092ffcc72c7bf41 (patch) | |
| tree | da50751d488fa4a6d280111622066c7bbaffa16d | |
| parent | b893ea5f1cd1adbbd7e0794d16d47bbb46f80733 (diff) | |
ASoC: dapm: Change prototype of soc_widget_read
soc_widget_read API returns the register data and it is possible
that a register can contain 0xffffffff. Thus, change the prototype
of soc_widget_read to return only the error code and pass the reg
data through pointer argument.
Signed-off-by: Arun Shamanna Lakshmi <aruns@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
| -rw-r--r-- | sound/soc/soc-dapm.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 51b4c192f41a..2a44fe9122a2 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -371,12 +371,16 @@ static void dapm_reset(struct snd_soc_card *card) | |||
| 371 | } | 371 | } |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg) | 374 | static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, |
| 375 | unsigned int *value) | ||
| 375 | { | 376 | { |
| 376 | if (w->codec) | 377 | if (w->codec) { |
| 377 | return snd_soc_read(w->codec, reg); | 378 | *value = snd_soc_read(w->codec, reg); |
| 378 | else if (w->platform) | 379 | return 0; |
| 379 | return snd_soc_platform_read(w->platform, reg); | 380 | } else if (w->platform) { |
| 381 | *value = snd_soc_platform_read(w->platform, reg); | ||
| 382 | return 0; | ||
| 383 | } | ||
| 380 | 384 | ||
| 381 | dev_err(w->dapm->dev, "ASoC: no valid widget read method\n"); | 385 | dev_err(w->dapm->dev, "ASoC: no valid widget read method\n"); |
| 382 | return -1; | 386 | return -1; |
| @@ -430,13 +434,12 @@ static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, | |||
| 430 | return ret; | 434 | return ret; |
| 431 | } else { | 435 | } else { |
| 432 | soc_widget_lock(w); | 436 | soc_widget_lock(w); |
| 433 | ret = soc_widget_read(w, reg); | 437 | ret = soc_widget_read(w, reg, &old); |
| 434 | if (ret < 0) { | 438 | if (ret < 0) { |
| 435 | soc_widget_unlock(w); | 439 | soc_widget_unlock(w); |
| 436 | return ret; | 440 | return ret; |
| 437 | } | 441 | } |
| 438 | 442 | ||
| 439 | old = ret; | ||
| 440 | new = (old & ~mask) | (value & mask); | 443 | new = (old & ~mask) | (value & mask); |
| 441 | change = old != new; | 444 | change = old != new; |
| 442 | if (change) { | 445 | if (change) { |
| @@ -513,7 +516,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
| 513 | unsigned int invert = mc->invert; | 516 | unsigned int invert = mc->invert; |
| 514 | 517 | ||
| 515 | if (reg != SND_SOC_NOPM) { | 518 | if (reg != SND_SOC_NOPM) { |
| 516 | val = soc_widget_read(w, reg); | 519 | soc_widget_read(w, reg, &val); |
| 517 | val = (val >> shift) & mask; | 520 | val = (val >> shift) & mask; |
| 518 | if (invert) | 521 | if (invert) |
| 519 | val = max - val; | 522 | val = max - val; |
| @@ -529,7 +532,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
| 529 | w->kcontrol_news[i].private_value; | 532 | w->kcontrol_news[i].private_value; |
| 530 | int val, item; | 533 | int val, item; |
| 531 | 534 | ||
| 532 | val = soc_widget_read(w, e->reg); | 535 | soc_widget_read(w, e->reg, &val); |
| 533 | item = (val >> e->shift_l) & e->mask; | 536 | item = (val >> e->shift_l) & e->mask; |
| 534 | 537 | ||
| 535 | if (item < e->max && !strcmp(p->name, e->texts[item])) | 538 | if (item < e->max && !strcmp(p->name, e->texts[item])) |
| @@ -558,7 +561,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
| 558 | w->kcontrol_news[i].private_value; | 561 | w->kcontrol_news[i].private_value; |
| 559 | int val, item; | 562 | int val, item; |
| 560 | 563 | ||
| 561 | val = soc_widget_read(w, e->reg); | 564 | soc_widget_read(w, e->reg, &val); |
| 562 | val = (val >> e->shift_l) & e->mask; | 565 | val = (val >> e->shift_l) & e->mask; |
| 563 | for (item = 0; item < e->max; item++) { | 566 | for (item = 0; item < e->max; item++) { |
| 564 | if (val == e->values[item]) | 567 | if (val == e->values[item]) |
| @@ -2782,7 +2785,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) | |||
| 2782 | 2785 | ||
| 2783 | /* Read the initial power state from the device */ | 2786 | /* Read the initial power state from the device */ |
| 2784 | if (w->reg >= 0) { | 2787 | if (w->reg >= 0) { |
| 2785 | val = soc_widget_read(w, w->reg) >> w->shift; | 2788 | soc_widget_read(w, w->reg, &val); |
| 2789 | val = val >> w->shift; | ||
| 2786 | val &= w->mask; | 2790 | val &= w->mask; |
| 2787 | if (val == w->on_val) | 2791 | if (val == w->on_val) |
| 2788 | w->power = 1; | 2792 | w->power = 1; |
