diff mbox series

usb: misc: brcmstb-usb-pinmap: Fix an IS_ERR() vs NULL check

Message ID 20201102075655.GA4163205@mwanda (mailing list archive)
State Accepted
Commit 35ad0d901eac56ac6af2e4d726f255486c1ee36c
Headers show
Series usb: misc: brcmstb-usb-pinmap: Fix an IS_ERR() vs NULL check | expand

Commit Message

Dan Carpenter Nov. 2, 2020, 7:56 a.m. UTC
The devm_ioremap() function doesn't return error pointers, it returns
NULL on error.

Fixes: 517c4c44b323 ("usb: Add driver to allow any GPIO to be used for 7211 USB signals")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The commit original commit "usb: Add driver to allow any GPIO to ..."
has a bad subsystem prefix.  This is a common anti-pattern for new
drivers.  (Although less common after I started whinging to everyone
about it).  It means that the first person to fix a bug in the driver
has to imagine what the original author wanted.  Sometimes people get
annoyed which prefix we pick for them.

 drivers/usb/misc/brcmstb-usb-pinmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alan Cooper Nov. 3, 2020, 7:53 p.m. UTC | #1
On Mon, Nov 2, 2020 at 2:57 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The devm_ioremap() function doesn't return error pointers, it returns
> NULL on error.
>
> Fixes: 517c4c44b323 ("usb: Add driver to allow any GPIO to be used for 7211 USB signals")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> The commit original commit "usb: Add driver to allow any GPIO to ..."
> has a bad subsystem prefix.  This is a common anti-pattern for new
> drivers.  (Although less common after I started whinging to everyone
> about it).  It means that the first person to fix a bug in the driver
> has to imagine what the original author wanted.  Sometimes people get
> annoyed which prefix we pick for them.
>
>  drivers/usb/misc/brcmstb-usb-pinmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/misc/brcmstb-usb-pinmap.c b/drivers/usb/misc/brcmstb-usb-pinmap.c
> index 02144c39aaba..2326e60545f7 100644
> --- a/drivers/usb/misc/brcmstb-usb-pinmap.c
> +++ b/drivers/usb/misc/brcmstb-usb-pinmap.c
> @@ -277,8 +277,8 @@ static int __init brcmstb_usb_pinmap_probe(struct platform_device *pdev)
>         pdata->out_pins = (struct out_pin *)(pdata->in_pins + in_count);
>
>         pdata->regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
> -       if (IS_ERR(pdata->regs))
> -               return PTR_ERR(pdata->regs);
> +       if (!pdata->regs)
> +               return -ENOMEM;
>         platform_set_drvdata(pdev, pdata);
>
>         err = parse_pins(&pdev->dev, dn, pdata);
> --
> 2.28.0
>

Acked-by: Al Cooper <alcooperx@gmail.com> # prefix change noted
diff mbox series

Patch

diff --git a/drivers/usb/misc/brcmstb-usb-pinmap.c b/drivers/usb/misc/brcmstb-usb-pinmap.c
index 02144c39aaba..2326e60545f7 100644
--- a/drivers/usb/misc/brcmstb-usb-pinmap.c
+++ b/drivers/usb/misc/brcmstb-usb-pinmap.c
@@ -277,8 +277,8 @@  static int __init brcmstb_usb_pinmap_probe(struct platform_device *pdev)
 	pdata->out_pins = (struct out_pin *)(pdata->in_pins + in_count);
 
 	pdata->regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (IS_ERR(pdata->regs))
-		return PTR_ERR(pdata->regs);
+	if (!pdata->regs)
+		return -ENOMEM;
 	platform_set_drvdata(pdev, pdata);
 
 	err = parse_pins(&pdev->dev, dn, pdata);