Commit 0c28dcc0 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[media] em28xx: fix eeprom data endianess

The data is stored as little endian in the eeprom.
Hence the correct data types should be used and the data should be converted
to the machine endianess before using it.
The eeprom id (key) also isn't a 32 bit value but 4 separate bytes instead.

[mchehab@redhat.com: Fix CodingStyle]
Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f55eacbe
...@@ -434,19 +434,21 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) ...@@ -434,19 +434,21 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
printk("\n"); printk("\n");
} }
if (em_eeprom->id != 0x9567eb1a) { if (em_eeprom->id[0] != 0x1a || em_eeprom->id[1] != 0xeb ||
em_eeprom->id[2] != 0x67 || em_eeprom->id[3] != 0x95) {
em28xx_errdev("Unknown eeprom type or eeprom corrupted !"); em28xx_errdev("Unknown eeprom type or eeprom corrupted !");
return -ENODEV; return -ENODEV;
} }
dev->hash = em28xx_hash_mem(eedata, len, 32); dev->hash = em28xx_hash_mem(eedata, len, 32);
em28xx_info("EEPROM ID = 0x%08x, EEPROM hash = 0x%08lx\n", em28xx_info("EEPROM ID = %02x %02x %02x %02x, EEPROM hash = 0x%08lx\n",
em_eeprom->id, dev->hash); em_eeprom->id[0], em_eeprom->id[1],
em_eeprom->id[2], em_eeprom->id[3], dev->hash);
em28xx_info("EEPROM info:\n"); em28xx_info("EEPROM info:\n");
switch (em_eeprom->chip_conf >> 4 & 0x3) { switch (le16_to_cpu(em_eeprom->chip_conf) >> 4 & 0x3) {
case 0: case 0:
em28xx_info("\tNo audio on board.\n"); em28xx_info("\tNo audio on board.\n");
break; break;
...@@ -461,13 +463,13 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) ...@@ -461,13 +463,13 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
break; break;
} }
if (em_eeprom->chip_conf & 1 << 3) if (le16_to_cpu(em_eeprom->chip_conf) & 1 << 3)
em28xx_info("\tUSB Remote wakeup capable\n"); em28xx_info("\tUSB Remote wakeup capable\n");
if (em_eeprom->chip_conf & 1 << 2) if (le16_to_cpu(em_eeprom->chip_conf) & 1 << 2)
em28xx_info("\tUSB Self power capable\n"); em28xx_info("\tUSB Self power capable\n");
switch (em_eeprom->chip_conf & 0x3) { switch (le16_to_cpu(em_eeprom->chip_conf) & 0x3) {
case 0: case 0:
em28xx_info("\t500mA max power\n"); em28xx_info("\t500mA max power\n");
break; break;
...@@ -483,9 +485,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) ...@@ -483,9 +485,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
} }
em28xx_info("\tTable at offset 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n", em28xx_info("\tTable at offset 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n",
em_eeprom->string_idx_table, em_eeprom->string_idx_table,
em_eeprom->string1, le16_to_cpu(em_eeprom->string1),
em_eeprom->string2, le16_to_cpu(em_eeprom->string2),
em_eeprom->string3); le16_to_cpu(em_eeprom->string3));
return 0; return 0;
} }
......
...@@ -405,15 +405,15 @@ struct em28xx_board { ...@@ -405,15 +405,15 @@ struct em28xx_board {
}; };
struct em28xx_eeprom { struct em28xx_eeprom {
u32 id; /* 0x9567eb1a */ u8 id[4]; /* 1a eb 67 95 */
u16 vendor_ID; __le16 vendor_ID;
u16 product_ID; __le16 product_ID;
u16 chip_conf; __le16 chip_conf;
u16 board_conf; __le16 board_conf;
u16 string1, string2, string3; __le16 string1, string2, string3;
u8 string_idx_table; u8 string_idx_table;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment