diff mbox series

[-next,v2] usb: fotg210: fix return value check in fotg210_probe()

Message ID 20230130120633.3342285-1-yangyingliang@huawei.com (mailing list archive)
State Accepted
Commit 21ef9c91f0ab4f11d31fddbdc6d886fed114be74
Headers show
Series [-next,v2] usb: fotg210: fix return value check in fotg210_probe() | expand

Commit Message

Yang Yingliang Jan. 30, 2023, 12:06 p.m. UTC
devm_platform_get_and_ioremap_resource() never returns NULL pointer,
it will return ERR_PTR() when it fails, so replace the check with
IS_ERR().

Fixes: baef5330d35b ("usb: fotg210: Acquire memory resource in core")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
v1 -> v2:
  Change the return value to PTR_ERR().
---
 drivers/usb/fotg210/fotg210-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Linus Walleij Jan. 30, 2023, 2:55 p.m. UTC | #1
On Mon, Jan 30, 2023 at 1:07 PM Yang Yingliang <yangyingliang@huawei.com> wrote:

> devm_platform_get_and_ioremap_resource() never returns NULL pointer,
> it will return ERR_PTR() when it fails, so replace the check with
> IS_ERR().
>
> Fixes: baef5330d35b ("usb: fotg210: Acquire memory resource in core")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

BR
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
index 202d80adca2c..cb75464ab290 100644
--- a/drivers/usb/fotg210/fotg210-core.c
+++ b/drivers/usb/fotg210/fotg210-core.c
@@ -136,8 +136,8 @@  static int fotg210_probe(struct platform_device *pdev)
 	fotg->dev = dev;
 
 	fotg->base = devm_platform_get_and_ioremap_resource(pdev, 0, &fotg->res);
-	if (!fotg->base)
-		return -ENOMEM;
+	if (IS_ERR(fotg->base))
+		return PTR_ERR(fotg->base);
 
 	fotg->pclk = devm_clk_get_optional_enabled(dev, "PCLK");
 	if (IS_ERR(fotg->pclk))