[PATCH 1/2] pmac-zilog: add platform driver

Geert Uytterhoeven geert at linux-m68k.org
Fri Jan 8 08:12:12 EST 2010


On Tue, Nov 17, 2009 at 10:04, Finn Thain <fthain at telegraphics.com.au> wrote:
> Add platform driver to the pmac-zilog driver for mac 68k, putting the
> powermac-specific bits inside #ifdef CONFIG_PPC_PMAC.

> --- linux-2.6.31.orig/drivers/serial/pmac_zilog.c       2009-11-17 17:07:28.000000000 +1100
> +++ linux-2.6.31/drivers/serial/pmac_zilog.c    2009-11-17 17:07:38.000000000 +1100

> +static int pmz_attach(struct platform_device *pdev)

__devinit (or __init, see platform_driver_probe() below)

BTW, the same is true for the PowerMac version.

> +{
> +       int i;
> +
> +       for (i = 0; i < pmz_ports_count; i++)
> +               if (pmz_ports[i].node == pdev)
> +                       return 0;
> +       return -ENODEV;
> +}
> +
> +static int pmz_detach(struct platform_device *pdev)

__devexit (or __exit, see platform_driver_probe() below)

Idem ditto for PowerMac.

> +{
> +       return 0;
> +}
> +
> +#endif /* !CONFIG_PPC_PMAC */

> +static struct platform_driver pmz_driver = {
> +       .probe          = pmz_attach,
> +       .remove         = __devexit_p(pmz_detach),
> +       .driver         = {
> +               .name           = "scc",
> +               .owner          = THIS_MODULE,
> +       },
> +};
> +
> +#endif /* !CONFIG_PPC_PMAC */
> +
>  static int __init init_pmz(void)
>  {
>        int rc, i;
> @@ -1942,15 +2053,23 @@ static int __init init_pmz(void)
>        /*
>         * Then we register the macio driver itself
>         */
> +#ifdef CONFIG_PPC_PMAC
>        return macio_register_driver(&pmz_driver);
> +#else
> +       return platform_driver_register(&pmz_driver);

Since this device is not hot-pluggable, you could use
platform_driver_probe() instead (and leave pmz_driver.probe() empty).

> --- linux-2.6.31.orig/drivers/serial/pmac_zilog.h       2009-11-17 17:07:28.000000000 +1100
> +++ linux-2.6.31/drivers/serial/pmac_zilog.h    2009-11-17 17:07:38.000000000 +1100
> @@ -1,7 +1,15 @@
>  #ifndef __PMAC_ZILOG_H__
>  #define __PMAC_ZILOG_H__
>
> +#ifdef CONFIG_PPC_PMAC
>  #define pmz_debug(fmt, arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg)
> +#define pmz_error(fmt, arg...) dev_err(&uap->dev->ofdev.dev, fmt, ## arg)
> +#define pmz_info(fmt, arg...)  dev_info(&uap->dev->ofdev.dev, fmt, ## arg)
> +#else
> +#define pmz_debug(fmt, arg...) do { } while (0)
> +#define pmz_error(fmt, arg...) printk(KERN_ERR fmt, ## arg)
> +#define pmz_info(fmt, arg...)  printk(KERN_INFO fmt, ## arg)

Any chance you can sneak the platform device in and use dev_*()?

Anyway, I'm gonna take it, and feed it upstream if BenH adds his ack. Ben?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


More information about the Linuxppc-dev mailing list