drivercore: Add helper macro for platform_driver boilerplate
authorGrant Likely <grant.likely@secretlab.ca>
Wed, 5 Oct 2011 17:29:49 +0000 (11:29 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Mon, 24 Oct 2011 22:35:47 +0000 (00:35 +0200)
For simple modules that contain a single platform_driver without any
additional setup code then ends up being a block of duplicated
boilerplate.  This patch adds a new macro, module_platform_driver(),
which replaces the module_init()/module_exit() registrations with
template functions.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Reviewed-by: Magnus Damm <magnus.damm@gmail.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
27 files changed:
drivers/spi/spi-altera.c
drivers/spi/spi-ath79.c
drivers/spi/spi-atmel.c
drivers/spi/spi-bfin-sport.c
drivers/spi/spi-coldfire-qspi.c
drivers/spi/spi-davinci.c
drivers/spi/spi-dw-mmio.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-fsl-espi.c
drivers/spi/spi-gpio.c
drivers/spi/spi-imx.c
drivers/spi/spi-mpc512x-psc.c
drivers/spi/spi-mpc52xx-psc.c
drivers/spi/spi-mpc52xx.c
drivers/spi/spi-nuc900.c
drivers/spi/spi-oc-tiny.c
drivers/spi/spi-ppc4xx.c
drivers/spi/spi-s3c24xx.c
drivers/spi/spi-sh-msiof.c
drivers/spi/spi-sh-sci.c
drivers/spi/spi-sh.c
drivers/spi/spi-stmp.c
drivers/spi/spi-tegra.c
drivers/spi/spi-ti-ssp.c
drivers/spi/spi-xilinx.c
drivers/tty/serial/of_serial.c
include/linux/platform_device.h

index 4813a63ce6fbe9b05a6c52c5274239831f84ed0d..881c1967741d396502caa94194a6aae4ac6a91c3 100644 (file)
@@ -320,18 +320,7 @@ static struct platform_driver altera_spi_driver = {
                .of_match_table = altera_spi_match,
        },
 };
-
-static int __init altera_spi_init(void)
-{
-       return platform_driver_register(&altera_spi_driver);
-}
-module_init(altera_spi_init);
-
-static void __exit altera_spi_exit(void)
-{
-       platform_driver_unregister(&altera_spi_driver);
-}
-module_exit(altera_spi_exit);
+module_platform_driver(altera_spi_driver);
 
 MODULE_DESCRIPTION("Altera SPI driver");
 MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>");
index 03019bf5a5e907b36ba4c1512c04b9ec15a4da09..024b48aed5ca6bba6f32857965e8904fe012ca1b 100644 (file)
@@ -273,18 +273,7 @@ static struct platform_driver ath79_spi_driver = {
                .owner  = THIS_MODULE,
        },
 };
-
-static __init int ath79_spi_init(void)
-{
-       return platform_driver_register(&ath79_spi_driver);
-}
-module_init(ath79_spi_init);
-
-static __exit void ath79_spi_exit(void)
-{
-       platform_driver_unregister(&ath79_spi_driver);
-}
-module_exit(ath79_spi_exit);
+module_platform_driver(ath79_spi_driver);
 
 MODULE_DESCRIPTION("SPI controller driver for Atheros AR71XX/AR724X/AR913X");
 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
index 82dee9a6c0de5a7761c95820697963938bbfb3fe..a356392ab2f6bd9d537c4459c83d66ed2794447d 100644 (file)
@@ -1074,18 +1074,7 @@ static struct platform_driver atmel_spi_driver = {
        .resume         = atmel_spi_resume,
        .remove         = __exit_p(atmel_spi_remove),
 };
-
-static int __init atmel_spi_init(void)
-{
-       return platform_driver_probe(&atmel_spi_driver, atmel_spi_probe);
-}
-module_init(atmel_spi_init);
-
-static void __exit atmel_spi_exit(void)
-{
-       platform_driver_unregister(&atmel_spi_driver);
-}
-module_exit(atmel_spi_exit);
+module_platform_driver(atmel_spi_driver);
 
 MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver");
 MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
