aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-11-13 12:01:15 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-11-14 11:24:44 -0500
commit099b7fcc770764ec06441066fddd90b97d868e11 (patch)
tree3d361ef75ebd2a9298f46b5f229dd7552695fe9a /drivers/media
parentdd03e970a18f266faf120e47355349d224f64e3f (diff)
V4L/DVB (9618): tvaudio: add additional logic to avoid OOPS
This patch checks for volume, bass, treble, set mode and get mode callbacks before actually enabling the code that would use them. Instead of aborting the driver for load, this patch will allow it to load with a reduced number of functionatities. This prevents OOPS if some board entry is missing a needed callback. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tvaudio.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 1387c54b7f02..6c920bf74973 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1511,20 +1511,49 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1511 chip_cmd(chip,"init",&desc->init); 1511 chip_cmd(chip,"init",&desc->init);
1512 1512
1513 if (desc->flags & CHIP_HAS_VOLUME) { 1513 if (desc->flags & CHIP_HAS_VOLUME) {
1514 chip->left = desc->leftinit ? desc->leftinit : 65535; 1514 if (!desc->volfunc) {
1515 chip->right = desc->rightinit ? desc->rightinit : 65535; 1515 /* This shouldn't be happen. Warn user, but keep working
1516 chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); 1516 without volume controls
1517 chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); 1517 */
1518 v4l_info(chip->c, "volume callback undefined!\n");
1519 desc->flags &= ~CHIP_HAS_VOLUME;
1520 } else {
1521 chip->left = desc->leftinit ? desc->leftinit : 65535;
1522 chip->right = desc->rightinit ? desc->rightinit : 65535;
1523 chip_write(chip, desc->leftreg,
1524 desc->volfunc(chip->left));
1525 chip_write(chip, desc->rightreg,
1526 desc->volfunc(chip->right));
1527 }
1518 } 1528 }
1519 if (desc->flags & CHIP_HAS_BASSTREBLE) { 1529 if (desc->flags & CHIP_HAS_BASSTREBLE) {
1520 chip->treble = desc->trebleinit ? desc->trebleinit : 32768; 1530 if (!desc->bassfunc || !desc->treblefunc) {
1521 chip->bass = desc->bassinit ? desc->bassinit : 32768; 1531 /* This shouldn't be happen. Warn user, but keep working
1522 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); 1532 without bass/treble controls
1523 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1533 */
1534 v4l_info(chip->c, "bass/treble callbacks undefined!\n");
1535 desc->flags &= ~CHIP_HAS_BASSTREBLE;
1536 } else {
1537 chip->treble = desc->trebleinit ?
1538 desc->trebleinit : 32768;
1539 chip->bass = desc->bassinit ?
1540 desc->bassinit : 32768;
1541 chip_write(chip, desc->bassreg,
1542 desc->bassfunc(chip->bass));
1543 chip_write(chip, desc->treblereg,
1544 desc->treblefunc(chip->treble));
1545 }
1524 } 1546 }
1525 1547
1526 chip->thread = NULL; 1548 chip->thread = NULL;
1527 if (desc->flags & CHIP_NEED_CHECKMODE) { 1549 if (desc->flags & CHIP_NEED_CHECKMODE) {
1550 if (!desc->getmode || !desc->setmode) {
1551 /* This shouldn't be happen. Warn user, but keep working
1552 without kthread
1553 */
1554 v4l_info(chip->c, "set/get mode callbacks undefined!\n");
1555 return 0;
1556 }
1528 /* start async thread */ 1557 /* start async thread */
1529 init_timer(&chip->wt); 1558 init_timer(&chip->wt);
1530 chip->wt.function = chip_thread_wake; 1559 chip->wt.function = chip_thread_wake;