diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-17 12:09:10 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-17 12:09:10 -0400 |
commit | 6f84083bbb7d206c8555e5834a2c9b887452fd54 (patch) | |
tree | b19d6916d590b0f5531700d624866580385ec597 /drivers | |
parent | 8f29cd9f12e97d46e601f59810ea6aadd938945d (diff) |
ide-floppy: use drive->capacity64 for caching current capacity
* Use drive->capacity64 for caching current capacity.
* Switch ide_floppy_capacity() to use drive->capacity64.
* Call set_capacity() in idefloppy_open() and ide_floppy_probe()
instead of ide_floppy_get_capacity().
There should be no functional changes caused by this patch.
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-floppy.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 4a3d7e08b65a..3271e56d091c 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -445,7 +445,9 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
445 | drive->name, lba_capacity, capacity); | 445 | drive->name, lba_capacity, capacity); |
446 | floppy->blocks = floppy->block_size ? | 446 | floppy->blocks = floppy->block_size ? |
447 | capacity / floppy->block_size : 0; | 447 | capacity / floppy->block_size : 0; |
448 | drive->capacity64 = floppy->blocks * floppy->bs_factor; | ||
448 | } | 449 | } |
450 | |||
449 | return 0; | 451 | return 0; |
450 | } | 452 | } |
451 | 453 | ||
@@ -466,7 +468,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
466 | drive->bios_head = drive->bios_sect = 0; | 468 | drive->bios_head = drive->bios_sect = 0; |
467 | floppy->blocks = 0; | 469 | floppy->blocks = 0; |
468 | floppy->bs_factor = 1; | 470 | floppy->bs_factor = 1; |
469 | set_capacity(floppy->disk, 0); | 471 | drive->capacity64 = 0; |
470 | 472 | ||
471 | ide_floppy_create_read_capacity_cmd(&pc); | 473 | ide_floppy_create_read_capacity_cmd(&pc); |
472 | if (ide_queue_pc_tail(drive, disk, &pc)) { | 474 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
@@ -523,6 +525,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
523 | "non 512 bytes block size not " | 525 | "non 512 bytes block size not " |
524 | "fully supported\n", | 526 | "fully supported\n", |
525 | drive->name); | 527 | drive->name); |
528 | drive->capacity64 = | ||
529 | floppy->blocks * floppy->bs_factor; | ||
526 | rc = 0; | 530 | rc = 0; |
527 | } | 531 | } |
528 | break; | 532 | break; |
@@ -547,17 +551,12 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
547 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | 551 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
548 | (void) ide_floppy_get_flexible_disk_page(drive); | 552 | (void) ide_floppy_get_flexible_disk_page(drive); |
549 | 553 | ||
550 | set_capacity(disk, floppy->blocks * floppy->bs_factor); | ||
551 | |||
552 | return rc; | 554 | return rc; |
553 | } | 555 | } |
554 | 556 | ||
555 | sector_t ide_floppy_capacity(ide_drive_t *drive) | 557 | sector_t ide_floppy_capacity(ide_drive_t *drive) |
556 | { | 558 | { |
557 | idefloppy_floppy_t *floppy = drive->driver_data; | 559 | return drive->capacity64; |
558 | unsigned long capacity = floppy->blocks * floppy->bs_factor; | ||
559 | |||
560 | return capacity; | ||
561 | } | 560 | } |
562 | 561 | ||
563 | static void idefloppy_setup(ide_drive_t *drive) | 562 | static void idefloppy_setup(ide_drive_t *drive) |
@@ -671,14 +670,16 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
671 | if (ide_do_test_unit_ready(drive, disk)) | 670 | if (ide_do_test_unit_ready(drive, disk)) |
672 | ide_do_start_stop(drive, disk, 1); | 671 | ide_do_start_stop(drive, disk, 1); |
673 | 672 | ||
674 | if (ide_floppy_get_capacity(drive) | 673 | ret = ide_floppy_get_capacity(drive); |
675 | && (filp->f_flags & O_NDELAY) == 0 | 674 | |
675 | set_capacity(disk, ide_floppy_capacity(drive)); | ||
676 | |||
677 | if (ret && (filp->f_flags & O_NDELAY) == 0) { | ||
676 | /* | 678 | /* |
677 | * Allow O_NDELAY to open a drive without a disk, or with an | 679 | * Allow O_NDELAY to open a drive without a disk, or with an |
678 | * unreadable disk, so that we can get the format capacity | 680 | * unreadable disk, so that we can get the format capacity |
679 | * of the drive or begin the format - Sam | 681 | * of the drive or begin the format - Sam |
680 | */ | 682 | */ |
681 | ) { | ||
682 | ret = -EIO; | 683 | ret = -EIO; |
683 | goto out_put_floppy; | 684 | goto out_put_floppy; |
684 | } | 685 | } |
@@ -811,6 +812,8 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
811 | 812 | ||
812 | idefloppy_setup(drive); | 813 | idefloppy_setup(drive); |
813 | 814 | ||
815 | set_capacity(g, ide_floppy_capacity(drive)); | ||
816 | |||
814 | g->minors = 1 << PARTN_BITS; | 817 | g->minors = 1 << PARTN_BITS; |
815 | g->driverfs_dev = &drive->gendev; | 818 | g->driverfs_dev = &drive->gendev; |
816 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) | 819 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) |