ASoC: remove dapm_update_bits()
PATCH 1/2 ASoC: remove dapm_update_bits()
dapm_update_bits() is only called in dapm_generic_apply_power(). And in turn, dapm_generic_apply_power() is only called in dapm_seq_run() when w->id is snd_soc_dapm_{input|output|hp|line|mic}. Under these cases, dapm_update_bits() is rather useless, because the below tests are always true:
/* check for valid widgets */
if (widget->reg < 0 || widget->id == snd_soc_dapm_input ||
widget->id == snd_soc_dapm_output ||
widget->id == snd_soc_dapm_hp ||
widget->id == snd_soc_dapm_mic ||
widget->id == snd_soc_dapm_line ||
widget->id == snd_soc_dapm_spk)
return 0;Therefore, we better omit this function for simplicity.
--- sound/soc/soc-dapm.c | 41 ----------------------------------------- 1 files changed, 0 insertions(+), 41 deletions(-)
sound/soc/soc-dapm.c +0 -41
@@ -322,45 +322,6 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,return -ENODEV ; } -/* update dapm codec register bits */ -static int dapm_update_bits (struct snd_soc_dapm_widget *widget) -{ -int change, power; -unsigned int old, new; -struct snd_soc_codec *codec = widget->codec; -struct snd_soc_dapm_context *dapm = widget->dapm; -struct snd_soc_card *card = dapm->card; - -/* check for valid widgets */ -if (widget->reg <0 || widget->id == snd_soc_dapm_input || - widget->id == snd_soc_dapm_output || - widget->id == snd_soc_dapm_hp || - widget->id == snd_soc_dapm_mic || - widget->id == snd_soc_dapm_line || - widget->id == snd_soc_dapm_spk) -return 0 ; - - power = widget->power; -if (widget->invert) - power = (power ?0 :1 ); - - old =snd_soc_read (codec, widget->reg); - new = (old & ~(0x1 << widget->shift)) | (power << widget->shift); - - change = old != new; -if (change) { -pop_dbg (dapm->dev, card->pop_time, -"pop test %s : %s in %d ms\n" , - widget->name, widget->power ?"on" :"off" , - card->pop_time); -pop_wait (card->pop_time); -snd_soc_write (codec, widget->reg, new); - } -dev_dbg (dapm->dev,"reg %x old %x new %x change %d\n" , widget->reg, - old, new, change); -return change; -} -/* create new dapm mixer control */ static int dapm_new_mixer (struct snd_soc_dapm_context *dapm,struct snd_soc_dapm_widget *w)
@@ -673,8 +634,6 @@ static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w)return ret; } -dapm_update_bits (w); -/* power up post event */ if (w->power && w->event && (w->event_flags &SND_SOC_DAPM_POST_PMU )) {
Signature · 1 line
1.7.2.3
PATCH 2/2 ASoC: rename dapm_generic_apply_power()
dapm_generic_apply_power() is only called in dapm_seq_run() when w->id is snd_soc_dapm_{input|output|hp|line|mic}. So, it's not a generic function at all, we better rename it to reflect what it's doing.
--- sound/soc/soc-dapm.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +4 -4
@@ -605,10 +605,10 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w, }EXPORT_SYMBOL_GPL (dapm_reg_event); -/* Standard power change method, used to apply power changes to most -* widgets. +/* +* power change method, used for input, output, hp, line, spk, mic. */ -static int dapm_generic_apply_power (struct snd_soc_dapm_widget *w) +static int dapm_input_output_apply_power (struct snd_soc_dapm_widget *w) {int ret;
@@ -947,7 +947,7 @@ static void dapm_seq_run(struct snd_soc_dapm_context *dapm,case snd_soc_dapm_line:case snd_soc_dapm_spk:/* No register support currently */ - ret =dapm_generic_apply_power (w); + ret =dapm_input_output_apply_power (w);break ;default :
Signature · 1 line
1.7.2.3
Re: [PATCH 2/2] ASoC: rename dapm_generic_apply_power()
Quoted 3 lines · Lu Guanqun
dapm_generic_apply_power()is only called indapm_seq_run()whenw->idis snd_soc_dapm_{input|output|hp|line|mic}. So, it's not a generic function at all, we better rename it to reflect what it's doing.
I don't think you've really understood what the code is doing here. While it's true that we don't ever call this function for most widget types due to the write compression code it is actually the generic method for applying power changes to a widget in isolation - it does a register update surrounded by the event callbacks in the appropriate sequence which really is something that is generic to all widgets. A better question if you want to refector the code here would be why these widgets are treated differently to other widgets.
Re: [PATCH 2/2] ASoC: rename dapm_generic_apply_power()
Hi Mark,
Quoted 8 lines · Mark Brown
Quoted 3 lines · Lu Guanqun
dapm_generic_apply_power()is only called indapm_seq_run()whenw->idis snd_soc_dapm_{input|output|hp|line|mic}. So, it's not a generic function at all, we better rename it to reflect what it's doing.I don't think you've really understood what the code is doing here. While it's true that we don't ever call this function for most widget types due to the write compression code it is actually the generic
I don't get into write compression code yet, do you mean by "coalesce register writes", that part of code?
Quoted 5 lines
method for applying power changes to a widget in isolation - it does a register update surrounded by the event callbacks in the appropriate sequence which really is something that is generic to all widgets. A better question if you want to refector the code here would be why these widgets are treated differently to other widgets.
Signature · 1 line
guanqun
Re: [PATCH 2/2] ASoC: rename dapm_generic_apply_power()
Quoted 8 lines · Lu Guanqun
Quoted 3 lines · Mark Brown
I don't think you've really understood what the code is doing here. While it's true that we don't ever call this function for most widget types due to the write compression code it is actually the generic
I don't get into write compression code yet, do you mean by "coalesce register writes", that part of code?
Yes.