drm: Mark constant arrays of drm_display_mode const
... and fixup some methods to accept the constant argument. Now that constant module arrays are loaded into read-only memory, using const appropriately has some benefits beyond warning the programmer about likely mistakes. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
committed by
Dave Airlie
parent
60b212f8dd
commit
b1f559ecdc
@ -449,12 +449,11 @@ static void edid_fixup_preferred(struct drm_connector *connector,
|
||||
struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
|
||||
int hsize, int vsize, int fresh)
|
||||
{
|
||||
struct drm_display_mode *mode = NULL;
|
||||
int i;
|
||||
struct drm_display_mode *ptr, *mode;
|
||||
|
||||
mode = NULL;
|
||||
for (i = 0; i < drm_num_dmt_modes; i++) {
|
||||
ptr = &drm_dmt_modes[i];
|
||||
const struct drm_display_mode *ptr = &drm_dmt_modes[i];
|
||||
if (hsize == ptr->hdisplay &&
|
||||
vsize == ptr->vdisplay &&
|
||||
fresh == drm_mode_vrefresh(ptr)) {
|
||||
@ -885,7 +884,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
|
||||
}
|
||||
|
||||
static bool
|
||||
mode_is_rb(struct drm_display_mode *mode)
|
||||
mode_is_rb(const struct drm_display_mode *mode)
|
||||
{
|
||||
return (mode->htotal - mode->hdisplay == 160) &&
|
||||
(mode->hsync_end - mode->hdisplay == 80) &&
|
||||
@ -894,7 +893,8 @@ mode_is_rb(struct drm_display_mode *mode)
|
||||
}
|
||||
|
||||
static bool
|
||||
mode_in_hsync_range(struct drm_display_mode *mode, struct edid *edid, u8 *t)
|
||||
mode_in_hsync_range(const struct drm_display_mode *mode,
|
||||
struct edid *edid, u8 *t)
|
||||
{
|
||||
int hsync, hmin, hmax;
|
||||
|
||||
@ -910,7 +910,8 @@ mode_in_hsync_range(struct drm_display_mode *mode, struct edid *edid, u8 *t)
|
||||
}
|
||||
|
||||
static bool
|
||||
mode_in_vsync_range(struct drm_display_mode *mode, struct edid *edid, u8 *t)
|
||||
mode_in_vsync_range(const struct drm_display_mode *mode,
|
||||
struct edid *edid, u8 *t)
|
||||
{
|
||||
int vsync, vmin, vmax;
|
||||
|
||||
@ -941,7 +942,7 @@ range_pixel_clock(struct edid *edid, u8 *t)
|
||||
}
|
||||
|
||||
static bool
|
||||
mode_in_range(struct drm_display_mode *mode, struct edid *edid,
|
||||
mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
|
||||
struct detailed_timing *timing)
|
||||
{
|
||||
u32 max_clock;
|
||||
@ -1472,7 +1473,7 @@ int drm_add_modes_noedid(struct drm_connector *connector,
|
||||
int hdisplay, int vdisplay)
|
||||
{
|
||||
int i, count, num_modes = 0;
|
||||
struct drm_display_mode *mode, *ptr;
|
||||
struct drm_display_mode *mode;
|
||||
struct drm_device *dev = connector->dev;
|
||||
|
||||
count = sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode);
|
||||
@ -1482,7 +1483,7 @@ int drm_add_modes_noedid(struct drm_connector *connector,
|
||||
vdisplay = 0;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr = &drm_dmt_modes[i];
|
||||
const struct drm_display_mode *ptr = &drm_dmt_modes[i];
|
||||
if (hdisplay && vdisplay) {
|
||||
/*
|
||||
* Only when two are valid, they will be used to check
|
||||
|
Reference in New Issue
Block a user