Skip to content

Commit

Permalink
SPI driver runtime footprint shrinkage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Brownell authored and Linus Torvalds committed Oct 16, 2007
1 parent 86eeb6f commit d1e44d9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
9 changes: 4 additions & 5 deletions drivers/spi/omap_uwire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
};
Expand All @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions drivers/spi/pxa2xx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1621,18 +1621,15 @@ 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,
};

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);

Expand Down
11 changes: 5 additions & 6 deletions drivers/spi/spi_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1622,7 +1622,7 @@ static int spi_imx_probe(struct platform_device *pdev)
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;
Expand Down Expand Up @@ -1739,16 +1739,15 @@ 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,
};

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);

Expand Down
7 changes: 3 additions & 4 deletions drivers/spi/spi_mpc83xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
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;
Expand All @@ -529,16 +529,15 @@ 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",
},
};

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)
Expand Down
9 changes: 4 additions & 5 deletions drivers/spi/spi_s3c24xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 = {
Expand All @@ -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)
Expand Down

0 comments on commit d1e44d9

Please sign in to comment.