From patchwork Mon Feb 19 15:44:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10228115 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 2953E60392 for ; Mon, 19 Feb 2018 15:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A32328987 for ; Mon, 19 Feb 2018 15:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E168289F0; Mon, 19 Feb 2018 15:46:31 +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 91B7828987 for ; Mon, 19 Feb 2018 15:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753059AbeBSPqN (ORCPT ); Mon, 19 Feb 2018 10:46:13 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57043 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752602AbeBSPpK (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 20180219154507euoutp019c84ca9ebf5a0f91e92bfdcf2fbc9d17~UxJJw-GOP0897708977euoutp01h; Mon, 19 Feb 2018 15:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180219154507euoutp019c84ca9ebf5a0f91e92bfdcf2fbc9d17~UxJJw-GOP0897708977euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519055107; bh=BKZVSW9rKnlCooUcFSnAt+FN3LbSM5setXULzYcKVIU=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=gwedf3RpLLz8lZYQhvjjeibdp81/5iKK/A4drQaaOvmeCW1586686mUiR/Kty5WDW kyakAXEAtGsOnaQ2YjKm5DKsz9Ybz4TsNrdqmpVVDhYFD1rwGy2DVpwxcC4+GBsZtJ /zkssR4ecKBxBl5s61L9GZBGrmSYrSsalejP2KmQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154505eucas1p1ebe67b2809e54cda09b6d41d36c66692~UxJHq2jy41661616616eucas1p1h; Mon, 19 Feb 2018 15:45:05 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 46.CB.17380.FF0FA8A5; Mon, 19 Feb 2018 15:45:03 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154501eucas1p1e16a883d2eb0c8a99bafce5d71656066~UxJERlmkl0552305523eucas1p1f; Mon, 19 Feb 2018 15:45:01 +0000 (GMT) X-AuditID: cbfec7f4-b4fc79c0000043e4-67-5a8af0ff4669 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FA.1D.04183.DF0FA8A5; Mon, 19 Feb 2018 15:45:01 +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:01 +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 6/8] drm/exynos/hdmi: Use clk bulk API Date: Mon, 19 Feb 2018 16:44:04 +0100 Message-id: <1519055046-2399-7-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: H4sIAAAAAAAAAzWSe0hTURzHPbtPzdVlGh00jYZCFNmDHgeKSjO4f0REfxQMSldeVHTLtuxl pBNsejO1lWlWzkAslpZO3XKl5XzMik2WtmxmFlFpKnP5oIdorqv/fc738fudA4fGJB1ECJ2s PM2plPJUKRmAmzp/O9bPjfOyjZ6xSOR+5CDQVcdLESob1uKorvQxgXqnPCQav3YLIM99nkS6 wSIc9TfW4mh0rFqE2mveitDQRyeObnVpCVT4ZQRD3d21FLJnj1LI+MVFIG/+RwL1WO6QKL+2 kUCl3S0iZC1uBqhi2I2jmvYBClUZZ0TI+WofahudHzLrqsNR6fVhEk280GF7wtkelxNjPX05 FHvjbx3BNpUNUKzRkEey5ulPBDt4xSZi6ysz2YbCeb2gwQDYCWM429uuoQ4GygJ2JnCpyWc4 1YZd8QFJ/MOveFpvxDmj4QOWBQbDeOBPQ2YLbHF5SR4E0BLmAYB6nR0IhwkAh7vbicWUu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4lMIDaL gKrE2Y/n2EF6eQWcJb7MVYTYJSdx81wn2C5OAReJB7v3skHsdZY4f/8S2wRGngWMDKsYRVJL i3PTc4uN9IoTc4tL89L1kvNzNzECI2zbsZ9bdjB2vQs+xCjAwajEwytwtytKiDWxrLgy9xCj BAezkgivzw2gEG9KYmVValF+fFFpTmrxIUZpDhYlcd7zBpVRQgLpiSWp2ampBalFMFkmDk6p Bkav0h930i2dGLrm8mRtf/3w0ZPsJ9oJcTkTa3L87y6V1vf1sFQ/tXGjw0bL3pJfq9zbJi/h X/GlWUbEtndv2zXuUypzrae6xFrsZcpNiPjzg6fjSXGd+KLF1UETAwO79Q4cU9lS4MbErdXq 8LJG6YmL0iJO6Ze3Kqe8ULNiPlP6Lqp80mErFiWW4oxEQy3mouJEAJBFq2ysAgAA X-CMS-MailID: 20180219154501eucas1p1e16a883d2eb0c8a99bafce5d71656066 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180219154501eucas1p1e16a883d2eb0c8a99bafce5d71656066 X-RootMTR: 20180219154501eucas1p1e16a883d2eb0c8a99bafce5d71656066 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/gpu/drm/exynos/exynos_hdmi.c | 97 ++++++++++-------------------------- 1 file changed, 27 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index a4b75a4..6c208f7 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -136,8 +136,8 @@ struct hdmi_context { int irq; struct regmap *pmureg; struct regmap *sysreg; - struct clk **clk_gates; - struct clk **clk_muxes; + struct clk_bulk_data *clk_gates; + struct clk_bulk_data *clk_muxes; struct regulator_bulk_data regul_bulk[ARRAY_SIZE(supply)]; struct regulator *reg_hdmi_en; struct exynos_drm_clk phy_clk; @@ -739,43 +739,16 @@ static int hdmiphy_reg_write_buf(struct hdmi_context *hdata, } } -static int hdmi_clk_enable_gates(struct hdmi_context *hdata) -{ - int i, ret; - - for (i = 0; i < hdata->drv_data->clk_gates.count; ++i) { - ret = clk_prepare_enable(hdata->clk_gates[i]); - if (!ret) - continue; - - dev_err(hdata->dev, "Cannot enable clock '%s', %d\n", - hdata->drv_data->clk_gates.data[i], ret); - while (i--) - clk_disable_unprepare(hdata->clk_gates[i]); - return ret; - } - - return 0; -} - -static void hdmi_clk_disable_gates(struct hdmi_context *hdata) -{ - int i = hdata->drv_data->clk_gates.count; - - while (i--) - clk_disable_unprepare(hdata->clk_gates[i]); -} - static int hdmi_clk_set_parents(struct hdmi_context *hdata, bool to_phy) { struct device *dev = hdata->dev; int ret = 0; + struct clk_bulk_data *clk_muxes = hdata->clk_muxes; int i; for (i = 0; i < hdata->drv_data->clk_muxes.count; i += 3) { - struct clk **c = &hdata->clk_muxes[i]; - - ret = clk_set_parent(c[2], c[to_phy]); + ret = clk_set_parent(clk_muxes[i + 2].clk, + clk_muxes[i + to_phy].clk); if (!ret) continue; @@ -1655,54 +1628,36 @@ static irqreturn_t hdmi_irq_thread(int irq, void *arg) return IRQ_HANDLED; } -static int hdmi_clks_get(struct hdmi_context *hdata, - const struct string_array_spec *names, - struct clk **clks) +static struct clk_bulk_data *hdmi_clks_alloc_get(struct hdmi_context *hdata, + const struct string_array_spec *names) { - struct device *dev = hdata->dev; - int i; - - for (i = 0; i < names->count; ++i) { - struct clk *clk = devm_clk_get(dev, names->data[i]); - - if (IS_ERR(clk)) { - int ret = PTR_ERR(clk); + struct clk_bulk_data *ptr; + int ret; - dev_err(dev, "Cannot get clock %s, %d\n", - names->data[i], ret); + ptr = devm_clk_bulk_alloc(hdata->dev, names->count, names->data); + if (IS_ERR(ptr)) + return ptr; - return ret; - } - - clks[i] = clk; - } + ret = devm_clk_bulk_get(hdata->dev, names->count, ptr); + if (ret < 0) + return ERR_PTR(ret); - return 0; + return ptr; } static int hdmi_clk_init(struct hdmi_context *hdata) { const struct hdmi_driver_data *drv_data = hdata->drv_data; - int count = drv_data->clk_gates.count + drv_data->clk_muxes.count; - struct device *dev = hdata->dev; - struct clk **clks; - int ret; - if (!count) - return 0; - - clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL); - if (!clks) - return -ENOMEM; + hdata->clk_muxes = hdmi_clks_alloc_get(hdata, &drv_data->clk_muxes); + if (IS_ERR(hdata->clk_muxes)) + return PTR_ERR(hdata->clk_muxes); - hdata->clk_gates = clks; - hdata->clk_muxes = clks + drv_data->clk_gates.count; + hdata->clk_gates = hdmi_clks_alloc_get(hdata, &drv_data->clk_gates); + if (IS_ERR(hdata->clk_gates)) + return PTR_ERR(hdata->clk_gates); - ret = hdmi_clks_get(hdata, &drv_data->clk_gates, hdata->clk_gates); - if (ret) - return ret; - - return hdmi_clks_get(hdata, &drv_data->clk_muxes, hdata->clk_muxes); + return 0; } @@ -2073,7 +2028,8 @@ static int __maybe_unused exynos_hdmi_suspend(struct device *dev) { struct hdmi_context *hdata = dev_get_drvdata(dev); - hdmi_clk_disable_gates(hdata); + clk_bulk_disable_unprepare(hdata->drv_data->clk_gates.count, + hdata->clk_gates); return 0; } @@ -2083,7 +2039,8 @@ static int __maybe_unused exynos_hdmi_resume(struct device *dev) struct hdmi_context *hdata = dev_get_drvdata(dev); int ret; - ret = hdmi_clk_enable_gates(hdata); + ret = clk_bulk_prepare_enable(hdata->drv_data->clk_gates.count, + hdata->clk_gates); if (ret < 0) return ret;