]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
SPI driver runtime footprint shrinkage
authorDavid Brownell <david-b@pacbell.net>
Tue, 16 Oct 2007 08:27:46 +0000 (01:27 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 16 Oct 2007 16:43:09 +0000 (09:43 -0700)
Shrink the runtime footprint of various SPI drivers:

  - Move the probe() routine into the init section where practical,
    using platform_driver_probe() to make that safe.  This often saves
    around 1KB.  Using platform_driver_probe() can also be a correctness
    fix, if the probe routine is already marked __init but the driver
    struct keeps a dangling pointer to it after init section removal.

  - Likewise move remove() routines into the exit sections.

These changes would be inappropriate iff the platform devices were
actually hotpluggable (e.g. they're found on optional addon cards,
or in an FPGA that's dynamically reprogrammed).  In these cases,
that's not the situation; it's an SOC controller and the only device
is initialized before these drivers.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/spi/omap_uwire.c
drivers/spi/pxa2xx_spi.c
drivers/spi/spi_imx.c
drivers/spi/spi_mpc83xx.c
drivers/spi/spi_s3c24xx.c

index d275c615a73ecb7a516689595c9c9c8dca322062..8245b5153f30957e9e12d705b25ced31b03fbed5 100644 (file)
@@ -481,7 +481,7 @@ static void uwire_off(struct uwire_spi *uwire)
        spi_master_put(uwire->bitbang.master);
 }
 
-static int uwire_probe(struct platform_device *pdev)
+static int __init uwire_probe(struct platform_device *pdev)
 {
        struct spi_master       *master;
        struct uwire_spi        *uwire;
@@ -525,7 +525,7 @@ static int uwire_probe(struct platform_device *pdev)
        return status;
 }
 
-static int uwire_remove(struct platform_device *pdev)
+static int __exit uwire_remove(struct platform_device *pdev)
 {
        struct uwire_spi        *uwire = dev_get_drvdata(&pdev->dev);
        int                     status;
@@ -543,8 +543,7 @@ static struct platform_driver uwire_driver = {
                .bus            = &platform_bus_type,
                .owner          = THIS_MODULE,
        },
-       .probe          = uwire_probe,
-       .remove         = uwire_remove,
+       .remove         = __exit_p(uwire_remove),
        // suspend ... unuse ck
        // resume ... use ck
 };
@@ -566,7 +565,7 @@ static int __init omap_uwire_init(void)
                omap_writel(val | 0x00AAA000, OMAP730_IO_CONF_9);
        }
 
-       return platform_driver_register(&uwire_driver);
+       return platform_driver_probe(&uwire_driver, uwire_probe);
 }
 
 static void __exit omap_uwire_exit(void)
index 16bf66b7c94eac83259fbd76b2be369273d4b407..e05918e79eae9ad193697d393ff0730a8b77eabe 100644 (file)
@@ -1229,7 +1229,7 @@ static void cleanup(struct spi_device *spi)
        kfree(chip);
 }
 
-static int init_queue(struct driver_data *drv_data)
+static int __init init_queue(struct driver_data *drv_data)
 {
        INIT_LIST_HEAD(&drv_data->queue);
        spin_lock_init(&drv_data->lock);
@@ -1317,7 +1317,7 @@ static int destroy_queue(struct driver_data *drv_data)
        return 0;
 }
 
-static int pxa2xx_spi_probe(struct platform_device *pdev)
+static int __init pxa2xx_spi_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct pxa2xx_spi_master *platform_info;
@@ -1621,8 +1621,7 @@ static struct platform_driver driver = {
                .bus = &platform_bus_type,
                .owner = THIS_MODULE,
        },
-       .probe = pxa2xx_spi_probe,
-       .remove = __devexit_p(pxa2xx_spi_remove),
+       .remove = pxa2xx_spi_remove,
        .shutdown = pxa2xx_spi_shutdown,
        .suspend = pxa2xx_spi_suspend,
        .resume = pxa2xx_spi_resume,
@@ -1630,9 +1629,7 @@ static struct platform_driver driver = {
 
 static int __init pxa2xx_spi_init(void)
 {
-       platform_driver_register(&driver);
-
-       return 0;
+       return platform_driver_probe(&driver, pxa2xx_spi_probe);
 }
 module_init(pxa2xx_spi_init);
 
index bd9177f51de9d347062e2493d4d7fd1d963ce0d6..0f0c5c11c79f4581bd26101acff12ee121c62605 100644 (file)
@@ -1361,7 +1361,7 @@ static void cleanup(struct spi_device *spi)
        kfree(spi_get_ctldata(spi));
 }
 
-static int init_queue(struct driver_data *drv_data)
+static int __init init_queue(struct driver_data *drv_data)
 {
        INIT_LIST_HEAD(&drv_data->queue);
        spin_lock_init(&drv_data->lock);
@@ -1444,7 +1444,7 @@ static int destroy_queue(struct driver_data *drv_data)
        return 0;
 }
 
-static int spi_imx_probe(struct platform_device *pdev)
+static int __init spi_imx_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct spi_imx_master *platform_info;
@@ -1622,7 +1622,7 @@ err_no_mem:
        return status;
 }
 
-static int __devexit spi_imx_remove(struct platform_device *pdev)
+static int __exit spi_imx_remove(struct platform_device *pdev)
 {
        struct driver_data *drv_data = platform_get_drvdata(pdev);
        int irq;
@@ -1739,8 +1739,7 @@ static struct platform_driver driver = {
                .bus = &platform_bus_type,
                .owner = THIS_MODULE,
        },
-       .probe = spi_imx_probe,
-       .remove = __devexit_p(spi_imx_remove),
+       .remove = __exit_p(spi_imx_remove),
        .shutdown = spi_imx_shutdown,
        .suspend = spi_imx_suspend,
        .resume = spi_imx_resume,
@@ -1748,7 +1747,7 @@ static struct platform_driver driver = {
 
 static int __init spi_imx_init(void)
 {
-       return platform_driver_register(&driver);
+       return platform_driver_probe(&driver, spi_imx_probe);
 }
 module_init(spi_imx_init);
 
index 32cda77b31cd2c5625bf8c10eeabb88814ede008..4580b9cf625d159585793d05d848c5781e9a9f2b 100644 (file)
@@ -511,7 +511,7 @@ err:
        return ret;
 }
 
-static int __devexit mpc83xx_spi_remove(struct platform_device *dev)
+static int __exit mpc83xx_spi_remove(struct platform_device *dev)
 {
        struct mpc83xx_spi *mpc83xx_spi;
        struct spi_master *master;
@@ -529,8 +529,7 @@ static int __devexit mpc83xx_spi_remove(struct platform_device *dev)
 
 MODULE_ALIAS("mpc83xx_spi");                   /* for platform bus hotplug */
 static struct platform_driver mpc83xx_spi_driver = {
-       .probe = mpc83xx_spi_probe,
-       .remove = __devexit_p(mpc83xx_spi_remove),
+       .remove = __exit_p(mpc83xx_spi_remove),
        .driver = {
                   .name = "mpc83xx_spi",
        },
@@ -538,7 +537,7 @@ static struct platform_driver mpc83xx_spi_driver = {
 
 static int __init mpc83xx_spi_init(void)
 {
-       return platform_driver_register(&mpc83xx_spi_driver);
+       return platform_driver_probe(&mpc83xx_spi_driver, mpc83xx_spi_probe);
 }
 
 static void __exit mpc83xx_spi_exit(void)
index e9b683f7d7b3bc7f77d0e3e55b611cf09b0f96ea..89d6685a5ca4860594773a346e37dbad40021762 100644 (file)
@@ -233,7 +233,7 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev)
        return IRQ_HANDLED;
 }
 
-static int s3c24xx_spi_probe(struct platform_device *pdev)
+static int __init s3c24xx_spi_probe(struct platform_device *pdev)
 {
        struct s3c24xx_spi *hw;
        struct spi_master *master;
@@ -382,7 +382,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
        return err;
 }
 
-static int s3c24xx_spi_remove(struct platform_device *dev)
+static int __exit s3c24xx_spi_remove(struct platform_device *dev)
 {
        struct s3c24xx_spi *hw = platform_get_drvdata(dev);
 
@@ -429,8 +429,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev)
 
 MODULE_ALIAS("s3c2410_spi");                   /* for platform bus hotplug */
 static struct platform_driver s3c24xx_spidrv = {
-       .probe          = s3c24xx_spi_probe,
-       .remove         = s3c24xx_spi_remove,
+       .remove         = __exit_p(s3c24xx_spi_remove),
        .suspend        = s3c24xx_spi_suspend,
        .resume         = s3c24xx_spi_resume,
        .driver         = {
@@ -441,7 +440,7 @@ static struct platform_driver s3c24xx_spidrv = {
 
 static int __init s3c24xx_spi_init(void)
 {
-        return platform_driver_register(&s3c24xx_spidrv);
+        return platform_driver_probe(&s3c24xx_spidrv, s3c24xx_spi_probe);
 }
 
 static void __exit s3c24xx_spi_exit(void)