Skip to contentSkip to conversation

char, moxa: Make isabrds variable global.

PATCH In review Rakib Mullick 2 participants 6 messages Nov 3, 2009 – Nov 10, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char, moxa: Make isabrds variable global.

When CONFIG_MODULE=n and CONFIG_PCI=n, then variable
isabrds becomes unused variable. So place it outside moxa_init solves this problem.

We were warned by the following warning:

drivers/char/moxa.c: In function `moxa_init':
drivers/char/moxa.c:1012: warning: unused variable `isabrds'

----

drivers/char/moxa.c +2 -1
@@ -1007,9 +1007,10 @@ static struct pci_driver moxa_pci_driver
 };
 #endif /* CONFIG_PCI */
 
+static unsigned int __initdata isabrds;
+
 static int __init moxa_init(void)
 {
-	unsigned int isabrds = 0;
 	int retval = 0;
 
 	printk(KERN_INFO "MOXA Intellio family driver version %s\n",
#1 lore raw
Quoted 8 lines · Rakib Mullick

When CONFIG_MODULE=n and CONFIG_PCI=n, then variable isabrds becomes unused variable. So place it outside moxa_init solves this problem.

We were warned by the following warning:

drivers/char/moxa.c: In function `moxa_init':
drivers/char/moxa.c:1012: warning: unused variable `isabrds'

Hi Andrew, after applying this one, it introduce a new warning:

drivers/char/moxa.c:1010: warning: 'isabrds' defined but not used

And while compiling moxa.c we are also warned by the following warnings:

drivers/char/moxa.c:81: warning: 'moxa_brdname' defined but not used drivers/char/moxa.c:818: warning: 'moxa_init_board' defined but not used

To fix this warnings we need to properly #ifdef above functions. So after applying the following patch - moxa.c compiles cleanly.

Would you mind check this out, Andrew?

Fix compilation warning when CONFIG_PCI=n.

----

drivers/char/moxa.c +6 -1
@@ -78,6 +78,7 @@ enum {
 	MOXA_BOARD_CP204J,
 };
 
+#if defined MODULE || defined CONFIG_PCI
 static char *moxa_brdname[] =
 {
 	"C218 Turbo PCI series",
@@ -87,6 +88,9 @@ static char *moxa_brdname[] =
 	"CP-204J series",
 };
 
+static unsigned int __initdata isabrds;
+#endif
+
 #ifdef CONFIG_PCI
 static struct pci_device_id moxa_pcibrds[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218),
@@ -419,6 +423,7 @@ static DEFINE_SPINLOCK(moxa_lock);
  * HW init
  */
 
+#if defined MODULE || defined CONFIG_PCI
 static int moxa_check_fw_model(struct moxa_board_conf *brd, u8 model)
 {
 	switch (brd->boardType) {
@@ -878,6 +883,7 @@ err_free:
 err:
 	return ret;
 }
+#endif
 
 static void moxa_board_deinit(struct moxa_board_conf *brd)
 {
@@ -1009,7 +1015,6 @@ static struct pci_driver moxa_pci_driver
 
 static int __init moxa_init(void)
 {
-	unsigned int isabrds = 0;
 	int retval = 0;
 
 	printk(KERN_INFO "MOXA Intellio family driver version %s\n",
#2 lore raw
Quoted 11 lines · Rakib Mullick
Quoted 8 lines · Rakib Mullick

When CONFIG_MODULE=n and CONFIG_PCI=n, then variable isabrds becomes unused variable. So place it outside moxa_init solves this problem.

We were warned by the following warning:

drivers/char/moxa.c: In function `moxa_init':
drivers/char/moxa.c:1012: warning: unused variable `isabrds'

Hi Andrew, after applying this one, it introduce a new warning:

Sorry I had no time to look into the first patch. And it makes no sense. The driver is unusable on !MODULE && !PCI. So better fix is to disallow whole build on such configurations. Care to fix that?

#3 lore raw
Quoted 5 lines · Jiri Slaby

Sorry I had no time to look into the first patch. And it makes no sense.
The driver is unusable on !MODULE && !PCI. So better fix is to disallow whole build on such configurations. Care to fix that?

Hi Jiri, thanks for your care. Would you please checkout the patch below? Is it okay?

moxa: Disallow moxa build when !MODULE && !PCI.
If MODULES support is not enabled then MODULE=y is not possible.

-----

drivers/char/Kconfig +2 -2
@@ -216,7 +216,7 @@ config ESPSERIAL
 
 config MOXA_INTELLIO
 	tristate "Moxa Intellio support"
-	depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
+	depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) || MODULES
 	select FW_LOADER
 	help
 	  Say Y here if you have a Moxa Intellio multiport serial card.
@@ -226,7 +226,7 @@ config MOXA_INTELLIO
 
 config MOXA_SMARTIO
 	tristate "Moxa SmartIO support v. 2.0"
-	depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
+	depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) || MODULES
 	help
 	  Say Y here if you have a Moxa SmartIO multiport serial card and/or
 	  want to help develop a new version of this driver.
#4 lore raw
Quoted 8 lines · Rakib Mullick
Quoted 5 lines · Jiri Slaby

Sorry I had no time to look into the first patch. And it makes no sense.
The driver is unusable on !MODULE && !PCI. So better fix is to disallow whole build on such configurations. Care to fix that?

Hi Jiri, thanks for your care. Would you please checkout the patch below? Is it okay?

Actually I'm idiot. I forgot, that today people can just pass "module parameters" on the kernel cmdline even on !MODULE in the KBUILD_MODNAME.param manner. So no, a better fix is to remove !MODULE ifdefs completely.

Sorry for the confusion.

#5 lore raw
Quoted 6 lines · Jiri Slaby

Actually I'm idiot. I forgot, that today people can just pass "module
parameters" on the kernel cmdline even on !MODULE in the KBUILD_MODNAME.param manner. So no, a better fix is to remove !MODULE ifdefs completely.

Sorry for the confusion.

Okay, hope this will be right. Checkout the following patch.

moxa: Remove #ifdef MODULE completely.

We can pass "module parameters" on the kernel command
line even when !MODULE. So, #ifdef MODULE becomes obsolete. Also move the declaration moxa_board_conf at the start of the function, since we were hit by the following warning.

drivers/char/moxa.c: In function `moxa_init':
drivers/char/moxa.c:1040: warning: ISO C90 forbids mixed declarations and code

---

drivers/char/moxa.c +6 -11
@@ -165,24 +165,22 @@ static struct mon_str moxaLog;
 static unsigned int moxaFuncTout = HZ / 2;
 static unsigned int moxaLowWaterChk;
 static DEFINE_MUTEX(moxa_openlock);
-/* Variables for insmod */
-#ifdef MODULE
+
 static unsigned long baseaddr[MAX_BOARDS];
 static unsigned int type[MAX_BOARDS];
 static unsigned int numports[MAX_BOARDS];
-#endif
 
 MODULE_AUTHOR("William Chen");
 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
 MODULE_LICENSE("GPL");
-#ifdef MODULE
+
 module_param_array(type, uint, NULL, 0);
 MODULE_PARM_DESC(type, "card type: C218=2, C320=4");
 module_param_array(baseaddr, ulong, NULL, 0);
 MODULE_PARM_DESC(baseaddr, "base address");
 module_param_array(numports, uint, NULL, 0);
 MODULE_PARM_DESC(numports, "numports (ignored for C218)");
-#endif
+
 module_param(ttymajor, int, 0);
 
 /*
@@ -1011,6 +1009,8 @@ static int __init moxa_init(void)
 {
 	unsigned int isabrds = 0;
 	int retval = 0;
+	struct moxa_board_conf *brd = moxa_boards;
+	unsigned int i;
 
 	printk(KERN_INFO "MOXA Intellio family driver version %s\n",
 			MOXA_VERSION);
@@ -1038,10 +1038,7 @@ static int __init moxa_init(void)
 	}
 
 	/* Find the boards defined from module args. */
-#ifdef MODULE
-	{
-	struct moxa_board_conf *brd = moxa_boards;
-	unsigned int i;
+
 	for (i = 0; i < MAX_BOARDS; i++) {
 		if (!baseaddr[i])
 			break;
@@ -1074,8 +1071,6 @@ static int __init moxa_init(void)
 			isabrds++;
 		}
 	}
-	}
-#endif
 
 #ifdef CONFIG_PCI
 	retval = pci_register_driver(&moxa_pci_driver);