Skip to contentSkip to conversation

ASoC: codecs: wcd938x/wcd934x: loglevel fix and cleanups

PATCH In review Johan Hovold 3 participants 10 messages Jun 30, 2023 – Jul 3, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: codecs: wcd938x/wcd934x: loglevel fix and cleanups

When investigating a race in the wcd938x driver I noticed that the MBHC impedance measurements where printed at error loglevel which is clearly wrong.

Fix that, and clean up the logging somewhat by using dev_printk() and addressing some style issues.

Included are also two patches that drop the bogus inline keywords from the functions involved.

Johan

Johan Hovold (5):
ASoC: codecs: wcd938x: fix mbhc impedance loglevel
ASoC: codecs: wcd938x: drop inline keywords
ASoC: codecs: wcd938x: use dev_printk() for impedance logging
ASoC: codecs: wcd934x: demote impedance printk loglevel
ASoC: codecs: wcd934x: drop inline keywords

 sound/soc/codecs/wcd934x.c |  8 ++++----
 sound/soc/codecs/wcd938x.c | 17 +++++++++--------
 2 files changed, 13 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.3
#1 lore raw

PATCH 1/5 ASoC: codecs: wcd938x: fix mbhc impedance loglevel

Demote the MBHC impedance measurement printk, which is not an error message, from error to debug level.

While at it, fix the capitalisation of "ohm" and add the missing space before the opening parenthesis.

Fixes bcee7ed09b8e ("ASoC: codecs: wcd938x: add Multi Button Headset Control support")
---
 sound/soc/codecs/wcd938x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wcd938x.c +2 -2
index e3ae4fb2c4db..b8a52a1a63d5 100644
@@ -2165,8 +2165,8 @@ static inline void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
 	else if (x1 < minCode_param[noff])
 		*zdet = WCD938X_ZDET_FLOATING_IMPEDANCE;
 
-	pr_err("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
-		__func__, d1, c1, x1, *zdet);
+	pr_debug("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d (milliohm)\n",
+		 __func__, d1, c1, x1, *zdet);
 ramp_down:
 	i = 0;
 	while (x1) {
Signature · 1 line
2.39.3
maintainer
#2 lore raw

Re: [PATCH 1/5] ASoC: codecs: wcd938x: fix mbhc impedance loglevel

sound/soc/codecs/wcd938x.c static inline void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x, · line 2169

Quoted 4 lines · Johan Hovold
sound/soc/codecs/wcd938x.c +2 -2
-	pr_err("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
-		__func__, d1, c1, x1, *zdet);
+	pr_debug("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d (milliohm)\n",
+		 __func__, d1, c1, x1, *zdet);

Indeed we should really be able to arrange to make this a dev_dbg().

#3 lore raw

PATCH 2/5 ASoC: codecs: wcd938x: drop inline keywords

In reply to Johan Hovold

The compiler is generally better at deciding what functions should be inlined than driver authors are.

Drop the bogus inline keyword from two functions that were neither very small or used in a single place.

---
 sound/soc/codecs/wcd938x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wcd938x.c +3 -3
index b8a52a1a63d5..5ce15b622a91 100644
@@ -2124,7 +2124,7 @@ static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *compon
 	return wcd938x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2);
 }
 
-static inline void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
+static void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
 						s16 *d1_a, u16 noff,
 						int32_t *zdet)
 {
@@ -2231,8 +2231,8 @@ static void wcd938x_mbhc_zdet_ramp(struct snd_soc_component *component,
 	*zr = zdet;
 }
 
-static inline void wcd938x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
-					      int32_t *z_val, int flag_l_r)
+static void wcd938x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
+					int32_t *z_val, int flag_l_r)
 {
 	s16 q1;
 	int q1_cal;
Signature · 1 line
2.39.3
#4 lore raw

PATCH 3/5 ASoC: codecs: wcd938x: use dev_printk() for impedance logging

In reply to Johan Hovold

Pass the component structure also to the wcd938x_mbhc_get_result_params() helper so that the component device can be used for logging consistently.

---
 sound/soc/codecs/wcd938x.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
sound/soc/codecs/wcd938x.c +8 -7
index 5ce15b622a91..ddefe4af0b1e 100644
@@ -2124,10 +2124,11 @@ static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *compon
 	return wcd938x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2);
 }
 
