2020-05-25 02:04:38

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH] thermal: sprd: Fix return value of sprd_thm_probe()

When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.

Fixes: 554fdbaf19b1 ("thermal: sprd: Add Spreadtrum thermal driver support")
Signed-off-by: Tiezhu Yang <[email protected]>
---
drivers/thermal/sprd_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c
index a340374..4cde70d 100644
--- a/drivers/thermal/sprd_thermal.c
+++ b/drivers/thermal/sprd_thermal.c
@@ -348,8 +348,8 @@ static int sprd_thm_probe(struct platform_device *pdev)

thm->var_data = pdata;
thm->base = devm_platform_ioremap_resource(pdev, 0);
- if (!thm->base)
- return -ENOMEM;
+ if (IS_ERR(thm->base))
+ return PTR_ERR(thm->base);

thm->nr_sensors = of_get_child_count(np);
if (thm->nr_sensors == 0 || thm->nr_sensors > SPRD_THM_MAX_SENSOR) {
--
2.1.0


2020-05-29 14:28:07

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH] thermal: sprd: Fix return value of sprd_thm_probe()

Hi,

On Mon, May 25, 2020 at 10:00 AM Tiezhu Yang <[email protected]> wrote:
>
> When call function devm_platform_ioremap_resource(), we should use IS_ERR()
> to check the return value and return PTR_ERR() if failed.
>
> Fixes: 554fdbaf19b1 ("thermal: sprd: Add Spreadtrum thermal driver support")
> Signed-off-by: Tiezhu Yang <[email protected]>

Good catch. Thanks.
Reviewed-by: Baolin Wang <[email protected]>

> ---
> drivers/thermal/sprd_thermal.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c
> index a340374..4cde70d 100644
> --- a/drivers/thermal/sprd_thermal.c
> +++ b/drivers/thermal/sprd_thermal.c
> @@ -348,8 +348,8 @@ static int sprd_thm_probe(struct platform_device *pdev)
>
> thm->var_data = pdata;
> thm->base = devm_platform_ioremap_resource(pdev, 0);
> - if (!thm->base)
> - return -ENOMEM;
> + if (IS_ERR(thm->base))
> + return PTR_ERR(thm->base);
>
> thm->nr_sensors = of_get_child_count(np);
> if (thm->nr_sensors == 0 || thm->nr_sensors > SPRD_THM_MAX_SENSOR) {
> --
> 2.1.0
>


--
Baolin Wang

2020-06-29 20:47:06

by Amit Kucheria

[permalink] [raw]
Subject: Re: [PATCH] thermal: sprd: Fix return value of sprd_thm_probe()

On Fri, May 29, 2020 at 7:55 PM Baolin Wang <[email protected]> wrote:
>
> Hi,
>
> On Mon, May 25, 2020 at 10:00 AM Tiezhu Yang <[email protected]> wrote:
> >
> > When call function devm_platform_ioremap_resource(), we should use IS_ERR()
> > to check the return value and return PTR_ERR() if failed.
> >
> > Fixes: 554fdbaf19b1 ("thermal: sprd: Add Spreadtrum thermal driver support")
> > Signed-off-by: Tiezhu Yang <[email protected]>
>
> Good catch. Thanks.
> Reviewed-by: Baolin Wang <[email protected]>

Reviewed-by: Amit Kucheria <[email protected]>

> > ---
> > drivers/thermal/sprd_thermal.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c
> > index a340374..4cde70d 100644
> > --- a/drivers/thermal/sprd_thermal.c
> > +++ b/drivers/thermal/sprd_thermal.c
> > @@ -348,8 +348,8 @@ static int sprd_thm_probe(struct platform_device *pdev)
> >
> > thm->var_data = pdata;
> > thm->base = devm_platform_ioremap_resource(pdev, 0);
> > - if (!thm->base)
> > - return -ENOMEM;
> > + if (IS_ERR(thm->base))
> > + return PTR_ERR(thm->base);
> >
> > thm->nr_sensors = of_get_child_count(np);
> > if (thm->nr_sensors == 0 || thm->nr_sensors > SPRD_THM_MAX_SENSOR) {
> > --
> > 2.1.0
> >
>
>
> --
> Baolin Wang