From patchwork Mon Jun 3 06:21:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 2650851 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 281A640D82 for ; Mon, 3 Jun 2013 06:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175Ab3FCGV6 (ORCPT ); Mon, 3 Jun 2013 02:21:58 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:42913 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752539Ab3FCGVz (ORCPT ); Mon, 3 Jun 2013 02:21:55 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MNT009NL0BV9BN0@mailout4.samsung.com>; Mon, 03 Jun 2013 15:21:52 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 22.5F.11618.FF53CA15; Mon, 03 Jun 2013 15:21:51 +0900 (KST) X-AuditID: cbfee691-b7fef6d000002d62-6e-51ac35ff643d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id CA.31.28381.FF53CA15; Mon, 03 Jun 2013 15:21:51 +0900 (KST) Received: from DOJG1HAN03 ([12.23.120.99]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MNT0049I0CF9FY0@mmp2.samsung.com>; Mon, 03 Jun 2013 15:21:51 +0900 (KST) From: Jingoo Han To: "'Rafael J. Wysocki'" Cc: 'Jean-Christophe PLAGNIOL-VILLARD' , 'Lars-Peter Clausen' , 'Michael Hennerich' , 'Tomi Valkeinen' , linux-fbdev@vger.kernel.org, linux-pm@vger.kernel.org, 'Jingoo Han' Subject: [PATCH] PM: Add pm_sleep_ops_ptr() macro Date: Mon, 03 Jun 2013 15:21:51 +0900 Message-id: <002801ce6022$a2928930$e7b79b90$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Content-language: ko Thread-index: Ac5gIo/8gk9HGOCiTmS60jkQrqY7UA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGIsWRmVeSWpSXmKPExsVy+t8zI93/pmsCDW4eMbK4vPASq8WSyfNZ LU70fWC1+Nx7hNFiwuHN7BbrHr5gsuhf2MtksX7+LTYHDo9XVx09Xl24w+Kx5M0hVo++LasY PR4tbmH0OH5jO5PH501yAexRXDYpqTmZZalF+nYJXBmzvj5gLpgsXvFgX0ID42HhLkYODgkB E4lHP7y6GDmBTDGJC/fWs3UxcnEICSxjlPh7eCYTRMJEYtn+74wQiemMEo9b9rJAOL8YJWZ0 3GQFqWITUJP48uUwO8hUEQF1iWMnRUBqmAWWM0m0rnzLAlIjLGAo8eLRRDCbRUBVYs++B4wg 9bwClhLvnqeBhHkFBCV+TL4HVsIsoCWxeVsTK4QtL7F5zVtmiIMUJHacfc0IEReR2PfiHZgt IqAn8amlmxlkr4TAW3aJhWvfM0HsEpD4NvkQC8THshKbDkDNkZQ4uOIGywRGsVlIVs9CsnoW ktWzkKxbwMiyilE0tSC5oDgpvchUrzgxt7g0L10vOT93EyMkTifuYLx/wPoQYzLQ+onMUqLJ +cA4zyuJNzQ2M7IwNTE1NjK3NCNNWEmcV73FOlBIID2xJDU7NbUgtSi+qDQntfgQIxMHp1QD I9+6d9liPs8Ttl3lmuif9PSdzQwFKx5D9awl5nGL/y7//E3k/dO37kpM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fu5ckaCvxFKckWioxVxUnAgAoRXg 6UcDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Add pm_sleep_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM_SLEEP is not enabled. Signed-off-by: Jingoo Han Cc: Jean-Christophe PLAGNIOL-VILLARD Cc: Lars-Peter Clausen Cc: Tomi Valkeinen Cc: Michael Hennerich --- drivers/video/bfin-lq035q1-fb.c | 20 +++++++++++--------- include/linux/pm.h | 6 ++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c index 29d8c04..4474e64 100644 --- a/drivers/video/bfin-lq035q1-fb.c +++ b/drivers/video/bfin-lq035q1-fb.c @@ -170,16 +170,19 @@ static int lq035q1_spidev_remove(struct spi_device *spi) return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT); } -#ifdef CONFIG_PM -static int lq035q1_spidev_suspend(struct spi_device *spi, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int lq035q1_spidev_suspend(struct device *dev) { + struct spi_device *spi = to_spi_device(dev); + return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT); } -static int lq035q1_spidev_resume(struct spi_device *spi) +static int lq035q1_spidev_resume(struct device *dev) { - int ret; + struct spi_device *spi = to_spi_device(dev); struct spi_control *ctl = spi_get_drvdata(spi); + int ret; ret = lq035q1_control(spi, LQ035_DRIVER_OUTPUT_CTL, ctl->mode); if (ret) @@ -187,11 +190,11 @@ static int lq035q1_spidev_resume(struct spi_device *spi) return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_ON); } -#else -# define lq035q1_spidev_suspend NULL -# define lq035q1_spidev_resume NULL #endif +static SIMPLE_DEV_PM_OPS(lq035q1_spidev_pm_ops, lq035q1_spidev_suspend, + lq035q1_spidev_resume); + /* Power down all displays on reboot, poweroff or halt */ static void lq035q1_spidev_shutdown(struct spi_device *spi) { @@ -708,8 +711,7 @@ static int bfin_lq035q1_probe(struct platform_device *pdev) info->spidrv.probe = lq035q1_spidev_probe; info->spidrv.remove = lq035q1_spidev_remove; info->spidrv.shutdown = lq035q1_spidev_shutdown; - info->spidrv.suspend = lq035q1_spidev_suspend; - info->spidrv.resume = lq035q1_spidev_resume; + info->spidrv.driver.pm = pm_sleep_ops_ptr(&lq035q1_spidev_pm_ops); ret = spi_register_driver(&info->spidrv); if (ret < 0) { diff --git a/include/linux/pm.h b/include/linux/pm.h index bd50d15..999d652 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -61,6 +61,12 @@ extern const char power_group_name[]; /* = "power" */ #define pm_ops_ptr(_ptr) NULL #endif +#ifdef CONFIG_PM_SLEEP +#define pm_sleep_ops_ptr(_ptr) (_ptr) +#else +#define pm_sleep_ops_ptr(_ptr) NULL +#endif + typedef struct pm_message { int event; } pm_message_t;