index e557ff617b11658547fdea3cdbb352f4485492ca..248a2cc671a9bc8e6c6a83c5b515557f432c7841 100644 (file)
@@ -938,15 +938,4 @@ static struct platform_driver bfin_sport_spi_driver = {
        .suspend = bfin_sport_spi_suspend,
        .resume  = bfin_sport_spi_resume,
 };
-
-static int __init bfin_sport_spi_init(void)
-{
-       return platform_driver_register(&bfin_sport_spi_driver);
-}
-module_init(bfin_sport_spi_init);
-
-static void __exit bfin_sport_spi_exit(void)
-{
-       platform_driver_unregister(&bfin_sport_spi_driver);
-}
-module_exit(bfin_sport_spi_exit);
+module_platform_driver(bfin_sport_spi_driver);
index 7397c4d5700731a6863615d6972714920c4782ed..6eee64a5d240d882647d15a2e80f2e547dda91f4 100644 (file)
@@ -621,20 +621,10 @@ static struct platform_driver mcfqspi_driver = {
        .driver.name    = DRIVER_NAME,
        .driver.owner   = THIS_MODULE,
        .driver.pm      = MCFQSPI_DEV_PM_OPS,
+       .probe          = mcfqspi_probe,
        .remove         = __devexit_p(mcfqspi_remove),
 };
-
-static int __init mcfqspi_init(void)
-{
-       return platform_driver_probe(&mcfqspi_driver, mcfqspi_probe);
-}
-module_init(mcfqspi_init);
-
-static void __exit mcfqspi_exit(void)
-{
-       platform_driver_unregister(&mcfqspi_driver);
-}
-module_exit(mcfqspi_exit);
+module_platform_driver(mcfqspi_driver);
 
 MODULE_AUTHOR("Steven King <sfking@fdwdc.com>");
 MODULE_DESCRIPTION("Coldfire QSPI Controller Driver");
index 1f0ed8005c9170f3462d80a5e79e000c2ecc88ff..31bfba805cf473e51edbeb437a72666f9b735595 100644 (file)
@@ -799,7 +799,7 @@ rx_dma_failed:
  * It will invoke spi_bitbang_start to create work queue so that client driver
  * can register transfer method to work queue.
  */
-static int davinci_spi_probe(struct platform_device *pdev)
+static int __devinit davinci_spi_probe(struct platform_device *pdev)
 {
        struct spi_master *master;
        struct davinci_spi *dspi;
@@ -984,7 +984,7 @@ err:
  * It will also call spi_bitbang_stop to destroy the work queue which was
  * created by spi_bitbang_start.
  */
-static int __exit davinci_spi_remove(struct platform_device *pdev)
+static int __devexit davinci_spi_remove(struct platform_device *pdev)
 {
        struct davinci_spi *dspi;
        struct spi_master *master;
@@ -1011,20 +1011,10 @@ static struct platform_driver davinci_spi_driver = {
                .name = "spi_davinci",
                .owner = THIS_MODULE,
        },
-       .remove = __exit_p(davinci_spi_remove),
+       .probe = davinci_spi_probe,
+       .remove = __devexit_p(davinci_spi_remove),
 };
-
-static int __init davinci_spi_init(void)
-{
-       return platform_driver_probe(&davinci_spi_driver, davinci_spi_probe);
-}
-module_init(davinci_spi_init);
-
-static void __exit davinci_spi_exit(void)
-{
-       platform_driver_unregister(&davinci_spi_driver);
-}
-module_exit(davinci_spi_exit);
+module_platform_driver(davinci_spi_driver);
 
 MODULE_DESCRIPTION("TI DaVinci SPI Master Controller Driver");
 MODULE_LICENSE("GPL");
index 34eb66501dbf1ad081710cf2346e10e93dc6e66c..fac399c3022cd4a1045ac09f962309d9e9c63d23 100644 (file)
@@ -127,24 +127,14 @@ static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver dw_spi_mmio_driver = {
+       .probe          = dw_spi_mmio_probe,
        .remove         = __devexit_p(dw_spi_mmio_remove),
        .driver         = {
                .name   = DRIVER_NAME,
                .owner  = THIS_MODULE,
        },
 };
-
-static int __init dw_spi_mmio_init(void)
-{
-       return platform_driver_probe(&dw_spi_mmio_driver, dw_spi_mmio_probe);
-}
-module_init(dw_spi_mmio_init);
-
-static void __exit dw_spi_mmio_exit(void)
-{
-       platform_driver_unregister(&dw_spi_mmio_driver);
-}
-module_exit(dw_spi_mmio_exit);
+module_platform_driver(dw_spi_mmio_driver);
 
 MODULE_AUTHOR("Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>");
 MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core");
index 11515c5531dfd1e1a879217186d173322e9e8476..0a282e5fcc9c3fe4931a871acd6d89708162bd0d 100644 (file)
@@ -1026,7 +1026,7 @@ static void ep93xx_spi_release_dma(struct ep93xx_spi *espi)
                free_page((unsigned long)espi->zeropage);
 }
 
