aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx25840
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-05-23 18:58:24 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-10 09:26:02 -0400
commit9ad46a6ac5422882d9f9a7f0d77ca0766f56bb6e (patch)
tree4716d6cc576cd6c9b34a11f4845b33561949908e /drivers/media/video/cx25840
parentf61e761e2128c7ca0d044651b18928991ab03be2 (diff)
cx25840: treat firmware data as const
Signed-off-by: David Woodhouse <dwmw2@infradead.org> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Acked-by: Tyler Trafford <ttrafford@gmail.com> Acked-by: Mike Isely <isely@pobox.com>
Diffstat (limited to 'drivers/media/video/cx25840')
-rw-r--r--drivers/media/video/cx25840/cx25840-firmware.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
index 620d295947ab..8d489a4b9570 100644
--- a/drivers/media/video/cx25840/cx25840-firmware.c
+++ b/drivers/media/video/cx25840/cx25840-firmware.c
@@ -79,7 +79,7 @@ static int check_fw_load(struct i2c_client *client, int size)
79 return 0; 79 return 0;
80} 80}
81 81
82static int fw_write(struct i2c_client *client, u8 *data, int size) 82static int fw_write(struct i2c_client *client, const u8 *data, int size)
83{ 83{
84 if (i2c_master_send(client, data, size) < size) { 84 if (i2c_master_send(client, data, size) < size) {
85 v4l_err(client, "firmware load i2c failure\n"); 85 v4l_err(client, "firmware load i2c failure\n");
@@ -93,7 +93,8 @@ int cx25840_loadfw(struct i2c_client *client)
93{ 93{
94 struct cx25840_state *state = i2c_get_clientdata(client); 94 struct cx25840_state *state = i2c_get_clientdata(client);
95 const struct firmware *fw = NULL; 95 const struct firmware *fw = NULL;
96 u8 buffer[4], *ptr; 96 u8 buffer[FWSEND];
97 const u8 *ptr;
97 int size, retval; 98 int size, retval;
98 99
99 if (state->is_cx23885) 100 if (state->is_cx23885)
@@ -108,29 +109,23 @@ int cx25840_loadfw(struct i2c_client *client)
108 109
109 buffer[0] = 0x08; 110 buffer[0] = 0x08;
110 buffer[1] = 0x02; 111 buffer[1] = 0x02;
111 buffer[2] = fw->data[0];
112 buffer[3] = fw->data[1];
113 retval = fw_write(client, buffer, 4);
114 112
115 if (retval < 0) { 113 size = fw->size;
116 release_firmware(fw);
117 return retval;
118 }
119
120 size = fw->size - 2;
121 ptr = fw->data; 114 ptr = fw->data;
122 while (size > 0) { 115 while (size > 0) {
123 ptr[0] = 0x08; 116 int len = min(FWSEND - 2, size);
124 ptr[1] = 0x02; 117
125 retval = fw_write(client, ptr, min(FWSEND, size + 2)); 118 memcpy(buffer + 2, ptr, len);
119
120 retval = fw_write(client, buffer, len + 2);
126 121
127 if (retval < 0) { 122 if (retval < 0) {
128 release_firmware(fw); 123 release_firmware(fw);
129 return retval; 124 return retval;
130 } 125 }
131 126
132 size -= FWSEND - 2; 127 size -= len;
133 ptr += FWSEND - 2; 128 ptr += len;
134 } 129 }
135 130
136 end_fw_load(client); 131 end_fw_load(client);