Commit 3f62e570 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Driver core: make device_is_registered() work for class devices

device_is_registered() can use the kobject value for this, so it will
now work with devices that are associated with only a class, not a bus
and a driver.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9a3df1f7
...@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev) ...@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev)
int ret = 0; int ret = 0;
if (bus) { if (bus) {
dev->is_registered = 1;
if (bus->p->drivers_autoprobe) if (bus->p->drivers_autoprobe)
ret = device_attach(dev); ret = device_attach(dev);
WARN_ON(ret < 0); WARN_ON(ret < 0);
if (ret >= 0) if (ret >= 0)
klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
else
dev->is_registered = 0;
} }
} }
...@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev) ...@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev)
sysfs_remove_link(&dev->bus->p->devices_kset->kobj, sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
dev->bus_id); dev->bus_id);
device_remove_attrs(dev->bus, dev); device_remove_attrs(dev->bus, dev);
if (dev->is_registered) { klist_del(&dev->knode_bus);
dev->is_registered = 0;
klist_del(&dev->knode_bus);
}
pr_debug("bus: '%s': remove device %s\n", pr_debug("bus: '%s': remove device %s\n",
dev->bus->name, dev->bus_id); dev->bus->name, dev->bus_id);
device_release_driver(dev); device_release_driver(dev);
......
...@@ -429,7 +429,6 @@ struct device { ...@@ -429,7 +429,6 @@ struct device {
struct kobject kobj; struct kobject kobj;
char bus_id[BUS_ID_SIZE]; /* position on parent bus */ char bus_id[BUS_ID_SIZE]; /* position on parent bus */
struct device_type *type; struct device_type *type;
unsigned is_registered:1;
unsigned uevent_suppress:1; unsigned uevent_suppress:1;
struct semaphore sem; /* semaphore to synchronize calls to struct semaphore sem; /* semaphore to synchronize calls to
...@@ -509,7 +508,7 @@ static inline void dev_set_drvdata(struct device *dev, void *data) ...@@ -509,7 +508,7 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
static inline int device_is_registered(struct device *dev) static inline int device_is_registered(struct device *dev)
{ {
return dev->is_registered; return dev->kobj.state_in_sysfs;
} }
void driver_init(void); void driver_init(void);
......
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