mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: cs42l42: Some small code improvements
@ 2022-08-17 12:23 Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 1/5] ASoC: cs42l42: Don't include kernel.h Richard Fitzgerald
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

This is a collection of minor improvements to the code or comments.

Richard Fitzgerald (5):
  ASoC: cs42l42: Don't include kernel.h
  ASoC: cs42l42: Add include dependencies to cs42l42.h
  ASoC: cs42l42: Move cs42l42_supply_names to .c file
  ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put()
  ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk()

 sound/soc/codecs/cs42l42.c | 24 ++++++++++++++++--------
 sound/soc/codecs/cs42l42.h | 13 +++++--------
 2 files changed, 21 insertions(+), 16 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] ASoC: cs42l42: Don't include kernel.h
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
@ 2022-08-17 12:23 ` Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 2/5] ASoC: cs42l42: Add include dependencies to cs42l42.h Richard Fitzgerald
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

kernel.h includes a lot of other headers that we don't need.
Replace with an include of types.h.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index daafd4251ce6..9032dd1b9d57 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -12,7 +12,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/version.h>
-#include <linux/kernel.h>
+#include <linux/types.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/5] ASoC: cs42l42: Add include dependencies to cs42l42.h
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 1/5] ASoC: cs42l42: Don't include kernel.h Richard Fitzgerald
@ 2022-08-17 12:23 ` Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 3/5] ASoC: cs42l42: Move cs42l42_supply_names to .c file Richard Fitzgerald
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

Make cs42l42.h include the other headers it depends on instead of
assuming that the .c file already included them.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h
index 5f50970375d4..1d53e0e050ee 100644
--- a/sound/soc/codecs/cs42l42.h
+++ b/sound/soc/codecs/cs42l42.h
@@ -12,7 +12,12 @@
 #ifndef __CS42L42_H__
 #define __CS42L42_H__
 
+#include <dt-bindings/sound/cs42l42.h>
+#include <linux/device.h>
+#include <linux/gpio.h>
 #include <linux/mutex.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <sound/jack.h>
 #include <sound/cs42l42.h>
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/5] ASoC: cs42l42: Move cs42l42_supply_names to .c file
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 1/5] ASoC: cs42l42: Don't include kernel.h Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 2/5] ASoC: cs42l42: Add include dependencies to cs42l42.h Richard Fitzgerald
@ 2022-08-17 12:23 ` Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 4/5] ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put() Richard Fitzgerald
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

The array of supply name strings doesn't need to be in the header file.
Move it to the .c file.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 9 +++++++++
 sound/soc/codecs/cs42l42.h | 8 --------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 9032dd1b9d57..2235c17a0247 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -37,6 +37,14 @@
 #include "cs42l42.h"
 #include "cirrus_legacy.h"
 
+static const char * const cs42l42_supply_names[] = {
+	"VA",
+	"VP",
+	"VCP",
+	"VD_FILT",
+	"VL",
+};
+
 static const struct reg_default cs42l42_reg_defaults[] = {
 	{ CS42L42_FRZ_CTL,			0x00 },
 	{ CS42L42_SRC_CTL,			0x10 },
@@ -2215,6 +2223,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client)
 		return ret;
 	}
 
+	BUILD_BUG_ON(ARRAY_SIZE(cs42l42_supply_names) != ARRAY_SIZE(cs42l42->supplies));
 	for (i = 0; i < ARRAY_SIZE(cs42l42->supplies); i++)
 		cs42l42->supplies[i].supply = cs42l42_supply_names[i];
 
diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h
index 1d53e0e050ee..50299c9f283a 100644
--- a/sound/soc/codecs/cs42l42.h
+++ b/sound/soc/codecs/cs42l42.h
@@ -21,14 +21,6 @@
 #include <sound/jack.h>
 #include <sound/cs42l42.h>
 
-static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = {
-	"VA",
-	"VP",
-	"VCP",
-	"VD_FILT",
-	"VL",
-};
-
 struct  cs42l42_private {
 	struct regmap *regmap;
 	struct device *dev;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/5] ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put()
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
                   ` (2 preceding siblings ...)
  2022-08-17 12:23 ` [PATCH 3/5] ASoC: cs42l42: Move cs42l42_supply_names to .c file Richard Fitzgerald
@ 2022-08-17 12:23 ` Richard Fitzgerald
  2022-08-17 12:23 ` [PATCH 5/5] ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk() Richard Fitzgerald
  2022-08-17 17:05 ` [PATCH 0/5] ASoC: cs42l42: Some small code improvements Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

Fix "much change together" to "must change together".

