From patchwork Wed Nov 9 14:23:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 81491 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp223001qge; Wed, 9 Nov 2016 06:24:18 -0800 (PST) X-Received: by 10.98.198.207 with SMTP id x76mr20329054pfk.33.1478701458792; Wed, 09 Nov 2016 06:24:18 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gv1si35421464pac.69.2016.11.09.06.24.18; Wed, 09 Nov 2016 06:24:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753016AbcKIOYP (ORCPT + 4 others); Wed, 9 Nov 2016 09:24:15 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:61095 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753182AbcKIOYM (ORCPT ); Wed, 9 Nov 2016 09:24:12 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGD0077KPC80440@mailout1.w1.samsung.com>; Wed, 09 Nov 2016 14:24:08 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161109142407eucas1p1d845fb09d1537ef6d37a836847bdb63a~FZyHlqi2Y3108331083eucas1p1Z; Wed, 9 Nov 2016 14:24:07 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 8D.39.02283.78133285; Wed, 9 Nov 2016 14:24:07 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161109142407eucas1p14c59e64f284a9d556a63047295611984~FZyG-BmiJ1372713727eucas1p1r; Wed, 9 Nov 2016 14:24:07 +0000 (GMT) X-AuditID: cbfec7f1-f79f46d0000008eb-e0-58233187fb66 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 72.AE.07726.78133285; Wed, 9 Nov 2016 14:24:07 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGD009LGPC36HB0@eusync2.samsung.com>; Wed, 09 Nov 2016 14:24:07 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Ulf Hansson , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas Subject: [PATCH 01/12] exynos-gsc: Simplify clock management Date: Wed, 09 Nov 2016 15:23:50 +0100 Message-id: <1478701441-29107-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1478701441-29107-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNIsWRmVeSWpSXmKPExsWy7djP87rthsoRBs0/NC02zljPavHm7Rom i/PnN7Bb9GzYymox4/w+Jou1R+6yWxx+085qcXxtuAOHx6ZVnWwed67tYfPY0n+X3aNvyypG j8+b5AJYo7hsUlJzMstSi/TtErgydnY9ZSuYIFHR8XMmcwPjZJEuRk4OCQETiZ+tnxkhbDGJ C/fWs3UxcnEICSxllFg2ZysLhPO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ENvkJE4emwxmcwp4Sqw6chPMFgKq2bp8FuME Rt4FjAyrGEVSS4tz03OLDfWKE3OLS/PS9ZLzczcxAoN627Gfm3cwXtoYfIhRgINRiYe3Q1M5 Qog1say4MvcQowQHs5II70wDoBBvSmJlVWpRfnxRaU5q8SFGU6CjJjJLiSbnAyMuryTe0MTQ 3NLQyNjCwtzISEmct+TDlXAhgfTEktTs1NSC1CKYPiYOTqkGRhO2o3klFqLv/D7vK5G5um56 22nmsHCFM3M9vCUFp6Sl+q3nFLg10adGs2irenjH5kUX5s2bE74wY9n6lWx1m2qvhjowHjre wN394fgKj5I1d9ZWr1KfWPp7skrQfi8nntXLE8+8LV+z/r+6uqp0d/BjR7/t1V1/lSKfBPqW LT9VxruG/VLieiWW4oxEQy3mouJEABbAEASAAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161109142407eucas1p14c59e64f284a9d556a63047295611984 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161109142407eucas1p14c59e64f284a9d556a63047295611984 X-RootMTR: 20161109142407eucas1p14c59e64f284a9d556a63047295611984 References: <1478701441-29107-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org From: Ulf Hansson Instead of having separate functions that fecthes, prepares and unprepares the clock, let's encapsulate this code into ->probe(). This makes error handling easier and decreases the lines of code. Signed-off-by: Ulf Hansson [mszyprow: rebased onto v4.9-rc4] Signed-off-by: Marek Szyprowski --- drivers/media/platform/exynos-gsc/gsc-core.c | 49 ++++++++-------------------- 1 file changed, 14 insertions(+), 35 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index 787bd16..abebbdb 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -988,36 +988,6 @@ static void *gsc_get_drv_data(struct platform_device *pdev) return driver_data; } -static void gsc_clk_put(struct gsc_dev *gsc) -{ - if (!IS_ERR(gsc->clock)) - clk_unprepare(gsc->clock); -} - -static int gsc_clk_get(struct gsc_dev *gsc) -{ - int ret; - - dev_dbg(&gsc->pdev->dev, "gsc_clk_get Called\n"); - - gsc->clock = devm_clk_get(&gsc->pdev->dev, GSC_CLOCK_GATE_NAME); - if (IS_ERR(gsc->clock)) { - dev_err(&gsc->pdev->dev, "failed to get clock~~~: %s\n", - GSC_CLOCK_GATE_NAME); - return PTR_ERR(gsc->clock); - } - - ret = clk_prepare(gsc->clock); - if (ret < 0) { - dev_err(&gsc->pdev->dev, "clock prepare failed for clock: %s\n", - GSC_CLOCK_GATE_NAME); - gsc->clock = ERR_PTR(-EINVAL); - return ret; - } - - return 0; -} - static int gsc_m2m_suspend(struct gsc_dev *gsc) { unsigned long flags; @@ -1085,7 +1055,6 @@ static int gsc_probe(struct platform_device *pdev) init_waitqueue_head(&gsc->irq_queue); spin_lock_init(&gsc->slock); mutex_init(&gsc->lock); - gsc->clock = ERR_PTR(-EINVAL); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); gsc->regs = devm_ioremap_resource(dev, res); @@ -1098,9 +1067,19 @@ static int gsc_probe(struct platform_device *pdev) return -ENXIO; } - ret = gsc_clk_get(gsc); - if (ret) + gsc->clock = devm_clk_get(dev, GSC_CLOCK_GATE_NAME); + if (IS_ERR(gsc->clock)) { + dev_err(dev, "failed to get clock~~~: %s\n", + GSC_CLOCK_GATE_NAME); + return PTR_ERR(gsc->clock); + } + + ret = clk_prepare(gsc->clock); + if (ret) { + dev_err(&gsc->pdev->dev, "clock prepare failed for clock: %s\n", + GSC_CLOCK_GATE_NAME); return ret; + } ret = devm_request_irq(dev, res->start, gsc_irq_handler, 0, pdev->name, gsc); @@ -1135,7 +1114,7 @@ static int gsc_probe(struct platform_device *pdev) err_v4l2: v4l2_device_unregister(&gsc->v4l2_dev); err_clk: - gsc_clk_put(gsc); + clk_unprepare(gsc->clock); return ret; } @@ -1148,7 +1127,7 @@ static int gsc_remove(struct platform_device *pdev) vb2_dma_contig_clear_max_seg_size(&pdev->dev); pm_runtime_disable(&pdev->dev); - gsc_clk_put(gsc); + clk_unprepare(gsc->clock); dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); return 0;