[Intel-gfx] [PATCH 4/4] drm: Constify the pretty-print functions

Daniel Vetter daniel at ffwll.ch
Fri Jun 7 18:03:04 CEST 2013


On Fri, Jun 07, 2013 at 06:43:07PM +0300, ville.syrjala at linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> The structures and strings involved with various pretty-print functions
> aren't meant to be modified, so make them all const. The exception is
> drm_connector_enum_list which does get modified in drm_connector_init().
> 
> While at it move the drm_get_connector_status_name() prototype from
> drmP.h to drm_crtc.h where it belongs.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Looks good to me, and probably simplest if we merge everything (including
drm/i915 parts) through drm-next. On the series:

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> ---
>  drivers/gpu/drm/drm_crtc.c | 30 +++++++++++++++---------------
>  include/drm/drmP.h         |  1 -
>  include/drm/drm_crtc.h     | 17 +++++++++--------
>  3 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 079996a..44c3421 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -92,7 +92,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
>  
>  /* Avoid boilerplate.  I'm tired of typing. */
>  #define DRM_ENUM_NAME_FN(fnname, list)				\
> -	char *fnname(int val)					\
> +	const char *fnname(int val)				\
>  	{							\
>  		int i;						\
>  		for (i = 0; i < ARRAY_SIZE(list); i++) {	\
> @@ -105,7 +105,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
>  /*
>   * Global properties
>   */
> -static struct drm_prop_enum_list drm_dpms_enum_list[] =
> +static const struct drm_prop_enum_list drm_dpms_enum_list[] =
>  {	{ DRM_MODE_DPMS_ON, "On" },
>  	{ DRM_MODE_DPMS_STANDBY, "Standby" },
>  	{ DRM_MODE_DPMS_SUSPEND, "Suspend" },
> @@ -117,7 +117,7 @@ DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
>  /*
>   * Optional properties
>   */
> -static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
>  {
>  	{ DRM_MODE_SCALE_NONE, "None" },
>  	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
> @@ -125,7 +125,7 @@ static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
>  	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
>  };
>  
> -static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
>  {
>  	{ DRM_MODE_DITHERING_OFF, "Off" },
>  	{ DRM_MODE_DITHERING_ON, "On" },
> @@ -135,7 +135,7 @@ static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
>  /*
>   * Non-global properties, but "required" for certain connectors.
>   */
> -static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -144,7 +144,7 @@ static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
>  
>  DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
>  
> -static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -154,7 +154,7 @@ static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
>  DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
>  		 drm_dvi_i_subconnector_enum_list)
>  
> -static struct drm_prop_enum_list drm_tv_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -165,7 +165,7 @@ static struct drm_prop_enum_list drm_tv_select_enum_list[] =
>  
>  DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
>  
> -static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -177,7 +177,7 @@ static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
>  DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
>  		 drm_tv_subconnector_enum_list)
>  
> -static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
> +static const struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
>  	{ DRM_MODE_DIRTY_OFF,      "Off"      },
>  	{ DRM_MODE_DIRTY_ON,       "On"       },
>  	{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" },
> @@ -185,7 +185,7 @@ static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
>  
>  struct drm_conn_prop_enum_list {
>  	int type;
> -	char *name;
> +	const char *name;
>  	int count;
>  };
>  
> @@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
>  	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0},
>  };
>  
> -static struct drm_prop_enum_list drm_encoder_enum_list[] =
> +static const struct drm_prop_enum_list drm_encoder_enum_list[] =
>  {	{ DRM_MODE_ENCODER_NONE, "None" },
>  	{ DRM_MODE_ENCODER_DAC, "DAC" },
>  	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
> @@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[] =
>  	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
>  };
>  
> -char *drm_get_encoder_name(struct drm_encoder *encoder)
> +const char *drm_get_encoder_name(const struct drm_encoder *encoder)
>  {
>  	static char buf[32];
>  
> @@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder)
>  }
>  EXPORT_SYMBOL(drm_get_encoder_name);
>  
> -char *drm_get_connector_name(struct drm_connector *connector)
> +const char *drm_get_connector_name(const struct drm_connector *connector)
>  {
>  	static char buf[32];
>  
> @@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector *connector)
>  }
>  EXPORT_SYMBOL(drm_get_connector_name);
>  
> -char *drm_get_connector_status_name(enum drm_connector_status status)
> +const char *drm_get_connector_status_name(enum drm_connector_status status)
>  {
>  	if (status == connector_status_connected)
>  		return "connected";
> @@ -258,7 +258,7 @@ static char printable_char(int c)
>  	return isascii(c) && isprint(c) ? c : '?';
>  }
>  
> -char *drm_get_format_name(uint32_t format)
> +const char *drm_get_format_name(uint32_t format)
>  {
>  	static char buf[32];
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index b06f5af..e931a65 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1598,7 +1598,6 @@ extern void drm_sysfs_destroy(void);
>  extern int drm_sysfs_device_add(struct drm_minor *minor);
>  extern void drm_sysfs_hotplug_event(struct drm_device *dev);
>  extern void drm_sysfs_device_remove(struct drm_minor *minor);
> -extern char *drm_get_connector_status_name(enum drm_connector_status status);
>  extern int drm_sysfs_connector_add(struct drm_connector *connector);
>  extern void drm_sysfs_connector_remove(struct drm_connector *connector);
>  
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 2cbbfd4..53c33e2 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane *plane);
>  
>  extern void drm_encoder_cleanup(struct drm_encoder *encoder);
>  
> -extern char *drm_get_connector_name(struct drm_connector *connector);
> -extern char *drm_get_dpms_name(int val);
> -extern char *drm_get_dvi_i_subconnector_name(int val);
> -extern char *drm_get_dvi_i_select_name(int val);
> -extern char *drm_get_tv_subconnector_name(int val);
> -extern char *drm_get_tv_select_name(int val);
> +extern const char *drm_get_connector_name(const struct drm_connector *connector);
> +extern const char *drm_get_connector_status_name(enum drm_connector_status status);
> +extern const char *drm_get_dpms_name(int val);
> +extern const char *drm_get_dvi_i_subconnector_name(int val);
> +extern const char *drm_get_dvi_i_select_name(int val);
> +extern const char *drm_get_tv_subconnector_name(int val);
> +extern const char *drm_get_tv_select_name(int val);
>  extern void drm_fb_release(struct drm_file *file_priv);
>  extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
>  extern bool drm_probe_ddc(struct i2c_adapter *adapter);
> @@ -994,7 +995,7 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  extern int drm_mode_create_dithering_property(struct drm_device *dev);
>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
> -extern char *drm_get_encoder_name(struct drm_encoder *encoder);
> +extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
>  
>  extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
>  					     struct drm_encoder *encoder);
> @@ -1094,6 +1095,6 @@ extern int drm_format_num_planes(uint32_t format);
>  extern int drm_format_plane_cpp(uint32_t format, int plane);
>  extern int drm_format_horz_chroma_subsampling(uint32_t format);
>  extern int drm_format_vert_chroma_subsampling(uint32_t format);
> -extern char *drm_get_format_name(uint32_t format);
> +extern const char *drm_get_format_name(uint32_t format);
>  
>  #endif /* __DRM_CRTC_H__ */
> -- 
> 1.8.1.5
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch



More information about the Intel-gfx mailing list