From patchwork Tue Aug 28 09:33:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10578103 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 B859A920 for ; Tue, 28 Aug 2018 09:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7EB82910D for ; Tue, 28 Aug 2018 09:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 980C4293BB; Tue, 28 Aug 2018 09:43:33 +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 43CBB2910D for ; Tue, 28 Aug 2018 09:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727201AbeH1NeV (ORCPT ); Tue, 28 Aug 2018 09:34:21 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41371 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727162AbeH1NeV (ORCPT ); Tue, 28 Aug 2018 09:34:21 -0400 Received: by mail-wr1-f65.google.com with SMTP id z96-v6so929533wrb.8 for ; Tue, 28 Aug 2018 02:43:31 -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=p//iCCA1MuEaI2HpuhoGbJeHcq2jmfgPJ3XDrG/O5LZF3RXf2wsubecp6Goz7f0o79 LzT65i1lmWoaar1tB5UxTxjHYLeLVHrvQscb6ydeLJHCsQEC69i39aaxHAOKVE1CKahY 0m9Ms8Rx7z5+D6L0OSVn9vhev1b0VzkzfM2hrtrjE+pygIscDuYgdSobWncG3TQ7++De sD6EF5qddYdMx2C+2m+idpSPuNykz0yd5T2H8HNxVmT7wG1hwYOhg8Dyg+E1NitcTEm1 xEWToxnbd0MTBOykkCMbKgEEowFIq/mwptYz6+dx0HFbepSNxia95yLEO1YoSRRJiJ0/ KiIg== 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=f/eVuye3/xuAlXQhG0j74/TSiisc+4HqImSyYHCkklovdO+8VHpXVL8FVdQOBP3sVu Yk82bPv62kgWNT9KlgbrszZL15mpwJh9CnaWoJL/wnjoiTD8QbqJ6u1dKyaQynBPgdK+ EDfH9czpq9FSsn9H/y7TtE1P6mK03IR0wvhtWxAPGY8bgN3j2DxqUTFamtXYpAvZ3357 qR6U4JuOhbyE9AfLCzTT8K41DAUSvAgbhiSXaS/8UTLuGLWo8l4dUVIuQH9N3dbM3A2Y Kgvsr/+R7IF+dde5xbpEGs1m7zx5RU6QRB3Lj+OZafb0Xnm9tBQFM1vHtYPz4rw6Q3ZB 3QHQ== X-Gm-Message-State: APzg51AcsQ6gI0C8cwgGU4KpPgWk7cx6u5pM6etWoegQqLnJJzHhEVq6 mUnbN/UhyyLEdgoBIOu4MHFddg== X-Google-Smtp-Source: ANB0Vdb1z1itApQb6iLVseTRPyo4shStOLvpCOq0LLmwi14Xk+YVt9l+6hKfzi1quea3dB05Pl4LFQ== X-Received: by 2002:adf:9d1c:: with SMTP id k28-v6mr604790wre.104.1535448851396; Tue, 28 Aug 2018 02:34:11 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l18-v6sm952276wru.75.2018.08.28.02.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:34:10 -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 , Arnd Bergmann Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v2 4/4] clk: pmc-atom: use devm_kstrdup_const() Date: Tue, 28 Aug 2018 11:33:32 +0200 Message-Id: <20180828093332.20674-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828093332.20674-1-brgl@bgdev.pl> References: <20180828093332.20674-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 Reviewed-by: Stephen Boyd Reviewed-by: Bjorn Andersson --- 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; }