[PATCH 09/22] drm/i915: Move test for max voltage on all lanes to separate function

Ander Conselvan de Oliveira
2015-10-23T10:02:30Z

Move the logic for checking if we have reached max voltage swing on all
lanes to a separate function to declutter the link training clock
recovery code.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
---
drivers/gpu/drm/i915/intel_dp_link_training.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
index b39ed51..9fdcc77 100644
--- a/drivers/gpu/drm/i915/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
@@ -143,11 +143,22 @@ setup_clock_recovery(struct intel_dp *intel_dp)
return true;
}

+static bool
+max_voltage_reached_on_all_lanes(struct intel_dp *intel_dp)
+{
+ int i;
+
+ for (i = 0; i < intel_dp->lane_count; i++)
+ if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0)
+ return false;
+
+ return true;
+}
+
/* Enable corresponding port and start training pattern 1 */
static void
intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp)
{
- int i;
uint8_t voltage;
int voltage_tries, loop_tries;

@@ -189,10 +200,7 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp)
}

/* Check to see if we've tried the max voltage */
- for (i = 0; i < intel_dp->lane_count; i++)
- if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0)
- break;
- if (i == intel_dp->lane_count) {
+ if (max_voltage_reached_on_all_lanes(intel_dp)) {
++loop_tries;
if (loop_tries == 5) {
DRM_ERROR("too many full retries, give up\n");