public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH/RFC 12/16] m68k: amiga - Serial port platform device conversion
Date: Sat, 18 Apr 2009 20:52:20 +0200	[thread overview]
Message-ID: <1240080744-14995-13-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1240080744-14995-12-git-send-email-geert@linux-m68k.org>

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/amiga/platform.c |    3 ++
 drivers/char/amiserial.c   |   61 +++++++++++++++++++++++++------------------
 2 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c
index 269bafc..52aa62d 100644
--- a/arch/m68k/amiga/platform.c
+++ b/arch/m68k/amiga/platform.c
@@ -168,6 +168,9 @@ static int __init amiga_init_devices(void)
 	if (AMIGAHW_PRESENT(AMI_MOUSE))
 		platform_device_register_simple("amiga-mouse", -1, NULL, 0);
 
+	if (AMIGAHW_PRESENT(AMI_SERIAL))
+		platform_device_register_simple("amiga-serial", -1, NULL, 0);
+
 	return 0;
 }
 
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index fd3ebd1..6826dd1 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -83,6 +83,7 @@ static char *serial_version = "4.30";
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/platform_device.h>
 
 #include <asm/setup.h>
 
@@ -1953,29 +1954,16 @@ static const struct tty_operations serial_ops = {
 /*
  * The serial driver boot-time initialization code!
  */
-static int __init rs_init(void)
+static int __init amiga_serial_probe(struct platform_device *pdev)
 {
 	unsigned long flags;
 	struct serial_state * state;
 	int error;
 
-	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL))
-		return -ENODEV;
-
 	serial_driver = alloc_tty_driver(1);
 	if (!serial_driver)
 		return -ENOMEM;
 
-	/*
-	 *  We request SERDAT and SERPER only, because the serial registers are
-	 *  too spreaded over the custom register space
-	 */
-	if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4,
-				"amiserial [Paula]")) {
-		error = -EBUSY;
-		goto fail_put_tty_driver;
-	}
-
 	IRQ_ports = NULL;
 
 	show_serial_version();
@@ -1997,7 +1985,7 @@ static int __init rs_init(void)
 
 	error = tty_register_driver(serial_driver);
 	if (error)
-		goto fail_release_mem_region;
+		goto fail_put_tty_driver;
 
 	state = rs_table;
 	state->magic = SSTATE_MAGIC;
@@ -2049,23 +2037,24 @@ static int __init rs_init(void)
 	ciab.ddra |= (SER_DTR | SER_RTS);   /* outputs */
 	ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR);  /* inputs */
 
+	platform_set_drvdata(pdev, state);
+
 	return 0;
 
 fail_free_irq:
 	free_irq(IRQ_AMIGA_TBE, state);
 fail_unregister:
 	tty_unregister_driver(serial_driver);
-fail_release_mem_region:
-	release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
 fail_put_tty_driver:
 	put_tty_driver(serial_driver);
 	return error;
 }
 
-static __exit void rs_exit(void) 
+static int __exit amiga_serial_remove(struct platform_device *pdev)
 {
 	int error;
-	struct async_struct *info = rs_table[0].info;
+	struct serial_state *state = platform_get_drvdata(pdev);
+	struct async_struct *info = state->info;
 
 	/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
 	tasklet_kill(&info->tlet);
@@ -2074,19 +2063,38 @@ static __exit void rs_exit(void)
 		       error);
 	put_tty_driver(serial_driver);
 
-	if (info) {
-	  rs_table[0].info = NULL;
-	  kfree(info);
-	}
+	rs_table[0].info = NULL;
+	kfree(info);
 
 	free_irq(IRQ_AMIGA_TBE, rs_table);
 	free_irq(IRQ_AMIGA_RBF, rs_table);
 
