diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 91 |
1 files changed, 26 insertions, 65 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index aaa3b0528a35..2a2bc89aba83 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -86,12 +86,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); -#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) -#define SD_MINORS 16 -#else -#define SD_MINORS 0 -#endif - static int sd_revalidate_disk(struct gendisk *); static int sd_probe(struct device *); static int sd_remove(struct device *); @@ -383,6 +377,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) sector_t block = rq->sector; sector_t threshold; unsigned int this_count = rq->nr_sectors; + unsigned int timeout = sdp->timeout; int ret; if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { @@ -583,6 +578,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) SCpnt->transfersize = sdp->sector_size; SCpnt->underflow = this_count << 9; SCpnt->allowed = SD_MAX_RETRIES; + SCpnt->timeout_per_command = timeout; /* * This indicates that the command is ready from our end to be @@ -1768,52 +1764,6 @@ static int sd_revalidate_disk(struct gendisk *disk) } /** - * sd_format_disk_name - format disk name - * @prefix: name prefix - ie. "sd" for SCSI disks - * @index: index of the disk to format name for - * @buf: output buffer - * @buflen: length of the output buffer - * - * SCSI disk names starts at sda. The 26th device is sdz and the - * 27th is sdaa. The last one for two lettered suffix is sdzz - * which is followed by sdaaa. - * - * This is basically 26 base counting with one extra 'nil' entry - * at the beggining from the second digit on and can be - * determined using similar method as 26 base conversion with the - * index shifted -1 after each digit is computed. - * - * CONTEXT: - * Don't care. - * - * RETURNS: - * 0 on success, -errno on failure. - */ -static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen) -{ - const int base = 'z' - 'a' + 1; - char *begin = buf + strlen(prefix); - char *end = buf + buflen; - char *p; - int unit; - - p = end - 1; - *p = '\0'; - unit = base; - do { - if (p == begin) - return -EINVAL; - *--p = 'a' + (index % unit); - index = (index / unit) - 1; - } while (index >= 0); - - memmove(begin, p, end - p); - memcpy(buf, prefix, strlen(prefix)); - - return 0; -} - -/** * sd_probe - called during driver initialization and whenever a * new scsi device is attached to the system. It is called once * for each scsi device (not just disks) present. @@ -1851,7 +1801,7 @@ static int sd_probe(struct device *dev) if (!sdkp) goto out; - gd = alloc_disk(SD_MINORS); + gd = alloc_disk(16); if (!gd) goto out_free; @@ -1865,8 +1815,8 @@ static int sd_probe(struct device *dev) if (error) goto out_put; - error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); - if (error) + error = -EBUSY; + if (index >= SD_MAX_DISKS) goto out_free_index; sdkp->device = sdp; @@ -1876,12 +1826,11 @@ static int sd_probe(struct device *dev) sdkp->openers = 0; sdkp->previous_state = 1; - if (!sdp->request_queue->rq_timeout) { + if (!sdp->timeout) { if (sdp->type != TYPE_MOD) - blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT); + sdp->timeout = SD_TIMEOUT; else - blk_queue_rq_timeout(sdp->request_queue, - SD_MOD_TIMEOUT); + sdp->timeout = SD_MOD_TIMEOUT; } device_initialize(&sdkp->dev); @@ -1894,12 +1843,24 @@ static int sd_probe(struct device *dev) get_device(&sdp->sdev_gendev); - if (index < SD_MAX_DISKS) { - gd->major = sd_major((index & 0xf0) >> 4); - gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); - gd->minors = SD_MINORS; - } + gd->major = sd_major((index & 0xf0) >> 4); + gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); + gd->minors = 16; gd->fops = &sd_fops; + + if (index < 26) { + sprintf(gd->disk_name, "sd%c", 'a' + index % 26); + } else if (index < (26 + 1) * 26) { + sprintf(gd->disk_name, "sd%c%c", + 'a' + index / 26 - 1,'a' + index % 26); + } else { + const unsigned int m1 = (index / 26 - 1) / 26 - 1; + const unsigned int m2 = (index / 26 - 1) % 26; + const unsigned int m3 = index % 26; + sprintf(gd->disk_name, "sd%c%c%c", + 'a' + m1, 'a' + m2, 'a' + m3); + } + gd->private_data = &sdkp->driver; gd->queue = sdkp->device->request_queue; @@ -1908,7 +1869,7 @@ static int sd_probe(struct device *dev) blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); gd->driverfs_dev = &sdp->sdev_gendev; - gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS; + gd->flags = GENHD_FL_DRIVERFS; if (sdp->removable) gd->flags |= GENHD_FL_REMOVABLE; |