It's probably obvious what was meant but it's nice to fix it.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 2235c17a0247..a84d873e29df 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -403,7 +403,7 @@ static int cs42l42_slow_start_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	u8 val;
 
-	/* all bits of SLOW_START_EN much change together */
+	/* all bits of SLOW_START_EN must change together */
 	switch (ucontrol->value.integer.value[0]) {
 	case 0:
 		val = 0;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/5] ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk()
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
                   ` (3 preceding siblings ...)
  2022-08-17 12:23 ` [PATCH 4/5] ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put() Richard Fitzgerald
@ 2022-08-17 12:23 ` Richard Fitzgerald
  2022-08-17 17:05 ` [PATCH 0/5] ASoC: cs42l42: Some small code improvements Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2022-08-17 12:23 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, linux-kernel, patches, Richard Fitzgerald

Use the new snd_soc_tdm_params_to_bclk() helper function to
calculate the bclk. This function handles most of the previous
manipulation and makes the code tidier.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index a84d873e29df..42cdb051e0fb 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -893,22 +893,21 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
 	struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
 	unsigned int channels = params_channels(params);
 	unsigned int width = (params_width(params) / 8) - 1;
+	unsigned int slot_width = 0;
 	unsigned int val = 0;
 	int ret;
 
 	cs42l42->srate = params_rate(params);
-	cs42l42->bclk = snd_soc_params_to_bclk(params);
-
-	/* I2S frame always has 2 channels even for mono audio */
-	if (channels == 1)
-		cs42l42->bclk *= 2;
 
 	/*
 	 * Assume 24-bit samples are in 32-bit slots, to prevent SCLK being
 	 * more than assumed (which would result in overclocking).
 	 */
 	if (params_width(params) == 24)
-		cs42l42->bclk = (cs42l42->bclk / 3) * 4;
+		slot_width = 32;
+
+	/* I2S frame always has multiple of 2 channels */
+	cs42l42->bclk = snd_soc_tdm_params_to_bclk(params, slot_width, 0, 2);
 
 	switch (substream->stream) {
 	case SNDRV_PCM_STREAM_CAPTURE:
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] ASoC: cs42l42: Some small code improvements
  2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
                   ` (4 preceding siblings ...)
  2022-08-17 12:23 ` [PATCH 5/5] ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk() Richard Fitzgerald
@ 2022-08-17 17:05 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2022-08-17 17:05 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: linux-kernel, patches, alsa-devel

On Wed, 17 Aug 2022 13:23:42 +0100, Richard Fitzgerald wrote:
> This is a collection of minor improvements to the code or comments.
> 
> Richard Fitzgerald (5):
>   ASoC: cs42l42: Don't include kernel.h
>   ASoC: cs42l42: Add include dependencies to cs42l42.h
>   ASoC: cs42l42: Move cs42l42_supply_names to .c file
>   ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put()
>   ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk()
> 
> [...]

Applied to

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

Thanks!

[1/5] ASoC: cs42l42: Don't include kernel.h
      commit: 8ccaa7eb76742579864ddf834a8ea9c036c2cc5a
[2/5] ASoC: cs42l42: Add include dependencies to cs42l42.h
      commit: b48d1da00fc8f32f7f75b8a34eb484f08b39ffaa
[3/5] ASoC: cs42l42: Move cs42l42_supply_names to .c file
      commit: dbd231732c99e336c2ece4a70896139e7f5a51a7
[4/5] ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put()
      commit: db568aab37c1af80057c12c97e6af049495c3e4a
[5/5] ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk()
      commit: c2683ecfd1850cc99829691b2e1d90f1a6d75b8b

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-17 17:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17 12:23 [PATCH 0/5] ASoC: cs42l42: Some small code improvements Richard Fitzgerald
2022-08-17 12:23 ` [PATCH 1/5] ASoC: cs42l42: Don't include kernel.h Richard Fitzgerald
2022-08-17 12:23 ` [PATCH 2/5] ASoC: cs42l42: Add include dependencies to cs42l42.h Richard Fitzgerald
2022-08-17 12:23 ` [PATCH 3/5] ASoC: cs42l42: Move cs42l42_supply_names to .c file Richard Fitzgerald
2022-08-17 12:23 ` [PATCH 4/5] ASoC: cs42l42: Fix comment typo in cs42l42_slow_start_put() Richard Fitzgerald
2022-08-17 12:23 ` [PATCH 5/5] ASoC: cs42l42: Use snd_soc_tdm_params_to_bclk() Richard Fitzgerald
2022-08-17 17:05 ` [PATCH 0/5] ASoC: cs42l42: Some small code improvements Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®