From patchwork Mon Feb 19 15:44:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10228125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5954260392 for ; Mon, 19 Feb 2018 15:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48E61286C1 for ; Mon, 19 Feb 2018 15:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D3F5289E7; Mon, 19 Feb 2018 15:46:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29BE286C1 for ; Mon, 19 Feb 2018 15:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbeBSPqM (ORCPT ); Mon, 19 Feb 2018 10:46:12 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57059 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbeBSPpK (ORCPT ); Mon, 19 Feb 2018 10:45:10 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180219154508euoutp01a751069217df79f214678ba66fc96c64~UxJKfY_Vl0858208582euoutp016; Mon, 19 Feb 2018 15:45:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180219154508euoutp01a751069217df79f214678ba66fc96c64~UxJKfY_Vl0858208582euoutp016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519055108; bh=bkmIFiS+7+s9bt3zbHq8PD2U7EWX+JfmlnxSf4du1/U=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=hdU4wfZBYW+NiKATm4+esa4GSvgY4FBZFwpd8vZmMRGoE8fn1FEDFjnUqs7+P8tsr uRnOGDJjkk1bJ0WcEprTImeN9rDekBuJigImuMBkf3ZdIrbuS2+IW5JEg5UNHIcGEs X5vyTDozNUduOadoSvREWhm0TnblaAUZwhf0JNIQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154506eucas1p1144a9fdd1cc8cdff391747a58fe02fe9~UxJImN14H0552805528eucas1p10; Mon, 19 Feb 2018 15:45:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id EE.C8.05700.001FA8A5; Mon, 19 Feb 2018 15:45:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180219154502eucas1p20e8daf3edc6737817f8d62db5a2099f2~UxJFPyzL90490004900eucas1p2y; Mon, 19 Feb 2018 15:45:02 +0000 (GMT) X-AuditID: cbfec7f2-5ffe19c000011644-5d-5a8af1006e01 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 36.DB.04178.EF0FA8A5; Mon, 19 Feb 2018 15:45:02 +0000 (GMT) Received: from AMDC2075.DIGITAL.local ([106.120.51.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4E00C9VMEN0Z00@eusync4.samsung.com>; Mon, 19 Feb 2018 15:45:02 +0000 (GMT) From: Maciej Purski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , David Airlie , Kukjin Kim , Krzysztof Kozlowski , Mauro Carvalho Chehab , Andrzej Pietrasiewicz , Jacek Anaszewski , Kamil Debski , Jeongtae Park , Andrzej Hajda , Russell King , Sylwester Nawrocki , Thibault Saunier , Javier Martinez Canillas , Hans Verkuil , Hoegeun Kwon , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Maciej Purski Subject: [PATCH 7/8] [media] exynos-gsc: Use clk bulk API Date: Mon, 19 Feb 2018 16:44:05 +0100 Message-id: <1519055046-2399-8-git-send-email-m.purski@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1519055046-2399-1-git-send-email-m.purski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0iTURzGPe9dc3aYRgezBSMphczID6cL0RXeDxJ9iIwF2soXtXTqll20 iwq6XJrLFKd0mWEaYqXLS2qWruGlaKIuSXOr0EBLW0600qi2Xv32nOf5nef/P3A4UtpNB3IJ qjOCWqVMlDM+VFPXr75NXjM6RXjLfAgeeWSlcYG1l8Dlk1oK1xse09g252Tw9xtlADurdQwu +qCn8PvGOgpPTdcS2PLwLYEnHP0ULuvR0rhw7CuJ+/rqWPwme4rFprEhGs/kO2g82HqLwfl1 jTQ29D0nsLmkHWDj5AiFH1rsLK4y/SZw/6sD+OWUu+TPUD2FDTcnGTzbUUTulvGDQ/0k73yX w/LFi/U031JuZ3lTTR7DN89/pPkP17oJ/knlFb6h0O1fb6gB/KxJxtssWewhX4XPzlghMeGs oN6867hPvOu+kU55JD9fMK6jM8HtIB3w5hCMQC5HM6kDPpwUPgCotzGXEg+zAGX/mGCXqU/a CkIMqgCyG1xL1F+ADE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EXiwe69bCC2EFDN+fuX2CYw8ixgZFjFKJJa WpybnltsqFecmFtcmpeul5yfu4kRGGXbjv3cvIPx0sbgQ4wCHIxKPLwCd7uihFgTy4orcw8x SnAwK4nw+twACvGmJFZWpRblxxeV5qQWH2KU5mBREuc9b1AZJSSQnliSmp2aWpBaBJNl4uCU amBkl4qu/XWtgSNTWPjSI+kja7y4oyQFFbdkbt7Qoj2r7shrN6W/p5dOybBVUUmtdpA81v5P TWE3R4CahbCdVd7UDycM2rdE681zjvR6I3tc07OaffKOc6cC1x663/tnRfTPFo7pB67KuE8z so7N2Fx2jfPKxvLyyc1tbz0XnqyqDrs86ZRNmrMSS3FGoqEWc1FxIgCEqztrrgIAAA== X-CMS-MailID: 20180219154502eucas1p20e8daf3edc6737817f8d62db5a2099f2 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180219154502eucas1p20e8daf3edc6737817f8d62db5a2099f2 X-RootMTR: 20180219154502eucas1p20e8daf3edc6737817f8d62db5a2099f2 References: <1519055046-2399-1-git-send-email-m.purski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using bulk clk functions simplifies the driver's code. Use devm_clk_bulk functions instead of iterating over an array of clks. Signed-off-by: Maciej Purski --- drivers/media/platform/exynos-gsc/gsc-core.c | 55 ++++++++++------------------ drivers/media/platform/exynos-gsc/gsc-core.h | 2 +- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index 17854a3..fa7e993 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -1149,7 +1149,6 @@ static int gsc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; const struct gsc_driverdata *drv_data = of_device_get_match_data(dev); int ret; - int i; gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL); if (!gsc) @@ -1187,25 +1186,19 @@ static int gsc_probe(struct platform_device *pdev) return -ENXIO; } - for (i = 0; i < gsc->num_clocks; i++) { - gsc->clock[i] = devm_clk_get(dev, drv_data->clk_names[i]); - if (IS_ERR(gsc->clock[i])) { - dev_err(dev, "failed to get clock: %s\n", - drv_data->clk_names[i]); - return PTR_ERR(gsc->clock[i]); - } - } + gsc->clocks = devm_clk_bulk_alloc(dev, gsc->num_clocks, + drv_data->clk_names); + if (IS_ERR(gsc->clocks)) + return PTR_ERR(gsc->clocks); - for (i = 0; i < gsc->num_clocks; i++) { - ret = clk_prepare_enable(gsc->clock[i]); - if (ret) { - dev_err(dev, "clock prepare failed for clock: %s\n", - drv_data->clk_names[i]); - while (--i >= 0) - clk_disable_unprepare(gsc->clock[i]); - return ret; - } - } + ret = devm_clk_bulk_get(dev, gsc->num_clocks, + gsc->clocks); + if (ret) + return ret; + + ret = clk_bulk_prepare_enable(gsc->num_clocks, gsc->clocks); + if (ret) + return ret; ret = devm_request_irq(dev, res->start, gsc_irq_handler, 0, pdev->name, gsc); @@ -1239,15 +1232,14 @@ static int gsc_probe(struct platform_device *pdev) err_v4l2: v4l2_device_unregister(&gsc->v4l2_dev); err_clk: - for (i = gsc->num_clocks - 1; i >= 0; i--) - clk_disable_unprepare(gsc->clock[i]); + clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks); + return ret; } static int gsc_remove(struct platform_device *pdev) { struct gsc_dev *gsc = platform_get_drvdata(pdev); - int i; pm_runtime_get_sync(&pdev->dev); @@ -1255,8 +1247,7 @@ static int gsc_remove(struct platform_device *pdev) v4l2_device_unregister(&gsc->v4l2_dev); vb2_dma_contig_clear_max_seg_size(&pdev->dev); - for (i = 0; i < gsc->num_clocks; i++) - clk_disable_unprepare(gsc->clock[i]); + clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks); pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -1307,18 +1298,12 @@ static int gsc_runtime_resume(struct device *dev) { struct gsc_dev *gsc = dev_get_drvdata(dev); int ret = 0; - int i; pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state); - for (i = 0; i < gsc->num_clocks; i++) { - ret = clk_prepare_enable(gsc->clock[i]); - if (ret) { - while (--i >= 0) - clk_disable_unprepare(gsc->clock[i]); - return ret; - } - } + ret = clk_bulk_prepare_enable(gsc->num_clocks, gsc->clocks); + if (ret) + return ret; gsc_hw_set_sw_reset(gsc); gsc_wait_reset(gsc); @@ -1331,14 +1316,12 @@ static int gsc_runtime_suspend(struct device *dev) { struct gsc_dev *gsc = dev_get_drvdata(dev); int ret = 0; - int i; ret = gsc_m2m_suspend(gsc); if (ret) return ret; - for (i = gsc->num_clocks - 1; i >= 0; i--) - clk_disable_unprepare(gsc->clock[i]); + clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks); pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state); return ret; diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h index 715d9c9d..08ff7b9 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.h +++ b/drivers/media/platform/exynos-gsc/gsc-core.h @@ -334,7 +334,7 @@ struct gsc_dev { struct gsc_variant *variant; u16 id; int num_clocks; - struct clk *clock[GSC_MAX_CLOCKS]; + struct clk_bulk_data *clocks; void __iomem *regs; wait_queue_head_t irq_queue; struct gsc_m2m_device m2m;