* [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
@ 2025-04-28 9:52 Prabhakar
2025-04-28 9:59 ` Laurent Pinchart
0 siblings, 1 reply; 10+ messages in thread
From: Prabhakar @ 2025-04-28 9:52 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Tommaso Merciai, Lad Prabhakar, Dan Carpenter
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
comparison in the return path. Now the function explicitly returns `true`
if the FIFO write and read pointers match, and `false` otherwise, improving
readability without changing behavior.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 067c6af14e95..97faefcd6019 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
if (amnfifopntr_w == amnfifopntr_r_y)
return true;
- return amnfifopntr_w == amnfifopntr_r_y;
+ return false;
}
void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru)
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 9:52 [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check Prabhakar
@ 2025-04-28 9:59 ` Laurent Pinchart
2025-04-28 11:17 ` Lad, Prabhakar
0 siblings, 1 reply; 10+ messages in thread
From: Laurent Pinchart @ 2025-04-28 9:59 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel,
linux-renesas-soc, Biju Das, Fabrizio Castro, Tommaso Merciai,
Lad Prabhakar, Dan Carpenter
Hi Prabhakar,
Thank you for the patch.
On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> comparison in the return path. Now the function explicitly returns `true`
> if the FIFO write and read pointers match, and `false` otherwise, improving
> readability without changing behavior.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 067c6af14e95..97faefcd6019 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> if (amnfifopntr_w == amnfifopntr_r_y)
> return true;
>
> - return amnfifopntr_w == amnfifopntr_r_y;
> + return false;
So the function always returned true. This seems to be a bug fix, please
add a Fixes: tag. The commit message should also make it clear that
you're fixing an issue, not just simplifying the code.
Personally I'd have written
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 067c6af14e95..3d0810b3c35e 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
amnfifopntr_r_y =
(amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
- if (amnfifopntr_w == amnfifopntr_r_y)
- return true;
return amnfifopntr_w == amnfifopntr_r_y;
}
but that's also a bit of a style preference.
> }
>
> void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru)
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 9:59 ` Laurent Pinchart
@ 2025-04-28 11:17 ` Lad, Prabhakar
2025-04-28 11:25 ` Laurent Pinchart
0 siblings, 1 reply; 10+ messages in thread
From: Lad, Prabhakar @ 2025-04-28 11:17 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel,
linux-renesas-soc, Biju Das, Fabrizio Castro, Tommaso Merciai,
Lad Prabhakar, Dan Carpenter
Hi Laurent,
Thank you for the review.
On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > comparison in the return path. Now the function explicitly returns `true`
> > if the FIFO write and read pointers match, and `false` otherwise, improving
> > readability without changing behavior.
> >
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > index 067c6af14e95..97faefcd6019 100644
> > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > if (amnfifopntr_w == amnfifopntr_r_y)
> > return true;
> >
> > - return amnfifopntr_w == amnfifopntr_r_y;
> > + return false;
>
> So the function always returned true. This seems to be a bug fix, please
> add a Fixes: tag. The commit message should also make it clear that
> you're fixing an issue, not just simplifying the code.
>
No, the function returned true only if the pointers matched;
otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
simply removing the repetitive pointer check and directly returning
false at the end of the function, as we can be certain at that point.
Hence, I did not add a Fixes tag. Am I missing something?
> Personally I'd have written
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 067c6af14e95..3d0810b3c35e 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> amnfifopntr_r_y =
> (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> - if (amnfifopntr_w == amnfifopntr_r_y)
> - return true;
>
> return amnfifopntr_w == amnfifopntr_r_y;
> }
>
> but that's also a bit of a style preference.
>
I wanted to keep this consistent with the rz3e_fifo_empty(). If you
prefer the above I'll do that in v2.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:17 ` Lad, Prabhakar
@ 2025-04-28 11:25 ` Laurent Pinchart
2025-04-28 11:32 ` Lad, Prabhakar
0 siblings, 1 reply; 10+ messages in thread
From: Laurent Pinchart @ 2025-04-28 11:25 UTC (permalink / raw)
To: Lad, Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel,
linux-renesas-soc, Biju Das, Fabrizio Castro, Tommaso Merciai,
Lad Prabhakar, Dan Carpenter
On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > >
> > > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > > comparison in the return path. Now the function explicitly returns `true`
> > > if the FIFO write and read pointers match, and `false` otherwise, improving
> > > readability without changing behavior.
> > >
> > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > ---
> > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > index 067c6af14e95..97faefcd6019 100644
> > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > return true;
> > >
> > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > + return false;
> >
> > So the function always returned true. This seems to be a bug fix, please
> > add a Fixes: tag. The commit message should also make it clear that
> > you're fixing an issue, not just simplifying the code.
>
> No, the function returned true only if the pointers matched;
> otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
> simply removing the repetitive pointer check and directly returning
> false at the end of the function, as we can be certain at that point.
> Hence, I did not add a Fixes tag. Am I missing something?
Oops, you're right, my bad.
> > Personally I'd have written
> >
> > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > index 067c6af14e95..3d0810b3c35e 100644
> > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > amnfifopntr_r_y =
> > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > - if (amnfifopntr_w == amnfifopntr_r_y)
> > - return true;
> >
> > return amnfifopntr_w == amnfifopntr_r_y;
> > }
> >
> > but that's also a bit of a style preference.
>
> I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> prefer the above I'll do that in v2.
Up to you.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:25 ` Laurent Pinchart
@ 2025-04-28 11:32 ` Lad, Prabhakar
2025-04-28 11:36 ` Biju Das
2025-04-28 11:36 ` Geert Uytterhoeven
0 siblings, 2 replies; 10+ messages in thread
From: Lad, Prabhakar @ 2025-04-28 11:32 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel,
linux-renesas-soc, Biju Das, Fabrizio Castro, Tommaso Merciai,
Lad Prabhakar, Dan Carpenter
Hi Laurent,
On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > >
> > > > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > > > comparison in the return path. Now the function explicitly returns `true`
> > > > if the FIFO write and read pointers match, and `false` otherwise, improving
> > > > readability without changing behavior.
> > > >
> > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > ---
> > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > index 067c6af14e95..97faefcd6019 100644
> > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > return true;
> > > >
> > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > + return false;
> > >
> > > So the function always returned true. This seems to be a bug fix, please
> > > add a Fixes: tag. The commit message should also make it clear that
> > > you're fixing an issue, not just simplifying the code.
> >
> > No, the function returned true only if the pointers matched;
> > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
> > simply removing the repetitive pointer check and directly returning
> > false at the end of the function, as we can be certain at that point.
> > Hence, I did not add a Fixes tag. Am I missing something?
>
> Oops, you're right, my bad.
>
> > > Personally I'd have written
> > >
> > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > index 067c6af14e95..3d0810b3c35e 100644
> > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > amnfifopntr_r_y =
> > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > - return true;
> > >
> > > return amnfifopntr_w == amnfifopntr_r_y;
> > > }
> > >
> > > but that's also a bit of a style preference.
> >
> > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > prefer the above I'll do that in v2.
>
> Up to you.
>
Thanks. OK, let's keep this patch as is to stay consistent with
rz3e_fifo_empty().
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:32 ` Lad, Prabhakar
@ 2025-04-28 11:36 ` Biju Das
2025-04-28 13:23 ` Lad, Prabhakar
2025-04-28 11:36 ` Geert Uytterhoeven
1 sibling, 1 reply; 10+ messages in thread
From: Biju Das @ 2025-04-28 11:36 UTC (permalink / raw)
To: Lad, Prabhakar, laurent.pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Fabrizio Castro, Tommaso Merciai, Prabhakar Mahadev Lad,
Dan Carpenter
> -----Original Message-----
> From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> Sent: 28 April 2025 12:33
> Subject: Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
>
> Hi Laurent,
>
> On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:
> >
> > On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > >
> > > > > Simplify the `rzg2l_fifo_empty()` helper by removing the
> > > > > redundant comparison in the return path. Now the function
> > > > > explicitly returns `true` if the FIFO write and read pointers
> > > > > match, and `false` otherwise, improving readability without changing behavior.
> > > > >
> > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > > Closes:
> > > > > https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > > Signed-off-by: Lad Prabhakar
> > > > > <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > ---
> > > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git
> > > > > a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > index 067c6af14e95..97faefcd6019 100644
> > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > return true;
> > > > >
> > > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > > + return false;
> > > >
> > > > So the function always returned true. This seems to be a bug fix,
> > > > please add a Fixes: tag. The commit message should also make it
> > > > clear that you're fixing an issue, not just simplifying the code.
> > >
> > > No, the function returned true only if the pointers matched;
> > > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I
> > > was simply removing the repetitive pointer check and directly
> > > returning false at the end of the function, as we can be certain at that point.
> > > Hence, I did not add a Fixes tag. Am I missing something?
> >
> > Oops, you're right, my bad.
> >
> > > > Personally I'd have written
> > > >
> > > > diff --git
> > > > a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > index 067c6af14e95..3d0810b3c35e 100644
> > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > > amnfifopntr_r_y =
> > > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > > - return true;
> > > >
> > > > return amnfifopntr_w == amnfifopntr_r_y; }
> > > >
> > > > but that's also a bit of a style preference.
> > >
> > > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > > prefer the above I'll do that in v2.
> >
> > Up to you.
> >
> Thanks. OK, let's keep this patch as is to stay consistent with rz3e_fifo_empty().
Looks a typo rz3e_fifo_empty()->rzg3e_fifo_empty(). Above as well.
Cheers,
Biju
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:32 ` Lad, Prabhakar
2025-04-28 11:36 ` Biju Das
@ 2025-04-28 11:36 ` Geert Uytterhoeven
2025-04-28 13:25 ` Lad, Prabhakar
1 sibling, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2025-04-28 11:36 UTC (permalink / raw)
To: Lad, Prabhakar
Cc: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel, linux-renesas-soc, Biju Das,
Fabrizio Castro, Tommaso Merciai, Lad Prabhakar, Dan Carpenter
Hi Prabhakar,
On Mon, 28 Apr 2025 at 13:33, Lad, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart
> <laurent.pinchart@ideasonboard.com> wrote:
> > On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > >
> > > > > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > > > > comparison in the return path. Now the function explicitly returns `true`
> > > > > if the FIFO write and read pointers match, and `false` otherwise, improving
> > > > > readability without changing behavior.
> > > > >
> > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > ---
> > > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > index 067c6af14e95..97faefcd6019 100644
> > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > return true;
> > > > >
> > > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > > + return false;
> > > >
> > > > So the function always returned true. This seems to be a bug fix, please
> > > > add a Fixes: tag. The commit message should also make it clear that
> > > > you're fixing an issue, not just simplifying the code.
> > >
> > > No, the function returned true only if the pointers matched;
> > > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
> > > simply removing the repetitive pointer check and directly returning
> > > false at the end of the function, as we can be certain at that point.
> > > Hence, I did not add a Fixes tag. Am I missing something?
> >
> > Oops, you're right, my bad.
> >
> > > > Personally I'd have written
> > > >
> > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > index 067c6af14e95..3d0810b3c35e 100644
> > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > > amnfifopntr_r_y =
> > > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > > - return true;
> > > >
> > > > return amnfifopntr_w == amnfifopntr_r_y;
> > > > }
> > > >
> > > > but that's also a bit of a style preference.
> > >
> > > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > > prefer the above I'll do that in v2.
> >
> > Up to you.
> >
> Thanks. OK, let's keep this patch as is to stay consistent with
> rz3e_fifo_empty().
rz3e_fifo_empty() has a rather complex conditional expression.
This one will probably be converted to a simple return statement by
a random janitor, soon after its introduction ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:36 ` Biju Das
@ 2025-04-28 13:23 ` Lad, Prabhakar
0 siblings, 0 replies; 10+ messages in thread
From: Lad, Prabhakar @ 2025-04-28 13:23 UTC (permalink / raw)
To: Biju Das
Cc: laurent.pinchart, Mauro Carvalho Chehab, Hans Verkuil,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, Fabrizio Castro,
Tommaso Merciai, Prabhakar Mahadev Lad, Dan Carpenter
On Mon, Apr 28, 2025 at 12:36 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> > Sent: 28 April 2025 12:33
> > Subject: Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
> >
> > Hi Laurent,
> >
> > On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:
> > >
> > > On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > > > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > >
> > > > > > Simplify the `rzg2l_fifo_empty()` helper by removing the
> > > > > > redundant comparison in the return path. Now the function
> > > > > > explicitly returns `true` if the FIFO write and read pointers
> > > > > > match, and `false` otherwise, improving readability without changing behavior.
> > > > > >
> > > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > > > Closes:
> > > > > > https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > > > Signed-off-by: Lad Prabhakar
> > > > > > <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > > ---
> > > > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git
> > > > > > a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > index 067c6af14e95..97faefcd6019 100644
> > > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > > return true;
> > > > > >
> > > > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > > > + return false;
> > > > >
> > > > > So the function always returned true. This seems to be a bug fix,
> > > > > please add a Fixes: tag. The commit message should also make it
> > > > > clear that you're fixing an issue, not just simplifying the code.
> > > >
> > > > No, the function returned true only if the pointers matched;
> > > > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I
> > > > was simply removing the repetitive pointer check and directly
> > > > returning false at the end of the function, as we can be certain at that point.
> > > > Hence, I did not add a Fixes tag. Am I missing something?
> > >
> > > Oops, you're right, my bad.
> > >
> > > > > Personally I'd have written
> > > > >
> > > > > diff --git
> > > > > a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > index 067c6af14e95..3d0810b3c35e 100644
> > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > > > amnfifopntr_r_y =
> > > > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > - return true;
> > > > >
> > > > > return amnfifopntr_w == amnfifopntr_r_y; }
> > > > >
> > > > > but that's also a bit of a style preference.
> > > >
> > > > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > > > prefer the above I'll do that in v2.
> > >
> > > Up to you.
> > >
> > Thanks. OK, let's keep this patch as is to stay consistent with rz3e_fifo_empty().
>
> Looks a typo rz3e_fifo_empty()->rzg3e_fifo_empty(). Above as well.
>
Good catch, this typo needs fixing.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 11:36 ` Geert Uytterhoeven
@ 2025-04-28 13:25 ` Lad, Prabhakar
2025-04-28 13:37 ` Geert Uytterhoeven
0 siblings, 1 reply; 10+ messages in thread
From: Lad, Prabhakar @ 2025-04-28 13:25 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel, linux-renesas-soc, Biju Das,
Fabrizio Castro, Tommaso Merciai, Lad Prabhakar, Dan Carpenter
Hi Geert,
On Mon, Apr 28, 2025 at 12:36 PM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>
> Hi Prabhakar,
>
> On Mon, 28 Apr 2025 at 13:33, Lad, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> > On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart
> > <laurent.pinchart@ideasonboard.com> wrote:
> > > On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > > > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > >
> > > > > > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > > > > > comparison in the return path. Now the function explicitly returns `true`
> > > > > > if the FIFO write and read pointers match, and `false` otherwise, improving
> > > > > > readability without changing behavior.
> > > > > >
> > > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > > > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > > ---
> > > > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > index 067c6af14e95..97faefcd6019 100644
> > > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > > return true;
> > > > > >
> > > > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > > > + return false;
> > > > >
> > > > > So the function always returned true. This seems to be a bug fix, please
> > > > > add a Fixes: tag. The commit message should also make it clear that
> > > > > you're fixing an issue, not just simplifying the code.
> > > >
> > > > No, the function returned true only if the pointers matched;
> > > > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
> > > > simply removing the repetitive pointer check and directly returning
> > > > false at the end of the function, as we can be certain at that point.
> > > > Hence, I did not add a Fixes tag. Am I missing something?
> > >
> > > Oops, you're right, my bad.
> > >
> > > > > Personally I'd have written
> > > > >
> > > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > index 067c6af14e95..3d0810b3c35e 100644
> > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > > > amnfifopntr_r_y =
> > > > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > - return true;
> > > > >
> > > > > return amnfifopntr_w == amnfifopntr_r_y;
> > > > > }
> > > > >
> > > > > but that's also a bit of a style preference.
> > > >
> > > > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > > > prefer the above I'll do that in v2.
> > >
> > > Up to you.
> > >
> > Thanks. OK, let's keep this patch as is to stay consistent with
> > rz3e_fifo_empty().
>
> rz3e_fifo_empty() has a rather complex conditional expression.
>
Hmm yes.
> This one will probably be converted to a simple return statement by
> a random janitor, soon after its introduction ;-)
>
Agreed, are you already working on it?
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check
2025-04-28 13:25 ` Lad, Prabhakar
@ 2025-04-28 13:37 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2025-04-28 13:37 UTC (permalink / raw)
To: Lad, Prabhakar
Cc: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel, linux-renesas-soc, Biju Das,
Fabrizio Castro, Tommaso Merciai, Lad Prabhakar, Dan Carpenter
Hi Prabhakar,
On Mon, 28 Apr 2025 at 15:25, Lad, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> On Mon, Apr 28, 2025 at 12:36 PM Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Mon, 28 Apr 2025 at 13:33, Lad, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> > > On Mon, Apr 28, 2025 at 12:25 PM Laurent Pinchart
> > > <laurent.pinchart@ideasonboard.com> wrote:
> > > > On Mon, Apr 28, 2025 at 12:17:54PM +0100, Lad, Prabhakar wrote:
> > > > > On Mon, Apr 28, 2025 at 10:59 AM Laurent Pinchart wrote:
> > > > > > On Mon, Apr 28, 2025 at 10:52:08AM +0100, Prabhakar wrote:
> > > > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > > >
> > > > > > > Simplify the `rzg2l_fifo_empty()` helper by removing the redundant
> > > > > > > comparison in the return path. Now the function explicitly returns `true`
> > > > > > > if the FIFO write and read pointers match, and `false` otherwise, improving
> > > > > > > readability without changing behavior.
> > > > > > >
> > > > > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > > > > Closes: https://lore.kernel.org/all/aAtQThCibZCROETx@stanley.mountain/
> > > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > > > > ---
> > > > > > > drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 2 +-
> > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > > >
> > > > > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > > index 067c6af14e95..97faefcd6019 100644
> > > > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > > @@ -348,7 +348,7 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > > > if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > > > return true;
> > > > > > >
> > > > > > > - return amnfifopntr_w == amnfifopntr_r_y;
> > > > > > > + return false;
> > > > > >
> > > > > > So the function always returned true. This seems to be a bug fix, please
> > > > > > add a Fixes: tag. The commit message should also make it clear that
> > > > > > you're fixing an issue, not just simplifying the code.
> > > > >
> > > > > No, the function returned true only if the pointers matched;
> > > > > otherwise, amnfifopntr_w == amnfifopntr_r_y would return false. I was
> > > > > simply removing the repetitive pointer check and directly returning
> > > > > false at the end of the function, as we can be certain at that point.
> > > > > Hence, I did not add a Fixes tag. Am I missing something?
> > > >
> > > > Oops, you're right, my bad.
> > > >
> > > > > > Personally I'd have written
> > > > > >
> > > > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > index 067c6af14e95..3d0810b3c35e 100644
> > > > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > > > @@ -345,8 +345,6 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru)
> > > > > > amnfifopntr_w = amnfifopntr & AMnFIFOPNTR_FIFOWPNTR;
> > > > > > amnfifopntr_r_y =
> > > > > > (amnfifopntr & AMnFIFOPNTR_FIFORPNTR_Y) >> 16;
> > > > > > - if (amnfifopntr_w == amnfifopntr_r_y)
> > > > > > - return true;
> > > > > >
> > > > > > return amnfifopntr_w == amnfifopntr_r_y;
> > > > > > }
> > > > > >
> > > > > > but that's also a bit of a style preference.
> > > > >
> > > > > I wanted to keep this consistent with the rz3e_fifo_empty(). If you
> > > > > prefer the above I'll do that in v2.
> > > >
> > > > Up to you.
> > > >
> > > Thanks. OK, let's keep this patch as is to stay consistent with
> > > rz3e_fifo_empty().
> >
> > rz3e_fifo_empty() has a rather complex conditional expression.
> >
> Hmm yes.
>
> > This one will probably be converted to a simple return statement by
> > a random janitor, soon after its introduction ;-)
> >
> Agreed, are you already working on it?
Nice try ;-)
-EBUSY.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-04-28 13:38 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-28 9:52 [PATCH] media: renesas: rzg2l-cru: Simplify FIFO empty check Prabhakar
2025-04-28 9:59 ` Laurent Pinchart
2025-04-28 11:17 ` Lad, Prabhakar
2025-04-28 11:25 ` Laurent Pinchart
2025-04-28 11:32 ` Lad, Prabhakar
2025-04-28 11:36 ` Biju Das
2025-04-28 13:23 ` Lad, Prabhakar
2025-04-28 11:36 ` Geert Uytterhoeven
2025-04-28 13:25 ` Lad, Prabhakar
2025-04-28 13:37 ` Geert Uytterhoeven
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.