[media] xc5000: Don't spin waiting for analog lock
authorDevin Heitmueller <dheitmueller@kernellabs.com>
Wed, 19 Apr 2017 23:13:52 +0000 (20:13 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 6 Jun 2017 10:51:05 +0000 (07:51 -0300)
The xc5000 driver should not be spinning waiting for an analog lock.
The ioctl() should be returning immediately and the application is
responsible for polling for lock status.

This behavior isn't very visible in cases where you tune to a valid
channel, since lock is usually achieved much faster than 400ms.
However it is highly visible where doing things like changing video
standards, which sends tuning request for a frequency that is
almost never going to have an actual channel on it.

Also fixup the return values to treat zero as success and an actual
error code on error (to be consistent with other functions).  Note
this change has no practical effect at this time as none of the
callers inspect the return value.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/tuners/xc5000.c

index afdf0c9903d2987c3b6d8acc2e90793f6d6c9394..0e7e4fdf9e50b72c0b3ce8bca7b5273c3040a4f4 100644 (file)
@@ -565,38 +565,16 @@ static int xc_get_totalgain(struct xc5000_priv *priv, u16 *totalgain)
        return xc5000_readreg(priv, XREG_TOTALGAIN, totalgain);
 }
 
-static u16 wait_for_lock(struct xc5000_priv *priv)
-{
-       u16 lock_state = 0;
-       int watch_dog_count = 40;
-
-       while ((lock_state == 0) && (watch_dog_count > 0)) {
-               xc_get_lock_status(priv, &lock_state);
-               if (lock_state != 1) {
-                       msleep(5);
-                       watch_dog_count--;
-               }
-       }
-       return lock_state;
-}
-
 #define XC_TUNE_ANALOG  0
 #define XC_TUNE_DIGITAL 1
 static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz, int mode)
 {
-       int found = 0;
-
        dprintk(1, "%s(%u)\n", __func__, freq_hz);
 
        if (xc_set_rf_frequency(priv, freq_hz) != 0)
-               return 0;
-
-       if (mode == XC_TUNE_ANALOG) {
-               if (wait_for_lock(priv) == 1)
-                       found = 1;
-       }
+               return -EREMOTEIO;
 
-       return found;
+       return 0;
 }
 
 static int xc_set_xtal(struct dvb_frontend *fe)