diff options
| author | Alexander Viro <viro@math.psu.edu> | 2002-10-31 19:26:31 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-10-31 19:26:31 -0800 |
| commit | e2e442ebcba531a5cb985f2becda8c60d1183c01 (patch) | |
| tree | 5a08b0d6dab8b8f3274287e46a84e75bf0fc741c | |
| parent | a7be265f87d5adb4ad30507466e271ed96b3f247 (diff) | |
[PATCH] remaining uses of ->rq_dev
* in floppy drivers and ps2esdi - replaced with use of ->rq_disk;
floppy drivers already have information about "type" part of device number
- they had stored that information in floppy_open(), so all we need is a
"which drive" part. And that is available from ->rq_disk.
* DAC960: changed ->private_data initialization - instead of pointing
it to controller (which we already have as disk->queue.queuedata) we simply
store a disk number in there. That had simplified ->revalidate_disk() and
allowed to kill the use of ->rq_dev in request handler.
| -rw-r--r-- | drivers/acorn/block/fd1772.c | 25 | ||||
| -rw-r--r-- | drivers/block/DAC960.c | 15 | ||||
| -rw-r--r-- | drivers/block/amiflop.c | 35 | ||||
| -rw-r--r-- | drivers/block/ataflop.c | 19 | ||||
| -rw-r--r-- | drivers/block/floppy.c | 23 | ||||
| -rw-r--r-- | drivers/block/ps2esdi.c | 4 |
6 files changed, 51 insertions, 70 deletions
diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c index eeda4bc48194..028d3151723e 100644 --- a/drivers/acorn/block/fd1772.c +++ b/drivers/acorn/block/fd1772.c @@ -1206,7 +1206,7 @@ static void setup_req_params(int drive) static void redo_fd_request(void) { - int device, drive, type; + int drive, type; struct archy_floppy_struct *floppy; DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", @@ -1218,10 +1218,9 @@ repeat: if (blk_queue_empty(QUEUE)) goto the_end; - device = minor(CURRENT->rq_dev); - drive = device & 3; - type = device >> 2; - floppy = &unit[drive]; + floppy = CURRENT->rq_disk->private_data; + drive = floppy - unit; + type = fd_device[drive]; if (!floppy->connected) { /* drive not connected */ @@ -1463,13 +1462,11 @@ static void config_types(void) static int floppy_open(struct inode *inode, struct file *filp) { int drive = minor(inode->i_rdev) & 3; - int old_dev; + int type = minor(inode->i_rdev) >> 2; + int old_dev = fd_device[drive]; - old_dev = fd_device[drive]; - - if (fd_ref[drive]) - if (old_dev != inode->i_rdev) - return -EBUSY; + if (fd_ref[drive] && old_dev != type) + return -EBUSY; if (fd_ref[drive] == -1 || (fd_ref[drive] && filp->f_flags & O_EXCL)) return -EBUSY; @@ -1479,10 +1476,10 @@ static int floppy_open(struct inode *inode, struct file *filp) else fd_ref[drive]++; - fd_device[drive] = inode->i_rdev; + fd_device[drive] = type; - if (old_dev && old_dev != inode->i_rdev) - invalidate_buffers(old_dev); + if (old_dev && old_dev != type) + invalidate_buffers(mk_kdev(MAJOR_NR, drive + (old_dev<<2))); if (filp->f_flags & O_NDELAY) return 0; diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 37e1713eeafb..efe4c47e7cc1 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -2019,14 +2019,9 @@ static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller) static int DAC960_revalidate(struct gendisk *disk) { - DAC960_Controller_T *p = disk->private_data; - int unit; - for (unit = 0; unit < DAC960_MaxLogicalDrives; unit++) { - if (p->disks[unit] == disk) { - set_capacity(disk, disk_size(p, unit)); - return 0; - } - } + DAC960_Controller_T *p = disk->queue->queuedata; + int unit = (int)disk->private_data; + set_capacity(disk, disk_size(p, unit)); return 0; } @@ -2205,7 +2200,7 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType) Controller->disks[i] = alloc_disk(1<<DAC960_MaxPartitionsBits); if (!Controller->disks[i]) goto Enomem; - Controller->disks[i]->private_data = Controller; + Controller->disks[i]->private_data = (void*)i; Controller->disks[i]->queue = &Controller->RequestQueue; } Controller->ControllerNumber = DAC960_ControllerCount; @@ -2855,7 +2850,7 @@ static boolean DAC960_ProcessRequest(DAC960_Controller_T *Controller, Command->CommandType = DAC960_ReadCommand; else Command->CommandType = DAC960_WriteCommand; Command->Completion = Request->waiting; - Command->LogicalDriveNumber = DAC960_LogicalDriveNumber(Request->rq_dev); + Command->LogicalDriveNumber = (int)Request->rq_disk->private_data; Command->BlockNumber = Request->sector; Command->BlockCount = Request->nr_sectors; Command->SegmentCount = Request->nr_phys_segments; diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 3bf9b48a0924..9a2d64da6330 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -208,7 +208,7 @@ static DECLARE_WAIT_QUEUE_HEAD(ms_wait); /* Prevent "aliased" accesses. */ static int fd_ref[4] = { 0,0,0,0 }; -static kdev_t fd_device[4] = { NODEV, NODEV, NODEV, NODEV }; +static int fd_device[4] = { 0, 0, 0, 0 }; /* * Here come the actual hardware access and helper functions. @@ -1369,7 +1369,7 @@ static int get_track(int drive, int track) static void redo_fd_request(void) { unsigned int cnt, block, track, sector; - int device, drive; + int drive; struct amiga_floppy_struct *floppy; char *data; unsigned long flags; @@ -1380,19 +1380,8 @@ static void redo_fd_request(void) return; } - device = minor(CURRENT->rq_dev); - if (device < 8) { - /* manual selection */ - drive = device & 3; - } else { - /* Auto-detection */ -#ifdef DEBUG - printk("redo_fd_request: can't handle auto detect\n"); - printk("redo_fd_request: default to normal\n"); -#endif - drive = device & 3; - } floppy = CURRENT->rq_disk->private_data; + drive = floppy - unit; /* Here someone could investigate to be more efficient */ for (cnt = 0; cnt < CURRENT->current_nr_sectors; cnt++) { @@ -1594,17 +1583,16 @@ static void fd_probe(int dev) */ static int floppy_open(struct inode *inode, struct file *filp) { - int drive; - kdev_t old_dev; + int drive = minor(inode->i_rdev) & 3; + int system = (minor(inode->i_rdev) & 4) >> 2; + int old_dev; int system; unsigned long flags; - drive = minor(inode->i_rdev) & 3; old_dev = fd_device[drive]; - if (fd_ref[drive]) - if (!kdev_same(old_dev, inode->i_rdev)) - return -EBUSY; + if (fd_ref[drive] && old_dev != system) + return -EBUSY; if (filp && filp->f_mode & 3) { check_disk_change(inode->i_bdev); @@ -1625,17 +1613,16 @@ static int floppy_open(struct inode *inode, struct file *filp) save_flags(flags); cli(); fd_ref[drive]++; - fd_device[drive] = inode->i_rdev; + fd_device[drive] = system; #ifdef MODULE if (unit[drive].motor == 0) MOD_INC_USE_COUNT; #endif restore_flags(flags); - if (!kdev_same(old_dev, NODEV) && !kdev_same(old_dev, inode->i_rdev)) - invalidate_buffers(old_dev); + if (old_dev != system) + invalidate_buffers(mk_kdev(MAJOR_NR, drive + (system << 2)); - system=(minor(inode->i_rdev) & 4)>>2; unit[drive].dtype=&data_types[system]; unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* data_types[system].sects*unit[drive].type->sect_mult; diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index efe87cfb8575..ec314799cf72 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1438,8 +1438,9 @@ static void setup_req_params( int drive ) static void redo_fd_request(void) { - int device, drive, type; - + int drive, type; + struct atari_floppy_struct *floppy; + DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", CURRENT, !blk_queue_empty(QUEUE) ? CURRENT->rq_disk->disk_name : "", !blk_queue_empty(QUEUE) ? CURRENT->sector : 0 )); @@ -1451,9 +1452,9 @@ repeat: if (blk_queue_empty(QUEUE)) goto the_end; - device = minor(CURRENT->rq_dev); - drive = device & 3; - type = device >> 2; + floppy = CURRENT->rq_disk->private_data; + drive = floppy - unit; + type = fd_device[drive]; if (!UD.connected) { /* drive not connected */ @@ -1857,7 +1858,7 @@ static int floppy_open( struct inode *inode, struct file *filp ) int old_dev = fd_device[drive]; DPRINT(("fd_open: type=%d\n",type)); - if (fd_ref[drive] && old_dev != minor(inode->i_rdev)) + if (fd_ref[drive] && old_dev != type) return -EBUSY; if (fd_ref[drive] == -1 || (fd_ref[drive] && filp->f_flags & O_EXCL)) @@ -1868,10 +1869,10 @@ static int floppy_open( struct inode *inode, struct file *filp ) else fd_ref[drive]++; - fd_device[drive] = minor(inode->i_rdev); + fd_device[drive] = type; - if (old_dev && old_dev != minor(inode->i_rdev)) - invalidate_buffers(mk_kdev(FLOPPY_MAJOR, old_dev)); + if (old_dev && old_dev != type) + invalidate_buffers(mk_kdev(FLOPPY_MAJOR, drive + (type<<2))); if (filp->f_flags & O_NDELAY) return 0; diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 49ce1f9297f7..f14c30940510 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -2158,12 +2158,13 @@ static void bad_flp_intr(void) DRS->track = NEED_2_RECAL; } -static void set_floppy(kdev_t device) +static void set_floppy(int drive) { - if (TYPE(device)) - _floppy = TYPE(device) + floppy_type; + int type = ITYPE(UDRS->fd_device); + if (type) + _floppy = floppy_type + type; else - _floppy = current_type[ DRIVE(device) ]; + _floppy = current_type[ drive ]; } /* @@ -2269,7 +2270,7 @@ static int do_format(kdev_t device, struct format_descr *tmp_format_req) int drive=DRIVE(device); LOCK_FDC(drive,1); - set_floppy(device); + set_floppy(drive); if (!_floppy || _floppy->track > DP->tracks || tmp_format_req->track >= _floppy->track || @@ -2631,7 +2632,7 @@ static int make_raw_rw_request(void) return 0; } - set_fdc(DRIVE(current_req->rq_dev)); + set_fdc((int)current_req->rq_disk->private_data); raw_cmd = &default_raw_cmd; raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_DISK | @@ -2902,7 +2903,7 @@ static int make_raw_rw_request(void) static void redo_fd_request(void) { #define REPEAT {request_done(0); continue; } - kdev_t device; + int drive; int tmp; lastredo = jiffies; @@ -2919,11 +2920,11 @@ static void redo_fd_request(void) } current_req = req; } - device = current_req->rq_dev; - set_fdc(DRIVE(device)); + drive = (int)current_req->rq_disk->private_data; + set_fdc(drive); reschedule_timeout(current_reqD, "redo fd request", 0); - set_floppy(device); + set_floppy(drive); raw_cmd = & default_raw_cmd; raw_cmd->flags = 0; if (start_motor(redo_fd_request)) return; @@ -3594,7 +3595,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, if (type) return -EINVAL; LOCK_FDC(drive,1); - set_floppy(device); + set_floppy(drive); CALL(i = raw_cmd_ioctl(cmd,(void *) param)); process_fd_request(); return i; diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c index 88fc315312ec..3f92b0923e1b 100644 --- a/drivers/block/ps2esdi.c +++ b/drivers/block/ps2esdi.c @@ -74,7 +74,7 @@ static int ps2esdi_geninit(void); static void do_ps2esdi_request(request_queue_t * q); -static void ps2esdi_readwrite(int cmd, u_char drive, u_int block, u_int count); +static void ps2esdi_readwrite(int cmd, struct request *req); static void ps2esdi_fill_cmd_block(u_short * cmd_blk, u_short cmd, u_short cyl, u_short head, u_short sector, u_short length, u_char drive); @@ -567,7 +567,7 @@ static void ps2esdi_readwrite(int cmd, struct request *req) struct ps2esdi_i_struct *p = req->rq_disk->private_data; unsigned block = req->sector; unsigned count = req->current_nr_sectors; - int drive = DEVICE_NR(req->rq_dev); + int drive = p - ps2esdi_info; u_short track, head, cylinder, sector; u_short cmd_blk[TYPE_1_CMD_BLK_LENGTH]; |
