cxusb: treat firmware data as const
authorDavid Woodhouse <dwmw2@infradead.org>
Fri, 23 May 2008 23:12:42 +0000 (00:12 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 10 Jul 2008 13:26:33 +0000 (14:26 +0100)
...which means allocating our own copy when we want to modify it.

(stupid thinko fixed by mkrufky)

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
drivers/media/dvb/dvb-usb/cxusb.c

index 720fcd1c3c1d75caad387932f9bc56329c42ff47..0286156704f2552e8a6ff429e30b34370040f4a2 100644 (file)
@@ -24,6 +24,7 @@
  * see Documentation/dvb/README.dvb-usb for more information
  */
 #include <media/tuner.h>
+#include <linux/vmalloc.h>
 
 #include "cxusb.h"
 
@@ -700,12 +701,26 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
 
                if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
                    fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
-                       fw->data[idoff + 2] =
+                       struct firmware new_fw;
+                       u8 *new_fw_data = vmalloc(fw->size);
+                       int ret;
+
+                       if (!new_fw_data)
+                               return -ENOMEM;
+
+                       memcpy(new_fw_data, fw->data, fw->size);
+                       new_fw.size = fw->size;
+                       new_fw.data = new_fw_data;
+
+                       new_fw_data[idoff + 2] =
                                le16_to_cpu(udev->descriptor.idProduct) + 1;
-                       fw->data[idoff + 3] =
+                       new_fw_data[idoff + 3] =
                                le16_to_cpu(udev->descriptor.idProduct) >> 8;
 
-                       return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
+                       ret = usb_cypress_load_firmware(udev, &new_fw,
+                                                       CYPRESS_FX2);
+                       vfree(new_fw_data);
+                       return ret;
                }
        }