2020-05-05 14:54:28

by Aishwarya Ramakrishnan

[permalink] [raw]
Subject: [PATCH] i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Signed-off-by: Aishwarya Ramakrishnan <[email protected]>
---
drivers/i2c/busses/i2c-nvidia-gpu.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
index f5d25ce00f03..f480105000b8 100644
--- a/drivers/i2c/busses/i2c-nvidia-gpu.c
+++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
@@ -277,10 +277,7 @@ static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
i2cd->gpu_ccgx_ucsi->irq = irq;
i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
- if (IS_ERR(i2cd->ccgx_client))
- return PTR_ERR(i2cd->ccgx_client);
-
- return 0;
+ return PTR_ERR_OR_ZERO(i2cd->ccgx_client);
}

static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)
--
2.17.1


2020-05-22 15:21:42

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code

On Tue, May 05, 2020 at 08:22:30PM +0530, Aishwarya Ramakrishnan wrote:
> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> Signed-off-by: Aishwarya Ramakrishnan <[email protected]>

Waiting for the Rev-by from Ajay (driver maintainer).

> ---
> drivers/i2c/busses/i2c-nvidia-gpu.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
> index f5d25ce00f03..f480105000b8 100644
> --- a/drivers/i2c/busses/i2c-nvidia-gpu.c
> +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
> @@ -277,10 +277,7 @@ static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
> i2cd->gpu_ccgx_ucsi->irq = irq;
> i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
> i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
> - if (IS_ERR(i2cd->ccgx_client))
> - return PTR_ERR(i2cd->ccgx_client);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(i2cd->ccgx_client);
> }
>
> static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> --
> 2.17.1
>


Attachments:
(No filename) (1.15 kB)
signature.asc (849.00 B)
Download all attachments

2020-05-26 16:12:53

by Ajay Gupta

[permalink] [raw]
Subject: RE: [PATCH] i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code

Hi Wolfram,

> -----Original Message-----
> From: [email protected] <[email protected]> On
> Behalf Of Wolfram Sang
> Sent: Friday, May 22, 2020 8:17 AM
> To: Aishwarya Ramakrishnan <[email protected]>
> Cc: Ajay Gupta <[email protected]>; [email protected]; linux-
> [email protected]
> Subject: Re: [PATCH] i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify
> code
>
> On Tue, May 05, 2020 at 08:22:30PM +0530, Aishwarya Ramakrishnan wrote:
> > PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.
> >
> > Generated by: scripts/coccinelle/api/ptr_ret.cocci
> >
> > Signed-off-by: Aishwarya Ramakrishnan <[email protected]>
>
> Waiting for the Rev-by from Ajay (driver maintainer).
Reviewed-by: Ajay Gupta <[email protected]>

Thanks
Ajay
>nvpublic
>
> > ---
> > drivers/i2c/busses/i2c-nvidia-gpu.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-
> nvidia-gpu.c
> > index f5d25ce00f03..f480105000b8 100644
> > --- a/drivers/i2c/busses/i2c-nvidia-gpu.c
> > +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
> > @@ -277,10 +277,7 @@ static int gpu_populate_client(struct gpu_i2c_dev
> *i2cd, int irq)
> > i2cd->gpu_ccgx_ucsi->irq = irq;
> > i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
> > i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd-
> >gpu_ccgx_ucsi);
> > - if (IS_ERR(i2cd->ccgx_client))
> > - return PTR_ERR(i2cd->ccgx_client);
> > -
> > - return 0;
> > + return PTR_ERR_OR_ZERO(i2cd->ccgx_client);
> > }
> >
> > static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id
> *id)
> > --
> > 2.17.1
> >

2020-05-27 15:34:38

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code

On Tue, May 05, 2020 at 08:22:30PM +0530, Aishwarya Ramakrishnan wrote:
> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> Signed-off-by: Aishwarya Ramakrishnan <[email protected]>

Applied to for-next, thanks!


Attachments:
(No filename) (292.00 B)
signature.asc (849.00 B)
Download all attachments