From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Linux kernel mailing list <linux-kernel@vger.kernel.org>,
Rusty Russell <rusty@rustcorp.com.au>,
Jeff Garzik <jgarzik@pobox.com>
Subject: [PATCH] : More module parameter compatibility for 2.5.52
Date: Mon, 16 Dec 2002 17:26:46 -0800 [thread overview]
Message-ID: <20021217012646.GA18021@bougret.hpl.hp.com> (raw)
Hi,
I've just downloaded 2.5.52 to try the new module parameter
support. Unfortunately, the letter 'c' was not implemented, and I need
it. This is used in few drivers (such as hp100, wavelan, wlan_cs...).
I've only checked that with this patch my hp100 cards load
fine, but I didn't test the various corner cases.
Have fun...
Jean
---------------------------------------------------------------
diff -u -p linux/include/linux/moduleparam.r1.h linux/include/linux/moduleparam.h
--- linux/include/linux/moduleparam.r1.h Mon Dec 16 16:19:59 2002
+++ linux/include/linux/moduleparam.h Mon Dec 16 16:23:55 2002
@@ -25,6 +25,7 @@ struct kernel_param {
param_set_fn set;
param_get_fn get;
void *arg;
+ void *priv;
};
/* Special one for strings we want to copy into */
diff -u -p linux/kernel/module.r1.c linux/kernel/module.c
--- linux/kernel/module.r1.c Mon Dec 16 16:08:42 2002
+++ linux/kernel/module.c Mon Dec 16 16:39:00 2002
@@ -569,9 +569,41 @@ static int param_string(const char *name
return 0;
}
+/* Do char array. This probably should be made available in the new stuff.
+ * Note : driver has already allocated the char array and tell us the
+ * size. The array is in fact two dimensional.
+ * Quick'n'dirty hack by Jean II */
+int param_set_chara(const char *val, struct kernel_param *kp)
+{
+ int maxchar = (int) kp->priv;
+
+ if (!val) {
+ printk(KERN_ERR "%s: char array parameter expected\n",
+ kp->name);
+ return -EINVAL;
+ }
+
+ /* Let's be on the safe side with respect to nul-termination
+ * and always set strings with a nul. */
+ if ((strlen(val) + 1) > maxchar) {
+ printk(KERN_ERR "%s: char array parameter too long\n",
+ kp->name);
+ return -ENOSPC;
+ }
+
+ strcpy((char *)kp->arg, (char *) val);
+ return 0;
+}
+
+int param_get_chara(char *buffer, struct kernel_param *kp)
+{
+ /* We may want to check the array size ? */
+ return sprintf(buffer, "%s", ((char *)kp->arg));
+}
+
extern int set_obsolete(const char *val, struct kernel_param *kp)
{
- unsigned int min, max;
+ unsigned int min, max, line;
char *p, *endp;
struct obsolete_modparm *obsparm = kp->arg;
@@ -581,6 +613,7 @@ extern int set_obsolete(const char *val,
}
/* type is: [min[-max]]{b,h,i,l,s} */
+ /* or [min[-max]]{c}line for 2d array of chars - Jean II */
p = obsparm->type;
min = simple_strtol(p, &endp, 10);
if (endp == obsparm->type)
@@ -605,6 +638,13 @@ extern int set_obsolete(const char *val,
sizeof(long), param_set_long);
case 's':
return param_string(kp->name, val, min, max, obsparm->addr);
+ case 'c':
+ p = endp+1;
+ line = simple_strtol(p, &endp, 10);
+ /* Maybe we should check that line doesn't get absurdly big */
+ kp->priv = (void *) line;
+ return param_array(kp->name, val, min, max, obsparm->addr,
+ line, param_set_chara);
}
printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type);
return -EINVAL;
next reply other threads:[~2002-12-17 1:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-17 1:26 Jean Tourrilhes [this message]
2002-12-17 3:02 ` Jean Tourrilhes
2002-12-17 4:20 ` Rusty Russell
2002-12-17 17:33 ` Jean Tourrilhes
2002-12-18 2:24 ` Rusty Russell
2002-12-18 2:29 ` Jean Tourrilhes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021217012646.GA18021@bougret.hpl.hp.com \
--to=jt@bougret.hpl.hp.com \
--cc=jgarzik@pobox.com \
--cc=jt@hpl.hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®