-static int __init ep93xx_spi_probe(struct platform_device *pdev)
+static int __devinit ep93xx_spi_probe(struct platform_device *pdev)
 {
        struct spi_master *master;
        struct ep93xx_spi_info *info;
@@ -1151,7 +1151,7 @@ fail_release_master:
        return error;
 }
 
-static int __exit ep93xx_spi_remove(struct platform_device *pdev)
+static int __devexit ep93xx_spi_remove(struct platform_device *pdev)
 {
        struct spi_master *master = platform_get_drvdata(pdev);
        struct ep93xx_spi *espi = spi_master_get_devdata(master);
@@ -1197,20 +1197,10 @@ static struct platform_driver ep93xx_spi_driver = {
                .name   = "ep93xx-spi",
                .owner  = THIS_MODULE,
        },
-       .remove         = __exit_p(ep93xx_spi_remove),
+       .probe          = ep93xx_spi_probe,
+       .remove         = __devexit_p(ep93xx_spi_remove),
 };
-
-static int __init ep93xx_spi_init(void)
-{
-       return platform_driver_probe(&ep93xx_spi_driver, ep93xx_spi_probe);
-}
-module_init(ep93xx_spi_init);
-
-static void __exit ep93xx_spi_exit(void)
-{
-       platform_driver_unregister(&ep93xx_spi_driver);
-}
-module_exit(ep93xx_spi_exit);
+module_platform_driver(ep93xx_spi_driver);
 
 MODULE_DESCRIPTION("EP93xx SPI Controller driver");
 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>");
index 54e499d5f92cb043d805517db43983def2d52b01..d770f03705c32b86a661dfc0a83d7997b7bfda1c 100644 (file)
@@ -744,18 +744,7 @@ static struct platform_driver fsl_espi_driver = {
        .probe          = of_fsl_espi_probe,
        .remove         = __devexit_p(of_fsl_espi_remove),
 };
-
-static int __init fsl_espi_init(void)
-{
-       return platform_driver_register(&fsl_espi_driver);
-}
-module_init(fsl_espi_init);
-
-static void __exit fsl_espi_exit(void)
-{
-       platform_driver_unregister(&fsl_espi_driver);
-}
-module_exit(fsl_espi_exit);
+module_platform_driver(fsl_espi_driver);
 
 MODULE_AUTHOR("Mingkai Hu");
 MODULE_DESCRIPTION("Enhanced Freescale SPI Driver");
index 0e88ab7454906ddb5dce94997dc51e84965559ea..635ff08b377f999c5f46ca21603272c97f60e277 100644 (file)
@@ -311,7 +311,7 @@ done:
        return value;
 }
 
-static int __init spi_gpio_probe(struct platform_device *pdev)
+static int __devinit spi_gpio_probe(struct platform_device *pdev)
 {
        int                             status;
        struct spi_master               *master;
@@ -379,7 +379,7 @@ gpio_free:
        return status;
 }
 
-static int __exit spi_gpio_remove(struct platform_device *pdev)
+static int __devexit spi_gpio_remove(struct platform_device *pdev)
 {
        struct spi_gpio                 *spi_gpio;
        struct spi_gpio_platform_data   *pdata;
@@ -408,21 +408,10 @@ MODULE_ALIAS("platform:" DRIVER_NAME);
 static struct platform_driver spi_gpio_driver = {
        .driver.name    = DRIVER_NAME,
        .driver.owner   = THIS_MODULE,
-       .remove         = __exit_p(spi_gpio_remove),
+       .probe          = spi_gpio_probe,
+       .remove         = __devexit_p(spi_gpio_remove),
 };
-
-static int __init spi_gpio_init(void)
-{
-       return platform_driver_probe(&spi_gpio_driver, spi_gpio_probe);
-}
-module_init(spi_gpio_init);
-
-static void __exit spi_gpio_exit(void)
-{
-       platform_driver_unregister(&spi_gpio_driver);
-}
-module_exit(spi_gpio_exit);
-
+module_platform_driver(spi_gpio_driver);
 
 MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO ");
 MODULE_AUTHOR("David Brownell");
index fa594d604acae4501986125e5ca25f6e2b8e3c22..c6e697f5e007a7642db7e30e6025160bf783ded9 100644 (file)
@@ -929,19 +929,7 @@ static struct platform_driver spi_imx_driver = {
        .probe = spi_imx_probe,
        .remove = __devexit_p(spi_imx_remove),
 };
-
-static int __init spi_imx_init(void)
-{
-       return platform_driver_register(&spi_imx_driver);
-}
-
-static void __exit spi_imx_exit(void)
-{
-       platform_driver_unregister(&spi_imx_driver);
-}
-
-module_init(spi_imx_init);
-module_exit(spi_imx_exit);
+module_platform_driver(spi_imx_driver);
 
 MODULE_DESCRIPTION("SPI Master Controller driver");
 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
index 6a5b4238fb6bd2dd43a0743371ed0550996f5333..4c63f772780adaf64e1412af167c791123eecb13 100644 (file)
@@ -559,18 +559,7 @@ static struct platform_driver mpc512x_psc_spi_of_driver = {
                .of_match_table = mpc512x_psc_spi_of_match,
        },
 };
-
-static int __init mpc512x_psc_spi_init(void)
-{
-       return platform_driver_register(&mpc512x_psc_spi_of_driver);
-}
-module_init(mpc512x_psc_spi_init);
-
-static void __exit mpc512x_psc_spi_exit(void)
-{
-       platform_driver_unregister(&mpc512x_psc_spi_of_driver);
-}
-module_exit(mpc512x_psc_spi_exit);
+module_platform_driver(mpc512x_psc_spi_of_driver);
 
 MODULE_AUTHOR("John Rigby");
 MODULE_DESCRIPTION("MPC512x PSC SPI Driver");
index e30baf0852ac78bf338fd31b7869896169649d37..66047156d90dbc8d1bd9980492050629ad1f40d1 100644 (file)
@@ -511,18 +511,7 @@ static struct platform_driver mpc52xx_psc_spi_of_driver = {
                .of_match_table = mpc52xx_psc_spi_of_match,
        },
 };
-
-static int __init mpc52xx_psc_spi_init(void)
-{
-       return platform_driver_register(&mpc52xx_psc_spi_of_driver);
-}
-module_init(mpc52xx_psc_spi_init);
-
-static void __exit mpc52xx_psc_spi_exit(void)
-{
-       platform_driver_unregister(&mpc52xx_psc_spi_of_driver);
-}
-module_exit(mpc52xx_psc_spi_exit);
+module_platform_driver(mpc52xx_psc_spi_of_driver);
 
 MODULE_AUTHOR("Dragos Carp");
 MODULE_DESCRIPTION("MPC52xx PSC SPI Driver");
index 015a974bed72d83b40d15407597c84749490ba66..57633d9634565682b8d89cfb66644e623c66ced8 100644 (file)
@@ -564,16 +564,4 @@ static struct platform_driver mpc52xx_spi_of_driver = {
        .probe = mpc52xx_spi_probe,
        .remove = __devexit_p(mpc52xx_spi_remove),
 };
-
-static int __init mpc52xx_spi_init(void)
-{
-       return platform_driver_register(&mpc52xx_spi_of_driver);
-}
-module_init(mpc52xx_spi_init);
-
-static void __exit mpc52xx_spi_exit(void)
-{
-       platform_driver_unregister(&mpc52xx_spi_of_driver);
-}
-module_exit(mpc52xx_spi_exit);
-
+module_platform_driver(mpc52xx_spi_of_driver);
index c0a6ce81f9c0e4ba42246395f5f60ec712f0075a..e763254741c296169b6d662d5f398c1a90170cc2 100644 (file)
@@ -484,19 +484,7 @@ static struct platform_driver nuc900_spi_driver = {
                .owner  = THIS_MODULE,
        },
 };
-
-static int __init nuc900_spi_init(void)
-{
-       return platform_driver_register(&nuc900_spi_driver);
-}
-
-static void __exit nuc900_spi_exit(void)
-{
-       platform_driver_unregister(&nuc900_spi_driver);
-}
-
-module_init(nuc900_spi_init);
-module_exit(nuc900_spi_exit);
+module_platform_driver(nuc900_spi_driver);
 
 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
 MODULE_DESCRIPTION("nuc900 spi driver!");
index f1bde66cea1940efefd812df590c415a46dd1c40..897274e8715c1913413d96b483f4fdc4f70553bf 100644 (file)
@@ -406,18 +406,7 @@ static struct platform_driver tiny_spi_driver = {
                .of_match_table = tiny_spi_match,
        },
 };
-
-static int __init tiny_spi_init(void)
-{
-       return platform_driver_register(&tiny_spi_driver);
-}
-module_init(tiny_spi_init);
-
-static void __exit tiny_spi_exit(void)
-{
-       platform_driver_unregister(&tiny_spi_driver);
-}
-module_exit(tiny_spi_exit);
+module_platform_driver(tiny_spi_driver);
 
 MODULE_DESCRIPTION("OpenCores tiny SPI driver");
 MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>");
index 8ec43e07aa1e44ce2b735b92b7769baac1ec3c8b..98ec53285fc7b03781160ec6da6c222e03821946 100644 (file)
@@ -594,18 +594,7 @@ static struct platform_driver spi_ppc4xx_of_driver = {
                .of_match_table = spi_ppc4xx_of_match,
        },
 };
-
-static int __init spi_ppc4xx_init(void)
-{
-       return platform_driver_register(&spi_ppc4xx_of_driver);
-}
-module_init(spi_ppc4xx_init);
-
-static void __exit spi_ppc4xx_exit(void)
-{
-       platform_driver_unregister(&spi_ppc4xx_of_driver);
-}
-module_exit(spi_ppc4xx_exit);
+module_platform_driver(spi_ppc4xx_of_driver);
 
 MODULE_AUTHOR("Gary Jennejohn & Stefan Roese");
 MODULE_DESCRIPTION("Simple PPC4xx SPI Driver");
index 1996ac57ef919186341a6c65d6a8ea89569825ef..b857a3e7af949138d136872339d17231bc7830dc 100644 (file)
@@ -505,7 +505,7 @@ static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw)
        }
 }
 
-static int __init s3c24xx_spi_probe(struct platform_device *pdev)
+static int __devinit s3c24xx_spi_probe(struct platform_device *pdev)
 {
        struct s3c2410_spi_info *pdata;
        struct s3c24xx_spi *hw;
@@ -661,7 +661,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
        return err;
 }
 
