Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5641655imm; Mon, 27 Aug 2018 01:23:02 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbk4Yo1tCdSP18rcYG+aMy2f1jbqX2BRDWWuB1HuhjqDEWO4f7gZdMq44SNm1+pqrHxNfrf X-Received: by 2002:a65:4285:: with SMTP id j5-v6mr3489048pgp.446.1535358182027; Mon, 27 Aug 2018 01:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535358181; cv=none; d=google.com; s=arc-20160816; b=zhpXVoq9mIQZ74iDCx7YV76q0cELAvBNFUhXfKADLLEUKT3Hyazr6SqJVe0P0uAsMr 8JegCR4ssm6A3/Qr1KX/Ned1EYhajTf8GxdV6rPxuXcRuPOcnaWCoXZYsbqARSp3bIJH sqe9WrWpv1EHoz2A1j8ug7jJkveECw3eYvnjQDvy9V98vLABm1exLfFOjDgZXHitRp3p H9PWIJDG/opxlaMGTN1nF7MSs2yJaDy/xKURSzWPY0onwK+IPAjE5zCohpz8xbjTKdQG 8RW6anywUFJ9EqIOZNu4u/LHHFpURuEE3rfN52MEh38L2LYGCy8nYitc13MjZBhAZqSq Mpyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=jHYqNbjaoVR9fJelMiH4k9e1f5IPEX7y+X9h+DStLxo3jRy143CpA8lgliom8X/6ws e+xr8XzyVs6JOyAQJnFyxjCG5+dcGuvkmf3v51wHVDo+5mv51cNOP9Q7cnpIEOdi1Oyg +UFOClzAge76nTJW5UBTlX8OOTCCTKGrMlUzMFegmEie5Zt3rXMpJDzN7JKYwlHVV4lg Rel+SEsPDyoZ8Nz9tFd7mexRraqMtGvT4vS1qyF2nPPMCU8iveAVxqH8Y2H1Sx1fMigK O6hTleuQI6iTMbwp76n826dMHCzBM6iwiWbVyxTBS6BEDoCR6PhxuktMyvt0TopbkFGz BZ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kSA+bUIP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3-v6si13883045plc.50.2018.08.27.01.22.46; Mon, 27 Aug 2018 01:23:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kSA+bUIP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbeH0MHR (ORCPT + 99 others); Mon, 27 Aug 2018 08:07:17 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41005 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbeH0MHQ (ORCPT ); Mon, 27 Aug 2018 08:07:16 -0400 Received: by mail-wr1-f68.google.com with SMTP id z96-v6so12751554wrb.8 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=DP1OqS3jQskRmvq1PLGS76H2TSUui5mjvIn3NC/ke4KkE+1RtXEXPYQqoiDPcY60b0 zYZHZWmL9fv+ohsSEqEw4hALoxJaRN/x9dxjsDUDV3fNEn1hVC+VNdOXtkwENuSKaQq6 hArPM2oqiKbNKGzijj553uSkGofGHmNgdeElz5DrCHqYXJlUvivH7DU/Jnmxjx2bLYQQ FEsrPMu5/pQtY2pgfNNd7hL1gx9aiWsIShUZ3Y3jwnwNn7HFxlFZXfKec6TUN67kwZiD NGhD2RbfTThpwTrgS4RQ9G9zn80e0IwyL5YCW8xT49d8UHb4G7NJK1syBBWurLpwqOFj i5Zg== X-Gm-Message-State: APzg51BsK21F5jpP6meA1fTZ2gCo4mz/BnXIhGZZKYiz6yTF6k6Ztz6e Tyk+VVqGWlX7EA87qJSY+yeCBw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.18.0