diff mbox series

[v2,pci-next] PCI: Keep both device name and resource name for config space remaps

Message ID WbKfdybjZ6xNIUjcC5oC8NcuLqrJfkxQAlnO80ag@cp3-web-020.plabs.ch (mailing list archive)
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series [v2,pci-next] PCI: Keep both device name and resource name for config space remaps | expand

Commit Message

Alexander Lobakin Nov. 19, 2020, 9:26 p.m. UTC
Follow the rule taken in commit 35bd8c07db2c
("devres: keep both device name and resource name in pretty name")
and keep both device and resource names while requesting memory
regions for PCI config space to prettify e.g. /proc/iomem output:

Before (DWC Host Controller):

18b00000-18b01fff : dbi
18b10000-18b11fff : config
18b20000-18b21fff : dbi
18b30000-18b31fff : config

After:

18b00000-18b01fff : 18b00000.pci dbi
18b10000-18b11fff : 18b00000.pci config
18b20000-18b21fff : 18b20000.pci dbi
18b30000-18b31fff : 18b20000.pci config

Since v1 [0]:
 - massage subject and commit message (Bjorn);
 - no functional changes.

[0] https://lore.kernel.org/lkml/JvyOzv8K8n5CCdP1xfLOdOWh4AbFrXdMMOEExr6em8@cp4-web-036.plabs.ch

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 drivers/pci/pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Bjorn Helgaas Dec. 10, 2020, 9:22 p.m. UTC | #1
On Thu, Nov 19, 2020 at 09:26:33PM +0000, Alexander Lobakin wrote:
> Follow the rule taken in commit 35bd8c07db2c
> ("devres: keep both device name and resource name in pretty name")
> and keep both device and resource names while requesting memory
> regions for PCI config space to prettify e.g. /proc/iomem output:
> 
> Before (DWC Host Controller):
> 
> 18b00000-18b01fff : dbi
> 18b10000-18b11fff : config
> 18b20000-18b21fff : dbi
> 18b30000-18b31fff : config
> 
> After:
> 
> 18b00000-18b01fff : 18b00000.pci dbi
> 18b10000-18b11fff : 18b00000.pci config
> 18b20000-18b21fff : 18b20000.pci dbi
> 18b30000-18b31fff : 18b20000.pci config
> 
> Since v1 [0]:
>  - massage subject and commit message (Bjorn);
>  - no functional changes.
> 
> [0] https://lore.kernel.org/lkml/JvyOzv8K8n5CCdP1xfLOdOWh4AbFrXdMMOEExr6em8@cp4-web-036.plabs.ch
> 
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Alexander Lobakin <alobakin@pm.me>

Applied to pci/enumeration for v5.11, thanks!

> ---
>  drivers/pci/pci.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e578d34095e9..0716691f7d14 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4188,7 +4188,14 @@ void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
>  	}
>  
>  	size = resource_size(res);
> -	name = res->name ?: dev_name(dev);
> +
> +	if (res->name)
> +		name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", dev_name(dev),
> +				      res->name);
> +	else
> +		name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
> +	if (!name)
> +		return IOMEM_ERR_PTR(-ENOMEM);
>  
>  	if (!devm_request_mem_region(dev, res->start, size, name)) {
>  		dev_err(dev, "can't request region for resource %pR\n", res);
> -- 
> 2.29.2
> 
>
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e578d34095e9..0716691f7d14 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4188,7 +4188,14 @@  void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
 	}
 
 	size = resource_size(res);
-	name = res->name ?: dev_name(dev);
+
+	if (res->name)
+		name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", dev_name(dev),
+				      res->name);
+	else
+		name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
+	if (!name)
+		return IOMEM_ERR_PTR(-ENOMEM);
 
 	if (!devm_request_mem_region(dev, res->start, size, name)) {
 		dev_err(dev, "can't request region for resource %pR\n", res);