Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 98016
b: refs/heads/master
c: 62b5884
h: refs/heads/master
v: v3
  • Loading branch information
Matthew Garrett authored and Greg Kroah-Hartman committed Jun 12, 2008
1 parent d5a0bb7 commit e52f5da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6460a261b5893e769a314c246faec31bbc4aad9c
refs/heads/master: 62b5884875fcd4babf6c0c377046f226abbfe491
23 changes: 16 additions & 7 deletions trunk/drivers/usb/misc/isight_firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ static int isight_firmware_load(struct usb_interface *intf,
struct usb_device *dev = interface_to_usbdev(intf);
int llen, len, req, ret = 0;
const struct firmware *firmware;
unsigned char *buf;
unsigned char *buf = kmalloc(50, GFP_KERNEL);
unsigned char data[4];
char *ptr;
u8 *ptr;

if (!buf)
return -ENOMEM;

if (request_firmware(&firmware, "isight.fw", &dev->dev) != 0) {
printk(KERN_ERR "Unable to load isight firmware\n");
Expand All @@ -59,7 +62,7 @@ static int isight_firmware_load(struct usb_interface *intf,
goto out;
}

while (1) {
while (ptr+4 <= firmware->data+firmware->size) {
memcpy(data, ptr, 4);
len = (data[0] << 8 | data[1]);
req = (data[2] << 8 | data[3]);
Expand All @@ -71,10 +74,14 @@ static int isight_firmware_load(struct usb_interface *intf,
continue;

for (; len > 0; req += 50) {
llen = len > 50 ? 50 : len;
llen = min(len, 50);
len -= llen;

buf = kmalloc(llen, GFP_KERNEL);
if (ptr+llen > firmware->data+firmware->size) {
printk(KERN_ERR
"Malformed isight firmware");
ret = -ENODEV;
goto out;
}
memcpy(buf, ptr, llen);

ptr += llen;
Expand All @@ -89,16 +96,18 @@ static int isight_firmware_load(struct usb_interface *intf,
goto out;
}

kfree(buf);
}
}

if (usb_control_msg
(dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\0", 1,
300) != 1) {
printk(KERN_ERR "isight firmware loading completion failed\n");
ret = -ENODEV;
}

out:
kfree(buf);
release_firmware(firmware);
return ret;
}
Expand Down

0 comments on commit e52f5da

Please sign in to comment.