Commit d1e44d9c authored by David Brownell's avatar David Brownell Committed by Linus Torvalds

SPI driver runtime footprint shrinkage

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: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 86eeb6fe
...@@ -481,7 +481,7 @@ static void uwire_off(struct uwire_spi *uwire) ...@@ -481,7 +481,7 @@ static void uwire_off(struct uwire_spi *uwire)
spi_master_put(uwire->bitbang.master); 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 spi_master *master;
struct uwire_spi *uwire; struct uwire_spi *uwire;
...@@ -525,7 +525,7 @@ static int uwire_probe(struct platform_device *pdev) ...@@ -525,7 +525,7 @@ static int uwire_probe(struct platform_device *pdev)
return status; 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); struct uwire_spi *uwire = dev_get_drvdata(&pdev->dev);
int status; int status;
...@@ -543,8 +543,7 @@ static struct platform_driver uwire_driver = { ...@@ -543,8 +543,7 @@ static struct platform_driver uwire_driver = {
.bus = &platform_bus_type, .bus = &platform_bus_type,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = uwire_probe, .remove = __exit_p(uwire_remove),
.remove = uwire_remove,
// suspend ... unuse ck // suspend ... unuse ck
// resume ... use ck // resume ... use ck
}; };
...@@ -566,7 +565,7 @@ static int __init omap_uwire_init(void) ...@@ -566,7 +565,7 @@ static int __init omap_uwire_init(void)
omap_writel(val | 0x00AAA000, OMAP730_IO_CONF_9); 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) static void __exit omap_uwire_exit(void)
......
...@@ -1229,7 +1229,7 @@ static void cleanup(struct spi_device *spi) ...@@ -1229,7 +1229,7 @@ static void cleanup(struct spi_device *spi)
kfree(chip); 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); INIT_LIST_HEAD(&drv_data->queue);
spin_lock_init(&drv_data->lock); spin_lock_init(&drv_data->lock);
...@@ -1317,7 +1317,7 @@ static int destroy_queue(struct driver_data *drv_data) ...@@ -1317,7 +1317,7 @@ static int destroy_queue(struct driver_data *drv_data)
return 0; 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 device *dev = &pdev->dev;
struct pxa2xx_spi_master *platform_info; struct pxa2xx_spi_master *platform_info;
...@@ -1621,8 +1621,7 @@ static struct platform_driver driver = { ...@@ -1621,8 +1621,7 @@ static struct platform_driver driver = {
.bus = &platform_bus_type, .bus = &platform_bus_type,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = pxa2xx_spi_probe, .remove = pxa2xx_spi_remove,
.remove = __devexit_p(pxa2xx_spi_remove),
.shutdown = pxa2xx_spi_shutdown, .shutdown = pxa2xx_spi_shutdown,
.suspend = pxa2xx_spi_suspend, .suspend = pxa2xx_spi_suspend,
.resume = pxa2xx_spi_resume, .resume = pxa2xx_spi_resume,
...@@ -1630,9 +1629,7 @@ static struct platform_driver driver = { ...@@ -1630,9 +1629,7 @@ static struct platform_driver driver = {
static int __init pxa2xx_spi_init(void) static int __init pxa2xx_spi_init(void)
{ {
platform_driver_register(&driver); return platform_driver_probe(&driver, pxa2xx_spi_probe);
return 0;
} }
module_init(pxa2xx_spi_init); module_init(pxa2xx_spi_init);
......
...@@ -1361,7 +1361,7 @@ static void cleanup(struct spi_device *spi) ...@@ -1361,7 +1361,7 @@ static void cleanup(struct spi_device *spi)
kfree(spi_get_ctldata(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); INIT_LIST_HEAD(&drv_data->queue);
spin_lock_init(&drv_data->lock); spin_lock_init(&drv_data->lock);
...@@ -1444,7 +1444,7 @@ static int destroy_queue(struct driver_data *drv_data) ...@@ -1444,7 +1444,7 @@ static int destroy_queue(struct driver_data *drv_data)
return 0; 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 device *dev = &pdev->dev;
struct spi_imx_master *platform_info; struct spi_imx_master *platform_info;
...@@ -1622,7 +1622,7 @@ static int spi_imx_probe(struct platform_device *pdev) ...@@ -1622,7 +1622,7 @@ static int spi_imx_probe(struct platform_device *pdev)
return status; 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); struct driver_data *drv_data = platform_get_drvdata(pdev);
int irq; int irq;
...@@ -1739,8 +1739,7 @@ static struct platform_driver driver = { ...@@ -1739,8 +1739,7 @@ static struct platform_driver driver = {
.bus = &platform_bus_type, .bus = &platform_bus_type,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = spi_imx_probe, .remove = __exit_p(spi_imx_remove),
.remove = __devexit_p(spi_imx_remove),
.shutdown = spi_imx_shutdown, .shutdown = spi_imx_shutdown,
.suspend = spi_imx_suspend, .suspend = spi_imx_suspend,
.resume = spi_imx_resume, .resume = spi_imx_resume,
...@@ -1748,7 +1747,7 @@ static struct platform_driver driver = { ...@@ -1748,7 +1747,7 @@ static struct platform_driver driver = {
static int __init spi_imx_init(void) 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); module_init(spi_imx_init);
......
...@@ -511,7 +511,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) ...@@ -511,7 +511,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
return ret; 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 mpc83xx_spi *mpc83xx_spi;
struct spi_master *master; struct spi_master *master;
...@@ -529,8 +529,7 @@ static int __devexit mpc83xx_spi_remove(struct platform_device *dev) ...@@ -529,8 +529,7 @@ static int __devexit mpc83xx_spi_remove(struct platform_device *dev)
MODULE_ALIAS("mpc83xx_spi"); /* for platform bus hotplug */ MODULE_ALIAS("mpc83xx_spi"); /* for platform bus hotplug */
static struct platform_driver mpc83xx_spi_driver = { static struct platform_driver mpc83xx_spi_driver = {
.probe = mpc83xx_spi_probe, .remove = __exit_p(mpc83xx_spi_remove),
.remove = __devexit_p(mpc83xx_spi_remove),
.driver = { .driver = {
.name = "mpc83xx_spi", .name = "mpc83xx_spi",
}, },
...@@ -538,7 +537,7 @@ static struct platform_driver mpc83xx_spi_driver = { ...@@ -538,7 +537,7 @@ static struct platform_driver mpc83xx_spi_driver = {
static int __init mpc83xx_spi_init(void) 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) static void __exit mpc83xx_spi_exit(void)
......
...@@ -233,7 +233,7 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev) ...@@ -233,7 +233,7 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev)
return IRQ_HANDLED; 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 s3c24xx_spi *hw;
struct spi_master *master; struct spi_master *master;
...@@ -382,7 +382,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -382,7 +382,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
return err; 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); struct s3c24xx_spi *hw = platform_get_drvdata(dev);
...@@ -429,8 +429,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev) ...@@ -429,8 +429,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev)
MODULE_ALIAS("s3c2410_spi"); /* for platform bus hotplug */ MODULE_ALIAS("s3c2410_spi"); /* for platform bus hotplug */
static struct platform_driver s3c24xx_spidrv = { static struct platform_driver s3c24xx_spidrv = {
.probe = s3c24xx_spi_probe, .remove = __exit_p(s3c24xx_spi_remove),
.remove = s3c24xx_spi_remove,
.suspend = s3c24xx_spi_suspend, .suspend = s3c24xx_spi_suspend,
.resume = s3c24xx_spi_resume, .resume = s3c24xx_spi_resume,
.driver = { .driver = {
...@@ -441,7 +440,7 @@ static struct platform_driver s3c24xx_spidrv = { ...@@ -441,7 +440,7 @@ static struct platform_driver s3c24xx_spidrv = {
static int __init s3c24xx_spi_init(void) 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) static void __exit s3c24xx_spi_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment