public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: constify find_section in VBT parsing
@ 2015-04-15 12:18 Jani Nikula
  2015-04-15 12:18 ` [PATCH 2/2] drm/i915: constify validate_vbt " Jani Nikula
  2015-05-12 12:06 ` [PATCH 1/2] drm/i915: constify find_section " Ville Syrjälä
  0 siblings, 2 replies; 8+ messages in thread
From: Jani Nikula @ 2015-04-15 12:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

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>
---
 drivers/gpu/drm/i915/intel_bios.c | 60 ++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index c08368c03dad..4e3f3f427178 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -36,10 +36,11 @@
 
 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) {
@@ -680,8 +681,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) {
@@ -791,11 +792,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;
 
@@ -1063,8 +1065,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;
 
@@ -1121,8 +1124,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;
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] drm/i915: constify validate_vbt in VBT parsing
  2015-04-15 12:18 [PATCH 1/2] drm/i915: constify find_section in VBT parsing Jani Nikula
@ 2015-04-15 12:18 ` Jani Nikula
  2015-05-12 12:09   ` Ville Syrjälä
  2015-05-12 12:06 ` [PATCH 1/2] drm/i915: constify find_section " Ville Syrjälä
  1 sibling, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2015-04-15 12:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Make input and output of validate_vbt 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>
---
 drivers/gpu/drm/i915/intel_bios.c | 50 ++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 4e3f3f427178..b1e047c5e594 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -205,7 +205,7 @@ get_lvds_fp_timing(const struct bdb_header *bdb,
 /* Try to find integrated panel data */
 static void
 parse_lfp_panel_data(struct drm_i915_private *dev_priv,
-			    struct bdb_header *bdb)
+		     const struct bdb_header *bdb)
 {
 	const struct bdb_lvds_options *lvds_options;
 	const struct bdb_lvds_lfp_data *lvds_lfp_data;
@@ -311,7 +311,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
 }
 
 static void
-parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_lfp_backlight(struct drm_i915_private *dev_priv,
+		    const struct bdb_header *bdb)
 {
 	const struct bdb_lfp_backlight_data *backlight_data;
 	const struct bdb_lfp_backlight_data_entry *entry;
@@ -349,7 +350,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 /* Try to find sdvo panel data */
 static void
 parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
-		      struct bdb_header *bdb)
+		      const struct bdb_header *bdb)
 {
 	const struct lvds_dvo_timing *dvo_timing;
 	struct drm_display_mode *panel_fixed_mode;
@@ -403,7 +404,7 @@ static int intel_bios_ssc_frequency(struct drm_device *dev,
 
 static void
 parse_general_features(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		       const struct bdb_header *bdb)
 {
 	struct drm_device *dev = dev_priv->dev;
 	const struct bdb_general_features *general;
@@ -429,7 +430,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
 
 static void
 parse_general_definitions(struct drm_i915_private *dev_priv,
-			  struct bdb_header *bdb)
+			  const struct bdb_header *bdb)
 {
 	const struct bdb_general_definitions *general;
 
@@ -456,7 +457,7 @@ child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
 
 static void
 parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
-			  struct bdb_header *bdb)
+			  const struct bdb_header *bdb)
 {
 	struct sdvo_device_mapping *p_mapping;
 	const struct bdb_general_definitions *p_defs;
@@ -546,7 +547,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
 
 static void
 parse_driver_features(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		      const struct bdb_header *bdb)
 {
 	const struct bdb_driver_features *driver;
 
@@ -572,7 +573,7 @@ parse_driver_features(struct drm_i915_private *dev_priv,
 }
 
 static void
-parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_edp *edp;
 	const struct edp_power_seq *edp_pps;
@@ -679,7 +680,7 @@ 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)
+parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_psr *psr;
 	const struct psr_table *psr_table;
@@ -790,7 +791,7 @@ static u8 *goto_next_sequence(u8 *data, int *size)
 }
 
 static void
-parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_mipi_config *start;
 	const struct bdb_mipi_sequence *sequence;
@@ -941,7 +942,7 @@ err:
 }
 
 static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
-			   struct bdb_header *bdb)
+			   const struct bdb_header *bdb)
 {
 	union child_device_config *it, *child = NULL;
 	struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
@@ -1043,7 +1044,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 }
 
 static void parse_ddi_ports(struct drm_i915_private *dev_priv,
-			    struct bdb_header *bdb)
+			    const struct bdb_header *bdb)
 {
 	struct drm_device *dev = dev_priv->dev;
 	enum port port;
@@ -1063,7 +1064,7 @@ static void parse_ddi_ports(struct drm_i915_private *dev_priv,
 
 static void
 parse_device_mapping(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		     const struct bdb_header *bdb)
 {
 	const struct bdb_general_definitions *p_defs;
 	const union child_device_config *p_child;
@@ -1193,19 +1194,21 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = {
 	{ }
 };
 
-static struct bdb_header *validate_vbt(char *base, size_t size,
-				       struct vbt_header *vbt,
-				       const char *source)
+const static struct bdb_header *validate_vbt(const void *_base, size_t size,
+					     const void *_vbt,
+					     const char *source)
 {
+	const char *base = _base;
+	const struct vbt_header *vbt = _vbt;
 	size_t offset;
-	struct bdb_header *bdb;
+	const struct bdb_header *bdb;
 
 	if (vbt == NULL) {
 		DRM_DEBUG_DRIVER("VBT signature missing\n");
 		return NULL;
 	}
 
-	offset = (char *)vbt - base;
+	offset = (const char *)vbt - base;
 	if (offset + sizeof(struct vbt_header) > size) {
 		DRM_DEBUG_DRIVER("VBT header incomplete\n");
 		return NULL;
@@ -1222,7 +1225,7 @@ static struct bdb_header *validate_vbt(char *base, size_t size,
 		return NULL;
 	}
 
-	bdb = (struct bdb_header *)(base + offset);
+	bdb = (const struct bdb_header *)(base + offset);
 	if (offset + bdb->bdb_size > size) {
 		DRM_DEBUG_DRIVER("BDB incomplete\n");
 		return NULL;
@@ -1247,7 +1250,7 @@ intel_parse_bios(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct pci_dev *pdev = dev->pdev;
-	struct bdb_header *bdb = NULL;
+	const struct bdb_header *bdb = NULL;
 	u8 __iomem *bios = NULL;
 
 	if (HAS_PCH_NOP(dev))
@@ -1257,9 +1260,8 @@ intel_parse_bios(struct drm_device *dev)
 
 	/* XXX Should this validation be moved to intel_opregion.c? */
 	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
-		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
-				   (struct vbt_header *)dev_priv->opregion.vbt,
-				   "OpRegion");
+		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
+				   dev_priv->opregion.vbt, "OpRegion");
 
 	if (bdb == NULL) {
 		size_t i, size;
@@ -1272,7 +1274,7 @@ intel_parse_bios(struct drm_device *dev)
 		for (i = 0; i + 4 < size; i++) {
 			if (memcmp(bios + i, "$VBT", 4) == 0) {
 				bdb = validate_vbt(bios, size,
-						   (struct vbt_header *)(bios + i),
+						   bios + i,
 						   "PCI ROM");
 				break;
 			}
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] drm/i915: constify find_section in VBT parsing
  2015-04-15 12:18 [PATCH 1/2] drm/i915: constify find_section in VBT parsing Jani Nikula
  2015-04-15 12:18 ` [PATCH 2/2] drm/i915: constify validate_vbt " Jani Nikula
@ 2015-05-12 12:06 ` Ville Syrjälä
  2015-05-12 12:30   ` Jani Nikula
  1 sibling, 1 reply; 8+ messages in thread
From: Ville Syrjälä @ 2015-05-12 12:06 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Wed, Apr 15, 2015 at 03:18:28PM +0300, Jani Nikula wrote:
> 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>
> ---
>  drivers/gpu/drm/i915/intel_bios.c | 60 ++++++++++++++++++++-------------------
>  1 file changed, 31 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> index c08368c03dad..4e3f3f427178 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -36,10 +36,11 @@
>  
>  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) {
> @@ -680,8 +681,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) {
> @@ -791,11 +792,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;

It would seem this guy could be constified as well, with a bit of extra
effort that is.

But the patch as is looks reasonable so:
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> +	const u8 *seq_data;
>  	int i, panel_id, seq_size;
>  	u16 block_size;
>  
> @@ -1063,8 +1065,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;
>  
> @@ -1121,8 +1124,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;
>  }
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] drm/i915: constify validate_vbt in VBT parsing
  2015-04-15 12:18 ` [PATCH 2/2] drm/i915: constify validate_vbt " Jani Nikula
@ 2015-05-12 12:09   ` Ville Syrjälä
  2015-05-12 12:41     ` [PATCH v2] " Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Ville Syrjälä @ 2015-05-12 12:09 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Wed, Apr 15, 2015 at 03:18:29PM +0300, Jani Nikula wrote:
> Make input and output of validate_vbt 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>
> ---
>  drivers/gpu/drm/i915/intel_bios.c | 50 ++++++++++++++++++++-------------------
>  1 file changed, 26 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> index 4e3f3f427178..b1e047c5e594 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -205,7 +205,7 @@ get_lvds_fp_timing(const struct bdb_header *bdb,
>  /* Try to find integrated panel data */
>  static void
>  parse_lfp_panel_data(struct drm_i915_private *dev_priv,
> -			    struct bdb_header *bdb)
> +		     const struct bdb_header *bdb)
>  {
>  	const struct bdb_lvds_options *lvds_options;
>  	const struct bdb_lvds_lfp_data *lvds_lfp_data;
> @@ -311,7 +311,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
>  }
>  
>  static void
> -parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_lfp_backlight(struct drm_i915_private *dev_priv,
> +		    const struct bdb_header *bdb)
>  {
>  	const struct bdb_lfp_backlight_data *backlight_data;
>  	const struct bdb_lfp_backlight_data_entry *entry;
> @@ -349,7 +350,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
>  /* Try to find sdvo panel data */
>  static void
>  parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
> -		      struct bdb_header *bdb)
> +		      const struct bdb_header *bdb)
>  {
>  	const struct lvds_dvo_timing *dvo_timing;
>  	struct drm_display_mode *panel_fixed_mode;
> @@ -403,7 +404,7 @@ static int intel_bios_ssc_frequency(struct drm_device *dev,
>  
>  static void
>  parse_general_features(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		       const struct bdb_header *bdb)
>  {
>  	struct drm_device *dev = dev_priv->dev;
>  	const struct bdb_general_features *general;
> @@ -429,7 +430,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_general_definitions(struct drm_i915_private *dev_priv,
> -			  struct bdb_header *bdb)
> +			  const struct bdb_header *bdb)
>  {
>  	const struct bdb_general_definitions *general;
>  
> @@ -456,7 +457,7 @@ child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
>  
>  static void
>  parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
> -			  struct bdb_header *bdb)
> +			  const struct bdb_header *bdb)
>  {
>  	struct sdvo_device_mapping *p_mapping;
>  	const struct bdb_general_definitions *p_defs;
> @@ -546,7 +547,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_driver_features(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		      const struct bdb_header *bdb)
>  {
>  	const struct bdb_driver_features *driver;
>  
> @@ -572,7 +573,7 @@ parse_driver_features(struct drm_i915_private *dev_priv,
>  }
>  
>  static void
> -parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_edp *edp;
>  	const struct edp_power_seq *edp_pps;
> @@ -679,7 +680,7 @@ 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)
> +parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_psr *psr;
>  	const struct psr_table *psr_table;
> @@ -790,7 +791,7 @@ static u8 *goto_next_sequence(u8 *data, int *size)
>  }
>  
>  static void
> -parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_mipi_config *start;
>  	const struct bdb_mipi_sequence *sequence;
> @@ -941,7 +942,7 @@ err:
>  }
>  
>  static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
> -			   struct bdb_header *bdb)
> +			   const struct bdb_header *bdb)
>  {
>  	union child_device_config *it, *child = NULL;
>  	struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
> @@ -1043,7 +1044,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
>  }
>  
>  static void parse_ddi_ports(struct drm_i915_private *dev_priv,
> -			    struct bdb_header *bdb)
> +			    const struct bdb_header *bdb)
>  {
>  	struct drm_device *dev = dev_priv->dev;
>  	enum port port;
> @@ -1063,7 +1064,7 @@ static void parse_ddi_ports(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_device_mapping(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		     const struct bdb_header *bdb)
>  {
>  	const struct bdb_general_definitions *p_defs;
>  	const union child_device_config *p_child;
> @@ -1193,19 +1194,21 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = {
>  	{ }
>  };
>  
> -static struct bdb_header *validate_vbt(char *base, size_t size,
> -				       struct vbt_header *vbt,
> -				       const char *source)
> +const static struct bdb_header *validate_vbt(const void *_base, size_t size,
> +					     const void *_vbt,
> +					     const char *source)
>  {
> +	const char *base = _base;
> +	const struct vbt_header *vbt = _vbt;
>  	size_t offset;
> -	struct bdb_header *bdb;
> +	const struct bdb_header *bdb;
>  
>  	if (vbt == NULL) {
>  		DRM_DEBUG_DRIVER("VBT signature missing\n");
>  		return NULL;
>  	}
>  
> -	offset = (char *)vbt - base;
> +	offset = (const char *)vbt - base;

I believe we're using void* arithmetic elsewhere already, so maybe just
use it here too and avoid the duplicated variables?

>  	if (offset + sizeof(struct vbt_header) > size) {
>  		DRM_DEBUG_DRIVER("VBT header incomplete\n");
>  		return NULL;
> @@ -1222,7 +1225,7 @@ static struct bdb_header *validate_vbt(char *base, size_t size,
>  		return NULL;
>  	}
>  
> -	bdb = (struct bdb_header *)(base + offset);
> +	bdb = (const struct bdb_header *)(base + offset);
>  	if (offset + bdb->bdb_size > size) {
>  		DRM_DEBUG_DRIVER("BDB incomplete\n");
>  		return NULL;
> @@ -1247,7 +1250,7 @@ intel_parse_bios(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct pci_dev *pdev = dev->pdev;
> -	struct bdb_header *bdb = NULL;
> +	const struct bdb_header *bdb = NULL;
>  	u8 __iomem *bios = NULL;
>  
>  	if (HAS_PCH_NOP(dev))
> @@ -1257,9 +1260,8 @@ intel_parse_bios(struct drm_device *dev)
>  
>  	/* XXX Should this validation be moved to intel_opregion.c? */
>  	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
> -		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
> -				   (struct vbt_header *)dev_priv->opregion.vbt,
> -				   "OpRegion");
> +		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
> +				   dev_priv->opregion.vbt, "OpRegion");
>  
>  	if (bdb == NULL) {
>  		size_t i, size;
> @@ -1272,7 +1274,7 @@ intel_parse_bios(struct drm_device *dev)
>  		for (i = 0; i + 4 < size; i++) {
>  			if (memcmp(bios + i, "$VBT", 4) == 0) {
>  				bdb = validate_vbt(bios, size,
> -						   (struct vbt_header *)(bios + i),
> +						   bios + i,
>  						   "PCI ROM");
>  				break;
>  			}
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] drm/i915: constify find_section in VBT parsing
  2015-05-12 12:06 ` [PATCH 1/2] drm/i915: constify find_section " Ville Syrjälä
