[PATCH 11/27] ALSA: hda/realtek: Rewrite to new probe method

Takashi Iwai
2025-07-09T16:12:21Z

Convert the Realtek codec drivers to use the new hda_codec_ops probe.
No functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/realtek/alc260.c | 20 ++++-
sound/hda/codecs/realtek/alc262.c | 20 ++++-
sound/hda/codecs/realtek/alc268.c | 22 +++++-
sound/hda/codecs/realtek/alc269.c | 111 +++++++++++++++-------------
sound/hda/codecs/realtek/alc662.c | 42 +++++++----
sound/hda/codecs/realtek/alc680.c | 20 ++++-
sound/hda/codecs/realtek/alc861.c | 22 +++++-
sound/hda/codecs/realtek/alc861vd.c | 22 +++++-
sound/hda/codecs/realtek/alc880.c | 24 ++++--
sound/hda/codecs/realtek/alc882.c | 48 +++++++-----
sound/hda/codecs/realtek/realtek.c | 17 +----
sound/hda/codecs/realtek/realtek.h | 4 -
12 files changed, 244 insertions(+), 128 deletions(-)

diff --git a/sound/hda/codecs/realtek/alc260.c b/sound/hda/codecs/realtek/alc260.c
index ebe20eaec58a..8bd47079dccb 100644
--- a/sound/hda/codecs/realtek/alc260.c
+++ b/sound/hda/codecs/realtek/alc260.c
@@ -211,7 +211,7 @@ static const struct hda_model_fixup alc260_fixup_models[] = {

/*
*/
-static int patch_alc260(struct hda_codec *codec)
+static int alc260_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -252,15 +252,28 @@ static int patch_alc260(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc260_codec_ops = {
+ .probe = alc260_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc260[] = {
- HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
+ HDA_CODEC_ID(0x10ec0260, "ALC260"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc260);
@@ -271,6 +284,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc260_driver = {
.id = snd_hda_id_alc260,
+ .ops = &alc260_codec_ops,
};

module_hda_codec_driver(alc260_driver);
diff --git a/sound/hda/codecs/realtek/alc262.c b/sound/hda/codecs/realtek/alc262.c
index ffe61f447667..3ec06cf5d2a6 100644
--- a/sound/hda/codecs/realtek/alc262.c
+++ b/sound/hda/codecs/realtek/alc262.c
@@ -126,7 +126,7 @@ static const struct hda_model_fixup alc262_fixup_models[] = {

/*
*/
-static int patch_alc262(struct hda_codec *codec)
+static int alc262_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -175,15 +175,28 @@ static int patch_alc262(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc262_codec_ops = {
+ .probe = alc262_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc262[] = {
- HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
+ HDA_CODEC_ID(0x10ec0262, "ALC262"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc262);
@@ -194,6 +207,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc262_driver = {
.id = snd_hda_id_alc262,
+ .ops = &alc262_codec_ops,
};

module_hda_codec_driver(alc262_driver);
diff --git a/sound/hda/codecs/realtek/alc268.c b/sound/hda/codecs/realtek/alc268.c
index d018f9982feb..e489cdc98eb8 100644
--- a/sound/hda/codecs/realtek/alc268.c
+++ b/sound/hda/codecs/realtek/alc268.c
@@ -101,7 +101,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)

/*
*/
-static int patch_alc268(struct hda_codec *codec)
+static int alc268_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int i, err;
@@ -151,16 +151,29 @@ static int patch_alc268(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc268_codec_ops = {
+ .probe = alc268_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc268[] = {
- HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
- HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
+ HDA_CODEC_ID(0x10ec0267, "ALC267"),
+ HDA_CODEC_ID(0x10ec0268, "ALC268"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc268);
@@ -171,6 +184,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc268_driver = {
.id = snd_hda_id_alc268,
+ .ops = &alc268_codec_ops,
};

module_hda_codec_driver(alc268_driver);
diff --git a/sound/hda/codecs/realtek/alc269.c b/sound/hda/codecs/realtek/alc269.c
index 325ba08e2981..b393338808d5 100644
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -992,7 +992,7 @@ static int alc269_resume(struct hda_codec *codec)
msleep(150);
}

- codec->patch_ops.init(codec);
+ snd_hda_codec_init(codec);

if (spec->codec_variant == ALC269_TYPE_ALC269VB)
alc269vb_toggle_power_output(codec, 1);
@@ -7841,19 +7841,19 @@ static void alc269_fill_coef(struct hda_codec *codec)
alc_update_coef_idx(codec, 0x4, 0, 1<<11);
}

-static void alc269_free(struct hda_codec *codec)
+static void alc269_remove(struct hda_codec *codec)
{
struct alc_spec *spec = codec->spec;

if (spec)
hda_component_manager_free(&spec->comps, &comp_master_ops);

- alc_free(codec);
+ snd_hda_gen_remove(codec);
}

/*
*/
-static int patch_alc269(struct hda_codec *codec)
+static int alc269_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -7867,9 +7867,6 @@ static int patch_alc269(struct hda_codec *codec)
codec->power_save_node = 0;
spec->en_3kpull_low = true;

- codec->patch_ops.suspend = alc269_suspend;
- codec->patch_ops.resume = alc269_resume;
- codec->patch_ops.free = alc269_free;
spec->shutup = alc_default_shutup;
spec->init_hook = alc_default_init;

@@ -8067,56 +8064,69 @@ static int patch_alc269(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ alc269_remove(codec);
return err;
}

+static const struct hda_codec_ops alc269_codec_ops = {
+ .probe = alc269_probe,
+ .remove = alc269_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .suspend = alc269_suspend,
+ .resume = alc269_resume,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc269[] = {
- HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
- HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
- HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
+ HDA_CODEC_ID(0x10ec0215, "ALC215"),
+ HDA_CODEC_ID(0x10ec0221, "ALC221"),
+ HDA_CODEC_ID(0x10ec0222, "ALC222"),
+ HDA_CODEC_ID(0x10ec0225, "ALC225"),
+ HDA_CODEC_ID(0x10ec0230, "ALC236"),
+ HDA_CODEC_ID(0x10ec0231, "ALC231"),
+ HDA_CODEC_ID(0x10ec0233, "ALC233"),
+ HDA_CODEC_ID(0x10ec0234, "ALC234"),
+ HDA_CODEC_ID(0x10ec0235, "ALC233"),
+ HDA_CODEC_ID(0x10ec0236, "ALC236"),
+ HDA_CODEC_ID(0x10ec0245, "ALC245"),
+ HDA_CODEC_ID(0x10ec0255, "ALC255"),
+ HDA_CODEC_ID(0x10ec0256, "ALC256"),
+ HDA_CODEC_ID(0x10ec0257, "ALC257"),
+ HDA_CODEC_ID(0x10ec0269, "ALC269"),
+ HDA_CODEC_ID(0x10ec0270, "ALC270"),
+ HDA_CODEC_ID(0x10ec0274, "ALC274"),
+ HDA_CODEC_ID(0x10ec0275, "ALC275"),
+ HDA_CODEC_ID(0x10ec0276, "ALC276"),
+ HDA_CODEC_ID(0x10ec0280, "ALC280"),
+ HDA_CODEC_ID(0x10ec0282, "ALC282"),
+ HDA_CODEC_ID(0x10ec0283, "ALC283"),
+ HDA_CODEC_ID(0x10ec0284, "ALC284"),
+ HDA_CODEC_ID(0x10ec0285, "ALC285"),
+ HDA_CODEC_ID(0x10ec0286, "ALC286"),
+ HDA_CODEC_ID(0x10ec0287, "ALC287"),
+ HDA_CODEC_ID(0x10ec0288, "ALC288"),
+ HDA_CODEC_ID(0x10ec0289, "ALC289"),
+ HDA_CODEC_ID(0x10ec0290, "ALC290"),
+ HDA_CODEC_ID(0x10ec0292, "ALC292"),
+ HDA_CODEC_ID(0x10ec0293, "ALC293"),
+ HDA_CODEC_ID(0x10ec0294, "ALC294"),
+ HDA_CODEC_ID(0x10ec0295, "ALC295"),
+ HDA_CODEC_ID(0x10ec0298, "ALC298"),
+ HDA_CODEC_ID(0x10ec0299, "ALC299"),
+ HDA_CODEC_ID(0x10ec0300, "ALC300"),
+ HDA_CODEC_ID(0x10ec0623, "ALC623"),
+ HDA_CODEC_ID(0x10ec0700, "ALC700"),
+ HDA_CODEC_ID(0x10ec0701, "ALC701"),
+ HDA_CODEC_ID(0x10ec0703, "ALC703"),
+ HDA_CODEC_ID(0x10ec0711, "ALC711"),
+ HDA_CODEC_ID(0x19e58326, "HW8326"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc269);
@@ -8128,6 +8138,7 @@ MODULE_IMPORT_NS("SND_HDA_SCODEC_COMPONENT");

static struct hda_codec_driver alc269_driver = {
.id = snd_hda_id_alc269,
+ .ops = &alc269_codec_ops,
};

module_hda_codec_driver(alc269_driver);
diff --git a/sound/hda/codecs/realtek/alc662.c b/sound/hda/codecs/realtek/alc662.c
index 94e4a313e5e2..5073165d1f3c 100644
--- a/sound/hda/codecs/realtek/alc662.c
+++ b/sound/hda/codecs/realtek/alc662.c
@@ -994,7 +994,7 @@ static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {

/*
*/
-static int patch_alc662(struct hda_codec *codec)
+static int alc662_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -1067,26 +1067,39 @@ static int patch_alc662(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc662_codec_ops = {
+ .probe = alc662_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc662[] = {
- HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
- HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
- HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
- HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
+ HDA_CODEC_ID(0x10ec0272, "ALC272"),
+ HDA_CODEC_ID_REV(0x10ec0662, 0x100101, "ALC662 rev1"),
+ HDA_CODEC_ID_REV(0x10ec0662, 0x100300, "ALC662 rev3"),
+ HDA_CODEC_ID(0x10ec0663, "ALC663"),
+ HDA_CODEC_ID(0x10ec0665, "ALC665"),
+ HDA_CODEC_ID(0x10ec0667, "ALC667"),
+ HDA_CODEC_ID(0x10ec0668, "ALC668"),
+ HDA_CODEC_ID(0x10ec0670, "ALC670"),
+ HDA_CODEC_ID(0x10ec0671, "ALC671"),
+ HDA_CODEC_ID(0x10ec0867, "ALC891"),
+ HDA_CODEC_ID(0x10ec0892, "ALC892"),
+ HDA_CODEC_ID(0x10ec0897, "ALC897"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc662);
@@ -1097,6 +1110,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc662_driver = {
.id = snd_hda_id_alc662,
+ .ops = &alc662_codec_ops,
};

module_hda_codec_driver(alc662_driver);
diff --git a/sound/hda/codecs/realtek/alc680.c b/sound/hda/codecs/realtek/alc680.c
index baf19ee3bc2f..8aab1026243c 100644
--- a/sound/hda/codecs/realtek/alc680.c
+++ b/sound/hda/codecs/realtek/alc680.c
@@ -14,7 +14,7 @@ static int alc680_parse_auto_config(struct hda_codec *codec)

/*
*/
-static int patch_alc680(struct hda_codec *codec)
+static int alc680_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
int err;

@@ -26,18 +26,31 @@ static int patch_alc680(struct hda_codec *codec)
/* automatic parse from the BIOS config */
err = alc680_parse_auto_config(codec);
if (err < 0) {
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

return 0;
}

+static const struct hda_codec_ops alc680_codec_ops = {
+ .probe = alc680_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc680[] = {
- HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
+ HDA_CODEC_ID(0x10ec0680, "ALC680"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc680);
@@ -48,6 +61,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc680_driver = {
.id = snd_hda_id_alc680,
+ .ops = &alc680_codec_ops,
};

module_hda_codec_driver(alc680_driver);
diff --git a/sound/hda/codecs/realtek/alc861.c b/sound/hda/codecs/realtek/alc861.c
index 0eb70b44dc05..270037c6504a 100644
--- a/sound/hda/codecs/realtek/alc861.c
+++ b/sound/hda/codecs/realtek/alc861.c
@@ -88,7 +88,7 @@ static const struct hda_quirk alc861_fixup_tbl[] = {

/*
*/
-static int patch_alc861(struct hda_codec *codec)
+static int alc861_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -124,16 +124,29 @@ static int patch_alc861(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc861_codec_ops = {
+ .probe = alc861_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc861[] = {
- HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
- HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
+ HDA_CODEC_ID_REV(0x10ec0861, 0x100340, "ALC660"),
+ HDA_CODEC_ID(0x10ec0861, "ALC861"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc861);
@@ -144,6 +157,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc861_driver = {
.id = snd_hda_id_alc861,
+ .ops = &alc861_codec_ops,
};

module_hda_codec_driver(alc861_driver);
diff --git a/sound/hda/codecs/realtek/alc861vd.c b/sound/hda/codecs/realtek/alc861vd.c
index ebf274ad730b..44264e0d6e56 100644
--- a/sound/hda/codecs/realtek/alc861vd.c
+++ b/sound/hda/codecs/realtek/alc861vd.c
@@ -62,7 +62,7 @@ static const struct hda_quirk alc861vd_fixup_tbl[] = {

/*
*/
-static int patch_alc861vd(struct hda_codec *codec)
+static int alc861vd_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -98,16 +98,29 @@ static int patch_alc861vd(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc861vd_codec_ops = {
+ .probe = alc861vd_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc861vd[] = {
- HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
- HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
+ HDA_CODEC_ID(0x10ec0660, "ALC660-VD"),
+ HDA_CODEC_ID(0x10ec0862, "ALC861-VD"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc861vd);
@@ -118,6 +131,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc861vd_driver = {
.id = snd_hda_id_alc861vd,
+ .ops = &alc861vd_codec_ops,
};

module_hda_codec_driver(alc861vd_driver);
diff --git a/sound/hda/codecs/realtek/alc880.c b/sound/hda/codecs/realtek/alc880.c
index 2e828ab96dc5..bf1bdf11ec2d 100644
--- a/sound/hda/codecs/realtek/alc880.c
+++ b/sound/hda/codecs/realtek/alc880.c
@@ -434,9 +434,9 @@ static const struct hda_model_fixup alc880_fixup_models[] = {

/*
- * OK, here we have finally the patch for ALC880
+ * OK, here we have finally the probe for ALC880
*/
-static int patch_alc880(struct hda_codec *codec)
+static int alc880_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -449,8 +449,6 @@ static int patch_alc880(struct hda_codec *codec)
spec->gen.need_dac_fix = 1;
spec->gen.beep_nid = 0x01;

- codec->patch_ops.unsol_event = alc880_unsol_event;
-
alc_pre_init(codec);

snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
@@ -473,15 +471,28 @@ static int patch_alc880(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc880_codec_ops = {
+ .probe = alc880_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = alc880_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc880[] = {
- HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
+ HDA_CODEC_ID(0x10ec0880, "ALC880"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc880);
@@ -492,6 +503,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc880_driver = {
.id = snd_hda_id_alc880,
+ .ops = &alc880_codec_ops,
};

module_hda_codec_driver(alc880_driver);
diff --git a/sound/hda/codecs/realtek/alc882.c b/sound/hda/codecs/realtek/alc882.c
index 6af2f7fcc6bb..529fecd5baa0 100644
--- a/sound/hda/codecs/realtek/alc882.c
+++ b/sound/hda/codecs/realtek/alc882.c
@@ -757,7 +757,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec)

/*
*/
-static int patch_alc882(struct hda_codec *codec)
+static int alc882_probe(struct hda_codec *codec, const struct hda_device_id *id)
{
struct alc_spec *spec;
int err;
@@ -809,29 +809,42 @@ static int patch_alc882(struct hda_codec *codec)
return 0;

error:
- alc_free(codec);
+ snd_hda_gen_remove(codec);
return err;
}

+static const struct hda_codec_ops alc882_codec_ops = {
+ .probe = alc882_probe,
+ .remove = snd_hda_gen_remove,
+ .build_controls = alc_build_controls,
+ .build_pcms = snd_hda_gen_build_pcms,
+ .init = alc_init,
+ .unsol_event = snd_hda_jack_unsol_event,
+ .resume = alc_resume,
+ .suspend = alc_suspend,
+ .check_power_status = snd_hda_gen_check_power_status,
+ .stream_pm = snd_hda_gen_stream_pm,
+};
+
/*
* driver entries
*/
static const struct hda_device_id snd_hda_id_alc882[] = {
- HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
- HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
- HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
- HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
- HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
+ HDA_CODEC_ID_REV(0x10ec0662, 0x100002, "ALC662 rev2"),
+ HDA_CODEC_ID(0x10ec0882, "ALC882"),
+ HDA_CODEC_ID(0x10ec0883, "ALC883"),
+ HDA_CODEC_ID_REV(0x10ec0885, 0x100101, "ALC889A"),
+ HDA_CODEC_ID_REV(0x10ec0885, 0x100103, "ALC889A"),
+ HDA_CODEC_ID(0x10ec0885, "ALC885"),
+ HDA_CODEC_ID(0x10ec0887, "ALC887"),
+ HDA_CODEC_ID_REV(0x10ec0888, 0x100101, "ALC1200"),
+ HDA_CODEC_ID(0x10ec0888, "ALC888"),
+ HDA_CODEC_ID(0x10ec0889, "ALC889"),
+ HDA_CODEC_ID(0x10ec0899, "ALC898"),
+ HDA_CODEC_ID(0x10ec0900, "ALC1150"),
+ HDA_CODEC_ID(0x10ec0b00, "ALCS1200A"),
+ HDA_CODEC_ID(0x10ec1168, "ALC1220"),
+ HDA_CODEC_ID(0x10ec1220, "ALC1220"),
{} /* terminator */
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_alc882);
@@ -842,6 +855,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_REALTEK");

static struct hda_codec_driver alc882_driver = {
.id = snd_hda_id_alc882,
+ .ops = &alc882_codec_ops,
};

module_hda_codec_driver(alc882_driver);
diff --git a/sound/hda/codecs/realtek/realtek.c b/sound/hda/codecs/realtek/realtek.c
index 4ab49e76c304..66b2efb9acb3 100644
--- a/sound/hda/codecs/realtek/realtek.c
+++ b/sound/hda/codecs/realtek/realtek.c
@@ -862,27 +862,13 @@ int alc_resume(struct hda_codec *codec)

if (!spec->no_depop_delay)
msleep(150); /* to avoid pop noise */
- codec->patch_ops.init(codec);
+ snd_hda_codec_init(codec);
snd_hda_regmap_sync(codec);
hda_call_check_power_status(codec, 0x01);
return 0;
}
EXPORT_SYMBOL_NS_GPL(alc_resume, "SND_HDA_CODEC_REALTEK");

-/*
- */
-const struct hda_codec_ops alc_patch_ops = {
- .build_controls = alc_build_controls,
- .build_pcms = snd_hda_gen_build_pcms,
- .init = alc_init,
- .free = alc_free,
- .unsol_event = snd_hda_jack_unsol_event,
- .resume = alc_resume,
- .suspend = alc_suspend,
- .check_power_status = snd_hda_gen_check_power_status,
-};
-EXPORT_SYMBOL_NS_GPL(alc_patch_ops, "SND_HDA_CODEC_REALTEK");
-
/*
* Rename codecs appropriately from COEF value or subvendor id
*/
@@ -1082,7 +1068,6 @@ int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
/* FIXME: do we need this for all Realtek codec models? */
codec->spdif_status_reset = 1;
codec->forced_resume = 1;
- codec->patch_ops = alc_patch_ops;
mutex_init(&spec->coef_mutex);

err = alc_codec_rename_from_preset(codec);
diff --git a/sound/hda/codecs/realtek/realtek.h b/sound/hda/codecs/realtek/realtek.h
index ac142f2540e3..ee893da0c486 100644
--- a/sound/hda/codecs/realtek/realtek.h
+++ b/sound/hda/codecs/realtek/realtek.h
@@ -226,15 +226,11 @@ void alc_power_eapd(struct hda_codec *codec);
int alc_suspend(struct hda_codec *codec);
int alc_resume(struct hda_codec *codec);

-#define alc_free snd_hda_gen_free
-
int alc_parse_auto_config(struct hda_codec *codec,
const hda_nid_t *ignore_nids,
const hda_nid_t *ssid_nids);
int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid);

-extern const struct hda_codec_ops alc_patch_ops;
-
#define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)

#ifdef CONFIG_SND_HDA_INPUT_BEEP
--
2.50.0