From patchwork Mon Feb 19 15:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10228071 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 9346660392 for ; Mon, 19 Feb 2018 15:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82BCD27B81 for ; Mon, 19 Feb 2018 15:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7694628987; Mon, 19 Feb 2018 15:45:14 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A10A27B81 for ; Mon, 19 Feb 2018 15:45:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8317B883C5; Mon, 19 Feb 2018 15:45:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 821A289DD3 for ; Mon, 19 Feb 2018 15:45:08 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180219154506euoutp01975445ecd9b9ff9010bf02f17a1a5fef~UxJIVVaWE0858208582euoutp013; Mon, 19 Feb 2018 15:45:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180219154506euoutp01975445ecd9b9ff9010bf02f17a1a5fef~UxJIVVaWE0858208582euoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519055106; bh=AmhzNKGMlnbctYfqszu5s38S6Cd0JoeGyXFshw4khTU=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=kQ1GPfStMB+5e/mqejSuUggV1WaesThmZulLwyQAeb3ZrDce8fItyF0aTSEIMiROR aUsuTb3i2mGv5Q6tLoZfi0NNLPaCU0GEPKiUteIHlS7/He7JVgZs/w6KuOnRX5ckFo NVrtXxCMIi3ZspDtgMAxl9M4WDqPKJsazKhFfplA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154504eucas1p14fa00972895ed464c44eb3fb22d3add6~UxJGhsXiE1022110221eucas1p1H; Mon, 19 Feb 2018 15:45:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id EB.C8.05700.EF0FA8A5; Mon, 19 Feb 2018 15:45:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180219154500eucas1p25e9f3bf44901cb2bbe9720cdc5bdd855~UxJDN6bvJ0919109191eucas1p23; Mon, 19 Feb 2018 15:45:00 +0000 (GMT) X-AuditID: cbfec7f2-5ffe19c000011644-56-5a8af0fe8a02 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 73.DB.04178.CF0FA8A5; Mon, 19 Feb 2018 15:45:00 +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:00 +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 Subject: [PATCH 5/8] drm/exynos: mic: Use clk bulk API Date: Mon, 19 Feb 2018 16:44:03 +0100 Message-id: <1519055046-2399-6-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: H4sIAAAAAAAAAzWSa0iTYRTHe967w+nLNH2w8sMiCCNLiHqwCKMLLyFdoIsYpFNfNNJpm1pe smmkbVnqKrzQxUjNptM5nbdYF1vTFBVrmc3UQLqYlppoZaFtvvbtd875n//hHA6DS16QPswp eSKvkMtipZSIaLT+7t24MKUJ3axSr0b2mh4SXe15iaGSsRwC1RXVksg2O0mhqYJigCYfaCik Hckn0KDJQKCJb9UYsujfYOjLcB+BijtySJQ3Oo6j3l4DjbqzJmhkHO0n0XTuMIlet96iUK7B RKKi3scYartpBqh0zE4gvWWIRhXGvxjq69yLnk84TBb66whUdH2MQjNPtXiQL/e6vw/nJgcu 0dyNP3Uk11IyRHNGnZrimuY+kNzIlXaMqy+7wDXkOfLXGnSAmzH6cjZLJn3INVS0I4qPPZXM KzbtDBfFaAzlZMJ7r3PZv21ABcolGsAwkN0Cr1iOa4CIkbCVAI6WmEgNcHEEMwCWmc462amZ y67EBFEFgHkdtuVgEcAW8yvc6USxfrA6J8zZ4MlaAbzTEuzU4OwcDfPnnwFnwYPdCtVWFeZk gl0H389/WmIxuxsO1ubjwjRf+K5HvcQu7B744ZGZchpBtp+GhiEjKYj2wI+Vv4DAHvBrewMt 8GqovvwMEzgN9s22UgKnw8x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wA5oC CrGEXhKypLhKx+vVdsBQqEImuTAfUJIclf4WpynK1mgLON4OIilMES5xxumzpHSuqpS7wXHF nOb/FaFCIgyAV3j25cLl78blnHvJau/6iN6VXqmzRMkyJJ/CM9fPhSpht2XiaOOM8sFkW8Sw kB6mOx2z63SqXdrS7KjPId60rk0wkOlvvV7va6iNqLmSNnos9Ky5No+sStn67X9XMiogj8Ut lxLJuQR0sNf483ZSapRjJ7LRnN8+QpwoUWB8nio+GtXwqr/GywcirQIAAA== X-CMS-MailID: 20180219154500eucas1p25e9f3bf44901cb2bbe9720cdc5bdd855 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180219154500eucas1p25e9f3bf44901cb2bbe9720cdc5bdd855 X-RootMTR: 20180219154500eucas1p25e9f3bf44901cb2bbe9720cdc5bdd855 References: <1519055046-2399-1-git-send-email-m.purski@samsung.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Michael Turquette , Kamil Debski , Maciej Purski , Sylwester Nawrocki , Marek Szyprowski , Thibault Saunier , Russell King , Krzysztof Kozlowski , Javier Martinez Canillas , Kukjin Kim , Hoegeun Kwon , Bartlomiej Zolnierkiewicz , Jeongtae Park , Jacek Anaszewski , Andrzej Pietrasiewicz , Mauro Carvalho Chehab , Stephen Boyd , Seung-Woo Kim , Hans Verkuil , Kyungmin Park MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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/gpu/drm/exynos/exynos_drm_mic.c | 41 +++++++++++---------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c index 2174814..276558a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_mic.c +++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c @@ -88,7 +88,7 @@ #define MIC_BS_SIZE_2D(x) ((x) & 0x3fff) -static char *clk_names[] = { "pclk_mic0", "sclk_rgb_vclk_to_mic0" }; +static const char *const clk_names[] = { "pclk_mic0", "sclk_rgb_vclk_to_mic0" }; #define NUM_CLKS ARRAY_SIZE(clk_names) static DEFINE_MUTEX(mic_mutex); @@ -96,7 +96,7 @@ struct exynos_mic { struct device *dev; void __iomem *reg; struct regmap *sysreg; - struct clk *clks[NUM_CLKS]; + struct clk_bulk_data *clks; bool i80_mode; struct videomode vm; @@ -338,10 +338,8 @@ static const struct component_ops exynos_mic_component_ops = { static int exynos_mic_suspend(struct device *dev) { struct exynos_mic *mic = dev_get_drvdata(dev); - int i; - for (i = NUM_CLKS - 1; i > -1; i--) - clk_disable_unprepare(mic->clks[i]); + clk_bulk_disable_unprepare(NUM_CLKS, mic->clks); return 0; } @@ -349,19 +347,8 @@ static int exynos_mic_suspend(struct device *dev) static int exynos_mic_resume(struct device *dev) { struct exynos_mic *mic = dev_get_drvdata(dev); - int ret, i; - - for (i = 0; i < NUM_CLKS; i++) { - ret = clk_prepare_enable(mic->clks[i]); - if (ret < 0) { - DRM_ERROR("Failed to enable clock (%s)\n", - clk_names[i]); - while (--i > -1) - clk_disable_unprepare(mic->clks[i]); - return ret; - } - } - return 0; + + return clk_bulk_prepare_enable(NUM_CLKS, mic->clks); } #endif @@ -374,7 +361,7 @@ static int exynos_mic_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct exynos_mic *mic; struct resource res; - int ret, i; + int ret; mic = devm_kzalloc(dev, sizeof(*mic), GFP_KERNEL); if (!mic) { @@ -405,16 +392,16 @@ static int exynos_mic_probe(struct platform_device *pdev) goto err; } - for (i = 0; i < NUM_CLKS; i++) { - mic->clks[i] = devm_clk_get(dev, clk_names[i]); - if (IS_ERR(mic->clks[i])) { - DRM_ERROR("mic: Failed to get clock (%s)\n", - clk_names[i]); - ret = PTR_ERR(mic->clks[i]); - goto err; - } + mic->clks = devm_clk_bulk_alloc(dev, NUM_CLKS, clk_names); + if (IS_ERR(mic->clks)) { + ret = PTR_ERR(mic->clks); + goto err; } + ret = devm_clk_bulk_get(dev, NUM_CLKS, mic->clks); + if (ret < 0) + goto err; + platform_set_drvdata(pdev, mic); mic->bridge.funcs = &mic_bridge_funcs;