]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: hda: Drop superfluous driver->ops NULL checks
authorTakashi Iwai <tiwai@suse.de>
Wed, 9 Jul 2025 16:04:28 +0000 (18:04 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:55:38 +0000 (09:55 +0200)
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
sound/hda/common/bind.c
sound/hda/common/codec.c
sound/hda/common/hda_local.h
sound/soc/codecs/hda.c
sound/soc/codecs/hdac_hda.c

index f85c640dd54fa5407026542f59ffad846f3630ad..bb1090b656990fa715cb1ab3eae3e66b111606bf 100644 (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;
index 33121d00208711f97e4883135548ec57fa0a84fb..fa07a296abe89598f2f43f63eaa5e0d25991203d 100644 (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);
index e56bea4c93571e1465cb7f7391be0cd73b2cfbaa..a7e53277a0fea6ad104bd774bf65d07a44aa8f01 100644 (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;
 }
index 126270ffd418da09c7dc9f6563eb4b3585b3d305..c8344e28df3d858ff431dbe31962f8fee2e1a33a 100644 (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);
index 191cb842766419c7ed9a1ff9231fe6b84eed0ee2..afd8edf10fdc87ae3f99a087fbe978de5819145f 100644 (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);