From patchwork Fri Aug 9 19:24:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 2842088 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2332BF546 for ; Fri, 9 Aug 2013 19:25:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D03820270 for ; Fri, 9 Aug 2013 19:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34E8720263 for ; Fri, 9 Aug 2013 19:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030816Ab3HITZb (ORCPT ); Fri, 9 Aug 2013 15:25:31 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:24108 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030789Ab3HITZ3 (ORCPT ); Fri, 9 Aug 2013 15:25:29 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MRA00L8Y3AFU320@mailout2.samsung.com>; Sat, 10 Aug 2013 04:25:28 +0900 (KST) X-AuditID: cbfee61a-b7f196d000007dfa-15-52054227823f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 80.F9.32250.72245025; Sat, 10 Aug 2013 04:25:27 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MRA006PU38GMW10@mmp1.samsung.com>; Sat, 10 Aug 2013 04:25:27 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: a.hajda@samsung.com, arun.kk@samsung.com, linux-samsung-soc@vger.kernel.org, Tomasz Figa , Sylwester Nawrocki , Kyungmin Park Subject: [PATCH 03/10] exynos4-is: Handle suspend/resume of fimc-is-i2c correctly Date: Fri, 09 Aug 2013 21:24:05 +0200 Message-id: <1376076252-30150-3-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1376076252-30150-1-git-send-email-s.nawrocki@samsung.com> References: <1376076122-29963-1-git-send-email-s.nawrocki@samsung.com> <1376076252-30150-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42I5/e+xgK66E2uQwfyXVha31p1jtfh46jar xdmmN+wWPRu2slrMOL+PyeLwm3ZWi/UzXrM4sHv0bVnF6PF5k1wAUxSXTUpqTmZZapG+XQJX RndDacFCoYqHc5QaGM/zdzFyckgImEgsOvSICcIWk7hwbz1bFyMXh5DAIkaJFT9bmSCcDiaJ G13XwarYBAwleo/2MYLYIgLyEk96b4B1MAucZ5SY0P8GLCEsECyx8tcCZhCbRUBV4t+zL+xd jBwcvAJuEi+Pq4GYEgIKEnMm2YBUcAq4S0x6NJsNxBYSaGaUePNBeQIj7wJGhlWMoqkFyQXF Sem5hnrFibnFpXnpesn5uZsYwSHzTGoH48oGi0OMAhyMSjy8E36xBAmxJpYVV+YeYpTgYFYS 4X3NxRokxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdAq3WgkEB6YklqdmpqQWoRTJaJg1OqgTHy Hue9dIX257HfXs5+FffsYubJ5oRret5RE6Nveb3qavQ78W7q7/i+1fy1Dx6xquqHv5xmFD9v eZdYgkrHH8knXwTjBOLjWDZMlfZlnxQQt2bCJmXNpKJkiaBFp7YVrODL6ZgisuvPBK3EC1N9 Fdzt7yj/6dHaIRkpfD+Tr3CuHjMbd/0fMSWW4oxEQy3mouJEAJEA6DAVAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tomasz Figa If the same callbacks are used for runtime and system suspend/resume, clocks can get disabled twice, which can lead to negative reference counts and kernel warnings. This patch splits suspend/resume callbacks into separate runtime and system-wide functions, so clock gating is done correctly. Signed-off-by: Tomasz Figa Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/exynos4-is/fimc-is-i2c.c | 33 ++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c index 617a798..6bc481a 100644 --- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c +++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c @@ -83,21 +83,46 @@ static int fimc_is_i2c_remove(struct platform_device *pdev) return 0; } -static int fimc_is_i2c_suspend(struct device *dev) +#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) +static int fimc_is_i2c_runtime_suspend(struct device *dev) { struct fimc_is_i2c *isp_i2c = dev_get_drvdata(dev); + clk_disable_unprepare(isp_i2c->clock); return 0; } -static int fimc_is_i2c_resume(struct device *dev) +static int fimc_is_i2c_runtime_resume(struct device *dev) { struct fimc_is_i2c *isp_i2c = dev_get_drvdata(dev); + return clk_prepare_enable(isp_i2c->clock); } +#endif -static UNIVERSAL_DEV_PM_OPS(fimc_is_i2c_pm_ops, fimc_is_i2c_suspend, - fimc_is_i2c_resume, NULL); +#ifdef CONFIG_PM_SLEEP +static int fimc_is_i2c_suspend(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return fimc_is_i2c_runtime_suspend(dev); +} + +static int fimc_is_i2c_resume(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return fimc_is_i2c_runtime_resume(dev); +} +#endif + +static struct dev_pm_ops fimc_is_i2c_pm_ops = { + SET_RUNTIME_PM_OPS(fimc_is_i2c_runtime_suspend, + fimc_is_i2c_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(fimc_is_i2c_suspend, fimc_is_i2c_resume) +}; static const struct of_device_id fimc_is_i2c_of_match[] = { { .compatible = FIMC_IS_I2C_COMPATIBLE },