OSDN Git Service

drm/i915: constify find_section in VBT parsing
authorJani Nikula <jani.nikula@intel.com>
Wed, 15 Apr 2015 12:18:28 +0000 (15:18 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 20 May 2015 09:25:49 +0000 (11:25 +0200)
Make input and output of find_section const, and fix the fallout. We
shouldn't modify the VBT, so make the compiler help us here.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_bios.c

index cee596d..5876e7c 100644 (file)
 
 static int panel_type;
 
-static void *
-find_section(struct bdb_header *bdb, int section_id)
+static const void *
+find_section(const void *_bdb, int section_id)
 {
-       u8 *base = (u8 *)bdb;
+       const struct bdb_header *bdb = _bdb;
+       const u8 *base = _bdb;
        int index = 0;
        u16 total, current_size;
        u8 current_id;
@@ -53,7 +54,7 @@ find_section(struct bdb_header *bdb, int section_id)
                current_id = *(base + index);
                index++;
 
-               current_size = *((u16 *)(base + index));
+               current_size = *((const u16 *)(base + index));
                index += 2;
 
                if (index + current_size > total)
@@ -69,7 +70,7 @@ find_section(struct bdb_header *bdb, int section_id)
 }
 
 static u16
-get_blocksize(void *p)
+get_blocksize(const void *p)
 {
        u16 *block_ptr, block_size;
 
@@ -350,7 +351,7 @@ static void
 parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
                      struct bdb_header *bdb)
 {
-       struct lvds_dvo_timing *dvo_timing;
+       const struct lvds_dvo_timing *dvo_timing;
        struct drm_display_mode *panel_fixed_mode;
        int index;
 
@@ -361,7 +362,7 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
        }
 
        if (index == -1) {
-               struct bdb_sdvo_lvds_options *sdvo_lvds_options;
+               const struct bdb_sdvo_lvds_options *sdvo_lvds_options;
 
                sdvo_lvds_options = find_section(bdb, BDB_SDVO_LVDS_OPTIONS);
                if (!sdvo_lvds_options)
@@ -405,7 +406,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
                       struct bdb_header *bdb)
 {
        struct drm_device *dev = dev_priv->dev;
-       struct bdb_general_features *general;
+       const struct bdb_general_features *general;
 
        general = find_section(bdb, BDB_GENERAL_FEATURES);
        if (general) {
@@ -430,7 +431,7 @@ static void
 parse_general_definitions(struct drm_i915_private *dev_priv,
                          struct bdb_header *bdb)
 {
-       struct bdb_general_definitions *general;
+       const struct bdb_general_definitions *general;
 
        general = find_section(bdb, BDB_GENERAL_DEFINITIONS);
        if (general) {
@@ -447,10 +448,10 @@ parse_general_definitions(struct drm_i915_private *dev_priv,
        }
 }
 
-static union child_device_config *
-child_device_ptr(struct bdb_general_definitions *p_defs, int i)
+static const union child_device_config *
+child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
 {
-       return (void *) &p_defs->devices[i * p_defs->child_dev_size];
+       return (const void *) &p_defs->devices[i * p_defs->child_dev_size];
 }
 
 static void
@@ -458,8 +459,8 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
                          struct bdb_header *bdb)
 {
        struct sdvo_device_mapping *p_mapping;
-       struct bdb_general_definitions *p_defs;
-       union child_device_config *p_child;
+       const struct bdb_general_definitions *p_defs;
+       const union child_device_config *p_child;
        int i, child_device_num, count;
        u16     block_size;
 
@@ -547,7 +548,7 @@ static void
 parse_driver_features(struct drm_i915_private *dev_priv,
                       struct bdb_header *bdb)
 {
-       struct bdb_driver_features *driver;
+       const struct bdb_driver_features *driver;
 
        driver = find_section(bdb, BDB_DRIVER_FEATURES);
        if (!driver)
@@ -573,9 +574,9 @@ parse_driver_features(struct drm_i915_private *dev_priv,
 static void
 parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 {
-       struct bdb_edp *edp;
-       struct edp_power_seq *edp_pps;
-       struct edp_link_params *edp_link_params;
+       const struct bdb_edp *edp;
+       const struct edp_power_seq *edp_pps;
+       const struct edp_link_params *edp_link_params;
 
        edp = find_section(bdb, BDB_EDP);
        if (!edp) {
@@ -685,8 +686,8 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 static void
 parse_psr(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 {
-       struct bdb_psr *psr;
-       struct psr_table *psr_table;
+       const struct bdb_psr *psr;
+       const struct psr_table *psr_table;
 
        psr = find_section(bdb, BDB_PSR);
        if (!psr) {
@@ -796,11 +797,12 @@ static u8 *goto_next_sequence(u8 *data, int *size)
 static void
 parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 {
-       struct bdb_mipi_config *start;
-       struct bdb_mipi_sequence *sequence;
-       struct mipi_config *config;
-       struct mipi_pps_data *pps;
-       u8 *data, *seq_data;
+       const struct bdb_mipi_config *start;
+       const struct bdb_mipi_sequence *sequence;
+       const struct mipi_config *config;
+       const struct mipi_pps_data *pps;
+       u8 *data;
+       const u8 *seq_data;
        int i, panel_id, seq_size;
        u16 block_size;
 
@@ -1068,8 +1070,9 @@ static void
 parse_device_mapping(struct drm_i915_private *dev_priv,
                       struct bdb_header *bdb)
 {
-       struct bdb_general_definitions *p_defs;
-       union child_device_config *p_child, *child_dev_ptr;
+       const struct bdb_general_definitions *p_defs;
+       const union child_device_config *p_child;
+       union child_device_config *child_dev_ptr;
        int i, child_device_num, count;
        u16     block_size;
 
@@ -1126,8 +1129,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv,
 
                child_dev_ptr = dev_priv->vbt.child_dev + count;
                count++;
-               memcpy((void *)child_dev_ptr, (void *)p_child,
-                                       sizeof(*p_child));
+               memcpy(child_dev_ptr, p_child, sizeof(*p_child));
        }
        return;
 }