Skip to content

Commit cabaf59

Browse files
committed
ALSA: hda: Drop old codec binding method
Now that all patch_ops usage have been converted to the new hda_codec_ops probe, we can drop patch_ops from the hda_codec, together with the calls of patch_ops callbacks. The hda_codec_ops.free callback is removed as all have been replaced with the new remove callback. Also, correct comments mentioning "patch"; it's replaced with "codec driver". Signed-off-by: Takashi Iwai <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent ad781b5 commit cabaf59

File tree

10 files changed

+26
-112
lines changed

10 files changed

+26
-112
lines changed

include/sound/hda_codec.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,8 @@ struct hda_bus {
7070

7171
/*
7272
* codec preset
73-
*
74-
* Known codecs have the patch to build and set up the controls/PCMs
75-
* better than the generic parser.
7673
*/
77-
typedef int (*hda_codec_patch_t)(struct hda_codec *);
78-
74+
7975
#define HDA_CODEC_ID_SKIP_PROBE 0x00000001
8076
#define HDA_CODEC_ID_GENERIC_HDMI 0x00000101
8177
#define HDA_CODEC_ID_GENERIC 0x00000201
@@ -90,14 +86,6 @@ typedef int (*hda_codec_patch_t)(struct hda_codec *);
9086
#define HDA_CODEC_ID(_vid, _name) \
9187
HDA_CODEC_ID_REV(_vid, 0, _name)
9288

93-
/* old macros for patch_ops -- to be deprecated */
94-
#define HDA_CODEC_REV_ENTRY(_vid, _rev, _name, _patch) \
95-
{ .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
96-
.api_version = HDA_DEV_LEGACY, \
97-
.driver_data = (unsigned long)(_patch) }
98-
#define HDA_CODEC_ENTRY(_vid, _name, _patch) \
99-
HDA_CODEC_REV_ENTRY(_vid, 0, _name, _patch)
100-
10189
struct hda_codec_driver {
10290
struct hdac_driver core;
10391
const struct hda_device_id *id;
@@ -116,14 +104,13 @@ void hda_codec_driver_unregister(struct hda_codec_driver *drv);
116104
module_driver(drv, hda_codec_driver_register, \
117105
hda_codec_driver_unregister)
118106

119-
/* ops set by the preset patch */
107+
/* ops for hda codec driver */
120108
struct hda_codec_ops {
121109
int (*probe)(struct hda_codec *codec, const struct hda_device_id *id);
122110
void (*remove)(struct hda_codec *codec);
123111
int (*build_controls)(struct hda_codec *codec);
124112
int (*build_pcms)(struct hda_codec *codec);
125113
int (*init)(struct hda_codec *codec);
126-
void (*free)(struct hda_codec *codec);
127114
void (*unsol_event)(struct hda_codec *codec, unsigned int res);
128115
void (*set_power_state)(struct hda_codec *codec, hda_nid_t fg,
129116
unsigned int power_state);
@@ -199,9 +186,6 @@ struct hda_codec {
199186
const struct hda_device_id *preset;
200187
const char *modelname; /* model name for preset */
201188

202-
/* set by patch */
203-
struct hda_codec_ops patch_ops;
204-
205189
/* PCM to create, set by hda_codec_ops.build_pcms callback */
206190
struct list_head pcm_list_head;
207191
refcount_t pcm_ref;
@@ -500,8 +484,6 @@ int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
500484

501485
if (driver->ops && driver->ops->check_power_status)
502486
return driver->ops->check_power_status(codec, nid);
503-
else if (codec->patch_ops.check_power_status)
504-
return codec->patch_ops.check_power_status(codec, nid);
505487
return 0;
506488
}
507489

sound/hda/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ obj-y += core/
33
obj-$(CONFIG_SND_HDA) += common/
44
obj-$(CONFIG_SND_HDA) += codecs/
55
# this must be the last entry after codec drivers;
6-
# otherwise the codec patches won't be hooked before the PCI probe
6+
# otherwise the codec drivers won't be hooked before the PCI probe
77
# when built in kernel
88
obj-$(CONFIG_SND_HDA) += controllers/

sound/hda/codecs/generic.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5190,8 +5190,6 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
51905190
if (spec->power_down_unused || codec->power_save_node) {
51915191
if (!codec->power_filter)
51925192
codec->power_filter = snd_hda_gen_path_power_filter;
5193-
if (!codec->patch_ops.stream_pm)
5194-
codec->patch_ops.stream_pm = snd_hda_gen_stream_pm;
51955193
}
51965194

51975195
if (!spec->no_analog && spec->beep_nid) {
@@ -6103,15 +6101,6 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_check_power_status);
61036101
* the generic codec support
61046102
*/
61056103

6106-
static const struct hda_codec_ops generic_patch_ops = {
6107-
.build_controls = snd_hda_gen_build_controls,
6108-
.build_pcms = snd_hda_gen_build_pcms,
6109-
.init = snd_hda_gen_init,
6110-
.free = snd_hda_gen_free,
6111-
.unsol_event = snd_hda_jack_unsol_event,
6112-
.check_power_status = snd_hda_gen_check_power_status,
6113-
};
6114-
61156104
static int snd_hda_gen_probe(struct hda_codec *codec,
61166105
const struct hda_device_id *id)
61176106
{
@@ -6132,7 +6121,6 @@ static int snd_hda_gen_probe(struct hda_codec *codec,
61326121
if (err < 0)
61336122
goto error;
61346123

6135-
codec->patch_ops = generic_patch_ops;
61366124
return 0;
61376125

61386126
error:

sound/hda/codecs/generic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
312312

313313
int snd_hda_gen_init(struct hda_codec *codec);
314314
void snd_hda_gen_remove(struct hda_codec *codec);
315-
#define snd_hda_gen_free snd_hda_gen_remove
316315

317316
int snd_hda_get_path_idx(struct hda_codec *codec, struct nid_path *path);
318317
struct nid_path *snd_hda_get_path_from_idx(struct hda_codec *codec, int idx);

sound/hda/codecs/hdmi/hdmi_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct hdmi_spec_per_pin {
5757
#endif
5858
};
5959

60-
/* operations used by generic code that can be overridden by patches */
60+
/* operations used by generic code that can be overridden by codec drivers */
6161
struct hdmi_ops {
6262
int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
6363
int dev_id, unsigned char *buf, int *eld_size);

sound/hda/common/bind.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
5454

5555
if (driver->ops && driver->ops->unsol_event)
5656
driver->ops->unsol_event(codec, ev);
57-
else if (codec->patch_ops.unsol_event)
58-
codec->patch_ops.unsol_event(codec, ev);
5957
}
6058

6159
/**
@@ -91,7 +89,6 @@ static int hda_codec_driver_probe(struct device *dev)
9189
struct hda_codec *codec = dev_to_hda_codec(dev);
9290
struct module *owner = dev->driver->owner;
9391
struct hda_codec_driver *driver = hda_codec_to_driver(codec);
94-
hda_codec_patch_t patch;
9592
int err;
9693

9794
if (codec->bus->core.ext_ops) {
@@ -115,19 +112,14 @@ static int hda_codec_driver_probe(struct device *dev)
115112
goto error;
116113
}
117114

118-
if (driver->ops && driver->ops->probe) {
119-
err = driver->ops->probe(codec, codec->preset);
120-
if (err < 0)
121-
goto error_module_put;
122-
} else {
123-
patch = (hda_codec_patch_t)codec->preset->driver_data;
124-
if (patch) {
125-
err = patch(codec);
126-
if (err < 0)
127-
goto error_module_put;
128-
}
115+
if (WARN_ON(!(driver->ops && driver->ops->probe))) {
116+
err = -EINVAL;
117+
goto error_module_put;
129118
}
130119

120+
err = driver->ops->probe(codec, codec->preset);
121+
if (err < 0)
122+
goto error_module_put;
131123
err = snd_hda_codec_build_pcms(codec);
132124
if (err < 0)
133125
goto error_module;
@@ -148,8 +140,6 @@ static int hda_codec_driver_probe(struct device *dev)
148140
error_module:
149141
if (driver->ops && driver->ops->remove)
150142
driver->ops->remove(codec);
151-
else if (codec->patch_ops.free)
152-
codec->patch_ops.free(codec);
153143
error_module_put:
154144
module_put(owner);
155145

@@ -178,8 +168,6 @@ static int hda_codec_driver_remove(struct device *dev)
178168

179169
if (driver->ops && driver->ops->remove)
180170
driver->ops->remove(codec);
181-
else if (codec->patch_ops.free)
182-
codec->patch_ops.free(codec);
183171
snd_hda_codec_cleanup_for_unbind(codec);
184172
codec->preset = NULL;
185173
module_put(dev->driver->owner);
@@ -320,7 +308,7 @@ static int codec_bind_generic(struct hda_codec *codec)
320308
* @codec: the HDA codec
321309
*
322310
* Start parsing of the given codec tree and (re-)initialize the whole
323-
* patch instance.
311+
* codec driver binding.
324312
*
325313
* Returns 0 if successful or a negative error code.
326314
*/

sound/hda/common/codec.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
766766
snd_hda_ctls_clear(codec);
767767
codec_release_pcms(codec);
768768
snd_hda_detach_beep_device(codec);
769-
memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
770769
snd_hda_jack_tbl_clear(codec);
771770
codec->proc_widget_hook = NULL;
772771
codec->spec = NULL;
@@ -1132,8 +1131,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
11321131

11331132
if (driver->ops && driver->ops->stream_pm)
11341133
driver->ops->stream_pm(codec, nid, true);
1135-
else if (codec->patch_ops.stream_pm)
1136-
codec->patch_ops.stream_pm(codec, nid, true);
11371134
if (codec->pcm_format_first)
11381135
update_pcm_format(codec, p, nid, format);
11391136
update_pcm_stream_id(codec, p, nid, stream_tag, channel_id);
@@ -1205,8 +1202,6 @@ static void really_cleanup_stream(struct hda_codec *codec,
12051202
q->nid = nid;
12061203
if (driver->ops && driver->ops->stream_pm)
12071204
driver->ops->stream_pm(codec, nid, false);
1208-
else if (codec->patch_ops.stream_pm)
1209-
codec->patch_ops.stream_pm(codec, nid, false);
12101205
}
12111206

12121207
/* clean up the all conflicting obsolete streams */
@@ -2397,7 +2392,7 @@ static const struct snd_kcontrol_new dig_mixes[] = {
23972392
* @cvt_nid: converter NID
23982393
* @type: HDA_PCM_TYPE_*
23992394
* Creates controls related with the digital output.
2400-
* Called from each patch supporting the digital out.
2395+
* Called from each codec driver supporting the digital out.
24012396
*
24022397
* Returns 0 if successful, or a negative error code.
24032398
*/
@@ -2656,7 +2651,7 @@ static const struct snd_kcontrol_new dig_in_ctls[] = {
26562651
* @nid: audio in widget NID
26572652
*
26582653
* Creates controls related with the SPDIF input.
2659-
* Called from each patch supporting the SPDIF in.
2654+
* Called from each codec driver supporting the SPDIF in.
26602655
*
26612656
* Returns 0 if successful, or a negative error code.
26622657
*/
@@ -2773,9 +2768,6 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
27732768
/* might be called before binding to driver, too */
27742769
if (driver && driver->ops && driver->ops->set_power_state)
27752770
driver->ops->set_power_state(codec, fg, power_state);
2776-
else if (codec->patch_ops.set_power_state)
2777-
codec->patch_ops.set_power_state(codec, fg,
2778-
power_state);
27792771
else {
27802772
state = power_state;
27812773
if (codec->power_filter)
@@ -2859,8 +2851,6 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
28592851
snd_hdac_enter_pm(&codec->core);
28602852
if (driver->ops && driver->ops->suspend)
28612853
driver->ops->suspend(codec);
2862-
else if (codec->patch_ops.suspend)
2863-
codec->patch_ops.suspend(codec);
28642854
if (!codec->no_stream_clean_at_suspend)
28652855
hda_cleanup_all_streams(codec);
28662856
state = hda_set_power_state(codec, AC_PWRST_D3);
@@ -2888,8 +2878,6 @@ static void hda_call_codec_resume(struct hda_codec *codec)
28882878
snd_hda_jack_set_dirty_all(codec);
28892879
if (driver->ops && driver->ops->resume)
28902880
driver->ops->resume(codec);
2891-
else if (codec->patch_ops.resume)
2892-
codec->patch_ops.resume(codec);
28932881
else {
28942882
snd_hda_codec_init(codec);
28952883
snd_hda_regmap_sync(codec);
@@ -3085,8 +3073,6 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
30853073
if (!err) {
30863074
if (driver->ops && driver->ops->build_controls)
30873075
err = driver->ops->build_controls(codec);
3088-
else if (codec->patch_ops.build_controls)
3089-
err = codec->patch_ops.build_controls(codec);
30903076
if (err < 0)
30913077
return err;
30923078
}
@@ -3284,8 +3270,6 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)
32843270

32853271
if (driver->ops && driver->ops->build_pcms)
32863272
err = driver->ops->build_pcms(codec);
3287-
else if (codec->patch_ops.build_pcms)
3288-
err = codec->patch_ops.build_pcms(codec);
32893273
else
32903274
return 0;
32913275

sound/hda/common/hda_local.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,6 @@ static inline int snd_hda_codec_init(struct hda_codec *codec)
658658

659659
if (driver->ops && driver->ops->init)
660660
return driver->ops->init(codec);
661-
else if (codec->patch_ops.init)
662-
return codec->patch_ops.init(codec);
663661
return 0;
664662
}
665663

sound/soc/codecs/hda.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ static int hda_codec_probe(struct snd_soc_component *component)
177177
struct hdac_device *hdev = &codec->core;
178178
struct hdac_bus *bus = hdev->bus;
179179
struct hdac_ext_link *hlink;
180-
hda_codec_patch_t patch;
181180
int ret;
182181

183182
#ifdef CONFIG_PM
@@ -215,19 +214,12 @@ static int hda_codec_probe(struct snd_soc_component *component)
215214
goto err;
216215
}
217216

218-
if (driver->ops && driver->ops->probe) {
219-
ret = driver->ops->probe(codec, codec->preset);
220-
} else {
221-
patch = (hda_codec_patch_t)codec->preset->driver_data;
222-
if (!patch) {
223-
dev_err(&hdev->dev, "no patch specified\n");
224-
ret = -EINVAL;
225-
goto err;
226-
}
227-
228-
ret = patch(codec);
217+
if (WARN_ON(!(driver->ops && driver->ops->probe))) {
218+
ret = -EINVAL;
219+
goto err;
229220
}
230221

222+
ret = driver->ops->probe(codec, codec->preset);
231223
if (ret < 0) {
232224
dev_err(&hdev->dev, "codec init failed: %d\n", ret);
233225
goto err;
@@ -260,8 +252,6 @@ static int hda_codec_probe(struct snd_soc_component *component)
260252
parse_pcms_err:
261253
if (driver->ops && driver->ops->remove)
262254
driver->ops->remove(codec);
263-
else if (codec->patch_ops.free)
264-
codec->patch_ops.free(codec);
265255
err:
266256
snd_hda_codec_cleanup_for_unbind(codec);
267257
device_new_err:
@@ -292,8 +282,6 @@ static void hda_codec_remove(struct snd_soc_component *component)
292282

293283
if (driver->ops && driver->ops->remove)
294284
driver->ops->remove(codec);
295-
else if (codec->patch_ops.free)
296-
codec->patch_ops.free(codec);
297285

298286
snd_hda_codec_cleanup_for_unbind(codec);
299287
pm_runtime_put_noidle(&hdev->dev);

sound/soc/codecs/hdac_hda.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
411411
struct hda_codec *hcodec = hda_pvt->codec;
412412
struct hda_codec_driver *driver = hda_codec_to_driver(hcodec);
413413
struct hdac_ext_link *hlink;
414-
hda_codec_patch_t patch;
415414
int ret;
416415

417416
hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev));
@@ -485,23 +484,15 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
485484
goto error_pm;
486485
}
487486

488-
if (driver->ops && driver->ops->probe) {
489-
ret = driver->ops->probe(hcodec, hcodec->preset);
490-
if (ret < 0) {
491-
dev_err(&hdev->dev, "%s: probe failed %d\n", __func__, ret);
492-
goto error_regmap;
493-
}
494-
} else {
495-
patch = (hda_codec_patch_t)hcodec->preset->driver_data;
496-
if (patch) {
497-
ret = patch(hcodec);
498-
if (ret < 0) {
499-
dev_err(&hdev->dev, "%s: patch failed %d\n", __func__, ret);
500-
goto error_regmap;
501-
}
502-
} else {
503-
dev_dbg(&hdev->dev, "%s: no patch file found\n", __func__);
504-
}
487+
if (WARN_ON(!(driver->ops && driver->ops->probe))) {
488+
ret = -EINVAL;
489+
goto error_regmap;
490+
}
491+
492+
ret = driver->ops->probe(hcodec, hcodec->preset);
493+
if (ret < 0) {
494+
dev_err(&hdev->dev, "%s: probe failed %d\n", __func__, ret);
495+
goto error_regmap;
505496
}
506497

507498
ret = snd_hda_codec_parse_pcms(hcodec);
@@ -542,8 +533,6 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
542533
error_patch:
543534
if (driver->ops && driver->ops->remove)
544535
driver->ops->remove(hcodec);
545-
else if (hcodec->patch_ops.free)
546-
hcodec->patch_ops.free(hcodec);
547536
error_regmap:
548537
snd_hdac_regmap_exit(hdev);
549538
error_pm:
@@ -573,8 +562,6 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)
573562

574563
if (driver->ops && driver->ops->remove)
575564
driver->ops->remove(codec);
576-
else if (codec->patch_ops.free)
577-
codec->patch_ops.free(codec);
578565

579566
snd_hda_codec_cleanup_for_unbind(codec);
580567
}

0 commit comments

Comments
 (0)