* [PATCH] aacraid: Add kernel command line parameter parsing
@ 2007-01-30 21:42 Salyzyn, Mark
2007-01-31 9:55 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Salyzyn, Mark @ 2007-01-30 21:42 UTC (permalink / raw)
To: SCSI Mailing List; +Cc: James Bottomley, Mark Haverkamp
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
One shortcoming of the driver relationship with the kernel is that there
is no standard means of having the insmod parameters associated with a
driver to also be parsed and set by the kernel parameter line. The
enclosed patch is a proposal for the aacraid driver to pick up the
kernel parameter line, parse it, and then adjust the insmod parameters.
The format of the kernel parameter line is
aacraid=<parm>:<value>[,<parm>:<value>]...
There may be a better way of providing this service via the kernel
without any modifications from the driver, since all the characteristics
of the insmod parameters are exported by the MODULE_PARM_* hints. Would
such mods be in insmod/modprobe and not in the kernel or driver?
Signed-off-by Mark Salyzyn <aacraid@adaptec.com>
---
Sincerely -- Mark Salyzyn
Illegitimi Non Carborundum
[-- Attachment #2: aacraid_command_line.patch --]
[-- Type: application/octet-stream, Size: 3401 bytes --]
diff -ru a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
--- a/drivers/scsi/aacraid/aachba.c 2007-01-30 16:24:35.781370236 -0500
+++ b/drivers/scsi/aacraid/aachba.c 2007-01-30 16:31:51.738891361 -0500
@@ -173,6 +173,51 @@
int expose_physicals = -1;
module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
+
+static char aacraid[COMMAND_LINE_SIZE];
+module_param_string(aacraid, aacraid, sizeof(aacraid), 0);
+MODULE_PARM_DESC(aacraid, "set the various published parameters of the aacraid driver with a syntax of aacraid=parm:value[,parm:value]...");
+
+static int aacraid_setup(char *str)
+{
+ int i;
+ char *key;
+ char *value;
+ struct {
+ char * option_name;
+ int * option_flag;
+ int option_value;
+ } options[] = {
+ { "nondasd", &nondasd, 1 },
+ { "dacmode", &dacmode, 1 },
+ { "commit", &commit, 1 },
+ { "acbsize", &acbsize, 8192 },
+ { "expose_physicals", &expose_physicals, -1 },
+ };
+
+ if (str) while ((key = strsep(&str, ",.;"))) {
+ if (!*key)
+ continue;
+ if (((value = strchr(key, ':')))
+ || ((value = strchr(key, '='))))
+ *value++ = '\0';
+ for (i = 0; i < (sizeof (options) / sizeof (options[0])); i++) {
+ if (strnicmp (key, options[i].option_name,
+ strlen(options[i].option_name)) == 0) {
+ *options[i].option_flag
+ = (value)
+ ? simple_strtoul(value, NULL, 0)
+ : options[i].option_value;
+ break;
+ }
+ }
+ }
+
+ return (1);
+}
+
+__setup("aacraid=", aacraid_setup);
+
/**
* aac_get_config_status - check the adapter configuration
* @common: adapter to query
@@ -1148,6 +1193,69 @@
dev->name, dev->id,
le32_to_cpu(dev->adapter_info.serial[0]));
}
+ if (!aacraid[0])
+ {
+ char * command_line;
+ char *from, *to;
+#ifdef MODULE
+ extern struct proc_dir_entry proc_root;
+ struct proc_dir_entry * entry;
+
+ command_line = kmalloc(COMMAND_LINE_SIZE, GFP_KERNEL);
+ memset(command_line, 0, COMMAND_LINE_SIZE);
+ for (entry = proc_root.subdir;
+ entry != (struct proc_dir_entry *)NULL;
+ entry = entry->next) {
+ if ((entry->low_ino != 0)
+ && (entry->namelen == 7)
+ && (memcmp ("cmdline", entry->name, 7) == 0)) {
+ if (entry->read_proc != (int (*)(char *, char **, off_t, int, int *, void *))NULL) {
+ char * start = command_line;
+ int eof;
+ mm_segment_t fs;
+
+ fs = get_fs();
+ set_fs(get_ds());
+ lock_kernel();
+ entry->read_proc(command_line, &start,
+ (off_t)0, COMMAND_LINE_SIZE-1, &eof,
+ NULL);
+ unlock_kernel();
+ set_fs(fs);
+ }
+ break;
+ }
+ }
+#else
+ extern char saved_command_line[];
+ command_line = saved_command_line;
+#endif
+ memset(aacraid, 0, sizeof(aacraid));
+ from = command_line;
+ to = aacraid;
+ while (*from) {
+ if ((from[0] == 'a')
+ && (from[1] == 'a')
+ && (from[2] == 'c')
+ && (from[3] == 'r')
+ && (from[4] == 'a')
+ && (from[5] == 'i')
+ && (from[6] == 'd')
+ && (from[7] == '=')) {
+ /* concatenate multiple instances of aacraid= */
+ if (to != aacraid)
+ *to++ = ',';
+ for (from += 8; *from && (*from != ' '); ++from)
+ *to++ =*from;
+ }
+ ++from;
+ }
+#ifdef MODULE
+ kfree(command_line);
+#endif
+ }
+ if (aacraid[0])
+ aacraid_setup(aacraid);
dev->nondasd_support = 0;
dev->raid_scsi_mode = 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-31 9:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-30 21:42 [PATCH] aacraid: Add kernel command line parameter parsing Salyzyn, Mark
2007-01-31 9:55 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.