ide: add generic ATA/ATAPI disk driver
cover ide: add generic ATA/ATAPI disk driver
[ Borislav, this is the 'futuristic' stuff that we were talking about. :) ]
Hi,
This patch series adds a generic ATA/ATAPI disk driver (ide-gd) replacing ide-disk and ide-floppy drivers. It is achieved by moving the common code to ide-gd.c, adding struct ide_disk_ops (which is used to abstract protocol specific details) and updating ide-{disk,floppy}.c accordingly.
The main goal is to make the code more maintainable / easier to extend later. As an immediate result we get driver specific debugging support for ATA disks and ability for driver specific Power Management for ATAPI devices. Otherwise it is really an initial merge (which means that in the future the code can be further unified, struct ide_disk_ops can be made more fine-grained etc.).
patches:
#01-02 drive-by bugfixes
#03-04 small improvements (good on their own) #05-12 small cleanups (good on their own)
#13-17 preparatory patches (just to make the review easier)
#18 the main patch
diffstat:
drivers/ide/Kconfig | 64 +-- drivers/ide/Makefile | 23 - drivers/ide/ide-atapi.c | 2 drivers/ide/ide-cd.c | 22 - drivers/ide/ide-cd_ioctl.c | 8 drivers/ide/ide-disk.c | 434 ++++------------------ drivers/ide/ide-disk.h | 35 - drivers/ide/ide-disk_ioctl.c | 6 drivers/ide/ide-disk_proc.c | 2 drivers/ide/ide-floppy.c | 419 +++------------------ drivers/ide/ide-floppy.h | 79 +--- drivers/ide/ide-floppy_ioctl.c | 15 drivers/ide/ide-floppy_proc.c | 2 drivers/ide/ide-gd-floppy.c | 802 ++++++++++++++++++++--------------------- drivers/ide/ide-gd.c | 437 +++++++++++++++++++++- drivers/ide/ide-gd.h | 44 ++ drivers/ide/ide-probe.c | 1 drivers/ide/ide-proc.c | 6 drivers/ide/ide-tape.c | 16 drivers/leds/Kconfig | 2 drivers/scsi/ide-scsi.c | 26 - include/linux/ide.h | 34 + 22 files changed, 1209 insertions(+), 1270 deletions(-)
PATCH 1/18 ide-disk: fix IDE_DFLAG_LBA48 handling on resume
Some code in idedisk_setup() should be in idedisk_capacity() instead.
--- drivers/ide/ide-disk.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/ide/ide-disk.c +20 -20
@@ -397,6 +397,26 @@ static void init_idedisk_capacity(ide_drif (ata_id_hpa_enabled (id))idedisk_check_hpa (drive); } + +/* limit drive capacity to 137GB if LBA48 cannot be used */ +if ((drive->dev_flags &IDE_DFLAG_LBA48 ) ==0 && + drive->capacity64 >1ULL <<28 ) { +printk (KERN_WARNING "%s: cannot use LBA48 - full capacity " +"%llu sectors (%llu MB)\n" , + drive->name, (unsigned long long )drive->capacity64, +sectors_to_MB (drive->capacity64)); + drive->capacity64 =1ULL <<28 ; + } + +if ((drive->hwif->host_flags &IDE_HFLAG_NO_LBA48_DMA ) && + (drive->dev_flags &IDE_DFLAG_LBA48 )) { +if (drive->capacity64 >1ULL <<28 ) { +printk (KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" +" will be used for accessing sectors " +"> %u\n" , drive->name,1 <<28 ); + }else + drive->dev_flags &= ~IDE_DFLAG_LBA48 ; + } }sector_t ide_disk_capacity (ide_drive_t *drive)
@@ -648,26 +668,6 @@ static void idedisk_setup(ide_drive_t *d/* calculate drive capacity, and select LBA if possible */ init_idedisk_capacity (drive); -/* limit drive capacity to 137GB if LBA48 cannot be used */ -if ((drive->dev_flags &IDE_DFLAG_LBA48 ) ==0 && - drive->capacity64 >1ULL <<28 ) { -printk (KERN_WARNING "%s: cannot use LBA48 - full capacity " -"%llu sectors (%llu MB)\n" , - drive->name, (unsigned long long )drive->capacity64, -sectors_to_MB (drive->capacity64)); - drive->capacity64 =1ULL <<28 ; - } - -if ((hwif->host_flags &IDE_HFLAG_NO_LBA48_DMA ) && - (drive->dev_flags &IDE_DFLAG_LBA48 )) { -if (drive->capacity64 >1ULL <<28 ) { -printk (KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" -" will be used for accessing sectors " -"> %u\n" , drive->name,1 <<28 ); - }else - drive->dev_flags &= ~IDE_DFLAG_LBA48 ; - } -/* * if possible, give fdisk access to more of the drive, * by correcting bios_cyls:
PATCH 2/18 ide-disk: lock media before checking for media change
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-disk.c +1 -1
@@ -836,7 +836,6 @@ static int idedisk_open(struct inode *in idkp->openers++;if ((drive->dev_flags &IDE_DFLAG_REMOVABLE ) && idkp->openers ==1 ) { -check_disk_change (inode->i_bdev);/* * Ignore the return code from door_lock, * since the open() has already succeeded,
@@ -845,6 +844,7 @@ static int idedisk_open(struct inode *inif ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) &&idedisk_set_doorlock (drive,1 )) drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; +check_disk_change (inode->i_bdev); }return 0 ; }
PATCH 3/18 ide-floppy: use alloc_disk_node()
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-floppy.c +1 -1
@@ -788,7 +788,7 @@ static int ide_floppy_probe(ide_drive_t goto failed; } - g =alloc_disk (1 <<PARTN_BITS ); + g =alloc_disk_node (1 <<PARTN_BITS ,hwif_to_node (drive->hwif));if (!g) goto out_free_floppy;
PATCH 4/18 ide-disk: use to_ide_drv() and ide_drv_g()
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-disk.c | 14 ++++++-------- drivers/ide/ide-disk.h | 3 --- drivers/ide/ide-disk_ioctl.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-)
drivers/ide/ide-disk.c +6 -8
@@ -43,8 +43,6 @@static DEFINE_MUTEX (idedisk_ref_mutex); -#define to_ide_disk (obj) container_of(obj, struct ide_disk_obj, kref) -static void ide_disk_release (struct kref *);static struct ide_disk_obj *ide_disk_get (struct gendisk *disk)
@@ -52,7 +50,7 @@ static struct ide_disk_obj *ide_disk_getstruct ide_disk_obj *idkp =NULL ;mutex_lock (&idedisk_ref_mutex); - idkp =ide_disk_g (disk); + idkp =ide_drv_g (disk, ide_disk_obj);if (idkp) {if (ide_device_get (idkp->drive)) idkp =NULL ;
@@ -740,7 +738,7 @@ static void ide_disk_remove(ide_drive_tstatic void ide_disk_release (struct kref *kref) { -struct ide_disk_obj *idkp =to_ide_disk (kref); +struct ide_disk_obj *idkp =to_ide_drv (kref, ide_disk_obj);ide_drive_t *drive = idkp->drive;struct gendisk *g = idkp->disk;
@@ -852,7 +850,7 @@ static int idedisk_open(struct inode *instatic int idedisk_release (struct inode *inode,struct file *filp) {struct gendisk *disk = inode->i_bdev->bd_disk; -struct ide_disk_obj *idkp =ide_disk_g (disk); +struct ide_disk_obj *idkp =ide_drv_g (disk, ide_disk_obj);ide_drive_t *drive = idkp->drive;if (idkp->openers ==1 )
@@ -873,7 +871,7 @@ static int idedisk_release(struct inodestatic int idedisk_getgeo (struct block_device *bdev,struct hd_geometry *geo) { -struct ide_disk_obj *idkp =ide_disk_g (bdev->bd_disk); +struct ide_disk_obj *idkp =ide_drv_g (bdev->bd_disk, ide_disk_obj);ide_drive_t *drive = idkp->drive; geo->heads = drive->bios_head;
@@ -884,7 +882,7 @@ static int idedisk_getgeo(struct block_dstatic int idedisk_media_changed (struct gendisk *disk) { -struct ide_disk_obj *idkp =ide_disk_g (disk); +struct ide_disk_obj *idkp =ide_drv_g (disk, ide_disk_obj);ide_drive_t *drive = idkp->drive;/* do not scan partitions twice if this is a removable device */
@@ -899,7 +897,7 @@ static int idedisk_media_changed(structstatic int idedisk_revalidate_disk (struct gendisk *disk) { -struct ide_disk_obj *idkp =ide_disk_g (disk); +struct ide_disk_obj *idkp =ide_drv_g (disk, ide_disk_obj);set_capacity (disk,ide_disk_capacity (idkp->drive));return 0 ; }
drivers/ide/ide-disk.h +0 -3
@@ -9,9 +9,6 @@ struct ide_disk_obj {unsigned int openers;/* protected by BKL for now */ }; -#define ide_disk_g (disk) \ - container_of((disk)->private_data, struct ide_disk_obj, driver) -/* ide-disk.c */ sector_t ide_disk_capacity (ide_drive_t *);ide_decl_devset (address);
drivers/ide/ide-disk_ioctl.c +1 -1
@@ -17,7 +17,7 @@ int ide_disk_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg) {struct block_device *bdev = inode->i_bdev; -struct ide_disk_obj *idkp =ide_disk_g (bdev->bd_disk); +struct ide_disk_obj *idkp =ide_drv_g (bdev->bd_disk, ide_disk_obj);ide_drive_t *drive = idkp->drive;int err;
PATCH 5/18 ide-disk: move IDE_DFLAG_DOORLOCKING flag handling to idedisk_set_doorlock()
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-disk.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/ide/ide-disk.c +13 -9
@@ -811,12 +811,21 @@ static ide_driver_t idedisk_driver = {static int idedisk_set_doorlock (ide_drive_t *drive,int on) {ide_task_t task; +int ret; + +if ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) ==0 ) +return 0 ;memset (&task,0 ,sizeof (task)); task.tf.command = on ?ATA_CMD_MEDIA_LOCK :ATA_CMD_MEDIA_UNLOCK ; task.tf_flags =IDE_TFLAG_TF |IDE_TFLAG_DEVICE ; -return ide_no_data_taskfile (drive, &task); + ret =ide_no_data_taskfile (drive, &task); + +if (ret) + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; + +return ret; }static int idedisk_open (struct inode *inode,struct file *filp)
@@ -839,9 +848,7 @@ static int idedisk_open(struct inode *in* since the open() has already succeeded, * and the door_lock is irrelevant at this point. */ -if ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) && -idedisk_set_doorlock (drive,1 )) - drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; +idedisk_set_doorlock (drive,1 );check_disk_change (inode->i_bdev); }return 0 ;
@@ -856,11 +863,8 @@ static int idedisk_release(struct inodeif (idkp->openers ==1 )ide_cacheflush_p (drive); -if ((drive->dev_flags &IDE_DFLAG_REMOVABLE ) && idkp->openers ==1 ) { -if ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) && -idedisk_set_doorlock (drive,0 )) - drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; - } +if ((drive->dev_flags &IDE_DFLAG_REMOVABLE ) && idkp->openers ==1 ) +idedisk_set_doorlock (drive,0 ); idkp->openers--;
PATCH 6/18 ide-{disk,floppy}: set IDE_DFLAG_ATTACH in *_setup()
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-disk.c | 18 ++++++++++-------- drivers/ide/ide-floppy.c | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/ide/ide-disk.c +10 -8
@@ -710,6 +710,14 @@ static void idedisk_setup(ide_drive_t *d drive->dev_flags |=IDE_DFLAG_WCACHE ;set_wcache (drive,1 ); + +if ((drive->dev_flags &IDE_DFLAG_LBA ) ==0 && + (drive->head ==0 || drive->head >16 )) { +printk (KERN_ERR "%s: invalid geometry: %d physical heads?\n" , + drive->name, drive->head); + drive->dev_flags &= ~IDE_DFLAG_ATTACH ; + }else + drive->dev_flags |=IDE_DFLAG_ATTACH ; }static void ide_cacheflush_p (ide_drive_t *drive)
@@ -952,19 +960,13 @@ static int ide_disk_probe(ide_drive_t *d drive->driver_data = idkp;idedisk_setup (drive); -if ((drive->dev_flags &IDE_DFLAG_LBA ) ==0 && - (drive->head ==0 || drive->head >16 )) { -printk (KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n" , - drive->name, drive->head); - drive->dev_flags &= ~IDE_DFLAG_ATTACH ; - }else - drive->dev_flags |=IDE_DFLAG_ATTACH ; + +set_capacity (g,ide_disk_capacity (drive)); g->minors =1 <<PARTN_BITS ; g->driverfs_dev = &drive->gendev;if (drive->dev_flags &IDE_DFLAG_REMOVABLE ) g->flags =GENHD_FL_REMOVABLE ; -set_capacity (g,ide_disk_capacity (drive)); g->fops = &idedisk_ops;add_disk (g);return 0 ;
drivers/ide/ide-floppy.c +2 -1
@@ -598,6 +598,8 @@ static void idefloppy_setup(ide_drive_t (void )ide_floppy_get_capacity (drive);ide_proc_register_driver (drive, floppy->driver); + + drive->dev_flags |=IDE_DFLAG_ATTACH ; }static void ide_floppy_remove (ide_drive_t *drive)
@@ -807,7 +809,6 @@ static int ide_floppy_probe(ide_drive_t drive->debug_mask = debug_mask;idefloppy_setup (drive, floppy); - drive->dev_flags |=IDE_DFLAG_ATTACH ; g->minors =1 <<PARTN_BITS ; g->driverfs_dev = &drive->gendev;
PATCH 7/18 ide-floppy: drop 'floppy' argument from idefloppy_setup()
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-floppy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ide/ide-floppy.c +3 -2
@@ -560,8 +560,9 @@ sector_t ide_floppy_capacity(ide_drive_treturn capacity; } -static void idefloppy_setup (ide_drive_t *drive,idefloppy_floppy_t *floppy) +static void idefloppy_setup (ide_drive_t *drive) { +struct ide_floppy_obj *floppy = drive->driver_data;u16 *id = drive->id; drive->pc_callback = ide_floppy_callback;
@@ -808,7 +809,7 @@ static int ide_floppy_probe(ide_drive_t drive->debug_mask = debug_mask; -idefloppy_setup (drive, floppy); +idefloppy_setup (drive); g->minors =1 <<PARTN_BITS ; g->driverfs_dev = &drive->gendev;
PATCH 8/18 ide-floppy: use drive->capacity64 for caching current capacity
In reply to Bartlomiej Zolnierkiewicz* 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.
--- drivers/ide/ide-floppy.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/ide/ide-floppy.c +13 -10
@@ -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_dif (!(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_tidefloppy_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 )
Re: [PATCH 08/18] ide-floppy: use drive->capacity64 for caching current capacity
Hi,
Quoted 20 lines · Bartlomiej Zolnierkiewicz
* Use
drive->capacity64for caching current capacity.* Switch
ide_floppy_capacity()to usedrive->capacity64.* Call
set_capacity()inidefloppy_open()andide_floppy_probe()instead ofide_floppy_get_capacity().There should be no functional changes caused by this patch.
Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ide/ide-floppy.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)Index:
b/drivers/ide/ide-floppy.c
===================================================================
drivers/ide/ide-floppy.c static int ide_floppy_get_flexible_disk_ · line 448
Quoted 4 lines
drivers/ide/ide-floppy.c +1
-0@@ -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;
why do we do the assignment only in the capacity < lba_capacity case? drive->capacity64 is the total number of sectors, shouldn't we do
drive->capacity64 = floppy->blocks;
in the floppy->bs_factor == 1 case? Otherwise you have the case of calling
idefloppy_setup()
|-> ide_floppy_get_capacity()
|-> ide_floppy_get_flexible_disk_page()
and having drive->capacity64 == 0 in the (capacity >= lba_capacity) case which assigns a capacity of 0 to disk->capacity in the set_capacity() call later ...
or am I missing something?
Quoted 29 lines
drivers/ide/ide-floppy.c +4
-3} +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_dif (!(drive->atapi_flags &IDE_AFLAG_CLIK_DRIVE )) (void )ide_floppy_get_flexible_disk_page (drive); -set_capacity (disk, floppy->blocks * floppy->bs_factor); -
drivers/ide/ide-floppy.c static int ide_floppy_get_capacity(ide_d · line 559
Quoted 10 lines
drivers/ide/ide-floppy.c +1
-4return 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;
you can simplify this one even further by killing ide_floppy_capacity() and doing
set_capacity(disk, floppy->drive->capacity64);
in idefloppy_revalidate_disk().
drivers/ide/ide-floppy.c static int idefloppy_open(struct inode * · line 675
Quoted 12 lines
drivers/ide/ide-floppy.c +3
-2}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));
ditto.
Quoted 12 lines
drivers/ide/ide-floppy.c +2
-1+ +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; }
drivers/ide/ide-floppy.c static int ide_floppy_probe(ide_drive_t · line 815
Quoted 4 lines
drivers/ide/ide-floppy.c +1
-0@@ -811,6 +812,8 @@ static int ide_floppy_probe(ide_drive_tidefloppy_setup (drive); +set_capacity (g,ide_floppy_capacity (drive));
ditto.
Quoted 4 lines
drivers/ide/ide-floppy.c +1
-0+ g->minors =1 <<PARTN_BITS ; g->driverfs_dev = &drive->gendev;if (drive->dev_flags &IDE_DFLAG_REMOVABLE )
Signature · 2 lines
Regards/Gruss,
Boris.Re: [PATCH 08/18] ide-floppy: use drive->capacity64 for caching current capacity
Hi,
Quoted 31 lines · Borislav Petkov
Hi,
Quoted 20 lines · Bartlomiej Zolnierkiewicz
* Use
drive->capacity64for caching current capacity.* Switch
ide_floppy_capacity()to usedrive->capacity64.* Call
set_capacity()inidefloppy_open()andide_floppy_probe()instead ofide_floppy_get_capacity().There should be no functional changes caused by this patch.
Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ide/ide-floppy.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)Index:
b/drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c static int ide_floppy_get_flexible_disk_ · line 448
Quoted 4 lines
drivers/ide/ide-floppy.c +1
-0@@ -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;why do we do the assignment only in the capacity <
lba_capacitycase?drive->capacity64is the total number of sectors, shouldn't we do
Quoted 3 lines
drive->capacity64=floppy->blocks;in the
floppy->bs_factor== 1 case? Otherwise you have the case of calling
Probably we should...
Quoted 8 lines
idefloppy_setup()
|->ide_floppy_get_capacity()|-> ide_floppy_get_flexible_disk_page()and having
drive->capacity64== 0 in the (capacity >=lba_capacity) case which assigns a capacity of 0 todisk->capacityin theset_capacity()call later ...or am I missing something?
...my patch just modified the code to also set ->capacity64 in places which previously were modifying ->blocks and/or ->bs_factor (since ->capacity64 replaced open-coded ->blocks * ->bs_factor calculation), so I think that the above problem is as an orthogonal issue and it is the best to address it in separate pre- or post- patch (could you please take care of it?).
[...]
Quoted 20 lines
Quoted 6 lines
drivers/ide/ide-floppy.c +0
-2@@ -547,17 +551,12 @@ static int ide_floppy_get_capacity(ide_dif (!(drive->atapi_flags &IDE_AFLAG_CLIK_DRIVE )) (void )ide_floppy_get_flexible_disk_page (drive); -set_capacity (disk, floppy->blocks * floppy->bs_factor); -drivers/ide/ide-floppy.c static int ide_floppy_get_capacity(ide_d · line 559
Quoted 10 lines
drivers/ide/ide-floppy.c +1
-4return 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;you can simplify this one even further by killing
ide_floppy_capacity()and doing
Quoted 1 line
set_capacity(disk, floppy->drive->capacity64);
I did it ide_floppy_capacity()-way to match ide_disk_capacity() and ease the merge (probably ide_gd_capacity() can be removed now).
Thanks,
Bart
PATCH 9/18 ide: IDE_AFLAG_MEDIA_CHANGED -> IDE_DFLAG_MEDIA_CHANGED
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-cd.c | 6 +++--- drivers/ide/ide-cd_ioctl.c | 4 ++-- drivers/ide/ide-floppy.c | 6 +++--- include/linux/ide.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/ide/ide-cd.c +3 -3
@@ -88,7 +88,7 @@ static void ide_cd_put(struct cdrom_info/* Mark that we've seen a media change and invalidate our internal buffers. */ static void cdrom_saw_media_change (ide_drive_t *drive) { - drive->atapi_flags |=IDE_AFLAG_MEDIA_CHANGED ; + drive->dev_flags |=IDE_DFLAG_MEDIA_CHANGED ; drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID ; }
@@ -1882,8 +1882,8 @@ static int ide_cdrom_setup(ide_drive_t *if (!drive->queue->unplug_delay) drive->queue->unplug_delay =1 ; - drive->atapi_flags =IDE_AFLAG_MEDIA_CHANGED |IDE_AFLAG_NO_EJECT | -ide_cd_flags (id); + drive->dev_flags |=IDE_DFLAG_MEDIA_CHANGED ; + drive->atapi_flags =IDE_AFLAG_NO_EJECT |ide_cd_flags (id);if ((drive->atapi_flags &IDE_AFLAG_VERTOS_300_SSD ) && fw_rev[4 ] =='1' && fw_rev[6 ] <='2' )
drivers/ide/ide-cd_ioctl.c +2 -2
@@ -86,8 +86,8 @@ int ide_cdrom_check_media_change_real(stif (slot_nr ==CDSL_CURRENT ) { (void )cdrom_check_status (drive,NULL ); - retval = (drive->atapi_flags &IDE_AFLAG_MEDIA_CHANGED ) ?1 :0 ; - drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED ; + retval = (drive->dev_flags &IDE_DFLAG_MEDIA_CHANGED ) ?1 :0 ; + drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED ;return retval; }else {return -EINVAL ;
drivers/ide/ide-floppy.c +3 -3
@@ -689,8 +689,8 @@ static int idefloppy_open(struct inode * goto out_put_floppy; } - drive->atapi_flags |=IDE_AFLAG_MEDIA_CHANGED ;ide_set_media_lock (drive, disk,1 ); + drive->dev_flags |=IDE_DFLAG_MEDIA_CHANGED ;check_disk_change (inode->i_bdev); }else if (drive->atapi_flags &IDE_AFLAG_FORMAT_IN_PROGRESS ) { ret = -EBUSY ;
@@ -747,8 +747,8 @@ static int idefloppy_media_changed(struc drive->dev_flags &= ~IDE_DFLAG_ATTACH ;return 0 ; } - ret = !!(drive->atapi_flags &IDE_AFLAG_MEDIA_CHANGED ); - drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED ; + ret = !!(drive->dev_flags &IDE_DFLAG_MEDIA_CHANGED ); + drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED ;return ret; }
include/linux/ide.h +1 -1
@@ -462,7 +462,6 @@ struct ide_acpi_hwif_link;/* ATAPI device flags */ enum {IDE_AFLAG_DRQ_INTERRUPT = (1 <<0 ), -IDE_AFLAG_MEDIA_CHANGED = (1 <<1 ),/* Drive cannot lock the door. */ IDE_AFLAG_NO_DOORLOCK = (1 <<2 ),
@@ -571,6 +570,7 @@ enum {/* retrying in PIO */ IDE_DFLAG_DMA_PIO_RETRY = (1 <<25 ),IDE_DFLAG_LBA = (1 <<26 ), + IDE_DFLAG_MEDIA_CHANGED = (1 << 27), }; struct ide_drive_s {
PATCH 10/18 ide: IDE_AFLAG_WP -> IDE_DFLAG_WP
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 8 ++++---- include/linux/ide.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/ide/ide-floppy.c +4 -4
@@ -410,11 +410,11 @@ static int ide_floppy_get_flexible_disk_ }if (pc.buf[3 ] &0x80 ) - drive->atapi_flags |=IDE_AFLAG_WP ; + drive->dev_flags |=IDE_DFLAG_WP ;else - drive->atapi_flags &= ~IDE_AFLAG_WP ; + drive->dev_flags &= ~IDE_DFLAG_WP ; -set_disk_ro (disk, !!(drive->atapi_flags &IDE_AFLAG_WP )); +set_disk_ro (disk, !!(drive->dev_flags &IDE_DFLAG_WP )); page = &pc.buf[8 ];
@@ -684,7 +684,7 @@ static int idefloppy_open(struct inode * goto out_put_floppy; } -if ((drive->atapi_flags &IDE_AFLAG_WP ) && (filp->f_mode &2 )) { +if ((drive->dev_flags &IDE_DFLAG_WP ) && (filp->f_mode &2 )) { ret = -EROFS ; goto out_put_floppy; }
include/linux/ide.h +2 -2
@@ -501,8 +501,6 @@ enum {IDE_AFLAG_CLIK_DRIVE = (1 <<19 ),/* Requires BH algorithm for packets */ IDE_AFLAG_ZIP_DRIVE = (1 <<20 ), -/* Write protect */ -IDE_AFLAG_WP = (1 <<21 ),/* Supports format progress report */ IDE_AFLAG_SRFP = (1 << 22),
@@ -571,6 +569,8 @@ enum {IDE_DFLAG_DMA_PIO_RETRY = (1 <<25 ),IDE_DFLAG_LBA = (1 <<26 ),IDE_DFLAG_MEDIA_CHANGED = (1 <<27 ), +/* write protect */ + IDE_DFLAG_WP = (1 << 28), }; struct ide_drive_s {
PATCH 11/18 ide: IDE_AFLAG_FORMAT_IN_PROGRESS -> IDE_DFLAG_FORMAT_IN_PROGRESS
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 6 +++--- drivers/ide/ide-floppy_ioctl.c | 6 +++--- include/linux/ide.h | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/ide/ide-floppy.c +3 -3
@@ -664,7 +664,7 @@ static int idefloppy_open(struct inode * floppy->openers++;if (floppy->openers ==1 ) { - drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS ; + drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS ;/* Just in case */ if (ide_do_test_unit_ready (drive, disk))
@@ -692,7 +692,7 @@ static int idefloppy_open(struct inode *ide_set_media_lock (drive, disk,1 ); drive->dev_flags |=IDE_DFLAG_MEDIA_CHANGED ;check_disk_change (inode->i_bdev); - }else if (drive->atapi_flags &IDE_AFLAG_FORMAT_IN_PROGRESS ) { + }else if (drive->dev_flags &IDE_DFLAG_FORMAT_IN_PROGRESS ) { ret = -EBUSY ; goto out_put_floppy; }
@@ -714,7 +714,7 @@ static int idefloppy_release(struct inodif (floppy->openers ==1 ) {ide_set_media_lock (drive, disk,0 ); - drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS ; + drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS ; } floppy->openers--;
drivers/ide/ide-floppy_ioctl.c +3 -3
@@ -138,11 +138,11 @@ static int ide_floppy_format_unit(ide_drif (floppy->openers >1 ) {/* Don't format if someone is using the disk */ - drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS ; + drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS ;return -EBUSY ; } - drive->atapi_flags |=IDE_AFLAG_FORMAT_IN_PROGRESS ; + drive->dev_flags |=IDE_DFLAG_FORMAT_IN_PROGRESS ;/* * Send ATAPI_FORMAT_UNIT to the drive.
@@ -174,7 +174,7 @@ static int ide_floppy_format_unit(ide_dr out:if (err) - drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS ; + drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS ;return err; }
include/linux/ide.h +1 -2
@@ -495,8 +495,6 @@ enum {IDE_AFLAG_LE_SPEED_FIELDS = (1 <<17 ),/* ide-floppy */ -/* Format in progress */ -IDE_AFLAG_FORMAT_IN_PROGRESS = (1 <<18 ),/* Avoid commands not supported in Clik drive */ IDE_AFLAG_CLIK_DRIVE = (1 << 19),/* Requires BH algorithm for packets */
@@ -571,6 +569,7 @@ enum {IDE_DFLAG_MEDIA_CHANGED = (1 <<27 ),/* write protect */ IDE_DFLAG_WP = (1 <<28 ), + IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 29), }; struct ide_drive_s {
PATCH 12/18 ide: remove IDE_AFLAG_NO_DOORLOCKING
In reply to Bartlomiej ZolnierkiewiczJust use IDE_DFLAG_DOORLOCKING instead.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-atapi.c | 2 +- drivers/ide/ide-cd.c | 2 +- drivers/ide/ide-cd_ioctl.c | 4 ++-- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-probe.c | 1 + drivers/ide/ide-tape.c | 2 +- include/linux/ide.h | 2 -- 7 files changed, 7 insertions(+), 8 deletions(-)
drivers/ide/ide-atapi.c +1 -1
@@ -191,7 +191,7 @@ int ide_set_media_lock(ide_drive_t *driv {struct ide_atapi_pc pc; -if (drive->atapi_flags &IDE_AFLAG_NO_DOORLOCK ) +if ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) ==0 )return 0 ;ide_init_pc (&pc);
drivers/ide/ide-cd.c +1 -1
@@ -1635,7 +1635,7 @@ static int ide_cdrom_probe_capabilities(return 0 ;if ((buf[8 +6 ] &0x01 ) ==0 ) - drive->atapi_flags |=IDE_AFLAG_NO_DOORLOCK ; + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ;if (buf[8 +6 ] &0x08 ) drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT ;if (buf[8 +3 ] &0x01 )
drivers/ide/ide-cd_ioctl.c +2 -2
@@ -136,7 +136,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, sense = &my_sense;/* If the drive cannot lock the door, just pretend. */ -if (drive->atapi_flags &IDE_AFLAG_NO_DOORLOCK ) { +if ((drive->dev_flags &IDE_DFLAG_DOORLOCKING ) ==0 ) { stat =0 ; }else {unsigned char cmd[BLK_MAX_CDB ];
@@ -157,7 +157,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, (sense->asc == 0x24 || sense->asc == 0x20)) {printk (KERN_ERR "%s: door locking not supported\n" , drive->name); - drive->atapi_flags |=IDE_AFLAG_NO_DOORLOCK ; + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; stat =0 ; }
drivers/ide/ide-floppy.c +1 -1
@@ -592,7 +592,7 @@ static void idefloppy_setup(ide_drive_tblk_queue_max_sectors (drive->queue,64 ); drive->atapi_flags |=IDE_AFLAG_CLIK_DRIVE ;/* IOMEGA Clik! drives do not support lock/unlock commands */ - drive->atapi_flags |=IDE_AFLAG_NO_DOORLOCK ; + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ; } (void )ide_floppy_get_capacity (drive);
drivers/ide/ide-probe.c +1 -0
@@ -208,6 +208,7 @@ static inline void do_identify (ide_driv drive->ready_stat =0 ;if (ata_id_cdb_intr (id)) drive->atapi_flags |=IDE_AFLAG_DRQ_INTERRUPT ; + drive->dev_flags |=IDE_DFLAG_DOORLOCKING ;return ; }
drivers/ide/ide-tape.c +1 -1
@@ -2107,7 +2107,7 @@ static void idetape_get_mode_sense_resul/* device lacks locking support according to capabilities page */ if ((caps[6 ] &1 ) ==0 ) - drive->atapi_flags |=IDE_AFLAG_NO_DOORLOCK ; + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING ;if (caps[7 ] &0x02 ) tape->blk_size =512 ;
include/linux/ide.h +0 -2
@@ -462,8 +462,6 @@ struct ide_acpi_hwif_link;/* ATAPI device flags */ enum {IDE_AFLAG_DRQ_INTERRUPT = (1 <<0 ), -/* Drive cannot lock the door. */ -IDE_AFLAG_NO_DOORLOCK = (1 <<2 ),/* ide-cd */ /* Drive cannot eject the disc. */
PATCH 13/18 ide-disk: factor out generic disk handling code to ide-gd.c
In reply to Bartlomiej ZolnierkiewiczWhile at it:
- IDEDISK_VERSION -> IDE_GD_VERSION
- ide_cacheflush_p() -> ide_disk_flush()
- init_idedisk_capacity() -> ide_disk_init_capacity()
- idedisk_set_doorlock() -> ide_disk_set_doorlock()
- idedisk_setup() -> ide_disk_setup()
- ide_disk_capacity() -> ide_gd_capacity()
- ide_disk_remove() -> ide_gd_remove()
- ide_disk_probe() -> ide_gd_probe()
- ide_disk_resume() -> ide_gd_resume()
- ide_device_shutdown() -> ide_gd_shutdown()
- idedisk_driver -> ide_gd_driver
- idedisk_open() -> ide_gd_open()
- idedisk_release() -> ide_gd_release()
- idedisk_getgeo() -> ide_gd_getgeo()
- idedisk_media_changed() -> ide_gd_media_changed()
- idedisk_revalidate_disk() -> ide_gd_revalidate_disk()
- idedisk_ops -> ide_gd_ops
- idedisk_init() -> ide_gd_init()
- idedisk_exit() -> ide_gd_exit()
There should be no functional changes caused by this patch.
--- drivers/ide/Makefile | 2 drivers/ide/ide-disk.c | 299 +------------------------------------------- drivers/ide/ide-disk.h | 8 + drivers/ide/ide-disk_proc.c | 2 drivers/ide/ide-gd.c | 289 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 307 insertions(+), 293 deletions(-)
drivers/ide/Makefile +1 -1
@@ -37,7 +37,7 @@ obj-$(CONFIG_IDE_H8300) += h8300/ obj-$(CONFIG_IDE_GENERIC) += ide-generic.o obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o -ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o +ide-disk_mod-y += ide-gd.o ide-disk.o ide-disk_ioctl.o ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o
drivers/ide/ide-disk.c +9 -290
367 lines not on this page · raw message
drivers/ide/ide-disk.h +7 -1
@@ -9,8 +9,14 @@ struct ide_disk_obj {unsigned int openers;/* protected by BKL for now */ }; +sector_t ide_gd_capacity (ide_drive_t *); +/* ide-disk.c */ -sector_t ide_disk_capacity (ide_drive_t *); +void ide_disk_init_capacity (ide_drive_t *); +void ide_disk_setup (ide_drive_t *); +void ide_disk_flush (ide_drive_t *); +int ide_disk_set_doorlock (ide_drive_t *,int ); +ide_startstop_t ide_do_rw_disk (ide_drive_t *,struct request *,sector_t );ide_decl_devset (address);ide_decl_devset (multcount);ide_decl_devset (nowerr);
drivers/ide/ide-disk_proc.c +1 -1
@@ -56,7 +56,7 @@ static int proc_idedisk_read_capacityide_drive_t *drive = (ide_drive_t *)data;int len; - len =sprintf (page,"%llu\n" , (long long )ide_disk_capacity (drive)); + len =sprintf (page,"%llu\n" , (long long )ide_gd_capacity (drive));PROC_IDE_READ_RETURN (page, start, off, count, eof, len); }
drivers/ide/ide-gd.c new file +289 -0
289 lines not on this page · raw message
PATCH 14/18 ide-disk: use IDE_DFLAG_MEDIA_CHANGED
In reply to Bartlomiej ZolnierkiewiczSet IDE_DFLAG_MEDIA_CHANGED in ide_gd_open() to signalize ide_gd_media_changed() that that media has changed (instead of relying on IDE_DFLAG_REMOVABLE).
There should be no functional changes caused by this patch.
--- drivers/ide/ide-gd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/ide/ide-gd.c +6 -2
@@ -154,6 +154,7 @@ static int ide_gd_open(struct inode *ino* and the door_lock is irrelevant at this point. */ ide_disk_set_doorlock (drive,1 ); + drive->dev_flags |=IDE_DFLAG_MEDIA_CHANGED ;check_disk_change (inode->i_bdev); }return 0 ;
@@ -193,6 +194,7 @@ static int ide_gd_media_changed(struct g {struct ide_disk_obj *idkp =ide_drv_g (disk, ide_disk_obj);ide_drive_t *drive = idkp->drive; +int ret;/* do not scan partitions twice if this is a removable device */ if (drive->dev_flags &IDE_DFLAG_ATTACH ) {
@@ -200,8 +202,10 @@ static int ide_gd_media_changed(struct greturn 0 ; } -/* if removable, always assume it was changed */ -return !!(drive->dev_flags &IDE_DFLAG_REMOVABLE ); + ret = !!(drive->dev_flags &IDE_DFLAG_MEDIA_CHANGED ); + drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED ; + +return ret; }static int ide_gd_revalidate_disk (struct gendisk *disk)
PATCH 15/18 ide-floppy: factor out generic disk handling code to ide-gd-floppy.c
In reply to Bartlomiej ZolnierkiewiczWhile at it:
- idefloppy_do_request() -> ide_floppy_do_request()
- idefloppy_end_request() -> ide_floppy_end_request()
- idefloppy_setup() -> ide_floppy_setup()
There should be no functional changes caused by this patch.
--- drivers/ide/Makefile | 2 drivers/ide/ide-floppy.c | 319 +------------------------------------------- drivers/ide/ide-floppy.h | 19 ++ drivers/ide/ide-gd-floppy.c | 298 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 327 insertions(+), 311 deletions(-)
drivers/ide/Makefile +1 -1
@@ -39,7 +39,7 @@ obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp ide-disk_mod-y += ide-gd.o ide-disk.o ide-disk_ioctl.o ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o -ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o +ide-floppy_mod-y += ide-gd-floppy.o ide-floppy.o ide-floppy_ioctl.o ifeq ($(CONFIG_IDE_PROC_FS), y) ide-disk_mod-y += ide-disk_proc.o
drivers/ide/ide-floppy.c +10 -309
392 lines not on this page · raw message
drivers/ide/ide-floppy.h +18 -1
@@ -1,6 +1,18 @@#ifndef __IDE_FLOPPY_H#define __IDE_FLOPPY_H +#define DRV_NAME "ide-floppy" +#define PFX DRV_NAME ": " + +/* define to see debug info */ +#define IDEFLOPPY_DEBUG_LOG 0 + +#if IDEFLOPPY_DEBUG_LOG +#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) +#else +#define ide_debug_log(lvl, fmt, args...) do {} while (0) +#endif +/* * Most of our global data which we need to save even as we leave the driver * due to an interrupt or a timer event is stored in a variable of type
@@ -45,10 +57,15 @@ typedef struct ide_floppy_obj {#define IDEFLOPPY_IOCTL_FORMAT_START 0x4602#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 +sector_t ide_floppy_capacity (ide_drive_t *); +/* ide-floppy.c */ void ide_floppy_create_mode_sense_cmd (struct ide_atapi_pc *,u8 );void ide_floppy_create_read_capacity_cmd (struct ide_atapi_pc *); -sector_t ide_floppy_capacity (ide_drive_t *); +int ide_floppy_get_capacity (ide_drive_t *); +void ide_floppy_setup (ide_drive_t *); +ide_startstop_t ide_floppy_do_request (ide_drive_t *,struct request *,sector_t ); +int ide_floppy_end_request (ide_drive_t *,int ,int );/* ide-floppy_ioctl.c */ int ide_floppy_ioctl (struct inode *,struct file *,unsigned ,unsigned long );
drivers/ide/ide-gd-floppy.c new file +298 -0
298 lines not on this page · raw message
PATCH 16/18 ide: prepare for merging ide-gd-floppy.c with ide-gd.c
In reply to Bartlomiej Zolnierkiewicz- idefloppy_ref_mutex -> ide_disk_ref_mutex
- idefloppy_cleanup_obj() -> ide_disk_release()
- ide_floppy_get() -> ide_disk_get()
- ide_floppy_put() -> ide_disk_put()
- ide_floppy_capacity() -> ide_gd_capacity()
- ide_floppy_remove() -> ide_gd_remove()
- ide_floppy_probe() -> ide_gd_probe()
- idefloppy_driver -> ide_gd_driver
- idefloppy_open() -> ide_gd_open()
- idefloppy_release() -> ide_gd_release()
- idefloppy_getgeo() -> ide_gd_getgeo()
- idefloppy_media_changed() -> ide_gd_media_changed()
- idefloppy_revalidate_disk() -> ide_gd_revalidate_disk()
- idefloppy_ops -> ide_gd_ops
- idefloppy_init() -> ide_gd_init()
- idefloppy_exit() -> ide_gd_exit()
- 'floppy' -> 'idkp' in ide_disk_*() and ide_gd_*()
- idefloppy_floppy_t -> struct ide_floppy_obj
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.h | 2 drivers/ide/ide-floppy_proc.c | 2 drivers/ide/ide-gd-floppy.c | 179 ++++++++++++++++++++---------------------- 3 files changed, 91 insertions(+), 92 deletions(-)
drivers/ide/ide-floppy.h +1 -1
@@ -57,7 +57,7 @@ typedef struct ide_floppy_obj {#define IDEFLOPPY_IOCTL_FORMAT_START 0x4602#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 -sector_t ide_floppy_capacity (ide_drive_t *); +sector_t ide_gd_capacity (ide_drive_t *);/* ide-floppy.c */ void ide_floppy_create_mode_sense_cmd (struct ide_atapi_pc *,u8 );
drivers/ide/ide-floppy_proc.c +1 -1
@@ -9,7 +9,7 @@ static int proc_idefloppy_read_capacity(ide_drive_t *drive = (ide_drive_t *)data;int len; - len =sprintf (page,"%llu\n" , (long long )ide_floppy_capacity (drive)); + len =sprintf (page,"%llu\n" , (long long )ide_gd_capacity (drive));PROC_IDE_READ_RETURN (page, start, off, count, eof, len); }
drivers/ide/ide-gd-floppy.c +89 -90
346 lines not on this page · raw message
PATCH 17/18 ide: allow device drivers to specify per-device type /proc settings
In reply to Bartlomiej ZolnierkiewiczTurn ide_driver_t's 'proc' field into ->proc_entries method (and also 'settings' field into ->proc_devsets method). Then update all device drivers accordingly.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-cd.c | 14 ++++++++++++-- drivers/ide/ide-gd-floppy.c | 16 ++++++++++++++-- drivers/ide/ide-gd.c | 16 ++++++++++++++-- drivers/ide/ide-proc.c | 6 +++--- drivers/ide/ide-tape.c | 14 ++++++++++++-- drivers/scsi/ide-scsi.c | 26 +++++++++++++++++--------- include/linux/ide.h | 4 ++-- 7 files changed, 74 insertions(+), 22 deletions(-)
drivers/ide/ide-cd.c +12 -2
@@ -1904,6 +1904,16 @@ static const struct ide_proc_devset idecIDE_PROC_DEVSET (dsc_overlap,0 ,1 ), { 0 }, }; + +static ide_proc_entry_t *ide_cd_proc_entries (ide_drive_t *drive) +{ +return idecd_proc; +} + +static const struct ide_proc_devset *ide_cd_proc_devsets (ide_drive_t *drive) +{ +return idecd_settings; +}#endif static const struct cd_list_entry ide_cd_quirks_list[] = {
@@ -2064,8 +2074,8 @@ static ide_driver_t ide_cdrom_driver = { .end_request = ide_end_request, .error = __ide_error, #ifdef CONFIG_IDE_PROC_FS - .proc = idecd_proc, - .settings = idecd_settings, + .proc_entries = ide_cd_proc_entries, + .proc_devsets = ide_cd_proc_devsets,#endif };
drivers/ide/ide-gd-floppy.c +14 -2
@@ -77,6 +77,18 @@ static void ide_disk_release(struct krefkfree (idkp); } +#ifdef CONFIG_IDE_PROC_FS +static ide_proc_entry_t *ide_floppy_proc_entries (ide_drive_t *drive) +{ +return ide_floppy_proc; +} + +static const struct ide_proc_devset *ide_floppy_proc_devsets (ide_drive_t *drive) +{ +return ide_floppy_settings; +} +#endif +static ide_driver_t ide_gd_driver = { .gen_driver = { .owner =THIS_MODULE ,
@@ -90,8 +102,8 @@ static ide_driver_t ide_gd_driver = { .end_request = ide_floppy_end_request, .error = __ide_error, #ifdef CONFIG_IDE_PROC_FS - .proc = ide_floppy_proc, - .settings = ide_floppy_settings, + .proc_entries = ide_floppy_proc_entries, + .proc_devsets = ide_floppy_proc_devsets,#endif };
drivers/ide/ide-gd.c +14 -2
@@ -113,6 +113,18 @@ static void ide_gd_shutdown(ide_drive_t drive->gendev.bus->suspend (&drive->gendev,PMSG_SUSPEND ); } +#ifdef CONFIG_IDE_PROC_FS +static ide_proc_entry_t *ide_disk_proc_entries (ide_drive_t *drive) +{ +return ide_disk_proc; +} + +static const struct ide_proc_devset *ide_disk_proc_devsets (ide_drive_t *drive) +{ +return ide_disk_settings; +} +#endif +static ide_driver_t ide_gd_driver = { .gen_driver = { .owner =THIS_MODULE ,
@@ -128,8 +140,8 @@ static ide_driver_t ide_gd_driver = { .end_request = ide_end_request, .error = __ide_error, #ifdef CONFIG_IDE_PROC_FS - .proc = ide_disk_proc, - .settings = ide_disk_settings, + .proc_entries = ide_disk_proc_entries, + .proc_devsets = ide_disk_proc_devsets,#endif };
drivers/ide/ide-proc.c +3 -3
@@ -567,10 +567,10 @@ static void ide_remove_proc_entries(struvoid ide_proc_register_driver (ide_drive_t *drive,ide_driver_t *driver) {mutex_lock (&ide_setting_mtx); - drive->settings = driver->settings; + drive->settings = driver->proc_devsets (drive);mutex_unlock (&ide_setting_mtx); -ide_add_proc_entries (drive->proc, driver->proc, drive); +ide_add_proc_entries (drive->proc, driver->proc_entries (drive), drive); }EXPORT_SYMBOL (ide_proc_register_driver);
@@ -591,7 +591,7 @@ void ide_proc_unregister_driver(ide_driv {unsigned long flags; -ide_remove_proc_entries (drive->proc, driver->proc); +ide_remove_proc_entries (drive->proc, driver->proc_entries (drive));mutex_lock (&ide_setting_mtx);spin_lock_irqsave (&ide_lock, flags);
drivers/ide/ide-tape.c +12 -2
@@ -2297,6 +2297,16 @@ static ide_proc_entry_t idetape_proc[] = { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, { NULL, 0, NULL, NULL } }; + +static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) +{ + return idetape_proc; +} + +static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive) +{ + return idetape_settings; +} #endif static int ide_tape_probe(ide_drive_t *);
@@ -2314,8 +2324,8 @@ static ide_driver_t idetape_driver = { .end_request = idetape_end_request, .error = __ide_error, #ifdef CONFIG_IDE_PROC_FS - .proc = idetape_proc, - .settings = idetape_settings, + .proc_entries = ide_tape_proc_entries, + .proc_devsets = ide_tape_proc_devsets,#endif };
drivers/scsi/ide-scsi.c +17 -9
@@ -343,6 +343,11 @@ static ide_startstop_t idescsi_do_reques }#ifdef CONFIG_IDE_PROC_FS +static ide_proc_entry_t idescsi_proc[] = { + {"capacity" ,S_IFREG |S_IRUGO , proc_ide_read_capacity,NULL }, + {NULL ,0 ,NULL ,NULL } +}; +#define ide_scsi_devset_get (name, field) \ static int get_##name(ide_drive_t *drive) \ { \
@@ -378,6 +383,16 @@ static const struct ide_proc_devset idesIDE_PROC_DEVSET (transform,0 ,3 ), { 0 }, }; + +static ide_proc_entry_t *ide_scsi_proc_entries (ide_drive_t *drive) +{ +return idescsi_proc; +} + +static const struct ide_proc_devset *ide_scsi_proc_devsets (ide_drive_t *drive) +{ +return idescsi_settings; +}#endif /*
@@ -419,13 +434,6 @@ static void ide_scsi_remove(ide_drive_tstatic int ide_scsi_probe (ide_drive_t *); -#ifdef CONFIG_IDE_PROC_FS -static ide_proc_entry_t idescsi_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , proc_ide_read_capacity,NULL }, - {NULL ,0 ,NULL ,NULL } -}; -#endif -static ide_driver_t idescsi_driver = { .gen_driver = { .owner =THIS_MODULE ,
@@ -439,8 +447,8 @@ static ide_driver_t idescsi_driver = { .end_request = idescsi_end_request, .error = idescsi_atapi_error, #ifdef CONFIG_IDE_PROC_FS - .proc = idescsi_proc, - .settings = idescsi_settings, + .proc_entries = ide_scsi_proc_entries, + .proc_devsets = ide_scsi_proc_devsets,#endif };
include/linux/ide.h +2 -2
@@ -1111,8 +1111,8 @@ struct ide_driver_s {void (*resume)(ide_drive_t *);void (*shutdown)(ide_drive_t *);#ifdef CONFIG_IDE_PROC_FS -ide_proc_entry_t *proc; -const struct ide_proc_devset *settings; +ide_proc_entry_t * (*proc_entries)(ide_drive_t *); +const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *);#endif };
PATCH 18/18 ide: add generic ATA/ATAPI disk driver
In reply to Bartlomiej Zolnierkiewicz* Add struct ide_disk_ops containing protocol specific methods.
* Add 'struct ide_disk_ops *' to ide_drive_t.
* Convert ide-{disk,floppy} drivers to use struct ide_disk_ops.
* Merge ide-{disk,floppy} drivers into generic ide-gd driver.
While at it:
- ide_disk_init_capacity() -> ide_disk_get_capacity()
--- drivers/ide/Kconfig | 64 +++----- drivers/ide/Makefile | 19 +- drivers/ide/ide-disk.c | 39 ++++- drivers/ide/ide-disk.h | 24 +-- drivers/ide/ide-disk_ioctl.c | 4 drivers/ide/ide-floppy.c | 45 ++++- drivers/ide/ide-floppy.h | 58 +------ drivers/ide/ide-floppy_ioctl.c | 9 - drivers/ide/ide-gd-floppy.c | 309 ----------------------------------------- drivers/ide/ide-gd.c | 124 ++++++++++++++-- drivers/ide/ide-gd.h | 44 +++++ drivers/leds/Kconfig | 2 include/linux/ide.h | 19 ++ 13 files changed, 305 insertions(+), 455 deletions(-)
drivers/ide/Kconfig +30 -34
@@ -84,21 +84,40 @@ config BLK_DEV_IDE_SATA If unsure, say N. -config BLK_DEV_IDEDISK - tristate "Include IDE/ATA-2 DISK support" - ---help--- - This will include enhanced support for MFM/RLL/IDE hard disks. If - you have a MFM/RLL/IDE disk, and there is no special reason to use - the old hard disk driver instead, say Y. If you have an SCSI-only - system, you can say N here. +config IDE_GD + tristate "generic ATA/ATAPI disk support" + default y + help + Support for ATA/ATAPI disks (including ATAPI floppy drives). - To compile this driver as a module, choose M here: the - module will be called ide-disk. - Do not compile this driver as a module if your root file system - (the one containing the directory /) is located on the IDE disk. + To compile this driver as a module, choose M here. + The module will be called ide-gd_mod. If unsure, say Y. +config IDE_GD_ATA + bool "ATA disk support" + depends on IDE_GD + default y + help + This will include support for ATA hard disks. + + If unsure, say Y. + +config IDE_GD_ATAPI + bool "ATAPI floppy support" + depends on IDE_GD + select IDE_ATAPI + help + This will include support for ATAPI floppy drives + (i.e. Iomega ZIP or MKE LS-120). + + For information about jumper settings and the question + of when a ZIP drive uses a partition table, see + <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>. + + If unsure, say N. + config BLK_DEV_IDECS tristate "PCMCIA IDE support" depends on PCMCIA
@@ -163,29 +182,6 @@ config BLK_DEV_IDETAPE To compile this driver as a module, choose M here: the module will be called ide-tape. -config BLK_DEV_IDEFLOPPY - tristate "Include IDE/ATAPI FLOPPY support" - select IDE_ATAPI - ---help--- - If you have an IDE floppy drive which uses the ATAPI protocol, - answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy - drives, similar to the SCSI protocol. - - The LS-120 and the IDE/ATAPI Iomega ZIP drive are also supported by - this driver. For information about jumper settings and the question - of when a ZIP drive uses a partition table, see - <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>. - (ATAPI PD-CD/CDR drives are not supported by this driver; support - for PD-CD/CDR drives is available if you answer Y to - "SCSI emulation support", below). - - If you say Y here, the FLOPPY drive will be identified along with - other IDE devices, as "hdb" or "hdc", or something similar (check - the boot messages with dmesg). - - To compile this driver as a module, choose M here: the - module will be called ide-floppy. - config BLK_DEV_IDESCSI tristate "SCSI emulation support (DEPRECATED)" depends on SCSI
drivers/ide/Makefile +13 -6
@@ -37,18 +37,25 @@ obj-$(CONFIG_IDE_H8300) += h8300/ obj-$(CONFIG_IDE_GENERIC) += ide-generic.o obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o -ide-disk_mod-y += ide-gd.o ide-disk.o ide-disk_ioctl.o +ide-gd_mod-y += ide-gd.o ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o -ide-floppy_mod-y += ide-gd-floppy.o ide-floppy.o ide-floppy_ioctl.o +ifeq ($(CONFIG_IDE_GD_ATA), y) + ide-gd_mod-y += ide-disk.o ide-disk_ioctl.o ifeq ($(CONFIG_IDE_PROC_FS), y) - ide-disk_mod-y += ide-disk_proc.o - ide-floppy_mod-y += ide-floppy_proc.o + ide-gd_mod-y += ide-disk_proc.o +endif +endif + +ifeq ($(CONFIG_IDE_GD_ATAPI), y) + ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o +ifeq ($(CONFIG_IDE_PROC_FS), y) + ide-gd_mod-y += ide-floppy_proc.o +endif endif -obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o +obj-$(CONFIG_IDE_GD) += ide-gd_mod.o obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o -obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o ifeq ($(CONFIG_BLK_DEV_IDECS), y)
drivers/ide/ide-disk.c +32 -7
@@ -184,8 +184,8 @@ static ide_startstop_t __ide_do_rw_disk(* 1073741822 == 549756 MB or 48bit addressing fake drive */ -ide_startstop_t ide_do_rw_disk (ide_drive_t *drive,struct request *rq, -sector_t block) +static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive,struct request *rq, +sector_t block) {ide_hwif_t *hwif =HWIF (drive);
@@ -333,7 +333,7 @@ static void idedisk_check_hpa(ide_drive_ } } -void ide_disk_init_capacity (ide_drive_t *drive) +static int ide_disk_get_capacity (ide_drive_t *drive) {u16 *id = drive->id;int lba;
@@ -382,6 +382,8 @@ void ide_disk_init_capacity(ide_drive_t }else drive->dev_flags &= ~IDE_DFLAG_LBA48 ; } + +return 0 ; }static void idedisk_prepare_flush (struct request_queue *q,struct request *rq)
@@ -590,7 +592,12 @@ ide_ext_devset_rw(wcache, wcache);ide_ext_devset_rw_sync (nowerr, nowerr); -void ide_disk_setup (ide_drive_t *drive) +static int ide_disk_check (ide_drive_t *drive,const char *s) +{ +return 1 ; +} + +static void ide_disk_setup (ide_drive_t *drive) {struct ide_disk_obj *idkp = drive->driver_data;ide_hwif_t *hwif = drive->hwif;
@@ -626,7 +633,7 @@ void ide_disk_setup(ide_drive_t *drive) drive->queue->max_sectors / 2);/* calculate drive capacity, and select LBA if possible */ -ide_disk_init_capacity (drive); +ide_disk_get_capacity (drive);/* * if possible, give fdisk access to more of the drive,
@@ -682,7 +689,7 @@ void ide_disk_setup(ide_drive_t *drive) drive->dev_flags |=IDE_DFLAG_ATTACH ; } -void ide_disk_flush (ide_drive_t *drive) +static void ide_disk_flush (ide_drive_t *drive) {if (ata_id_flush_enabled (drive->id) ==0 || (drive->dev_flags &IDE_DFLAG_WCACHE ) ==0 )
@@ -692,7 +699,13 @@ void ide_disk_flush(ide_drive_t *drive)printk (KERN_INFO "%s: wcache flush failed!\n" , drive->name); } -int ide_disk_set_doorlock (ide_drive_t *drive,int on) +static int ide_disk_init_media (ide_drive_t *drive,struct gendisk *disk) +{ +return 0 ; +} + +static int ide_disk_set_doorlock (ide_drive_t *drive,struct gendisk *disk, +int on) {ide_task_t task;int ret;
@@ -711,3 +724,15 @@ int ide_disk_set_doorlock(ide_drive_t *dreturn ret; } + +const struct ide_disk_ops ide_ata_disk_ops = { + .check = ide_disk_check, + .get_capacity = ide_disk_get_capacity, + .setup = ide_disk_setup, + .flush = ide_disk_flush, + .init_media = ide_disk_init_media, + .set_doorlock = ide_disk_set_doorlock, + .do_request = ide_do_rw_disk, + .end_request = ide_end_request, + .ioctl = ide_disk_ioctl, +};
drivers/ide/ide-disk.h +9 -15
@@ -1,22 +1,11 @@#ifndef __IDE_DISK_H#define __IDE_DISK_H -struct ide_disk_obj { -ide_drive_t *drive; -ide_driver_t *driver; -struct gendisk *disk; -struct kref kref; -unsigned int openers;/* protected by BKL for now */ -}; - -sector_t ide_gd_capacity (ide_drive_t *); +#include "ide-gd.h" +#ifdef CONFIG_IDE_GD_ATA /* ide-disk.c */ -void ide_disk_init_capacity (ide_drive_t *); -void ide_disk_setup (ide_drive_t *); -void ide_disk_flush (ide_drive_t *); -int ide_disk_set_doorlock (ide_drive_t *,int ); -ide_startstop_t ide_do_rw_disk (ide_drive_t *,struct request *,sector_t ); +extern const struct ide_disk_ops ide_ata_disk_ops;ide_decl_devset (address);ide_decl_devset (multcount);ide_decl_devset (nowerr);
@@ -24,12 +13,17 @@ ide_decl_devset(wcache);ide_decl_devset (acoustic);/* ide-disk_ioctl.c */ -int ide_disk_ioctl (struct inode *,struct file *,unsigned int ,unsigned long ); +int ide_disk_ioctl (ide_drive_t *,struct inode *,struct file *,unsigned int , +unsigned long );#ifdef CONFIG_IDE_PROC_FS /* ide-disk_proc.c */ extern ide_proc_entry_t ide_disk_proc[];extern const struct ide_proc_devset ide_disk_settings[];#endif +#else +#define ide_disk_proc NULL +#define ide_disk_settings NULL +#endif #endif /* __IDE_DISK_H */
drivers/ide/ide-disk_ioctl.c +1 -3
@@ -13,12 +13,10 @@ static const struct ide_ioctl_devset ide { 0 } }; -int ide_disk_ioctl (struct inode *inode,struct file *file, +int ide_disk_ioctl (ide_drive_t *drive,struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg) {struct block_device *bdev = inode->i_bdev; -struct ide_disk_obj *idkp =ide_drv_g (bdev->bd_disk, ide_disk_obj); -ide_drive_t *drive = idkp->drive;int err; err =ide_setting_ioctl (drive, bdev, cmd, arg, ide_disk_ioctl_settings);
drivers/ide/ide-floppy.c +37 -8
83 lines not on this page · raw message
drivers/ide/ide-floppy.h +10 -48
81 lines not on this page · raw message
drivers/ide/ide-floppy_ioctl.c +3 -6
@@ -33,7 +33,7 @@static int ide_floppy_get_format_capacities (ide_drive_t *drive,int __user *arg) { -struct ide_floppy_obj *floppy = drive->driver_data; +struct ide_disk_obj *floppy = drive->driver_data;struct ide_atapi_pc pc;u8 header_len, desc_cnt;int i, blocks, length, u_array_size, u_index;
@@ -260,13 +260,10 @@ static int ide_floppy_format_ioctl(ide_d } } -int ide_floppy_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +int ide_floppy_ioctl (ide_drive_t *drive,struct inode *inode, +struct file *file,unsigned int cmd,unsigned long arg) {struct block_device *bdev = inode->i_bdev; -struct ide_floppy_obj *floppy =ide_drv_g (bdev->bd_disk, - ide_floppy_obj); -ide_drive_t *drive = floppy->drive;struct ide_atapi_pc pc;void __user *argp = (void __user *)arg;int err;
drivers/ide/ide-gd-floppy.c deleted +0 -309
309 lines not on this page · raw message
drivers/ide/ide-gd.c +106 -18
255 lines not on this page · raw message
drivers/ide/ide-gd.h new file +44 -0
44 lines not on this page · raw message
drivers/leds/Kconfig +1 -1
@@ -185,7 +185,7 @@ config LEDS_TRIGGER_TIMER config LEDS_TRIGGER_IDE_DISK bool "LED IDE Disk Trigger" - depends on LEDS_TRIGGERS && BLK_DEV_IDEDISK + depends on LEDS_TRIGGERS && IDE_GD_ATA help This allows LEDs to be controlled by IDE disk activity. If unsure, say Y.
include/linux/ide.h +19 -0
@@ -459,6 +459,23 @@ struct ide_acpi_drive_link;struct ide_acpi_hwif_link ;#endif +struct ide_drive_s ; + +struct ide_disk_ops { +int (*check)(struct ide_drive_s *,const char *); +int (*get_capacity)(struct ide_drive_s *); +void (*setup)(struct ide_drive_s *); +void (*flush)(struct ide_drive_s *); +int (*init_media)(struct ide_drive_s *,struct gendisk *); +int (*set_doorlock)(struct ide_drive_s *,struct gendisk *, +int ); +ide_startstop_t (*do_request)(struct ide_drive_s *,struct request *, +sector_t ); +int (*end_request)(struct ide_drive_s *,int ,int ); +int (*ioctl)(struct ide_drive_s *,struct inode *, +struct file *,unsigned int ,unsigned long ); +}; +/* ATAPI device flags */ enum {IDE_AFLAG_DRQ_INTERRUPT = (1 <<0 ),
@@ -586,6 +603,8 @@ struct ide_drive_s {#endif struct hwif_s *hwif;/* actually (ide_hwif_t *) */ +const struct ide_disk_ops *disk_ops; +unsigned long dev_flags;unsigned long sleep;/* sleep until this time */
Quoted 10 lines · Bartlomiej Zolnierkiewicz
[ Borislav, this is the 'futuristic' stuff that we were talking about. :) ]
Hi,
This patch series adds a generic ATA/ATAPI disk driver (ide-gd) replacing ide-disk and ide-floppy drivers. It is achieved by moving the common code to
ide-gd.c, adding structide_disk_ops(which is used to abstract protocol specific details) and updating ide-{disk,floppy}.c accordingly.
Quoted 5 lines
The main goal is to make the code more maintainable / easier to extend later. As an immediate result we get driver specific debugging support for ATA disks and ability for driver specific Power Management for ATAPI devices. Otherwise it is really an initial merge (which means that in the future the code can be further unified, struct
ide_disk_opscan be made more fine-grained etc.).
Looks cool, ACK with some comments/questions in separate mail. Will test on my Iomega ZIP drive when I get back.
Signature · 2 lines
Regards/Gruss,
Boris.