[PATCH] Conversion to module_param
Pavel Roskin
proski at gnu.org
Fri Apr 16 20:50:30 BST 2004
Hello!
As it turns out, mixing MODULE_PARM and module_param in one module is
wrong. The parameters specified in module_param are ignored. I've just
posted a patch to LKML that will detect this condition and warn about it.
The new debugging code used the new-style module_param, which means that
all instances of MODULE_PARM should be converted. The attached patch does
that.
An additional bonus is that module_param_array provides the number of
array elements. This allowed me to change tcic.c and i82365.c to use
this number for IRQ list. This change was tested with i82365. If
"irq_list" is not specified, irq_list_count is 0.
I set all permissions to 0444 to be save. I think we have no secrets
from the users regarding those parameters. If some parameters can be
changed safely at the runtime, the permissions could be changed to 0644.
I didn't examine how safe (and how useful) it would be, so it's 0444 for
now.
--
Regards,
Pavel Roskin
-------------- next part --------------
--- linux.orig/drivers/pcmcia/cistpl.c
+++ linux/drivers/pcmcia/cistpl.c
@@ -33,6 +33,7 @@
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/major.h>
@@ -78,7 +79,7 @@ static const u_int exponent[] = {
/* Parameters that can be set with 'insmod' */
-#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
+#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
INT_MODULE_PARM(cis_width, 0); /* 16-bit CIS? */
--- linux.orig/drivers/pcmcia/cs.c
+++ linux/drivers/pcmcia/cs.c
@@ -94,7 +94,7 @@ MODULE_AUTHOR("David Hinds <dahinds at user
MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS);
MODULE_LICENSE("Dual MPL/GPL");
-#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
+#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
INT_MODULE_PARM(setup_delay, 10); /* centiseconds */
INT_MODULE_PARM(resume_delay, 20); /* centiseconds */
--- linux.orig/drivers/pcmcia/i82365.c
+++ linux/drivers/pcmcia/i82365.c
@@ -104,7 +104,8 @@ static int extra_sockets = 0;
static int ignore = -1;
/* Bit map or list of interrupts to choose from */
static u_int irq_mask = 0xffff;
-static int irq_list[16] = { -1 };
+static int irq_list[16];
+static int irq_list_count;
/* The card status change interrupt -- 0 means autoselect */
static int cs_irq = 0;
@@ -130,27 +131,27 @@ static int async_clock = -1;
static int cable_mode = -1;
static int wakeup = 0;
-MODULE_PARM(i365_base, "i");
-MODULE_PARM(ignore, "i");
-MODULE_PARM(extra_sockets, "i");
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-16i");
-MODULE_PARM(cs_irq, "i");
-MODULE_PARM(async_clock, "i");
-MODULE_PARM(cable_mode, "i");
-MODULE_PARM(wakeup, "i");
-
-MODULE_PARM(do_scan, "i");
-MODULE_PARM(poll_interval, "i");
-MODULE_PARM(cycle_time, "i");
-MODULE_PARM(has_dma, "i");
-MODULE_PARM(has_led, "i");
-MODULE_PARM(has_ring, "i");
-MODULE_PARM(dynamic_mode, "i");
-MODULE_PARM(freq_bypass, "i");
-MODULE_PARM(setup_time, "i");
-MODULE_PARM(cmd_time, "i");
-MODULE_PARM(recov_time, "i");
+module_param(i365_base, int, 0444);
+module_param(ignore, int, 0444);
+module_param(extra_sockets, int, 0444);
+module_param(irq_mask, int, 0444);
+module_param_array(irq_list, int, irq_list_count, 0444);
+module_param(cs_irq, int, 0444);
+module_param(async_clock, int, 0444);
+module_param(cable_mode, int, 0444);
+module_param(wakeup, int, 0444);
+
+module_param(do_scan, int, 0444);
+module_param(poll_interval, int, 0444);
+module_param(cycle_time, int, 0444);
+module_param(has_dma, int, 0444);
+module_param(has_led, int, 0444);
+module_param(has_ring, int, 0444);
+module_param(dynamic_mode, int, 0444);
+module_param(freq_bypass, int, 0444);
+module_param(setup_time, int, 0444);
+module_param(cmd_time, int, 0444);
+module_param(recov_time, int, 0444);
/*====================================================================*/
@@ -705,10 +706,10 @@ static void __init add_pcic(int ns, int
printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : ""));
/* Set host options, build basic interrupt mask */
- if (irq_list[0] == -1)
+ if (irq_list_count == 0)
mask = irq_mask;
else
- for (i = mask = 0; i < 16; i++)
+ for (i = mask = 0; i < irq_list_count; i++)
mask |= (1<<irq_list[i]);
mask &= I365_MASK & set_bridge_opts(base, ns);
/* Scan for ISA interrupts */
--- linux.orig/drivers/pcmcia/rsrc_mgr.c
+++ linux/drivers/pcmcia/rsrc_mgr.c
@@ -33,6 +33,7 @@
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
@@ -56,7 +57,7 @@
/* Parameters that can be set with 'insmod' */
-#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
+#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
INT_MODULE_PARM(probe_mem, 1); /* memory probe? */
#ifdef CONFIG_PCMCIA_PROBE
--- linux.orig/drivers/pcmcia/tcic.c
+++ linux/drivers/pcmcia/tcic.c
@@ -60,7 +60,6 @@
static int pc_debug;
module_param(pc_debug, int, 0644);
-MODULE_PARM(pc_debug, "i");
static const char *version =
"tcic.c 1.111 2000/02/15 04:13:12 (David Hinds)";
@@ -91,7 +90,8 @@ static int do_scan = 1;
/* Bit map of interrupts to choose from */
static u_int irq_mask = 0xffff;
-static int irq_list[16] = { -1 };
+static int irq_list[16];
+static int irq_list_count;
/* The card status change interrupt -- 0 means autoselect */
static int cs_irq;
@@ -105,15 +105,15 @@ static int poll_quick = HZ/20;
/* CCLK external clock time, in nanoseconds. 70 ns = 14.31818 MHz */
static int cycle_time = 70;
-MODULE_PARM(tcic_base, "i");
-MODULE_PARM(ignore, "i");
-MODULE_PARM(do_scan, "i");
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-16i");
-MODULE_PARM(cs_irq, "i");
-MODULE_PARM(poll_interval, "i");
-MODULE_PARM(poll_quick, "i");
-MODULE_PARM(cycle_time, "i");
+module_param(tcic_base, int, 0444);
+module_param(ignore, int, 0444);
+module_param(do_scan, int, 0444);
+module_param(irq_mask, int, 0444);
+module_param_array(irq_list, int, irq_list_count, 0444);
+module_param(cs_irq, int, 0444);
+module_param(poll_interval, int, 0444);
+module_param(poll_quick, int, 0444);
+module_param(cycle_time, int, 0444);
/*====================================================================*/
@@ -481,10 +481,10 @@ static int __init init_tcic(void)
/* Build interrupt mask */
printk(", %d sockets\n" KERN_INFO " irq list (", sockets);
- if (irq_list[0] == -1)
+ if (irq_list_count == 0)
mask = irq_mask;
else
- for (i = mask = 0; i < 16; i++)
+ for (i = mask = 0; i < irq_list_count; i++)
mask |= (1<<irq_list[i]);
/* irq 14, 11, 10, 7, 6, 5, 4, 3 */
More information about the linux-pcmcia
mailing list