-	release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
+	platform_set_drvdata(pdev, NULL);
+
+	return error;
+}
+
+static struct platform_driver amiga_serial_driver = {
+	.remove = __exit_p(amiga_serial_remove),
+	.driver   = {
+		.name	= "amiga-serial",
+		.owner	= THIS_MODULE,
+	},
+};
+
+static int __init amiga_serial_init(void)
+{
+	return platform_driver_probe(&amiga_serial_driver, amiga_serial_probe);
+}
+
+module_init(amiga_serial_init);
+
+static void __exit amiga_serial_exit(void)
+{
+	platform_driver_unregister(&amiga_serial_driver);
 }
 
-module_init(rs_init)
-module_exit(rs_exit)
+module_exit(amiga_serial_exit);
 
 
 #if defined(CONFIG_SERIAL_CONSOLE) && !defined(MODULE)
@@ -2153,3 +2161,4 @@ console_initcall(amiserial_console_init);
 #endif /* CONFIG_SERIAL_CONSOLE && !MODULE */
 
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:amiga-serial");
-- 
1.6.2.3


  reply	other threads:[~2009-04-18 18:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-18 18:52 [PATCH/RFC 0/16] m68k: Device model patches Geert Uytterhoeven
2009-04-18 18:52 ` [PATCH/RFC 01/16] platform: Make platform resources input parameters const Geert Uytterhoeven
2009-04-18 18:52   ` [PATCH/RFC 02/16] m68k: amiga - Zorro bus modalias support Geert Uytterhoeven
2009-04-18 18:52     ` [PATCH/RFC 03/16] m68k: amiga - Zorro host bridge platform device conversion Geert Uytterhoeven
2009-04-18 18:52       ` [PATCH/RFC 04/16] m68k: amiga - Frame buffer " Geert Uytterhoeven
2009-04-18 18:52         ` [PATCH/RFC 05/16] m68k: amiga - Sound " Geert Uytterhoeven
2009-04-18 18:52           ` [PATCH/RFC 06/16] m68k: amiga - Floppy " Geert Uytterhoeven
2009-04-18 18:52             ` [PATCH/RFC 07/16] m68k: amiga - A3000 SCSI " Geert Uytterhoeven
2009-04-18 18:52               ` [PATCH/RFC 08/16] m68k: amiga - A4000T " Geert Uytterhoeven
2009-04-18 18:52                 ` [PATCH/RFC 09/16] m68k: amiga - Amiga Gayle IDE " Geert Uytterhoeven
2009-04-18 18:52                   ` [PATCH/RFC 10/16] m68k: amiga - Keyboard " Geert Uytterhoeven
2009-04-18 18:52                     ` [PATCH/RFC 11/16] m68k: amiga - Mouse " Geert Uytterhoeven
2009-04-18 18:52                       ` Geert Uytterhoeven [this message]
2009-04-18 18:52                         ` [PATCH/RFC 13/16] m68k: amiga - Parallel port " Geert Uytterhoeven
2009-04-18 18:52                           ` [PATCH/RFC 14/16] rtc: Add an RTC driver for the Oki MSM6242 Geert Uytterhoeven
2009-04-18 18:52                             ` [PATCH/RFC 15/16] rtc: Add an RTC driver for the Ricoh RP5C01 Geert Uytterhoeven
2009-04-18 18:52                               ` [PATCH/RFC 16/16] m68k: amiga - RTC platform device conversion Geert Uytterhoeven
2009-04-18 21:55                               ` [rtc-linux] [PATCH/RFC 15/16] rtc: Add an RTC driver for the Ricoh RP5C01 Alessandro Zummo
2009-04-19 18:41                                 ` Geert Uytterhoeven
2009-04-19 18:56                                   ` [rtc-linux] " Alessandro Zummo
2009-04-18 21:57                             ` [rtc-linux] [PATCH/RFC 14/16] rtc: Add an RTC driver for the Oki MSM6242 Alessandro Zummo
2009-04-18 23:25   ` [PATCH/RFC 01/16] platform: Make platform resources input parameters const Greg KH
2009-04-19 18:23     ` Geert Uytterhoeven
2009-05-05  7:36 ` [PATCH/RFC 0/16] m68k: Device model patches Geert Uytterhoeven

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=1240080744-14995-13-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@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