Skip to content

Commit 43d16d8

Browse files
committed
drm/edid: make a number of functions, parameters and variables const
If there's no need to change it, it should be const. There's more to be done, but start off with changes that make follow-up work easier. No functional changes. Reviewed-by: Ville Syrjälä <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/41722f92ef81cd6adf65f936fcc5301418e1f94b.1617024940.git.jani.nikula@intel.com
1 parent e488b10 commit 43d16d8

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

drivers/gpu/drm/drm_edid.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ module_param_named(edid_fixup, edid_fixup, int, 0400);
15851585
MODULE_PARM_DESC(edid_fixup,
15861586
"Minimum number of valid EDID header bytes (0-8, default 6)");
15871587

1588-
static int validate_displayid(u8 *displayid, int length, int idx);
1588+
static int validate_displayid(const u8 *displayid, int length, int idx);
15891589

15901590
static int drm_edid_block_checksum(const u8 *raw_edid)
15911591
{
@@ -3241,10 +3241,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
32413241
/*
32423242
* Search EDID for CEA extension block.
32433243
*/
3244-
static u8 *drm_find_edid_extension(const struct edid *edid,
3245-
int ext_id, int *ext_index)
3244+
static const u8 *drm_find_edid_extension(const struct edid *edid,
3245+
int ext_id, int *ext_index)
32463246
{
3247-
u8 *edid_ext = NULL;
3247+
const u8 *edid_ext = NULL;
32483248
int i;
32493249

32503250
/* No EDID or EDID extensions */
@@ -3253,7 +3253,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid,
32533253

32543254
/* Find CEA extension */
32553255
for (i = *ext_index; i < edid->extensions; i++) {
3256-
edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
3256+
edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
32573257
if (edid_ext[0] == ext_id)
32583258
break;
32593259
}
@@ -3267,12 +3267,12 @@ static u8 *drm_find_edid_extension(const struct edid *edid,
32673267
}
32683268

32693269

3270-
static u8 *drm_find_displayid_extension(const struct edid *edid,
3271-
int *length, int *idx,
3272-
int *ext_index)
3270+
static const u8 *drm_find_displayid_extension(const struct edid *edid,
3271+
int *length, int *idx,
3272+
int *ext_index)
32733273
{
3274-
u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT, ext_index);
3275-
struct displayid_hdr *base;
3274+
const u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT, ext_index);
3275+
const struct displayid_hdr *base;
32763276
int ret;
32773277

32783278
if (!displayid)
@@ -3286,18 +3286,18 @@ static u8 *drm_find_displayid_extension(const struct edid *edid,
32863286
if (ret)
32873287
return NULL;
32883288

3289-
base = (struct displayid_hdr *)&displayid[*idx];
3289+
base = (const struct displayid_hdr *)&displayid[*idx];
32903290
*length = *idx + sizeof(*base) + base->bytes;
32913291

32923292
return displayid;
32933293
}
32943294

3295-
static u8 *drm_find_cea_extension(const struct edid *edid)
3295+
static const u8 *drm_find_cea_extension(const struct edid *edid)
32963296
{
32973297
int length, idx;
3298-
struct displayid_block *block;
3299-
u8 *cea;
3300-
u8 *displayid;
3298+
const struct displayid_block *block;
3299+
const u8 *cea;
3300+
const u8 *displayid;
33013301
int ext_index;
33023302

33033303
/* Look for a top level CEA extension block */
@@ -3318,7 +3318,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid)
33183318
idx += sizeof(struct displayid_hdr);
33193319
for_each_displayid_db(displayid, block, idx, length) {
33203320
if (block->tag == DATA_BLOCK_CTA)
3321-
return (u8 *)block;
3321+
return (const u8 *)block;
33223322
}
33233323
}
33243324

