Skip to contentSkip to conversation

staging/nvec: Do not pass resource to mfd_add_devices()

PATCH In review Thierry Reding 2 participants 4 messages Jul 29, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging/nvec: Do not pass resource to mfd_add_devices()

From: Thierry Reding <[email protected]>

The mfd_add_devices() function takes a struct resource * as fifth argument, but the nvec driver passes in a void __iomem *. The driver gets away with it because none of the subdevices ever directly access the registers.

Since subdevices never need to access the registers we can simply pass NULL instead.

---
 drivers/staging/nvec/nvec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec.c +1 -1
index 0a5c84ad3f41..815065837ce7 100644
@@ -893,7 +893,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 	}
 
 	ret = mfd_add_devices(nvec->dev, -1, nvec_devices,
-			      ARRAY_SIZE(nvec_devices), base, 0, NULL);
+			      ARRAY_SIZE(nvec_devices), NULL, 0, NULL);
 	if (ret)
 		dev_err(nvec->dev, "error adding subdevices\n");
 
Signature · 1 line
2.0.2
#1 lore raw

PATCH 2/2 staging/nvec: Use platform_get_irq()

From: Thierry Reding <[email protected]>

As opposed to platform_get_resource(), the platform_get_irq() function has special code to handle driver probe deferral when booting using DT and where an interrupt provider hasn't been registered yet. While this is unlikely to become an issue for nvec, platform_get_irq() is the recommended way to get at interrupts.

---
 drivers/staging/nvec/nvec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/nvec/nvec.c +2 -3
index 815065837ce7..a93208adbfcf 100644
@@ -821,8 +821,8 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res) {
+	nvec->irq = platform_get_irq(pdev, 0);
+	if (nvec->irq < 0) {
 		dev_err(&pdev->dev, "no irq resource?\n");
 		return -ENODEV;
 	}
@@ -840,7 +840,6 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 	}
 
 	nvec->base = base;
-	nvec->irq = res->start;
 	nvec->i2c_clk = i2c_clk;
 	nvec->rx = &nvec->msg_pool[0];
 
Signature · 1 line
2.0.2
Acked-by on v1 1/2
#3 lore raw
In reply to Thierry Reding

Am Dienstag 29 Juli 2014, 13:16:14 schrieb Thierry Reding:

Quoted 11 lines

From: Thierry Reding <[email protected]>

The mfd_add_devices() function takes a struct resource * as fifth argument, but the nvec driver passes in a void __iomem *. The driver gets away with it because none of the subdevices ever directly access the registers.

Since subdevices never need to access the registers we can simply pass NULL instead.

Quoted 16 lines
---
 drivers/staging/nvec/nvec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec.c +1 -1
index 0a5c84ad3f41..815065837ce7 100644
@@ -893,7 +893,7 @@ static int tegra_nvec_probe(struct platform_device
 *pdev) }
 
 	ret = mfd_add_devices(nvec->dev, -1, nvec_devices,
-			      ARRAY_SIZE(nvec_devices), base, 0, NULL);
+			      ARRAY_SIZE(nvec_devices), NULL, 0, NULL);
 	if (ret)
 		dev_err(nvec->dev, "error adding subdevices\n");
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] staging/nvec: Use platform_get_irq()

In reply to Thierry Reding

Am Dienstag 29 Juli 2014, 13:16:15 schrieb Thierry Reding:

Quoted 9 lines

From: Thierry Reding <[email protected]>

As opposed to platform_get_resource(), the platform_get_irq() function has special code to handle driver probe deferral when booting using DT and where an interrupt provider hasn't been registered yet. While this is unlikely to become an issue for nvec, platform_get_irq() is the recommended way to get at interrupts.

Thanks again, Thierry!

Quoted 26 lines
---
 drivers/staging/nvec/nvec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/nvec/nvec.c +2 -3
index 815065837ce7..a93208adbfcf 100644
@@ -821,8 +821,8 @@ static int tegra_nvec_probe(struct platform_device
 *pdev) if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res) {
+	nvec->irq = platform_get_irq(pdev, 0);
+	if (nvec->irq < 0) {
 		dev_err(&pdev->dev, "no irq resource?\n");
 		return -ENODEV;
 	}
@@ -840,7 +840,6 @@ static int tegra_nvec_probe(struct platform_device
 *pdev) }
 
 	nvec->base = base;
-	nvec->irq = res->start;
 	nvec->i2c_clk = i2c_clk;
 	nvec->rx = &nvec->msg_pool[0];