Skip to content

Commit 1d0e692

Browse files
committed
ALSA: hda/generic: Rewrite to new probe method
Convert the generic HD-audio codec driver to use the new hda_codec_ops probe. No functional changes. Signed-off-by: Takashi Iwai <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 6bf917e commit 1d0e692

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

sound/hda/codecs/generic.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4946,7 +4946,7 @@ static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix)
49464946
* @nid: audio widget
49474947
* @on: power on/off flag
49484948
*
4949-
* Set this in patch_ops.stream_pm. Only valid with power_save_node flag.
4949+
* Set this in hda_codec_ops.stream_pm. Only valid with power_save_node flag.
49504950
*/
49514951
void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on)
49524952
{
@@ -5230,7 +5230,7 @@ static const char * const follower_pfxs[] = {
52305230
* snd_hda_gen_build_controls - Build controls from the parsed results
52315231
* @codec: the HDA codec
52325232
*
5233-
* Pass this to build_controls patch_ops.
5233+
* Pass this to build_controls hda_codec_ops.
52345234
*/
52355235
int snd_hda_gen_build_controls(struct hda_codec *codec)
52365236
{
@@ -5743,7 +5743,7 @@ static void setup_pcm_stream(struct hda_pcm_stream *str,
57435743
* snd_hda_gen_build_pcms - build PCM streams based on the parsed results
57445744
* @codec: the HDA codec
57455745
*
5746-
* Pass this to build_pcms patch_ops.
5746+
* Pass this to build_pcms hda_codec_ops.
57475747
*/
57485748
int snd_hda_gen_build_pcms(struct hda_codec *codec)
57495749
{
@@ -6032,7 +6032,7 @@ static void clear_unsol_on_unused_pins(struct hda_codec *codec)
60326032
* snd_hda_gen_init - initialize the generic spec
60336033
* @codec: the HDA codec
60346034
*
6035-
* This can be put as patch_ops init function.
6035+
* This can be put as hda_codec_ops init function.
60366036
*/
60376037
int snd_hda_gen_init(struct hda_codec *codec)
60386038
{
@@ -6070,26 +6070,26 @@ int snd_hda_gen_init(struct hda_codec *codec)
60706070
EXPORT_SYMBOL_GPL(snd_hda_gen_init);
60716071

60726072
/**
6073-
* snd_hda_gen_free - free the generic spec
6073+
* snd_hda_gen_remove - free the generic spec
60746074
* @codec: the HDA codec
60756075
*
6076-
* This can be put as patch_ops free function.
6076+
* This can be put as hda_codec_ops remove function.
60776077
*/
6078-
void snd_hda_gen_free(struct hda_codec *codec)
6078+
void snd_hda_gen_remove(struct hda_codec *codec)
60796079
{
60806080
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
60816081
snd_hda_gen_spec_free(codec->spec);
60826082
kfree(codec->spec);
60836083
codec->spec = NULL;
60846084
}
6085-
EXPORT_SYMBOL_GPL(snd_hda_gen_free);
6085+
EXPORT_SYMBOL_GPL(snd_hda_gen_remove);
60866086

60876087
/**
60886088
* snd_hda_gen_check_power_status - check the loopback power save state
60896089
* @codec: the HDA codec
60906090
* @nid: NID to inspect
60916091
*
6092-
* This can be put as patch_ops check_power_status function.
6092+
* This can be put as hda_codec_ops check_power_status function.
60936093
*/
60946094
int snd_hda_gen_check_power_status(struct hda_codec *codec, hda_nid_t nid)
60956095
{
@@ -6112,11 +6112,8 @@ static const struct hda_codec_ops generic_patch_ops = {
61126112
.check_power_status = snd_hda_gen_check_power_status,
61136113
};
61146114

6115-
/*
6116-
* snd_hda_parse_generic_codec - Generic codec parser
6117-
* @codec: the HDA codec
6118-
*/
6119-
static int snd_hda_parse_generic_codec(struct hda_codec *codec)
6115+
static int snd_hda_gen_probe(struct hda_codec *codec,
6116+
const struct hda_device_id *id)
61206117
{
61216118
struct hda_gen_spec *spec;
61226119
int err;
@@ -6139,19 +6136,31 @@ static int snd_hda_parse_generic_codec(struct hda_codec *codec)
61396136
return 0;
61406137

61416138
error:
6142-
snd_hda_gen_free(codec);
6139+
snd_hda_gen_remove(codec);
61436140
return err;
61446141
}
61456142

6143+
static const struct hda_codec_ops generic_codec_ops = {
6144+
.probe = snd_hda_gen_probe,
6145+
.remove = snd_hda_gen_remove,
6146+
.build_controls = snd_hda_gen_build_controls,
6147+
.build_pcms = snd_hda_gen_build_pcms,
6148+
.init = snd_hda_gen_init,
6149+
.unsol_event = snd_hda_jack_unsol_event,
6150+
.check_power_status = snd_hda_gen_check_power_status,
6151+
.stream_pm = snd_hda_gen_stream_pm,
6152+
};
6153+
61466154
static const struct hda_device_id snd_hda_id_generic[] = {
6147-
HDA_CODEC_ENTRY(0x1af40021, "Generic", snd_hda_parse_generic_codec), /* QEMU */
6148-
HDA_CODEC_ENTRY(HDA_CODEC_ID_GENERIC, "Generic", snd_hda_parse_generic_codec),
6155+
HDA_CODEC_ID(0x1af40021, "Generic"), /* QEMU */
6156+
HDA_CODEC_ID(HDA_CODEC_ID_GENERIC, "Generic"),
61496157
{} /* terminator */
61506158
};
61516159
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_generic);
61526160

61536161
static struct hda_codec_driver generic_driver = {
61546162
.id = snd_hda_id_generic,
6163+
.ops = &generic_codec_ops,
61556164
};
61566165

61576166
module_hda_codec_driver(generic_driver);

sound/hda/codecs/generic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ enum {
311311
int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
312312

313313
int snd_hda_gen_init(struct hda_codec *codec);
314-
void snd_hda_gen_free(struct hda_codec *codec);
314+
void snd_hda_gen_remove(struct hda_codec *codec);
315+
#define snd_hda_gen_free snd_hda_gen_remove
315316

316317
int snd_hda_get_path_idx(struct hda_codec *codec, struct nid_path *path);
317318
struct nid_path *snd_hda_get_path_from_idx(struct hda_codec *codec, int idx);

0 commit comments

Comments
 (0)