All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: rt1015: apply some refactors
@ 2020-12-24 10:06 Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 1/5] ASoC: rt1015: sort header inclusions Tzung-Bi Shih
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

The series refactors rt1015.c.

The 1st patch sorts header inclusions alphabetically.

The 2nd and 3rd patch improve error handling for kcontrols.

The 4th patch enhances readability.

The 5th patch removes unused variables in rt1015_priv.

Tzung-Bi Shih (5):
  ASoC: rt1015: sort header inclusions
  ASoC: rt1015: save boost_mode only if valid
  ASoC: rt1015: return error if any when setting bypass_boost
  ASoC: rt1015: refactor retry loop and rt1015_priv allocation
  ASoC: rt1015: remove unneeded variables in rt1015_priv

 sound/soc/codecs/rt1015.c | 49 ++++++++++++++++++++-------------------
 sound/soc/codecs/rt1015.h |  4 ----
 2 files changed, 25 insertions(+), 28 deletions(-)

-- 
2.29.2.729.g45daf8777d-goog


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

* [PATCH 1/5] ASoC: rt1015: sort header inclusions
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
@ 2020-12-24 10:06 ` Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 2/5] ASoC: rt1015: save boost_mode only if valid Tzung-Bi Shih
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

Sorts header inclusions.  ASCII value of 'r' is less than 's'.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 32e6bcf763d1..1a29d3d5263e 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -24,10 +24,10 @@
 #include <sound/initval.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/rt1015.h>
 #include <sound/soc-dapm.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
-#include <sound/rt1015.h>
 
 #include "rl6231.h"
 #include "rt1015.h"
-- 
2.29.2.729.g45daf8777d-goog


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

* [PATCH 2/5] ASoC: rt1015: save boost_mode only if valid
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 1/5] ASoC: rt1015: sort header inclusions Tzung-Bi Shih
@ 2020-12-24 10:06 ` Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 3/5] ASoC: rt1015: return error if any when setting bypass_boost Tzung-Bi Shih
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

Saves boost_mode only if valid.  Also returns -EINVAL if it is invalid.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 1a29d3d5263e..696e00478991 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -444,10 +444,9 @@ static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol,
 		snd_soc_kcontrol_component(kcontrol);
 	struct rt1015_priv *rt1015 =
 		snd_soc_component_get_drvdata(component);
+	int boost_mode = ucontrol->value.integer.value[0];
 
-	rt1015->boost_mode = ucontrol->value.integer.value[0];
-
-	switch (rt1015->boost_mode) {
+	switch (boost_mode) {
 	case BYPASS:
 		snd_soc_component_update_bits(component,
 			RT1015_SMART_BST_CTRL1, RT1015_ABST_AUTO_EN_MASK |
@@ -471,8 +470,11 @@ static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol,
 		break;
 	default:
 		dev_err(component->dev, "Unknown boost control.\n");
+		return -EINVAL;
 	}
 
+	rt1015->boost_mode = boost_mode;
+
 	return 0;
 }
 
-- 
2.29.2.729.g45daf8777d-goog


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

* [PATCH 3/5] ASoC: rt1015: return error if any when setting bypass_boost
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 1/5] ASoC: rt1015: sort header inclusions Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 2/5] ASoC: rt1015: save boost_mode only if valid Tzung-Bi Shih
@ 2020-12-24 10:06 ` Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 4/5] ASoC: rt1015: refactor retry loop and rt1015_priv allocation Tzung-Bi Shih
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

Returns -EBUSY if DAC is using when setting bypass_boost.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 696e00478991..93e4763ece11 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -548,17 +548,19 @@ static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,
 	struct rt1015_priv *rt1015 =
 		snd_soc_component_get_drvdata(component);
 
-	if (!rt1015->dac_is_used) {
-		rt1015->bypass_boost = ucontrol->value.integer.value[0];
-		if (rt1015->bypass_boost == RT1015_Bypass_Boost &&
+	if (rt1015->dac_is_used) {
+		dev_err(component->dev, "DAC is being used!\n");
+		return -EBUSY;
+	}
+
+	rt1015->bypass_boost = ucontrol->value.integer.value[0];
+	if (rt1015->bypass_boost == RT1015_Bypass_Boost &&
 			!rt1015->cali_done) {
-			rt1015_calibrate(rt1015);
-			rt1015->cali_done = 1;
+		rt1015_calibrate(rt1015);
+		rt1015->cali_done = 1;
 
-			regmap_write(rt1015->regmap, RT1015_MONO_DYNA_CTRL, 0x0010);
-		}
-	} else
-		dev_err(component->dev, "DAC is being used!\n");
+		regmap_write(rt1015->regmap, RT1015_MONO_DYNA_CTRL, 0x0010);
+	}
 
 	return 0;
 }
-- 
2.29.2.729.g45daf8777d-goog


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

* [PATCH 4/5] ASoC: rt1015: refactor retry loop and rt1015_priv allocation
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
                   ` (2 preceding siblings ...)
  2020-12-24 10:06 ` [PATCH 3/5] ASoC: rt1015: return error if any when setting bypass_boost Tzung-Bi Shih
@ 2020-12-24 10:06 ` Tzung-Bi Shih
  2020-12-24 10:06 ` [PATCH 5/5] ASoC: rt1015: remove unneeded variables in rt1015_priv Tzung-Bi Shih
  2020-12-29 14:31 ` [PATCH 0/5] ASoC: rt1015: apply some refactors Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

Refactors retry loop in flush DAC work.  It is more clear to use a
for-loop here.

Uses !rt1015 to check if NULL.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 93e4763ece11..a7b9dfcb4b0f 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -570,15 +570,14 @@ static void rt1015_flush_work(struct work_struct *work)
 	struct rt1015_priv *rt1015 = container_of(work, struct rt1015_priv,
 						flush_work.work);
 	struct snd_soc_component *component = rt1015->component;
-	unsigned int val, i = 0, count = 200;
+	unsigned int val, i;
 
-	while (i < count) {
+	for (i = 0; i < 200; ++i) {
 		usleep_range(1000, 1500);
 		dev_dbg(component->dev, "Flush DAC (retry:%u)\n", i);
 		regmap_read(rt1015->regmap, RT1015_CLK_DET, &val);
 		if (val & 0x800)
 			break;
-		i++;
 	}
 
 	regmap_write(rt1015->regmap, RT1015_SYS_RST1, 0x0597);
@@ -1187,9 +1186,8 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
 	int ret;
 	unsigned int val;
 
-	rt1015 = devm_kzalloc(&i2c->dev, sizeof(struct rt1015_priv),
-				GFP_KERNEL);
-	if (rt1015 == NULL)
+	rt1015 = devm_kzalloc(&i2c->dev, sizeof(*rt1015), GFP_KERNEL);
+	if (!rt1015)
 		return -ENOMEM;
 
 	i2c_set_clientdata(i2c, rt1015);
-- 
2.29.2.729.g45daf8777d-goog


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

* [PATCH 5/5] ASoC: rt1015: remove unneeded variables in rt1015_priv
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
                   ` (3 preceding siblings ...)
  2020-12-24 10:06 ` [PATCH 4/5] ASoC: rt1015: refactor retry loop and rt1015_priv allocation Tzung-Bi Shih
@ 2020-12-24 10:06 ` Tzung-Bi Shih
  2020-12-29 14:31 ` [PATCH 0/5] ASoC: rt1015: apply some refactors Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2020-12-24 10:06 UTC (permalink / raw)
  To: broonie; +Cc: tzungbi, alsa-devel

- `lrck' is only used in .hw_params callback so that it can be local.
- `bclk' is unused.
- `id' is unused.
- `amp_ver' is unused.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015.c | 9 ++++-----
 sound/soc/codecs/rt1015.h | 4 ----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index a7b9dfcb4b0f..4a9e2eaebe30 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -724,11 +724,11 @@ static int rt1015_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_component *component = dai->component;
 	struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component);
-	int pre_div, bclk_ms, frame_size;
+	int pre_div, bclk_ms, frame_size, lrck;
 	unsigned int val_len = 0;
 
