From patchwork Sat Nov 18 07:55:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 166461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1047771vqn; Fri, 17 Nov 2023 23:59:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyr/WF6fCgdRcAM6C6sEhRmF8Ev8H/onH69TOXBsEZAgldG6UAZEWNVXbZO1iE66zfaWwY X-Received: by 2002:a05:6871:278a:b0:1f4:d1f3:6b18 with SMTP id zd10-20020a056871278a00b001f4d1f36b18mr1130979oab.34.1700294364234; Fri, 17 Nov 2023 23:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700294364; cv=none; d=google.com; s=arc-20160816; b=pjHRXJrt2web1hzISLlfPVw+AGmw82OmBXBYmjjXqxVTrV+EAwLv8rRovA3v4Wtb2v oDIPo94q2/5Suvml+l4bN4HRe80wXQ0gl99RdaUemEfDL0jcwLVPuq30q9MVNA46+iVJ IuL4Faq7Vdm9/67351odHDeNcKvx/HocA/7Nj2zfC9dqw07Nu5zSE2BajWAc0dOuaQbc /RFqccsPlMtpOgNPpbc6Ju5JH7xaDuGqwBHz/u6audA3q/PEwOFiL2/Gikor7/ZHbKiq 6X1SrytSUJkfmTeop/3cNMJ/D+uLEcaP31AOX7jmQjOKdiM+0YIC8dnvdzyOunccZ3aV 0UvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=V9Th/4FKB+iHrGZuL+784CAl/VlpMqyAVTrSivrk2DI=; fh=Sow5ICSqF9HJ/s1e+7qnAMb7OwHC1xK3Lb+XbW+ffM0=; b=ebYdOD/jWnvoGYYdnKdmHSS9lhMz7iVDgXR2WGKF3etV/W9nDfoUNPLCYt5MaWuINw ARdO2BA2NJFg1VjcuudrP3FiXpfJumDhUT4kWTMpMDAD2VVKm0rxM1WPaS/cvej3u3+Q nJaLGXkSfsBUZr7R+3k7r3/C4U5AaIlKXa0O7L4Eb7gUoskTRUzS/NCycwHDpUs8z/Qe n36fXYuZyvmXTmWX9CXOvNCnupVoKHKOecNn4R5SFJ0i+/ceckpIDDNz1+LVbto2aUGK Y/8T+Ywu4GIP5xE2MeBvApx0NyiT8MXyRyKMVFhdAfL40Zgtigk4bkApkVXWjP9Hnf9m ASaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=X3Sk6Ojh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e9-20020a056a0000c900b0069335e0c824si3732631pfj.204.2023.11.17.23.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 23:59:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=X3Sk6Ojh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6E61382663ED; Fri, 17 Nov 2023 23:59:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjKRH4B (ORCPT + 29 others); Sat, 18 Nov 2023 02:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjKRHz7 (ORCPT ); Sat, 18 Nov 2023 02:55:59 -0500 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8F6D75 for ; Fri, 17 Nov 2023 23:55:55 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 4GBDrwEoPODaN4GBDr1qY9; Sat, 18 Nov 2023 08:55:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1700294153; bh=V9Th/4FKB+iHrGZuL+784CAl/VlpMqyAVTrSivrk2DI=; h=From:To:Cc:Subject:Date; b=X3Sk6OjhaTrfqzMPiplQYjmJHnUa+bh94ufi/kGIuBy5qMNbGfcBw5ssqG/2sz8yC o4DKWGpTEFWwB7f4Pz9YQ7hMYkrTPlnZkVVoS66drjZatrRnOTwJm7j1xep2QljbK4 Ge6k7vO9PPnEf9p42cDStjPZ8emuC533bWXPmbllMWMlC4RwN2bKXz2jmtngMPG2SS ciorItkgIpTGVS0Hg+mDBQO3n+hj9a+8r4A/qP18S0e7fBUFtiwQM0i7DiMXNv5lFg S0XDvXegvYyrgl22lcQANdgmHYdejc6/6hpez52YehoFzCyb++pDJCK4XgWEcwvUZw iB80AMgC2xXog== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 18 Nov 2023 08:55:53 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Xiaowei Song , Binghui Wang , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-pci@vger.kernel.org Subject: [PATCH v2] PCI: kirin: Use devm_kasprintf() Date: Sat, 18 Nov 2023 08:55:48 +0100 Message-Id: <1bad6879083a7d836c8a47418a0afa22485e8f69.1700294127.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 23:59:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782887863225418064 X-GMAIL-MSGID: 1782887863225418064 Use devm_kasprintf() instead of hand writing it. This saves the need of an intermediate buffer. There was also no reason to use the _const() version of devm_kstrdup(). The string was known be not constant. Signed-off-by: Christophe JAILLET --- v2: Update kirin_pcie_parse_port() [Krzysztof WilczyƄski] v1: https://lore.kernel.org/all/085fc5ac70fc8d73d5da197967e76d18f2ab5208.1699774592.git.christophe.jaillet@wanadoo.fr/ --- drivers/pci/controller/dwc/pcie-kirin.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 2ee146767971..982f854bc39c 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -366,7 +366,6 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, struct platform_device *pdev) { struct device *dev = &pdev->dev; - char name[32]; int ret, i; /* This is an optional property */ @@ -387,9 +386,8 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, if (pcie->gpio_id_clkreq[i] < 0) return pcie->gpio_id_clkreq[i]; - sprintf(name, "pcie_clkreq_%d", i); - pcie->clkreq_names[i] = devm_kstrdup_const(dev, name, - GFP_KERNEL); + pcie->clkreq_names[i] = devm_kasprintf(dev, GFP_KERNEL, + "pcie_clkreq_%d", i); if (!pcie->clkreq_names[i]) return -ENOMEM; } @@ -404,7 +402,6 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, struct device *dev = &pdev->dev; struct device_node *parent, *child; int ret, slot, i; - char name[32]; for_each_available_child_of_node(node, parent) { for_each_available_child_of_node(parent, child) { @@ -430,9 +427,9 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, slot = PCI_SLOT(ret); - sprintf(name, "pcie_perst_%d", slot); - pcie->reset_names[i] = devm_kstrdup_const(dev, name, - GFP_KERNEL); + pcie->reset_names[i] = devm_kasprintf(dev, GFP_KERNEL, + "pcie_perst_%d", + slot); if (!pcie->reset_names[i]) { ret = -ENOMEM; goto put_node;