aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 40b2f2a6d3cc..a1ca0f5007e0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1209,7 +1209,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1209{ 1209{
1210 const struct firmware *fw_entry = NULL; 1210 const struct firmware *fw_entry = NULL;
1211 void *fw_ptr; 1211 void *fw_ptr;
1212 unsigned int pipe, fw_len, fw_done; 1212 unsigned int pipe, fw_len, fw_done, bcnt, icnt;
1213 int actual_length; 1213 int actual_length;
1214 int ret = 0; 1214 int ret = 0;
1215 int fwidx; 1215 int fwidx;
@@ -1265,11 +1265,11 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1265 1265
1266 fw_len = fw_entry->size; 1266 fw_len = fw_entry->size;
1267 1267
1268 if (fw_len % FIRMWARE_CHUNK_SIZE) { 1268 if (fw_len % sizeof(u32)) {
1269 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1269 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1270 "size of %s firmware" 1270 "size of %s firmware"
1271 " must be a multiple of 8192B", 1271 " must be a multiple of %u bytes",
1272 fw_files[fwidx]); 1272 fw_files[fwidx],sizeof(u32));
1273 release_firmware(fw_entry); 1273 release_firmware(fw_entry);
1274 return -1; 1274 return -1;
1275 } 1275 }
@@ -1284,18 +1284,21 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1284 1284
1285 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); 1285 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT);
1286 1286
1287 for (fw_done = 0 ; (fw_done < fw_len) && !ret ; 1287 fw_done = 0;
1288 fw_done += FIRMWARE_CHUNK_SIZE ) { 1288 for (fw_done = 0; fw_done < fw_len;) {
1289 int i; 1289 bcnt = fw_len - fw_done;
1290 memcpy(fw_ptr, fw_entry->data + fw_done, FIRMWARE_CHUNK_SIZE); 1290 if (bcnt > FIRMWARE_CHUNK_SIZE) bcnt = FIRMWARE_CHUNK_SIZE;
1291 /* Usbsnoop log shows that we must swap bytes... */ 1291 memcpy(fw_ptr, fw_entry->data + fw_done, bcnt);
1292 for (i = 0; i < FIRMWARE_CHUNK_SIZE/4 ; i++) 1292 /* Usbsnoop log shows that we must swap bytes... */
1293 ((u32 *)fw_ptr)[i] = ___swab32(((u32 *)fw_ptr)[i]); 1293 for (icnt = 0; icnt < bcnt/4 ; icnt++)
1294 1294 ((u32 *)fw_ptr)[icnt] =
1295 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr, 1295 ___swab32(((u32 *)fw_ptr)[icnt]);
1296 FIRMWARE_CHUNK_SIZE, 1296
1297 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt,
1297 &actual_length, HZ); 1298 &actual_length, HZ);
1298 ret |= (actual_length != FIRMWARE_CHUNK_SIZE); 1299 ret |= (actual_length != bcnt);
1300 if (ret) break;
1301 fw_done += bcnt;
1299 } 1302 }
1300 1303
1301 trace_firmware("upload of %s : %i / %i ", 1304 trace_firmware("upload of %s : %i / %i ",