-static void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
+static void wcd938x_mbhc_get_result_params(struct snd_soc_component *component,
 						s16 *d1_a, u16 noff,
 						int32_t *zdet)
 {
+	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
 	int i;
 	int val, val1;
 	s16 c1;
@@ -2154,8 +2155,8 @@ static void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
 		usleep_range(5000, 5050);
 
 	if (!c1 || !x1) {
-		pr_err("%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
-			__func__, c1, x1);
+		dev_err(component->dev, "Impedance detect ramp error, c1=%d, x1=0x%x\n",
+			c1, x1);
 		goto ramp_down;
 	}
 	d1 = d1_a[c1];
@@ -2165,8 +2166,8 @@ static void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x,
 	else if (x1 < minCode_param[noff])
 		*zdet = WCD938X_ZDET_FLOATING_IMPEDANCE;
 
-	pr_debug("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d (milliohm)\n",
-		 __func__, d1, c1, x1, *zdet);
+	dev_dbg(component->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d (milliohm)\n",
+		__func__, d1, c1, x1, *zdet);
 ramp_down:
 	i = 0;
 	while (x1) {
@@ -2210,7 +2211,7 @@ static void wcd938x_mbhc_zdet_ramp(struct snd_soc_component *component,
 			   WCD938X_ANA_MBHC_ZDET, 0x80, 0x80);
 	dev_dbg(component->dev, "%s: ramp for HPH_L, noff = %d\n",
 		__func__, zdet_param->noff);
-	wcd938x_mbhc_get_result_params(wcd938x, d1_a, zdet_param->noff, &zdet);
+	wcd938x_mbhc_get_result_params(component, d1_a, zdet_param->noff, &zdet);
 	regmap_update_bits(wcd938x->regmap,
 			   WCD938X_ANA_MBHC_ZDET, 0x80, 0x00);
 
@@ -2224,7 +2225,7 @@ static void wcd938x_mbhc_zdet_ramp(struct snd_soc_component *component,
 			   WCD938X_ANA_MBHC_ZDET, 0x40, 0x40);
 	dev_dbg(component->dev, "%s: ramp for HPH_R, noff = %d\n",
 		__func__, zdet_param->noff);
-	wcd938x_mbhc_get_result_params(wcd938x, d1_a, zdet_param->noff, &zdet);
+	wcd938x_mbhc_get_result_params(component, d1_a, zdet_param->noff, &zdet);
 	regmap_update_bits(wcd938x->regmap,
 			   WCD938X_ANA_MBHC_ZDET, 0x40, 0x00);
 
Signature · 1 line
2.39.3
maintainer
#5 lore raw

Re: [PATCH 3/5] ASoC: codecs: wcd938x: use dev_printk() for impedance logging

Quoted 3 lines · Johan Hovold

Pass the component structure also to the wcd938x_mbhc_get_result_params() helper so that the component device can be used for logging consistently.

Ah, in fact here we are.

#6 lore raw

PATCH 4/5 ASoC: codecs: wcd934x: demote impedance printk

In reply to Johan Hovold

Demote the MBHC impedance measurement printk, which is only needed for development and debugging, to debug level.

While at it, fix the capitalisation of "ohm" and add the missing space before the opening parenthesis.

---
 sound/soc/codecs/wcd934x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wcd934x.c +1 -1
index c0d1fa36d841..9d724b5710f7 100644
@@ -2683,7 +2683,7 @@ static inline void wcd934x_mbhc_get_result_params(struct wcd934x_codec *wcd934x,
 	else if (x1 < minCode_param[noff])
 		*zdet = WCD934X_ZDET_FLOATING_IMPEDANCE;
 
-	dev_info(wcd934x->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
+	dev_dbg(wcd934x->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%di (milliohm)\n",
 		__func__, d1, c1, x1, *zdet);
 ramp_down:
 	i = 0;
Signature · 1 line
2.39.3
#7 lore raw

PATCH 5/5 ASoC: codecs: wcd934x: drop inline keywords

In reply to Johan Hovold

The compiler is generally better at deciding what functions should be inlined than driver authors are.

Drop the bogus inline keyword from two functions that were neither very small or used in a single place.

---
 sound/soc/codecs/wcd934x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wcd934x.c +3 -3
index 9d724b5710f7..a17cd75b969b 100644
@@ -2642,7 +2642,7 @@ static int wcd934x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *compon
 	return rc;
 }
 
-static inline void wcd934x_mbhc_get_result_params(struct wcd934x_codec *wcd934x,
+static void wcd934x_mbhc_get_result_params(struct wcd934x_codec *wcd934x,
 						s16 *d1_a, u16 noff,
 						int32_t *zdet)
 {
@@ -2740,8 +2740,8 @@ static void wcd934x_mbhc_zdet_ramp(struct snd_soc_component *component,
 	*zr = zdet;
 }
 
-static inline void wcd934x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
-					      int32_t *z_val, int flag_l_r)
+static void wcd934x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
+					int32_t *z_val, int flag_l_r)
 {
 	s16 q1;
 	int q1_cal;
Signature · 1 line
2.39.3
Reviewed-by on the v1 series
#8 lore raw
In reply to Johan Hovold
Quoted 13 lines · Johan Hovold

When investigating a race in the wcd938x driver I noticed that the MBHC impedance measurements where printed at error loglevel which is clearly wrong.

Fix that, and clean up the logging somewhat by using dev_printk() and addressing some style issues.

Included are also two patches that drop the bogus inline keywords from the functions involved.

Johan

Quoted 7 lines

Johan Hovold (5):
ASoC: codecs: wcd938x: fix mbhc impedance loglevel
ASoC: codecs: wcd938x: drop inline keywords
ASoC: codecs: wcd938x: use dev_printk() for impedance logging
ASoC: codecs: wcd934x: demote impedance printk loglevel
ASoC: codecs: wcd934x: drop inline keywords

lgtm,

--srini

Quoted 4 lines
  sound/soc/codecs/wcd934x.c |  8 ++++----
  sound/soc/codecs/wcd938x.c | 17 +++++++++--------
  2 files changed, 13 insertions(+), 12 deletions(-)
maintainer
#9 lore raw
In reply to Johan Hovold
Quoted 8 lines · Johan Hovold

When investigating a race in the wcd938x driver I noticed that the MBHC impedance measurements where printed at error loglevel which is clearly wrong.

Fix that, and clean up the logging somewhat by using dev_printk() and addressing some style issues.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: codecs: wcd938x: fix mbhc impedance loglevel

      commit: e5ce198bd5c6923b6a51e1493b1401f84c24b26d
[2/5] ASoC: codecs: wcd938x: drop inline keywords
      commit: 5db9fe9562aaefca3c972401a9e3d6454707b1d5
[3/5] ASoC: codecs: wcd938x: use dev_printk() for impedance logging
      commit: 17d59d9ed832742f9572fe5e77ed3a66f5ae404d
[4/5] ASoC: codecs: wcd934x: demote impedance printk
      commit: cb7d60ab98cfe12fdd6052142176d42682f78540
[5/5] ASoC: codecs: wcd934x: drop inline keywords
      commit: c93723ada378a63929b3135b4f30483383e88e05

All 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