mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-10 15:58:47 +00:00
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>
This commit is contained in:
parent
8f29cd9f12
commit
6f84083bbb
@ -445,7 +445,9 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
|
|||||||
drive->name, lba_capacity, capacity);
|
drive->name, lba_capacity, capacity);
|
||||||
floppy->blocks = floppy->block_size ?
|
floppy->blocks = floppy->block_size ?
|
||||||
capacity / floppy->block_size : 0;
|
capacity / floppy->block_size : 0;
|
||||||
|
drive->capacity64 = floppy->blocks * floppy->bs_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +468,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
|
|||||||
drive->bios_head = drive->bios_sect = 0;
|
drive->bios_head = drive->bios_sect = 0;
|
||||||
floppy->blocks = 0;
|
floppy->blocks = 0;
|
||||||
floppy->bs_factor = 1;
|
floppy->bs_factor = 1;
|
||||||
set_capacity(floppy->disk, 0);
|
drive->capacity64 = 0;
|
||||||
|
|
||||||
ide_floppy_create_read_capacity_cmd(&pc);
|
ide_floppy_create_read_capacity_cmd(&pc);
|
||||||
if (ide_queue_pc_tail(drive, disk, &pc)) {
|
if (ide_queue_pc_tail(drive, disk, &pc)) {
|
||||||
@ -523,6 +525,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
|
|||||||
"non 512 bytes block size not "
|
"non 512 bytes block size not "
|
||||||
"fully supported\n",
|
"fully supported\n",
|
||||||
drive->name);
|
drive->name);
|
||||||
|
drive->capacity64 =
|
||||||
|
floppy->blocks * floppy->bs_factor;
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -547,17 +551,12 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
|
|||||||
if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
|
if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
|
||||||
(void) ide_floppy_get_flexible_disk_page(drive);
|
(void) ide_floppy_get_flexible_disk_page(drive);
|
||||||
|
|
||||||
set_capacity(disk, floppy->blocks * floppy->bs_factor);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
sector_t ide_floppy_capacity(ide_drive_t *drive)
|
sector_t ide_floppy_capacity(ide_drive_t *drive)
|
||||||
{
|
{
|
||||||
idefloppy_floppy_t *floppy = drive->driver_data;
|
return drive->capacity64;
|
||||||
unsigned long capacity = floppy->blocks * floppy->bs_factor;
|
|
||||||
|
|
||||||
return capacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void idefloppy_setup(ide_drive_t *drive)
|
static void idefloppy_setup(ide_drive_t *drive)
|
||||||
@ -671,14 +670,16 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
|
|||||||
if (ide_do_test_unit_ready(drive, disk))
|
if (ide_do_test_unit_ready(drive, disk))
|
||||||
ide_do_start_stop(drive, disk, 1);
|
ide_do_start_stop(drive, disk, 1);
|
||||||
|
|
||||||
if (ide_floppy_get_capacity(drive)
|
ret = ide_floppy_get_capacity(drive);
|
||||||
&& (filp->f_flags & O_NDELAY) == 0
|
|
||||||
|
set_capacity(disk, ide_floppy_capacity(drive));
|
||||||
|
|
||||||
|
if (ret && (filp->f_flags & O_NDELAY) == 0) {
|
||||||
/*
|
/*
|
||||||
* Allow O_NDELAY to open a drive without a disk, or with an
|
* Allow O_NDELAY to open a drive without a disk, or with an
|
||||||
* unreadable disk, so that we can get the format capacity
|
* unreadable disk, so that we can get the format capacity
|
||||||
* of the drive or begin the format - Sam
|
* of the drive or begin the format - Sam
|
||||||
*/
|
*/
|
||||||
) {
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto out_put_floppy;
|
goto out_put_floppy;
|
||||||
}
|
}
|
||||||
@ -811,6 +812,8 @@ static int ide_floppy_probe(ide_drive_t *drive)
|
|||||||
|
|
||||||
idefloppy_setup(drive);
|
idefloppy_setup(drive);
|
||||||
|
|
||||||
|
set_capacity(g, ide_floppy_capacity(drive));
|
||||||
|
|
||||||
g->minors = 1 << PARTN_BITS;
|
g->minors = 1 << PARTN_BITS;
|
||||||
g->driverfs_dev = &drive->gendev;
|
g->driverfs_dev = &drive->gendev;
|
||||||
if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
|
if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user