Commit 5f330849 authored by Patrick Mochel's avatar Patrick Mochel

driver model: make sure device has driver when we add it to the class.

There is a chance devclass_add_device() could get passed a device with no driver, so
we need to check that.
parent 0447d4d5
...@@ -53,16 +53,20 @@ static void unenum_device(struct device_class * cls, struct device * dev) ...@@ -53,16 +53,20 @@ static void unenum_device(struct device_class * cls, struct device * dev)
int devclass_add_device(struct device * dev) int devclass_add_device(struct device * dev)
{ {
struct device_class * cls = dev->driver->devclass; struct device_class * cls;
int error = 0; int error = 0;
if (cls) {
pr_debug("adding device '%s' to class '%s'\n", if (dev->driver) {
dev->name,cls->name); cls = dev->driver->devclass;
if (cls->add_device) if (cls) {
error = cls->add_device(dev); pr_debug("adding device '%s' to class '%s'\n",
if (!error) { dev->name,cls->name);
enum_device(cls,dev); if (cls->add_device)
interface_add(cls,dev); error = cls->add_device(dev);
if (!error) {
enum_device(cls,dev);
interface_add(cls,dev);
}
} }
} }
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment