Re: [PATCH] [OOPS] apbuart.c: Two problems related togrlib_apbuart_configure()

From: Miguel Ojeda
Date: Tue May 11 2010 - 09:38:23 EST


Hi,

Kristoffer, please check this one instead.

Changes:
1. Added the grlib_apbuart_port_nr = 0 line.
2. Returned -ENODEV instead of 0 in the "no ports found branch" in
init(), because if compiled as a module, exit() will try to unregister
things that were not registered. In addition, this will alert the users
that modprobe'd.
3. Deleted the unused __FILE__ argument of the previous patch (oops
sorry :).

Andrew, if Kristoffer agrees, please drop the older patch from -mm and
merge this one instead.

Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx>
---
--- drivers/serial/apbuart.c.orig 2010-04-26 16:48:30.000000000 +0200
+++ drivers/serial/apbuart.c 2010-05-11 15:21:28.984666230 +0200
@@ -525,6 +525,9 @@ static void grlib_apbuart_configure(void
static int __init apbuart_console_init(void)
{
grlib_apbuart_configure();
+ if (grlib_apbuart_port_nr == 0)
+ return 0;
+
register_console(&grlib_apbuart_console);
return 0;
}
@@ -612,6 +615,10 @@ static void grlib_apbuart_configure(void
rp = of_find_node_by_path("/");
rp = of_get_next_child(rp, NULL);
prop = of_get_property(rp, "clock-frequency", NULL);
+ if (prop == NULL) {
+ grlib_apbuart_port_nr = 0;
+ return;
+ }
freq_khz = *prop;

line = 0;
@@ -666,6 +673,10 @@ static int __init grlib_apbuart_init(voi

/* Find all APBUARTS in device the tree and initialize their ports */
grlib_apbuart_configure();
+ if (grlib_apbuart_port_nr == 0) {
+ printk(KERN_INFO "Serial: GRLIB APBUART: No ports found.\n");
+ return -ENODEV;
+ }

printk(KERN_INFO "Serial: GRLIB APBUART driver\n");


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/