@ 2015-05-12 12:30   ` Jani Nikula
  0 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2015-05-12 12:30 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

On Tue, 12 May 2015, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Wed, Apr 15, 2015 at 03:18:28PM +0300, Jani Nikula wrote:
>> 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>
>> ---
>>  drivers/gpu/drm/i915/intel_bios.c | 60 ++++++++++++++++++++-------------------
>>  1 file changed, 31 insertions(+), 29 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
>> index c08368c03dad..4e3f3f427178 100644
>> --- a/drivers/gpu/drm/i915/intel_bios.c
>> +++ b/drivers/gpu/drm/i915/intel_bios.c
>> @@ -36,10 +36,11 @@
>>  
>>  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) {
>> @@ -680,8 +681,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) {
>> @@ -791,11 +792,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;
>
> It would seem this guy could be constified as well, with a bit of extra
> effort that is.

Perhaps, but that's not actually used to point that the VBT itself, but
rather a copy of it, so not as important. Maybe later. ;)

Jani.

>
> But the patch as is looks reasonable so:
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>> +	const u8 *seq_data;
>>  	int i, panel_id, seq_size;
>>  	u16 block_size;
>>  
>> @@ -1063,8 +1065,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;
>>  
>> @@ -1121,8 +1124,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;
>>  }
>> -- 
>> 2.1.4
>> 
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> -- 
> Ville Syrjälä
> Intel OTC

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] drm/i915: constify validate_vbt in VBT parsing
  2015-05-12 12:09   ` Ville Syrjälä
