staging/nvec: Pass proper resource to mfd_add_devices()
Subsystems (3)
PATCH 1/1 staging/nvec: Pass proper resource to mfd_add_devices()
From: Thierry Reding <[email protected]>
The mfd_add_devices() parameter 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.
While at it, use platform_get_irq() instead of platform_get_resource() to get the device's interrupt. This makes it easier to pass in the register region since the variable is no longer reused.
---
Alternatively we could simply pass NULL into mfd_add_devices(), which might be a slightly more accurate representation of what's going on.
Marc, Greg, any preferences?
drivers/staging/nvec/nvec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/nvec/nvec.c +3 -4
@@ -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 ];
@@ -893,7 +892,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), res,0 ,NULL );if (ret)dev_err (nvec->dev,"error adding subdevices\n" );
Signature · 1 line
2.0.1
Marc Dietrich
maintainerHi Thierry,
Quoted 6 lines · On Mon, 21 Jul 2014 13:52:41 +0200 Thierry Reding <[email protected]>…
From: Thierry Reding <[email protected]>
The
mfd_add_devices()parameter 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.
you are right, this one looked bogus.
Quoted 10 lines
While at it, use
platform_get_irq()instead ofplatform_get_resource()to get the device's interrupt. This makes it easier to pass in the register region since the variable is no longer reused.Signed-off-by Thierry Reding <[email protected]>---
Alternatively we could simply pass NULL intomfd_add_devices(), which might be a slightly more accurate representation of what's going on.Marc, Greg, any preferences?
I just tested with NULL as base and it seems to produce no harm. Even if we may get rid of mfd_add_devices in the future, passing NULL is cleaner for now and no children will ever make use of it. So please send a new version with this change.
Otherwise, thanks for looking and cleaning up.
Marc
Quoted 38 lines
drivers/staging/nvec/nvec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/staging/nvec/nvec.c +3
-4@@ -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 ];@@ -893,7 +892,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), res,0 ,NULL );if (ret)dev_err (nvec->dev,"error adding subdevices\n" );Signature · 1 line
2.0.1
Signature · 1 line
Marc Dietrich <[email protected]>
Greg Kroah-Hartman
maintainerQuoted 11 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The
mfd_add_devices()parameter 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.While at it, use
platform_get_irq()instead ofplatform_get_resource()to get the device's interrupt. This makes it easier to pass in the register region since the variable is no longer reused.
Quoted 6 lines
Signed-off-by Thierry Reding <[email protected]>---
Alternatively we could simply pass NULL intomfd_add_devices(), which might be a slightly more accurate representation of what's going on.Marc, Greg, any preferences?
None from me, Marc?
Greg Kroah-Hartman
maintainerQuoted 23 lines · Marc Dietrich
Hi Thierry,
Quoted 6 lines · On Mon, 21 Jul 2014 13:52:41 +0200 Thierry Reding <[email protected]>…
From: Thierry Reding <[email protected]>
The
mfd_add_devices()parameter 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.you are right, this one looked bogus.
Quoted 9 lines
While at it, use
platform_get_irq()instead ofplatform_get_resource()to get the device's interrupt. This makes it easier to pass in the register region since the variable is no longer reused.Signed-off-by Thierry Reding <[email protected]>---
Alternatively we could simply pass NULL intomfd_add_devices(), which might be a slightly more accurate representation of what's going on.
Quoted 8 lines
Quoted 1 line
Marc, Greg, any preferences?
I just tested with NULL as base and it seems to produce no harm. Even if we may get rid of
mfd_add_devicesin the future, passing NULL is cleaner for now and no children will ever make use of it. So please send a new version with this change.Otherwise, thanks for looking and cleaning up.
Ok, can I get your ack for this patch then?
thanks,
greg k-h
Quoted 26 lines · Greg Kroah-Hartman
Quoted 25 lines · Marc Dietrich
Hi Thierry,
Quoted 6 lines · On Mon, 21 Jul 2014 13:52:41 +0200 Thierry Reding…
From: Thierry Reding <[email protected]>
The
mfd_add_devices()parameter 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.you are right, this one looked bogus.
Quoted 10 lines
While at it, use
platform_get_irq()instead ofplatform_get_resource()to get the device's interrupt. This makes it easier to pass in the register region since the variable is no longer reused.Signed-off-by Thierry Reding <[email protected]>---
Alternatively we could simply pass NULL intomfd_add_devices(), which might be a slightly more accurate representation of what's going on.Marc, Greg, any preferences?
Quoted 8 lines
Quoted 6 lines
I just tested with NULL as base and it seems to produce no harm. Even if we may get rid of
mfd_add_devicesin the future, passing NULL is cleaner for now and no children will ever make use of it. So please send a new version with this change.Otherwise, thanks for looking and cleaning up.
Ok, can I get your ack for this patch then?
I'll resend a patch which passes in NULL as base tomorrow as requested by Marc.
Thierry