Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] xc5000: Don't spin waiting for analog lock

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>

authored by

Devin Heitmueller and committed by
Mauro Carvalho Chehab
d9928a11 b01052ab

+2 -24
+2 -24
drivers/media/tuners/xc5000.c
··· 565 565 return xc5000_readreg(priv, XREG_TOTALGAIN, totalgain); 566 566 } 567 567 568 - static u16 wait_for_lock(struct xc5000_priv *priv) 569 - { 570 - u16 lock_state = 0; 571 - int watch_dog_count = 40; 572 - 573 - while ((lock_state == 0) && (watch_dog_count > 0)) { 574 - xc_get_lock_status(priv, &lock_state); 575 - if (lock_state != 1) { 576 - msleep(5); 577 - watch_dog_count--; 578 - } 579 - } 580 - return lock_state; 581 - } 582 - 583 568 #define XC_TUNE_ANALOG 0 584 569 #define XC_TUNE_DIGITAL 1 585 570 static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz, int mode) 586 571 { 587 - int found = 0; 588 - 589 572 dprintk(1, "%s(%u)\n", __func__, freq_hz); 590 573 591 574 if (xc_set_rf_frequency(priv, freq_hz) != 0) 592 - return 0; 575 + return -EREMOTEIO; 593 576 594 - if (mode == XC_TUNE_ANALOG) { 595 - if (wait_for_lock(priv) == 1) 596 - found = 1; 597 - } 598 - 599 - return found; 577 + return 0; 600 578 } 601 579 602 580 static int xc_set_xtal(struct dvb_frontend *fe)