Skip to content

Commit 49b0dea

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda: hda_cs_dsp_ctl: Minor clean and redundant code removal
The cs_dsp core will return an error if passed a NULL cs_dsp struct so there is no need for the hda_cs_dsp_write|read_ctl functions to manually check that. The cs_dsp core will also check the data is within bounds of the control so the additional bounds check is redundant too. Simplify things a bit by removing said code. Signed-off-by: Stefan Binding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 97d9178 commit 49b0dea

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

sound/pci/hda/hda_cs_dsp_ctl.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,19 @@ EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_control_remove, SND_HDA_CS_DSP_CONTROLS);
199199
int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
200200
unsigned int alg, const void *buf, size_t len)
201201
{
202-
struct cs_dsp_coeff_ctl *cs_ctl;
202+
struct cs_dsp_coeff_ctl *cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
203203
struct hda_cs_dsp_coeff_ctl *ctl;
204204
int ret;
205205

206-
cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
207-
if (!cs_ctl)
208-
return -EINVAL;
209-
210-
ctl = cs_ctl->priv;
211-
212206
ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len);
213207
if (ret)
214208
return ret;
215209

216210
if (cs_ctl->flags & WMFW_CTL_FLAG_SYS)
217211
return 0;
218212

213+
ctl = cs_ctl->priv;
214+
219215
snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);
220216

221217
return 0;
@@ -225,13 +221,8 @@ EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_write_ctl, SND_HDA_CS_DSP_CONTROLS);
225221
int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type,
226222
unsigned int alg, void *buf, size_t len)
227223
{
228-
struct cs_dsp_coeff_ctl *cs_ctl;
229-
230-
cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
231-
if (!cs_ctl)
232-
return -EINVAL;
224+
return cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len);
233225

234-
return cs_dsp_coeff_read_ctrl(cs_ctl, 0, buf, len);
235226
}
236227
EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS);
237228

0 commit comments

Comments
 (0)