aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/cx24123.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@hauppauge.com>2006-01-09 12:25:22 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:22 -0500
commit0144f31466f0b7f1a8b21b470bfeb93c174a2006 (patch)
treeb46367c45eaf577ae10ef9d10c93ff85504a7f2a /drivers/media/dvb/frontends/cx24123.c
parent2c3f11b20fc6c41b4d3f64f301f525e35f18b6bc (diff)
V4L/DVB (3130): cx24123: cleanup timout handling
- Cleanup timeout handling in cx24123_pll_writereg(), and use a reasonable value for the timeout. Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/dvb/frontends/cx24123.c')
-rw-r--r--drivers/media/dvb/frontends/cx24123.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 3e230fc59cac..d661c6f9cbe5 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -487,8 +487,7 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
487static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) 487static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data)
488{ 488{
489 struct cx24123_state *state = fe->demodulator_priv; 489 struct cx24123_state *state = fe->demodulator_priv;
490 490 unsigned long timeout;
491 u8 timeout = 0;
492 491
493 /* align the 21 bytes into to bit23 boundary */ 492 /* align the 21 bytes into to bit23 boundary */
494 data = data << 3; 493 data = data << 3;
@@ -496,43 +495,37 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
496 /* Reset the demod pll word length to 0x15 bits */ 495 /* Reset the demod pll word length to 0x15 bits */
497 cx24123_writereg(state, 0x21, 0x15); 496 cx24123_writereg(state, 0x21, 0x15);
498 497
499 timeout = 0;
500 /* write the msb 8 bits, wait for the send to be completed */ 498 /* write the msb 8 bits, wait for the send to be completed */
499 timeout = jiffies + msecs_to_jiffies(40);
501 cx24123_writereg(state, 0x22, (data >> 16) & 0xff); 500 cx24123_writereg(state, 0x22, (data >> 16) & 0xff);
502 while ( ( cx24123_readreg(state, 0x20) & 0x40 ) == 0 ) 501 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
503 { 502 if (time_after(jiffies, timeout)) {
504 /* Safety - No reason why the write should not complete, and we never get here, avoid hang */ 503 printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
505 if (timeout++ >= 4) {
506 printk("%s: demodulator is no longer responding, aborting.\n",__FUNCTION__);
507 return -EREMOTEIO; 504 return -EREMOTEIO;
508 } 505 }
509 msleep(500); 506 msleep(10);
510 } 507 }
511 508
512 timeout = 0;
513 /* send another 8 bytes, wait for the send to be completed */ 509 /* send another 8 bytes, wait for the send to be completed */
510 timeout = jiffies + msecs_to_jiffies(40);
514 cx24123_writereg(state, 0x22, (data>>8) & 0xff ); 511 cx24123_writereg(state, 0x22, (data>>8) & 0xff );
515 while ( (cx24123_readreg(state, 0x20) & 0x40 ) == 0 ) 512 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
516 { 513 if (time_after(jiffies, timeout)) {
517 /* Safety - No reason why the write should not complete, and we never get here, avoid hang */ 514 printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
518 if (timeout++ >= 4) {
519 printk("%s: demodulator is not responding, possibly hung, aborting.\n",__FUNCTION__);
520 return -EREMOTEIO; 515 return -EREMOTEIO;
521 } 516 }
522 msleep(500); 517 msleep(10);
523 } 518 }
524 519
525 timeout = 0;
526 /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ 520 /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */
521 timeout = jiffies + msecs_to_jiffies(40);
527 cx24123_writereg(state, 0x22, (data) & 0xff ); 522 cx24123_writereg(state, 0x22, (data) & 0xff );
528 while ((cx24123_readreg(state, 0x20) & 0x80)) 523 while ((cx24123_readreg(state, 0x20) & 0x80)) {
529 { 524 if (time_after(jiffies, timeout)) {
530 /* Safety - No reason why the write should not complete, and we never get here, avoid hang */ 525 printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
531 if (timeout++ >= 4) {
532 printk("%s: demodulator is not responding, possibly hung, aborting.\n",__FUNCTION__);
533 return -EREMOTEIO; 526 return -EREMOTEIO;
534 } 527 }
535 msleep(500); 528 msleep(10);
536 } 529 }
537 530
538 /* Trigger the demod to configure the tuner */ 531 /* Trigger the demod to configure the tuner */