forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/sound/pci/hda/hda_bind.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * HD-audio codec driver binding
34 * Copyright (c) Takashi Iwai <tiwai@suse.de>
....@@ -11,7 +12,7 @@
1112 #include <linux/pm.h>
1213 #include <linux/pm_runtime.h>
1314 #include <sound/core.h>
14
-#include "hda_codec.h"
15
+#include <sound/hda_codec.h>
1516 #include "hda_local.h"
1617
1718 /*
....@@ -89,6 +90,12 @@
8990 hda_codec_patch_t patch;
9091 int err;
9192
93
+ if (codec->bus->core.ext_ops) {
94
+ if (WARN_ON(!codec->bus->core.ext_ops->hdev_attach))
95
+ return -EINVAL;
96
+ return codec->bus->core.ext_ops->hdev_attach(&codec->core);
97
+ }
98
+
9299 if (WARN_ON(!codec->preset))
93100 return -EINVAL;
94101
....@@ -142,6 +149,12 @@
142149 static int hda_codec_driver_remove(struct device *dev)
143150 {
144151 struct hda_codec *codec = dev_to_hda_codec(dev);
152
+
153
+ if (codec->bus->core.ext_ops) {
154
+ if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach))
155
+ return -EINVAL;
156
+ return codec->bus->core.ext_ops->hdev_detach(&codec->core);
157
+ }
145158
146159 if (codec->patch_ops.free)
147160 codec->patch_ops.free(codec);
....@@ -288,29 +301,31 @@
288301 {
289302 int err;
290303
304
+ if (codec->configured)
305
+ return 0;
306
+
291307 if (is_generic_config(codec))
292308 codec->probe_id = HDA_CODEC_ID_GENERIC;
293309 else
294310 codec->probe_id = 0;
295311
296
- err = snd_hdac_device_register(&codec->core);
297
- if (err < 0)
298
- return err;
312
+ if (!device_is_registered(&codec->core.dev)) {
313
+ err = snd_hdac_device_register(&codec->core);
314
+ if (err < 0)
315
+ return err;
316
+ }
299317
300318 if (!codec->preset)
301319 codec_bind_module(codec);
302320 if (!codec->preset) {
303321 err = codec_bind_generic(codec);
304322 if (err < 0) {
305
- codec_err(codec, "Unable to bind the codec\n");
306
- goto error;
323
+ codec_dbg(codec, "Unable to bind the codec\n");
324
+ return err;
307325 }
308326 }
309327
328
+ codec->configured = 1;
310329 return 0;
311
-
312
- error:
313
- snd_hdac_device_unregister(&codec->core);
314
- return err;
315330 }
316331 EXPORT_SYMBOL_GPL(snd_hda_codec_configure);