From 9212f8ee412012252d4d7c93ea262b415ced00e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 13 Dec 2019 19:43:48 +0200 Subject: [PATCH] drm/edid: Make sure the CEA mode arrays have the correct amount of modes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We depend on a specific relationship between the VIC number and the index in the CEA mode arrays. Assert that the arrays have the expected size to make sure we've not accidentally left holes in them. v2: Pimp the BUILD_BUG_ON()s v3: Fix typos (Manasi) Cc: Hans Verkuil Reviewed-by: Manasi Navare Reviewed-by: Thomas Anderson Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20191213174348.27261-5-ville.syrjala@linux.intel.com --- drivers/gpu/drm/drm_edid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 8bc69da..ec5b881 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3213,6 +3213,9 @@ static u8 *drm_find_cea_extension(const struct edid *edid) static const struct drm_display_mode *cea_mode_for_vic(u8 vic) { + BUILD_BUG_ON(1 + ARRAY_SIZE(edid_cea_modes_1) - 1 != 127); + BUILD_BUG_ON(193 + ARRAY_SIZE(edid_cea_modes_193) - 1 != 219); + if (vic >= 1 && vic < 1 + ARRAY_SIZE(edid_cea_modes_1)) return &edid_cea_modes_1[vic - 1]; if (vic >= 193 && vic < 193 + ARRAY_SIZE(edid_cea_modes_193)) -- 2.7.4