thermal: qcom: tsens: Fix return value check in init_common()
Subsystems (3)
PATCH 1/1 thermal: qcom: tsens: Fix return value check in init_common()
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().
--- drivers/thermal/qcom/tsens-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/thermal/qcom/tsens-common.c +3 -3
@@ -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 ;
Quoted 6 lines · Wei Yongjun
In case of error, the function
of_iomap()returns NULL pointer notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.
And the functiondevm_regmap_init_mmio()returnsERR_PTR()and never returns NULL. The NULL test in the return value check should be replaced withIS_ERR().
Thanks for fixing this, I seem to have mixed up the return types for the two functions
Quoted 28 lines
Signed-off-by Wei Yongjun <[email protected]>--- drivers/thermal/qcom/tsens-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/thermal/qcom/tsens-common.c +3
-3@@ -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 ;
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Zhang Rui
reviewerQuoted 8 lines · Wei Yongjun
In case of error, the function
of_iomap()returns NULL pointer notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.
And the functiondevm_regmap_init_mmio()returnsERR_PTR()and never returns NULL. The NULL test in the return value check should be replaced withIS_ERR().Signed-off-by Wei Yongjun <[email protected]>
Patch applied.
thanks,
rui
Quoted 29 lines
---
drivers/thermal/qcom/tsens-common.c | 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)drivers/thermal/qcom/tsens-common.c +0
-0@@ -128,13 +128,13 @@ int __init init_common(struct tsens_device *tmdev) void __iomem *base;
base =of_iomap(tmdev->dev->of_node, 0);drivers/thermal/qcom/tsens-common.c +1
-1-if (IS_ERR (base)) +if (!base)return
-EINVAL;
tmdev->map=devm_regmap_init_mmio(tmdev->dev, base, &tsens_config);drivers/thermal/qcom/tsens-common.c +1
-1-if (!tmdev->map) { +if (IS_ERR (tmdev->map)) {iounmap(base);
drivers/thermal/qcom/tsens-common.c +1
-1-return -ENODEV ; +return PTR_ERR (tmdev->map);}
return 0;