ASoC: cs42l42: Remove redundant code
Subsystems (3)
Richard Fitzgerald
maintainerv2 cover ASoC: cs42l42: Remove redundant code
- Remove field writes in regmap_update_bits() calls where the code intends that the field value is not changed.
- Remove unnecessary complexity from reporting jack unplug event
- Remove a PLL config value member that was introduced in a bugfix but made redundant by a later bugfix.
Richard Fitzgerald (4):
ASoC: cs42l42: Remove redundant writes to DETECT_MODE
ASoC: cs42l42: Remove redundant writes to RS_PLUG/RS_UNPLUG masks
ASoC: cs42l42: Simplify reporting of jack unplug
ASoC: cs42l42: Remove redundant pll_divout member
sound/soc/codecs/cs42l42.c | 42 +++++++----------------------------------- sound/soc/codecs/cs42l42.h | 1 - 2 files changed, 7 insertions(+), 36 deletions(-)
Signature · 1 line
2.11.0
Richard Fitzgerald
maintainerPATCH v2 2/4 ASoC: cs42l42: Remove redundant writes to RS_PLUG/RS_UNPLUG masks
The RS_PLUG and RS_UNPLUG interrupt masks are always written as 1 so those writes are redundant and can be deleted.
This makes it completely clear in the code that only the TS_PLUG and TS_UNPLUG masks are being changed.
--- sound/soc/codecs/cs42l42.c | 8 -------- 1 file changed, 8 deletions(-)
sound/soc/codecs/cs42l42.c +0 -8
@@ -1320,12 +1320,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42)/* Unmask tip sense interrupts */ regmap_update_bits (cs42l42->regmap,CS42L42_TSRS_PLUG_INT_MASK , -CS42L42_RS_PLUG_MASK | -CS42L42_RS_UNPLUG_MASK |CS42L42_TS_PLUG_MASK |CS42L42_TS_UNPLUG_MASK , - (1 <<CS42L42_RS_PLUG_SHIFT ) | - (1 <<CS42L42_RS_UNPLUG_SHIFT ) | (0 <<CS42L42_TS_PLUG_SHIFT ) | (0 <<CS42L42_TS_UNPLUG_SHIFT )); }
@@ -1335,12 +1331,8 @@ static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42)/* Mask tip sense interrupts */ regmap_update_bits (cs42l42->regmap,CS42L42_TSRS_PLUG_INT_MASK , -CS42L42_RS_PLUG_MASK | -CS42L42_RS_UNPLUG_MASK |CS42L42_TS_PLUG_MASK |CS42L42_TS_UNPLUG_MASK , - (1 <<CS42L42_RS_PLUG_SHIFT ) | - (1 <<CS42L42_RS_UNPLUG_SHIFT ) | (1 <<CS42L42_TS_PLUG_SHIFT ) | (1 <<CS42L42_TS_UNPLUG_SHIFT ));
Signature · 1 line
2.11.0
Richard Fitzgerald
maintainerPATCH v2 3/4 ASoC: cs42l42: Simplify reporting of jack unplug
In reply to Richard FitzgeraldWhen reporting a jack unplug there's no need to make the reported flags conditional on which flags were reported during the plug event. It's perfectly safe to report all flags and buttons as not-present and let the higher code filter for changes.
There's also no need to make two separate snd_soc_jack_report() calls for presence flags and button flags. It can all be done in one report.
--- sound/soc/codecs/cs42l42.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
sound/soc/codecs/cs42l42.c +1 -11
@@ -1657,18 +1657,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) cs42l42->plug_state =CS42L42_TS_UNPLUG ;cs42l42_cancel_hs_type_detect (cs42l42); -switch (cs42l42->hs_type) { -case CS42L42_PLUG_CTIA : -case CS42L42_PLUG_OMTP : -snd_soc_jack_report (cs42l42->jack,0 ,SND_JACK_HEADSET ); -break ; -case CS42L42_PLUG_HEADPHONE : -snd_soc_jack_report (cs42l42->jack,0 ,SND_JACK_HEADPHONE ); -break ; -default : -break ; - }snd_soc_jack_report (cs42l42->jack,0 , +SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 );
Signature · 1 line
2.11.0
Richard Fitzgerald
maintainerPATCH v2 1/4 ASoC: cs42l42: Remove redundant writes to DETECT_MODE
In reply to Richard FitzgeraldThere are multiple places where DETECT_MODE is included in a register write, but in every case it is written as 0. Removing these redundant writes makes the code less cluttered and also makes it obvious that DETECT_MODE is never changed.
A single initialization to 0 is added to cs42l42_setup_hs_type_detect().
--- sound/soc/codecs/cs42l42.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
sound/soc/codecs/cs42l42.c +3 -10
@@ -1270,10 +1270,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42)/* Turn on level detect circuitry */ regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , -CS42L42_DETECT_MODE_MASK |CS42L42_HSBIAS_CTL_MASK |CS42L42_PDN_MIC_LVL_DET_MASK , - (0 <<CS42L42_DETECT_MODE_SHIFT ) | (3 <<CS42L42_HSBIAS_CTL_SHIFT ) | (0 <<CS42L42_PDN_MIC_LVL_DET_SHIFT ));
@@ -1300,10 +1298,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42)/* Make sure button detect and HS bias circuits are off */ regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , -CS42L42_DETECT_MODE_MASK |CS42L42_HSBIAS_CTL_MASK |CS42L42_PDN_MIC_LVL_DET_MASK , - (0 <<CS42L42_DETECT_MODE_SHIFT ) | (1 <<CS42L42_HSBIAS_CTL_SHIFT ) | (1 <<CS42L42_PDN_MIC_LVL_DET_SHIFT )); }
@@ -1351,10 +1347,8 @@ static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42)/* Make sure button detect and HS bias circuits are off */ regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , -CS42L42_DETECT_MODE_MASK |CS42L42_HSBIAS_CTL_MASK |CS42L42_PDN_MIC_LVL_DET_MASK , - (0 <<CS42L42_DETECT_MODE_SHIFT ) | (1 <<CS42L42_HSBIAS_CTL_SHIFT ) | (1 <<CS42L42_PDN_MIC_LVL_DET_SHIFT ));
@@ -1398,10 +1392,8 @@ static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42)/* Power up HS bias to 2.7V */ regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , -CS42L42_DETECT_MODE_MASK |CS42L42_HSBIAS_CTL_MASK |CS42L42_PDN_MIC_LVL_DET_MASK , - (0 <<CS42L42_DETECT_MODE_SHIFT ) | (3 <<CS42L42_HSBIAS_CTL_SHIFT ) | (1 <<CS42L42_PDN_MIC_LVL_DET_SHIFT ));
@@ -1448,10 +1440,8 @@ static void cs42l42_cancel_hs_type_detect(struct cs42l42_private *cs42l42)/* Ground HS bias */ regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , -CS42L42_DETECT_MODE_MASK |CS42L42_HSBIAS_CTL_MASK |CS42L42_PDN_MIC_LVL_DET_MASK , - (0 <<CS42L42_DETECT_MODE_SHIFT ) | (1 <<CS42L42_HSBIAS_CTL_SHIFT ) | (1 <<CS42L42_PDN_MIC_LVL_DET_SHIFT ));
@@ -1829,6 +1819,9 @@ static void cs42l42_setup_hs_type_detect(struct cs42l42_private *cs42l42) cs42l42->hs_type =CS42L42_PLUG_INVALID ; +regmap_update_bits (cs42l42->regmap,CS42L42_MISC_DET_CTL , +CS42L42_DETECT_MODE_MASK ,0 ); +/* Latch analog controls to VP power domain */ regmap_update_bits(cs42l42->regmap, CS42L42_MIC_DET_CTL1, CS42L42_LATCH_TO_VP_MASK |
Signature · 1 line
2.11.0
Richard Fitzgerald
maintainerPATCH v2 4/4 ASoC: cs42l42: Remove redundant pll_divout member
In reply to Richard FitzgeraldNow that struct cs42l42_private has pll_config, the current PLL configuration can be looked up directly in pll_ratio_table. This makes the pll_divout member of cs42l42_private redundant since it was only a copy of the value from pll_ratio_table.
--- sound/soc/codecs/cs42l42.c | 9 +++------ sound/soc/codecs/cs42l42.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-)
sound/soc/codecs/cs42l42.c +3 -6
@@ -734,10 +734,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component)CS42L42_PLL_DIVOUT_MASK , (pll_ratio_table[i].pll_divout * pll_ratio_table[i].n) << CS42L42_PLL_DIVOUT_SHIFT); -if (pll_ratio_table[i].n !=1 ) - cs42l42->pll_divout = pll_ratio_table[i].pll_divout; -else - cs42l42->pll_divout =0 ; snd_soc_component_update_bits(component, CS42L42_PLL_CAL_RATIO, CS42L42_PLL_CAL_RATIO_MASK,
@@ -1004,12 +1000,13 @@ static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream)snd_soc_component_update_bits (component,CS42L42_PLL_CTL1 ,CS42L42_PLL_START_MASK ,1 ); -if (cs42l42->pll_divout) { +if (pll_ratio_table[cs42l42->pll_config].n >1 ) {usleep_range (CS42L42_PLL_DIVOUT_TIME_US ,CS42L42_PLL_DIVOUT_TIME_US *2 ); + regval = pll_ratio_table[cs42l42->pll_config].pll_divout;snd_soc_component_update_bits (component,CS42L42_PLL_CTL3 ,CS42L42_PLL_DIVOUT_MASK , - cs42l42->pll_divout << + regval <<CS42L42_PLL_DIVOUT_SHIFT ); }
sound/soc/codecs/cs42l42.h +0 -1
@@ -845,7 +845,6 @@ struct cs42l42_private {int bclk;u32 sclk;u32 srate; -u8 pll_divout;u8 plug_state;u8 hs_type;u8 ts_inv;
Signature · 1 line
2.11.0
Mark Brown
maintainerQuoted 9 lines · Richard Fitzgerald
- Remove field writes in
regmap_update_bits()calls where the code intends that the field value is not changed.- Remove unnecessary complexity from reporting jack unplug event
- Remove a PLL config value member that was introduced in a bugfix but made redundant by a later bugfix.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: cs42l42: Remove redundant writes to DETECT_MODE
commit: 976001b10fa4441917f216452e70fd8c5aeccd94
[2/4] ASoC: cs42l42: Remove redundant writes to RS_PLUG/RS_UNPLUG masks
commit: f2dfbaaa5404cadf70213146a5b4b89b647d9092
[3/4] ASoC: cs42l42: Simplify reporting of jack unplug
commit: 3edde6de090617adea18f2068489086c0d8087e3
[4/4] ASoC: cs42l42: Remove redundant pll_divout member
commit: bbf0e1d36519a5cd2c08dc1348f997cd5240eb2eAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark