diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-11-25 03:46:55 -0600 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-11-25 03:46:55 -0600 |
| commit | b26ca10f9fb9db8b164bb9225424cceee13cbeea (patch) | |
| tree | 82346dd5ec96571d4f1206ab90355e1905650865 | |
| parent | 03c84d71ae50d05ca5991a63c261ca8c3e009fa1 (diff) | |
fix up block device usage of kobjects.
alloc_disk() should set the kobject's subsystem before calling kobject_init(),
which would increment the subsystem's refcount (to be decremented in
kobject_cleanup()). Since it was being set after the call, the subsystem's
refcount was being pushed to 0 if the floppy driver was enabled, but there
were no floppy drives found (the driver would alloc_disk(), then put_disk() if
no drives were found).
Partitions use kobject_register(), so they don't have to do kobject_init()
(it's done for them).
add_disk() should use kobject_add() instead of kobject_register(), since
it's already done kobject_init() in alloc_disk().
Also, del_gendisk() doesn't have to do extra refcount and call
kobject_unregister(); it should just call kobject_del(). The block device
will be freed up later when put_disk() pushes the refcount to 0.
| -rw-r--r-- | drivers/block/genhd.c | 4 | ||||
| -rw-r--r-- | fs/partitions/check.c | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 5bba83e69485..97fb55011fe7 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -408,11 +408,11 @@ struct gendisk *alloc_disk(int minors) disk->minors = minors; while (minors >>= 1) disk->minor_shift++; - kobject_init(&disk->kobj); disk->kobj.subsys = &block_subsys; + kobject_init(&disk->kobj); INIT_LIST_HEAD(&disk->full_list); + rand_initialize_disk(disk); } - rand_initialize_disk(disk); return disk; } diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 102e9f1f651b..797343c18942 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -377,7 +377,6 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len) p->start_sect = start; p->nr_sects = len; devfs_register_partition(disk, part); - kobject_init(&p->kobj); snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part); p->kobj.parent = &disk->kobj; p->kobj.subsys = &part_subsys; @@ -406,7 +405,7 @@ void register_disk(struct gendisk *disk) s = strchr(disk->kobj.name, '/'); if (s) *s = '!'; - kobject_register(&disk->kobj); + kobject_add(&disk->kobj); disk_sysfs_symlinks(disk); if (disk->flags & GENHD_FL_CD) @@ -529,8 +528,7 @@ void del_gendisk(struct gendisk *disk) sysfs_remove_link(&disk->driverfs_dev->kobj, "block"); put_device(disk->driverfs_dev); } - kobject_get(&disk->kobj); /* kobject model is fucked in head */ - kobject_unregister(&disk->kobj); + kobject_del(&disk->kobj); } struct dev_name { |
