patch-2.4.0-test9 linux/drivers/scsi/sd.c
Next file: linux/drivers/scsi/seagate.c
Previous file: linux/drivers/scsi/scsi_syms.c
Back to the patch index
Back to the overall index
- Lines: 255
- Date:
Sun Oct 1 20:35:16 2000
- Orig file:
v2.4.0-test8/linux/drivers/scsi/sd.c
- Orig date:
Thu Sep 7 08:56:00 2000
diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sd.c linux/drivers/scsi/sd.c
@@ -80,7 +80,7 @@
struct hd_struct *sd;
-static Scsi_Disk *rscsi_disks = NULL;
+static Scsi_Disk *rscsi_disks;
static int *sd_sizes;
static int *sd_blocksizes;
static int *sd_hardsizes; /* Hardware sector size */
@@ -96,10 +96,30 @@
static int sd_attach(Scsi_Device *);
static int sd_detect(Scsi_Device *);
static void sd_detach(Scsi_Device *);
-static void rw_intr(Scsi_Cmnd * SCpnt);
-
static int sd_init_command(Scsi_Cmnd *);
+static struct Scsi_Device_Template sd_template = {
+ name:"disk",
+ tag:"sd",
+ scsi_type:TYPE_DISK,
+ major:SCSI_DISK0_MAJOR,
+ /*
+ * Secondary range of majors that this driver handles.
+ */
+ min_major:SCSI_DISK1_MAJOR,
+ max_major:SCSI_DISK7_MAJOR,
+ blk:1,
+ detect:sd_detect,
+ init:sd_init,
+ finish:sd_finish,
+ attach:sd_attach,
+ detach:sd_detach,
+ init_command:sd_init_command,
+};
+
+
+static void rw_intr(Scsi_Cmnd * SCpnt);
+
#if defined(CONFIG_PPC)
/*
* Moved from arch/ppc/pmac_setup.c. This is where it really belongs.
@@ -243,25 +263,6 @@
}
}
-struct Scsi_Device_Template sd_template = {
- name:"disk",
- tag:"sd",
- scsi_type:TYPE_DISK,
- major:SCSI_DISK0_MAJOR,
- /*
- * Secondary range of majors that this driver handles.
- */
- min_major:SCSI_DISK1_MAJOR,
- max_major:SCSI_DISK7_MAJOR,
- blk:1,
- detect:sd_detect,
- init:sd_init,
- finish:sd_finish,
- attach:sd_attach,
- detach:sd_detach,
- init_command:sd_init_command,
-};
-
static request_queue_t *sd_find_queue(kdev_t dev)
{
Scsi_Disk *dpnt;
@@ -720,13 +721,14 @@
sd_devname(i, nbuff);
/*
- * If the device is offline, don't try and read capacity or any of the other
- * nicities.
+ * If the device is offline, don't try and read capacity or any
+ * of the other niceties.
*/
- if (rscsi_disks[i].device->online == FALSE) {
+ if (rscsi_disks[i].device->online == FALSE)
return i;
- }
- /* We need to retry the READ_CAPACITY because a UNIT_ATTENTION is
+
+ /*
+ * We need to retry the READ_CAPACITY because a UNIT_ATTENTION is
* considered a fatal error, and many devices report such an error
* just after a scsi bus reset.
*/
@@ -807,7 +809,8 @@
} while(time1);
printk(".");
}
- } while (the_result && spintime && time_after(spintime_value + 100 * HZ, jiffies));
+ } while (the_result && spintime &&
+ time_after(spintime_value + 100 * HZ, jiffies));
if (spintime) {
if (the_result)
printk("not responding...\n");
@@ -836,15 +839,16 @@
/*
* The SCSI standard says:
* "READ CAPACITY is necessary for self configuring software"
- * While not mandatory, support of READ CAPACITY is strongly encouraged.
+ * While not mandatory, support of READ CAPACITY is strongly
+ * encouraged.
* We used to die if we couldn't successfully do a READ CAPACITY.
* But, now we go on about our way. The side effects of this are
*
- * 1. We can't know block size with certainty. I have said "512 bytes
- * is it" as this is most common.
+ * 1. We can't know block size with certainty. I have said
+ * "512 bytes is it" as this is most common.
*
- * 2. Recovery from when some one attempts to read past the end of the
- * raw device will be slower.
+ * 2. Recovery from when someone attempts to read past the
+ * end of the raw device will be slower.
*/
if (the_result) {
@@ -867,15 +871,15 @@
rscsi_disks[i].capacity = 0x1fffff;
sector_size = 512;
- /* Set dirty bit for removable devices if not ready - sometimes drives
- * will not report this properly. */
+ /* Set dirty bit for removable devices if not ready -
+ * sometimes drives will not report this properly. */
if (rscsi_disks[i].device->removable &&
SRpnt->sr_sense_buffer[2] == NOT_READY)
rscsi_disks[i].device->changed = 1;
} else {
/*
- * FLOPTICAL , if read_capa is ok , drive is assumed to be ready
+ * FLOPTICAL, if read_capa is ok, drive is assumed to be ready
*/
rscsi_disks[i].ready = 1;
@@ -889,7 +893,8 @@
if (sector_size == 0) {
sector_size = 512;
- printk("%s : sector size 0 reported, assuming 512.\n", nbuff);
+ printk("%s : sector size 0 reported, assuming 512.\n",
+ nbuff);
}
if (sector_size != 512 &&
sector_size != 1024 &&
@@ -924,31 +929,30 @@
* So I have created this table. See ll_rw_blk.c
* Jacques Gelinas (Jacques@solucorp.qc.ca)
*/
- int m, mb;
- int sz_quot, sz_rem;
+ int m;
int hard_sector = sector_size;
+ int sz = rscsi_disks[i].capacity * (hard_sector/256);
+
/* There are 16 minors allocated for each major device */
for (m = i << 4; m < ((i + 1) << 4); m++) {
sd_hardsizes[m] = hard_sector;
}
- mb = rscsi_disks[i].capacity / 1024 * hard_sector / 1024;
- /* sz = div(m/100, 10); this seems to not be in the libr */
- m = (mb + 50) / 100;
- sz_quot = m / 10;
- sz_rem = m - (10 * sz_quot);
- printk("SCSI device %s: hdwr sector= %d bytes."
- " Sectors= %d [%d MB] [%d.%1d GB]\n",
- nbuff, hard_sector, rscsi_disks[i].capacity,
- mb, sz_quot, sz_rem);
+
+ printk("SCSI device %s: "
+ "%d %d-byte hdwr sectors (%d MB)\n",
+ nbuff, rscsi_disks[i].capacity,
+ hard_sector, (sz/2 - sz/1250 + 974)/1950);
}
+
+ /* Rescale capacity to 512-byte units */
if (sector_size == 4096)
rscsi_disks[i].capacity <<= 3;
if (sector_size == 2048)
- rscsi_disks[i].capacity <<= 2; /* Change into 512 byte sectors */
+ rscsi_disks[i].capacity <<= 2;
if (sector_size == 1024)
- rscsi_disks[i].capacity <<= 1; /* Change into 512 byte sectors */
+ rscsi_disks[i].capacity <<= 1;
if (sector_size == 256)
- rscsi_disks[i].capacity >>= 1; /* Change into 512 byte sectors */
+ rscsi_disks[i].capacity >>= 1;
}
@@ -1014,7 +1018,7 @@
* their size, and reads partition table entries for them.
*/
-static int sd_registered = 0;
+static int sd_registered;
static int sd_init()
{
@@ -1030,7 +1034,7 @@
sd_template.dev_max = N_SD_MAJORS * SCSI_DISKS_PER_MAJOR;
if (!sd_registered) {
- for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
+ for (i = 0; i < N_USED_SD_MAJORS; i++) {
if (devfs_register_blkdev(SD_MAJOR(i), "sd", &sd_fops)) {
printk("Unable to get major %d for SCSI disk\n", SD_MAJOR(i));
return 1;
@@ -1142,7 +1146,7 @@
struct gendisk *gendisk;
int i;
- for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
+ for (i = 0; i < N_USED_SD_MAJORS; i++) {
blk_dev[SD_MAJOR(i)].queue = sd_find_queue;
}
for (gendisk = gendisk_head; gendisk != NULL; gendisk = gendisk->next)
@@ -1335,12 +1339,13 @@
return;
}
-int init_sd(void)
+static int __init init_sd(void)
{
sd_template.module = THIS_MODULE;
return scsi_register_module(MODULE_SCSI_DEV, &sd_template);
}
-void exit_sd(void)
+
+static void __exit exit_sd(void)
{
struct gendisk **prev_sdgd_link;
struct gendisk *sdgd;
@@ -1349,7 +1354,7 @@
scsi_unregister_module(MODULE_SCSI_DEV, &sd_template);
- for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++)
+ for (i = 0; i < N_USED_SD_MAJORS; i++)
devfs_unregister_blkdev(SD_MAJOR(i), "sd");
sd_registered--;
@@ -1378,7 +1383,7 @@
removed > N_USED_SD_MAJORS ? "total" : "just", removed);
}
- for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
+ for (i = 0; i < N_USED_SD_MAJORS; i++) {
blk_size[SD_MAJOR(i)] = NULL;
hardsect_size[SD_MAJOR(i)] = NULL;
read_ahead[SD_MAJOR(i)] = 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)