From patchwork Mon Aug 27 08:21:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10576611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E11E1803 for ; Mon, 27 Aug 2018 08:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C769294E6 for ; Mon, 27 Aug 2018 08:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 609222994F; Mon, 27 Aug 2018 08:21:43 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0D74F29947 for ; Mon, 27 Aug 2018 08:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbeH0MHR (ORCPT ); Mon, 27 Aug 2018 08:07:17 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35877 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbeH0MHQ (ORCPT ); Mon, 27 Aug 2018 08:07:16 -0400 Received: by mail-wr1-f65.google.com with SMTP id m27-v6so12761750wrf.3 for ; Mon, 27 Aug 2018 01:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=kSA+bUIPd6Kz4LJRN6u2xwlR03fuwZZ0LXX7sehdNQwu33qwmRrZyno38C8pUoZHfw JeAER5jFwAR2r3pHlT72urG7rxpz27ZVMgsenvJk3vF9hJLAVE90j5/OlXAZupc+s3p+ tehRe76aLGrVhr/oZL/mdKoNuNCap/PIrVVcc4VZbZQ26r/dZxUekiJsXE67ET5wIOrG rPaamujN3EOrUS4t/N5dUJLHG7g8pvmO2+8HzrU+Wug2Vqt4WEo9hKOJjigQN8Uv+5Ny zc/DapaghZbfFfpIK7LLFtW/JQNpCfpK1mwPw+wKyo1A/S1BJsrMHK7bgBhmw57NPf9y tqhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=GSqH9TOlcGwZFmM/s0/Y4uHqB8RRlX/wJAzGRPDOyS6Sua6GAuSZ3t/GpcCNCXbzuo kgJf5HrjRVkRj751f2LKrRxZo+Qq7xLj0NezcxDqhTSg16r+VFzuilk2/ZELhJgcAQh/ 4F43StttAAzp8WHQ02D5Zt+K18lbF1netmdQfbld9FZpCdCwzbwFBBP2YJeoiI+7Ei03 qmVNl2lh7XwvhsuKuNmLM2nGPva9UvgKQ+HOKmmzmhfdr9g24ITRmLFJCAixAb4Cx1Z3 EIPymVTCGL84BDVxDgGRUIUqVpxkBBs3ckFuehXHCNUOthw1jTmLpiPns7jmT7B4vgz6 8vAg== X-Gm-Message-State: APzg51BzoUGOML7OTaObMQ+MRzhVaNY6kqdjNznX8SY2IW3a+oZlrzLc Xgs+Ah7uFCFM6qi5ZmgzZUU6BA== X-Google-Smtp-Source: ANB0Vda/wBMEVgVNlmupmmRuXOmBZUZx3pISV5xfHqiKv7wtutnfRK5d+xufRmR7miQhQbIZvZxuAw== X-Received: by 2002:adf:f24e:: with SMTP id b14-v6mr7420220wrp.184.1535358098735; Mon, 27 Aug 2018 01:21:38 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-34-229.w90-86.abo.wanadoo.fr. [90.86.153.229]) by smtp.gmail.com with ESMTPSA id b144-v6sm15402309wmd.23.2018.08.27.01.21.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 01:21:38 -0700 (PDT) From: Bartosz Golaszewski To: Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , "Rafael J . Wysocki" , Arend van Spriel , Ulf Hansson , Bjorn Helgaas , Vivek Gautam , Robin Murphy , Joe Perches , Heikki Krogerus , Andrew Morton , Mike Rapoport , Michal Hocko , Al Viro , Jonathan Corbet , Roman Gushchin , Huang Ying , Kees Cook , Bjorn Andersson Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH 2/2] clk: pmc-atom: use devm_kstrdup_const() Date: Mon, 27 Aug 2018 10:21:01 +0200 Message-Id: <20180827082101.5036-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827082101.5036-1-brgl@bgdev.pl> References: <20180827082101.5036-1-brgl@bgdev.pl> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_kstrdup_const() in the pmc-atom driver. This mostly serves as an example of how to use this new routine to shrink driver code. While we're at it: replace a call to kcalloc() with devm_kcalloc(). Signed-off-by: Bartosz Golaszewski --- drivers/clk/x86/clk-pmc-atom.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c index 08ef69945ffb..daa2192e6568 100644 --- a/drivers/clk/x86/clk-pmc-atom.c +++ b/drivers/clk/x86/clk-pmc-atom.c @@ -253,14 +253,6 @@ static void plt_clk_unregister_fixed_rate_loop(struct clk_plt_data *data, plt_clk_unregister_fixed_rate(data->parents[i]); } -static void plt_clk_free_parent_names_loop(const char **parent_names, - unsigned int i) -{ - while (i--) - kfree_const(parent_names[i]); - kfree(parent_names); -} - static void plt_clk_unregister_loop(struct clk_plt_data *data, unsigned int i) { @@ -286,8 +278,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, if (!data->parents) return ERR_PTR(-ENOMEM); - parent_names = kcalloc(nparents, sizeof(*parent_names), - GFP_KERNEL); + parent_names = devm_kcalloc(&pdev->dev, nparents, + sizeof(*parent_names), GFP_KERNEL); if (!parent_names) return ERR_PTR(-ENOMEM); @@ -300,7 +292,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, err = PTR_ERR(data->parents[i]); goto err_unreg; } - parent_names[i] = kstrdup_const(clks[i].name, GFP_KERNEL); + parent_names[i] = devm_kstrdup_const(&pdev->dev, + clks[i].name, GFP_KERNEL); } data->nparents = nparents; @@ -308,7 +301,6 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, err_unreg: plt_clk_unregister_fixed_rate_loop(data, i); - plt_clk_free_parent_names_loop(parent_names, i); return ERR_PTR(err); } @@ -351,15 +343,12 @@ static int plt_clk_probe(struct platform_device *pdev) goto err_unreg_clk_plt; } - plt_clk_free_parent_names_loop(parent_names, data->nparents); - platform_set_drvdata(pdev, data); return 0; err_unreg_clk_plt: plt_clk_unregister_loop(data, i); plt_clk_unregister_parents(data); - plt_clk_free_parent_names_loop(parent_names, data->nparents); return err; }