* [PATCH v2] PCI: kirin: Use devm_kasprintf()
@ 2023-11-18 7:55 Christophe JAILLET
2023-12-17 3:08 ` Krzysztof Wilczyński
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2023-11-18 7:55 UTC (permalink / raw)
To: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pci
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 <christophe.jaillet@wanadoo.fr>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] PCI: kirin: Use devm_kasprintf()
2023-11-18 7:55 [PATCH v2] PCI: kirin: Use devm_kasprintf() Christophe JAILLET
@ 2023-12-17 3:08 ` Krzysztof Wilczyński
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Wilczyński @ 2023-12-17 3:08 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi, Rob Herring,
Bjorn Helgaas, linux-kernel, kernel-janitors, linux-pci
Hello,
> 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.
Applied to controller/kirin, thank you!
[1/1] PCI: kirin: Use devm_kasprintf() to dynamically allocate clock names
https://git.kernel.org/pci/pci/c/9f5077ef8f81
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-17 3:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-18 7:55 [PATCH v2] PCI: kirin: Use devm_kasprintf() Christophe JAILLET
2023-12-17 3:08 ` Krzysztof Wilczyński
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox