Commit 32ee9eec authored by Pavel Roskin's avatar Pavel Roskin Committed by Russell King

[PCMCIA] Conversion to module_param

Patch from: Pavel Roskin

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 safe.  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.
parent 3b322077
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/major.h> #include <linux/major.h>
...@@ -78,7 +79,7 @@ static const u_int exponent[] = { ...@@ -78,7 +79,7 @@ static const u_int exponent[] = {
/* Parameters that can be set with 'insmod' */ /* 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? */ INT_MODULE_PARM(cis_width, 0); /* 16-bit CIS? */
......
...@@ -94,7 +94,7 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); ...@@ -94,7 +94,7 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS); MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS);
MODULE_LICENSE("Dual MPL/GPL"); 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(setup_delay, 10); /* centiseconds */
INT_MODULE_PARM(resume_delay, 20); /* centiseconds */ INT_MODULE_PARM(resume_delay, 20); /* centiseconds */
......
...@@ -104,7 +104,8 @@ static int extra_sockets = 0; ...@@ -104,7 +104,8 @@ static int extra_sockets = 0;
static int ignore = -1; static int ignore = -1;
/* Bit map or list of interrupts to choose from */ /* Bit map or list of interrupts to choose from */
static u_int irq_mask = 0xffff; 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 */ /* The card status change interrupt -- 0 means autoselect */
static int cs_irq = 0; static int cs_irq = 0;
...@@ -130,27 +131,27 @@ static int async_clock = -1; ...@@ -130,27 +131,27 @@ static int async_clock = -1;
static int cable_mode = -1; static int cable_mode = -1;
static int wakeup = 0; static int wakeup = 0;
MODULE_PARM(i365_base, "i"); module_param(i365_base, int, 0444);
MODULE_PARM(ignore, "i"); module_param(ignore, int, 0444);
MODULE_PARM(extra_sockets, "i"); module_param(extra_sockets, int, 0444);
MODULE_PARM(irq_mask, "i"); module_param(irq_mask, int, 0444);
MODULE_PARM(irq_list, "1-16i"); module_param_array(irq_list, int, irq_list_count, 0444);
MODULE_PARM(cs_irq, "i"); module_param(cs_irq, int, 0444);
MODULE_PARM(async_clock, "i"); module_param(async_clock, int, 0444);
MODULE_PARM(cable_mode, "i"); module_param(cable_mode, int, 0444);
MODULE_PARM(wakeup, "i"); module_param(wakeup, int, 0444);
MODULE_PARM(do_scan, "i"); module_param(do_scan, int, 0444);
MODULE_PARM(poll_interval, "i"); module_param(poll_interval, int, 0444);
MODULE_PARM(cycle_time, "i"); module_param(cycle_time, int, 0444);
MODULE_PARM(has_dma, "i"); module_param(has_dma, int, 0444);
MODULE_PARM(has_led, "i"); module_param(has_led, int, 0444);
MODULE_PARM(has_ring, "i"); module_param(has_ring, int, 0444);
MODULE_PARM(dynamic_mode, "i"); module_param(dynamic_mode, int, 0444);
MODULE_PARM(freq_bypass, "i"); module_param(freq_bypass, int, 0444);
MODULE_PARM(setup_time, "i"); module_param(setup_time, int, 0444);
MODULE_PARM(cmd_time, "i"); module_param(cmd_time, int, 0444);
MODULE_PARM(recov_time, "i"); module_param(recov_time, int, 0444);
/*====================================================================*/ /*====================================================================*/
...@@ -705,10 +706,10 @@ static void __init add_pcic(int ns, int type) ...@@ -705,10 +706,10 @@ static void __init add_pcic(int ns, int type)
printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : ""));
/* Set host options, build basic interrupt mask */ /* Set host options, build basic interrupt mask */
if (irq_list[0] == -1) if (irq_list_count == 0)
mask = irq_mask; mask = irq_mask;
else else
for (i = mask = 0; i < 16; i++) for (i = mask = 0; i < irq_list_count; i++)
mask |= (1<<irq_list[i]); mask |= (1<<irq_list[i]);
mask &= I365_MASK & set_bridge_opts(base, ns); mask &= I365_MASK & set_bridge_opts(base, ns);
/* Scan for ISA interrupts */ /* Scan for ISA interrupts */
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
/* Parameters that can be set with 'insmod' */ /* 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? */ INT_MODULE_PARM(probe_mem, 1); /* memory probe? */
#ifdef CONFIG_PCMCIA_PROBE #ifdef CONFIG_PCMCIA_PROBE
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
static int pc_debug; static int pc_debug;
module_param(pc_debug, int, 0644); module_param(pc_debug, int, 0644);
MODULE_PARM(pc_debug, "i");
static const char *version = static const char *version =
"tcic.c 1.111 2000/02/15 04:13:12 (David Hinds)"; "tcic.c 1.111 2000/02/15 04:13:12 (David Hinds)";
...@@ -91,7 +90,8 @@ static int do_scan = 1; ...@@ -91,7 +90,8 @@ static int do_scan = 1;
/* Bit map of interrupts to choose from */ /* Bit map of interrupts to choose from */
static u_int irq_mask = 0xffff; 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 */ /* The card status change interrupt -- 0 means autoselect */
static int cs_irq; static int cs_irq;
...@@ -105,15 +105,15 @@ static int poll_quick = HZ/20; ...@@ -105,15 +105,15 @@ static int poll_quick = HZ/20;
/* CCLK external clock time, in nanoseconds. 70 ns = 14.31818 MHz */ /* CCLK external clock time, in nanoseconds. 70 ns = 14.31818 MHz */
static int cycle_time = 70; static int cycle_time = 70;
MODULE_PARM(tcic_base, "i"); module_param(tcic_base, int, 0444);
MODULE_PARM(ignore, "i"); module_param(ignore, int, 0444);
MODULE_PARM(do_scan, "i"); module_param(do_scan, int, 0444);
MODULE_PARM(irq_mask, "i"); module_param(irq_mask, int, 0444);
MODULE_PARM(irq_list, "1-16i"); module_param_array(irq_list, int, irq_list_count, 0444);
MODULE_PARM(cs_irq, "i"); module_param(cs_irq, int, 0444);
MODULE_PARM(poll_interval, "i"); module_param(poll_interval, int, 0444);
MODULE_PARM(poll_quick, "i"); module_param(poll_quick, int, 0444);
MODULE_PARM(cycle_time, "i"); module_param(cycle_time, int, 0444);
/*====================================================================*/ /*====================================================================*/
...@@ -481,10 +481,10 @@ static int __init init_tcic(void) ...@@ -481,10 +481,10 @@ static int __init init_tcic(void)
/* Build interrupt mask */ /* Build interrupt mask */
printk(", %d sockets\n" KERN_INFO " irq list (", sockets); printk(", %d sockets\n" KERN_INFO " irq list (", sockets);
if (irq_list[0] == -1) if (irq_list_count == 0)
mask = irq_mask; mask = irq_mask;
else else
for (i = mask = 0; i < 16; i++) for (i = mask = 0; i < irq_list_count; i++)
mask |= (1<<irq_list[i]); mask |= (1<<irq_list[i]);
/* irq 14, 11, 10, 7, 6, 5, 4, 3 */ /* irq 14, 11, 10, 7, 6, 5, 4, 3 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment