diff mbox series

watchdog: sa1100: Fix PTR_ERR_OR_ZERO() vs NULL check in sa1100dog_probe()

Message ID 20240426075808.1582678-1-nichen@iscas.ac.cn
State New
Headers show
Series watchdog: sa1100: Fix PTR_ERR_OR_ZERO() vs NULL check in sa1100dog_probe() | expand

Commit Message

Chen Ni April 26, 2024, 7:58 a.m. UTC
devm_ioremap() doesn't return error pointers, it returns NULL on error.
Update the check accordingly.

Fixes: e86bd43bcfc5 ("watchdog: sa1100: use platform device registration")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/watchdog/sa1100_wdt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Guenter Roeck April 26, 2024, 1:36 p.m. UTC | #1
On 4/26/24 00:58, Chen Ni wrote:
> devm_ioremap() doesn't return error pointers, it returns NULL on error.
> Update the check accordingly.
> 
> Fixes: e86bd43bcfc5 ("watchdog: sa1100: use platform device registration")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/sa1100_wdt.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
> index 5d2df008b92a..34a917221e31 100644
> --- a/drivers/watchdog/sa1100_wdt.c
> +++ b/drivers/watchdog/sa1100_wdt.c
> @@ -191,9 +191,8 @@ static int sa1100dog_probe(struct platform_device *pdev)
>   	if (!res)
>   		return -ENXIO;
>   	reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
> -	ret = PTR_ERR_OR_ZERO(reg_base);
> -	if (ret)
> -		return ret;
> +	if (!reg_base)
> +		return -ENOMEM;
>   
>   	clk = clk_get(NULL, "OSTIMER0");
>   	if (IS_ERR(clk)) {
diff mbox series

Patch

diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index 5d2df008b92a..34a917221e31 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -191,9 +191,8 @@  static int sa1100dog_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENXIO;
 	reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	ret = PTR_ERR_OR_ZERO(reg_base);
-	if (ret)
-		return ret;
+	if (!reg_base)
+		return -ENOMEM;
 
 	clk = clk_get(NULL, "OSTIMER0");
 	if (IS_ERR(clk)) {