Commit e2e442eb authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[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.
parent a7be265f
......@@ -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 @@ static void redo_fd_request(void)
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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 @@ static void redo_fd_request(void)
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;
......
......@@ -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;
......
......@@ -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];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment