From patchwork Mon Feb 19 15:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10228069 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 D4D5E60467 for ; Mon, 19 Feb 2018 15:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4AA927B81 for ; Mon, 19 Feb 2018 15:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B80A128987; Mon, 19 Feb 2018 15:45:12 +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 5DE7F286C1 for ; Mon, 19 Feb 2018 15:45:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C748A89DB8; Mon, 19 Feb 2018 15:45:07 +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 9C76789DB8 for ; Mon, 19 Feb 2018 15:45:05 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180219154503euoutp01e6a00a0bf5d355875958a63ffc9fd0f7~UxJFpZ3hR0897708977euoutp01d; Mon, 19 Feb 2018 15:45:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180219154503euoutp01e6a00a0bf5d355875958a63ffc9fd0f7~UxJFpZ3hR0897708977euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519055103; bh=WBeR0eStCQOm+OO9HuZVqzzTf26osRQOuRL/ic1Jqqk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=Wrwv1aJiYOFyYxqdhTRii/T5QD1dwk8Q16xmio5fpagtqx0OJrv8BbGsN7D6J9/Ma +PaqA/0dfTA7lj3Anc483rIVnPCICYbkiKW7p5YdsZfB3SUcMu5G+rB+HlS6q8xKw4 DONiFhXx+2TWXFrdRWWrp6yCNImE5stvEPqOJJ0E= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154500eucas1p1144299fc539177d55792d3d1ec697b9e~UxJDet-xB1661216612eucas1p1c; Mon, 19 Feb 2018 15:45:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E4.C8.05700.BF0FA8A5; Mon, 19 Feb 2018 15:44:59 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180219154457eucas1p163264992903698a8878aa5abbc8aa17b~UxJABi1Ab1792217922eucas1p1c; Mon, 19 Feb 2018 15:44:57 +0000 (GMT) X-AuditID: cbfec7f2-5ffe19c000011644-48-5a8af0fb6cec Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 20.DB.04178.9F0FA8A5; Mon, 19 Feb 2018 15:44:57 +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:44:57 +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 2/8] media: s5p-jpeg: Use bulk clk API Date: Mon, 19 Feb 2018 16:44:00 +0100 Message-id: <1519055046-2399-3-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: H4sIAAAAAAAAAzWSe0iTURjGO99dcXKY0g6WRqOiBDPD6nTBbgYfJBHUPw26rPxSyVltXiqt 1CzdyktW3iqxKAuv25qVitGmuLJyWSle8gJ2cWWpW3YVbXP63+88z/O+D+dwOFJspn24qJhY QRkjj5Yy7tTD5j+WgH+jGtmK4usS3F3VSuPM1ucELrKmU1hXUE3jd+MjDB69XAjwyD0Ng3P7 cyjcU6Ol8PC3CgI3VbYTeKivjcKFz9JpnD34lcQWi5bFr1KHWawf7KDx2KU+Gr+tu8HgS9oa GhdYnhDYdK0B4BJrN4Urm3pZXKqfIHBbyzbcOOxYMtmho3DBFSuD7U9zyU1+/NuONpIf6TzP 8lf/6Wi+tqiX5fVlaoZ/9HOA5vsvmgn+wZ2zvCHboWcZygBv1/vx75pS2J0eMvcN4UJ0VLyg DAw54B5ZZrPRxz75nhgst1DJ4A3SADcOwWBUOnqOcLIY3gdIO+CvAe4OtgOkSztPzoYmjFrC ZZQClJ01BVyHKYBemP+wGsBxDPRHFen7nQPesBmg4towZ4aEP1mU89cInIYXXI2qBm/STqbg YqT90TddLYJb0W9DO+tq80NdrerpZjcYigbqGxjnIgQ7WDT2vXwmFIoKbl+kXeyFvpgNM/p8 pM4wE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2gc2WTjBhuGgCNAWk IjFt1cgkOKcSsuUmwFCo1E8cP+NR4iQuO4dXZCQolGm8YAL7KUy6T2wOz5ZJ6GQui7/B85m8 4n+KUD7+uYCzRakih0JOBMWUV0fZ3aF/irbaZX3bNXA4dvSodrdq9EuXct2R6Aox9G405o1s Oecq43pfrM2GtVzptk3dOqz9emDp0CY9I1ToS5curx7pYQI7rssCtZUNd85pLu2RX3Zd6B48 ppbFicHCVVHzwyfvDYZ38XU57jLT6c/3opOkmJDCRQSjCoH7C+Xv4JWuAgAA X-CMS-MailID: 20180219154457eucas1p163264992903698a8878aa5abbc8aa17b X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180219154457eucas1p163264992903698a8878aa5abbc8aa17b X-RootMTR: 20180219154457eucas1p163264992903698a8878aa5abbc8aa17b 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/media/platform/s5p-jpeg/jpeg-core.c | 45 ++++++++++++----------------- drivers/media/platform/s5p-jpeg/jpeg-core.h | 2 +- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 79b63da..681a515 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2903,7 +2903,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) { struct s5p_jpeg *jpeg; struct resource *res; - int i, ret; + int ret; /* JPEG IP abstraction struct */ jpeg = devm_kzalloc(&pdev->dev, sizeof(struct s5p_jpeg), GFP_KERNEL); @@ -2938,15 +2938,16 @@ static int s5p_jpeg_probe(struct platform_device *pdev) } /* clocks */ - for (i = 0; i < jpeg->variant->num_clocks; i++) { - jpeg->clocks[i] = devm_clk_get(&pdev->dev, - jpeg->variant->clk_names[i]); - if (IS_ERR(jpeg->clocks[i])) { - dev_err(&pdev->dev, "failed to get clock: %s\n", - jpeg->variant->clk_names[i]); - return PTR_ERR(jpeg->clocks[i]); - } - } + jpeg->clocks = devm_clk_bulk_alloc(&pdev->dev, + jpeg->variant->num_clocks, + jpeg->variant->clk_names); + if (IS_ERR(jpeg->clocks)) + return PTR_ERR(jpeg->clocks); + + ret = devm_clk_bulk_get(&pdev->dev, jpeg->variant->num_clocks, + jpeg->clocks); + if (ret < 0) + return ret; /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); @@ -3047,7 +3048,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev) static int s5p_jpeg_remove(struct platform_device *pdev) { struct s5p_jpeg *jpeg = platform_get_drvdata(pdev); - int i; pm_runtime_disable(jpeg->dev); @@ -3058,8 +3058,8 @@ static int s5p_jpeg_remove(struct platform_device *pdev) v4l2_device_unregister(&jpeg->v4l2_dev); if (!pm_runtime_status_suspended(&pdev->dev)) { - for (i = jpeg->variant->num_clocks - 1; i >= 0; i--) - clk_disable_unprepare(jpeg->clocks[i]); + clk_bulk_disable_unprepare(jpeg->variant->num_clocks, + jpeg->clocks); } return 0; @@ -3069,10 +3069,8 @@ static int s5p_jpeg_remove(struct platform_device *pdev) static int s5p_jpeg_runtime_suspend(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); - int i; - for (i = jpeg->variant->num_clocks - 1; i >= 0; i--) - clk_disable_unprepare(jpeg->clocks[i]); + clk_bulk_disable_unprepare(jpeg->variant->num_clocks, jpeg->clocks); return 0; } @@ -3081,16 +3079,11 @@ static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); unsigned long flags; - int i, ret; - - for (i = 0; i < jpeg->variant->num_clocks; i++) { - ret = clk_prepare_enable(jpeg->clocks[i]); - if (ret) { - while (--i >= 0) - clk_disable_unprepare(jpeg->clocks[i]); - return ret; - } - } + int ret; + + ret = clk_bulk_prepare_enable(jpeg->variant->num_clocks, jpeg->clocks); + if (ret) + return ret; spin_lock_irqsave(&jpeg->slock, flags); diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h index a46465e..dc6ed98 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h @@ -133,7 +133,7 @@ struct s5p_jpeg { void __iomem *regs; unsigned int irq; enum exynos4_jpeg_result irq_ret; - struct clk *clocks[JPEG_MAX_CLOCKS]; + struct clk_bulk_data *clocks; struct device *dev; struct s5p_jpeg_variant *variant; u32 irq_status;