Commit b26ca10f authored by Patrick Mochel's avatar Patrick Mochel

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. 
parent 03c84d71
......@@ -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;
}
......
......@@ -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 {
......
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