Commit 77e28ec2 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] ec168: re-implement firmware loading

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d32be218
...@@ -209,31 +209,28 @@ static int ec168_identify_state(struct dvb_usb_device *d) ...@@ -209,31 +209,28 @@ static int ec168_identify_state(struct dvb_usb_device *d)
static int ec168_download_firmware(struct dvb_usb_device *d, static int ec168_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw) const struct firmware *fw)
{ {
int i, len, packets, remainder, ret; int ret, len, remaining;
u16 addr = 0x0000; /* firmware start address */
struct ec168_req req = {DOWNLOAD_FIRMWARE, 0, 0, 0, NULL}; struct ec168_req req = {DOWNLOAD_FIRMWARE, 0, 0, 0, NULL};
pr_debug("%s:\n", __func__); pr_debug("%s:\n", __func__);
#define FW_PACKET_MAX_DATA 2048 #define LEN_MAX 2048 /* max packet size */
packets = fw->size / FW_PACKET_MAX_DATA; for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) {
remainder = fw->size % FW_PACKET_MAX_DATA; len = remaining;
len = FW_PACKET_MAX_DATA; if (len > LEN_MAX)
for (i = 0; i <= packets; i++) { len = LEN_MAX;
if (i == packets) /* set size of the last packet */
len = remainder;
req.size = len; req.size = len;
req.data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); req.data = (u8 *) &fw->data[fw->size - remaining];
req.index = addr; req.index = fw->size - remaining;
addr += FW_PACKET_MAX_DATA;
ret = ec168_ctrl_msg(d, &req); ret = ec168_ctrl_msg(d, &req);
if (ret) { if (ret) {
pr_err("%s: firmware download failed=%d packet=%d\n", pr_err("%s: firmware download failed=%d\n",
KBUILD_MODNAME, ret, i); KBUILD_MODNAME, ret);
goto error; goto error;
} }
} }
req.size = 0; req.size = 0;
/* set "warm"? */ /* set "warm"? */
......
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