@@ -76,7 +76,6 @@ static void ac97_codec_release(struct device *dev)
adev = to_ac97_device(dev);
ac97_ctrl = adev->ac97_ctrl;
ac97_ctrl->codecs[adev->num] = NULL;
- sysfs_remove_link(&dev->kobj, "ac97_controller");
kfree(adev);
}
@@ -269,8 +268,29 @@ static const struct attribute_group *ac97_adapter_groups[] = {
NULL,
};
+static void ac97_del_adapter(struct ac97_controller *ac97_ctrl)
+{
+ mutex_lock(&ac97_controllers_mutex);
+ ac97_ctrl_codecs_unregister(ac97_ctrl);
+ list_del(&ac97_ctrl->controllers);
+ mutex_unlock(&ac97_controllers_mutex);
+
+ device_unregister(&ac97_ctrl->adap);
+}
+
+static void ac97_adapter_release(struct device *dev)
+{
+ struct ac97_controller *ac97_ctrl;
+
+ ac97_ctrl = to_ac97_controller(dev);
+ idr_remove(&ac97_adapter_idr, ac97_ctrl->nr);
+ dev_dbg(&ac97_ctrl->adap, "adapter unregistered by %s\n",
+ dev_name(ac97_ctrl->parent));
+}
+
static const struct device_type ac97_adapter_type = {
.groups = ac97_adapter_groups,
+ .release = ac97_adapter_release,
};
static int ac97_add_adapter(struct ac97_controller *ac97_ctrl)
@@ -298,16 +318,6 @@ static int ac97_add_adapter(struct ac97_controller *ac97_ctrl)
return ret;
}
-static void ac97_del_adapter(struct ac97_controller *ac97_ctrl)
-{
- mutex_lock(&ac97_controllers_mutex);
- ac97_ctrl_codecs_unregister(ac97_ctrl);
- list_del(&ac97_ctrl->controllers);
- idr_remove(&ac97_adapter_idr, ac97_ctrl->nr);
- mutex_unlock(&ac97_controllers_mutex);
- put_device(&ac97_ctrl->adap);
-}
-
/**
* snd_ac97_controller_register - register an ac97 controller
* @ops: the ac97 bus operations
@@ -508,7 +518,7 @@ static int ac97_bus_remove(struct device *dev)
}
static struct bus_type ac97_bus_type = {
- .name = "ac97",
+ .name = "ac97bus",
.dev_groups = ac97_dev_groups,
.match = ac97_bus_match,
.pm = &ac97_pm,
@@ -522,5 +532,11 @@ static int __init ac97_bus_init(void)
}
subsys_initcall(ac97_bus_init);
+static void __exit ac97_bus_exit(void)
+{
+ bus_unregister(&ac97_bus_type);
+}
+module_exit(ac97_bus_exit);
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>");