2009-11-03 04:29:13

by Rakib Mullick

[permalink] [raw]
Subject: [PATCH -mm] 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'

Signed-off-by: Rakib Mullick <[email protected]>
----

--- linus/drivers/char/moxa.c 2009-09-11 20:39:02.000000000 +0600
+++ rakib/drivers/char/moxa.c 2009-11-03 10:57:44.000000000 +0600
@@ -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",


2009-11-07 05:08:32

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH -mm] char, moxa: Make isabrds variable global.

On 11/3/09, Rakib Mullick <[email protected]> wrote:
> 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.

Signed-off-by: Rakib Mullick <[email protected]>
----

--- linus/drivers/char/moxa.c 2009-11-06 17:12:13.000000000 +0600
+++ rakib/drivers/char/moxa.c 2009-11-06 17:47:18.000000000 +0600
@@ -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",

2009-11-07 10:26:45

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH -mm] char, moxa: Make isabrds variable global.

On 11/07/2009 06:08 AM, Rakib Mullick wrote:
> On 11/3/09, Rakib Mullick <[email protected]> wrote:
>> 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?

2009-11-09 02:06:43

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH -mm] char, moxa: Make isabrds variable global.

On 11/7/09, Jiri Slaby <[email protected]> wrote:
>
> 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.

Signed-off-by: Rakib Mullick <[email protected]>
-----

--- linus/drivers/char/Kconfig 2009-11-06 13:45:42.000000000 +0600
+++ rakib/drivers/char/Kconfig 2009-11-08 21:31:48.000000000 +0600
@@ -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.

2009-11-09 08:20:44

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH -mm] char, moxa: Make isabrds variable global.

On 11/09/2009 03:06 AM, Rakib Mullick wrote:
> On 11/7/09, Jiri Slaby <[email protected]> wrote:
>>
>> 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.

2009-11-10 17:42:24

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH -mm] char, moxa: Make isabrds variable global.

On 11/9/09, Jiri Slaby <[email protected]> wrote:
> 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

Signed-off-by: Rakib Mullick<[email protected]>
---

--- linus/drivers/char/moxa.c 2009-11-10 23:30:13.000000000 +0600
+++ rakib/drivers/char/moxa.c 2009-11-11 00:37:55.000000000 +0600
@@ -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);