@ 2015-05-12 12:41     ` Jani Nikula
  2015-05-12 12:53       ` Ville Syrjälä
  0 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2015-05-12 12:41 UTC (permalink / raw)
  To: Ville Syrjälä, Jani Nikula; +Cc: intel-gfx

Make input and output of validate_vbt const, and fix the fallout. We
shouldn't modify the VBT, so make the compiler help us here.

v2: use pointer arithmetics on void* to simplify (Ville)

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c | 49 ++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 5876e7cb132d..cbd16c01959a 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -205,7 +205,7 @@ get_lvds_fp_timing(const struct bdb_header *bdb,
 /* Try to find integrated panel data */
 static void
 parse_lfp_panel_data(struct drm_i915_private *dev_priv,
-			    struct bdb_header *bdb)
+		     const struct bdb_header *bdb)
 {
 	const struct bdb_lvds_options *lvds_options;
 	const struct bdb_lvds_lfp_data *lvds_lfp_data;
@@ -311,7 +311,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
 }
 
 static void
-parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_lfp_backlight(struct drm_i915_private *dev_priv,
+		    const struct bdb_header *bdb)
 {
 	const struct bdb_lfp_backlight_data *backlight_data;
 	const struct bdb_lfp_backlight_data_entry *entry;
@@ -349,7 +350,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 /* Try to find sdvo panel data */
 static void
 parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
-		      struct bdb_header *bdb)
+		      const struct bdb_header *bdb)
 {
 	const struct lvds_dvo_timing *dvo_timing;
 	struct drm_display_mode *panel_fixed_mode;
@@ -403,7 +404,7 @@ static int intel_bios_ssc_frequency(struct drm_device *dev,
 
 static void
 parse_general_features(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		       const struct bdb_header *bdb)
 {
 	struct drm_device *dev = dev_priv->dev;
 	const struct bdb_general_features *general;
@@ -429,7 +430,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
 
 static void
 parse_general_definitions(struct drm_i915_private *dev_priv,
-			  struct bdb_header *bdb)
+			  const struct bdb_header *bdb)
 {
 	const struct bdb_general_definitions *general;
 
@@ -456,7 +457,7 @@ child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
 
 static void
 parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
-			  struct bdb_header *bdb)
+			  const struct bdb_header *bdb)
 {
 	struct sdvo_device_mapping *p_mapping;
 	const struct bdb_general_definitions *p_defs;
@@ -546,7 +547,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
 
 static void
 parse_driver_features(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		      const struct bdb_header *bdb)
 {
 	const struct bdb_driver_features *driver;
 
@@ -572,7 +573,7 @@ parse_driver_features(struct drm_i915_private *dev_priv,
 }
 
 static void
-parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_edp *edp;
 	const struct edp_power_seq *edp_pps;
@@ -684,7 +685,7 @@ 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)
+parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_psr *psr;
 	const struct psr_table *psr_table;
@@ -795,7 +796,7 @@ static u8 *goto_next_sequence(u8 *data, int *size)
 }
 
 static void
-parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 {
 	const struct bdb_mipi_config *start;
 	const struct bdb_mipi_sequence *sequence;
@@ -946,7 +947,7 @@ err:
 }
 
 static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
-			   struct bdb_header *bdb)
+			   const struct bdb_header *bdb)
 {
 	union child_device_config *it, *child = NULL;
 	struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
@@ -1048,7 +1049,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 }
 
 static void parse_ddi_ports(struct drm_i915_private *dev_priv,
-			    struct bdb_header *bdb)
+			    const struct bdb_header *bdb)
 {
 	struct drm_device *dev = dev_priv->dev;
 	enum port port;
@@ -1068,7 +1069,7 @@ static void parse_ddi_ports(struct drm_i915_private *dev_priv,
 
 static void
 parse_device_mapping(struct drm_i915_private *dev_priv,
-		       struct bdb_header *bdb)
+		     const struct bdb_header *bdb)
 {
 	const struct bdb_general_definitions *p_defs;
 	const union child_device_config *p_child;
@@ -1198,19 +1199,20 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = {
 	{ }
 };
 
-static struct bdb_header *validate_vbt(char *base, size_t size,
-				       struct vbt_header *vbt,
-				       const char *source)
+static const struct bdb_header *validate_vbt(const void *base, size_t size,
+					     const void *_vbt,
+					     const char *source)
 {
+	const struct vbt_header *vbt = _vbt;
 	size_t offset;
-	struct bdb_header *bdb;
+	const struct bdb_header *bdb;
 
 	if (vbt == NULL) {
 		DRM_DEBUG_DRIVER("VBT signature missing\n");
 		return NULL;
 	}
 
-	offset = (char *)vbt - base;
+	offset = _vbt - base;
 	if (offset + sizeof(struct vbt_header) > size) {
 		DRM_DEBUG_DRIVER("VBT header incomplete\n");
 		return NULL;
@@ -1227,7 +1229,7 @@ static struct bdb_header *validate_vbt(char *base, size_t size,
 		return NULL;
 	}
 
-	bdb = (struct bdb_header *)(base + offset);
+	bdb = base + offset;
 	if (offset + bdb->bdb_size > size) {
 		DRM_DEBUG_DRIVER("BDB incomplete\n");
 		return NULL;
@@ -1252,7 +1254,7 @@ intel_parse_bios(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct pci_dev *pdev = dev->pdev;
-	struct bdb_header *bdb = NULL;
+	const struct bdb_header *bdb = NULL;
 	u8 __iomem *bios = NULL;
 
 	if (HAS_PCH_NOP(dev))
@@ -1262,9 +1264,8 @@ intel_parse_bios(struct drm_device *dev)
 
 	/* XXX Should this validation be moved to intel_opregion.c? */
 	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
-		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
-				   (struct vbt_header *)dev_priv->opregion.vbt,
-				   "OpRegion");
+		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
+				   dev_priv->opregion.vbt, "OpRegion");
 
 	if (bdb == NULL) {
 		size_t i, size;
@@ -1277,7 +1278,7 @@ intel_parse_bios(struct drm_device *dev)
 		for (i = 0; i + 4 < size; i++) {
 			if (memcmp(bios + i, "$VBT", 4) == 0) {
 				bdb = validate_vbt(bios, size,
-						   (struct vbt_header *)(bios + i),
+						   bios + i,
 						   "PCI ROM");
 				break;
 			}
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] drm/i915: constify validate_vbt in VBT parsing
  2015-05-12 12:41     ` [PATCH v2] " Jani Nikula
@ 2015-05-12 12:53       ` Ville Syrjälä
  2015-05-12 13:07         ` Daniel Vetter
  0 siblings, 1 reply; 8+ messages in thread
From: Ville Syrjälä @ 2015-05-12 12:53 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Tue, May 12, 2015 at 03:41:32PM +0300, Jani Nikula wrote:
> Make input and output of validate_vbt const, and fix the fallout. We
> shouldn't modify the VBT, so make the compiler help us here.
> 
> v2: use pointer arithmetics on void* to simplify (Ville)
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

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

> ---
>  drivers/gpu/drm/i915/intel_bios.c | 49 ++++++++++++++++++++-------------------
>  1 file changed, 25 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> index 5876e7cb132d..cbd16c01959a 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -205,7 +205,7 @@ get_lvds_fp_timing(const struct bdb_header *bdb,
>  /* Try to find integrated panel data */
>  static void
>  parse_lfp_panel_data(struct drm_i915_private *dev_priv,
> -			    struct bdb_header *bdb)
> +		     const struct bdb_header *bdb)
>  {
>  	const struct bdb_lvds_options *lvds_options;
>  	const struct bdb_lvds_lfp_data *lvds_lfp_data;
> @@ -311,7 +311,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
>  }
>  
>  static void
> -parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_lfp_backlight(struct drm_i915_private *dev_priv,
> +		    const struct bdb_header *bdb)
>  {
>  	const struct bdb_lfp_backlight_data *backlight_data;
>  	const struct bdb_lfp_backlight_data_entry *entry;
> @@ -349,7 +350,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
>  /* Try to find sdvo panel data */
>  static void
>  parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
> -		      struct bdb_header *bdb)
> +		      const struct bdb_header *bdb)
>  {
>  	const struct lvds_dvo_timing *dvo_timing;
>  	struct drm_display_mode *panel_fixed_mode;
> @@ -403,7 +404,7 @@ static int intel_bios_ssc_frequency(struct drm_device *dev,
>  
>  static void
>  parse_general_features(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		       const struct bdb_header *bdb)
>  {
>  	struct drm_device *dev = dev_priv->dev;
>  	const struct bdb_general_features *general;
> @@ -429,7 +430,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_general_definitions(struct drm_i915_private *dev_priv,
> -			  struct bdb_header *bdb)
> +			  const struct bdb_header *bdb)
>  {
>  	const struct bdb_general_definitions *general;
>  
> @@ -456,7 +457,7 @@ child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
>  
>  static void
>  parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
> -			  struct bdb_header *bdb)
> +			  const struct bdb_header *bdb)
>  {
>  	struct sdvo_device_mapping *p_mapping;
>  	const struct bdb_general_definitions *p_defs;
> @@ -546,7 +547,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_driver_features(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		      const struct bdb_header *bdb)
>  {
>  	const struct bdb_driver_features *driver;
>  
> @@ -572,7 +573,7 @@ parse_driver_features(struct drm_i915_private *dev_priv,
>  }
>  
>  static void
> -parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_edp *edp;
>  	const struct edp_power_seq *edp_pps;
> @@ -684,7 +685,7 @@ 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)
> +parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_psr *psr;
>  	const struct psr_table *psr_table;
> @@ -795,7 +796,7 @@ static u8 *goto_next_sequence(u8 *data, int *size)
>  }
>  
>  static void
> -parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> +parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
>  {
>  	const struct bdb_mipi_config *start;
>  	const struct bdb_mipi_sequence *sequence;
> @@ -946,7 +947,7 @@ err:
>  }
>  
>  static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
> -			   struct bdb_header *bdb)
> +			   const struct bdb_header *bdb)
>  {
>  	union child_device_config *it, *child = NULL;
>  	struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
> @@ -1048,7 +1049,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
>  }
>  
>  static void parse_ddi_ports(struct drm_i915_private *dev_priv,
> -			    struct bdb_header *bdb)
> +			    const struct bdb_header *bdb)
>  {
>  	struct drm_device *dev = dev_priv->dev;
>  	enum port port;
> @@ -1068,7 +1069,7 @@ static void parse_ddi_ports(struct drm_i915_private *dev_priv,
>  
>  static void
>  parse_device_mapping(struct drm_i915_private *dev_priv,
> -		       struct bdb_header *bdb)
> +		     const struct bdb_header *bdb)
>  {
>  	const struct bdb_general_definitions *p_defs;
>  	const union child_device_config *p_child;
> @@ -1198,19 +1199,20 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = {
>  	{ }
>  };
>  
> -static struct bdb_header *validate_vbt(char *base, size_t size,
> -				       struct vbt_header *vbt,
> -				       const char *source)
> +static const struct bdb_header *validate_vbt(const void *base, size_t size,
> +					     const void *_vbt,
> +					     const char *source)
>  {
> +	const struct vbt_header *vbt = _vbt;
>  	size_t offset;
> -	struct bdb_header *bdb;
> +	const struct bdb_header *bdb;
>  
>  	if (vbt == NULL) {
>  		DRM_DEBUG_DRIVER("VBT signature missing\n");
>  		return NULL;
>  	}
>  
> -	offset = (char *)vbt - base;
> +	offset = _vbt - base;
>  	if (offset + sizeof(struct vbt_header) > size) {
>  		DRM_DEBUG_DRIVER("VBT header incomplete\n");
>  		return NULL;
> @@ -1227,7 +1229,7 @@ static struct bdb_header *validate_vbt(char *base, size_t size,
>  		return NULL;
>  	}
>  
> -	bdb = (struct bdb_header *)(base + offset);
> +	bdb = base + offset;
>  	if (offset + bdb->bdb_size > size) {
>  		DRM_DEBUG_DRIVER("BDB incomplete\n");
>  		return NULL;
> @@ -1252,7 +1254,7 @@ intel_parse_bios(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct pci_dev *pdev = dev->pdev;
> -	struct bdb_header *bdb = NULL;
> +	const struct bdb_header *bdb = NULL;
>  	u8 __iomem *bios = NULL;
>  
>  	if (HAS_PCH_NOP(dev))
> @@ -1262,9 +1264,8 @@ intel_parse_bios(struct drm_device *dev)
>  
>  	/* XXX Should this validation be moved to intel_opregion.c? */
>  	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
> -		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
> -				   (struct vbt_header *)dev_priv->opregion.vbt,
> -				   "OpRegion");
> +		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
> +				   dev_priv->opregion.vbt, "OpRegion");
>  
>  	if (bdb == NULL) {
>  		size_t i, size;
> @@ -1277,7 +1278,7 @@ intel_parse_bios(struct drm_device *dev)
>  		for (i = 0; i + 4 < size; i++) {
>  			if (memcmp(bios + i, "$VBT", 4) == 0) {
>  				bdb = validate_vbt(bios, size,
> -						   (struct vbt_header *)(bios + i),
> +						   bios + i,
>  						   "PCI ROM");
>  				break;
>  			}
> -- 
> 2.1.4

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] drm/i915: constify validate_vbt in VBT parsing
  2015-05-12 12:53       ` Ville Syrjälä
@ 2015-05-12 13:07         ` Daniel Vetter
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2015-05-12 13:07 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Jani Nikula, intel-gfx

On Tue, May 12, 2015 at 03:53:49PM +0300, Ville Syrjälä wrote:
> On Tue, May 12, 2015 at 03:41:32PM +0300, Jani Nikula wrote:
> > Make input and output of validate_vbt const, and fix the fallout. We
> > shouldn't modify the VBT, so make the compiler help us here.
> > 
> > v2: use pointer arithmetics on void* to simplify (Ville)
> > 
> > Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Both patches merged, thanks.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/i915/intel_bios.c | 49 ++++++++++++++++++++-------------------
> >  1 file changed, 25 insertions(+), 24 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> > index 5876e7cb132d..cbd16c01959a 100644
> > --- a/drivers/gpu/drm/i915/intel_bios.c
> > +++ b/drivers/gpu/drm/i915/intel_bios.c
> > @@ -205,7 +205,7 @@ get_lvds_fp_timing(const struct bdb_header *bdb,
> >  /* Try to find integrated panel data */
> >  static void
> >  parse_lfp_panel_data(struct drm_i915_private *dev_priv,
> > -			    struct bdb_header *bdb)
> > +		     const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_lvds_options *lvds_options;
> >  	const struct bdb_lvds_lfp_data *lvds_lfp_data;
> > @@ -311,7 +311,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
> >  }
> >  
> >  static void
> > -parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> > +parse_lfp_backlight(struct drm_i915_private *dev_priv,
> > +		    const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_lfp_backlight_data *backlight_data;
> >  	const struct bdb_lfp_backlight_data_entry *entry;
> > @@ -349,7 +350,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> >  /* Try to find sdvo panel data */
> >  static void
> >  parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
> > -		      struct bdb_header *bdb)
> > +		      const struct bdb_header *bdb)
> >  {
> >  	const struct lvds_dvo_timing *dvo_timing;
> >  	struct drm_display_mode *panel_fixed_mode;
> > @@ -403,7 +404,7 @@ static int intel_bios_ssc_frequency(struct drm_device *dev,
> >  
> >  static void
> >  parse_general_features(struct drm_i915_private *dev_priv,
> > -		       struct bdb_header *bdb)
> > +		       const struct bdb_header *bdb)
> >  {
> >  	struct drm_device *dev = dev_priv->dev;
> >  	const struct bdb_general_features *general;
> > @@ -429,7 +430,7 @@ parse_general_features(struct drm_i915_private *dev_priv,
> >  
> >  static void
> >  parse_general_definitions(struct drm_i915_private *dev_priv,
> > -			  struct bdb_header *bdb)
> > +			  const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_general_definitions *general;
> >  
> > @@ -456,7 +457,7 @@ child_device_ptr(const struct bdb_general_definitions *p_defs, int i)
> >  
> >  static void
> >  parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
> > -			  struct bdb_header *bdb)
> > +			  const struct bdb_header *bdb)
> >  {
> >  	struct sdvo_device_mapping *p_mapping;
> >  	const struct bdb_general_definitions *p_defs;
> > @@ -546,7 +547,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
> >  
> >  static void
> >  parse_driver_features(struct drm_i915_private *dev_priv,
> > -		       struct bdb_header *bdb)
> > +		      const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_driver_features *driver;
> >  
> > @@ -572,7 +573,7 @@ parse_driver_features(struct drm_i915_private *dev_priv,
> >  }
> >  
> >  static void
> > -parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> > +parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_edp *edp;
> >  	const struct edp_power_seq *edp_pps;
> > @@ -684,7 +685,7 @@ 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)
> > +parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_psr *psr;
> >  	const struct psr_table *psr_table;
> > @@ -795,7 +796,7 @@ static u8 *goto_next_sequence(u8 *data, int *size)
> >  }
> >  
> >  static void
> > -parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
> > +parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_mipi_config *start;
> >  	const struct bdb_mipi_sequence *sequence;
> > @@ -946,7 +947,7 @@ err:
> >  }
> >  
> >  static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
> > -			   struct bdb_header *bdb)
> > +			   const struct bdb_header *bdb)
> >  {
> >  	union child_device_config *it, *child = NULL;
> >  	struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
> > @@ -1048,7 +1049,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
> >  }
> >  
> >  static void parse_ddi_ports(struct drm_i915_private *dev_priv,
> > -			    struct bdb_header *bdb)
> > +			    const struct bdb_header *bdb)
> >  {
> >  	struct drm_device *dev = dev_priv->dev;
> >  	enum port port;
> > @@ -1068,7 +1069,7 @@ static void parse_ddi_ports(struct drm_i915_private *dev_priv,
> >  
> >  static void
> >  parse_device_mapping(struct drm_i915_private *dev_priv,
> > -		       struct bdb_header *bdb)
> > +		     const struct bdb_header *bdb)
> >  {
> >  	const struct bdb_general_definitions *p_defs;
> >  	const union child_device_config *p_child;
> > @@ -1198,19 +1199,20 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = {
> >  	{ }
> >  };
> >  
> > -static struct bdb_header *validate_vbt(char *base, size_t size,
> > -				       struct vbt_header *vbt,
> > -				       const char *source)
> > +static const struct bdb_header *validate_vbt(const void *base, size_t size,
> > +					     const void *_vbt,
> > +					     const char *source)
> >  {
> > +	const struct vbt_header *vbt = _vbt;
> >  	size_t offset;
> > -	struct bdb_header *bdb;
> > +	const struct bdb_header *bdb;
> >  
> >  	if (vbt == NULL) {
> >  		DRM_DEBUG_DRIVER("VBT signature missing\n");
> >  		return NULL;
> >  	}
> >  
> > -	offset = (char *)vbt - base;
> > +	offset = _vbt - base;
> >  	if (offset + sizeof(struct vbt_header) > size) {
> >  		DRM_DEBUG_DRIVER("VBT header incomplete\n");
> >  		return NULL;
> > @@ -1227,7 +1229,7 @@ static struct bdb_header *validate_vbt(char *base, size_t size,
> >  		return NULL;
> >  	}
> >  
> > -	bdb = (struct bdb_header *)(base + offset);
> > +	bdb = base + offset;
> >  	if (offset + bdb->bdb_size > size) {
> >  		DRM_DEBUG_DRIVER("BDB incomplete\n");
> >  		return NULL;
> > @@ -1252,7 +1254,7 @@ intel_parse_bios(struct drm_device *dev)
> >  {
> >  	struct drm_i915_private *dev_priv = dev->dev_private;
> >  	struct pci_dev *pdev = dev->pdev;
> > -	struct bdb_header *bdb = NULL;
> > +	const struct bdb_header *bdb = NULL;
> >  	u8 __iomem *bios = NULL;
> >  
> >  	if (HAS_PCH_NOP(dev))
> > @@ -1262,9 +1264,8 @@ intel_parse_bios(struct drm_device *dev)
> >  
> >  	/* XXX Should this validation be moved to intel_opregion.c? */
> >  	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
> > -		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
> > -				   (struct vbt_header *)dev_priv->opregion.vbt,
> > -				   "OpRegion");
> > +		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
> > +				   dev_priv->opregion.vbt, "OpRegion");
> >  
> >  	if (bdb == NULL) {
> >  		size_t i, size;
> > @@ -1277,7 +1278,7 @@ intel_parse_bios(struct drm_device *dev)
> >  		for (i = 0; i + 4 < size; i++) {
> >  			if (memcmp(bios + i, "$VBT", 4) == 0) {
> >  				bdb = validate_vbt(bios, size,
> > -						   (struct vbt_header *)(bios + i),
> > +						   bios + i,
> >  						   "PCI ROM");
> >  				break;
> >  			}
> > -- 
> > 2.1.4
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-12 13:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 12:18 [PATCH 1/2] drm/i915: constify find_section in VBT parsing Jani Nikula
2015-04-15 12:18 ` [PATCH 2/2] drm/i915: constify validate_vbt " Jani Nikula
2015-05-12 12:09   ` Ville Syrjälä
2015-05-12 12:41     ` [PATCH v2] " Jani Nikula
2015-05-12 12:53       ` Ville Syrjälä
2015-05-12 13:07         ` Daniel Vetter
2015-05-12 12:06 ` [PATCH 1/2] drm/i915: constify find_section " Ville Syrjälä
2015-05-12 12:30   ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox