All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	kristoffer@gaisler.com, Andrew Morton <akpm@linux-foundation.org>,
	davem@davemloft.net, Anton Vorontsov <avorontsov@ru.mvista.com>
Subject: Re: [alternative-merged] serial-apbuartc-fix-two-problems-related-to-grlib_apbuart_configure.patch removed from -mm tree
Date: Thu, 20 May 2010 21:52:36 +0200	[thread overview]
Message-ID: <1274385156.9756.4.camel@carter> (raw)
In-Reply-To: <1273355935.13191.6.camel@carter>

Hi,

I found two problems using the Simics' sunfire target. It occurs as well on real machines.

1. At grlib_apbuart_configure() in apbuart.c, prop can be NULL if
"clock-frequency" doesn't exist in the OF tree:

       /* Get bus frequency */
       rp = of_find_node_by_path("/");
       rp = of_get_next_child(rp, NULL);
       prop = of_get_property(rp, "clock-frequency", NULL);
       freq_khz = *prop;

2. In addition, apbuart.c does not check if there aren't any ports
configured after calls to grlib_apbuart_configure(), so other oops will
occur if no port was configured (e.g. uart_set_options() because of
port->ops).

In order to solve that, I added a check after both of the calls to
grlib_apbuart_configure().

The patch that I provide below prevents both problems in the Simics'
sunfire target. In addition, it warns the users if no ports were found.

Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Acked-by: Kristoffer Glembo <kristoffer@gaisler.com>
---
--- 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");
 



  parent reply	other threads:[~2010-05-20 19:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-08 21:58 [PATCH] [OOPS] apbuart.c: Two problems related to grlib_apbuart_configure() Miguel Ojeda
2010-05-10 13:20 ` Miguel Ojeda
2010-05-11  7:11   ` Kristoffer Glembo
2010-05-11 13:38 ` Miguel Ojeda
2010-05-11 13:42   ` Kristoffer Glembo
2010-05-20 19:52 ` Miguel Ojeda [this message]
2010-05-20 20:09   ` [alternative-merged] serial-apbuartc-fix-two-problems-related-to-grlib_apbuart_configure.patch removed from -mm tree Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2010-05-19 14:16 akpm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274385156.9756.4.camel@carter \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=avorontsov@ru.mvista.com \
    --cc=davem@davemloft.net \
    --cc=greg@kroah.com \
    --cc=kristoffer@gaisler.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.