[PATCH v2 11/16] media: platform: rzg2l-cru: rzg2l-ip: Use `rzg2l_cru_ip_formats` array in enum_frame_size callback

Prabhakar posted 16 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH v2 11/16] media: platform: rzg2l-cru: rzg2l-ip: Use `rzg2l_cru_ip_formats` array in enum_frame_size callback
Posted by Prabhakar 2 months, 2 weeks ago
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Use the `rzg2l_cru_ip_formats` array in `rzg2l_cru_ip_enum_frame_size()`
to validate the index range and format code.

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

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 2d3b985b7b0d..c7bc82bf3f14 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -162,10 +162,10 @@ static int rzg2l_cru_ip_enum_frame_size(struct v4l2_subdev *sd,
 					struct v4l2_subdev_state *state,
 					struct v4l2_subdev_frame_size_enum *fse)
 {
-	if (fse->index != 0)
+	if (fse->index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
 		return -EINVAL;
 
-	if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16)
+	if (!rzg2l_cru_ip_code_to_fmt(fse->code))
 		return -EINVAL;
 
 	fse->min_width = RZG2L_CRU_MIN_INPUT_WIDTH;
-- 
2.34.1
Re: [PATCH v2 11/16] media: platform: rzg2l-cru: rzg2l-ip: Use `rzg2l_cru_ip_formats` array in enum_frame_size callback
Posted by Laurent Pinchart 2 months ago
Hi Prabhakar,

Thank you for the patch.

On Tue, Sep 10, 2024 at 06:53:52PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> Use the `rzg2l_cru_ip_formats` array in `rzg2l_cru_ip_enum_frame_size()`
> to validate the index range and format code.
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> index 2d3b985b7b0d..c7bc82bf3f14 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> @@ -162,10 +162,10 @@ static int rzg2l_cru_ip_enum_frame_size(struct v4l2_subdev *sd,
>  					struct v4l2_subdev_state *state,
>  					struct v4l2_subdev_frame_size_enum *fse)
>  {
> -	if (fse->index != 0)
> +	if (fse->index >= ARRAY_SIZE(rzg2l_cru_ip_formats))

This isn't right, the index is related to frame sizes, not frame
formats. You should keep the code as-is.

>  		return -EINVAL;
>  
> -	if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16)
> +	if (!rzg2l_cru_ip_code_to_fmt(fse->code))
>  		return -EINVAL;

This is good.

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

>  
>  	fse->min_width = RZG2L_CRU_MIN_INPUT_WIDTH;

-- 
Regards,

Laurent Pinchart