diff options
-rw-r--r-- | block/blk-integrity.c | 5 | ||||
-rw-r--r-- | block/blk-sysfs.c | 4 | ||||
-rw-r--r-- | block/genhd.c | 27 | ||||
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 4 | ||||
-rw-r--r-- | drivers/block/nbd.c | 4 | ||||
-rw-r--r-- | drivers/ide/ide-probe.c | 2 | ||||
-rw-r--r-- | drivers/md/dm.c | 4 | ||||
-rw-r--r-- | drivers/md/md.c | 10 | ||||
-rw-r--r-- | fs/block_dev.c | 4 | ||||
-rw-r--r-- | fs/partitions/check.c | 79 | ||||
-rw-r--r-- | include/linux/genhd.h | 20 |
11 files changed, 86 insertions, 77 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index d87606eaca1d..69023da63151 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -331,7 +331,8 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) | |||
331 | return -1; | 331 | return -1; |
332 | 332 | ||
333 | if (kobject_init_and_add(&bi->kobj, &integrity_ktype, | 333 | if (kobject_init_and_add(&bi->kobj, &integrity_ktype, |
334 | &disk->dev.kobj, "%s", "integrity")) { | 334 | &disk_to_dev(disk)->kobj, |
335 | "%s", "integrity")) { | ||
335 | kmem_cache_free(integrity_cachep, bi); | 336 | kmem_cache_free(integrity_cachep, bi); |
336 | return -1; | 337 | return -1; |
337 | } | 338 | } |
@@ -375,7 +376,7 @@ void blk_integrity_unregister(struct gendisk *disk) | |||
375 | 376 | ||
376 | kobject_uevent(&bi->kobj, KOBJ_REMOVE); | 377 | kobject_uevent(&bi->kobj, KOBJ_REMOVE); |
377 | kobject_del(&bi->kobj); | 378 | kobject_del(&bi->kobj); |
378 | kobject_put(&disk->dev.kobj); | 379 | kobject_put(&disk_to_dev(disk)->kobj); |
379 | kmem_cache_free(integrity_cachep, bi); | 380 | kmem_cache_free(integrity_cachep, bi); |
380 | } | 381 | } |
381 | EXPORT_SYMBOL(blk_integrity_unregister); | 382 | EXPORT_SYMBOL(blk_integrity_unregister); |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 304ec73ab821..b9a6ed166649 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -310,7 +310,7 @@ int blk_register_queue(struct gendisk *disk) | |||
310 | if (!q->request_fn) | 310 | if (!q->request_fn) |
311 | return 0; | 311 | return 0; |
312 | 312 | ||
313 | ret = kobject_add(&q->kobj, kobject_get(&disk->dev.kobj), | 313 | ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj), |
314 | "%s", "queue"); | 314 | "%s", "queue"); |
315 | if (ret < 0) | 315 | if (ret < 0) |
316 | return ret; | 316 | return ret; |
@@ -339,6 +339,6 @@ void blk_unregister_queue(struct gendisk *disk) | |||
339 | 339 | ||
340 | kobject_uevent(&q->kobj, KOBJ_REMOVE); | 340 | kobject_uevent(&q->kobj, KOBJ_REMOVE); |
341 | kobject_del(&q->kobj); | 341 | kobject_del(&q->kobj); |
342 | kobject_put(&disk->dev.kobj); | 342 | kobject_put(&disk_to_dev(disk)->kobj); |
343 | } | 343 | } |
344 | } | 344 | } |
diff --git a/block/genhd.c b/block/genhd.c index 67e5a59ced2a..0a2f16bd54b7 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -59,7 +59,7 @@ struct hd_struct *disk_get_part(struct gendisk *disk, int partno) | |||
59 | rcu_read_lock(); | 59 | rcu_read_lock(); |
60 | part = rcu_dereference(disk->__part[partno - 1]); | 60 | part = rcu_dereference(disk->__part[partno - 1]); |
61 | if (part) | 61 | if (part) |
62 | get_device(&part->dev); | 62 | get_device(part_to_dev(part)); |
63 | rcu_read_unlock(); | 63 | rcu_read_unlock(); |
64 | 64 | ||
65 | return part; | 65 | return part; |
@@ -130,7 +130,7 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter) | |||
130 | if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects) | 130 | if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects) |
131 | continue; | 131 | continue; |
132 | 132 | ||
133 | get_device(&part->dev); | 133 | get_device(part_to_dev(part)); |
134 | piter->part = part; | 134 | piter->part = part; |
135 | piter->idx += inc; | 135 | piter->idx += inc; |
136 | break; | 136 | break; |
@@ -435,7 +435,7 @@ static struct kobject *exact_match(dev_t devt, int *partno, void *data) | |||
435 | { | 435 | { |
436 | struct gendisk *p = data; | 436 | struct gendisk *p = data; |
437 | 437 | ||
438 | return &p->dev.kobj; | 438 | return &disk_to_dev(p)->kobj; |
439 | } | 439 | } |
440 | 440 | ||
441 | static int exact_lock(dev_t devt, void *data) | 441 | static int exact_lock(dev_t devt, void *data) |
@@ -460,7 +460,7 @@ void add_disk(struct gendisk *disk) | |||
460 | int retval; | 460 | int retval; |
461 | 461 | ||
462 | disk->flags |= GENHD_FL_UP; | 462 | disk->flags |= GENHD_FL_UP; |
463 | disk->dev.devt = MKDEV(disk->major, disk->first_minor); | 463 | disk_to_dev(disk)->devt = MKDEV(disk->major, disk->first_minor); |
464 | blk_register_region(disk_devt(disk), disk->minors, NULL, | 464 | blk_register_region(disk_devt(disk), disk->minors, NULL, |
465 | exact_match, exact_lock, disk); | 465 | exact_match, exact_lock, disk); |
466 | register_disk(disk); | 466 | register_disk(disk); |
@@ -468,7 +468,8 @@ void add_disk(struct gendisk *disk) | |||
468 | 468 | ||
469 | bdi = &disk->queue->backing_dev_info; | 469 | bdi = &disk->queue->backing_dev_info; |
470 | bdi_register_dev(bdi, disk_devt(disk)); | 470 | bdi_register_dev(bdi, disk_devt(disk)); |
471 | retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi"); | 471 | retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, |
472 | "bdi"); | ||
472 | WARN_ON(retval); | 473 | WARN_ON(retval); |
473 | } | 474 | } |
474 | 475 | ||
@@ -477,7 +478,7 @@ EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */ | |||
477 | 478 | ||
478 | void unlink_gendisk(struct gendisk *disk) | 479 | void unlink_gendisk(struct gendisk *disk) |
479 | { | 480 | { |
480 | sysfs_remove_link(&disk->dev.kobj, "bdi"); | 481 | sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi"); |
481 | bdi_unregister(&disk->queue->backing_dev_info); | 482 | bdi_unregister(&disk->queue->backing_dev_info); |
482 | blk_unregister_queue(disk); | 483 | blk_unregister_queue(disk); |
483 | blk_unregister_region(disk_devt(disk), disk->minors); | 484 | blk_unregister_region(disk_devt(disk), disk->minors); |
@@ -903,7 +904,7 @@ static int diskstats_show(struct seq_file *seqf, void *v) | |||
903 | int cpu; | 904 | int cpu; |
904 | 905 | ||
905 | /* | 906 | /* |
906 | if (&gp->dev.kobj.entry == block_class.devices.next) | 907 | if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next) |
907 | seq_puts(seqf, "major minor name" | 908 | seq_puts(seqf, "major minor name" |
908 | " rio rmerge rsect ruse wio wmerge " | 909 | " rio rmerge rsect ruse wio wmerge " |
909 | "wsect wuse running use aveq" | 910 | "wsect wuse running use aveq" |
@@ -972,7 +973,7 @@ static void media_change_notify_thread(struct work_struct *work) | |||
972 | * set enviroment vars to indicate which event this is for | 973 | * set enviroment vars to indicate which event this is for |
973 | * so that user space will know to go check the media status. | 974 | * so that user space will know to go check the media status. |
974 | */ | 975 | */ |
975 | kobject_uevent_env(&gd->dev.kobj, KOBJ_CHANGE, envp); | 976 | kobject_uevent_env(&disk_to_dev(gd)->kobj, KOBJ_CHANGE, envp); |
976 | put_device(gd->driverfs_dev); | 977 | put_device(gd->driverfs_dev); |
977 | } | 978 | } |
978 | 979 | ||
@@ -1062,9 +1063,9 @@ struct gendisk *alloc_disk_ext_node(int minors, int ext_minors, int node_id) | |||
1062 | disk->minors = minors; | 1063 | disk->minors = minors; |
1063 | disk->ext_minors = ext_minors; | 1064 | disk->ext_minors = ext_minors; |
1064 | rand_initialize_disk(disk); | 1065 | rand_initialize_disk(disk); |
1065 | disk->dev.class = &block_class; | 1066 | disk_to_dev(disk)->class = &block_class; |
1066 | disk->dev.type = &disk_type; | 1067 | disk_to_dev(disk)->type = &disk_type; |
1067 | device_initialize(&disk->dev); | 1068 | device_initialize(disk_to_dev(disk)); |
1068 | INIT_WORK(&disk->async_notify, | 1069 | INIT_WORK(&disk->async_notify, |
1069 | media_change_notify_thread); | 1070 | media_change_notify_thread); |
1070 | } | 1071 | } |
@@ -1086,7 +1087,7 @@ struct kobject *get_disk(struct gendisk *disk) | |||
1086 | owner = disk->fops->owner; | 1087 | owner = disk->fops->owner; |
1087 | if (owner && !try_module_get(owner)) | 1088 | if (owner && !try_module_get(owner)) |
1088 | return NULL; | 1089 | return NULL; |
1089 | kobj = kobject_get(&disk->dev.kobj); | 1090 | kobj = kobject_get(&disk_to_dev(disk)->kobj); |
1090 | if (kobj == NULL) { | 1091 | if (kobj == NULL) { |
1091 | module_put(owner); | 1092 | module_put(owner); |
1092 | return NULL; | 1093 | return NULL; |
@@ -1100,7 +1101,7 @@ EXPORT_SYMBOL(get_disk); | |||
1100 | void put_disk(struct gendisk *disk) | 1101 | void put_disk(struct gendisk *disk) |
1101 | { | 1102 | { |
1102 | if (disk) | 1103 | if (disk) |
1103 | kobject_put(&disk->dev.kobj); | 1104 | kobject_put(&disk_to_dev(disk)->kobj); |
1104 | } | 1105 | } |
1105 | 1106 | ||
1106 | EXPORT_SYMBOL(put_disk); | 1107 | EXPORT_SYMBOL(put_disk); |
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 0c39782b2660..3edb6cb7d68f 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -109,12 +109,12 @@ static const struct attribute_group attr_group = { | |||
109 | static int | 109 | static int |
110 | aoedisk_add_sysfs(struct aoedev *d) | 110 | aoedisk_add_sysfs(struct aoedev *d) |
111 | { | 111 | { |
112 | return sysfs_create_group(&d->gd->dev.kobj, &attr_group); | 112 | return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group); |
113 | } | 113 | } |
114 | void | 114 | void |
115 | aoedisk_rm_sysfs(struct aoedev *d) | 115 | aoedisk_rm_sysfs(struct aoedev *d) |
116 | { | 116 | { |
117 | sysfs_remove_group(&d->gd->dev.kobj, &attr_group); | 117 | sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group); |
118 | } | 118 | } |
119 | 119 | ||
120 | static int | 120 | static int |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 1778e4a2c672..7b3351260d56 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -403,7 +403,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
403 | BUG_ON(lo->magic != LO_MAGIC); | 403 | BUG_ON(lo->magic != LO_MAGIC); |
404 | 404 | ||
405 | lo->pid = current->pid; | 405 | lo->pid = current->pid; |
406 | ret = sysfs_create_file(&lo->disk->dev.kobj, &pid_attr.attr); | 406 | ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); |
407 | if (ret) { | 407 | if (ret) { |
408 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); | 408 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); |
409 | return ret; | 409 | return ret; |
@@ -412,7 +412,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
412 | while ((req = nbd_read_stat(lo)) != NULL) | 412 | while ((req = nbd_read_stat(lo)) != NULL) |
413 | nbd_end_request(req); | 413 | nbd_end_request(req); |
414 | 414 | ||
415 | sysfs_remove_file(&lo->disk->dev.kobj, &pid_attr.attr); | 415 | sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); |
416 | return 0; | 416 | return 0; |
417 | } | 417 | } |
418 | 418 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index a51a30e9eab3..70aa86c8807e 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1188,7 +1188,7 @@ static struct kobject *exact_match(dev_t dev, int *part, void *data) | |||
1188 | { | 1188 | { |
1189 | struct gendisk *p = data; | 1189 | struct gendisk *p = data; |
1190 | *part &= (1 << PARTN_BITS) - 1; | 1190 | *part &= (1 << PARTN_BITS) - 1; |
1191 | return &p->dev.kobj; | 1191 | return &disk_to_dev(p)->kobj; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | static int exact_lock(dev_t dev, void *data) | 1194 | static int exact_lock(dev_t dev, void *data) |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 653624792eaf..637806695bb9 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -1186,7 +1186,7 @@ static void event_callback(void *context) | |||
1186 | list_splice_init(&md->uevent_list, &uevents); | 1186 | list_splice_init(&md->uevent_list, &uevents); |
1187 | spin_unlock_irqrestore(&md->uevent_lock, flags); | 1187 | spin_unlock_irqrestore(&md->uevent_lock, flags); |
1188 | 1188 | ||
1189 | dm_send_uevents(&uevents, &md->disk->dev.kobj); | 1189 | dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj); |
1190 | 1190 | ||
1191 | atomic_inc(&md->event_nr); | 1191 | atomic_inc(&md->event_nr); |
1192 | wake_up(&md->eventq); | 1192 | wake_up(&md->eventq); |
@@ -1643,7 +1643,7 @@ out: | |||
1643 | *---------------------------------------------------------------*/ | 1643 | *---------------------------------------------------------------*/ |
1644 | void dm_kobject_uevent(struct mapped_device *md) | 1644 | void dm_kobject_uevent(struct mapped_device *md) |
1645 | { | 1645 | { |
1646 | kobject_uevent(&md->disk->dev.kobj, KOBJ_CHANGE); | 1646 | kobject_uevent(&disk_to_dev(md->disk)->kobj, KOBJ_CHANGE); |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | uint32_t dm_next_uevent_seq(struct mapped_device *md) | 1649 | uint32_t dm_next_uevent_seq(struct mapped_device *md) |
diff --git a/drivers/md/md.c b/drivers/md/md.c index deeac4b44173..96e9fccd2eab 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1465,9 +1465,9 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1465 | goto fail; | 1465 | goto fail; |
1466 | 1466 | ||
1467 | if (rdev->bdev->bd_part) | 1467 | if (rdev->bdev->bd_part) |
1468 | ko = &rdev->bdev->bd_part->dev.kobj; | 1468 | ko = &part_to_dev(rdev->bdev->bd_part)->kobj; |
1469 | else | 1469 | else |
1470 | ko = &rdev->bdev->bd_disk->dev.kobj; | 1470 | ko = &disk_to_dev(rdev->bdev->bd_disk)->kobj; |
1471 | if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) { | 1471 | if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) { |
1472 | kobject_del(&rdev->kobj); | 1472 | kobject_del(&rdev->kobj); |
1473 | goto fail; | 1473 | goto fail; |
@@ -3470,8 +3470,8 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) | |||
3470 | disk->queue = mddev->queue; | 3470 | disk->queue = mddev->queue; |
3471 | add_disk(disk); | 3471 | add_disk(disk); |
3472 | mddev->gendisk = disk; | 3472 | mddev->gendisk = disk; |
3473 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj, | 3473 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, |
3474 | "%s", "md"); | 3474 | &disk_to_dev(disk)->kobj, "%s", "md"); |
3475 | mutex_unlock(&disks_mutex); | 3475 | mutex_unlock(&disks_mutex); |
3476 | if (error) | 3476 | if (error) |
3477 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", | 3477 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", |
@@ -3761,7 +3761,7 @@ static int do_md_run(mddev_t * mddev) | |||
3761 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3761 | sysfs_notify(&mddev->kobj, NULL, "array_state"); |
3762 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); | 3762 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); |
3763 | sysfs_notify(&mddev->kobj, NULL, "degraded"); | 3763 | sysfs_notify(&mddev->kobj, NULL, "degraded"); |
3764 | kobject_uevent(&mddev->gendisk->dev.kobj, KOBJ_CHANGE); | 3764 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
3765 | return 0; | 3765 | return 0; |
3766 | } | 3766 | } |
3767 | 3767 | ||
diff --git a/fs/block_dev.c b/fs/block_dev.c index 2f2873b9a041..a02df22f37c3 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -543,9 +543,9 @@ EXPORT_SYMBOL(bd_release); | |||
543 | static struct kobject *bdev_get_kobj(struct block_device *bdev) | 543 | static struct kobject *bdev_get_kobj(struct block_device *bdev) |
544 | { | 544 | { |
545 | if (bdev->bd_contains != bdev) | 545 | if (bdev->bd_contains != bdev) |
546 | return kobject_get(&bdev->bd_part->dev.kobj); | 546 | return kobject_get(&part_to_dev(bdev->bd_part)->kobj); |
547 | else | 547 | else |
548 | return kobject_get(&bdev->bd_disk->dev.kobj); | 548 | return kobject_get(&disk_to_dev(bdev->bd_disk)->kobj); |
549 | } | 549 | } |
550 | 550 | ||
551 | static struct kobject *bdev_get_holder(struct block_device *bdev) | 551 | static struct kobject *bdev_get_holder(struct block_device *bdev) |
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 0d4b7f28f13f..ac0df3acdcda 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -309,7 +309,7 @@ static inline void disk_sysfs_add_subdirs(struct gendisk *disk) | |||
309 | { | 309 | { |
310 | struct kobject *k; | 310 | struct kobject *k; |
311 | 311 | ||
312 | k = kobject_get(&disk->dev.kobj); | 312 | k = kobject_get(&disk_to_dev(disk)->kobj); |
313 | disk->holder_dir = kobject_create_and_add("holders", k); | 313 | disk->holder_dir = kobject_create_and_add("holders", k); |
314 | disk->slave_dir = kobject_create_and_add("slaves", k); | 314 | disk->slave_dir = kobject_create_and_add("slaves", k); |
315 | kobject_put(k); | 315 | kobject_put(k); |
@@ -322,7 +322,7 @@ static void delete_partition_rcu_cb(struct rcu_head *head) | |||
322 | part->start_sect = 0; | 322 | part->start_sect = 0; |
323 | part->nr_sects = 0; | 323 | part->nr_sects = 0; |
324 | part_stat_set_all(part, 0); | 324 | part_stat_set_all(part, 0); |
325 | put_device(&part->dev); | 325 | put_device(part_to_dev(part)); |
326 | } | 326 | } |
327 | 327 | ||
328 | void delete_partition(struct gendisk *disk, int partno) | 328 | void delete_partition(struct gendisk *disk, int partno) |
@@ -336,7 +336,7 @@ void delete_partition(struct gendisk *disk, int partno) | |||
336 | blk_free_devt(part_devt(part)); | 336 | blk_free_devt(part_devt(part)); |
337 | rcu_assign_pointer(disk->__part[partno-1], NULL); | 337 | rcu_assign_pointer(disk->__part[partno-1], NULL); |
338 | kobject_put(part->holder_dir); | 338 | kobject_put(part->holder_dir); |
339 | device_del(&part->dev); | 339 | device_del(part_to_dev(part)); |
340 | 340 | ||
341 | call_rcu(&part->rcu_head, delete_partition_rcu_cb); | 341 | call_rcu(&part->rcu_head, delete_partition_rcu_cb); |
342 | } | 342 | } |
@@ -354,6 +354,9 @@ int add_partition(struct gendisk *disk, int partno, | |||
354 | { | 354 | { |
355 | struct hd_struct *p; | 355 | struct hd_struct *p; |
356 | dev_t devt = MKDEV(0, 0); | 356 | dev_t devt = MKDEV(0, 0); |
357 | struct device *ddev = disk_to_dev(disk); | ||
358 | struct device *pdev; | ||
359 | const char *dname; | ||
357 | int err; | 360 | int err; |
358 | 361 | ||
359 | if (disk->__part[partno - 1]) | 362 | if (disk->__part[partno - 1]) |
@@ -367,42 +370,43 @@ int add_partition(struct gendisk *disk, int partno, | |||
367 | err = -ENOMEM; | 370 | err = -ENOMEM; |
368 | goto out_free; | 371 | goto out_free; |
369 | } | 372 | } |
373 | pdev = part_to_dev(p); | ||
374 | |||
370 | p->start_sect = start; | 375 | p->start_sect = start; |
371 | p->nr_sects = len; | 376 | p->nr_sects = len; |
372 | p->partno = partno; | 377 | p->partno = partno; |
373 | p->policy = disk->policy; | 378 | p->policy = disk->policy; |
374 | 379 | ||
375 | if (isdigit(disk->dev.bus_id[strlen(disk->dev.bus_id)-1])) | 380 | dname = dev_name(ddev); |
376 | snprintf(p->dev.bus_id, BUS_ID_SIZE, | 381 | if (isdigit(dname[strlen(dname) - 1])) |
377 | "%sp%d", disk->dev.bus_id, partno); | 382 | snprintf(pdev->bus_id, BUS_ID_SIZE, "%sp%d", dname, partno); |
378 | else | 383 | else |
379 | snprintf(p->dev.bus_id, BUS_ID_SIZE, | 384 | snprintf(pdev->bus_id, BUS_ID_SIZE, "%s%d", dname, partno); |
380 | "%s%d", disk->dev.bus_id, partno); | ||
381 | 385 | ||
382 | device_initialize(&p->dev); | 386 | device_initialize(pdev); |
383 | p->dev.class = &block_class; | 387 | pdev->class = &block_class; |
384 | p->dev.type = &part_type; | 388 | pdev->type = &part_type; |
385 | p->dev.parent = &disk->dev; | 389 | pdev->parent = ddev; |
386 | 390 | ||
387 | err = blk_alloc_devt(p, &devt); | 391 | err = blk_alloc_devt(p, &devt); |
388 | if (err) | 392 | if (err) |
389 | goto out_put; | 393 | goto out_free; |
390 | p->dev.devt = devt; | 394 | pdev->devt = devt; |
391 | 395 | ||
392 | /* delay uevent until 'holders' subdir is created */ | 396 | /* delay uevent until 'holders' subdir is created */ |
393 | p->dev.uevent_suppress = 1; | 397 | pdev->uevent_suppress = 1; |
394 | err = device_add(&p->dev); | 398 | err = device_add(pdev); |
395 | if (err) | 399 | if (err) |
396 | goto out_put; | 400 | goto out_put; |
397 | 401 | ||
398 | err = -ENOMEM; | 402 | err = -ENOMEM; |
399 | p->holder_dir = kobject_create_and_add("holders", &p->dev.kobj); | 403 | p->holder_dir = kobject_create_and_add("holders", &pdev->kobj); |
400 | if (!p->holder_dir) | 404 | if (!p->holder_dir) |
401 | goto out_del; | 405 | goto out_del; |
402 | 406 | ||
403 | p->dev.uevent_suppress = 0; | 407 | pdev->uevent_suppress = 0; |
404 | if (flags & ADDPART_FLAG_WHOLEDISK) { | 408 | if (flags & ADDPART_FLAG_WHOLEDISK) { |
405 | err = device_create_file(&p->dev, &dev_attr_whole_disk); | 409 | err = device_create_file(pdev, &dev_attr_whole_disk); |
406 | if (err) | 410 | if (err) |
407 | goto out_del; | 411 | goto out_del; |
408 | } | 412 | } |
@@ -412,8 +416,8 @@ int add_partition(struct gendisk *disk, int partno, | |||
412 | rcu_assign_pointer(disk->__part[partno - 1], p); | 416 | rcu_assign_pointer(disk->__part[partno - 1], p); |
413 | 417 | ||
414 | /* suppress uevent if the disk supresses it */ | 418 | /* suppress uevent if the disk supresses it */ |
415 | if (!disk->dev.uevent_suppress) | 419 | if (!ddev->uevent_suppress) |
416 | kobject_uevent(&p->dev.kobj, KOBJ_ADD); | 420 | kobject_uevent(&pdev->kobj, KOBJ_ADD); |
417 | 421 | ||
418 | return 0; | 422 | return 0; |
419 | 423 | ||
@@ -422,9 +426,9 @@ out_free: | |||
422 | return err; | 426 | return err; |
423 | out_del: | 427 | out_del: |
424 | kobject_put(p->holder_dir); | 428 | kobject_put(p->holder_dir); |
425 | device_del(&p->dev); | 429 | device_del(pdev); |
426 | out_put: | 430 | out_put: |
427 | put_device(&p->dev); | 431 | put_device(pdev); |
428 | blk_free_devt(devt); | 432 | blk_free_devt(devt); |
429 | return err; | 433 | return err; |
430 | } | 434 | } |
@@ -432,30 +436,31 @@ out_put: | |||
432 | /* Not exported, helper to add_disk(). */ | 436 | /* Not exported, helper to add_disk(). */ |
433 | void register_disk(struct gendisk *disk) | 437 | void register_disk(struct gendisk *disk) |
434 | { | 438 | { |
439 | struct device *ddev = disk_to_dev(disk); | ||
435 | struct block_device *bdev; | 440 | struct block_device *bdev; |
436 | struct disk_part_iter piter; | 441 | struct disk_part_iter piter; |
437 | struct hd_struct *part; | 442 | struct hd_struct *part; |
438 | char *s; | 443 | char *s; |
439 | int err; | 444 | int err; |
440 | 445 | ||
441 | disk->dev.parent = disk->driverfs_dev; | 446 | ddev->parent = disk->driverfs_dev; |
442 | 447 | ||
443 | strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE); | 448 | strlcpy(ddev->bus_id, disk->disk_name, BUS_ID_SIZE); |
444 | /* ewww... some of these buggers have / in the name... */ | 449 | /* ewww... some of these buggers have / in the name... */ |
445 | s = strchr(disk->dev.bus_id, '/'); | 450 | s = strchr(ddev->bus_id, '/'); |
446 | if (s) | 451 | if (s) |
447 | *s = '!'; | 452 | *s = '!'; |
448 | 453 | ||
449 | /* delay uevents, until we scanned partition table */ | 454 | /* delay uevents, until we scanned partition table */ |
450 | disk->dev.uevent_suppress = 1; | 455 | ddev->uevent_suppress = 1; |
451 | 456 | ||
452 | if (device_add(&disk->dev)) | 457 | if (device_add(ddev)) |
453 | return; | 458 | return; |
454 | #ifndef CONFIG_SYSFS_DEPRECATED | 459 | #ifndef CONFIG_SYSFS_DEPRECATED |
455 | err = sysfs_create_link(block_depr, &disk->dev.kobj, | 460 | err = sysfs_create_link(block_depr, &ddev->kobj, |
456 | kobject_name(&disk->dev.kobj)); | 461 | kobject_name(&ddev->kobj)); |
457 | if (err) { | 462 | if (err) { |
458 | device_del(&disk->dev); | 463 | device_del(ddev); |
459 | return; | 464 | return; |
460 | } | 465 | } |
461 | #endif | 466 | #endif |
@@ -481,13 +486,13 @@ void register_disk(struct gendisk *disk) | |||
481 | 486 | ||
482 | exit: | 487 | exit: |
483 | /* announce disk after possible partitions are created */ | 488 | /* announce disk after possible partitions are created */ |
484 | disk->dev.uevent_suppress = 0; | 489 | ddev->uevent_suppress = 0; |
485 | kobject_uevent(&disk->dev.kobj, KOBJ_ADD); | 490 | kobject_uevent(&ddev->kobj, KOBJ_ADD); |
486 | 491 | ||
487 | /* announce possible partitions */ | 492 | /* announce possible partitions */ |
488 | disk_part_iter_init(&piter, disk, 0); | 493 | disk_part_iter_init(&piter, disk, 0); |
489 | while ((part = disk_part_iter_next(&piter))) | 494 | while ((part = disk_part_iter_next(&piter))) |
490 | kobject_uevent(&part->dev.kobj, KOBJ_ADD); | 495 | kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD); |
491 | disk_part_iter_exit(&piter); | 496 | disk_part_iter_exit(&piter); |
492 | } | 497 | } |
493 | 498 | ||
@@ -518,7 +523,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) | |||
518 | return -EIO; | 523 | return -EIO; |
519 | 524 | ||
520 | /* tell userspace that the media / partition table may have changed */ | 525 | /* tell userspace that the media / partition table may have changed */ |
521 | kobject_uevent(&disk->dev.kobj, KOBJ_CHANGE); | 526 | kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); |
522 | 527 | ||
523 | for (p = 1; p < state->limit; p++) { | 528 | for (p = 1; p < state->limit; p++) { |
524 | sector_t size = state->parts[p].size; | 529 | sector_t size = state->parts[p].size; |
@@ -591,7 +596,7 @@ void del_gendisk(struct gendisk *disk) | |||
591 | kobject_put(disk->slave_dir); | 596 | kobject_put(disk->slave_dir); |
592 | disk->driverfs_dev = NULL; | 597 | disk->driverfs_dev = NULL; |
593 | #ifndef CONFIG_SYSFS_DEPRECATED | 598 | #ifndef CONFIG_SYSFS_DEPRECATED |
594 | sysfs_remove_link(block_depr, disk->dev.bus_id); | 599 | sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); |
595 | #endif | 600 | #endif |
596 | device_del(&disk->dev); | 601 | device_del(disk_to_dev(disk)); |
597 | } | 602 | } |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 6fc532424062..e4e18c509ac5 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -15,9 +15,11 @@ | |||
15 | 15 | ||
16 | #ifdef CONFIG_BLOCK | 16 | #ifdef CONFIG_BLOCK |
17 | 17 | ||
18 | #define kobj_to_dev(k) container_of(k, struct device, kobj) | 18 | #define kobj_to_dev(k) container_of((k), struct device, kobj) |
19 | #define dev_to_disk(device) container_of(device, struct gendisk, dev) | 19 | #define dev_to_disk(device) container_of((device), struct gendisk, __dev) |
20 | #define dev_to_part(device) container_of(device, struct hd_struct, dev) | 20 | #define dev_to_part(device) container_of((device), struct hd_struct, __dev) |
21 | #define disk_to_dev(disk) (&((disk)->__dev)) | ||
22 | #define part_to_dev(part) (&((part)->__dev)) | ||
21 | 23 | ||
22 | extern struct device_type part_type; | 24 | extern struct device_type part_type; |
23 | extern struct kobject *block_depr; | 25 | extern struct kobject *block_depr; |
@@ -88,7 +90,7 @@ struct disk_stats { | |||
88 | struct hd_struct { | 90 | struct hd_struct { |
89 | sector_t start_sect; | 91 | sector_t start_sect; |
90 | sector_t nr_sects; | 92 | sector_t nr_sects; |
91 | struct device dev; | 93 | struct device __dev; |
92 | struct kobject *holder_dir; | 94 | struct kobject *holder_dir; |
93 | int policy, partno; | 95 | int policy, partno; |
94 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 96 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
@@ -139,7 +141,7 @@ struct gendisk { | |||
139 | 141 | ||
140 | int flags; | 142 | int flags; |
141 | struct device *driverfs_dev; // FIXME: remove | 143 | struct device *driverfs_dev; // FIXME: remove |
142 | struct device dev; | 144 | struct device __dev; |
143 | struct kobject *holder_dir; | 145 | struct kobject *holder_dir; |
144 | struct kobject *slave_dir; | 146 | struct kobject *slave_dir; |
145 | 147 | ||
@@ -163,7 +165,7 @@ struct gendisk { | |||
163 | static inline struct gendisk *part_to_disk(struct hd_struct *part) | 165 | static inline struct gendisk *part_to_disk(struct hd_struct *part) |
164 | { | 166 | { |
165 | if (likely(part)) | 167 | if (likely(part)) |
166 | return dev_to_disk((part)->dev.parent); | 168 | return dev_to_disk(part_to_dev(part)->parent); |
167 | return NULL; | 169 | return NULL; |
168 | } | 170 | } |
169 | 171 | ||
@@ -174,12 +176,12 @@ static inline int disk_max_parts(struct gendisk *disk) | |||
174 | 176 | ||
175 | static inline dev_t disk_devt(struct gendisk *disk) | 177 | static inline dev_t disk_devt(struct gendisk *disk) |
176 | { | 178 | { |
177 | return disk->dev.devt; | 179 | return disk_to_dev(disk)->devt; |
178 | } | 180 | } |
179 | 181 | ||
180 | static inline dev_t part_devt(struct hd_struct *part) | 182 | static inline dev_t part_devt(struct hd_struct *part) |
181 | { | 183 | { |
182 | return part->dev.devt; | 184 | return part_to_dev(part)->devt; |
183 | } | 185 | } |
184 | 186 | ||
185 | extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); | 187 | extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); |
@@ -187,7 +189,7 @@ extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); | |||
187 | static inline void disk_put_part(struct hd_struct *part) | 189 | static inline void disk_put_part(struct hd_struct *part) |
188 | { | 190 | { |
189 | if (likely(part)) | 191 | if (likely(part)) |
190 | put_device(&part->dev); | 192 | put_device(part_to_dev(part)); |
191 | } | 193 | } |
192 | 194 | ||
193 | /* | 195 | /* |