Skip to contentSkip to conversation

[2.6] units= parameter for ide-scsi

PATCH In review Mikael Pettersson 2 participants 2 messages Jan 10, 2004 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [2.6] units= parameter for ide-scsi

Quoted 10 lines · Willem Riede
Quoted 9 lines · Mikael Pettersson

On Fri, 26 Dec 2003 13:12:42 -0500, Willem Riede wrote:
...

Quoted 6 lines

So can we agree to keep ide-scsi? I know it is not desired any more for cd writers. To avoid the problem reports from people who don't realize that and select ide-scsi anyway, we can refuse to attach to a cd-type device (today it just warns). And/or make a new explicit module parameter to tell ide-scsi exactly which drives to attach to.

Quoted 3 lines
Quoted 1 line

I have a simple patch to do exactly that. Contact me if you want it.

Yes, please do send me that patch.

This is my patch to add a "units=" parameter to ide-scsi. It's useful for people that, like me, have more than one ATAPI device in a machine. Sample usage:

modprobe ide_scsi units=hdc+hdd
to claim both hdc and hdd for ide-scsi.

modprobe ide_scsi units=hdd
to claim only hdd for ide-scsi, skipping all
other unclaimed devices.

This also works in the non-modular case. Simply pass "ide_scsi.units=..." as a kernel boot argument.

The /* XXX: too horrible to explain */ comment refers to a problem with the module_param implementation, which creates a string literal from the kbuild-defined module name. Unfortunately "ide_scsi" is a #define in <linux/ide.h>, so the string literal ends up containing the value of ide_scsi rather than its spelling. Hence the #undef.

/Mikael

drivers/scsi/ide-scsi.c +9 -0
diff -rupN linux-2.6.1/drivers/scsi/ide-scsi.c linux-2.6.1.ide-scsi-units/drivers/scsi/ide-scsi.c
@@ -45,6 +45,7 @@
 #include <linux/hdreg.h>
 #include <linux/slab.h>
 #include <linux/ide.h>
+#include <linux/moduleparam.h>
 
 #include <asm/io.h>
 #include <asm/bitops.h>
@@ -947,6 +948,10 @@ static Scsi_Host_Template idescsi_templa
 	.proc_name		= "ide-scsi",
 };
 
+static char *units;
+#undef ide_scsi /* XXX: too horrible to explain */
+module_param_named(units, units, charp, 0);
+
 static int idescsi_attach(ide_drive_t *drive)
 {
 	idescsi_scsi_t *idescsi;
@@ -954,6 +959,10 @@ static int idescsi_attach(ide_drive_t *d
 	static int warned;
 	int err;
 
+	if (units && !strstr(units, drive->name)) {
+		printk(KERN_INFO "ide-scsi: ignoring drive %s\n", drive->name);
+		return 1;
+	}
 	if (!warned && drive->media == ide_cdrom) {
 		printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n");
 		warned = 1;
#1 lore raw
Quoted 3 lines · Mikael Pettersson

This is my patch to add a "units=" parameter to ide-scsi. It's useful for people that, like me, have more than one ATAPI device in a machine. Sample usage:

I found that if only the existing hdx=ide-scsi mechanism had been strictly enforced, this functionality had already existed:

tmp/ide-scsi.c renamed from drivers/scsi/ide-scsi.c +10 -7
@@ -54,6 +54,9 @@
 #include "hosts.h"
 #include <scsi/sg.h>
 
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Scsi emulator for ATAPI Tape and MO devices");
+
 #define IDESCSI_DEBUG_LOG		0
 
 typedef struct idescsi_pc_s {
@@ -954,17 +957,18 @@
 	static int warned;
 	int err;
 
-	if (!warned && drive->media == ide_cdrom) {
-		printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n");
-		warned = 1;
-	}
-
-	if (!strstr("ide-scsi", drive->driver_req) ||
+	if (!drive->driver_req ||
+	    !strstr(drive->driver_req, "ide-scsi") ||
 	    !drive->present ||
 	    drive->media == ide_disk ||
 	    !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
 		return 1;
 
+	if (!warned && drive->media == ide_cdrom) {
+		printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n");
+		warned = 1;
+	}
+
 	host->max_id = 1;
 	host->max_lun = 1;
 	drive->driver_data = host;
@@ -1000,4 +1004,3 @@
 
 module_init(init_idescsi_module);
 module_exit(exit_idescsi_module);
-MODULE_LICENSE("GPL");

Regards, Willem Riede.