diff mbox series

[2/7] ASoC: cs42l43: Minor code tidy ups

Message ID 20240124165558.1876407-2-ckeepax@opensource.cirrus.com (mailing list archive)
State Superseded
Headers show
Series [1/7] ASoC: cs42l43: Tidy up header includes | expand

Commit Message

Charles Keepax Jan. 24, 2024, 4:55 p.m. UTC
Add some missing commas, refactor a couple small bits of code.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43-jack.c |  8 ++++----
 sound/soc/codecs/cs42l43.c      | 12 ++++--------
 2 files changed, 8 insertions(+), 12 deletions(-)

Comments

Andy Shevchenko Jan. 24, 2024, 10:22 p.m. UTC | #1
On Wed, Jan 24, 2024 at 6:56 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
>
> Add some missing commas, refactor a couple small bits of code.

...

> -       BUILD_BUG_ON(ARRAY_SIZE(cs42l43_jack_override_modes) !=
> -                    ARRAY_SIZE(cs42l43_jack_text) - 1);
> +       static_assert(ARRAY_SIZE(cs42l43_jack_override_modes) ==
> +                     ARRAY_SIZE(cs42l43_jack_text) - 1);

Now you can move this closer to the both array definitions (as
static_assert() can be global, and basically that is the idea behind
it, besides nicer error messaging).
diff mbox series

Patch

diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c
index 1d8d7bf0a6b0d..d0569577a8699 100644
--- a/sound/soc/codecs/cs42l43-jack.c
+++ b/sound/soc/codecs/cs42l43-jack.c
@@ -29,11 +29,11 @@ 
 #include "cs42l43.h"
 
 static const unsigned int cs42l43_accdet_us[] = {
-	20, 100, 1000, 10000, 50000, 75000, 100000, 200000
+	20, 100, 1000, 10000, 50000, 75000, 100000, 200000,
 };
 
 static const unsigned int cs42l43_accdet_db_ms[] = {
-	0, 125, 250, 500, 750, 1000, 1250, 1500
+	0, 125, 250, 500, 750, 1000, 1250, 1500,
 };
 
 static const unsigned int cs42l43_accdet_ramp_ms[] = { 10, 40, 90, 170 };
@@ -873,8 +873,8 @@  int cs42l43_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int override = ucontrol->value.integer.value[0];
 
-	BUILD_BUG_ON(ARRAY_SIZE(cs42l43_jack_override_modes) !=
-		     ARRAY_SIZE(cs42l43_jack_text) - 1);
+	static_assert(ARRAY_SIZE(cs42l43_jack_override_modes) ==
+		      ARRAY_SIZE(cs42l43_jack_text) - 1);
 
 	if (override >= e->items)
 		return -EINVAL;
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index f2332f90f8337..d418c0b0ce9aa 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -1059,12 +1059,10 @@  static int cs42l43_decim_get(struct snd_kcontrol *kcontrol,
 	int ret;
 
 	ret = cs42l43_shutter_get(priv, CS42L43_STATUS_MIC_SHUTTER_MUTE_SHIFT);
-	if (ret < 0)
-		return ret;
+	if (ret > 0)
+		ret = cs42l43_dapm_get_volsw(kcontrol, ucontrol);
 	else if (!ret)
 		ucontrol->value.integer.value[0] = ret;
-	else
-		ret = cs42l43_dapm_get_volsw(kcontrol, ucontrol);
 
 	return ret;
 }
@@ -1077,12 +1075,10 @@  static int cs42l43_spk_get(struct snd_kcontrol *kcontrol,
 	int ret;
 
 	ret = cs42l43_shutter_get(priv, CS42L43_STATUS_SPK_SHUTTER_MUTE_SHIFT);
-	if (ret < 0)
-		return ret;
+	if (ret > 0)
+		ret = snd_soc_get_volsw(kcontrol, ucontrol);
 	else if (!ret)
 		ucontrol->value.integer.value[0] = ret;
-	else
-		ret = snd_soc_get_volsw(kcontrol, ucontrol);
 
 	return ret;
 }