IDE driver with CD-RWs (ide-scsi)

Andrew T. Veliath (andrewtv@usa.net)
Wed, 16 Dec 1998 17:53:30 -0500


Hello,

A few days ago I picked up one of these cheap ACER CD-RWs. I didn't
want to use IDE SCSI emulation for my DVD-ROM, and I noticed the
hdd=ide_scsi option was no longer an option and echo "ide-scsi" >
/proc/ide/hdd/driver also didn't appear to work. My /dev/hdc is a
DVD-ROM.

``echo "ide-scsi" > /proc/ide/hdx/driver'' or ``echo "ide-cdrom" >
/proc/ide/hdx/driver'' should work, even if the ide-cd and ide-scsi
modules aren't loaded yet (it doesn't NULL driver_req like it used to
after writing to /proc). This seems useful if ide-scsi is set to the
scsi_hostadapter.

With the following changes, I can do the following things, since I
have ide.c compiled into the kernel, and ide-cd.c and ide-scsi.c as
modular. Of course, I will leave it to the maintainers to fix the
deficiencies in this patch :-). I don't think it will change anything
for a non-modular setup.

1.
echo "ide-scsi" > /proc/ide/hdd/driver
modprobe ide-cd
modprobe ide-scsi

or 2.

modprobe ide-cd
modprobe ide-scsi
echo "ide-scsi" > /proc/ide/hdd/driver

With the same effect in that cat hdd/driver will show ide-cdrom and
cat hdc/driver will show ide-scsi. Patch is against 2.1.131ac11.

diff -ur /usr/src/orig/linux/drivers/block/ide-proc.c linux/drivers/block/ide-proc.c
--- /usr/src/orig/linux/drivers/block/ide-proc.c Wed May 6 17:42:53 1998
+++ linux/drivers/block/ide-proc.c Mon Dec 14 16:33:35 1998
@@ -551,10 +551,26 @@
(struct file *file, const char *buffer, unsigned long count, void *data)
{
ide_drive_t *drive = (ide_drive_t *) data;
+ char name[MAX_LEN + 1];
+ int n;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (ide_replace_subdriver(drive, buffer))
+ /*
+ * Skip over leading whitespace
+ */
+ while (count && isspace(*buffer)) {
+ --count;
+ ++buffer;
+ }
+ n = IDE_MIN(count, MAX_LEN);
+ strncpy(name, buffer, n);
+ name[n] = 0;
+ n = strlen(name);
+ if (name[n - 1] == '\n')
+ name[n - 1] = 0;
+
+ if (ide_replace_subdriver(drive, name))
return -EINVAL;
return count;
}
diff -ur /usr/src/orig/linux/drivers/block/ide.c linux/drivers/block/ide.c
--- /usr/src/orig/linux/drivers/block/ide.c Mon Dec 14 13:49:20 1998
+++ linux/drivers/block/ide.c Mon Dec 14 16:38:43 1998
@@ -1651,9 +1651,8 @@
goto abort;
strncpy(drive->driver_req, driver, 9);
ide_init_module(IDE_DRIVER_MODULE);
- drive->driver_req[0] = 0;
- ide_init_module(IDE_DRIVER_MODULE);
- if (DRIVER(drive) && !strcmp(DRIVER(drive)->name, driver))
+ if (DRIVER(drive) &&
+ !strncmp(DRIVER(drive)->name, drive->driver_req, 9))
return 0;
abort:
return 1;
diff -ur /usr/src/orig/linux/drivers/scsi/ide-scsi.c linux/drivers/scsi/ide-scsi.c
--- /usr/src/orig/linux/drivers/scsi/ide-scsi.c Sun Oct 4 16:30:27 1998
+++ linux/drivers/scsi/ide-scsi.c Mon Dec 14 17:35:40 1998
@@ -496,7 +496,6 @@
*/
static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi, int id)
{
- DRIVER(drive)->busy++;
idescsi_drives[id] = drive;
drive->driver_data = scsi;
drive->ready_stat = 0;
@@ -556,6 +555,10 @@

static struct proc_dir_entry idescsi_proc_dir = {PROC_SCSI_IDESCSI, 8, "ide-scsi", S_IFDIR | S_IRUGO | S_IXUGO, 2};

+#ifdef MODULE
+Scsi_Host_Template idescsi_template = IDESCSI;
+#endif
+
/*
* idescsi_init will register the driver for each scsi.
*/
@@ -565,10 +568,16 @@
idescsi_scsi_t *scsi;
byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255};
int i, failed, id;
-
- if (idescsi_initialized)
+
+ if (idescsi_initialized) {
+#ifdef MODULE
+ scsi_unregister_module (MODULE_SCSI_HA, &idescsi_template);
+#else
return 0;
+#endif
+ }
idescsi_initialized = 1;
+
for (i = 0; i < MAX_HWIFS * MAX_DRIVES; i++)
idescsi_drives[i] = NULL;
MOD_INC_USE_COUNT;
@@ -584,12 +593,17 @@
kfree (scsi);
continue;
}
+ DRIVER(drive)->busy++;
for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
idescsi_setup (drive, scsi, id);
+ DRIVER(drive)->busy--;
failed--;
}
}
ide_register_module(&idescsi_module);
+#ifdef MODULE
+ scsi_register_module (MODULE_SCSI_HA, &idescsi_template);
+#endif
MOD_DEC_USE_COUNT;
return 0;
}
@@ -609,14 +623,6 @@

int idescsi_release (struct Scsi_Host *host)
{
- ide_drive_t *drive;
- int id;
-
- for (id = 0; id < MAX_HWIFS * MAX_DRIVES; id++) {
- drive = idescsi_drives[id];
- if (drive)
- DRIVER(drive)->busy--;
- }
return 0;
}

@@ -805,8 +811,6 @@
}

#ifdef MODULE
-Scsi_Host_Template idescsi_template = IDESCSI;
-
int init_module (void)
{
idescsi_init ();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/