aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-03-13 17:07:03 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:26 -0400
commit3f62e5700b2a679ae987b32a68126dd6dcf2488f (patch)
tree4f8eda958d328b6fc068409c0fb464bc7c21266b
parent9a3df1f7de0ecaf77a1dde86f2a4dc020f37f87e (diff)
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: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/base/bus.c9
-rw-r--r--include/linux/device.h3
2 files changed, 3 insertions, 9 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2d207ad30336..450942acca1a 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev)
505 int ret = 0; 505 int ret = 0;
506 506
507 if (bus) { 507 if (bus) {
508 dev->is_registered = 1;
509 if (bus->p->drivers_autoprobe) 508 if (bus->p->drivers_autoprobe)
510 ret = device_attach(dev); 509 ret = device_attach(dev);
511 WARN_ON(ret < 0); 510 WARN_ON(ret < 0);
512 if (ret >= 0) 511 if (ret >= 0)
513 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 512 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
514 else
515 dev->is_registered = 0;
516 } 513 }
517} 514}
518 515
@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev)
533 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 530 sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
534 dev->bus_id); 531 dev->bus_id);
535 device_remove_attrs(dev->bus, dev); 532 device_remove_attrs(dev->bus, dev);
536 if (dev->is_registered) { 533 klist_del(&dev->knode_bus);
537 dev->is_registered = 0; 534
538 klist_del(&dev->knode_bus);
539 }
540 pr_debug("bus: '%s': remove device %s\n", 535 pr_debug("bus: '%s': remove device %s\n",
541 dev->bus->name, dev->bus_id); 536 dev->bus->name, dev->bus_id);
542 device_release_driver(dev); 537 device_release_driver(dev);
diff --git a/include/linux/device.h b/include/linux/device.h
index d7a1ae063b65..441461f5ee20 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -429,7 +429,6 @@ struct device {
429 struct kobject kobj; 429 struct kobject kobj;
430 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 430 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
431 struct device_type *type; 431 struct device_type *type;
432 unsigned is_registered:1;
433 unsigned uevent_suppress:1; 432 unsigned uevent_suppress:1;
434 433
435 struct semaphore sem; /* semaphore to synchronize calls to 434 struct semaphore sem; /* semaphore to synchronize calls to
@@ -509,7 +508,7 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
509 508
510static inline int device_is_registered(struct device *dev) 509static inline int device_is_registered(struct device *dev)
511{ 510{
512 return dev->is_registered; 511 return dev->kobj.state_in_sysfs;
513} 512}
514 513
515void driver_init(void); 514void driver_init(void);