Commit 9efb0525 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

Staging: go7007: small cleanup

small cleanup of go7007:

- prepare for urb->status conversion
- micro optimization
- use kzalloc
- fix free of memory in use in go7007_usb_disconnect
Signed-off-by: default avatarOliver Neukum <oneukum@suse.de>
Cc: Cohen <rcohen@snurgle.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8fca1cb3
...@@ -680,9 +680,10 @@ static void go7007_usb_readinterrupt_complete(struct urb *urb) ...@@ -680,9 +680,10 @@ static void go7007_usb_readinterrupt_complete(struct urb *urb)
{ {
struct go7007 *go = (struct go7007 *)urb->context; struct go7007 *go = (struct go7007 *)urb->context;
u16 *regs = (u16 *)urb->transfer_buffer; u16 *regs = (u16 *)urb->transfer_buffer;
int status = urb->status;
if (urb->status != 0) { if (status) {
if (urb->status != -ESHUTDOWN && if (status != -ESHUTDOWN &&
go->status != STATUS_SHUTDOWN) { go->status != STATUS_SHUTDOWN) {
printk(KERN_ERR printk(KERN_ERR
"go7007-usb: error in read interrupt: %d\n", "go7007-usb: error in read interrupt: %d\n",
...@@ -723,15 +724,14 @@ static int go7007_usb_read_interrupt(struct go7007 *go) ...@@ -723,15 +724,14 @@ static int go7007_usb_read_interrupt(struct go7007 *go)
static void go7007_usb_read_video_pipe_complete(struct urb *urb) static void go7007_usb_read_video_pipe_complete(struct urb *urb)
{ {
struct go7007 *go = (struct go7007 *)urb->context; struct go7007 *go = (struct go7007 *)urb->context;
int r; int r, status = urb-> status;
if (!go->streaming) { if (!go->streaming) {
wake_up_interruptible(&go->frame_waitq); wake_up_interruptible(&go->frame_waitq);
return; return;
} }
if (urb->status != 0) { if (status) {
printk(KERN_ERR "go7007-usb: error in video pipe: %d\n", printk(KERN_ERR "go7007-usb: error in video pipe: %d\n", status);
urb->status);
return; return;
} }
if (urb->actual_length != urb->transfer_buffer_length) { if (urb->actual_length != urb->transfer_buffer_length) {
...@@ -747,13 +747,12 @@ static void go7007_usb_read_video_pipe_complete(struct urb *urb) ...@@ -747,13 +747,12 @@ static void go7007_usb_read_video_pipe_complete(struct urb *urb)
static void go7007_usb_read_audio_pipe_complete(struct urb *urb) static void go7007_usb_read_audio_pipe_complete(struct urb *urb)
{ {
struct go7007 *go = (struct go7007 *)urb->context; struct go7007 *go = (struct go7007 *)urb->context;
int r; int r, status = urb->status;
if (!go->streaming) if (!go->streaming)
return; return;
if (urb->status != 0) { if (status) {
printk(KERN_ERR "go7007-usb: error in audio pipe: %d\n", printk(KERN_ERR "go7007-usb: error in audio pipe: %d\n", status);
urb->status);
return; return;
} }
if (urb->actual_length != urb->transfer_buffer_length) { if (urb->actual_length != urb->transfer_buffer_length) {
...@@ -794,7 +793,7 @@ static int go7007_usb_stream_start(struct go7007 *go) ...@@ -794,7 +793,7 @@ static int go7007_usb_stream_start(struct go7007 *go)
return 0; return 0;
audio_submit_failed: audio_submit_failed:
for (i = 0; i < 8; ++i) for (i = 0; i < 7; ++i)
usb_kill_urb(usb->audio_urbs[i]); usb_kill_urb(usb->audio_urbs[i]);
video_submit_failed: video_submit_failed:
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
...@@ -1019,10 +1018,9 @@ static int go7007_usb_probe(struct usb_interface *intf, ...@@ -1019,10 +1018,9 @@ static int go7007_usb_probe(struct usb_interface *intf,
return 0; return 0;
} }
usb = kmalloc(sizeof(struct go7007_usb), GFP_KERNEL); usb = kzalloc(sizeof(struct go7007_usb), GFP_KERNEL);
if (usb == NULL) if (usb == NULL)
return -ENOMEM; return -ENOMEM;
memset(usb, 0, sizeof(struct go7007_usb));
/* Allocate the URB and buffer for receiving incoming interrupts */ /* Allocate the URB and buffer for receiving incoming interrupts */
usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL); usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
...@@ -1227,6 +1225,7 @@ static void go7007_usb_disconnect(struct usb_interface *intf) ...@@ -1227,6 +1225,7 @@ static void go7007_usb_disconnect(struct usb_interface *intf)
{ {
struct go7007 *go = usb_get_intfdata(intf); struct go7007 *go = usb_get_intfdata(intf);
struct go7007_usb *usb = go->hpi_context; struct go7007_usb *usb = go->hpi_context;
struct urb *vurb, *aurb;
int i; int i;
go->status = STATUS_SHUTDOWN; go->status = STATUS_SHUTDOWN;
...@@ -1234,15 +1233,19 @@ static void go7007_usb_disconnect(struct usb_interface *intf) ...@@ -1234,15 +1233,19 @@ static void go7007_usb_disconnect(struct usb_interface *intf)
/* Free USB-related structs */ /* Free USB-related structs */
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
if (usb->video_urbs[i] != NULL) { vurb = usb->video_urbs[i];
if (usb->video_urbs[i]->transfer_buffer != NULL) if (vurb) {
kfree(usb->video_urbs[i]->transfer_buffer); usb_kill_urb(vurb);
usb_free_urb(usb->video_urbs[i]); if (vurb->transfer_buffer)
kfree(vurb->transfer_buffer);
usb_free_urb(vurb);
} }
if (usb->audio_urbs[i] != NULL) { aurb = usb->audio_urbs[i];
if (usb->audio_urbs[i]->transfer_buffer != NULL) if (aurb) {
kfree(usb->audio_urbs[i]->transfer_buffer); usb_kill_urb(aurb);
usb_free_urb(usb->audio_urbs[i]); if (aurb->transfer_buffer)
kfree(aurb->transfer_buffer);
usb_free_urb(aurb);
} }
} }
kfree(usb->intr_urb->transfer_buffer); kfree(usb->intr_urb->transfer_buffer);
......
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