diff mbox series

[07/15] drm/edid: split drm_edid block count helper

Message ID d573b83a4a55f3da6949b2e89c001a74d1932d96.1665496046.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: EDID override refactoring and fixes | expand

Commit Message

Jani Nikula Oct. 11, 2022, 1:49 p.m. UTC
Split the drm_edid block count helper to a base version that reports the
block count indicated by EDID contents, and another on top that limits
the block count based on size allocated for the EDID.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Ville Syrjälä Oct. 19, 2022, 7:44 p.m. UTC | #1
On Tue, Oct 11, 2022 at 04:49:41PM +0300, Jani Nikula wrote:
> Split the drm_edid block count helper to a base version that reports the
> block count indicated by EDID contents, and another on top that limits
> the block count based on size allocated for the EDID.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 8baa46dc2537..616c1cdc7507 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1613,7 +1613,8 @@ static const void *edid_extension_block_data(const struct edid *edid, int index)
>  	return edid_block_data(edid, index + 1);
>  }
>  
> -static int drm_edid_block_count(const struct drm_edid *drm_edid)
> +/* EDID block count indicated in EDID, may exceed allocated size */
> +static int __drm_edid_block_count(const struct drm_edid *drm_edid)
>  {
>  	int num_blocks;
>  
> @@ -1633,12 +1634,18 @@ static int drm_edid_block_count(const struct drm_edid *drm_edid)
>  			num_blocks = eeodb;
>  	}
>  
> -	/* Limit by allocated size */
> -	num_blocks = min(num_blocks, (int)drm_edid->size / EDID_LENGTH);
> -
>  	return num_blocks;
>  }
>  
> +/* EDID block count, limited by allocated size */
> +static int drm_edid_block_count(const struct drm_edid *drm_edid)
> +{
> +	/* Limit by allocated size */
> +	return min(__drm_edid_block_count(drm_edid),
> +		   (int)drm_edid->size / EDID_LENGTH);
> +}
> +
> +/* EDID extension block count, limited by allocated size */
>  static int drm_edid_extension_block_count(const struct drm_edid *drm_edid)
>  {
>  	return drm_edid_block_count(drm_edid) - 1;
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 8baa46dc2537..616c1cdc7507 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1613,7 +1613,8 @@  static const void *edid_extension_block_data(const struct edid *edid, int index)
 	return edid_block_data(edid, index + 1);
 }
 
-static int drm_edid_block_count(const struct drm_edid *drm_edid)
+/* EDID block count indicated in EDID, may exceed allocated size */
+static int __drm_edid_block_count(const struct drm_edid *drm_edid)
 {
 	int num_blocks;
 
@@ -1633,12 +1634,18 @@  static int drm_edid_block_count(const struct drm_edid *drm_edid)
 			num_blocks = eeodb;
 	}
 
-	/* Limit by allocated size */
-	num_blocks = min(num_blocks, (int)drm_edid->size / EDID_LENGTH);
-
 	return num_blocks;
 }
 
+/* EDID block count, limited by allocated size */
+static int drm_edid_block_count(const struct drm_edid *drm_edid)
+{
+	/* Limit by allocated size */
+	return min(__drm_edid_block_count(drm_edid),
+		   (int)drm_edid->size / EDID_LENGTH);
+}
+
+/* EDID extension block count, limited by allocated size */
 static int drm_edid_extension_block_count(const struct drm_edid *drm_edid)
 {
 	return drm_edid_block_count(drm_edid) - 1;