drivers/media/dvb-core/dvb_frontend.c | 83 +++++++++++++++------------ 1 file changed, 45 insertions(+), 38 deletions(-)
Move the logic which sets LNB drift and inversion to a separate
function, to make the code cleaner.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/media/dvb-core/dvb_frontend.c | 83 +++++++++++++++------------
1 file changed, 45 insertions(+), 38 deletions(-)
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index a05aa271a1ba..6ee46bf6e45a 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -375,32 +375,13 @@ static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepr
fepriv->delay = fepriv->min_delay + q2 * HZ / (128 * 128);
}
-/**
- * dvb_frontend_swzigzag_autotune - Performs automatic twiddling of frontend
- * parameters.
- *
- * @fe: The frontend concerned.
- * @check_wrapped: Checks if an iteration has completed.
- * DO NOT SET ON THE FIRST ATTEMPT.
- *
- * return: Number of complete iterations that have been performed.
- */
-static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped)
+static void dvb_frontend_swzigzag_inversion_drift(struct dvb_frontend *fe,
+ int autoinversion)
{
- int autoinversion;
- int ready = 0;
- int fe_set_err = 0;
struct dvb_frontend_private *fepriv = fe->frontend_priv;
- struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp;
- int original_inversion = c->inversion;
- u32 original_frequency = c->frequency;
-
- /* are we using autoinversion? */
- autoinversion = ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) &&
- (c->inversion == INVERSION_AUTO));
/* setup parameters correctly */
- while (!ready) {
+ while (1) {
/* calculate the lnb_drift */
fepriv->lnb_drift = fepriv->auto_step * fepriv->step_size;
@@ -415,40 +396,66 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
switch (fepriv->auto_sub_step) {
case 0:
/* try with the current inversion and current drift setting */
- ready = 1;
- break;
+ return;
case 1:
- if (!autoinversion) break;
+ if (!autoinversion)
+ return;
- fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
- ready = 1;
- break;
+ fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ?
+ INVERSION_ON : INVERSION_OFF;
+ return;
case 2:
- if (fepriv->lnb_drift == 0) break;
+ if (fepriv->lnb_drift == 0)
+ return;
fepriv->lnb_drift = -fepriv->lnb_drift;
- ready = 1;
- break;
+ return;
case 3:
- if (fepriv->lnb_drift == 0) break;
- if (!autoinversion) break;
+ if (fepriv->lnb_drift == 0)
+ return;
+ if (!autoinversion)
+ return;
- fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
+ fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ?
+ INVERSION_ON : INVERSION_OFF;
fepriv->lnb_drift = -fepriv->lnb_drift;
- ready = 1;
- break;
+ return;
default:
fepriv->auto_step++;
fepriv->auto_sub_step = 0;
continue;
}
-
- if (!ready) fepriv->auto_sub_step++;
}
+}
+/**
+ * dvb_frontend_swzigzag_autotune - Performs automatic twiddling of frontend
+ * parameters.
+ *
+ * @fe: The frontend concerned.
+ * @check_wrapped: Checks if an iteration has completed.
+ * DO NOT SET ON THE FIRST ATTEMPT.
+ *
+ * return: Number of complete iterations that have been performed.
+ */
+static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped)
+{
+ int fe_set_err = 0;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp;
+ int original_inversion = c->inversion;
+ u32 original_frequency = c->frequency;
+ int autoinversion;
+
+ /* are we using autoinversion? */
+ autoinversion = ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) &&
+ (c->inversion == INVERSION_AUTO));
+
+ /* setup parameters correctly */
+ dvb_frontend_swzigzag_inversion_drift(fe, autoinversion);
/* if this attempt would hit where we started, indicate a complete
* iteration has occurred */
--
2.47.0
© 2016 - 2024 Red Hat, Inc.