[PATCH 08/18] ide-floppy: use drive->capacity64 for caching current capacity

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bartlomiej Zolnierkiewicz
Date: Sunday, September 7, 2008 - 3:15 pm

* 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>
---
 drivers/ide/ide-floppy.c |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Index: b/drivers/ide/ide-floppy.c
===================================================================
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -445,7 +445,9 @@ static int ide_floppy_get_flexible_disk_
 			drive->name, lba_capacity, capacity);
 		floppy->blocks = floppy->block_size ?
 			capacity / floppy->block_size : 0;
+		drive->capacity64 = floppy->blocks * floppy->bs_factor;
 	}
+
 	return 0;
 }
 
@@ -466,7 +468,7 @@ static int ide_floppy_get_capacity(ide_d
 	drive->bios_head = drive->bios_sect = 0;
 	floppy->blocks = 0;
 	floppy->bs_factor = 1;
-	set_capacity(floppy->disk, 0);
+	drive->capacity64 = 0;
 
 	ide_floppy_create_read_capacity_cmd(&pc);
 	if (ide_queue_pc_tail(drive, disk, &pc)) {
@@ -523,6 +525,8 @@ static int ide_floppy_get_capacity(ide_d
 					       "non 512 bytes block size not "
 					       "fully supported\n",
 					       drive->name);
+				drive->capacity64 =
+					floppy->blocks * floppy->bs_factor;
 				rc = 0;
 			}
 			break;
@@ -547,17 +551,12 @@ static int ide_floppy_get_capacity(ide_d
 	if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
 		(void) ide_floppy_get_flexible_disk_page(drive);
 
-	set_capacity(disk, floppy->blocks * floppy->bs_factor);
-
 	return rc;
 }
 
 sector_t ide_floppy_capacity(ide_drive_t *drive)
 {
-	idefloppy_floppy_t *floppy = drive->driver_data;
-	unsigned long capacity = floppy->blocks * floppy->bs_factor;
-
-	return capacity;
+	return drive->capacity64;
 }
 
 static void idefloppy_setup(ide_drive_t *drive)
@@ -671,14 +670,16 @@ static int idefloppy_open(struct inode *
 		if (ide_do_test_unit_ready(drive, disk))
 			ide_do_start_stop(drive, disk, 1);
 
-		if (ide_floppy_get_capacity(drive)
-		   && (filp->f_flags & O_NDELAY) == 0
+		ret = ide_floppy_get_capacity(drive);
+
+		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
 		     * unreadable disk, so that we can get the format capacity
 		     * of the drive or begin the format - Sam
 		     */
-		    ) {
 			ret = -EIO;
 			goto out_put_floppy;
 		}
@@ -811,6 +812,8 @@ static int ide_floppy_probe(ide_drive_t 
 
 	idefloppy_setup(drive);
 
+	set_capacity(g, ide_floppy_capacity(drive));
+
 	g->minors = 1 << PARTN_BITS;
 	g->driverfs_dev = &drive->gendev;
 	if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/18] ide: add generic ATA/ATAPI disk driver, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 01/18] ide-disk: fix IDE_DFLAG_LBA48 handling on resume, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 02/18] ide-disk: lock media before checking for med ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 03/18] ide-floppy: use alloc_disk_node(), Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 04/18] ide-disk: use to_ide_drv() and ide_drv_g(), Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 05/18] ide-disk: move IDE_DFLAG_DOORLOCKING flag ha ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 06/18] ide-{disk,floppy}: set IDE_DFLAG_ATTACH in * ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 07/18] ide-floppy: drop 'floppy' argument from idef ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 08/18] ide-floppy: use drive->capacity64 for cachin ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 09/18] ide: IDE_AFLAG_MEDIA_CHANGED -&gt; IDE_DFLAG_ME ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 10/18] ide: IDE_AFLAG_WP -&gt; IDE_DFLAG_WP, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 11/18] ide: IDE_AFLAG_FORMAT_IN_PROGRESS -&gt; IDE_DFL ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 12/18] ide: remove IDE_AFLAG_NO_DOORLOCKING, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 13/18] ide-disk: factor out generic disk handling c ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 14/18] ide-disk: use IDE_DFLAG_MEDIA_CHANGED, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 15/18] ide-floppy: factor out generic disk handling ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 16/18] ide: prepare for merging ide-gd-floppy.c wit ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 17/18] ide: allow device drivers to specify per-dev ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 18/18] ide: add generic ATA/ATAPI disk driver, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
Re: [PATCH 00/18] ide: add generic ATA/ATAPI disk driver, Borislav Petkov, (Wed Sep 10, 4:20 am)
Re: [PATCH 08/18] ide-floppy: use drive-&gt;capacity64 for ca ..., Bartlomiej Zolnierki ..., (Sat Sep 27, 8:34 am)