From patchwork Fri Jan 5 00:38:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10145899 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 BF2C260244 for ; Fri, 5 Jan 2018 00:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 020B728882 for ; Fri, 5 Jan 2018 00:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9AC628885; Fri, 5 Jan 2018 00:45:20 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62C8F28882 for ; Fri, 5 Jan 2018 00:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QNLOycl5TX+j69jCQt50Fx1r1L1jChkxQmwbBznZU/A=; b=WQiX/kEvGZzuYQQ1YojlJfezkz KasFLn1gGwlKK66dKc6ocNFMacEXzxSUECy1484a4ythbftqep78h/3pvSIp4BWIvphGz+k8c2Yem 1fohUhm1M4DfPkiCZlW+IhPMYC0GvXzi1QuNaHRoyTCyehbbNAD4EBMdTgdZJ/nr7rR69Ot38HDm2 bEfPo6R8lha8eru0mzmE5U92XVZUlg2Pd/QRBTQmWuTC25Y8GLWtZ7B7Ts+nqq+HazvQ7s7q75vTf x2IxvaAngf+SphUiSrK1lheOVaWtnyIY2JBrwI/aUmMBdHDG106q4sA8NhnYW9ZuFiqrTfL47FZUR 0gLpo28A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eXG8I-0004mp-3e; Fri, 05 Jan 2018 00:45:14 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXG4J-00025m-WB; Fri, 05 Jan 2018 00:41:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wYQOFyBjcrJT1KkXyXyGkYYoAJew9/8ItsU/3tfjFDQ=; b=gTvA8SDjQxjgyl3+JuYdvkm9T 9ebvZ5RFOXxizrjCCTeWsDMEyaV5T8OVz4MNwv727o50eOGOLJK8ghcGX1bK/ckh2JoYwVTCNTbfq ssWw5cRWiTucoK0WIj8/nZqaBX+iU72aDKdWxDQj/v80Ih3JvmP2KJn169frYcjy2Vy0DerNbRRNY tqDXHXYDAWU9437FYMYjdK7mSvbWs6+tQRenuVw3n/4qWftfCGOMxlsuiElMJDwxRU/17UQerj3i0 q7z1HsO7atLyrumRT3l+nQ3aib/cdCmVBqqf/UdUPPR1O9+0OMZ3FJkO0CKuNwrP7VySNf/8BgnPW Ex/kJDQYg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:37626 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1eXG49-003bYU-RA; Thu, 04 Jan 2018 19:40:58 -0500 From: David Lechner To: linux-clk@vger.kernel.org Subject: [PATCH 7/7] clk: sunxi: make use of clk_alloc_onecell_data() Date: Thu, 4 Jan 2018 18:38:12 -0600 Message-Id: <1515112695-3160-8-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515112695-3160-1-git-send-email-david@lechnology.com> References: <1515112695-3160-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180104_164108_887843_4143F6D0 X-CRM114-Status: UNSURE ( 7.83 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Lechner , =?UTF-8?q?Emilio=20L=C3=B3pez?= , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , linux-mediatek@lists.infradead.org, Matthias Brugger , Maxime Ripard , linux-arm-kernel@lists.infradead.org, Heiko Stuebner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data. Signed-off-by: David Lechner --- drivers/clk/sunxi/clk-a10-pll2.c | 14 ++++---------- drivers/clk/sunxi/clk-mod0.c | 13 +++---------- drivers/clk/sunxi/clk-simple-gates.c | 13 +++---------- drivers/clk/sunxi/clk-sun8i-bus-gates.c | 13 +++---------- drivers/clk/sunxi/clk-sunxi.c | 14 ++++---------- drivers/clk/sunxi/clk-usb.c | 8 +------- 6 files changed, 18 insertions(+), 57 deletions(-) diff --git a/drivers/clk/sunxi/clk-a10-pll2.c b/drivers/clk/sunxi/clk-a10-pll2.c index d8eab90..54b8386 100644 --- a/drivers/clk/sunxi/clk-a10-pll2.c +++ b/drivers/clk/sunxi/clk-a10-pll2.c @@ -58,13 +58,11 @@ static void __init sun4i_pll2_setup(struct device_node *node, if (IS_ERR(reg)) return; - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(SUN4I_PLL2_OUTPUTS); if (!clk_data) goto err_unmap; - clks = kcalloc(SUN4I_PLL2_OUTPUTS, sizeof(struct clk *), GFP_KERNEL); - if (!clks) - goto err_free_data; + clks = clk_data->clks; parent = of_clk_get_parent_name(node, 0); prediv_clk = clk_register_divider(NULL, "pll2-prediv", @@ -75,7 +73,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, &sun4i_a10_pll2_lock); if (IS_ERR(prediv_clk)) { pr_err("Couldn't register the prediv clock\n"); - goto err_free_array; + goto err_free_data; } /* Setup the gate part of the PLL2 */ @@ -166,8 +164,6 @@ static void __init sun4i_pll2_setup(struct device_node *node, 2, 1); WARN_ON(IS_ERR(clks[SUN4I_A10_PLL2_8X])); - clk_data->clks = clks; - clk_data->clk_num = SUN4I_PLL2_OUTPUTS; of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); return; @@ -178,10 +174,8 @@ static void __init sun4i_pll2_setup(struct device_node *node, kfree(gate); err_unregister_prediv: clk_unregister_divider(prediv_clk); -err_free_array: - kfree(clks); err_free_data: - kfree(clk_data); + clk_free_onecell_data(clk_data); err_unmap: iounmap(reg); } diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c index 4417ae1..d14c3f1 100644 --- a/drivers/clk/sunxi/clk-mod0.c +++ b/drivers/clk/sunxi/clk-mod0.c @@ -315,18 +315,13 @@ static void __init sunxi_mmc_setup(struct device_node *node, return; } - clk_data = kmalloc(sizeof(*clk_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(3); if (!clk_data) return; - clk_data->clks = kcalloc(3, sizeof(*clk_data->clks), GFP_KERNEL); - if (!clk_data->clks) - goto err_free_data; - - clk_data->clk_num = 3; clk_data->clks[0] = sunxi_factors_register(node, data, lock, reg); if (!clk_data->clks[0]) - goto err_free_clks; + goto err_free_data; parent = __clk_get_name(clk_data->clks[0]); @@ -366,10 +361,8 @@ static void __init sunxi_mmc_setup(struct device_node *node, return; -err_free_clks: - kfree(clk_data->clks); err_free_data: - kfree(clk_data); + clk_free_onecell_data(clk_data); } static DEFINE_SPINLOCK(sun4i_a10_mmc_lock); diff --git a/drivers/clk/sunxi/clk-simple-gates.c b/drivers/clk/sunxi/clk-simple-gates.c index a085c3b..4685358 100644 --- a/drivers/clk/sunxi/clk-simple-gates.c +++ b/drivers/clk/sunxi/clk-simple-gates.c @@ -44,16 +44,12 @@ static void __init sunxi_simple_gates_setup(struct device_node *node, clk_parent = of_clk_get_parent_name(node, 0); - clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL); - if (!clk_data) - goto err_unmap; - number = of_property_count_u32_elems(node, "clock-indices"); of_property_read_u32_index(node, "clock-indices", number - 1, &number); - clk_data->clks = kcalloc(number + 1, sizeof(struct clk *), GFP_KERNEL); - if (!clk_data->clks) - goto err_free_data; + clk_data = clk_alloc_onecell_data(number + 1); + if (!clk_data) + goto err_unmap; of_property_for_each_u32(node, "clock-indices", prop, p, index) { of_property_read_string_index(node, "clock-output-names", @@ -80,13 +76,10 @@ static void __init sunxi_simple_gates_setup(struct device_node *node, } - clk_data->clk_num = number + 1; of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); return; -err_free_data: - kfree(clk_data); err_unmap: iounmap(reg); of_address_to_resource(node, 0, &res); diff --git a/drivers/clk/sunxi/clk-sun8i-bus-gates.c b/drivers/clk/sunxi/clk-sun8i-bus-gates.c index bee305b..f3a3e05 100644 --- a/drivers/clk/sunxi/clk-sun8i-bus-gates.c +++ b/drivers/clk/sunxi/clk-sun8i-bus-gates.c @@ -54,16 +54,12 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node) parents[i] = of_clk_get_parent_name(node, idx); } - clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL); - if (!clk_data) - goto err_unmap; - number = of_property_count_u32_elems(node, "clock-indices"); of_property_read_u32_index(node, "clock-indices", number - 1, &number); - clk_data->clks = kcalloc(number + 1, sizeof(struct clk *), GFP_KERNEL); - if (!clk_data->clks) - goto err_free_data; + clk_data = clk_alloc_onecell_data(number + 1); + if (!clk_data) + goto err_unmap; i = 0; of_property_for_each_u32(node, "clock-indices", prop, p, index) { @@ -98,13 +94,10 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node) } } - clk_data->clk_num = number + 1; of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); return; -err_free_data: - kfree(clk_data); err_unmap: iounmap(reg); of_address_to_resource(node, 0, &res); diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index aa4add5..5a09d35 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -1012,15 +1012,11 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node, return NULL; } - clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(ndivs); if (!clk_data) goto out_unmap; - clks = kcalloc(ndivs, sizeof(*clks), GFP_KERNEL); - if (!clks) - goto free_clkdata; - - clk_data->clks = clks; + clks = clk_data->clks; /* It's not a good idea to have automatic reparenting changing * our RAM clock! */ @@ -1045,7 +1041,7 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node, if (data->div[i].gate) { gate = kzalloc(sizeof(*gate), GFP_KERNEL); if (!gate) - goto free_clks; + goto free_clkdata; gate->reg = reg; gate->bit_idx = data->div[i].gate; @@ -1106,10 +1102,8 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node, return clks; free_gate: kfree(gate); -free_clks: - kfree(clks); free_clkdata: - kfree(clk_data); + clk_free_onecell_data(clk_data); out_unmap: iounmap(reg); return NULL; diff --git a/drivers/clk/sunxi/clk-usb.c b/drivers/clk/sunxi/clk-usb.c index fe0c3d16..4358d33 100644 --- a/drivers/clk/sunxi/clk-usb.c +++ b/drivers/clk/sunxi/clk-usb.c @@ -118,16 +118,10 @@ static void __init sunxi_usb_clk_setup(struct device_node *node, qty = find_last_bit((unsigned long *)&data->clk_mask, SUNXI_USB_MAX_SIZE); - clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(qty + 1); if (!clk_data) return; - clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL); - if (!clk_data->clks) { - kfree(clk_data); - return; - } - for_each_set_bit(i, (unsigned long *)&data->clk_mask, SUNXI_USB_MAX_SIZE) { of_property_read_string_index(node, "clock-output-names",