Groundwork that allocates a temporary drm_edid from raw edid to take advantage of DRM common-code helpers instead of driver-specific code.
Signed-off-by: Melissa Wen <[email protected]> --- v8: - centralize cleanup and return to a single place (Timur) --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 7d0ecce6b034..ef7f27ce4b50 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -110,18 +110,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps( struct drm_connector *connector = &aconnector->base; struct drm_device *dev = connector->dev; struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; + const struct drm_edid *drm_edid; struct cea_sad *sads; int sad_count = -1; int sadb_count = -1; int i = 0; uint8_t *sadb = NULL; - enum dc_edid_status result = EDID_OK; + if (!edid_caps || !edid) return EDID_BAD_INPUT; - if (!drm_edid_is_valid(edid_buf)) + drm_edid = drm_edid_alloc(edid_buf, EDID_LENGTH * (edid_buf->extensions + 1)); + + if (!drm_edid_valid(drm_edid)) result = EDID_BAD_CHECKSUM; edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] | @@ -145,8 +148,9 @@ enum dc_edid_status dm_helpers_parse_edid_caps( apply_edid_quirks(dev, edid_buf, edid_caps); sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads); - if (sad_count <= 0) - return result; + if (sad_count <= 0) { + goto cleanup; + } edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT); for (i = 0; i < edid_caps->audio_mode_count; ++i) { @@ -173,6 +177,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps( kfree(sads); kfree(sadb); +cleanup: + drm_edid_free(drm_edid); return result; } -- 2.51.0
