Skip to content

Commit 4be4768

Browse files
simontrimmerbroonie
authored andcommitted
ASoC: cs35l56: Remove redundant dsp_ready_completion
dsp_ready_completion is redundant and can be replaced by a call flush_work() to wait for cs35l56_dsp_work() to complete. As the dsp_work is queued by component_probe() it must run before other ASoC component callbacks and therefore there is no risk of calling flush_work() before the dsp_work() has been queued. Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230414133753.653139-5-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 440c2d3 commit 4be4768

2 files changed

Lines changed: 9 additions & 33 deletions

File tree

sound/soc/codecs/cs35l56.c

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,19 @@ static int cs35l56_mbox_send(struct cs35l56_private *cs35l56, unsigned int comma
5151
return 0;
5252
}
5353

54-
static int cs35l56_wait_dsp_ready(struct cs35l56_private *cs35l56)
54+
static void cs35l56_wait_dsp_ready(struct cs35l56_private *cs35l56)
5555
{
56-
int ret;
57-
58-
if (!cs35l56->fw_patched) {
59-
/* block until firmware download completes */
60-
ret = wait_for_completion_timeout(&cs35l56->dsp_ready_completion,
61-
msecs_to_jiffies(25000));
62-
if (!ret) {
63-
dev_err(cs35l56->dev, "dsp_ready_completion timeout\n");
64-
return -ETIMEDOUT;
65-
}
66-
}
67-
68-
return 0;
56+
/* Wait for patching to complete */
57+
flush_work(&cs35l56->dsp_work);
6958
}
7059

7160
static int cs35l56_dspwait_get_volsw(struct snd_kcontrol *kcontrol,
7261
struct snd_ctl_elem_value *ucontrol)
7362
{
7463
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
7564
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
76-
int ret = cs35l56_wait_dsp_ready(cs35l56);
77-
78-
if (ret)
79-
return ret;
8065

66+
cs35l56_wait_dsp_ready(cs35l56);
8167
return snd_soc_get_volsw(kcontrol, ucontrol);
8268
}
8369

@@ -86,11 +72,8 @@ static int cs35l56_dspwait_put_volsw(struct snd_kcontrol *kcontrol,
8672
{
8773
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
8874
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
89-
int ret = cs35l56_wait_dsp_ready(cs35l56);
90-
91-
if (ret)
92-
return ret;
9375

76+
cs35l56_wait_dsp_ready(cs35l56);
9477
return snd_soc_put_volsw(kcontrol, ucontrol);
9578
}
9679

@@ -876,13 +859,13 @@ static void cs35l56_dsp_work(struct work_struct *work)
876859
int ret = 0;
877860

878861
if (!cs35l56->init_done)
879-
goto complete;
862+
return;
880863

881864
cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x",
882865
cs35l56->secured ? "s" : "", cs35l56->rev);
883866

884867
if (!cs35l56->dsp.part)
885-
goto complete;
868+
return;
886869

887870
pm_runtime_get_sync(cs35l56->dev);
888871

@@ -961,9 +944,6 @@ static void cs35l56_dsp_work(struct work_struct *work)
961944
sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_MASK_1,
962945
CS35L56_SDW_INT_MASK_CODEC_IRQ);
963946
}
964-
965-
complete:
966-
complete_all(&cs35l56->dsp_ready_completion);
967947
}
968948

969949
static int cs35l56_component_probe(struct snd_soc_component *component)
@@ -1002,7 +982,6 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component,
1002982
enum snd_soc_bias_level level)
1003983
{
1004984
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
1005-
int ret = 0;
1006985

1007986
switch (level) {
1008987
case SND_SOC_BIAS_STANDBY:
@@ -1011,14 +990,14 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component,
1011990
* BIAS_OFF to BIAS_STANDBY
1012991
*/
1013992
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
1014-
ret = cs35l56_wait_dsp_ready(cs35l56);
993+
cs35l56_wait_dsp_ready(cs35l56);
1015994

1016995
break;
1017996
default:
1018997
break;
1019998
}
1020999

1021-
return ret;
1000+
return 0;
10221001
}
10231002

10241003
static const struct snd_soc_component_driver soc_component_dev_cs35l56 = {
@@ -1336,7 +1315,6 @@ int cs35l56_system_resume(struct device *dev)
13361315
return ret;
13371316

13381317
cs35l56->fw_patched = false;
1339-
init_completion(&cs35l56->dsp_ready_completion);
13401318
queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work);
13411319

13421320
/*
@@ -1358,7 +1336,6 @@ static int cs35l56_dsp_init(struct cs35l56_private *cs35l56)
13581336
return -ENOMEM;
13591337

13601338
INIT_WORK(&cs35l56->dsp_work, cs35l56_dsp_work);
1361-
init_completion(&cs35l56->dsp_ready_completion);
13621339

13631340
dsp = &cs35l56->dsp;
13641341
dsp->part = "cs35l56";

sound/soc/codecs/cs35l56.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ struct cs35l56_private {
3434
struct wm_adsp dsp; /* must be first member */
3535
struct work_struct dsp_work;
3636
struct workqueue_struct *dsp_wq;
37-
struct completion dsp_ready_completion;
3837
struct mutex irq_lock;
3938
struct snd_soc_component *component;
4039
struct device *dev;

0 commit comments

Comments
 (0)