From patchwork Thu Nov 22 10:22:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egbert Eich X-Patchwork-Id: 1783351 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id E60293FC64 for ; Thu, 22 Nov 2012 11:02:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDE01E63CC for ; Thu, 22 Nov 2012 03:02:01 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B51DE5E07 for ; Thu, 22 Nov 2012 02:51:09 -0800 (PST) Received: from debian (p5DCF0728.dip0.t-ipconnect.de [93.207.7.40]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0LrXFh-1T8JmS3cpJ-013J0m; Thu, 22 Nov 2012 11:51:02 +0100 Received: from sles11.fritz.box (sles11.fritz.box [192.168.178.22]) by debian (Postfix) with ESMTP id 56F393F35C; Thu, 22 Nov 2012 11:50:59 +0100 (CET) From: Egbert Eich To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 02/18] DRM/KMS/EDID: 0x7e -> EDID_EXTENSION_FLAG_OFFSET (v2) Date: Thu, 22 Nov 2012 05:22:52 -0500 Message-Id: <1353579788-30637-3-git-send-email-eich@suse.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1353579788-30637-1-git-send-email-eich@suse.com> References: <1353356598-10634-1-git-send-email-eich@suse.de> <1353579788-30637-1-git-send-email-eich@suse.com> X-Provags-ID: V02:K0:HoxJ/DHU+XJauI9VsUQeBEmnfTUZxEUBLl1q4l5/PxF 8kqpd+NyNQjjm9wgS+uZI34heHUyHiPky0hLJBMgJ0bigN5UH/ k4TYG/vYln78CzG2w1QHx5p0RlO5cp1Nry3Rw2g6nDXlLdZs/l 1p3ftcolfYmm9HoJ5etSLWcAIOeDzVdRx/hAANvOBZfNowCnQm 55jccAkcPmxidGemsN2qE0FaiSDBj3bg+371z/1n02NfTE4SYr NLLVmwmYQhmJ4WaU8yOf/q+bQ/v9gPeNjzpep/7EnD9C4Odd9M KYh52FW8oiNsZwAMKr647oKEmgltBolO4yIcfahUsQahw3Z3as dPzH4XXIgQBjgUfq66pM= Cc: Egbert Eich , tiwai@suse.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org v2: Use offsetof(). Signed-off-by: Egbert Eich --- 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: