Skip to content

Commit b16c9e6

Browse files
committed
drm/edid: split drm_edid block count helper
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 <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/a7d63878c7fb3dd6f3b987f5257897113797b94f.1666614699.git.jani.nikula@intel.com
1 parent 019b938 commit b16c9e6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/gpu/drm/drm_edid.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,8 @@ static const void *edid_extension_block_data(const struct edid *edid, int index)
16131613
return edid_block_data(edid, index + 1);
16141614
}
16151615

1616-
static int drm_edid_block_count(const struct drm_edid *drm_edid)
1616+
/* EDID block count indicated in EDID, may exceed allocated size */
1617+
static int __drm_edid_block_count(const struct drm_edid *drm_edid)
16171618
{
16181619
int num_blocks;
16191620

@@ -1633,12 +1634,18 @@ static int drm_edid_block_count(const struct drm_edid *drm_edid)
16331634
num_blocks = eeodb;
16341635
}
16351636

1636-
/* Limit by allocated size */
1637-
num_blocks = min(num_blocks, (int)drm_edid->size / EDID_LENGTH);
1638-
16391637
return num_blocks;
16401638
}
16411639

1640+
/* EDID block count, limited by allocated size */
1641+
static int drm_edid_block_count(const struct drm_edid *drm_edid)
1642+
{
1643+
/* Limit by allocated size */
1644+
return min(__drm_edid_block_count(drm_edid),
1645+
(int)drm_edid->size / EDID_LENGTH);
1646+
}
1647+
1648+
/* EDID extension block count, limited by allocated size */
16421649
static int drm_edid_extension_block_count(const struct drm_edid *drm_edid)
16431650
{
16441651
return drm_edid_block_count(drm_edid) - 1;

0 commit comments

Comments
 (0)