From patchwork Thu Feb 17 07:49:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 570771 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1HGpOZj001708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 17 Feb 2011 16:51:44 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p1HGnKYh024315; Thu, 17 Feb 2011 08:49:22 -0800 Received: from eu1sys200aog101.obsmtp.com (eu1sys200aog101.obsmtp.com [207.126.144.111]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with SMTP id p1H7pG5k005849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 16 Feb 2011 23:51:19 -0800 Received: from source ([138.198.100.35]) (using TLSv1) by eu1sys200aob101.postini.com ([207.126.147.11]) with SMTP ID DSNKTVzTStUwq95guLp/+Od+YHVkzarkL0F8@postini.com; Thu, 17 Feb 2011 07:51:22 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id A2115DF; Thu, 17 Feb 2011 07:50:07 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8129793B; Thu, 17 Feb 2011 07:50:06 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id AD09B24C2E7; Thu, 17 Feb 2011 08:50:01 +0100 (CET) Received: from localhost (10.201.54.153) by exdcvycastm022.EQ1STM.local (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.2.254.0; Thu, 17 Feb 2011 08:50:05 +0100 From: Rabin Vincent To: Date: Thu, 17 Feb 2011 13:19:46 +0530 Message-ID: <1297928986-31171-1-git-send-email-rabin.vincent@stericsson.com> X-Mailer: git-send-email 1.7.2.dirty MIME-Version: 1.0 Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-5.801 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 X-Mailman-Approved-At: Thu, 17 Feb 2011 08:49:19 -0800 Cc: Rabin Vincent , Takashi Iwai , Dmitry Torokhov , Grant Likely , linux-pm@lists.linux-foundation.org, Chris Ball , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Subject: [linux-pm] [PATCH] amba: move to pm ops X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Feb 2011 16:51:54 +0000 (UTC) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index ca96b0a..402b07e 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include -#define to_amba_device(d) container_of(d, struct amba_device, dev) #define to_amba_driver(d) container_of(d, struct amba_driver, drv) static struct amba_id * @@ -57,26 +57,6 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env) #define amba_uevent NULL #endif -static int amba_suspend(struct device *dev, pm_message_t state) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - int ret = 0; - - if (dev->driver && drv->suspend) - ret = drv->suspend(to_amba_device(dev), state); - return ret; -} - -static int amba_resume(struct device *dev) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - int ret = 0; - - if (dev->driver && drv->resume) - ret = drv->resume(to_amba_device(dev)); - return ret; -} - #define amba_attr_func(name,fmt,arg...) \ static ssize_t name##_show(struct device *_dev, \ struct device_attribute *attr, char *buf) \ @@ -111,8 +91,7 @@ struct bus_type amba_bustype = { .dev_attrs = amba_dev_attrs, .match = amba_match, .uevent = amba_uevent, - .suspend = amba_suspend, - .resume = amba_resume, + .pm = GENERIC_SUBSYS_PM_OPS, }; static int __init amba_init(void) diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index 92563a6..c710437 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -176,15 +176,22 @@ static int __devexit amba_kmi_remove(struct amba_device *dev) return 0; } -static int amba_kmi_resume(struct amba_device *dev) +#ifdef CONFIG_PM_SLEEP +static int amba_kmi_resume(struct device *dev) { - struct amba_kmi_port *kmi = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct amba_kmi_port *kmi = amba_get_drvdata(adev); /* kick the serio layer to rescan this port */ serio_reconnect(kmi->io); return 0; } +#else +#define amba_kmi_resume NULL +#endif + +static SIMPLE_DEV_PM_OPS(amba_kmi_pm, NULL, amba_kmi_resume); static struct amba_id amba_kmi_idtable[] = { { @@ -198,11 +205,11 @@ static struct amba_driver ambakmi_driver = { .drv = { .name = "kmi-pl050", .owner = THIS_MODULE, + .pm = &amba_kmi_pm, }, .id_table = amba_kmi_idtable, .probe = amba_kmi_probe, .remove = __devexit_p(amba_kmi_remove), - .resume = amba_kmi_resume, }; static int __init amba_kmi_init(void) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 8a29c9f..18e142b 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1236,10 +1236,11 @@ static int __devexit mmci_remove(struct amba_device *dev) return 0; } -#ifdef CONFIG_PM -static int mmci_suspend(struct amba_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int mmci_suspend(struct device *dev) { - struct mmc_host *mmc = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct mmc_host *mmc = amba_get_drvdata(adev); int ret = 0; if (mmc) { @@ -1253,9 +1254,10 @@ static int mmci_suspend(struct amba_device *dev, pm_message_t state) return ret; } -static int mmci_resume(struct amba_device *dev) +static int mmci_resume(struct device *dev) { - struct mmc_host *mmc = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct mmc_host *mmc = amba_get_drvdata(adev); int ret = 0; if (mmc) { @@ -1273,6 +1275,8 @@ static int mmci_resume(struct amba_device *dev) #define mmci_resume NULL #endif +static SIMPLE_DEV_PM_OPS(mmci_pm, mmci_suspend, mmci_resume); + static struct amba_id mmci_ids[] = { { .id = 0x00041180, @@ -1306,11 +1310,10 @@ static struct amba_id mmci_ids[] = { static struct amba_driver mmci_driver = { .drv = { .name = DRIVER_NAME, + .pm = &mmci_pm, }, .probe = mmci_probe, .remove = __devexit_p(mmci_remove), - .suspend = mmci_suspend, - .resume = mmci_resume, .id_table = mmci_ids, }; diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c index 71a1219..eb16ea5 100644 --- a/drivers/spi/amba-pl022.c +++ b/drivers/spi/amba-pl022.c @@ -2184,9 +2184,10 @@ pl022_remove(struct amba_device *adev) return 0; } -#ifdef CONFIG_PM -static int pl022_suspend(struct amba_device *adev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int pl022_suspend(struct device *dev) { + struct amba_device *adev = to_amba_device(dev); struct pl022 *pl022 = amba_get_drvdata(adev); int status = 0; @@ -2203,8 +2204,9 @@ static int pl022_suspend(struct amba_device *adev, pm_message_t state) return 0; } -static int pl022_resume(struct amba_device *adev) +static int pl022_resume(struct device *dev) { + struct amba_device *adev = to_amba_device(dev); struct pl022 *pl022 = amba_get_drvdata(adev); int status = 0; @@ -2220,7 +2222,9 @@ static int pl022_resume(struct amba_device *adev) #else #define pl022_suspend NULL #define pl022_resume NULL -#endif /* CONFIG_PM */ +#endif + +static SIMPLE_DEV_PM_OPS(pl022_pm, pl022_suspend, pl022_resume); static struct vendor_data vendor_arm = { .fifodepth = 8, @@ -2284,12 +2288,11 @@ static struct amba_id pl022_ids[] = { static struct amba_driver pl022_driver = { .drv = { .name = "ssp-pl022", + .pm = &pl022_pm, }, .id_table = pl022_ids, .probe = pl022_probe, .remove = __devexit_p(pl022_remove), - .suspend = pl022_suspend, - .resume = pl022_resume, }; diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 2904aa0..5e0e62f 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -757,9 +757,11 @@ static int pl010_remove(struct amba_device *dev) return 0; } -static int pl010_suspend(struct amba_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int pl010_suspend(struct device *dev) { - struct uart_amba_port *uap = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct uart_amba_port *uap = amba_get_drvdata(adev); if (uap) uart_suspend_port(&amba_reg, &uap->port); @@ -767,15 +769,22 @@ static int pl010_suspend(struct amba_device *dev, pm_message_t state) return 0; } -static int pl010_resume(struct amba_device *dev) +static int pl010_resume(struct device *dev) { - struct uart_amba_port *uap = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct uart_amba_port *uap = amba_get_drvdata(adev); if (uap) uart_resume_port(&amba_reg, &uap->port); return 0; } +#else +#define pl010_suspend NULL +#define pl010_resume NULL +#endif + +static SIMPLE_DEV_PM_OPS(pl010_pm, pl010_suspend, pl010_resume); static struct amba_id pl010_ids[] = { { @@ -788,12 +797,11 @@ static struct amba_id pl010_ids[] = { static struct amba_driver pl010_driver = { .drv = { .name = "uart-pl010", + .pm = &pl010_pm, }, .id_table = pl010_ids, .probe = pl010_probe, .remove = pl010_remove, - .suspend = pl010_suspend, - .resume = pl010_resume, }; static int __init pl010_init(void) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index e76d7d0..52a5e18 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1438,10 +1438,11 @@ static int pl011_remove(struct amba_device *dev) return 0; } -#ifdef CONFIG_PM -static int pl011_suspend(struct amba_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int pl011_suspend(struct device *dev) { - struct uart_amba_port *uap = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct uart_amba_port *uap = amba_get_drvdata(adev); if (!uap) return -EINVAL; @@ -1449,17 +1450,23 @@ static int pl011_suspend(struct amba_device *dev, pm_message_t state) return uart_suspend_port(&amba_reg, &uap->port); } -static int pl011_resume(struct amba_device *dev) +static int pl011_resume(struct device *dev) { - struct uart_amba_port *uap = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct uart_amba_port *uap = amba_get_drvdata(adev); if (!uap) return -EINVAL; return uart_resume_port(&amba_reg, &uap->port); } +#else +#define pl011_suspend NULL +#define pl011_resume NULL #endif +static SIMPLE_DEV_PM_OPS(pl011_pm, pl011_suspend, pl011_resume); + static struct amba_id pl011_ids[] = { { .id = 0x00041011, @@ -1477,14 +1484,11 @@ static struct amba_id pl011_ids[] = { static struct amba_driver pl011_driver = { .drv = { .name = "uart-pl011", + .pm = &pl011_pm, }, .id_table = pl011_ids, .probe = pl011_probe, .remove = pl011_remove, -#ifdef CONFIG_PM - .suspend = pl011_suspend, - .resume = pl011_resume, -#endif }; static int __init pl011_init(void) diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index a0ccf28..2f48827 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -46,8 +46,6 @@ struct amba_driver { int (*probe)(struct amba_device *, struct amba_id *); int (*remove)(struct amba_device *); void (*shutdown)(struct amba_device *); - int (*suspend)(struct amba_device *, pm_message_t); - int (*resume)(struct amba_device *); struct amba_id *id_table; }; @@ -58,6 +56,8 @@ enum amba_vendor { extern struct bus_type amba_bustype; +#define to_amba_device(d) container_of(d, struct amba_device, dev) + #define amba_get_drvdata(d) dev_get_drvdata(&d->dev) #define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index af5a152..040c5f0 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -35,7 +35,7 @@ /* * PM support is not complete. Turn it off. */ -#undef CONFIG_PM +#undef CONFIG_PM_SLEEP static void aaci_ac97_select_codec(struct aaci *aaci, struct snd_ac97 *ac97) { @@ -752,7 +752,7 @@ static struct snd_pcm_ops aaci_capture_ops = { /* * Power Management. */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int aaci_do_suspend(struct snd_card *card, unsigned int state) { struct aaci *aaci = card->private_data; @@ -767,15 +767,17 @@ static int aaci_do_resume(struct snd_card *card, unsigned int state) return 0; } -static int aaci_suspend(struct amba_device *dev, pm_message_t state) +static int aaci_suspend(struct device *dev) { - struct snd_card *card = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct snd_card *card = amba_get_drvdata(adev); return card ? aaci_do_suspend(card) : 0; } -static int aaci_resume(struct amba_device *dev) +static int aaci_resume(struct device *dev) { - struct snd_card *card = amba_get_drvdata(dev); + struct amba_device *adev = to_amba_device(dev); + struct snd_card *card = amba_get_drvdata(adev); return card ? aaci_do_resume(card) : 0; } #else @@ -785,6 +787,7 @@ static int aaci_resume(struct amba_device *dev) #define aaci_resume NULL #endif +static SIMPLE_DEV_PM_OPS(aaci_pm, aaci_suspend, aaci_resume); static struct ac97_pcm ac97_defs[] __devinitdata = { [0] = { /* Front PCM */ @@ -1099,11 +1102,10 @@ static struct amba_id aaci_ids[] = { static struct amba_driver aaci_driver = { .drv = { .name = DRIVER_NAME, + .pm = &aaci_pm, }, .probe = aaci_probe, .remove = __devexit_p(aaci_remove), - .suspend = aaci_suspend, - .resume = aaci_resume, .id_table = aaci_ids, };