diff options
author | Jani Nikula <jani.nikula@intel.com> | 2022-03-31 21:45:07 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2022-04-01 17:44:46 +0300 |
commit | 4ec53461d69010b7b5d39fdc558e9c3044418288 (patch) | |
tree | 05c52aef7c0cac33fb50f72503d56b409bf5817b /drivers/gpu/drm/drm_edid.c | |
parent | 23e38d7b48fda3730fe0a7ebc9293dd2810b49d7 (diff) | |
download | linux-stable-4ec53461d69010b7b5d39fdc558e9c3044418288.tar.gz linux-stable-4ec53461d69010b7b5d39fdc558e9c3044418288.tar.bz2 linux-stable-4ec53461d69010b7b5d39fdc558e9c3044418288.zip |
drm/edid: split out invalid block filtering to a separate function
It's such a special case there's no point in keeping it inline in the
happy day scenario, confusing matters.
v2: Rebase on the invalid block filtering fix
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ea8ccd654b5beca6ccf99666754aea09c836b6a5.1648752228.git.jani.nikula@intel.com
Diffstat (limited to 'drivers/gpu/drm/drm_edid.c')
-rw-r--r-- | drivers/gpu/drm/drm_edid.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index e63a93f138dd..32d9f2a8edf7 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1823,6 +1823,33 @@ bool drm_edid_is_valid(struct edid *edid) } EXPORT_SYMBOL(drm_edid_is_valid); +static struct edid *edid_filter_invalid_blocks(const struct edid *edid, + int valid_extensions) +{ + struct edid *new, *dest_block; + int i; + + new = kmalloc_array(valid_extensions + 1, EDID_LENGTH, GFP_KERNEL); + if (!new) + goto out; + + dest_block = new; + for (i = 0; i <= edid->extensions; i++) { + const void *block = edid + i; + + if (edid_block_valid(block, i == 0)) + memcpy(dest_block++, block, EDID_LENGTH); + } + + new->checksum += new->extensions - valid_extensions; + new->extensions = valid_extensions; + +out: + kfree(edid); + + return new; +} + #define DDC_SEGMENT_ADDR 0x30 /** * drm_do_probe_ddc_edid() - get EDID information via I2C @@ -2072,32 +2099,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, } if (valid_extensions != edid->extensions) { - struct edid *dest_block; - int i; - connector_bad_edid(connector, (u8 *)edid, edid->extensions + 1); - new = kmalloc_array(valid_extensions + 1, EDID_LENGTH, - GFP_KERNEL); - if (!new) - goto out; - - dest_block = new; - for (i = 0; i <= edid->extensions; i++) { - void *block = edid + i; - - if (!edid_block_valid(block, i == 0)) - continue; - - memcpy(dest_block, block, EDID_LENGTH); - dest_block++; - } - - new->checksum += new->extensions - valid_extensions; - new->extensions = valid_extensions; - - kfree(edid); - edid = new; + edid = edid_filter_invalid_blocks(edid, valid_extensions); } return edid; |