-static int __exit s3c24xx_spi_remove(struct platform_device *dev)
+static int __devexit s3c24xx_spi_remove(struct platform_device *dev)
 {
        struct s3c24xx_spi *hw = platform_get_drvdata(dev);
 
@@ -719,26 +719,15 @@ static const struct dev_pm_ops s3c24xx_spi_pmops = {
 
 MODULE_ALIAS("platform:s3c2410-spi");
 static struct platform_driver s3c24xx_spi_driver = {
-       .remove         = __exit_p(s3c24xx_spi_remove),
+       .probe          = s3c24xx_spi_probe,
+       .remove         = __devexit_p(s3c24xx_spi_remove),
        .driver         = {
                .name   = "s3c2410-spi",
                .owner  = THIS_MODULE,
                .pm     = S3C24XX_SPI_PMOPS,
        },
 };
-
-static int __init s3c24xx_spi_init(void)
-{
-        return platform_driver_probe(&s3c24xx_spi_driver, s3c24xx_spi_probe);
-}
-
-static void __exit s3c24xx_spi_exit(void)
-{
-        platform_driver_unregister(&s3c24xx_spi_driver);
-}
-
-module_init(s3c24xx_spi_init);
-module_exit(s3c24xx_spi_exit);
+module_platform_driver(s3c24xx_spi_driver);
 
 MODULE_DESCRIPTION("S3C24XX SPI Driver");
 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
index e38554f892568e9317de5572364f7e4c637157b4..0f4834ae28cdea08f0ff995708001a2a2c67cf56 100644 (file)
@@ -730,18 +730,7 @@ static struct platform_driver sh_msiof_spi_drv = {
                .pm             = &sh_msiof_spi_dev_pm_ops,
        },
 };
-
-static int __init sh_msiof_spi_init(void)
-{
-       return platform_driver_register(&sh_msiof_spi_drv);
-}
-module_init(sh_msiof_spi_init);
-
-static void __exit sh_msiof_spi_exit(void)
-{
-       platform_driver_unregister(&sh_msiof_spi_drv);
-}
-module_exit(sh_msiof_spi_exit);
+module_platform_driver(sh_msiof_spi_drv);
 
 MODULE_DESCRIPTION("SuperH MSIOF SPI Master Interface Driver");
 MODULE_AUTHOR("Magnus Damm");
index e7779c09f6efb0e5564dd2a4cf0880b93ac17bd3..8844bc3427824209808519db50eb94fdaccb4b8d 100644 (file)
@@ -186,18 +186,7 @@ static struct platform_driver sh_sci_spi_drv = {
                .owner  = THIS_MODULE,
        },
 };
-
-static int __init sh_sci_spi_init(void)
-{
-       return platform_driver_register(&sh_sci_spi_drv);
-}
-module_init(sh_sci_spi_init);
-
-static void __exit sh_sci_spi_exit(void)
-{
-       platform_driver_unregister(&sh_sci_spi_drv);
-}
-module_exit(sh_sci_spi_exit);
+module_platform_driver(sh_sci_spi_drv);
 
 MODULE_DESCRIPTION("SH SCI SPI Driver");
 MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
index e0343d48da6cafe2b089491adb5d952497f74e47..70c8af9f7cccbc7ad9c01d9202f2b34af7b976ed 100644 (file)
@@ -524,18 +524,7 @@ static struct platform_driver spi_sh_driver = {
                .owner = THIS_MODULE,
        },
 };
-
-static int __init spi_sh_init(void)
-{
-       return platform_driver_register(&spi_sh_driver);
-}
-module_init(spi_sh_init);
-
-static void __exit spi_sh_exit(void)
-{
-       platform_driver_unregister(&spi_sh_driver);
-}
-module_exit(spi_sh_exit);
+module_platform_driver(spi_sh_driver);
 
 MODULE_DESCRIPTION("SH SPI bus driver");
 MODULE_LICENSE("GPL");
index fadff76eb7e06807e5171dc074b5416db02d032b..58e38528532393f89c0b8688469ad3af8a982b21 100644 (file)
@@ -659,19 +659,8 @@ static struct platform_driver stmp_spi_driver = {
        .suspend = stmp_spi_suspend,
        .resume  = stmp_spi_resume,
 };
+module_platform_driver(stmp_spi_driver);
 
-static int __init stmp_spi_init(void)
-{
-       return platform_driver_register(&stmp_spi_driver);
-}
-
-static void __exit stmp_spi_exit(void)
-{
-       platform_driver_unregister(&stmp_spi_driver);
-}
-
-module_init(stmp_spi_init);
-module_exit(stmp_spi_exit);
 module_param(pio, int, S_IRUGO);
 module_param(clock, int, S_IRUGO);
 MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com>");
index e8cd58f63e229b66fab1f52a919c39f1640f51f0..ae6d78a3e9129a483ecf60ee5919dc4a685b3235 100644 (file)
@@ -465,7 +465,7 @@ static int spi_tegra_transfer(struct spi_device *spi, struct spi_message *m)
        return 0;
 }
 
-static int __init spi_tegra_probe(struct platform_device *pdev)
+static int __devinit spi_tegra_probe(struct platform_device *pdev)
 {
        struct spi_master       *master;
        struct spi_tegra_data   *tspi;
@@ -613,19 +613,9 @@ static struct platform_driver spi_tegra_driver = {
                .owner =        THIS_MODULE,
                .of_match_table = spi_tegra_of_match_table,
        },
+       .probe =        spi_tegra_probe,
        .remove =       __devexit_p(spi_tegra_remove),
 };
-
-static int __init spi_tegra_init(void)
-{
-       return platform_driver_probe(&spi_tegra_driver, spi_tegra_probe);
-}
-module_init(spi_tegra_init);
-
-static void __exit spi_tegra_exit(void)
-{
-       platform_driver_unregister(&spi_tegra_driver);
-}
-module_exit(spi_tegra_exit);
+module_platform_driver(spi_tegra_driver);
 
 MODULE_LICENSE("GPL");
index ee22795c7973fdf250a94f50b215afc8419bcb0c..7963c60063d6843bae1aea0d63dea4d7d80f13d0 100644 (file)
@@ -383,18 +383,7 @@ static struct platform_driver ti_ssp_spi_driver = {
                .owner  = THIS_MODULE,
        },
 };
-
-static int __init ti_ssp_spi_init(void)
-{
-       return platform_driver_register(&ti_ssp_spi_driver);
-}
-module_init(ti_ssp_spi_init);
-
-static void __exit ti_ssp_spi_exit(void)
-{
-       platform_driver_unregister(&ti_ssp_spi_driver);
-}
-module_exit(ti_ssp_spi_exit);
+module_platform_driver(ti_ssp_spi_driver);
 
 MODULE_DESCRIPTION("SSP SPI Master");
 MODULE_AUTHOR("Cyril Chemparathy");
index 4d2c75df886c88621e43a453db625e59e7876ccf..4c5a663b9fa897e4a510f6cf6dbba084efc6bfb6 100644 (file)
@@ -538,18 +538,7 @@ static struct platform_driver xilinx_spi_driver = {
                .of_match_table = xilinx_spi_of_match,
        },
 };
-
-static int __init xilinx_spi_pltfm_init(void)
-{
-       return platform_driver_register(&xilinx_spi_driver);
-}
-module_init(xilinx_spi_pltfm_init);
-
-static void __exit xilinx_spi_pltfm_exit(void)
-{
-       platform_driver_unregister(&xilinx_spi_driver);
-}
-module_exit(xilinx_spi_pltfm_exit);
+module_platform_driver(xilinx_spi_driver);
 
 MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
 MODULE_DESCRIPTION("Xilinx SPI driver");
index e58cece6f443a6bb8d48ababf6a74e4846c63557..e8c9cee07d00e2b7e9b4dfeb3a5119475d21eacc 100644 (file)
@@ -200,17 +200,7 @@ static struct platform_driver of_platform_serial_driver = {
        .remove = of_platform_serial_remove,
 };
 
-static int __init of_platform_serial_init(void)
-{
-       return platform_driver_register(&of_platform_serial_driver);
-}
-module_init(of_platform_serial_init);
-
-static void __exit of_platform_serial_exit(void)
-{
-       return platform_driver_unregister(&of_platform_serial_driver);
-};
-module_exit(of_platform_serial_exit);
+module_platform_driver(of_platform_serial_driver);
 
 MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
 MODULE_LICENSE("GPL");
index 27bb05aae70d48eea4b151522d204e4e00b014e8..08de528afd6603d6cdb1888102c83b14ef19966d 100644 (file)
@@ -146,6 +146,23 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data
        dev_set_drvdata(&pdev->dev, data);
 }
 
+/* module_platform_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit()
+ */
+#define module_platform_driver(__platform_driver) \
+static int __init __platform_driver##_init(void) \
+{ \
+       return platform_driver_register(&(__platform_driver)); \
+} \
+module_init(__platform_driver##_init); \
+static void __exit __platform_driver##_exit(void) \
+{ \
+       platform_driver_unregister(&(__platform_driver)); \
+} \
+module_exit(__platform_driver##_exit);
+
 extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
                                        int (*probe)(struct platform_device *),
                                        struct resource *res, unsigned int n_res,