diff options
-rw-r--r-- | drivers/media/dvb/frontends/af9013.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c index 6f50f0673994..345311c33383 100644 --- a/drivers/media/dvb/frontends/af9013.c +++ b/drivers/media/dvb/frontends/af9013.c | |||
@@ -1323,13 +1323,11 @@ static struct dvb_frontend_ops af9013_ops; | |||
1323 | 1323 | ||
1324 | static int af9013_download_firmware(struct af9013_state *state) | 1324 | static int af9013_download_firmware(struct af9013_state *state) |
1325 | { | 1325 | { |
1326 | int i, len, packets, remainder, ret; | 1326 | int i, len, remaining, ret; |
1327 | const struct firmware *fw; | 1327 | const struct firmware *fw; |
1328 | u16 addr = 0x5100; /* firmware start address */ | ||
1329 | u16 checksum = 0; | 1328 | u16 checksum = 0; |
1330 | u8 val; | 1329 | u8 val; |
1331 | u8 fw_params[4]; | 1330 | u8 fw_params[4]; |
1332 | u8 *data; | ||
1333 | u8 *fw_file = AF9013_DEFAULT_FIRMWARE; | 1331 | u8 *fw_file = AF9013_DEFAULT_FIRMWARE; |
1334 | 1332 | ||
1335 | msleep(100); | 1333 | msleep(100); |
@@ -1373,21 +1371,18 @@ static int af9013_download_firmware(struct af9013_state *state) | |||
1373 | if (ret) | 1371 | if (ret) |
1374 | goto error_release; | 1372 | goto error_release; |
1375 | 1373 | ||
1376 | #define FW_PACKET_MAX_DATA 16 | 1374 | #define FW_ADDR 0x5100 /* firmware start address */ |
1377 | 1375 | #define LEN_MAX 16 /* max packet size */ | |
1378 | packets = fw->size / FW_PACKET_MAX_DATA; | 1376 | for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) { |
1379 | remainder = fw->size % FW_PACKET_MAX_DATA; | 1377 | len = remaining; |
1380 | len = FW_PACKET_MAX_DATA; | 1378 | if (len > LEN_MAX) |
1381 | for (i = 0; i <= packets; i++) { | 1379 | len = LEN_MAX; |
1382 | if (i == packets) /* set size of the last packet */ | ||
1383 | len = remainder; | ||
1384 | |||
1385 | data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); | ||
1386 | ret = af9013_write_ofsm_regs(state, addr, data, len); | ||
1387 | addr += FW_PACKET_MAX_DATA; | ||
1388 | 1380 | ||
1381 | ret = af9013_write_ofsm_regs(state, | ||
1382 | FW_ADDR + fw->size - remaining, | ||
1383 | (u8 *) &fw->data[fw->size - remaining], len); | ||
1389 | if (ret) { | 1384 | if (ret) { |
1390 | err("firmware download failed at %d with %d", i, ret); | 1385 | err("firmware download failed:%d", ret); |
1391 | goto error_release; | 1386 | goto error_release; |
1392 | } | 1387 | } |
1393 | } | 1388 | } |