diff mbox series

[v5,10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func

Message ID 20241011173052.1088341-11-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State New
Headers show
Series media: platform: rzg2l-cru: CSI-2 and CRU enhancements | expand

Commit Message

Lad, Prabhakar Oct. 11, 2024, 5:30 p.m. UTC
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

`WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
because the `rzg2l_cru_format_align()` function ensures that a valid
`pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
non-NULL value, making the check redundant.

Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
`u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
now  resolved by removing the invalid error return path.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Laurent Pinchart Oct. 15, 2024, 10:22 a.m. UTC | #1
Hi Prabhakar,

Thank you for the patch.

On Fri, Oct 11, 2024 at 06:30:40PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> `WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
> because the `rzg2l_cru_format_align()` function ensures that a valid
> `pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
> a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
> non-NULL value, making the check redundant.
> 
> Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
> `u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
> now  resolved by removing the invalid error return path.

s/now  /now /

> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index de88c0fab961..401ef7be58ec 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -835,9 +835,6 @@ static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
>  
>  	fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
>  
> -	if (WARN_ON(!fmt))
> -		return -EINVAL;
> -
>  	return pix->width * fmt->bpp[0];
>  }
>
Lad, Prabhakar Oct. 15, 2024, 5:33 p.m. UTC | #2
Hi Laurent,

Thank you for the review.

On Tue, Oct 15, 2024 at 11:22 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Fri, Oct 11, 2024 at 06:30:40PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > `WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
> > because the `rzg2l_cru_format_align()` function ensures that a valid
> > `pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
> > a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
> > non-NULL value, making the check redundant.
> >
> > Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
> > `u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
> > now  resolved by removing the invalid error return path.
>
> s/now  /now /
>
Oops, I will drop the extra space.

Cheers,
Prabhakar
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index de88c0fab961..401ef7be58ec 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -835,9 +835,6 @@  static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
 
 	fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
 
-	if (WARN_ON(!fmt))
-		return -EINVAL;
-
 	return pix->width * fmt->bpp[0];
 }