[PATCH] small hp_sdc_rtc cleanup: use no_llseek
[powerpc.git] / drivers / serial / mpc52xx_uart.c
index 0585ab2..1288d62 100644 (file)
  * by the bootloader or in the platform init code.
  *
  * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2,
- * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so
- * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for
- * the console code : without this 1:1 mapping, at early boot time, when we are
- * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be
- * mapped to.
+ * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
+ * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
+ * fpr the console code : without this 1:1 mapping, at early boot time, when we
+ * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it
+ * will be mapped to.
  */
 
 #include <linux/config.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/module.h>
 #include <linux/tty.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 
 
+/* We've been assigned a range on the "Low-density serial ports" major */
+#define SERIAL_PSC_MAJOR       204
+#define SERIAL_PSC_MINOR       148
+
 
 #define ISR_PASS_LIMIT 256     /* Max number of iteration in the interrupt */
 
@@ -668,15 +672,15 @@ mpc52xx_console_setup(struct console *co, char *options)
 }
 
 
-extern struct uart_driver mpc52xx_uart_driver;
+static struct uart_driver mpc52xx_uart_driver;
 
 static struct console mpc52xx_console = {
-       .name   = "ttyS",
+       .name   = "ttyPSC",
        .write  = mpc52xx_console_write,
        .device = uart_console_device,
        .setup  = mpc52xx_console_setup,
        .flags  = CON_PRINTBUFFER,
-       .index  = -1,   /* Specified on the cmdline (e.g. console=ttyS0 ) */
+       .index  = -1,   /* Specified on the cmdline (e.g. console=ttyPSC0 ) */
        .data   = &mpc52xx_uart_driver,
 };
 
@@ -703,10 +707,10 @@ console_initcall(mpc52xx_console_init);
 static struct uart_driver mpc52xx_uart_driver = {
        .owner          = THIS_MODULE,
        .driver_name    = "mpc52xx_psc_uart",
-       .dev_name       = "ttyS",
-       .devfs_name     = "ttyS",
-       .major          = TTY_MAJOR,
-       .minor          = 64,
+       .dev_name       = "ttyPSC",
+       .devfs_name     = "ttyPSC",
+       .major          = SERIAL_PSC_MAJOR,
+       .minor          = SERIAL_PSC_MINOR,
        .nr             = MPC52xx_PSC_MAXNUM,
        .cons           = MPC52xx_PSC_CONSOLE,
 };
@@ -717,16 +721,15 @@ static struct uart_driver mpc52xx_uart_driver = {
 /* ======================================================================== */
 
 static int __devinit
-mpc52xx_uart_probe(struct device *dev)
+mpc52xx_uart_probe(struct platform_device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct resource *res = pdev->resource;
+       struct resource *res = dev->resource;
 
        struct uart_port *port = NULL;
        int i, idx, ret;
 
        /* Check validity & presence */
-       idx = pdev->id;
+       idx = dev->id;
        if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM)
                return -EINVAL;
 
@@ -749,7 +752,7 @@ mpc52xx_uart_probe(struct device *dev)
        port->ops       = &mpc52xx_uart_ops;
 
        /* Search for IRQ and mapbase */
-       for (i=0 ; i<pdev->num_resources ; i++, res++) {
+       for (i=0 ; i<dev->num_resources ; i++, res++) {
                if (res->flags & IORESOURCE_MEM)
                        port->mapbase = res->start;
                else if (res->flags & IORESOURCE_IRQ)
@@ -761,17 +764,17 @@ mpc52xx_uart_probe(struct device *dev)
        /* Add the port to the uart sub-system */
        ret = uart_add_one_port(&mpc52xx_uart_driver, port);
        if (!ret)
-               dev_set_drvdata(dev, (void*)port);
+               platform_set_drvdata(dev, (void*)port);
 
        return ret;
 }
 
 static int
-mpc52xx_uart_remove(struct device *dev)
+mpc52xx_uart_remove(struct platform_device *dev)
 {
-       struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
+       struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
 
-       dev_set_drvdata(dev, NULL);
+       platform_set_drvdata(dev, NULL);
 
        if (port)
                uart_remove_one_port(&mpc52xx_uart_driver, port);
@@ -781,37 +784,38 @@ mpc52xx_uart_remove(struct device *dev)
 
 #ifdef CONFIG_PM
 static int
-mpc52xx_uart_suspend(struct device *dev, pm_message_t state, u32 level)
+mpc52xx_uart_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
+       struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
 
-       if (sport && level == SUSPEND_DISABLE)
+       if (sport)
                uart_suspend_port(&mpc52xx_uart_driver, port);
 
        return 0;
 }
 
 static int
-mpc52xx_uart_resume(struct device *dev, u32 level)
+mpc52xx_uart_resume(struct platform_device *dev)
 {
-       struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
+       struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
 
-       if (port && level == RESUME_ENABLE)
+       if (port)
                uart_resume_port(&mpc52xx_uart_driver, port);
 
        return 0;
 }
 #endif
 
-static struct device_driver mpc52xx_uart_platform_driver = {
-       .name           = "mpc52xx-psc",
-       .bus            = &platform_bus_type,
+static struct platform_driver mpc52xx_uart_platform_driver = {
        .probe          = mpc52xx_uart_probe,
        .remove         = mpc52xx_uart_remove,
 #ifdef CONFIG_PM
        .suspend        = mpc52xx_uart_suspend,
        .resume         = mpc52xx_uart_resume,
 #endif
+       .driver         = {
+               .name   = "mpc52xx-psc",
+       },
 };
 
 
@@ -828,7 +832,7 @@ mpc52xx_uart_init(void)
 
        ret = uart_register_driver(&mpc52xx_uart_driver);
        if (ret == 0) {
-               ret = driver_register(&mpc52xx_uart_platform_driver);
+               ret = platform_driver_register(&mpc52xx_uart_platform_driver);
                if (ret)
                        uart_unregister_driver(&mpc52xx_uart_driver);
        }
@@ -839,7 +843,7 @@ mpc52xx_uart_init(void)
 static void __exit
 mpc52xx_uart_exit(void)
 {
-       driver_unregister(&mpc52xx_uart_platform_driver);
+       platform_driver_unregister(&mpc52xx_uart_platform_driver);
        uart_unregister_driver(&mpc52xx_uart_driver);
 }