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

[PATCH] scsi_get_request_dev() cleanup

	_Now_ we can clean the scsi_get_request_dev() up.  Indeed, for
any SCSI request we either have ->rq_dev == NODEV and ->rq_disk == NULL
or ->rq_disk->private_data points to address of template in question.
IOW, scsi_get_request_dev() becomes simply
{
	struct gendisk *p = req->rq_disk;
	return p ? *(struct Scsi_Device_Template **)p->private_data : NULL;
}
and that allows to kill ->max_major, ->min_major and ->major in
Scsi_Device_Template, along with the last non-trivial use of ->rq_dev.
parent 1c48fba3
...@@ -560,9 +560,6 @@ struct Scsi_Device_Template ...@@ -560,9 +560,6 @@ struct Scsi_Device_Template
const char * tag; const char * tag;
struct module * module; /* Used for loadable modules */ struct module * module; /* Used for loadable modules */
unsigned char scsi_type; unsigned char scsi_type;
unsigned int major;
unsigned int min_major; /* Minimum major in range. */
unsigned int max_major; /* Maximum major in range. */
unsigned int nr_dev; /* Number currently attached */ unsigned int nr_dev; /* Number currently attached */
unsigned int dev_noticed; /* Number of devices detected. */ unsigned int dev_noticed; /* Number of devices detected. */
unsigned int dev_max; /* Current size of arrays */ unsigned int dev_max; /* Current size of arrays */
......
...@@ -760,9 +760,13 @@ static inline struct bio *idescsi_dma_bio(ide_drive_t *drive, idescsi_pc_t *pc) ...@@ -760,9 +760,13 @@ static inline struct bio *idescsi_dma_bio(ide_drive_t *drive, idescsi_pc_t *pc)
static inline int should_transform(ide_drive_t *drive, Scsi_Cmnd *cmd) static inline int should_transform(ide_drive_t *drive, Scsi_Cmnd *cmd)
{ {
idescsi_scsi_t *scsi = drive->driver_data; idescsi_scsi_t *scsi = drive->driver_data;
struct gendisk *disk = cmd->request->rq_disk;
if (major(cmd->request->rq_dev) == SCSI_GENERIC_MAJOR) if (disk) {
struct Scsi_Device_Template **p = disk->private_data;
if (strcmp((*p)->tag, "sg") == 0)
return test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); return test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
}
return test_bit(IDESCSI_TRANSFORM, &scsi->transform); return test_bit(IDESCSI_TRANSFORM, &scsi->transform);
} }
......
...@@ -162,7 +162,6 @@ struct Scsi_Device_Template osst_template = ...@@ -162,7 +162,6 @@ struct Scsi_Device_Template osst_template =
name: "OnStream tape", name: "OnStream tape",
tag: "osst", tag: "osst",
scsi_type: TYPE_TAPE, scsi_type: TYPE_TAPE,
major: OSST_MAJOR,
detect: osst_detect, detect: osst_detect,
init: osst_init, init: osst_init,
attach: osst_attach, attach: osst_attach,
......
...@@ -635,7 +635,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -635,7 +635,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
break; break;
case NOT_READY: case NOT_READY:
printk(KERN_INFO "Device %s not ready.\n", printk(KERN_INFO "Device %s not ready.\n",
kdevname(req->rq_dev)); req->rq_disk ? req->rq_disk->disk_name : "");
SCpnt = scsi_end_request(SCpnt, 0, this_count); SCpnt = scsi_end_request(SCpnt, 0, this_count);
return; return;
break; break;
...@@ -703,36 +703,8 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -703,36 +703,8 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
*/ */
struct Scsi_Device_Template *scsi_get_request_dev(struct request *req) struct Scsi_Device_Template *scsi_get_request_dev(struct request *req)
{ {
struct Scsi_Device_Template *spnt; struct gendisk *p = req->rq_disk;
kdev_t dev = req->rq_dev; return p ? *(struct Scsi_Device_Template **)p->private_data : NULL;
int major = major(dev);
for (spnt = scsi_devicelist; spnt; spnt = spnt->next) {
/*
* Search for a block device driver that supports this
* major.
*/
if (spnt->blk && spnt->major == major) {
return spnt;
}
/*
* I am still not entirely satisfied with this solution,
* but it is good enough for now. Disks have a number of
* major numbers associated with them, the primary
* 8, which we test above, and a secondary range of 7
* different consecutive major numbers. If this ever
* becomes insufficient, then we could add another function
* to the structure, and generalize this completely.
*/
if( spnt->min_major != 0
&& spnt->max_major != 0
&& major >= spnt->min_major
&& major <= spnt->max_major )
{
return spnt;
}
}
return NULL;
} }
/* /*
......
...@@ -106,9 +106,6 @@ static struct Scsi_Device_Template sd_template = { ...@@ -106,9 +106,6 @@ static struct Scsi_Device_Template sd_template = {
.name = "disk", .name = "disk",
.tag = "sd", .tag = "sd",
.scsi_type = TYPE_DISK, .scsi_type = TYPE_DISK,
.major = SCSI_DISK0_MAJOR,
.min_major = SCSI_DISK1_MAJOR,
.max_major = SCSI_DISK7_MAJOR,
.blk = 1, .blk = 1,
.detect = sd_detect, .detect = sd_detect,
.attach = sd_attach, .attach = sd_attach,
......
...@@ -125,7 +125,6 @@ static struct Scsi_Device_Template sg_template = { ...@@ -125,7 +125,6 @@ static struct Scsi_Device_Template sg_template = {
.name = "generic", .name = "generic",
.tag = "sg", .tag = "sg",
.scsi_type = 0xff, .scsi_type = 0xff,
.major = SCSI_GENERIC_MAJOR,
.detect = sg_detect, .detect = sg_detect,
.init = sg_init, .init = sg_init,
.attach = sg_attach, .attach = sg_attach,
......
...@@ -77,7 +77,6 @@ static struct Scsi_Device_Template sr_template = { ...@@ -77,7 +77,6 @@ static struct Scsi_Device_Template sr_template = {
.name = "cdrom", .name = "cdrom",
.tag = "sr", .tag = "sr",
.scsi_type = TYPE_ROM, .scsi_type = TYPE_ROM,
.major = SCSI_CDROM_MAJOR,
.blk = 1, .blk = 1,
.detect = sr_detect, .detect = sr_detect,
.init = sr_init, .init = sr_init,
......
...@@ -175,7 +175,6 @@ static struct Scsi_Device_Template st_template = { ...@@ -175,7 +175,6 @@ static struct Scsi_Device_Template st_template = {
.name = "tape", .name = "tape",
.tag = "st", .tag = "st",
.scsi_type = TYPE_TAPE, .scsi_type = TYPE_TAPE,
.major = SCSI_TAPE_MAJOR,
.detect = st_detect, .detect = st_detect,
.attach = st_attach, .attach = st_attach,
.detach = st_detach .detach = st_detach
......
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