diff options
author | Douglas Schilling Landgraf <dougsland@linuxtv.org> | 2008-09-08 02:27:20 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:37:00 -0400 |
commit | f2a01a0027b29f682c3833d582e2827a4690f661 (patch) | |
tree | b16a459c19b4861b991e039b4d859d60e5110f6c /drivers/media/video | |
parent | a50f4a444a14a116e2eb077e01c2eaf58ddb7c6a (diff) |
V4L/DVB (8937): em28xx: Fix and add some validations
Fixed and Added some validations
Signed-off-by: Douglas Schilling Landgraf <dougsland@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-i2c.c | 28 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 45 |
2 files changed, 61 insertions, 12 deletions
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 2989a65f6917..3bab56b997fc 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
@@ -336,8 +336,11 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
336 | 336 | ||
337 | /* Check if board has eeprom */ | 337 | /* Check if board has eeprom */ |
338 | err = i2c_master_recv(&dev->i2c_client, &buf, 0); | 338 | err = i2c_master_recv(&dev->i2c_client, &buf, 0); |
339 | if (err < 0) | 339 | if (err < 0) { |
340 | return -1; | 340 | em28xx_errdev("%s: i2c_master_recv failed! err [%d]\n", |
341 | __func__, err); | ||
342 | return err; | ||
343 | } | ||
341 | 344 | ||
342 | buf = 0; | 345 | buf = 0; |
343 | 346 | ||
@@ -345,7 +348,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
345 | if (err != 1) { | 348 | if (err != 1) { |
346 | printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n", | 349 | printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n", |
347 | dev->name, err); | 350 | dev->name, err); |
348 | return -1; | 351 | return err; |
349 | } | 352 | } |
350 | while (size > 0) { | 353 | while (size > 0) { |
351 | if (size > 16) | 354 | if (size > 16) |
@@ -358,7 +361,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
358 | printk(KERN_WARNING | 361 | printk(KERN_WARNING |
359 | "%s: i2c eeprom read error (err=%d)\n", | 362 | "%s: i2c eeprom read error (err=%d)\n", |
360 | dev->name, err); | 363 | dev->name, err); |
361 | return -1; | 364 | return err; |
362 | } | 365 | } |
363 | size -= block; | 366 | size -= block; |
364 | p += block; | 367 | p += block; |
@@ -586,18 +589,31 @@ void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg) | |||
586 | */ | 589 | */ |
587 | int em28xx_i2c_register(struct em28xx *dev) | 590 | int em28xx_i2c_register(struct em28xx *dev) |
588 | { | 591 | { |
592 | int retval; | ||
593 | |||
589 | BUG_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg); | 594 | BUG_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg); |
590 | BUG_ON(!dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req); | 595 | BUG_ON(!dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req); |
591 | dev->i2c_adap = em28xx_adap_template; | 596 | dev->i2c_adap = em28xx_adap_template; |
592 | dev->i2c_adap.dev.parent = &dev->udev->dev; | 597 | dev->i2c_adap.dev.parent = &dev->udev->dev; |
593 | strcpy(dev->i2c_adap.name, dev->name); | 598 | strcpy(dev->i2c_adap.name, dev->name); |
594 | dev->i2c_adap.algo_data = dev; | 599 | dev->i2c_adap.algo_data = dev; |
595 | i2c_add_adapter(&dev->i2c_adap); | 600 | |
601 | retval = i2c_add_adapter(&dev->i2c_adap); | ||
602 | if (retval < 0) { | ||
603 | em28xx_errdev("%s: i2c_add_adapter failed! retval [%d]\n", | ||
604 | __func__, retval); | ||
605 | return retval; | ||
606 | } | ||
596 | 607 | ||
597 | dev->i2c_client = em28xx_client_template; | 608 | dev->i2c_client = em28xx_client_template; |
598 | dev->i2c_client.adapter = &dev->i2c_adap; | 609 | dev->i2c_client.adapter = &dev->i2c_adap; |
599 | 610 | ||
600 | em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); | 611 | retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); |
612 | if (retval < 0) { | ||
613 | em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", | ||
614 | __func__, retval); | ||
615 | return retval; | ||
616 | } | ||
601 | 617 | ||
602 | if (i2c_scan) | 618 | if (i2c_scan) |
603 | em28xx_do_i2c_scan(dev); | 619 | em28xx_do_i2c_scan(dev); |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 600b340e3550..50d2c7a9b3c1 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -513,10 +513,17 @@ static struct videobuf_queue_ops em28xx_video_qops = { | |||
513 | */ | 513 | */ |
514 | static int em28xx_config(struct em28xx *dev) | 514 | static int em28xx_config(struct em28xx *dev) |
515 | { | 515 | { |
516 | int retval; | ||
516 | 517 | ||
517 | /* Sets I2C speed to 100 KHz */ | 518 | /* Sets I2C speed to 100 KHz */ |
518 | if (!dev->is_em2800) | 519 | if (!dev->is_em2800) { |
519 | em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1); | 520 | retval = em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1); |
521 | if (retval < 0) { | ||
522 | em28xx_errdev("%s: em28xx_write_regs_req failed! retval [%d]\n", | ||
523 | __func__, retval); | ||
524 | return retval; | ||
525 | } | ||
526 | } | ||
520 | 527 | ||
521 | /* enable vbi capturing */ | 528 | /* enable vbi capturing */ |
522 | 529 | ||
@@ -1953,13 +1960,23 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1953 | } | 1960 | } |
1954 | 1961 | ||
1955 | /* register i2c bus */ | 1962 | /* register i2c bus */ |
1956 | em28xx_i2c_register(dev); | 1963 | errCode = em28xx_i2c_register(dev); |
1964 | if (errCode < 0) { | ||
1965 | em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n", | ||
1966 | __func__, errCode); | ||
1967 | return errCode; | ||
1968 | } | ||
1957 | 1969 | ||
1958 | /* Do board specific init and eeprom reading */ | 1970 | /* Do board specific init and eeprom reading */ |
1959 | em28xx_card_setup(dev); | 1971 | em28xx_card_setup(dev); |
1960 | 1972 | ||
1961 | /* Configure audio */ | 1973 | /* Configure audio */ |
1962 | em28xx_audio_analog_set(dev); | 1974 | errCode = em28xx_audio_analog_set(dev); |
1975 | if (errCode < 0) { | ||
1976 | em28xx_errdev("%s: em28xx_audio_analog_set - errCode [%d]!\n", | ||
1977 | __func__, errCode); | ||
1978 | return errCode; | ||
1979 | } | ||
1963 | 1980 | ||
1964 | /* configure the device */ | 1981 | /* configure the device */ |
1965 | em28xx_config_i2c(dev); | 1982 | em28xx_config_i2c(dev); |
@@ -1979,6 +1996,11 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1979 | dev->ctl_input = 2; | 1996 | dev->ctl_input = 2; |
1980 | 1997 | ||
1981 | errCode = em28xx_config(dev); | 1998 | errCode = em28xx_config(dev); |
1999 | if (errCode < 0) { | ||
2000 | em28xx_errdev("%s: em28xx_config - errCode [%d]!\n", | ||
2001 | __func__, errCode); | ||
2002 | return errCode; | ||
2003 | } | ||
1982 | 2004 | ||
1983 | list_add_tail(&dev->devlist, &em28xx_devlist); | 2005 | list_add_tail(&dev->devlist, &em28xx_devlist); |
1984 | 2006 | ||
@@ -2031,9 +2053,20 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2031 | 2053 | ||
2032 | if (dev->has_msp34xx) { | 2054 | if (dev->has_msp34xx) { |
2033 | /* Send a reset to other chips via gpio */ | 2055 | /* Send a reset to other chips via gpio */ |
2034 | em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); | 2056 | errCode = em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); |
2057 | if (errCode < 0) { | ||
2058 | em28xx_errdev("%s: em28xx_write_regs_req - msp34xx(1) failed! errCode [%d]\n", | ||
2059 | __func__, errCode); | ||
2060 | return errCode; | ||
2061 | } | ||
2035 | msleep(3); | 2062 | msleep(3); |
2036 | em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1); | 2063 | |
2064 | errCode = em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1); | ||
2065 | if (errCode < 0) { | ||
2066 | em28xx_errdev("%s: em28xx_write_regs_req - msp34xx(2) failed! errCode [%d]\n", | ||
2067 | __func__, errCode); | ||
2068 | return errCode; | ||
2069 | } | ||
2037 | msleep(3); | 2070 | msleep(3); |
2038 | } | 2071 | } |
2039 | 2072 | ||