aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorYeasah Pell <yeasah@schwide.com>2006-08-08 08:10:18 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-08-08 14:53:04 -0400
commit0851fb48486c044476b019029245cb9b348fca33 (patch)
tree4a664e168f9d809963a52f507e0b5c4f6803e881 /drivers/media/dvb
parenteafa98177a388700d613c187c7716e11869b7171 (diff)
V4L/DVB (4431): Add several error checks to dst
Signed-off-by: Yeasah Pell <yeasah@shwide.com> Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/bt8xx/dst.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index d687a14ec0a7..06ac899a9a26 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -393,7 +393,7 @@ static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
393 state->bandwidth = bandwidth; 393 state->bandwidth = bandwidth;
394 394
395 if (state->dst_type != DST_TYPE_IS_TERR) 395 if (state->dst_type != DST_TYPE_IS_TERR)
396 return 0; 396 return -EOPNOTSUPP;
397 397
398 switch (bandwidth) { 398 switch (bandwidth) {
399 case BANDWIDTH_6_MHZ: 399 case BANDWIDTH_6_MHZ:
@@ -462,7 +462,7 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
462 462
463 state->symbol_rate = srate; 463 state->symbol_rate = srate;
464 if (state->dst_type == DST_TYPE_IS_TERR) { 464 if (state->dst_type == DST_TYPE_IS_TERR) {
465 return 0; 465 return -EOPNOTSUPP;
466 } 466 }
467 dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); 467 dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
468 srate /= 1000; 468 srate /= 1000;
@@ -504,7 +504,7 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
504static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulation) 504static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulation)
505{ 505{
506 if (state->dst_type != DST_TYPE_IS_CABLE) 506 if (state->dst_type != DST_TYPE_IS_CABLE)
507 return 0; 507 return -EOPNOTSUPP;
508 508
509 state->modulation = modulation; 509 state->modulation = modulation;
510 switch (modulation) { 510 switch (modulation) {
@@ -1234,7 +1234,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
1234 goto error; 1234 goto error;
1235 } 1235 }
1236 if (write_dst(state, data, len)) { 1236 if (write_dst(state, data, len)) {
1237 dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); 1237 dprintk(verbose, DST_INFO, 1, "Trying to recover.. ");
1238 if ((dst_error_recovery(state)) < 0) { 1238 if ((dst_error_recovery(state)) < 0) {
1239 dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); 1239 dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
1240 goto error; 1240 goto error;
@@ -1328,15 +1328,13 @@ static int dst_tone_power_cmd(struct dst_state *state)
1328{ 1328{
1329 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; 1329 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
1330 1330
1331 if (state->dst_type == DST_TYPE_IS_TERR) 1331 if (state->dst_type != DST_TYPE_IS_SAT)
1332 return 0; 1332 return -EOPNOTSUPP;
1333 paket[4] = state->tx_tuna[4]; 1333 paket[4] = state->tx_tuna[4];
1334 paket[2] = state->tx_tuna[2]; 1334 paket[2] = state->tx_tuna[2];
1335 paket[3] = state->tx_tuna[3]; 1335 paket[3] = state->tx_tuna[3];
1336 paket[7] = dst_check_sum (paket, 7); 1336 paket[7] = dst_check_sum (paket, 7);
1337 dst_command(state, paket, 8); 1337 return dst_command(state, paket, 8);
1338
1339 return 0;
1340} 1338}
1341 1339
1342static int dst_get_tuna(struct dst_state *state) 1340static int dst_get_tuna(struct dst_state *state)
@@ -1465,7 +1463,7 @@ static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd
1465 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; 1463 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
1466 1464
1467 if (state->dst_type != DST_TYPE_IS_SAT) 1465 if (state->dst_type != DST_TYPE_IS_SAT)
1468 return 0; 1466 return -EOPNOTSUPP;
1469 if (cmd->msg_len > 0 && cmd->msg_len < 5) 1467 if (cmd->msg_len > 0 && cmd->msg_len < 5)
1470 memcpy(&paket[3], cmd->msg, cmd->msg_len); 1468 memcpy(&paket[3], cmd->msg, cmd->msg_len);
1471 else if (cmd->msg_len == 5 && state->dst_hw_cap & DST_TYPE_HAS_DISEQC5) 1469 else if (cmd->msg_len == 5 && state->dst_hw_cap & DST_TYPE_HAS_DISEQC5)
@@ -1473,18 +1471,17 @@ static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd
1473 else 1471 else
1474 return -EINVAL; 1472 return -EINVAL;
1475 paket[7] = dst_check_sum(&paket[0], 7); 1473 paket[7] = dst_check_sum(&paket[0], 7);
1476 dst_command(state, paket, 8); 1474 return dst_command(state, paket, 8);
1477 return 0;
1478} 1475}
1479 1476
1480static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 1477static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1481{ 1478{
1482 int need_cmd; 1479 int need_cmd, retval = 0;
1483 struct dst_state *state = fe->demodulator_priv; 1480 struct dst_state *state = fe->demodulator_priv;
1484 1481
1485 state->voltage = voltage; 1482 state->voltage = voltage;
1486 if (state->dst_type != DST_TYPE_IS_SAT) 1483 if (state->dst_type != DST_TYPE_IS_SAT)
1487 return 0; 1484 return -EOPNOTSUPP;
1488 1485
1489 need_cmd = 0; 1486 need_cmd = 0;
1490 1487
@@ -1506,9 +1503,9 @@ static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1506 } 1503 }
1507 1504
1508 if (need_cmd) 1505 if (need_cmd)
1509 dst_tone_power_cmd(state); 1506 retval = dst_tone_power_cmd(state);
1510 1507
1511 return 0; 1508 return retval;
1512} 1509}
1513 1510
1514static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) 1511static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
@@ -1517,7 +1514,7 @@ static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
1517 1514
1518 state->tone = tone; 1515 state->tone = tone;
1519 if (state->dst_type != DST_TYPE_IS_SAT) 1516 if (state->dst_type != DST_TYPE_IS_SAT)
1520 return 0; 1517 return -EOPNOTSUPP;
1521 1518
1522 switch (tone) { 1519 switch (tone) {
1523 case SEC_TONE_OFF: 1520 case SEC_TONE_OFF:
@@ -1533,9 +1530,7 @@ static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
1533 default: 1530 default:
1534 return -EINVAL; 1531 return -EINVAL;
1535 } 1532 }
1536 dst_tone_power_cmd(state); 1533 return dst_tone_power_cmd(state);
1537
1538 return 0;
1539} 1534}
1540 1535
1541static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) 1536static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
@@ -1543,7 +1538,7 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1543 struct dst_state *state = fe->demodulator_priv; 1538 struct dst_state *state = fe->demodulator_priv;
1544 1539
1545 if (state->dst_type != DST_TYPE_IS_SAT) 1540 if (state->dst_type != DST_TYPE_IS_SAT)
1546 return 0; 1541 return -EOPNOTSUPP;
1547 state->minicmd = minicmd; 1542 state->minicmd = minicmd;
1548 switch (minicmd) { 1543 switch (minicmd) {
1549 case SEC_MINI_A: 1544 case SEC_MINI_A:
@@ -1553,9 +1548,7 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1553 state->tx_tuna[3] = 0xff; 1548 state->tx_tuna[3] = 0xff;
1554 break; 1549 break;
1555 } 1550 }
1556 dst_tone_power_cmd(state); 1551 return dst_tone_power_cmd(state);
1557
1558 return 0;
1559} 1552}
1560 1553
1561 1554
@@ -1608,28 +1601,31 @@ static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1608{ 1601{
1609 struct dst_state *state = fe->demodulator_priv; 1602 struct dst_state *state = fe->demodulator_priv;
1610 1603
1611 dst_get_signal(state); 1604 int retval = dst_get_signal(state);
1612 *strength = state->decode_strength; 1605 *strength = state->decode_strength;
1613 1606
1614 return 0; 1607 return retval;
1615} 1608}
1616 1609
1617static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) 1610static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
1618{ 1611{
1619 struct dst_state *state = fe->demodulator_priv; 1612 struct dst_state *state = fe->demodulator_priv;
1620 1613
1621 dst_get_signal(state); 1614 int retval = dst_get_signal(state);
1622 *snr = state->decode_snr; 1615 *snr = state->decode_snr;
1623 1616
1624 return 0; 1617 return retval;
1625} 1618}
1626 1619
1627static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 1620static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1628{ 1621{
1622 int retval = -EINVAL;
1629 struct dst_state *state = fe->demodulator_priv; 1623 struct dst_state *state = fe->demodulator_priv;
1630 1624
1631 if (p != NULL) { 1625 if (p != NULL) {
1632 dst_set_freq(state, p->frequency); 1626 retval = dst_set_freq(state, p->frequency);
1627 if(retval != 0)
1628 return retval;
1633 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); 1629 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
1634 1630
1635 if (state->dst_type == DST_TYPE_IS_SAT) { 1631 if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1647,10 +1643,10 @@ static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_paramet
1647 dst_set_symbolrate(state, p->u.qam.symbol_rate); 1643 dst_set_symbolrate(state, p->u.qam.symbol_rate);
1648 dst_set_modulation(state, p->u.qam.modulation); 1644 dst_set_modulation(state, p->u.qam.modulation);
1649 } 1645 }
1650 dst_write_tuna(fe); 1646 retval = dst_write_tuna(fe);
1651 } 1647 }
1652 1648
1653 return 0; 1649 return retval;
1654} 1650}
1655 1651
1656static int dst_tune_frontend(struct dvb_frontend* fe, 1652static int dst_tune_frontend(struct dvb_frontend* fe,