ASoC: rt1015: apply some refactors
Subsystems (3)
cover ASoC: rt1015: apply some refactors
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(-)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 1/5 ASoC: rt1015: sort header inclusions
Sorts header inclusions. ASCII value of 'r' is less than 's'.
--- sound/soc/codecs/rt1015.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1015.c +1 -1
@@ -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"
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 2/5 ASoC: rt1015: save boost_mode only if valid
In reply to Tzung-Bi ShihSaves boost_mode only if valid. Also returns -EINVAL if it is invalid.
--- sound/soc/codecs/rt1015.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/codecs/rt1015.c +5 -3
@@ -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 ; }
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 3/5 ASoC: rt1015: return error if any when setting bypass_boost
In reply to Tzung-Bi ShihReturns -EBUSY if DAC is using when setting bypass_boost.
--- sound/soc/codecs/rt1015.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
sound/soc/codecs/rt1015.c +11 -9
@@ -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 ; }
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 4/5 ASoC: rt1015: refactor retry loop and rt1015_priv allocation
In reply to Tzung-Bi ShihRefactors retry loop in flush DAC work. It is more clear to use a for-loop here.
Uses !rt1015 to check if NULL.
--- sound/soc/codecs/rt1015.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1015.c +4 -6
@@ -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);
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 5/5 ASoC: rt1015: remove unneeded variables in rt1015_priv
In reply to Tzung-Bi Shih- `lrck' is only used in .hw_params callback so that it can be local.
- `bclk' is unused.
- `id' is unused.
- `amp_ver' is unused.
--- sound/soc/codecs/rt1015.c | 9 ++++----- sound/soc/codecs/rt1015.h | 4 ---- 2 files changed, 4 insertions(+), 9 deletions(-)
sound/soc/codecs/rt1015.c +4 -5
@@ -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 :
sound/soc/codecs/rt1015.h +0 -4
@@ -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;
Signature · 1 line
2.29.2.729.g45daf8777d-goog
Mark Brown
maintainerQuoted 9 lines · Tzung-Bi Shih
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: a5db2ca51367eeafb0c4013d3a6fc58932612c03All 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