v2: Use offsetof(). Signed-off-by: Egbert Eich <eich@xxxxxxxx> --- drivers/gpu/drm/drm_edid.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 049fa52..9e64069 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -43,6 +43,8 @@ #define EDID_STD_TIMINGS 8 #define EDID_DETAILED_TIMINGS 4 +#define EDID_EXTENSION_FLAG_OFFSET offsetof(struct edid, extensions) +#define EDID_CHECKSUM_OFFSET offsetof(struct edid, checksum) /* * EDID blocks out in the wild have a variety of bugs, try to collect * them here (note that userspace may work around broken monitors first, @@ -341,15 +343,15 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) goto carp; /* if there's no extensions, we're done */ - if (block[0x7e] == 0) + if (block[EDID_EXTENSION_FLAG_OFFSET] == 0) return block; - new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL); + new = krealloc(block, (block[EDID_EXTENSION_FLAG_OFFSET] + 1) * EDID_LENGTH, GFP_KERNEL); if (!new) goto out; block = new; - for (j = 1; j <= block[0x7e]; j++) { + for (j = 1; j <= block[EDID_EXTENSION_FLAG_OFFSET]; j++) { for (i = 0; i < 4; i++) { if (drm_do_probe_ddc_edid(adapter, block + (valid_extensions + 1) * EDID_LENGTH, @@ -366,9 +368,9 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) drm_get_connector_name(connector), j); } - if (valid_extensions != block[0x7e]) { - block[EDID_LENGTH-1] += block[0x7e] - valid_extensions; - block[0x7e] = valid_extensions; + if (valid_extensions != block[EDID_EXTENSION_FLAG_OFFSET]) { + block[EDID_CHECKSUM_OFFSET] += block[EDID_EXTENSION_FLAG_OFFSET] - valid_extensions; + block[EDID_EXTENSION_FLAG_OFFSET] = valid_extensions; new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); if (!new) goto out; @@ -601,7 +603,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) for (i = 0; i < EDID_DETAILED_TIMINGS; i++) cb(&(edid->detailed_timings[i]), closure); - for (i = 1; i <= raw_edid[0x7e]; i++) { + for (i = 1; i <= raw_edid[EDID_EXTENSION_FLAG_OFFSET]; i++) { u8 *ext = raw_edid + (i * EDID_LENGTH); switch (*ext) { case CEA_EXT: -- 1.7.7 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel