Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2368291imm; Mon, 24 Sep 2018 03:12:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV61kHwuzgOhb6DHmAiK/DvpZLqQJL9nNqwdLHnOPhK+TJfhPuk3em5GlP1oPM12OHTESuPxW X-Received: by 2002:a17:902:290a:: with SMTP id g10-v6mr9973749plb.110.1537783962843; Mon, 24 Sep 2018 03:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537783962; cv=none; d=google.com; s=arc-20160816; b=zA/OXerByNR/YKGME2GnCDdFeIMtRnb19bKsukb0Zij5tJ9feiN6YirW0Vpqdb2pMI dLxj9qcqP9frwCth/qaY+Crwm+k8muTY5XQNMgsDf827dqWQRQEQAZCYj7mKRdSQgaBi kHp5GtJKdw3fk9POoK6uNZ6DREgFbkej0rVGxnGZ7RmBujHuGSQgNaZEvnNvHNyBBwVB YrHkAfaOz/qLFwj7lVYvQLqZObaPWeXmAdbpAAKOhcNlMutJnQGu5dEnqWOp6VbIAEsm nPeGRVlaMHBGX8L9Y21+y4xPL/mfivMnbH3Z+4jc9GDSyMKJBgI/7mvKTB5VOUYpOT88 m5YA== 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; bh=jLISmJc2dPUxbBj3RDyXz5hdQLm9DxNuC15aZU3ms6g=; b=LD5Y6+l2m7aEnCoWkqv6IKYGdc4SJh+bNHjSVgU0Ss6XKLYgEFufSTZZB1jlDuse4Q zJggqNjACEnsGq6dl2BqrxgOxlTiHs3Oz7temSmfXKoN0ILSLkfC4p1BCywAzcKd8haB 2VMyAPQIBvT3PNanxGCnAdRO4eob3uBRjHpiHJe4Oub0un53W/e7P6eMkAKCkwpn9puo ZFp6t6mHP1Ha82BclqZTmh0xXwwMtbW9MyHG8oE9FzNgqqWPrGI62SjGi3Br/dXRQXje JDbsPZrAgbiO1lIZKQgpc9V4733h1b8FAJl59SWDSEh6M7PvXrf8Zgfv1EzK5WXud4GO R7Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=BDV7axJa; 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 91-v6si33652482ply.405.2018.09.24.03.12.27; Mon, 24 Sep 2018 03:12:42 -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=BDV7axJa; 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 S1728635AbeIXQNa (ORCPT + 99 others); Mon, 24 Sep 2018 12:13:30 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42052 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728624AbeIXQN3 (ORCPT ); Mon, 24 Sep 2018 12:13:29 -0400 Received: by mail-wr1-f67.google.com with SMTP id b11-v6so2857353wru.9 for ; Mon, 24 Sep 2018 03:12:09 -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=jLISmJc2dPUxbBj3RDyXz5hdQLm9DxNuC15aZU3ms6g=; b=BDV7axJatr4Cp/LBdA1G+Vka0/jKPXb00CWdvOX431pLfQhTXSlFx6jbCOJK3Ajxor Wl9GQa5xgfkoKGBjNNdbYM3/72d+n77JH9SdjDJkKEPrG+f7+SOp8Zr/0Ki/H9YFJ3eT EoPuOWVQbC044VSDjJDLe9cOXRc5aAoF0MkrNyYqVkOTT/JKGmOdqZ9ZdlB6OK4YUknR okBgcDquosDFY3+hUcLNBsDEK5HH9XJdgjApl2acAeurJHFFd7zl2Z1xzn9YBaaYWHj7 CTPBqInRbHes4J3J2Kd0+c5iyc0t+tnQ1/UHcyKScX2Lo+6njEHfYSxi7cUg2Ol/xTzk pKOw== 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=jLISmJc2dPUxbBj3RDyXz5hdQLm9DxNuC15aZU3ms6g=; b=tvRg2TLJY2U+iR/QhJ0sGC5uQgExDrgsUJEijdgOx5JpCDZNR/E2k4nbxmwfKYBMmI JeYNb8zkfs5QL3hV+N7e5+aWLmACjjkrbfMruVpIq14WTapfE7IAFClu+tpng6QyhVAp HMFIes8qpmbtrnMiG3ItloSfOldU0HeBfcIng1EznMUuDspL0XjPFFVA4Hj/gdmsMo1y b3r2yvozfvvbc07p50GNiN6b7kzOqv9XC4qstLK5JacTwwxcQovcQmpKUSt7NT2hzGLt ww0icQcTO4SM6kNVJ78stJYu+FO9symFWcgydhC36yBko40fWqdbd7p74jodI1ZRjMDH FncQ== X-Gm-Message-State: ABuFfoiviPb/goycMyhS8MgzOkvAiuwbMKq3DpKfeLeXEbYiYOvlsAeL EcDIq16XVl7ZXuSmatIgm8d4fw== X-Received: by 2002:a5d:5009:: with SMTP id e9-v6mr8199080wrt.18.1537783928856; Mon, 24 Sep 2018 03:12:08 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-2-33.w90-86.abo.wanadoo.fr. [90.86.1.33]) by smtp.gmail.com with ESMTPSA id o12-v6sm3291728wrj.58.2018.09.24.03.12.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Sep 2018 03:12:08 -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 , Andy Shevchenko Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v3 4/4] clk: pmc-atom: use devm_kstrdup_const() Date: Mon, 24 Sep 2018 12:11:50 +0200 Message-Id: <20180924101150.23349-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180924101150.23349-1-brgl@bgdev.pl> References: <20180924101150.23349-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 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 d977193842df..239197799ea3 100644 --- a/drivers/clk/x86/clk-pmc-atom.c +++ b/drivers/clk/x86/clk-pmc-atom.c @@ -247,14 +247,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) { @@ -280,8 +272,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); @@ -294,7 +286,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; @@ -302,7 +295,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); } @@ -352,8 +344,6 @@ static int plt_clk_probe(struct platform_device *pdev) goto err_drop_mclk; } - plt_clk_free_parent_names_loop(parent_names, data->nparents); - platform_set_drvdata(pdev, data); return 0; @@ -362,7 +352,6 @@ static int plt_clk_probe(struct platform_device *pdev) 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