drm: Constify the pretty-print functions

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@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Ville Syrjälä 2013-06-07 15:43:07 +00:00 коммит произвёл Dave Airlie
Родитель 4ee62c7669
Коммит d20d317480
3 изменённых файлов: 24 добавлений и 24 удалений

Просмотреть файл

@ -92,7 +92,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
/* Avoid boilerplate. I'm tired of typing. */ /* Avoid boilerplate. I'm tired of typing. */
#define DRM_ENUM_NAME_FN(fnname, list) \ #define DRM_ENUM_NAME_FN(fnname, list) \
char *fnname(int val) \ const char *fnname(int val) \
{ \ { \
int i; \ int i; \
for (i = 0; i < ARRAY_SIZE(list); i++) { \ for (i = 0; i < ARRAY_SIZE(list); i++) { \
@ -105,7 +105,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
/* /*
* Global properties * 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_ON, "On" },
{ DRM_MODE_DPMS_STANDBY, "Standby" }, { DRM_MODE_DPMS_STANDBY, "Standby" },
{ DRM_MODE_DPMS_SUSPEND, "Suspend" }, { DRM_MODE_DPMS_SUSPEND, "Suspend" },
@ -117,7 +117,7 @@ DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
/* /*
* Optional properties * 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_NONE, "None" },
{ DRM_MODE_SCALE_FULLSCREEN, "Full" }, { 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" }, { 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_OFF, "Off" },
{ DRM_MODE_DITHERING_ON, "On" }, { 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. * 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_Automatic, "Automatic" }, /* DVI-I and TV-out */
{ DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ { 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) 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_Unknown, "Unknown" }, /* DVI-I and TV-out */
{ DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ { 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_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
drm_dvi_i_subconnector_enum_list) 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_Automatic, "Automatic" }, /* DVI-I and TV-out */
{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* 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) 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_Unknown, "Unknown" }, /* DVI-I and TV-out */
{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* 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_ENUM_NAME_FN(drm_get_tv_subconnector_name,
drm_tv_subconnector_enum_list) 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_OFF, "Off" },
{ DRM_MODE_DIRTY_ON, "On" }, { DRM_MODE_DIRTY_ON, "On" },
{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" }, { 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 { struct drm_conn_prop_enum_list {
int type; int type;
char *name; const char *name;
int count; int count;
}; };
@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0}, { 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_NONE, "None" },
{ DRM_MODE_ENCODER_DAC, "DAC" }, { DRM_MODE_ENCODER_DAC, "DAC" },
{ DRM_MODE_ENCODER_TMDS, "TMDS" }, { DRM_MODE_ENCODER_TMDS, "TMDS" },
@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[] =
{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, { 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]; static char buf[32];
@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder)
} }
EXPORT_SYMBOL(drm_get_encoder_name); 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]; static char buf[32];
@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector *connector)
} }
EXPORT_SYMBOL(drm_get_connector_name); 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) if (status == connector_status_connected)
return "connected"; return "connected";
@ -258,7 +258,7 @@ static char printable_char(int c)
return isascii(c) && isprint(c) ? 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]; static char buf[32];

Просмотреть файл

@ -1599,7 +1599,6 @@ extern void drm_sysfs_destroy(void);
extern int drm_sysfs_device_add(struct drm_minor *minor); extern int drm_sysfs_device_add(struct drm_minor *minor);
extern void drm_sysfs_hotplug_event(struct drm_device *dev); extern void drm_sysfs_hotplug_event(struct drm_device *dev);
extern void drm_sysfs_device_remove(struct drm_minor *minor); 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 int drm_sysfs_connector_add(struct drm_connector *connector);
extern void drm_sysfs_connector_remove(struct drm_connector *connector); extern void drm_sysfs_connector_remove(struct drm_connector *connector);

Просмотреть файл

@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane *plane);
extern void drm_encoder_cleanup(struct drm_encoder *encoder); extern void drm_encoder_cleanup(struct drm_encoder *encoder);
extern char *drm_get_connector_name(struct drm_connector *connector); extern const char *drm_get_connector_name(const struct drm_connector *connector);
extern char *drm_get_dpms_name(int val); extern const char *drm_get_connector_status_name(enum drm_connector_status status);
extern char *drm_get_dvi_i_subconnector_name(int val); extern const char *drm_get_dpms_name(int val);
extern char *drm_get_dvi_i_select_name(int val); extern const char *drm_get_dvi_i_subconnector_name(int val);
extern char *drm_get_tv_subconnector_name(int val); extern const char *drm_get_dvi_i_select_name(int val);
extern char *drm_get_tv_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 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 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); 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_scaling_mode_property(struct drm_device *dev);
extern int drm_mode_create_dithering_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 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, extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
struct drm_encoder *encoder); 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_plane_cpp(uint32_t format, int plane);
extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_horz_chroma_subsampling(uint32_t format);
extern int drm_format_vert_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__ */ #endif /* __DRM_CRTC_H__ */