diff options
author | Tejun Heo <tj@kernel.org> | 2010-05-15 14:09:29 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2010-05-21 14:01:02 -0400 |
commit | c3e33e043f5e9c583aa59d5591a614b2a8243d3a (patch) | |
tree | fe8fef91dafb670fad1f433ae48514472b8d23e5 | |
parent | 56bca01738733709bef076e2e97bbd01e5659f24 (diff) |
block,ide: simplify bdops->set_capacity() to ->unlock_native_capacity()
bdops->set_capacity() is unnecessarily generic. All that's required
is a simple one way notification to lower level driver telling it to
try to unlock native capacity. There's no reason to pass in target
capacity or return the new capacity. The former is always the
inherent native capacity and the latter can be handled via the usual
device resize / revalidation path. In fact, the current API is always
used that way.
Replace ->set_capacity() with ->unlock_native_capacity() which take
only @disk and doesn't return anything. IDE which is the only current
user of the API is converted accordingly.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | drivers/ide/ide-disk.c | 40 | ||||
-rw-r--r-- | drivers/ide/ide-gd.c | 11 | ||||
-rw-r--r-- | fs/partitions/check.c | 4 | ||||
-rw-r--r-- | include/linux/blkdev.h | 3 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
5 files changed, 24 insertions, 36 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 3b128dce9c3a..33d65039cce9 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -407,32 +407,24 @@ static int ide_disk_get_capacity(ide_drive_t *drive) | |||
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity) | 410 | static void ide_disk_unlock_native_capacity(ide_drive_t *drive) |
411 | { | 411 | { |
412 | u64 set = min(capacity, drive->probed_capacity); | ||
413 | u16 *id = drive->id; | 412 | u16 *id = drive->id; |
414 | int lba48 = ata_id_lba48_enabled(id); | 413 | int lba48 = ata_id_lba48_enabled(id); |
415 | 414 | ||
416 | if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || | 415 | if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || |
417 | ata_id_hpa_enabled(id) == 0) | 416 | ata_id_hpa_enabled(id) == 0) |
418 | goto out; | 417 | return; |
419 | 418 | ||
420 | /* | 419 | /* |
421 | * according to the spec the SET MAX ADDRESS command shall be | 420 | * according to the spec the SET MAX ADDRESS command shall be |
422 | * immediately preceded by a READ NATIVE MAX ADDRESS command | 421 | * immediately preceded by a READ NATIVE MAX ADDRESS command |
423 | */ | 422 | */ |
424 | capacity = ide_disk_hpa_get_native_capacity(drive, lba48); | 423 | if (!ide_disk_hpa_get_native_capacity(drive, lba48)) |
425 | if (capacity == 0) | 424 | return; |
426 | goto out; | 425 | |
427 | 426 | if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48)) | |
428 | set = ide_disk_hpa_set_capacity(drive, set, lba48); | 427 | drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */ |
429 | if (set) { | ||
430 | /* needed for ->resume to disable HPA */ | ||
431 | drive->dev_flags |= IDE_DFLAG_NOHPA; | ||
432 | return set; | ||
433 | } | ||
434 | out: | ||
435 | return drive->capacity64; | ||
436 | } | 428 | } |
437 | 429 | ||
438 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | 430 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) |
@@ -783,13 +775,13 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk, | |||
783 | } | 775 | } |
784 | 776 | ||
785 | const struct ide_disk_ops ide_ata_disk_ops = { | 777 | const struct ide_disk_ops ide_ata_disk_ops = { |
786 | .check = ide_disk_check, | 778 | .check = ide_disk_check, |
787 | .set_capacity = ide_disk_set_capacity, | 779 | .unlock_native_capacity = ide_disk_unlock_native_capacity, |
788 | .get_capacity = ide_disk_get_capacity, | 780 | .get_capacity = ide_disk_get_capacity, |
789 | .setup = ide_disk_setup, | 781 | .setup = ide_disk_setup, |
790 | .flush = ide_disk_flush, | 782 | .flush = ide_disk_flush, |
791 | .init_media = ide_disk_init_media, | 783 | .init_media = ide_disk_init_media, |
792 | .set_doorlock = ide_disk_set_doorlock, | 784 | .set_doorlock = ide_disk_set_doorlock, |
793 | .do_request = ide_do_rw_disk, | 785 | .do_request = ide_do_rw_disk, |
794 | .ioctl = ide_disk_ioctl, | 786 | .ioctl = ide_disk_ioctl, |
795 | }; | 787 | }; |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index c32d83996ae1..c102d23d9b38 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -288,17 +288,14 @@ static int ide_gd_media_changed(struct gendisk *disk) | |||
288 | return ret; | 288 | return ret; |
289 | } | 289 | } |
290 | 290 | ||
291 | static unsigned long long ide_gd_set_capacity(struct gendisk *disk, | 291 | static void ide_gd_unlock_native_capacity(struct gendisk *disk) |
292 | unsigned long long capacity) | ||
293 | { | 292 | { |
294 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); | 293 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); |
295 | ide_drive_t *drive = idkp->drive; | 294 | ide_drive_t *drive = idkp->drive; |
296 | const struct ide_disk_ops *disk_ops = drive->disk_ops; | 295 | const struct ide_disk_ops *disk_ops = drive->disk_ops; |
297 | 296 | ||
298 | if (disk_ops->set_capacity) | 297 | if (disk_ops->unlock_native_capacity) |
299 | return disk_ops->set_capacity(drive, capacity); | 298 | disk_ops->unlock_native_capacity(drive); |
300 | |||
301 | return drive->capacity64; | ||
302 | } | 299 | } |
303 | 300 | ||
304 | static int ide_gd_revalidate_disk(struct gendisk *disk) | 301 | static int ide_gd_revalidate_disk(struct gendisk *disk) |
@@ -329,7 +326,7 @@ static const struct block_device_operations ide_gd_ops = { | |||
329 | .locked_ioctl = ide_gd_ioctl, | 326 | .locked_ioctl = ide_gd_ioctl, |
330 | .getgeo = ide_gd_getgeo, | 327 | .getgeo = ide_gd_getgeo, |
331 | .media_changed = ide_gd_media_changed, | 328 | .media_changed = ide_gd_media_changed, |
332 | .set_capacity = ide_gd_set_capacity, | 329 | .unlock_native_capacity = ide_gd_unlock_native_capacity, |
333 | .revalidate_disk = ide_gd_revalidate_disk | 330 | .revalidate_disk = ide_gd_revalidate_disk |
334 | }; | 331 | }; |
335 | 332 | ||
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 8f01df354f04..4f1fee0355ad 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -601,10 +601,10 @@ rescan: | |||
601 | "%s: p%d size %llu exceeds device capacity, ", | 601 | "%s: p%d size %llu exceeds device capacity, ", |
602 | disk->disk_name, p, (unsigned long long) size); | 602 | disk->disk_name, p, (unsigned long long) size); |
603 | 603 | ||
604 | if (bdops->set_capacity && | 604 | if (bdops->unlock_native_capacity && |
605 | (disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) { | 605 | (disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) { |
606 | printk(KERN_CONT "enabling native capacity\n"); | 606 | printk(KERN_CONT "enabling native capacity\n"); |
607 | bdops->set_capacity(disk, ~0ULL); | 607 | bdops->unlock_native_capacity(disk); |
608 | disk->flags |= GENHD_FL_NATIVE_CAPACITY; | 608 | disk->flags |= GENHD_FL_NATIVE_CAPACITY; |
609 | /* free state and restart */ | 609 | /* free state and restart */ |
610 | kfree(state); | 610 | kfree(state); |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 346fd4856733..be411c12ebbe 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1330,8 +1330,7 @@ struct block_device_operations { | |||
1330 | int (*direct_access) (struct block_device *, sector_t, | 1330 | int (*direct_access) (struct block_device *, sector_t, |
1331 | void **, unsigned long *); | 1331 | void **, unsigned long *); |
1332 | int (*media_changed) (struct gendisk *); | 1332 | int (*media_changed) (struct gendisk *); |
1333 | unsigned long long (*set_capacity) (struct gendisk *, | 1333 | void (*unlock_native_capacity) (struct gendisk *); |
1334 | unsigned long long); | ||
1335 | int (*revalidate_disk) (struct gendisk *); | 1334 | int (*revalidate_disk) (struct gendisk *); |
1336 | int (*getgeo)(struct block_device *, struct hd_geometry *); | 1335 | int (*getgeo)(struct block_device *, struct hd_geometry *); |
1337 | struct module *owner; | 1336 | struct module *owner; |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 3239d1c10acb..b6d448048ae2 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -362,7 +362,7 @@ struct ide_drive_s; | |||
362 | struct ide_disk_ops { | 362 | struct ide_disk_ops { |
363 | int (*check)(struct ide_drive_s *, const char *); | 363 | int (*check)(struct ide_drive_s *, const char *); |
364 | int (*get_capacity)(struct ide_drive_s *); | 364 | int (*get_capacity)(struct ide_drive_s *); |
365 | u64 (*set_capacity)(struct ide_drive_s *, u64); | 365 | void (*unlock_native_capacity)(struct ide_drive_s *); |
366 | void (*setup)(struct ide_drive_s *); | 366 | void (*setup)(struct ide_drive_s *); |
367 | void (*flush)(struct ide_drive_s *); | 367 | void (*flush)(struct ide_drive_s *); |
368 | int (*init_media)(struct ide_drive_s *, struct gendisk *); | 368 | int (*init_media)(struct ide_drive_s *, struct gendisk *); |