Commit 9ad46a6a authored by David Woodhouse's avatar David Woodhouse Committed by David Woodhouse

cx25840: treat firmware data as const

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Acked-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Acked-by: default avatarTyler Trafford <ttrafford@gmail.com>
Acked-by: default avatarMike Isely <isely@pobox.com>
parent f61e761e
...@@ -79,7 +79,7 @@ static int check_fw_load(struct i2c_client *client, int size) ...@@ -79,7 +79,7 @@ static int check_fw_load(struct i2c_client *client, int size)
return 0; return 0;
} }
static int fw_write(struct i2c_client *client, u8 *data, int size) static int fw_write(struct i2c_client *client, const u8 *data, int size)
{ {
if (i2c_master_send(client, data, size) < size) { if (i2c_master_send(client, data, size) < size) {
v4l_err(client, "firmware load i2c failure\n"); v4l_err(client, "firmware load i2c failure\n");
...@@ -93,7 +93,8 @@ int cx25840_loadfw(struct i2c_client *client) ...@@ -93,7 +93,8 @@ int cx25840_loadfw(struct i2c_client *client)
{ {
struct cx25840_state *state = i2c_get_clientdata(client); struct cx25840_state *state = i2c_get_clientdata(client);
const struct firmware *fw = NULL; const struct firmware *fw = NULL;
u8 buffer[4], *ptr; u8 buffer[FWSEND];
const u8 *ptr;
int size, retval; int size, retval;
if (state->is_cx23885) if (state->is_cx23885)
...@@ -108,29 +109,23 @@ int cx25840_loadfw(struct i2c_client *client) ...@@ -108,29 +109,23 @@ int cx25840_loadfw(struct i2c_client *client)
buffer[0] = 0x08; buffer[0] = 0x08;
buffer[1] = 0x02; buffer[1] = 0x02;
buffer[2] = fw->data[0];
buffer[3] = fw->data[1];
retval = fw_write(client, buffer, 4);
if (retval < 0) { size = fw->size;
release_firmware(fw);
return retval;
}
size = fw->size - 2;
ptr = fw->data; ptr = fw->data;
while (size > 0) { while (size > 0) {
ptr[0] = 0x08; int len = min(FWSEND - 2, size);
ptr[1] = 0x02;
retval = fw_write(client, ptr, min(FWSEND, size + 2)); memcpy(buffer + 2, ptr, len);
retval = fw_write(client, buffer, len + 2);
if (retval < 0) { if (retval < 0) {
release_firmware(fw); release_firmware(fw);
return retval; return retval;
} }
size -= FWSEND - 2; size -= len;
ptr += FWSEND - 2; ptr += len;
} }
end_fw_load(client); end_fw_load(client);
......
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