Skip to contentSkip to conversation

PCI: tegra: add missing __iomem annotation

PATCH Superseded Jingoo Han 3 participants 8 messages Sep 12, 2013 – Sep 19, 2013

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/3 PCI: tegra: add missing __iomem annotation

Added missing __iomem annotation in order to fix the following sparse warnings:

drivers/pci/host/pci-tegra.c:411:41: warning: incorrect type in return expression (different address spaces)
drivers/pci/host/pci-tegra.c:411:41: expected void [noderef] <asn:2>*
drivers/pci/host/pci-tegra.c:411:41: got void *addr
drivers/pci/host/pci-tegra.c:419:25: warning: incorrect type in return expression (different address spaces)
drivers/pci/host/pci-tegra.c:419:25: expected void [noderef] <asn:2>*
drivers/pci/host/pci-tegra.c:419:25: got void *addr

---
 drivers/pci/host/pci-tegra.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/host/pci-tegra.c +2 -2
index 2e9888a..7c4f38d 100644
@@ -408,7 +408,7 @@ static void __iomem *tegra_pcie_bus_map(struct tegra_pcie *pcie,
 
 	list_for_each_entry(bus, &pcie->busses, list)
 		if (bus->nr == busnr)
-			return bus->area->addr;
+			return (void __iomem *)bus->area->addr;
 
 	bus = tegra_pcie_bus_alloc(pcie, busnr);
 	if (IS_ERR(bus))
@@ -416,7 +416,7 @@ static void __iomem *tegra_pcie_bus_map(struct tegra_pcie *pcie,
 
 	list_add_tail(&bus->list, &pcie->busses);
 
-	return bus->area->addr;
+	return (void __iomem *)bus->area->addr;
 }
 
 static void __iomem *tegra_pcie_conf_address(struct pci_bus *bus,
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 2/3 PCI: mvebu: make local functions static

mvebu_pcie_add_bus(), mvebu_pcie_align_resource() are used only in this file. Thus, these local functions should be staticized in order to fix the following sparse warnings:

drivers/pci/host/pci-mvebu.c:684:6: warning: symbol 'mvebu_pcie_add_bus' was not declared. Should it be static? drivers/pci/host/pci-mvebu.c:690:17: warning: symbol 'mvebu_pcie_align_resource' was not declared. Should it be static?

---
 drivers/pci/host/pci-mvebu.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/host/pci-mvebu.c +6 -6
index d66530e..b54ceb1 100644
@@ -681,17 +681,17 @@ static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	return bus;
 }
 
-void mvebu_pcie_add_bus(struct pci_bus *bus)
+static void mvebu_pcie_add_bus(struct pci_bus *bus)
 {
 	struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
 	bus->msi = pcie->msi;
 }
 
-resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
-					  const struct resource *res,
-					  resource_size_t start,
-					  resource_size_t size,
-					  resource_size_t align)
+static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
+						const struct resource *res,
+						resource_size_t start,
+						resource_size_t size,
+						resource_size_t align)
 {
 	if (dev->bus->number != 0)
 		return start;
Signature · 1 line
1.7.10.4
Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] PCI: mvebu: make local functions static

Dear Jingoo Han,

Quoted 10 lines · Jingoo Han

mvebu_pcie_add_bus(), mvebu_pcie_align_resource() are used only in this file. Thus, these local functions should be staticized in order to fix the following sparse warnings:

drivers/pci/host/pci-mvebu.c:684:6: warning: symbol 'mvebu_pcie_add_bus' was not declared. Should it be static? drivers/pci/host/pci-mvebu.c:690:17: warning: symbol 'mvebu_pcie_align_resource' was not declared. Should it be static?

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
author
#3 lore raw

PATCH 3/3 PCI: mvebu: add missing __iomem annotation

In reply to Jingoo Han

Added missing __iomem annotation in order to fix the following sparse warning:

drivers/pci/host/pci-mvebu.c:744:31: warning: incorrect type in return expression (different address spaces)
drivers/pci/host/pci-mvebu.c:744:31: expected void [noderef] <asn:2>*
drivers/pci/host/pci-mvebu.c:744:31: got void *

---
 drivers/pci/host/pci-mvebu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-mvebu.c +1 -1
index b54ceb1..2d8e478 100644
@@ -741,7 +741,7 @@ static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev,
 
 	ret = of_address_to_resource(np, 0, &regs);
 	if (ret)
-		return ERR_PTR(ret);
+		return (void __iomem *)ERR_PTR(ret);
 
 	return devm_ioremap_resource(&pdev->dev, &regs);
 }
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH 3/3] PCI: mvebu: add missing __iomem annotation

