Thermal: spear_thermal: convert to devm_ioremap_resource
Subsystems (2)
Zhang Rui
reviewerPATCH 1/2 Thermal: spear_thermal: convert to devm_ioremap_resource
Use the newly introduced devm_ioremap_resource().
devm_ioremap_resource() provides its own error messages; so all explicit error messages can be removed from the failure code paths.
--- drivers/thermal/spear_thermal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/thermal/spear_thermal.c +10 -10
@@ -104,7 +104,7 @@ static int spear_thermal_probe(struct platform_device *pdev)struct thermal_zone_device *spear_thermal =NULL ;struct spear_thermal_dev *stdev;struct device_node *np = pdev->dev.of_node; -struct resource *stres =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +struct resource *res;int ret =0 , val;if (!np || !of_property_read_u32 (np,"st,thermal-flags" , &val)) {
@@ -112,23 +112,23 @@ static int spear_thermal_probe(struct platform_device *pdev)return -EINVAL ; } -if (!stres) { -dev_err (&pdev->dev,"memory resource missing\n" ); -return -ENODEV ; - } - stdev =devm_kzalloc (&pdev->dev,sizeof (*stdev),GFP_KERNEL );if (!stdev) {dev_err (&pdev->dev,"kzalloc fail\n" );return -ENOMEM ; } + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (&pdev->dev,"memory resource missing\n" ); +return -ENODEV ; + } +/* Enable thermal sensor */ - stdev->thermal_base =devm_ioremap (&pdev->dev, stres->start, -resource_size (stres)); -if (!stdev->thermal_base) { + stdev->thermal_base =devm_ioremap_resource (dev, res); +if (IS_ERR (stdev->thermal_base)) {dev_err (&pdev->dev,"ioremap failed\n" ); -return -ENOMEM ; +return PTR_ERR (stdev->thermal_base); } stdev->clk =devm_clk_get (&pdev->dev,NULL );
Signature · 1 line
1.7.9.5
Zhang Rui
reviewerPATCH 2/2 Thermal: don't check resource with devm_ioremap_resource
devm_ioremap_resource does sanity checks on the given resource. No need to duplicate this in the driver.
--- drivers/thermal/armada_thermal.c | 10 ---------- drivers/thermal/spear_thermal.c | 7 +------ 2 files changed, 1 insertion(+), 16 deletions(-)
drivers/thermal/armada_thermal.c +0 -10
@@ -169,21 +169,11 @@ static int armada_thermal_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"Failed to get platform resource\n" ); -return -ENODEV ; - } - priv->sensor =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (priv->sensor))return PTR_ERR (priv->sensor); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (!res) { -dev_err (&pdev->dev,"Failed to get platform resource\n" ); -return -ENODEV ; - } - priv->control =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (priv->control))return PTR_ERR (priv->control);
drivers/thermal/spear_thermal.c +1 -6
@@ -118,13 +118,8 @@ static int spear_thermal_probe(struct platform_device *pdev)return -ENOMEM ; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"memory resource missing\n" ); -return -ENODEV ; - } -/* Enable thermal sensor */ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); stdev->thermal_base =devm_ioremap_resource (dev, res);if (IS_ERR (stdev->thermal_base)) {dev_err (&pdev->dev,"ioremap failed\n" );
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource
Quoted 6 lines · Zhang Rui
devm_ioremap_resourcedoes sanity checks on the given resource. No need to duplicate this in the driver.CC Ezequiel Garcia <[email protected]>CC Vincenzo Frascino <[email protected]>Signed-off-by Zhang Rui <[email protected]>
Thanks,
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
RE: [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource
In reply to Zhang RuiQuoted 12 lines
-----Original Message-----
From: Zhang, Rui
Sent: Thursday, May 16, 2013 10:16 AM
To: [email protected]
Cc: [email protected]; Zhang, Rui; Ezequiel Garcia; Vincenzo Frascino
Subject: [PATCH 2/2] Thermal: don't check resource withdevm_ioremap_resource
Importance: High
Quoted 6 lines
devm_ioremap_resourcedoes sanity checks on the given resource. No need to duplicate this in the driver.CC Ezequiel Garcia <[email protected]>CC Vincenzo Frascino <[email protected]>Signed-off-by Zhang Rui <[email protected]>
Applied to thermal -next.
Thanks,
rui
Quoted 55 lines
--- drivers/thermal/armada_thermal.c | 10 ---------- drivers/thermal/spear_thermal.c | 7 +------ 2 files changed, 1 insertion(+), 16 deletions(-)drivers/thermal/armada_thermal.c +0
-10@@ -169,21 +169,11 @@ static int armada_thermal_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"Failed to get platform resource\n" ); -return -ENODEV ; - } - priv->sensor =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (priv->sensor))return PTR_ERR (priv->sensor); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (!res) { -dev_err (&pdev->dev,"Failed to get platform resource\n" ); -return -ENODEV ; - } - priv->control =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (priv->control))drivers/thermal/armada_thermal.c +0
-0return PTR_ERR (priv->control);(quoted diff) +0
-0
b/drivers/thermal/spear_thermal.cindex 1b652ab..fa30918 100644drivers/thermal/spear_thermal.c +1
-6@@ -118,13 +118,8 @@ static int spear_thermal_probe(struct platform_device *pdev)return -ENOMEM ; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"memory resource missing\n" ); -return -ENODEV ; - } -/* Enable thermal sensor */ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); stdev->thermal_base =devm_ioremap_resource (dev, res);if (IS_ERR (stdev->thermal_base)) {
dev_err(&pdev->dev, "ioremap failed\n");
--
1.7.9.5
Quoted 11 lines
-----Original Message-----
From: Zhang, Rui
Sent: Thursday, May 16, 2013 10:16 AM
To: [email protected]
Cc: [email protected]; Zhang, Rui; Vincenzo Frascino
Subject: [PATCH 1/2] Thermal:spear_thermal: convert todevm_ioremap_resource
Importance: High
Quoted 7 lines
Use the newly introduced
devm_ioremap_resource().
devm_ioremap_resource()provides its own error messages; so all explicit error messages can be removed from the failure code paths.CC Vincenzo Frascino <[email protected]>Signed-off-by Zhang Rui <[email protected]>
Applied to thermal -next.
Thanks,
rui
Quoted 55 lines
--- drivers/thermal/spear_thermal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/thermal/spear_thermal.cindex 1a14eaa..1b652ab 100644drivers/thermal/spear_thermal.c +1
-1@@ -104,7 +104,7 @@ static int spear_thermal_probe(struct platform_device *pdev)struct thermal_zone_device *spear_thermal =NULL ;struct spear_thermal_dev *stdev;struct device_node *np = pdev->dev.of_node; -struct resource *stres =platform_get_resource (pdev, IORESOURCE_MEM, 0); +struct resource *res;int ret =0 , val;if (!np || !of_property_read_u32(np, "st,thermal-flags", &val))
{ @@ -112,23 +112,23 @@ static intspear_thermal_probe(struct platform_device *pdev)drivers/thermal/spear_thermal.c +9
-10return -EINVAL ; } -if (!stres) { -dev_err (&pdev->dev,"memory resource missing\n" ); -return -ENODEV ; - } - stdev =devm_kzalloc (&pdev->dev,sizeof (*stdev),GFP_KERNEL );if (!stdev) {dev_err (&pdev->dev,"kzalloc fail\n" );return -ENOMEM ; } + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (&pdev->dev,"memory resource missing\n" ); +return -ENODEV ; + } +/* Enable thermal sensor */ - stdev->thermal_base =devm_ioremap (&pdev->dev, stres->start, -resource_size (stres)); -if (!stdev->thermal_base) { + stdev->thermal_base =devm_ioremap_resource (dev, res); +if (IS_ERR (stdev->thermal_base)) {dev_err (&pdev->dev,"ioremap failed\n" ); -return -ENOMEM ; +return PTR_ERR (stdev->thermal_base); } stdev->clk =devm_clk_get (&pdev->dev,NULL ); --1.7.9.5