Commit 9f5077ef authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Krzysztof Wilczyński

PCI: kirin: Use devm_kasprintf() to dynamically allocate clock names

Use devm_kasprintf() instead of open coding it.  This saves the need of
an intermediate buffer.

There was also no reason to use devm_kstrdup_const() as string is known
to be constant.

[kwilczynski: commit log, and add missing Reviewed-by tag]
Link: https://lore.kernel.org/linux-pci/1bad6879083a7d836c8a47418a0afa22485e8f69.1700294127.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarKrzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent b85ea95d
...@@ -366,7 +366,6 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, ...@@ -366,7 +366,6 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie,
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
char name[32];
int ret, i; int ret, i;
/* This is an optional property */ /* This is an optional property */
...@@ -387,9 +386,8 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, ...@@ -387,9 +386,8 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie,
if (pcie->gpio_id_clkreq[i] < 0) if (pcie->gpio_id_clkreq[i] < 0)
return pcie->gpio_id_clkreq[i]; return pcie->gpio_id_clkreq[i];
sprintf(name, "pcie_clkreq_%d", i); pcie->clkreq_names[i] = devm_kasprintf(dev, GFP_KERNEL,
pcie->clkreq_names[i] = devm_kstrdup_const(dev, name, "pcie_clkreq_%d", i);
GFP_KERNEL);
if (!pcie->clkreq_names[i]) if (!pcie->clkreq_names[i])
return -ENOMEM; return -ENOMEM;
} }
...@@ -404,7 +402,6 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, ...@@ -404,7 +402,6 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *parent, *child; struct device_node *parent, *child;
int ret, slot, i; int ret, slot, i;
char name[32];
for_each_available_child_of_node(node, parent) { for_each_available_child_of_node(node, parent) {
for_each_available_child_of_node(parent, child) { for_each_available_child_of_node(parent, child) {
...@@ -430,9 +427,9 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, ...@@ -430,9 +427,9 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
slot = PCI_SLOT(ret); slot = PCI_SLOT(ret);
sprintf(name, "pcie_perst_%d", slot); pcie->reset_names[i] = devm_kasprintf(dev, GFP_KERNEL,
pcie->reset_names[i] = devm_kstrdup_const(dev, name, "pcie_perst_%d",
GFP_KERNEL); slot);
if (!pcie->reset_names[i]) { if (!pcie->reset_names[i]) {
ret = -ENOMEM; ret = -ENOMEM;
goto put_node; goto put_node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment