diff options
author | Antti Palosaari <crope@iki.fi> | 2012-06-12 22:16:12 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-04 07:56:31 -0300 |
commit | 77e28ec27927dbb130d84a9fe7cbe85bf6bf47ea (patch) | |
tree | 4cf4d9ce91c999d136eed7a34bb3d50d62c3b405 | |
parent | d32be21800feb38d51a584437f1a5eb3f4126a17 (diff) |
[media] ec168: re-implement firmware loading
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/dvb-usb/ec168.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c index 717c66a4bddd..3ed80b01d5fa 100644 --- a/drivers/media/dvb/dvb-usb/ec168.c +++ b/drivers/media/dvb/dvb-usb/ec168.c @@ -209,31 +209,28 @@ error: static int ec168_download_firmware(struct dvb_usb_device *d, const struct firmware *fw) { - int i, len, packets, remainder, ret; - u16 addr = 0x0000; /* firmware start address */ + int ret, len, remaining; struct ec168_req req = {DOWNLOAD_FIRMWARE, 0, 0, 0, NULL}; pr_debug("%s:\n", __func__); - #define FW_PACKET_MAX_DATA 2048 - packets = fw->size / FW_PACKET_MAX_DATA; - remainder = fw->size % FW_PACKET_MAX_DATA; - len = FW_PACKET_MAX_DATA; - for (i = 0; i <= packets; i++) { - if (i == packets) /* set size of the last packet */ - len = remainder; + #define LEN_MAX 2048 /* max packet size */ + for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) { + len = remaining; + if (len > LEN_MAX) + len = LEN_MAX; req.size = len; - req.data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); - req.index = addr; - addr += FW_PACKET_MAX_DATA; + req.data = (u8 *) &fw->data[fw->size - remaining]; + req.index = fw->size - remaining; ret = ec168_ctrl_msg(d, &req); if (ret) { - pr_err("%s: firmware download failed=%d packet=%d\n", - KBUILD_MODNAME, ret, i); + pr_err("%s: firmware download failed=%d\n", + KBUILD_MODNAME, ret); goto error; } } + req.size = 0; /* set "warm"? */ |