From patchwork Fri Jan 5 00:38:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10145887 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 C5F9460244 for ; Fri, 5 Jan 2018 00:44:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 096EA28882 for ; Fri, 5 Jan 2018 00:44:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F239C28887; Fri, 5 Jan 2018 00:44:22 +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 D577E28882 for ; Fri, 5 Jan 2018 00:44:21 +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=UCQ0V7GNnU+fBTthto3AK0117cpz2jKXGuBy383YuIg=; b=M2o7l7WwMw2TVyzBaVoKtFDFMa 6eTy4LWX5NHqEM6UqiuFLmzUWocCWyHNEk0ovMAe7V1ScgI8SBfzi5sVxNiikYxMBrBXQR7zc7gc/ 4wYuJFftGhVZhDJxbk4qtMqHUYCCjjt0F6/yVWO+Q0lOhdTw05XCpGF3lsXIKPlGOV6u3bw2uVCXT cFGlG3Ii2d0hbvgAkUiCDt0nfyEPi0wCOmbrsubiXc54bZjz629cIKCwEK5sYBKoDFpdwah5qHasR e05MK1liI10puWzIu3r7xBXj2xsg9iiYKwleQKIlcY98ZkVAHVclK2arhgUvdeNVJ2weuZQCMOE+r tAdI5JDg==; 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 1eXG7M-00046O-TK; Fri, 05 Jan 2018 00:44:16 +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-00022v-WA; Fri, 05 Jan 2018 00:41:23 +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=wJiEul3PY1KBvQzZ3ZYmlT3Q+GtxEag73bmTjy18OCE=; b=KI2VSKAGaLan/gB0ueC/Rohuo v+khXFb7pvHWjd+U5IOynftyxZwVKb3XCLyHfWkkfKG1bM+6YqhVitTolrvjokRYE/7bfb7mA9T4S 2BsoUvDNB1ZtFbTrYBfW7IY6JBDWWb8Vno4j0Y7L1IN7iKfCp433TmzyYXdEJbozItfP0v2h6ycew AjtXNIwU+uT806ZbjKTwIXmK1raUk5qKVw1ZIP6XbApQ1DR4qFpS8pi03iug9KPhsdIAtqYnMLYri eug5ZI94tirf7YN0avmEMk0rBIl+sUvlDxYXHRT944Nndtc1mS42ZqX4TQHmAvdBvKfPyZNSuRyMI i10X1YCQg==; 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 1eXG45-003bYU-0r; Thu, 04 Jan 2018 19:40:53 -0500 From: David Lechner To: linux-clk@vger.kernel.org Subject: [PATCH 6/7] clk: st: make use of clk_alloc_onecell_data() Date: Thu, 4 Jan 2018 18:38:11 -0600 Message-Id: <1515112695-3160-7-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_795403_4981477E X-CRM114-Status: UNSURE ( 8.02 ) 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/st/clk-flexgen.c | 17 +++++------------ drivers/clk/st/clkgen-fsyn.c | 11 +---------- drivers/clk/st/clkgen-pll.c | 12 ++---------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c index 918ba31..29ff00d 100644 --- a/drivers/clk/st/clk-flexgen.c +++ b/drivers/clk/st/clk-flexgen.c @@ -310,7 +310,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) { struct device_node *pnode; void __iomem *reg; - struct clk_onecell_data *clk_data; + struct clk_onecell_data *clk_data = NULL; const char **parents; int num_parents, i; spinlock_t *rlock = NULL; @@ -341,21 +341,15 @@ static void __init st_of_flexgen_setup(struct device_node *np) clk_mode = data->mode; } - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); - if (!clk_data) - goto err; - ret = of_property_count_strings(np, "clock-output-names"); if (ret <= 0) { pr_err("%s: Failed to get number of output clocks (%d)", - __func__, clk_data->clk_num); + __func__, ret); goto err; } - clk_data->clk_num = ret; - clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *), - GFP_KERNEL); - if (!clk_data->clks) + clk_data = clk_alloc_onecell_data(ret); + if (!clk_data) goto err; rlock = kzalloc(sizeof(spinlock_t), GFP_KERNEL); @@ -397,8 +391,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) err: iounmap(reg); - if (clk_data) - kfree(clk_data->clks); + clk_free_onecell_data(clk_data); kfree(clk_data); kfree(parents); kfree(rlock); diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c index 14819d9..48e6bff 100644 --- a/drivers/clk/st/clkgen-fsyn.c +++ b/drivers/clk/st/clkgen-fsyn.c @@ -869,19 +869,10 @@ static void __init st_of_create_quadfs_fsynths( struct clk_onecell_data *clk_data; int fschan; - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(QUADFS_MAX_CHAN); if (!clk_data) return; - clk_data->clk_num = QUADFS_MAX_CHAN; - clk_data->clks = kzalloc(QUADFS_MAX_CHAN * sizeof(struct clk *), - GFP_KERNEL); - - if (!clk_data->clks) { - kfree(clk_data); - return; - } - for (fschan = 0; fschan < QUADFS_MAX_CHAN; fschan++) { struct clk *clk; const char *clk_name; diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c index 25bda48..07795ee 100644 --- a/drivers/clk/st/clkgen-pll.c +++ b/drivers/clk/st/clkgen-pll.c @@ -733,17 +733,10 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, num_odfs = data->num_odfs; - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); + clk_data = clk_alloc_onecell_data(num_odfs); if (!clk_data) return; - clk_data->clk_num = num_odfs; - clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *), - GFP_KERNEL); - - if (!clk_data->clks) - goto err; - for (odf = 0; odf < num_odfs; odf++) { struct clk *clk; const char *clk_name; @@ -768,8 +761,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, err: kfree(pll_name); - kfree(clk_data->clks); - kfree(clk_data); + clk_free_onecell_data(clk_data); } static void __init clkgen_c32_pll0_setup(struct device_node *np) {