diff mbox

[10/27] drivers/memory: don't check resource with devm_ioremap_resource

Message ID 1374602524-3398-11-git-send-email-wsa@the-dreams.de
State Not Applicable, archived
Headers show

Commit Message

Wolfram Sang July 23, 2013, 6:01 p.m. UTC
devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
Please apply via the subsystem-tree.

 drivers/memory/tegra20-mc.c |    2 --
 drivers/memory/tegra30-mc.c |    2 --
 2 files changed, 4 deletions(-)

Comments

Joe Perches July 23, 2013, 6:25 p.m. UTC | #1
On Tue, 2013-07-23 at 20:01 +0200, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.

Hi Wolfram:

This is the first and only one of the patch series I looked at.

> diff --git a/drivers/memory/tegra20-mc.c b/drivers/memory/tegra20-mc.c
[]
> @@ -218,8 +218,6 @@ static int tegra20_mc_probe(struct platform_device *pdev)
>  		struct resource *res;
>  
>  		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> -		if (!res)
> -			return -ENODEV;
>  		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);

I'm not so sure this is appropriate.

devm_ioremap_resource returns ERR_PTR(-EINVAL) for
null resource so this changes the return.

devm_ioremap_resource also emits a noisy dev_err
message when resource is NULL.

It's a probe and before the message log would be silent
but now there's a new dmesg.

Perhaps that should be mentioned in the changelog here
and elsewhere in the series.


--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Warren July 24, 2013, 1:27 a.m. UTC | #2
On 07/23/2013 11:25 AM, Joe Perches wrote:
> On Tue, 2013-07-23 at 20:01 +0200, Wolfram Sang wrote:
>> devm_ioremap_resource does sanity checks on the given resource. No need to
>> duplicate this in the driver.
> 
> Hi Wolfram:
> 
> This is the first and only one of the patch series I looked at.
> 
>> diff --git a/drivers/memory/tegra20-mc.c b/drivers/memory/tegra20-mc.c
> []
>> @@ -218,8 +218,6 @@ static int tegra20_mc_probe(struct platform_device *pdev)
>>  		struct resource *res;
>>  
>>  		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
>> -		if (!res)
>> -			return -ENODEV;
>>  		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
> 
> I'm not so sure this is appropriate.
> 
> devm_ioremap_resource returns ERR_PTR(-EINVAL) for
> null resource so this changes the return.

I think the exact return value is probably pretty arbitrary here.

> devm_ioremap_resource also emits a noisy dev_err
> message when resource is NULL.
> 
> It's a probe and before the message log would be silent
> but now there's a new dmesg.

I think those changes are fine, at least for this driver. It's a bug if
the required resources are missing, and having probe() actively point
out why it's failing can only be a good thing in my book.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Warren July 24, 2013, 1:32 a.m. UTC | #3
On 07/23/2013 11:01 AM, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
> Please apply via the subsystem-tree.

Greg KH usually commits patches to thus tree. I Cc'd him here.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches July 24, 2013, 1:38 a.m. UTC | #4
On Tue, 2013-07-23 at 18:27 -0700, Stephen Warren wrote:
> On 07/23/2013 11:25 AM, Joe Perches wrote:
> > On Tue, 2013-07-23 at 20:01 +0200, Wolfram Sang wrote:
> >> devm_ioremap_resource does sanity checks on the given resource. No need to
> >> duplicate this in the driver.
[]
> > This is the first and only one of the patch series I looked at.
> > 
> >> diff --git a/drivers/memory/tegra20-mc.c b/drivers/memory/tegra20-mc.c
> > []
> >> @@ -218,8 +218,6 @@ static int tegra20_mc_probe(struct platform_device *pdev)
> >>  		struct resource *res;
> >>  
> >>  		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> >> -		if (!res)
> >> -			return -ENODEV;
> >>  		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
> > 
> > I'm not so sure this is appropriate.
> > 
> > devm_ioremap_resource returns ERR_PTR(-EINVAL) for
> > null resource so this changes the return.
> 
> I think the exact return value is probably pretty arbitrary here.

I think so as well, but it takes code inspection to
determine whether or not there's any code impact.

I want to make sure Wolfram has done that inspection.

> > devm_ioremap_resource also emits a noisy dev_err
> > message when resource is NULL.
> > 
> > It's a probe and before the message log would be silent
> > but now there's a new dmesg.
> 
> I think those changes are fine, at least for this driver. It's a bug if
> the required resources are missing, and having probe() actively point
> out why it's failing can only be a good thing in my book.

Again, I haven't looked at _all_ the paths for all
of these patches, I just picked one at random.

Extra dmesg output with some device probes that are
expected to fail is not good.


--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/memory/tegra20-mc.c b/drivers/memory/tegra20-mc.c
index 0548eea..7cd82b8 100644
--- a/drivers/memory/tegra20-mc.c
+++ b/drivers/memory/tegra20-mc.c
@@ -218,8 +218,6 @@  static int tegra20_mc_probe(struct platform_device *pdev)
 		struct resource *res;
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			return -ENODEV;
 		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(mc->regs[i]))
 			return PTR_ERR(mc->regs[i]);
diff --git a/drivers/memory/tegra30-mc.c b/drivers/memory/tegra30-mc.c
index 58d2979..ef79345 100644
--- a/drivers/memory/tegra30-mc.c
+++ b/drivers/memory/tegra30-mc.c
@@ -340,8 +340,6 @@  static int tegra30_mc_probe(struct platform_device *pdev)
 		struct resource *res;
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			return -ENODEV;
 		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(mc->regs[i]))
 			return PTR_ERR(mc->regs[i]);