aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/af9015.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/af9015.c')
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 8b60a601fb82..9f8370f4cc81 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#include <linux/hash.h>
25
24#include "af9015.h" 26#include "af9015.h"
25#include "af9013.h" 27#include "af9013.h"
26#include "mt2060.h" 28#include "mt2060.h"
@@ -553,26 +555,45 @@ exit:
553 return ret; 555 return ret;
554} 556}
555 557
556/* dump eeprom */ 558/* hash (and dump) eeprom */
557static int af9015_eeprom_dump(struct dvb_usb_device *d) 559static int af9015_eeprom_hash(struct usb_device *udev)
558{ 560{
559 u8 reg, val; 561 static const unsigned int eeprom_size = 256;
562 unsigned int reg;
563 int ret;
564 u8 val, *eeprom;
565 struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};
560 566
561 for (reg = 0; ; reg++) { 567 eeprom = kmalloc(eeprom_size, GFP_KERNEL);
562 if (reg % 16 == 0) { 568 if (eeprom == NULL)
563 if (reg) 569 return -ENOMEM;
564 deb_info(KERN_CONT "\n"); 570
565 deb_info(KERN_DEBUG "%02x:", reg); 571 for (reg = 0; reg < eeprom_size; reg++) {
566 } 572 req.addr = reg;
567 if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0) 573 ret = af9015_rw_udev(udev, &req);
568 deb_info(KERN_CONT " %02x", val); 574 if (ret)
569 else 575 goto free;
570 deb_info(KERN_CONT " --"); 576 eeprom[reg] = val;
571 if (reg == 0xff)
572 break;
573 } 577 }
574 deb_info(KERN_CONT "\n"); 578
575 return 0; 579 if (dvb_usb_af9015_debug & 0x01)
580 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, eeprom,
581 eeprom_size);
582
583 BUG_ON(eeprom_size % 4);
584
585 af9015_config.eeprom_sum = 0;
586 for (reg = 0; reg < eeprom_size / sizeof(u32); reg++) {
587 af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
588 af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
589 }
590
591 deb_info("%s: eeprom sum=%.8x\n", __func__, af9015_config.eeprom_sum);
592
593 ret = 0;
594free:
595 kfree(eeprom);
596 return ret;
576} 597}
577 598
578static int af9015_download_ir_table(struct dvb_usb_device *d) 599static int af9015_download_ir_table(struct dvb_usb_device *d)
@@ -728,6 +749,11 @@ static int af9015_read_config(struct usb_device *udev)
728 } 749 }
729 if (ret) 750 if (ret)
730 goto error; 751 goto error;
752
753 ret = af9015_eeprom_hash(udev);
754 if (ret)
755 goto error;
756
731 deb_info("%s: IR mode:%d\n", __func__, val); 757 deb_info("%s: IR mode:%d\n", __func__, val);
732 for (i = 0; i < af9015_properties_count; i++) { 758 for (i = 0; i < af9015_properties_count; i++) {
733 if (val == AF9015_IR_MODE_DISABLED) { 759 if (val == AF9015_IR_MODE_DISABLED) {
@@ -1125,11 +1151,6 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
1125 1151
1126 deb_info("%s: init I2C\n", __func__); 1152 deb_info("%s: init I2C\n", __func__);
1127 ret = af9015_i2c_init(adap->dev); 1153 ret = af9015_i2c_init(adap->dev);
1128
1129 /* dump eeprom (debug) */
1130 ret = af9015_eeprom_dump(adap->dev);
1131 if (ret)
1132 return ret;
1133 } else { 1154 } else {
1134 /* select I2C adapter */ 1155 /* select I2C adapter */
1135 i2c_adap = &state->i2c_adap; 1156 i2c_adap = &state->i2c_adap;