Skip to content

Commit 00c7a01

Browse files
committed
drm/edid: make drm_edid_are_equal() more convenient for its single user
Repurpose drm_edid_are_equal() to be more helpful for its single user, and rename drm_edid_eq(). Functionally deduce the length from the blob size, not the blob data, making it more robust against any errors. Reviewed-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/1011a285d30babce3aabd8218abb7ece7dcf58a2.1713259151.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent d7bf5fc commit 00c7a01

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

drivers/gpu/drm/drm_edid.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,30 +1820,20 @@ static bool edid_block_is_zero(const void *edid)
18201820
return !memchr_inv(edid, 0, EDID_LENGTH);
18211821
}
18221822

1823-
/**
1824-
* drm_edid_are_equal - compare two edid blobs.
1825-
* @edid1: pointer to first blob
1826-
* @edid2: pointer to second blob
1827-
* This helper can be used during probing to determine if
1828-
* edid had changed.
1829-
*/
1830-
static bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2)
1823+
static bool drm_edid_eq(const struct drm_edid *drm_edid,
1824+
const void *raw_edid, size_t raw_edid_size)
18311825
{
1832-
int edid1_len, edid2_len;
1833-
bool edid1_present = edid1 != NULL;
1834-
bool edid2_present = edid2 != NULL;
1826+
bool edid1_present = drm_edid && drm_edid->edid && drm_edid->size;
1827+
bool edid2_present = raw_edid && raw_edid_size;
18351828

18361829
if (edid1_present != edid2_present)
18371830
return false;
18381831

1839-
if (edid1) {
1840-
edid1_len = edid_size(edid1);
1841-
edid2_len = edid_size(edid2);
1842-
1843-
if (edid1_len != edid2_len)
1832+
if (edid1_present) {
1833+
if (drm_edid->size != raw_edid_size)
18441834
return false;
18451835

1846-
if (memcmp(edid1, edid2, edid1_len))
1836+
if (memcmp(drm_edid->edid, raw_edid, drm_edid->size))
18471837
return false;
18481838
}
18491839

@@ -6936,15 +6926,14 @@ static int _drm_edid_connector_property_update(struct drm_connector *connector,
69366926
int ret;
69376927

69386928
if (connector->edid_blob_ptr) {
6939-
const struct edid *old_edid = connector->edid_blob_ptr->data;
6940-
6941-
if (old_edid) {
6942-
if (!drm_edid_are_equal(drm_edid ? drm_edid->edid : NULL, old_edid)) {
6943-
connector->epoch_counter++;
6944-
drm_dbg_kms(dev, "[CONNECTOR:%d:%s] EDID changed, epoch counter %llu\n",
6945-
connector->base.id, connector->name,
6946-
connector->epoch_counter);
6947-
}
6929+
const void *old_edid = connector->edid_blob_ptr->data;
6930+
size_t old_edid_size = connector->edid_blob_ptr->length;
6931+
6932+
if (old_edid && !drm_edid_eq(drm_edid, old_edid, old_edid_size)) {
6933+
connector->epoch_counter++;
6934+
drm_dbg_kms(dev, "[CONNECTOR:%d:%s] EDID changed, epoch counter %llu\n",
6935+
connector->base.id, connector->name,
6936+
connector->epoch_counter);
69486937
}
69496938
}
69506939

0 commit comments

Comments
 (0)