diff options
| author | Patrick Mochel <mochel@osdl.org> | 2003-01-04 23:08:51 -0600 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2003-01-04 23:08:51 -0600 |
| commit | d7677dc711c772fd8cf792fbc9387af27b09e86a (patch) | |
| tree | 0a471ea4433de0f0adda45f0ffc4386b7551d495 | |
| parent | 1d0619c5bcec6ce9f7ce577899bffcbf83d2aa44 (diff) | |
| parent | 8624ae3d2d3928a83d54585dd053583d81d781f2 (diff) | |
Merge bk://linux.bkbits.net/linux-2.5
into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-virgin
| -rw-r--r-- | drivers/base/bus.c | 16 | ||||
| -rw-r--r-- | drivers/base/intf.c | 24 | ||||
| -rw-r--r-- | fs/partitions/check.c | 5 | ||||
| -rw-r--r-- | include/linux/device.h | 2 | ||||
| -rw-r--r-- | include/linux/kobject.h | 2 | ||||
| -rw-r--r-- | lib/kobject.c | 11 |
6 files changed, 29 insertions, 31 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index ca5ef19aa4a9..4cd3e9e002a4 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -19,7 +19,7 @@ static DECLARE_MUTEX(bus_sem); #define to_dev(node) container_of(node,struct device,bus_list) -#define to_drv(node) container_of(node,struct device_driver,bus_list) +#define to_drv(node) container_of(node,struct device_driver,kobj.entry) #define to_bus_attr(_attr) container_of(_attr,struct bus_attribute,attr) #define to_bus(obj) container_of(obj,struct bus_type,subsys.kobj) @@ -203,9 +203,9 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, if(!(bus = get_bus(bus))) return -EINVAL; - head = start ? &start->bus_list : &bus->drivers; + head = start ? &start->kobj.entry : &bus->drvsubsys.list; - down_read(&bus->subsys.rwsem); + down_read(&bus->drvsubsys.rwsem); list_for_each(entry,head) { struct device_driver * drv = get_driver(to_drv(entry)); error = fn(drv,data); @@ -213,7 +213,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, if(error) break; } - up_read(&bus->subsys.rwsem); + up_read(&bus->drvsubsys.rwsem); return error; } @@ -287,9 +287,8 @@ static int device_attach(struct device * dev) if (!bus->match) return 0; - list_for_each(entry,&bus->drivers) { - struct device_driver * drv = - container_of(entry,struct device_driver,bus_list); + list_for_each(entry,&bus->drvsubsys.list) { + struct device_driver * drv = to_drv(entry); if (!(error = bus_match(dev,drv))) break; } @@ -437,7 +436,6 @@ int bus_add_driver(struct device_driver * drv) kobject_register(&drv->kobj); devclass_add_driver(drv); - list_add_tail(&drv->bus_list,&bus->drivers); driver_attach(drv); up_write(&bus->subsys.rwsem); } @@ -460,7 +458,6 @@ void bus_remove_driver(struct device_driver * drv) down_write(&drv->bus->subsys.rwsem); pr_debug("bus %s: remove driver %s\n",drv->bus->name,drv->name); driver_detach(drv); - list_del_init(&drv->bus_list); devclass_remove_driver(drv); kobject_unregister(&drv->kobj); up_write(&drv->bus->subsys.rwsem); @@ -491,7 +488,6 @@ void put_bus(struct bus_type * bus) int bus_register(struct bus_type * bus) { INIT_LIST_HEAD(&bus->devices); - INIT_LIST_HEAD(&bus->drivers); down(&bus_sem); strncpy(bus->subsys.kobj.name,bus->name,KOBJ_NAME_LEN); diff --git a/drivers/base/intf.c b/drivers/base/intf.c index 63c5a4d12cd4..83e98a1e9a02 100644 --- a/drivers/base/intf.c +++ b/drivers/base/intf.c @@ -14,9 +14,6 @@ #define to_data(e) container_of(e,struct intf_data,kobj.entry) -#define intf_from_data(d) container_of(d->kobj.subsys,struct device_interface, subsys); - - /** * intf_dev_link - create sysfs symlink for interface. * @data: interface data descriptor. @@ -61,15 +58,18 @@ static void intf_dev_unlink(struct intf_data * data) int interface_add_data(struct intf_data * data) { - struct device_interface * intf = intf_from_data(data); + struct device_interface * intf = data->intf; - data->intf_num = data->intf->devnum++; - data->kobj.subsys = &intf->subsys; - kobject_register(&data->kobj); + if (intf) { + data->intf_num = intf->devnum++; + data->kobj.subsys = &intf->subsys; + kobject_register(&data->kobj); - list_add_tail(&data->dev_entry,&data->dev->intf_list); - intf_dev_link(data); - return 0; + list_add_tail(&data->dev_entry,&data->dev->intf_list); + intf_dev_link(data); + return 0; + } + return -EINVAL; } @@ -121,9 +121,9 @@ static int add(struct device_interface * intf, struct device * dev) static void del(struct intf_data * data) { - struct device_interface * intf = intf_from_data(data); + struct device_interface * intf = data->intf; - pr_debug(" -> %s ",data->intf->name); + pr_debug(" -> %s ",intf->name); interface_remove_data(data); if (intf->remove_device) intf->remove_device(data); diff --git a/fs/partitions/check.c b/fs/partitions/check.c index b1d436feb241..8950a2d03ba7 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -19,7 +19,6 @@ #include <linux/blk.h> #include <linux/kmod.h> #include <linux/ctype.h> -#include <../drivers/base/fs/fs.h> /* Eeeeewwwww */ #include "check.h" @@ -399,13 +398,15 @@ void register_disk(struct gendisk *disk) struct block_device *bdev; char *s; int j; + int err; strncpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN); /* ewww... some of these buggers have / in name... */ s = strchr(disk->kobj.name, '/'); if (s) *s = '!'; - kobject_add(&disk->kobj); + if ((err = kobject_add(&disk->kobj))) + return; disk_sysfs_symlinks(disk); if (disk->flags & GENHD_FL_CD) diff --git a/include/linux/device.h b/include/linux/device.h index a2d6e8171f9b..1552ec5a4abd 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -69,7 +69,6 @@ struct bus_type { struct subsystem drvsubsys; struct subsystem devsubsys; struct list_head devices; - struct list_head drivers; int (*match)(struct device * dev, struct device_driver * drv); struct device * (*add) (struct device * parent, char * bus_id); @@ -119,7 +118,6 @@ struct device_driver { struct semaphore unload_sem; struct kobject kobj; - struct list_head bus_list; struct list_head class_list; struct list_head devices; diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 6b528c5a61cb..821d17e15a01 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -52,7 +52,7 @@ extern void subsystem_unregister(struct subsystem *); static inline struct subsystem * subsys_get(struct subsystem * s) { - return container_of(kobject_get(&s->kobj),struct subsystem,kobj); + return s ? container_of(kobject_get(&s->kobj),struct subsystem,kobj) : NULL; } static inline void subsys_put(struct subsystem * s) diff --git a/lib/kobject.c b/lib/kobject.c index 04b1fd760d45..24807bc72f81 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -74,10 +74,13 @@ int kobject_add(struct kobject * kobj) { int error = 0; struct subsystem * s = kobj->subsys; - struct kobject * parent = kobject_get(kobj->parent); + struct kobject * parent; if (!(kobj = kobject_get(kobj))) return -ENOENT; + + parent = kobject_get(kobj->parent); + pr_debug("kobject %s: registering. parent: %s, subsys: %s\n", kobj->name, parent ? parent->name : "<NULL>", kobj->subsys ? kobj->subsys->kobj.name : "<NULL>" ); @@ -93,8 +96,8 @@ int kobject_add(struct kobject * kobj) up_write(&s->rwsem); } error = create_dir(kobj); - if (error && kobj->parent) - kobject_put(kobj->parent); + if (error && parent) + kobject_put(parent); return error; } @@ -218,7 +221,7 @@ int subsystem_register(struct subsystem * s) s->kobj.parent = &s->parent->kobj; pr_debug("subsystem %s: registering, parent: %s\n", s->kobj.name,s->parent ? s->parent->kobj.name : "<none>"); - return kobject_register(&s->kobj); + return kobject_add(&s->kobj); } void subsystem_unregister(struct subsystem * s) |
