Convert MMC subsys drivers to dev_pm_ops
PATCH 1/1 Convert MMC subsys drivers to dev_pm_ops
Hi,
This converts most of the drivers found in drivers/mmc/host to dev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.
This needs testing, so I'd be very glad if the affected maintainers expressed their opinion on this.
Cheers!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Convert-MMC-subsys-drivers-to-dev_pm_ops.patch
Type: text/x-patch
Size: 30733 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20090822/485a29cf/attachment-0001.bin>
Quoted 4 lines · Marek Vasut
Hi,
This converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.
Are you sure you're actually fixing things?
You replaced platform_driver_probe() calls with platform_driver_register() calls, and made the probe functions __devinit instead of __init. Especially when the platform device is unlikely to go away or new ones to ever appear, there is no point keeping the probe code around after it is done.
Nicolas
Dne So 22. srpna 2009 04:44:00 Nicolas Pitre napsal(a):
Quoted 7 lines · Marek Vasut
Quoted 5 lines
Hi,
This converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.
Quoted 7 lines
Are you sure you're actually fixing things?
You replaced
platform_driver_probe()calls withplatform_driver_register()calls, and made the probe functions__devinitinstead of__init. Especially when the platform device is unlikely to go away or new ones to ever appear, there is no point keeping the probe code around after it is done.
Yeah, the __devinit should actually remove the init function when done ... to my understanding. Sorry in case I'm wrong.
Quoted 3 lines
Nicolas
Quoted 10 lines · Marek Vasut
Dne So 22. srpna 2009 04:44:00 Nicolas Pitre napsal(a):
Quoted 9 lines · Marek Vasut
Quoted 5 lines
Hi,
This converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.Are you sure you're actually fixing things?
Quoted 8 lines
Quoted 5 lines
You replaced
platform_driver_probe()calls withplatform_driver_register()calls, and made the probe functions__devinitinstead of__init. Especially when the platform device is unlikely to go away or new ones to ever appear, there is no point keeping the probe code around after it is done.Yeah, the
__devinitshould actually remove the init function when done ... to my understanding. Sorry in case I'm wrong.
No it cannot, because there is normally no way if it is really done as new device, like on a USB bus, may appear later and bind to the same driver. So __devinit will actually discard the code only if hotplug is disabled in the kernel config (see include/linux/init.h and include/asm-generic/vmlinux.lds.h).
Quoting drivers/base/platform.c:
* platform_driver_probe - register driver for non-hotpluggable device
* @drv: platform driver structure
* @probe: the driver probe routine, probably from an __init section *
* Use this instead of platform_driver_register() when you know the device
* is not hotpluggable and has already been registered, and you want to
* remove its run-once probe() infrastructure from memory after the driver
* has bound to the device.
*
* One typical use for this would be with drivers for controllers integrated
* into system-on-chip processors, where the controller devices have been
* configured as part of board setup.
Nicolas
Review
Quoted 4 lines · Marek Vasut
(quoted diff) +4
-0+static struct dev_pm_ops cm710_mmc_pm_ops = { + .suspend = cb710_mmc_suspend, + .resume = cb710_mmc_resume, +};
This is almost certainly wrong (same for the other drivers you converted) as they now no longer support hibernation, which requires different ops. Please see: http://lkml.org/lkml/2009/7/25/118.
You also seem to have handled the #ifndef CONFIG_PM case incorrectly. See http://lkml.org/lkml/2009/8/3/253 for an example how it can be done.
There have already been several threads on lkml discussing this. Please search for posts with dev_pm_ops in the subject if you want more information.
Also, please CC linux-pm at lists.linux-foundation.org on patches related to this conversion.
Cheers,
FJP
Hi Marek,
Quoted 10 lines · Frans Pop
Review
Quoted 4 lines · Marek Vasut
(quoted diff) +4
-0+static struct dev_pm_ops cm710_mmc_pm_ops = { + ? ? ? .suspend = cb710_mmc_suspend, + ? ? ? .resume = cb710_mmc_resume, +};This is almost certainly wrong (same for the other drivers you converted) as they now no longer support hibernation, which requires different ops. Please see: http://lkml.org/lkml/2009/7/25/118.
Quoted 2 lines
You also seem to have handled the #ifndef
CONFIG_PMcase incorrectly. See http://lkml.org/lkml/2009/8/3/253 for an example how it can be done.
In addition to what Frans said, at least for platform drivers you could avoid adding (mostly) unused platform_device temp vars like these
+ struct platform_device *pdev = to_platform_device(dev);
struct au1xmmc_host *host = platform_get_drvdata(pdev);by simply doing
- struct au1xmmc_host *host = platform_get_drvdata(pdev);
+ struct au1xmmc_host *host = dev_get_drvdata(dev);
What do you think?
Thanks!
Manuel Lauss
(Adding linux-mmc at vger.kernel.org to the CC list)
Quoted 1,037 lines · Marek Vasut
Hi,
This converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.This needs testing, so I'd be very glad if the affected maintainers expressed their opinion on this.
Cheers!
From
66978eef1d2bd64222901f0b6c6d9c35dcca044eMon Sep 17 00:00:00 2001
From: Marek Vasut <[email protected]>
Date: Sat, 22 Aug 2009 02:10:27 +0200
Subject: [PATCH] Convert MMC subsys drivers todev_pm_opsThis converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.Signed-off-by Marek Vasut <[email protected]>--- drivers/mmc/core/core.c | 3 +- drivers/mmc/host/at91_mci.c | 28 ++++++++++++++---------- drivers/mmc/host/au1xmmc.c | 29 ++++++++++++++----------- drivers/mmc/host/cb710-mmc.c | 26 ++++++++++++++--------- drivers/mmc/host/imxmmc.c | 34 +++++++++++++++++------------- drivers/mmc/host/mmci.c | 2 +- drivers/mmc/host/mvsdio.c | 33 +++++++++++++++++------------ drivers/mmc/host/mxcmmc.c | 29 ++++++++++++++----------- drivers/mmc/host/omap.c | 26 ++++++++++++---------- drivers/mmc/host/omap_hsmmc.c | 28 +++++++++++++----------- drivers/mmc/host/pxamci.c | 28 +++++++++++++----------- drivers/mmc/host/s3cmci.c | 46 +++++++++++++++++++++++----------------- drivers/mmc/host/sdhci-of.c | 2 +- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdricoh_cs.c | 2 +- drivers/mmc/host/tifm_sd.c | 2 +- drivers/mmc/host/tmio_mmc.c | 41 +++++++++++++++++++----------------- drivers/mmc/host/via-sdmmc.c | 2 +- drivers/mmc/host/wbsd.c | 2 +- include/linux/mmc/host.h | 2 +- 20 files changed, 203 insertions(+), 164 deletions(-)drivers/mmc/core/core.c +1
-2@@ -971,9 +971,8 @@ void mmc_stop_host(struct mmc_host *host)/** * mmc_suspend_host - suspend a host * @host: mmc host -* @state: suspend mode (PM_SUSPEND_xxx) */ -int mmc_suspend_host (struct mmc_host *host,pm_message_t state) +int mmc_suspend_host (struct mmc_host *host) {cancel_delayed_work (&host->detect);mmc_flush_scheduled_work ();drivers/mmc/host/at91_mci.c +16
-12@@ -982,7 +982,7 @@ static const struct mmc_host_ops at91_mci_ops = {/* * Probe for the device */ -static int __init at91_mci_probe (struct platform_device *pdev) +static int __devinit at91_mci_probe (struct platform_device *pdev) {struct mmc_host *mmc;struct at91mci_host *host;@@ -1144,7 +1144,7 @@ fail6:/* * Remove a device */ -static int __exit at91_mci_remove(struct platform_device *pdev) +static int __devexit at91_mci_remove(struct platform_device *pdev) {struct mmc_host *mmc =platform_get_drvdata (pdev);struct at91mci_host *host;@@ -1187,8 +1187,9 @@ static int __exit at91_mci_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int at91_mci_suspend (struct platform_device *pdev,pm_message_t state) +static int at91_mci_suspend (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct mmc_host *mmc =platform_get_drvdata (pdev);struct at91mci_host *host =mmc_priv (mmc);int ret =0 ;@@ -1197,13 +1198,14 @@ static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state)enable_irq_wake (host->board->det_pin);if (mmc) - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);return ret; } -static int at91_mci_resume (struct platform_device *pdev) +static int at91_mci_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct mmc_host *mmc =platform_get_drvdata (pdev);struct at91mci_host *host =mmc_priv (mmc);int ret =0 ;@@ -1216,24 +1218,26 @@ static int at91_mci_resume(struct platform_device *pdev)return ret; } -#else -#define at91_mci_suspend NULL -#define at91_mci_resume NULL -#endif -static struct platform_driver at91_mci_driver = { - .remove =__exit_p (at91_mci_remove), +static struct dev_pm_ops at91_mci_pm_ops = { .suspend = at91_mci_suspend, .resume = at91_mci_resume, +}; +#endif + +static struct platform_driver at91_mci_driver = { + .probe = at91_mci_probe, + .remove =__devexit_p (at91_mci_remove), .driver = { .name =DRIVER_NAME , .owner =THIS_MODULE , + .pm = &at91_mci_pm_ops, }, };static int __init at91_mci_init (void ) { -return platform_driver_probe (&at91_mci_driver, at91_mci_probe); +return platform_driver_register (&at91_mci_driver); } static void __exit at91_mci_exit(void)drivers/mmc/host/au1xmmc.c +16
-13@@ -1132,12 +1132,13 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int au1xmmc_suspend (struct platform_device *pdev,pm_message_t state) +static int au1xmmc_suspend (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct au1xmmc_host *host =platform_get_drvdata (pdev);int ret; - ret =mmc_suspend_host (host->mmc, state); + ret =mmc_suspend_host (host->mmc);if (ret)return ret;@@ -1150,27 +1151,29 @@ static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) return 0; } -static int au1xmmc_resume (struct platform_device *pdev) +static int au1xmmc_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct au1xmmc_host *host =platform_get_drvdata (pdev);au1xmmc_reset_controller (host);return mmc_resume_host (host->mmc); } -#else -#define au1xmmc_suspend NULL -#define au1xmmc_resume NULL -#endif -static struct platform_driver au1xmmc_driver = { - .probe = au1xmmc_probe, - .remove = au1xmmc_remove, +static struct dev_pm_ops au1xmmc_pm_ops = { .suspend = au1xmmc_suspend, .resume = au1xmmc_resume, - .driver = { - .name =DRIVER_NAME , - .owner =THIS_MODULE , +}; +#endif + +static struct platform_driver au1xmmc_driver = { + .probe = au1xmmc_probe, + .remove =__devexit_p (au1xmmc_remove), + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + .pm = &au1xmmc_pm_ops, }, };drivers/mmc/host/cb710-mmc.c +16
-10@@ -670,13 +670,14 @@ static const struct mmc_host_ops cb710_mmc_host = {#ifdef CONFIG_PM -static int cb710_mmc_suspend (struct platform_device *pdev,pm_message_t state) +static int cb710_mmc_suspend (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct cb710_slot *slot =cb710_pdev_to_slot (pdev);struct mmc_host *mmc =cb710_slot_to_mmc (slot);int err; - err =mmc_suspend_host (mmc, state); + err =mmc_suspend_host (mmc);if (err)return err;@@ -684,8 +685,9 @@ static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)return 0 ; } -static int cb710_mmc_resume (struct platform_device *pdev) +static int cb710_mmc_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct cb710_slot *slot =cb710_pdev_to_slot (pdev);struct mmc_host *mmc =cb710_slot_to_mmc (slot);@@ -694,6 +696,10 @@ static int cb710_mmc_resume(struct platform_device *pdev) return mmc_resume_host(mmc); } +static struct dev_pm_ops cm710_mmc_pm_ops = { + .suspend = cb710_mmc_suspend, + .resume = cb710_mmc_resume, +};#endif /* CONFIG_PM */ static int __devinit cb710_mmc_init (struct platform_device *pdev)@@ -776,13 +782,13 @@ static int __devexit cb710_mmc_exit(struct platform_device *pdev) }static struct platform_driver cb710_mmc_driver = { - .driver.name ="cb710-mmc" , - .probe = cb710_mmc_init, - .remove =__devexit_p (cb710_mmc_exit), -#ifdef CONFIG_PM - .suspend = cb710_mmc_suspend, - .resume = cb710_mmc_resume, -#endif + .driver = { + .name ="cb710-mmc" , + .owner =THIS_MODULE , + .pm = &cb710_mmc_pm_ops, + }, + .probe = cb710_mmc_init, + .remove =__devexit_p (cb710_mmc_exit), };static int __init cb710_mmc_init_module (void )drivers/mmc/host/imxmmc.c +19
-15@@ -933,7 +933,7 @@ static void imxmci_check_status(unsigned long data)mod_timer (&host->timer, jiffies + (HZ >>1 )); } -static int __init imxmci_probe (struct platform_device *pdev) +static int __devinit imxmci_probe (struct platform_device *pdev) {struct mmc_host *mmc;struct imxmci_host *host =NULL ;@@ -1075,7 +1075,7 @@ out:return ret; } -static int __exit imxmci_remove(struct platform_device *pdev) +static int __devexit imxmci_remove(struct platform_device *pdev) {struct mmc_host *mmc =platform_get_drvdata (pdev);@@ -1109,20 +1109,22 @@ static int __exit imxmci_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int imxmci_suspend (struct platform_device *dev,pm_message_t state) +static int imxmci_suspend (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc) - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);return ret; } -static int imxmci_resume (struct platform_device *dev) +static int imxmci_resume (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);struct imxmci_host *host;int ret =0 ;@@ -1135,24 +1137,26 @@ static int imxmci_resume(struct platform_device *dev)return ret; } -#else -#define imxmci_suspend NULL -#define imxmci_resume NULL -#endif /* CONFIG_PM */ -static struct platform_driver imxmci_driver = { - .remove =__exit_p (imxmci_remove), +static struct dev_pm_ops imxmci_pm_ops = { .suspend = imxmci_suspend, .resume = imxmci_resume, +}; +#endif /* CONFIG_PM */ + +static struct platform_driver imxmci_driver = { + .probe = imxmci_probe, + .remove =__devexit_p (imxmci_remove), .driver = { .name =DRIVER_NAME , .owner =THIS_MODULE , - } + .pm = &imxmci_pm_ops, + }, };static int __init imxmci_init (void ) { -return platform_driver_probe (&imxmci_driver, imxmci_probe); +return platform_driver_register (&imxmci_driver); } static void __exit imxmci_exit(void)drivers/mmc/host/mmci.c +1
-1@@ -676,7 +676,7 @@ static int mmci_suspend(struct amba_device *dev, pm_message_t state)if (mmc) {struct mmci_host *host =mmc_priv (mmc); - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);if (ret ==0 )writel (0 , host->base +MMCIMASK0 ); }drivers/mmc/host/mvsdio.c +19
-14@@ -700,7 +700,7 @@ static void __init mv_conf_mbus_windows(struct mvsd_host *host, } } -static int __init mvsd_probe (struct platform_device *pdev) +static int __devinit mvsd_probe (struct platform_device *pdev) {struct mmc_host *mmc =NULL ;struct mvsd_host *host =NULL ;@@ -833,7 +833,7 @@ out:return ret; } -static int __exit mvsd_remove(struct platform_device *pdev) +static int __devexit mvsd_remove(struct platform_device *pdev) {struct mmc_host *mmc =platform_get_drvdata (pdev);@@ -859,20 +859,22 @@ static int __exit mvsd_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int mvsd_suspend (struct platform_device *dev,pm_message_t state) +static int mvsd_suspend (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc) - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);return ret; } -static int mvsd_resume (struct platform_device *dev) +static int mvsd_resume (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc)@@ -880,23 +882,26 @@ static int mvsd_resume(struct platform_device *dev)return ret; } -#else -#define mvsd_suspend NULL -#define mvsd_resume NULL -#endif -static struct platform_driver mvsd_driver = { - .remove =__exit_p (mvsd_remove), +static struct dev_pm_ops mvsd_pm_ops = { .suspend = mvsd_suspend, .resume = mvsd_resume, +}; +#endif + +static struct platform_driver mvsd_driver = { + .probe = mvsd_probe, + .remove =__devexit_p (mvsd_remove), .driver = { .name =DRIVER_NAME , + .owner =THIS_DRIVER , + .pm = &mvsd_pm_ops, }, };static int __init mvsd_init (void ) { -return platform_driver_probe (&mvsd_driver, mvsd_probe); +return platform_driver_register (&mvsd_driver); } static void __exit mvsd_exit(void)drivers/mmc/host/mxcmmc.c +16
-13@@ -675,7 +675,7 @@ static const struct mmc_host_ops mxcmci_ops = { .get_ro = mxcmci_get_ro, }; -static int mxcmci_probe (struct platform_device *pdev) +static int __devinit mxcmci_probe (struct platform_device *pdev) {struct mmc_host *mmc;struct mxcmci_host *host =NULL ;@@ -813,7 +813,7 @@ out_release_mem:return ret; } -static int mxcmci_remove (struct platform_device *pdev) +static int __devexit mxcmci_remove(struct platform_device *pdev) {struct mmc_host *mmc =platform_get_drvdata (pdev);struct mxcmci_host *host =mmc_priv (mmc);@@ -842,20 +842,22 @@ static int mxcmci_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int mxcmci_suspend (struct platform_device *dev,pm_message_t state) +static int mxcmci_suspend (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc) - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);return ret; } -static int mxcmci_resume (struct platform_device *dev) +static int mxcmci_resume (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);struct mxcmci_host *host;int ret =0 ;@@ -866,19 +868,20 @@ static int mxcmci_resume(struct platform_device *dev) return ret; } -#else -#define mxcmci_suspend NULL -#define mxcmci_resume NULL + +static struct dev_pm_ops mxcmci_pm_ops = { + .suspend = mxcmci_suspend, + .resume = mxcmci_resume, +};#endif /* CONFIG_PM */ static struct platform_driver mxcmci_driver = { .probe = mxcmci_probe, - .remove = mxcmci_remove, - .suspend = mxcmci_suspend, - .resume = mxcmci_resume, + .remove =__devexit_p (mxcmci_remove), .driver = { .name =DRIVER_NAME , .owner =THIS_MODULE , + .pm = &mxcmci_pm_ops, } };drivers/mmc/host/omap.c +14
-12@@ -1392,7 +1392,7 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot)mmc_free_host (mmc); } -static int __init mmc_omap_probe (struct platform_device *pdev) +static int __devinit mmc_omap_probe (struct platform_device *pdev) {struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;struct mmc_omap_host *host =NULL ;@@ -1513,7 +1513,7 @@ err_free_mem_region:return ret; } -static int mmc_omap_remove (struct platform_device *pdev) +static int __devexit mmc_omap_remove(struct platform_device *pdev) {struct mmc_omap_host *host =platform_get_drvdata (pdev);int i;@@ -1543,9 +1543,10 @@ static int mmc_omap_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int mmc_omap_suspend (struct platform_device *pdev,pm_message_t mesg) +static int mmc_omap_suspend (struct device *dev) {int i, ret =0 ; +struct platform_device *pdev =to_platform_device (dev);struct mmc_omap_host *host =platform_get_drvdata (pdev);if (host ==NULL || host->suspended)@@ -1555,7 +1556,7 @@ static int mmc_omap_suspend(struct platform_device *pdev, pm_message_t mesg)struct mmc_omap_slot *slot; slot = host->slots[i]; - ret =mmc_suspend_host (slot->mmc, mesg); + ret =mmc_suspend_host (slot->mmc);if (ret <0 ) {while (--i >=0 ) { slot = host->slots[i];@@ -1568,9 +1569,10 @@ static int mmc_omap_suspend(struct platform_device *pdev, pm_message_t mesg)return 0 ; } -static int mmc_omap_resume (struct platform_device *pdev) +static int mmc_omap_resume (struct device *dev) {int i, ret =0 ; +struct platform_device *pdev =to_platform_device (dev);struct mmc_omap_host *host =platform_get_drvdata (pdev);if (host ==NULL || !host->suspended)@@ -1587,15 +1589,15 @@ static int mmc_omap_resume(struct platform_device *pdev) }return 0 ; } -#else -#define mmc_omap_suspend NULL -#define mmc_omap_resume NULL +static struct dev_pm_ops mmc_omap_pm_ops = { + .suspend = mmc_omap_suspend, + .resume = mmc_omap_resume, +};#endif static struct platform_driver mmc_omap_driver = { - .remove = mmc_omap_remove, - .suspend = mmc_omap_suspend, - .resume = mmc_omap_resume, + .probe = mmc_omap_probe, + .remove =__devexit_p (mmc_omap_remove), .driver = { .name =DRIVER_NAME , .owner =THIS_MODULE ,@@ -1604,7 +1606,7 @@ static struct platform_driver mmc_omap_driver = {static int __init mmc_omap_init (void ) { -return platform_driver_probe (&mmc_omap_driver, mmc_omap_probe); +return platform_driver_register (&mmc_omap_driver); } static void __exit mmc_omap_exit(void)drivers/mmc/host/omap_hsmmc.c +15
-13@@ -967,7 +967,7 @@ static struct mmc_host_ops mmc_omap_ops = {/* NYET -- enable_sdio_irq */ }; -static int __init omap_mmc_probe (struct platform_device *pdev) +static int __devinit omap_mmc_probe (struct platform_device *pdev) {struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;struct mmc_host *mmc;@@ -1180,7 +1180,7 @@ err:return ret; } -static int omap_mmc_remove (struct platform_device *pdev) +static int __devexit omap_mmc_remove(struct platform_device *pdev) {struct mmc_omap_host *host =platform_get_drvdata (pdev);struct resource *res;@@ -1216,16 +1216,17 @@ static int omap_mmc_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int omap_mmc_suspend (struct platform_device *pdev,pm_message_t state) +static int omap_mmc_suspend (struct device *pdev) {int ret =0 ; +struct platform_device *pdev =to_platform_device (dev);struct mmc_omap_host *host =platform_get_drvdata (pdev);if (host && host->suspended)return 0 ;if (host) { - ret =mmc_suspend_host (host->mmc, state); + ret =mmc_suspend_host (host->mmc);if (ret ==0 ) { host->suspended =1 ;@@ -1253,9 +1254,10 @@ static int omap_mmc_suspend(struct platform_device *pdev, pm_message_t state) }/* Routine to resume the MMC device */ -static int omap_mmc_resume (struct platform_device *pdev) +static int omap_mmc_resume (struct device *pdev) {int ret =0 ; +struct platform_device *pdev =to_platform_device (dev);struct mmc_omap_host *host =platform_get_drvdata (pdev);if (host && !host->suspended)@@ -1301,19 +1303,19 @@ clk_en_err: return ret; } -#else -#define omap_mmc_suspend NULL -#define omap_mmc_resume NULL +static struct dev_pm_ops omap_mmc_pm_ops = { + .suspend = omap_mmc_suspend, + .resume = omap_mmc_resume, +};#endif static struct platform_driver omap_mmc_driver = { .probe = omap_mmc_probe, - .remove = omap_mmc_remove, - .suspend = omap_mmc_suspend, - .resume = omap_mmc_resume, + .remove =__devexit_p (omap_mmc_remove), .driver = { - .name =DRIVER_NAME , - .owner =THIS_MODULE , + .name =DRIVER_NAME , + .owner =THIS_MODULE , + .pm = &omap_mmc_pm_ops, }, };drivers/mmc/host/pxamci.c +15
-13@@ -544,7 +544,7 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid)return IRQ_HANDLED ; } -static int pxamci_probe (struct platform_device *pdev) +static int __devinit pxamci_probe (struct platform_device *pdev) {struct mmc_host *mmc;struct pxamci_host *host =NULL ;@@ -750,7 +750,7 @@ err_gpio_ro:return ret; } -static int pxamci_remove (struct platform_device *pdev) +static int __devexit pxamci_remove(struct platform_device *pdev) {struct mmc_host *mmc =platform_get_drvdata (pdev);int gpio_cd =-1 , gpio_ro =-1 , gpio_power =-1 ;@@ -804,20 +804,22 @@ static int pxamci_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int pxamci_suspend (struct platform_device *dev,pm_message_t state) +static int pxamci_suspend (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc) - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);return ret; } -static int pxamci_resume (struct platform_device *dev) +static int pxamci_resume (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret =0 ;if (mmc)@@ -825,19 +827,19 @@ static int pxamci_resume(struct platform_device *dev) return ret; } -#else -#define pxamci_suspend NULL -#define pxamci_resume NULL +static struct dev_pm_ops pxamci_pm_ops = { + .suspend = pxamci_suspend, + .resume = pxamci_resume, +};#endif static struct platform_driver pxamci_driver = { .probe = pxamci_probe, - .remove = pxamci_remove, - .suspend = pxamci_suspend, - .resume = pxamci_resume, + .remove =__devexit_p (pxamci_remove), .driver = { .name =DRIVER_NAME , .owner =THIS_MODULE , + .pm = &pxamci_pm_ops, }, };drivers/mmc/host/s3cmci.c +26
-20@@ -1492,54 +1492,60 @@ static int __devinit s3cmci_2440_probe(struct platform_device *dev)#ifdef CONFIG_PM -static int s3cmci_suspend (struct platform_device *dev,pm_message_t state) +static int s3cmci_suspend (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev); -return mmc_suspend_host (mmc, state); +return mmc_suspend_host (mmc); } -static int s3cmci_resume (struct platform_device *dev) +static int s3cmci_resume (struct device *dev) { -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev);return mmc_resume_host (mmc); } -#else /* CONFIG_PM */ -#define s3cmci_suspend NULL -#define s3cmci_resume NULL +static struct dev_pm_ops s3cmci_pm_ops = { + .suspend = s3cmci_suspend, + .resume = s3cmci_resume, +};#endif /* CONFIG_PM */ static struct platform_driver s3cmci_2410_driver = { - .driver.name ="s3c2410-sdi" , - .driver.owner =THIS_MODULE , + .driver = { + .name ="s3c2410-sdi" , + .owner =THIS_MODULE , + .pm = &s3cmci_pm_ops, + }, .probe = s3cmci_2410_probe, .remove =__devexit_p (s3cmci_remove), .shutdown = s3cmci_shutdown, - .suspend = s3cmci_suspend, - .resume = s3cmci_resume, };static struct platform_driver s3cmci_2412_driver = { - .driver.name ="s3c2412-sdi" , - .driver.owner =THIS_MODULE , + .driver = { + .name ="s3c2412-sdi" , + .owner =THIS_MODULE , + .pm = &s3cmci_pm_ops, + }, .probe = s3cmci_2412_probe, .remove =__devexit_p (s3cmci_remove), .shutdown = s3cmci_shutdown, - .suspend = s3cmci_suspend, - .resume = s3cmci_resume, };static struct platform_driver s3cmci_2440_driver = { - .driver.name ="s3c2440-sdi" , - .driver.owner =THIS_MODULE , + .driver = { + .name ="s3c2440-sdi" , + .owner =THIS_MODULE , + .pm = &s3cmci_pm_ops, + }, .probe = s3cmci_2440_probe, .remove =__devexit_p (s3cmci_remove), .shutdown = s3cmci_shutdown, - .suspend = s3cmci_suspend, - .resume = s3cmci_resume, };drivers/mmc/host/sdhci-of.c +1
-1@@ -194,7 +194,7 @@ static int sdhci_of_suspend(struct of_device *ofdev, pm_message_t state) {struct sdhci_host *host =dev_get_drvdata (&ofdev->dev); -return mmc_suspend_host (host->mmc, state); +return mmc_suspend_host (host->mmc); }static int sdhci_of_resume (struct of_device *ofdev)drivers/mmc/host/sdhci.c +1
-1@@ -1576,7 +1576,7 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)sdhci_disable_card_detection (host); - ret =mmc_suspend_host (host->mmc, state); + ret =mmc_suspend_host (host->mmc);if (ret)return ret;drivers/mmc/host/sdricoh_cs.c +1
-1@@ -519,7 +519,7 @@ static int sdricoh_pcmcia_suspend(struct pcmcia_device *link) {struct mmc_host *mmc = link->priv;dev_dbg (&link->dev,"suspend\n" ); -mmc_suspend_host (mmc,PMSG_SUSPEND ); +mmc_suspend_host (mmc);return 0 ; }drivers/mmc/host/tifm_sd.c +1
-1@@ -1032,7 +1032,7 @@ static void tifm_sd_remove(struct tifm_dev *sock)static int tifm_sd_suspend (struct tifm_dev *sock,pm_message_t state) { -return mmc_suspend_host (tifm_get_drvdata (sock), state); +return mmc_suspend_host (tifm_get_drvdata (sock)); }static int tifm_sd_resume (struct tifm_dev *sock)drivers/mmc/host/tmio_mmc.c +22
-19@@ -466,31 +466,33 @@ static struct mmc_host_ops tmio_mmc_ops = { };#ifdef CONFIG_PM -static int tmio_mmc_suspend (struct platform_device *dev,pm_message_t state) +static int tmio_mmc_suspend (struct device *dev) { -struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mfd_cell *cell = (struct mfd_cell *)pdev->dev.platform_data; +struct mmc_host *mmc =platform_get_drvdata (pdev);int ret; - ret =mmc_suspend_host (mmc, state); + ret =mmc_suspend_host (mmc);/* Tell MFD core it can disable us now.*/ if (!ret && cell->disable) - cell->disable (dev); + cell->disable (pdev);return ret; } -static int tmio_mmc_resume (struct platform_device *dev) +static int tmio_mmc_resume (struct device *dev) { -struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; -struct mmc_host *mmc =platform_get_drvdata (dev); +struct platform_device *pdev =to_platform_device (dev); +struct mfd_cell *cell = (struct mfd_cell *)pdev->dev.platform_data; +struct mmc_host *mmc =platform_get_drvdata (pdev);struct tmio_mmc_host *host =mmc_priv (mmc);int ret =0 ;/* Tell the MFD core we are ready to be enabled */ if (cell->enable) { - ret = cell->enable (dev); + ret = cell->enable (pdev);if (ret) goto out; }@@ -498,16 +500,18 @@ static int tmio_mmc_resume(struct platform_device *dev)/* Enable the MMC/SD Control registers */ sd_config_write16 (host,CNF_CMD ,SDCREN );sd_config_write32 (host,CNF_CTL_BASE , - (dev->resource[0 ].start >> host->bus_shift) &0xfffe ); + (pdev->resource[0 ].start >> host->bus_shift) &0xfffe );mmc_resume_host (mmc); out: return ret; } -#else -#define tmio_mmc_suspend NULL -#define tmio_mmc_resume NULL + +static struct dev_pm_ops tmio_mmc_pm_ops = { + .suspend = tmio_mmc_suspend, + .resume = tmio_mmc_resume, +};#endif static int __devinit tmio_mmc_probe (struct platform_device *dev)@@ -637,13 +641,12 @@ static int __devexit tmio_mmc_remove(struct platform_device *dev)static struct platform_driver tmio_mmc_driver = { .driver = { - .name ="tmio-mmc" , - .owner =THIS_MODULE , + .name ="tmio-mmc" , + .owner =THIS_MODULE , + .pm = &tmio_mmc_pm_ops, }, - .probe = tmio_mmc_probe, - .remove =__devexit_p (tmio_mmc_remove), - .suspend = tmio_mmc_suspend, - .resume = tmio_mmc_resume, + .probe = tmio_mmc_probe, + .remove =__devexit_p (tmio_mmc_remove), };drivers/mmc/host/via-sdmmc.c +1
-1@@ -1280,7 +1280,7 @@ static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state)via_save_pcictrlreg (host);via_save_sdcreg (host); - ret =mmc_suspend_host (host->mmc, state); + ret =mmc_suspend_host (host->mmc);pci_save_state (pcidev);pci_enable_wake (pcidev,pci_choose_state (pcidev, state),0 );drivers/mmc/host/wbsd.c +1
-1@@ -1818,7 +1818,7 @@ static int wbsd_suspend(struct wbsd_host *host, pm_message_t state) {BUG_ON (host ==NULL ); -return mmc_suspend_host (host->mmc, state); +return mmc_suspend_host (host->mmc); }static int wbsd_resume (struct wbsd_host *host)include/linux/mmc/host.h +1
-1@@ -180,7 +180,7 @@ static inline void *mmc_priv(struct mmc_host *host)#define mmc_classdev (x) (&(x)->class_dev)#define mmc_hostname (x) (dev_name(&(x)->class_dev)) -extern int mmc_suspend_host (struct mmc_host *,pm_message_t ); +extern int mmc_suspend_host (struct mmc_host *);extern int mmc_resume_host (struct mmc_host *);extern void mmc_detect_change (struct mmc_host *,unsigned long delay);Signature · 1 line
1.6.3.3
Dne So 22. srpna 2009 10:27:37 Matt Fleming napsal(a):
Quoted 22 lines
(Adding linux-mmc at vger.kernel.org to the CC list)
Quoted 19 lines · Marek Vasut
Hi,
This converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.This needs testing, so I'd be very glad if the affected maintainers expressed their opinion on this.
Cheers!
From
66978eef1d2bd64222901f0b6c6d9c35dcca044eMon Sep 17 00:00:00 2001
From: Marek Vasut <[email protected]>
Date: Sat, 22 Aug 2009 02:10:27 +0200
Subject: [PATCH] Convert MMC subsys drivers todev_pm_opsThis converts most of the drivers found in
drivers/mmc/hosttodev_pm_ops. Also, it contains some fixes for the probe/remove functions in some cases.
Hi.
it might be actually better if you fixed your platforms and submitted the patches independently as it seems you have better understanding of the hardware you maintain ;-)
Cheers!
sorry, there is already quite a big series touching the s3cmci driver in drivers/mmc/host/s3cmci.c which already have this conversion done.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.