linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource
@ 2013-05-16  2:16 Zhang Rui
  2013-05-16  2:16 ` [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource Zhang Rui
  2013-05-20 15:39 ` [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang, Rui
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang Rui @ 2013-05-16  2:16 UTC (permalink / raw)
  To: linux-pm; +Cc: eduardo.valentin, Zhang Rui, Vincenzo Frascino

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 <vincenzo.frascino@st.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/spear_thermal.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
index 1a14eaa..1b652ab 100644
--- a/drivers/thermal/spear_thermal.c
+++ b/drivers/thermal/spear_thermal.c
@@ -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);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource
  2013-05-16  2:16 [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang Rui
@ 2013-05-16  2:16 ` Zhang Rui
  2013-05-16  8:46   ` Ezequiel Garcia
  2013-05-20 15:39   ` Zhang, Rui
  2013-05-20 15:39 ` [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang, Rui
  1 sibling, 2 replies; 5+ messages in thread
From: Zhang Rui @ 2013-05-16  2:16 UTC (permalink / raw)
  To: linux-pm; +Cc: eduardo.valentin, Zhang Rui, Ezequiel Garcia, Vincenzo Frascino

devm_ioremap_resource does sanity checks on the given resource.
No need to duplicate this in the driver.

CC: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
CC: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/armada_thermal.c |   10 ----------
 drivers/thermal/spear_thermal.c  |    7 +------
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 0d02d4e..0491465 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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);
diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
index 1b652ab..fa30918 100644
--- a/drivers/thermal/spear_thermal.c
+++ b/drivers/thermal/spear_thermal.c
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource
  2013-05-16  2:16 ` [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource Zhang Rui
@ 2013-05-16  8:46   ` Ezequiel Garcia
  2013-05-20 15:39   ` Zhang, Rui
  1 sibling, 0 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2013-05-16  8:46 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, eduardo.valentin, Vincenzo Frascino

On Thu, May 16, 2013 at 10:16:21AM +0800, Zhang Rui wrote:
> devm_ioremap_resource does sanity checks on the given resource.
> No need to duplicate this in the driver.
> 
> CC: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> CC: Vincenzo Frascino <vincenzo.frascino@st.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>

Thanks,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource
  2013-05-16  2:16 [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang Rui
  2013-05-16  2:16 ` [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource Zhang Rui
@ 2013-05-20 15:39 ` Zhang, Rui
  1 sibling, 0 replies; 5+ messages in thread
From: Zhang, Rui @ 2013-05-20 15:39 UTC (permalink / raw)
  To: Zhang, Rui, linux-pm@vger.kernel.org
  Cc: eduardo.valentin@ti.com, Vincenzo Frascino



> -----Original Message-----
> From: Zhang, Rui
> Sent: Thursday, May 16, 2013 10:16 AM
> To: linux-pm@vger.kernel.org
> Cc: eduardo.valentin@ti.com; Zhang, Rui; Vincenzo Frascino
> Subject: [PATCH 1/2] Thermal: spear_thermal: convert to
> devm_ioremap_resource
> Importance: High
> 
> 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 <vincenzo.frascino@st.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Applied to thermal -next.

Thanks,
rui
> ---
>  drivers/thermal/spear_thermal.c |   20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/thermal/spear_thermal.c
> b/drivers/thermal/spear_thermal.c index 1a14eaa..1b652ab 100644
> --- a/drivers/thermal/spear_thermal.c
> +++ b/drivers/thermal/spear_thermal.c
> @@ -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);
> --
> 1.7.9.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource
  2013-05-16  2:16 ` [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource Zhang Rui
  2013-05-16  8:46   ` Ezequiel Garcia
@ 2013-05-20 15:39   ` Zhang, Rui
  1 sibling, 0 replies; 5+ messages in thread
From: Zhang, Rui @ 2013-05-20 15:39 UTC (permalink / raw)
  To: Zhang, Rui, linux-pm@vger.kernel.org
  Cc: eduardo.valentin@ti.com, Ezequiel Garcia, Vincenzo Frascino



> -----Original Message-----
> From: Zhang, Rui
> Sent: Thursday, May 16, 2013 10:16 AM
> To: linux-pm@vger.kernel.org
> Cc: eduardo.valentin@ti.com; Zhang, Rui; Ezequiel Garcia; Vincenzo
> Frascino
> Subject: [PATCH 2/2] Thermal: don't check resource with
> devm_ioremap_resource
> Importance: High
> 
> devm_ioremap_resource does sanity checks on the given resource.
> No need to duplicate this in the driver.
> 
> CC: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> CC: Vincenzo Frascino <vincenzo.frascino@st.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Applied to thermal -next.

Thanks,
rui
> ---
>  drivers/thermal/armada_thermal.c |   10 ----------
>  drivers/thermal/spear_thermal.c  |    7 +------
>  2 files changed, 1 insertion(+), 16 deletions(-)
> 
> diff --git a/drivers/thermal/armada_thermal.c
> b/drivers/thermal/armada_thermal.c
> index 0d02d4e..0491465 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -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);
> diff --git a/drivers/thermal/spear_thermal.c
> b/drivers/thermal/spear_thermal.c index 1b652ab..fa30918 100644
> --- a/drivers/thermal/spear_thermal.c
> +++ b/drivers/thermal/spear_thermal.c
> @@ -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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-20 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16  2:16 [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang Rui
2013-05-16  2:16 ` [PATCH 2/2] Thermal: don't check resource with devm_ioremap_resource Zhang Rui
2013-05-16  8:46   ` Ezequiel Garcia
2013-05-20 15:39   ` Zhang, Rui
2013-05-20 15:39 ` [PATCH 1/2] Thermal: spear_thermal: convert to devm_ioremap_resource Zhang, Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).