-	rt1015->lrck = params_rate(params);
-	pre_div = rl6231_get_clk_info(rt1015->sysclk, rt1015->lrck);
+	lrck = params_rate(params);
+	pre_div = rl6231_get_clk_info(rt1015->sysclk, lrck);
 	if (pre_div < 0) {
 		dev_err(component->dev, "Unsupported clock rate\n");
 		return -EINVAL;
@@ -742,13 +742,12 @@ static int rt1015_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	bclk_ms = frame_size > 32;
-	rt1015->bclk = rt1015->lrck * (32 << bclk_ms);
 
 	dev_dbg(component->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
 				bclk_ms, pre_div, dai->id);
 
 	dev_dbg(component->dev, "lrck is %dHz and pre_div is %d for iis %d\n",
-				rt1015->lrck, pre_div, dai->id);
+				lrck, pre_div, dai->id);
 
 	switch (params_width(params)) {
 	case 16:
diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h
index b6ea753014e1..e9b498a754e0 100644
--- a/sound/soc/codecs/rt1015.h
+++ b/sound/soc/codecs/rt1015.h
@@ -427,16 +427,12 @@ struct rt1015_priv {
 	struct regmap *regmap;
 	int sysclk;
 	int sysclk_src;
-	int lrck;
-	int bclk;
 	int bclk_ratio;
-	int id;
 	int pll_src;
 	int pll_in;
 	int pll_out;
 	int boost_mode;
 	int bypass_boost;
-	int amp_ver;
 	int dac_is_used;
 	int cali_done;
 	int hw_config;
-- 
2.29.2.729.g45daf8777d-goog


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

* Re: [PATCH 0/5] ASoC: rt1015: apply some refactors
  2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
                   ` (4 preceding siblings ...)
  2020-12-24 10:06 ` [PATCH 5/5] ASoC: rt1015: remove unneeded variables in rt1015_priv Tzung-Bi Shih
@ 2020-12-29 14:31 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-12-29 14:31 UTC (permalink / raw)
  To: Tzung-Bi Shih; +Cc: alsa-devel

On Thu, 24 Dec 2020 18:06:02 +0800, Tzung-Bi Shih wrote:
> The series refactors rt1015.c.
> 
> The 1st patch sorts header inclusions alphabetically.
> 
> The 2nd and 3rd patch improve error handling for kcontrols.
> 
> The 4th patch enhances readability.
> 
> [...]

Applied to

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

Thanks!

[1/5] ASoC: rt1015: sort header inclusions
      commit: 4ac275eda0d7bf6f222ad0093ffbdfd2f4228eaa
[2/5] ASoC: rt1015: save boost_mode only if valid
      commit: bf1eb056ac15a058fb5e254307f14f45efbe79d8
[3/5] ASoC: rt1015: return error if any when setting bypass_boost
      commit: e48b41e903a102744827661080acd500b7bbef26
[4/5] ASoC: rt1015: refactor retry loop and rt1015_priv allocation
      commit: 3128f1c3b53d73e35e1069663736284358fcdd01
[5/5] ASoC: rt1015: remove unneeded variables in rt1015_priv
      commit: a5db2ca51367eeafb0c4013d3a6fc58932612c03

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:[~2020-12-29 14:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24 10:06 [PATCH 0/5] ASoC: rt1015: apply some refactors Tzung-Bi Shih
2020-12-24 10:06 ` [PATCH 1/5] ASoC: rt1015: sort header inclusions Tzung-Bi Shih
2020-12-24 10:06 ` [PATCH 2/5] ASoC: rt1015: save boost_mode only if valid Tzung-Bi Shih
2020-12-24 10:06 ` [PATCH 3/5] ASoC: rt1015: return error if any when setting bypass_boost Tzung-Bi Shih
2020-12-24 10:06 ` [PATCH 4/5] ASoC: rt1015: refactor retry loop and rt1015_priv allocation Tzung-Bi Shih
2020-12-24 10:06 ` [PATCH 5/5] ASoC: rt1015: remove unneeded variables in rt1015_priv Tzung-Bi Shih
2020-12-29 14:31 ` [PATCH 0/5] ASoC: rt1015: apply some refactors Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.