summaryrefslogtreecommitdiff
path: root/sound/hda
diff options
context:
space:
mode:
Diffstat (limited to 'sound/hda')
-rw-r--r--sound/hda/hdac_device.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index b26cc93e7e10..033bcef8751a 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -61,10 +61,6 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
pm_runtime_get_noresume(&codec->dev);
atomic_set(&codec->in_pm, 0);
- err = snd_hdac_bus_add_device(bus, codec);
- if (err < 0)
- goto error;
-
/* fill parameters */
codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT,
AC_PAR_VENDOR_ID);
@@ -143,15 +139,22 @@ int snd_hdac_device_register(struct hdac_device *codec)
err = device_add(&codec->dev);
if (err < 0)
return err;
+ err = snd_hdac_bus_add_device(codec->bus, codec);
+ if (err < 0)
+ goto error;
mutex_lock(&codec->widget_lock);
err = hda_widget_sysfs_init(codec);
mutex_unlock(&codec->widget_lock);
- if (err < 0) {
- device_del(&codec->dev);
- return err;
- }
+ if (err < 0)
+ goto error_remove;
return 0;
+
+ error_remove:
+ snd_hdac_bus_remove_device(codec->bus, codec);
+ error:
+ device_del(&codec->dev);
+ return err;
}
EXPORT_SYMBOL_GPL(snd_hdac_device_register);
@@ -165,8 +168,8 @@ void snd_hdac_device_unregister(struct hdac_device *codec)
mutex_lock(&codec->widget_lock);
hda_widget_sysfs_exit(codec);
mutex_unlock(&codec->widget_lock);
- device_del(&codec->dev);
snd_hdac_bus_remove_device(codec->bus, codec);
+ device_del(&codec->dev);
}
}
EXPORT_SYMBOL_GPL(snd_hdac_device_unregister);