drm/i915/dsi: be defensive about out of bounds sequence id
authorJani Nikula <jani.nikula@intel.com>
Mon, 21 Dec 2015 13:10:58 +0000 (15:10 +0200)
committerJani Nikula <jani.nikula@intel.com>
Tue, 5 Jan 2016 14:38:11 +0000 (16:38 +0200)
Untie the VBT based generic panel driver from the VBT parsing, so that
the two don't have to be updated in lockstep.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/7a6e3e7c4404c0e4dbcf003acd8737a6ecbe218f.1450702954.git.jani.nikula@intel.com
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c

index aa1f7bc8f4d0bee0376ba7b432494ba156228a51..c6aea69230e838441eb1c01503fc54d699d23a8e 100644 (file)
@@ -246,14 +246,21 @@ static const fn_mipi_elem_exec exec_elem[] = {
  */
 
 static const char * const seq_name[] = {
-       "UNDEFINED",
-       "MIPI_SEQ_ASSERT_RESET",
-       "MIPI_SEQ_INIT_OTP",
-       "MIPI_SEQ_DISPLAY_ON",
-       "MIPI_SEQ_DISPLAY_OFF",
-       "MIPI_SEQ_DEASSERT_RESET"
+       [MIPI_SEQ_ASSERT_RESET] = "MIPI_SEQ_ASSERT_RESET",
+       [MIPI_SEQ_INIT_OTP] = "MIPI_SEQ_INIT_OTP",
+       [MIPI_SEQ_DISPLAY_ON] = "MIPI_SEQ_DISPLAY_ON",
+       [MIPI_SEQ_DISPLAY_OFF]  = "MIPI_SEQ_DISPLAY_OFF",
+       [MIPI_SEQ_DEASSERT_RESET] = "MIPI_SEQ_DEASSERT_RESET",
 };
 
+static const char *sequence_name(enum mipi_seq seq_id)
+{
+       if (seq_id < ARRAY_SIZE(seq_name) && seq_name[seq_id])
+               return seq_name[seq_id];
+       else
+               return "(unknown)";
+}
+
 static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)
 {
        fn_mipi_elem_exec mipi_elem_exec;
@@ -262,7 +269,8 @@ static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)
        if (!data)
                return;
 
-       DRM_DEBUG_DRIVER("Starting MIPI sequence - %s\n", seq_name[*data]);
+       DRM_DEBUG_DRIVER("Starting MIPI sequence %u - %s\n",
+                        *data, sequence_name(*data));
 
        /* go to the first element of the sequence */
        data++;