usbtuner: demod lgdt3306a: optimize search duration
Henning Garbers [Wed, 28 Sep 2016 16:01:18 +0000 (18:01 +0200)]
Bug: 31834690
Bug 1736911

Change-Id: I0adcaa1911dee150831b91bd6c27a7b78a94237f
Signed-off-by: Jean Huang <jeanh@nvidia.com>
Signed-off-by: Patrick Horng <phorng@nvidia.com>
Reviewed-on: http://git-master/r/1284464
(cherry picked from commit 90a4ba957235c112c2ae724bcad964446238c3cf)
Reviewed-on: http://git-master/r/1311292
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-on: http://git-master/r/1456506
Reviewed-by: Manish Tuteja <mtuteja@nvidia.com>

drivers/media/dvb-frontends/lgdt3306a.c

index 656a38d..73ee1cc 100644 (file)
@@ -1737,7 +1737,8 @@ static int lgdt3306a_get_tune_settings(struct dvb_frontend *fe,
 static int lgdt3306a_search(struct dvb_frontend *fe)
 {
        fe_status_t status = 0;
-       int i, ret;
+       int i = 0, ret;
+       unsigned long timeout;
 
        /* set frontend */
        ret = lgdt3306a_set_parameters(fe);
@@ -1745,8 +1746,9 @@ static int lgdt3306a_search(struct dvb_frontend *fe)
                goto error;
 
        /* wait frontend lock */
-       for (i = 20; i > 0; i--) {
-               dbg_info(": loop=%d\n", i);
+       timeout = jiffies + msecs_to_jiffies(1000);
+       while (!time_after(jiffies, timeout)) {
+               dbg_info(": loop=%d\n", ++i);
                msleep(50);
                ret = lgdt3306a_read_status(fe, &status);
                if (ret)