@@ -4503,8 +4503,8 @@ static void clear_eld(struct drm_connector *connector)
45034503
static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
45044504
{
45054505
uint8_t *eld = connector->eld;
4506-
u8 *cea;
4507-
u8 *db;
4506+
const u8 *cea;
4507+
const u8 *db;
45084508
int total_sad_count = 0;
45094509
int mnl;
45104510
int dbl;
@@ -4600,7 +4600,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
46004600
{
46014601
int count = 0;
46024602
int i, start, end, dbl;
4603-
u8 *cea;
4603+
const u8 *cea;
46044604

46054605
cea = drm_find_cea_extension(edid);
46064606
if (!cea) {
@@ -4619,7 +4619,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
46194619
}
46204620

46214621
for_each_cea_db(cea, i, start, end) {
4622-
u8 *db = &cea[i];
4622+
const u8 *db = &cea[i];
46234623

46244624
if (cea_db_tag(db) == AUDIO_BLOCK) {
46254625
int j;
@@ -4631,7 +4631,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
46314631
if (!*sads)
46324632
return -ENOMEM;
46334633
for (j = 0; j < count; j++) {
4634-
u8 *sad = &db[1 + j * 3];
4634+
const u8 *sad = &db[1 + j * 3];
46354635

46364636
(*sads)[j].format = (sad[0] & 0x78) >> 3;
46374637
(*sads)[j].channels = sad[0] & 0x7;
@@ -4755,7 +4755,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
47554755
*/
47564756
bool drm_detect_hdmi_monitor(struct edid *edid)
47574757
{
4758-
u8 *edid_ext;
4758+
const u8 *edid_ext;
47594759
int i;
47604760
int start_offset, end_offset;
47614761

@@ -4793,7 +4793,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
47934793
*/
47944794
bool drm_detect_monitor_audio(struct edid *edid)
47954795
{
4796-
u8 *edid_ext;
4796+
const u8 *edid_ext;
47974797
int i, j;
47984798
bool has_audio = false;
47994799
int start_offset, end_offset;
@@ -5287,13 +5287,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
52875287
return quirks;
52885288
}
52895289

5290-
static int validate_displayid(u8 *displayid, int length, int idx)
5290+
static int validate_displayid(const u8 *displayid, int length, int idx)
52915291
{
52925292
int i, dispid_length;
52935293
u8 csum = 0;
5294-
struct displayid_hdr *base;
5294+
const struct displayid_hdr *base;
52955295

5296-
base = (struct displayid_hdr *)&displayid[idx];
5296+
base = (const struct displayid_hdr *)&displayid[idx];
52975297

52985298
DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
52995299
base->rev, base->bytes, base->prod_id, base->ext_count);
@@ -5359,7 +5359,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
53595359
}
53605360

53615361
static int add_displayid_detailed_1_modes(struct drm_connector *connector,
5362-
struct displayid_block *block)
5362+
const struct displayid_block *block)
53635363
{
53645364
struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
53655365
int i;
@@ -5387,9 +5387,9 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
53875387
static int add_displayid_detailed_modes(struct drm_connector *connector,
53885388
struct edid *edid)
53895389
{
5390-
u8 *displayid;
5390+
const u8 *displayid;
53915391
int length, idx;
5392-
struct displayid_block *block;
5392+
const struct displayid_block *block;
53935393
int num_modes = 0;
53945394
int ext_index = 0;
53955395

include/drm/drm_displayid.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ struct displayid_detailed_timing_block {
9393
};
9494

9595
#define for_each_displayid_db(displayid, block, idx, length) \
96-
for ((block) = (struct displayid_block *)&(displayid)[idx]; \
96+
for ((block) = (const struct displayid_block *)&(displayid)[idx]; \
9797
(idx) + sizeof(struct displayid_block) <= (length) && \
9898
(idx) + sizeof(struct displayid_block) + (block)->num_bytes <= (length) && \
9999
(block)->num_bytes > 0; \
100100
(idx) += sizeof(struct displayid_block) + (block)->num_bytes, \
101-
(block) = (struct displayid_block *)&(displayid)[idx])
101+
(block) = (const struct displayid_block *)&(displayid)[idx])
102102

103103
#endif

0 commit comments

Comments
 (0)