Skip to content

Commit 691351d

Browse files
committed
ALSA: hda: Drop superfluous driver->ops NULL checks
After all conversions, driver->ops became a must in most places (except for the codec power setup which might be called before binding to the codec driver), hence we can get rid of the superfluous driver->ops NULL checks, too. Signed-off-by: Takashi Iwai <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent cabaf59 commit 691351d

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

sound/hda/common/bind.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
5252
if (codec->core.dev.power.power_state.event != PM_EVENT_ON)
5353
return;
5454

55-
if (driver->ops && driver->ops->unsol_event)
55+
if (driver->ops->unsol_event)
5656
driver->ops->unsol_event(codec, ev);
5757
}
5858

@@ -138,7 +138,7 @@ static int hda_codec_driver_probe(struct device *dev)
138138
return 0;
139139

140140
error_module:
141-
if (driver->ops && driver->ops->remove)
141+
if (driver->ops->remove)
142142
driver->ops->remove(codec);
143143
error_module_put:
144144
module_put(owner);
@@ -166,7 +166,7 @@ static int hda_codec_driver_remove(struct device *dev)
166166
wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
167167
snd_power_sync_ref(codec->bus->card);
168168

169-
if (driver->ops && driver->ops->remove)
169+
if (driver->ops->remove)
170170
driver->ops->remove(codec);
171171
snd_hda_codec_cleanup_for_unbind(codec);
172172
codec->preset = NULL;

sound/hda/common/codec.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
11291129
if (!p)
11301130
return;
11311131

1132-
if (driver->ops && driver->ops->stream_pm)
1132+
if (driver->ops->stream_pm)
11331133
driver->ops->stream_pm(codec, nid, true);
11341134
if (codec->pcm_format_first)
11351135
update_pcm_format(codec, p, nid, format);
@@ -1200,7 +1200,7 @@ static void really_cleanup_stream(struct hda_codec *codec,
12001200
);
12011201
memset(q, 0, sizeof(*q));
12021202
q->nid = nid;
1203-
if (driver->ops && driver->ops->stream_pm)
1203+
if (driver->ops->stream_pm)
12041204
driver->ops->stream_pm(codec, nid, false);
12051205
}
12061206

@@ -2849,7 +2849,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
28492849
unsigned int state;
28502850

28512851
snd_hdac_enter_pm(&codec->core);
2852-
if (driver->ops && driver->ops->suspend)
2852+
if (driver->ops->suspend)
28532853
driver->ops->suspend(codec);
28542854
if (!codec->no_stream_clean_at_suspend)
28552855
hda_cleanup_all_streams(codec);
@@ -2876,7 +2876,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
28762876
restore_shutup_pins(codec);
28772877
hda_exec_init_verbs(codec);
28782878
snd_hda_jack_set_dirty_all(codec);
2879-
if (driver->ops && driver->ops->resume)
2879+
if (driver->ops->resume)
28802880
driver->ops->resume(codec);
28812881
else {
28822882
snd_hda_codec_init(codec);
@@ -3071,7 +3071,7 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
30713071
/* continue to initialize... */
30723072
err = snd_hda_codec_init(codec);
30733073
if (!err) {
3074-
if (driver->ops && driver->ops->build_controls)
3074+
if (driver->ops->build_controls)
30753075
err = driver->ops->build_controls(codec);
30763076
if (err < 0)
30773077
return err;
@@ -3268,11 +3268,10 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)
32683268
if (!list_empty(&codec->pcm_list_head))
32693269
return 0; /* already parsed */
32703270

3271-
if (driver->ops && driver->ops->build_pcms)
3272-
err = driver->ops->build_pcms(codec);
3273-
else
3271+
if (!driver->ops->build_pcms)
32743272
return 0;
32753273

3274+
err = driver->ops->build_pcms(codec);
32763275
if (err < 0) {
32773276
codec_err(codec, "cannot build PCMs for #%d (error %d)\n",
32783277
codec->core.addr, err);

sound/hda/common/hda_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static inline int snd_hda_codec_init(struct hda_codec *codec)
656656
{
657657
struct hda_codec_driver *driver = hda_codec_to_driver(codec);
658658

659-
if (driver->ops && driver->ops->init)
659+
if (driver->ops->init)
660660
return driver->ops->init(codec);
661661
return 0;
662662
}

sound/soc/codecs/hda.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int hda_codec_probe(struct snd_soc_component *component)
250250
complete_err:
251251
hda_codec_unregister_dais(codec, component);
252252
parse_pcms_err:
253-
if (driver->ops && driver->ops->remove)
253+
if (driver->ops->remove)
254254
driver->ops->remove(codec);
255255
err:
256256
snd_hda_codec_cleanup_for_unbind(codec);
@@ -280,7 +280,7 @@ static void hda_codec_remove(struct snd_soc_component *component)
280280

281281
hda_codec_unregister_dais(codec, component);
282282

283-
if (driver->ops && driver->ops->remove)
283+
if (driver->ops->remove)
284284
driver->ops->remove(codec);
285285

286286
snd_hda_codec_cleanup_for_unbind(codec);

sound/soc/codecs/hdac_hda.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
531531
return 0;
532532

533533
error_patch:
534-
if (driver->ops && driver->ops->remove)
534+
if (driver->ops->remove)
535535
driver->ops->remove(hcodec);
536536
error_regmap:
537537
snd_hdac_regmap_exit(hdev);
@@ -560,7 +560,7 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)
560560
pm_runtime_disable(&hdev->dev);
561561
snd_hdac_ext_bus_link_put(hdev->bus, hlink);
562562

563-
if (driver->ops && driver->ops->remove)
563+
if (driver->ops->remove)
564564
driver->ops->remove(codec);
565565

566566
snd_hda_codec_cleanup_for_unbind(codec);

0 commit comments

Comments
 (0)