Dear Jingoo Han,

drivers/pci/host/pci-mvebu.c static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev, · line 744

Quoted 4 lines · Jingoo Han
drivers/pci/host/pci-mvebu.c +1 -1
 	ret = of_address_to_resource(np, 0, &regs);
 	if (ret)
-		return ERR_PTR(ret);
+		return (void __iomem *)ERR_PTR(ret);

This doesn't look very pretty to tell the truth, but I don't quite see any other option. Just return NULL when of_address_to_resource() fails instead of trying to propagate the error? Make this entire function return an 'int' and have the iomem address returned through a pointer passed by address as argument to the function? Any other suggestion?

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
author
#5 lore raw

Re: [PATCH 3/3] PCI: mvebu: add missing __iomem annotation

Quoted 13 lines · Thomas Petazzoni

Review

Quoted 4 lines · Jingoo Han
(quoted diff) +1 -1
 	ret = of_address_to_resource(np, 0, &regs);
 	if (ret)
-		return ERR_PTR(ret);
+		return (void __iomem *)ERR_PTR(ret);

This doesn't look very pretty to tell the truth, but I don't quite see any other option. Just return NULL when of_address_to_resource() fails instead of trying to propagate the error? Make this entire function return an 'int' and have the iomem address returned through a pointer passed by address as argument to the function? Any other suggestion?

Hi Thomas Petazzoni,
I appreciated your feedback. :-)

'Just returning NULL when of_address_to_resource() fails instead of trying to propagate the error' looks better.

Then, how about the following?

drivers/pci/host/pci-mvebu.c +0 -0
@@ -728,7 +728,7 @@ mvebu_pcie_map_registers(struct platform_device *pdev,
 
	ret = of_address_to_resource(np, 0, &regs);
	if (ret)

- return ERR_PTR(ret);
+ return NULL;

	return devm_ioremap_resource(&pdev->dev, &regs);
 }
@@ -874,7 +874,7 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
		}

		port->base = mvebu_pcie_map_registers(pdev, child, port);
-		if (IS_ERR(port->base)) {
+		if (!port->base) {
			dev_err(&pdev->dev, "PCIe%d.%d: cannot map registers\n",
  				port->port, port->lane);
			port->base = NULL;

Best regards,
Jingoo Han

#6 lore raw

Re: [PATCH 3/3] PCI: mvebu: add missing __iomem annotation

Dear Jingoo Han,

Quoted 17 lines · Jingoo Han

'Just returning NULL when of_address_to_resource() fails instead of trying to propagate the error' looks better.

Then, how about the following?

drivers/pci/host/pci-mvebu.c +1 -1
@@ -728,7 +728,7 @@ mvebu_pcie_map_registers(struct platform_device *pdev,
 
 	ret = of_address_to_resource(np, 0, &regs);
 	if (ret)
-		return ERR_PTR(ret);
+		return NULL;
 
 	return devm_ioremap_resource(&pdev->dev, &regs);
 }

drivers/pci/host/pci-mvebu.c static int __init mvebu_pcie_probe(struct platform_device *pdev) · line 880

Quoted 8 lines
drivers/pci/host/pci-mvebu.c +1 -1
@@ -874,7 +874,7 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
 		}
 
 		port->base = mvebu_pcie_map_registers(pdev, child, port);
-		if (IS_ERR(port->base)) {
+		if (!port->base) {
 			dev_err(&pdev->dev, "PCIe%d.%d: cannot map registers\n",
  				port->port, port->lane);
 			port->base = NULL;

Yes, I believe it makes more sense since we were anyway to using the error code returned by of_address_to_ressource().

However, you can get rid of the port->base = NULL assignment in the if () { ... } code now.

With that fixed, you can add my:

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
Acked-by on v1 1/3
#7 lore raw
In reply to Jingoo Han
Quoted 10 lines · Jingoo Han

Added missing __iomem annotation in order to fix the following sparse warnings:

drivers/pci/host/pci-tegra.c:411:41: warning: incorrect type in return expression (different address spaces)
drivers/pci/host/pci-tegra.c:411:41: expected void [noderef] <asn:2>*
drivers/pci/host/pci-tegra.c:411:41: got void *addr
drivers/pci/host/pci-tegra.c:419:25: warning: incorrect type in return expression (different address spaces)
drivers/pci/host/pci-tegra.c:419:25: expected void [noderef] <asn:2>*
drivers/pci/host/pci-tegra.c:419:25: got void *addr

Quoted 4 lines
---
 drivers/pci/host/pci-tegra.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

I can carry this in a local tree or if somebody else wants to take it: