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 <tiwai@suse.de>
Link: https://patch.msgid.link/20250709160434.1859-26-tiwai@suse.de
This commit is contained in:
Takashi Iwai
2025-07-09 18:04:28 +02:00
parent cabaf5908e
commit 691351de31
5 changed files with 15 additions and 16 deletions

View File

@@ -52,7 +52,7 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
if (codec->core.dev.power.power_state.event != PM_EVENT_ON)
return;
if (driver->ops && driver->ops->unsol_event)
if (driver->ops->unsol_event)
driver->ops->unsol_event(codec, ev);
}
@@ -138,7 +138,7 @@ static int hda_codec_driver_probe(struct device *dev)
return 0;
error_module:
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(codec);
error_module_put:
module_put(owner);
@@ -166,7 +166,7 @@ static int hda_codec_driver_remove(struct device *dev)
wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
snd_power_sync_ref(codec->bus->card);
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(codec);
snd_hda_codec_cleanup_for_unbind(codec);
codec->preset = NULL;

View File

@@ -1129,7 +1129,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
if (!p)
return;
if (driver->ops && driver->ops->stream_pm)
if (driver->ops->stream_pm)
driver->ops->stream_pm(codec, nid, true);
if (codec->pcm_format_first)
update_pcm_format(codec, p, nid, format);
@@ -1200,7 +1200,7 @@ static void really_cleanup_stream(struct hda_codec *codec,
);
memset(q, 0, sizeof(*q));
q->nid = nid;
if (driver->ops && driver->ops->stream_pm)
if (driver->ops->stream_pm)
driver->ops->stream_pm(codec, nid, false);
}
@@ -2849,7 +2849,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
unsigned int state;
snd_hdac_enter_pm(&codec->core);
if (driver->ops && driver->ops->suspend)
if (driver->ops->suspend)
driver->ops->suspend(codec);
if (!codec->no_stream_clean_at_suspend)
hda_cleanup_all_streams(codec);
@@ -2876,7 +2876,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
restore_shutup_pins(codec);
hda_exec_init_verbs(codec);
snd_hda_jack_set_dirty_all(codec);
if (driver->ops && driver->ops->resume)
if (driver->ops->resume)
driver->ops->resume(codec);
else {
snd_hda_codec_init(codec);
@@ -3071,7 +3071,7 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
/* continue to initialize... */
err = snd_hda_codec_init(codec);
if (!err) {
if (driver->ops && driver->ops->build_controls)
if (driver->ops->build_controls)
err = driver->ops->build_controls(codec);
if (err < 0)
return err;
@@ -3268,11 +3268,10 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)
if (!list_empty(&codec->pcm_list_head))
return 0; /* already parsed */
if (driver->ops && driver->ops->build_pcms)
err = driver->ops->build_pcms(codec);
else
if (!driver->ops->build_pcms)
return 0;
err = driver->ops->build_pcms(codec);
if (err < 0) {
codec_err(codec, "cannot build PCMs for #%d (error %d)\n",
codec->core.addr, err);

View File

@@ -656,7 +656,7 @@ static inline int snd_hda_codec_init(struct hda_codec *codec)
{
struct hda_codec_driver *driver = hda_codec_to_driver(codec);
if (driver->ops && driver->ops->init)
if (driver->ops->init)
return driver->ops->init(codec);
return 0;
}

View File

@@ -250,7 +250,7 @@ static int hda_codec_probe(struct snd_soc_component *component)
complete_err:
hda_codec_unregister_dais(codec, component);
parse_pcms_err:
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(codec);
err:
snd_hda_codec_cleanup_for_unbind(codec);
@@ -280,7 +280,7 @@ static void hda_codec_remove(struct snd_soc_component *component)
hda_codec_unregister_dais(codec, component);
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(codec);
snd_hda_codec_cleanup_for_unbind(codec);

View File

@@ -531,7 +531,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
return 0;
error_patch:
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(hcodec);
error_regmap:
snd_hdac_regmap_exit(hdev);
@@ -560,7 +560,7 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)
pm_runtime_disable(&hdev->dev);
snd_hdac_ext_bus_link_put(hdev->bus, hlink);
if (driver->ops && driver->ops->remove)
if (driver->ops->remove)
driver->ops->remove(codec);
snd_hda_codec_cleanup_for_unbind(codec);