Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1034889rdb; Fri, 17 Nov 2023 23:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3pHxp4TqaKduz6J2wE1uebgFhZsh6kXKZnUgd8wSRdJykPWffdKQW3WP+abDB7BCgSJWR X-Received: by 2002:a05:6808:e86:b0:3a7:4e0c:faa2 with SMTP id k6-20020a0568080e8600b003a74e0cfaa2mr2039924oil.27.1700294384136; Fri, 17 Nov 2023 23:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700294384; cv=none; d=google.com; s=arc-20160816; b=r5OCoft49I9xU0LSZ0lJ/+OFSzNfVVwPFxJbvevwJk6PdeZ71U7SaeqAsc/+GMdNqP TO5cC+g6J/+/1s9ivLg0540gqMMwi3p1YY3pujgG8jeS6ReZ/0ujGHyninKdIWrJ6oA4 vIX1Kibr94tp+38Lnm5tgbbdOJ0GW9S7bt36i2YYVEM90GV8QXyZrek/xiMbNOA8FUvI n2+Zptwpzee/YFbFC4rfMOOwvA3WiMZP51WRIEy68ioirivFr6N78k/M6GMjTQfi9IST mrdHPWsQ0Wjm/WNScnWmbhN4O3CU3HFXzI3oj92KNx/t9mYKWYwG9y1VhlSrsyip3lbR NPJw== 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.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o188-20020a6341c5000000b005bdfda8e04esi3837584pga.800.2023.11.17.23.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 23:59:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; 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.33 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 lipwig.vger.email (Postfix) with ESMTP id DC88D8246E33; Fri, 17 Nov 2023 23:59:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbjKRH4B (ORCPT + 99 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=20Wilczy=C5=84ski?= , 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,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 lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 23:59:34 -0800 (PST) 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; -- 2.34.1