Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 522965ef authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Gerrit - the friendly Code Review server
Browse files

drm: Add drm_connector_for_each_possible_encoder()



Add a convenience macro for iterating connector->encoder_ids[].
Isolates the users from the implementation details.

Note that we don't seem to pass the file_priv down to drm_encoder_find()
because encoders apparently don't get leased. No idea why
drm_encoder_finc() even takes the file_priv actually.

Also use ARRAY_SIZE() when populating the array to avoid spreading
knowledge about the array size all over.

v2: Hide the drm_encoder_find() in the macro, and
    rename the macro appropriately (Daniel)
v3: Fix kernel docs (Daniel)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180628131315.14156-4-ville.syrjala@linux.intel.com


Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Patch-mainline: 20180628131315.14156-4-ville.syrjala@linux.intel.com @ 28/06/18, 01:13 p.m.
[stalek@codeaurora.org: Drop changes for drm_fb_helper.c and drm_probe_helper.c due to conflicts].

Change-Id: If47307349b7997c93f14ffc4d5c5bfbe14a69bfe
Signed-off-by: default avatarShubham Talekar <stalek@codeaurora.org>
parent 5ed1b2d3
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ int drm_mode_connector_attach_encoder(struct drm_connector *connector,
	if (WARN_ON(connector->encoder))
		return -EINVAL;

	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
	for (i = 0; i < ARRAY_SIZE(connector->encoder_ids); i++) {
		if (connector->encoder_ids[i] == 0) {
			connector->encoder_ids[i] = encoder->base.id;
			return 0;
@@ -1050,8 +1050,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
		goto out_unlock;
	}

	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
		if (connector->encoder_ids[i] != 0)
	drm_connector_for_each_possible_encoder(connector, encoder, i)
		encoders_count++;

	if (out_resp->count_modes == 0) {
@@ -1112,17 +1111,14 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
	if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
		copied = 0;
		encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr);
		for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
			if (connector->encoder_ids[i] != 0) {
				if (put_user(connector->encoder_ids[i],
					     encoder_ptr + copied)) {
		drm_connector_for_each_possible_encoder(connector, encoder, i) {
			if (put_user(encoder->base.id, encoder_ptr + copied)) {
				ret = -EFAULT;
				goto out;
			}
			copied++;
		}
	}
	}
	out_resp->count_encoders = encoders_count;

out: