linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard Röjfors" <richard.rojfors@mocean-labs.com>
To: linux-serial@vger.kernel.org
Cc: alan@lxorguk.ukuu.org.uk, Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH RESEND] timbuart: Support for beeing probed more than once
Date: Tue, 22 Sep 2009 14:25:31 +0200	[thread overview]
Message-ID: <4AB8C23B.3020309@mocean-labs.com> (raw)

There was a problem in the current implementation where a global static
uart_driver struct was used. The same struct was reused every time the
driver got probed. Since the struct has a state within the serial core
it can not be reused.

A uart_driver struct is added to the timbuart_port struct which is
allocated per platform device.

The probe and remove functions are declared __devinit and __devexit.

Signed-off-by: Richard Röjfors <richard.rojfors@mocean-labs.com>
---
diff --git a/drivers/serial/timbuart.c b/drivers/serial/timbuart.c
index 063a313..75a741b 100644
--- a/drivers/serial/timbuart.c
+++ b/drivers/serial/timbuart.c
@@ -31,6 +31,7 @@

 struct timbuart_port {
 	struct uart_port	port;
+	struct uart_driver	uart_driver;
 	struct tasklet_struct	tasklet;
 	int			usedma;
 	u32			last_ier;
@@ -410,7 +411,7 @@ static struct uart_ops timbuart_ops = {
 	.verify_port = timbuart_verify_port
 };

-static struct uart_driver timbuart_driver = {
+static const __devinitconst struct uart_driver timbuart_driver_template = {
 	.owner = THIS_MODULE,
 	.driver_name = "timberdale_uart",
 	.dev_name = "ttyTU",
@@ -419,7 +420,7 @@ static struct uart_driver timbuart_driver = {
 	.nr = 1
 };

-static int timbuart_probe(struct platform_device *dev)
+static int __devinit timbuart_probe(struct platform_device *dev)
 {
 	int err;
 	struct timbuart_port *uart;
@@ -433,6 +434,8 @@ static int timbuart_probe(struct platform_device *dev)
 		goto err_mem;
 	}

+	uart->uart_driver = timbuart_driver_template;
+
 	uart->usedma = 0;

 	uart->port.uartclk = 3250000 * 16;
@@ -461,11 +464,11 @@ static int timbuart_probe(struct platform_device *dev)

 	tasklet_init(&uart->tasklet, timbuart_tasklet, (unsigned long)uart);

-	err = uart_register_driver(&timbuart_driver);
+	err = uart_register_driver(&uart->uart_driver);
 	if (err)
 		goto err_register;

-	err = uart_add_one_port(&timbuart_driver, &uart->port);
+	err = uart_add_one_port(&uart->uart_driver, &uart->port);
 	if (err)
 		goto err_add_port;

@@ -474,7 +477,7 @@ static int timbuart_probe(struct platform_device *dev)
 	return 0;

 err_add_port:
-	uart_unregister_driver(&timbuart_driver);
+	uart_unregister_driver(&uart->uart_driver);
 err_register:
 	kfree(uart);
 err_mem:
@@ -484,13 +487,13 @@ err_mem:
 	return err;
 }

-static int timbuart_remove(struct platform_device *dev)
+static int __devexit timbuart_remove(struct platform_device *dev)
 {
 	struct timbuart_port *uart = platform_get_drvdata(dev);

 	tasklet_kill(&uart->tasklet);
-	uart_remove_one_port(&timbuart_driver, &uart->port);
-	uart_unregister_driver(&timbuart_driver);
+	uart_remove_one_port(&uart->uart_driver, &uart->port);
+	uart_unregister_driver(&uart->uart_driver);
 	kfree(uart);

 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2009-09-22 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-22 12:25 Richard Röjfors [this message]
2009-09-29 23:20 ` [PATCH RESEND] timbuart: Support for beeing probed more than once Andrew Morton
2009-09-30  7:56   ` Richard Röjfors

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=4AB8C23B.3020309@mocean-labs.com \
    --to=richard.rojfors@mocean-labs.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-serial@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).