diff mbox

[-next] thermal: qcom: tsens: Fix return value check in init_common()

Message ID 1469860357-2773-1-git-send-email-weiyj.lk@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Wei Yongjun July 30, 2016, 6:32 a.m. UTC
In case of error, the function of_iomap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.
And the function devm_regmap_init_mmio() returns ERR_PTR()
and never returns NULL. The NULL test in the return value
check should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
---
 drivers/thermal/qcom/tsens-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


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

Comments

Rajendra Nayak Aug. 10, 2016, 4:59 a.m. UTC | #1
On 07/30/2016 12:02 PM, Wei Yongjun wrote:
> In case of error, the function of_iomap() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check
> should be replaced with NULL test.
> And the function devm_regmap_init_mmio() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().

Thanks for fixing this, I seem to have mixed up the return types
for the two functions

Acked-by: Rajendra Nayak <rnayak@codeaurora.org>

> 
> Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
> ---
>  drivers/thermal/qcom/tsens-common.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
> index 4a1af15..b1449ad 100644
> --- a/drivers/thermal/qcom/tsens-common.c
> +++ b/drivers/thermal/qcom/tsens-common.c
> @@ -128,13 +128,13 @@ int __init init_common(struct tsens_device *tmdev)
>  	void __iomem *base;
>  
>  	base = of_iomap(tmdev->dev->of_node, 0);
> -	if (IS_ERR(base))
> +	if (!base)
>  		return -EINVAL;
>  
>  	tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config);
> -	if (!tmdev->map) {
> +	if (IS_ERR(tmdev->map)) {
>  		iounmap(base);
> -		return -ENODEV;
> +		return PTR_ERR(tmdev->map);
>  	}
>  
>  	return 0;
>
Zhang Rui Aug. 19, 2016, 1:12 p.m. UTC | #2
On 六, 2016-07-30 at 00:32 -0600, Wei Yongjun wrote:
> In case of error, the function of_iomap() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check
> should be replaced with NULL test.
> And the function devm_regmap_init_mmio() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().
> 
> Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>

Patch applied.

thanks,
rui
> ---
>  drivers/thermal/qcom/tsens-common.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/tsens-common.c
> b/drivers/thermal/qcom/tsens-common.c
> index 4a1af15..b1449ad 100644
> --- a/drivers/thermal/qcom/tsens-common.c
> +++ b/drivers/thermal/qcom/tsens-common.c
> @@ -128,13 +128,13 @@ int __init init_common(struct tsens_device
> *tmdev)
>  	void __iomem *base;
>  
>  	base = of_iomap(tmdev->dev->of_node, 0);
> -	if (IS_ERR(base))
> +	if (!base)
>  		return -EINVAL;
>  
>  	tmdev->map = devm_regmap_init_mmio(tmdev->dev, base,
> &tsens_config);
> -	if (!tmdev->map) {
> +	if (IS_ERR(tmdev->map)) {
>  		iounmap(base);
> -		return -ENODEV;
> +		return PTR_ERR(tmdev->map);
>  	}
>  
>  	return 0;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" 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/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index 4a1af15..b1449ad 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -128,13 +128,13 @@  int __init init_common(struct tsens_device *tmdev)
 	void __iomem *base;
 
 	base = of_iomap(tmdev->dev->of_node, 0);
-	if (IS_ERR(base))
+	if (!base)
 		return -EINVAL;
 
 	tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config);
-	if (!tmdev->map) {
+	if (IS_ERR(tmdev->map)) {
 		iounmap(base);
-		return -ENODEV;
+		return PTR_ERR(tmdev->map);
 	}
 
 	return 0;