struct urb *vurb, *aurb;
int i;
- usb_kill_urb(usb->intr_urb);
+ if (usb->intr_urb) {
+ usb_kill_urb(usb->intr_urb);
+ kfree(usb->intr_urb->transfer_buffer);
+ usb_free_urb(usb->intr_urb);
+ }
/* Free USB-related structs */
for (i = 0; i < 8; ++i) {
usb_free_urb(aurb);
}
}
- kfree(usb->intr_urb->transfer_buffer);
- usb_free_urb(usb->intr_urb);
kfree(go->hpi_context);
}
return 0;
}
- usb = kzalloc(sizeof(struct go7007_usb), GFP_KERNEL);
- if (usb == NULL)
+ go = go7007_alloc(&board->main_info, &intf->dev);
+ if (go == NULL)
return -ENOMEM;
- /* Allocate the URB and buffer for receiving incoming interrupts */
- usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (usb->intr_urb == NULL)
- goto allocfail;
- usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL);
- if (usb->intr_urb->transfer_buffer == NULL)
- goto allocfail;
+ usb = kzalloc(sizeof(struct go7007_usb), GFP_KERNEL);
+ if (usb == NULL) {
+ kfree(go);
+ return -ENOMEM;
+ }
- go = go7007_alloc(&board->main_info, &intf->dev);
- if (go == NULL)
- goto allocfail;
usb->board = board;
usb->usbdev = usbdev;
usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info));
else
go->hpi_ops = &go7007_usb_onboard_hpi_ops;
go->hpi_context = usb;
+
+ /* Allocate the URB and buffer for receiving incoming interrupts */
+ usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (usb->intr_urb == NULL)
+ goto allocfail;
+ usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL);
+ if (usb->intr_urb->transfer_buffer == NULL)
+ goto allocfail;
+
if (go->board_id == GO7007_BOARDID_SENSORAY_2250)
usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
usb_rcvbulkpipe(usb->usbdev, 4),
/* Boot the GO7007 */
if (go7007_boot_encoder(go, go->board_info->flags &
GO7007_BOARD_USE_ONBOARD_I2C) < 0)
- goto initfail;
+ goto allocfail;
/* Register the EZ-USB I2C adapter, if we're using it */
if (board->flags & GO7007_USB_EZUSB_I2C) {
if (i2c_add_adapter(&go->i2c_adapter) < 0) {
printk(KERN_ERR
"go7007-usb: error: i2c_add_adapter failed\n");
- goto initfail;
+ goto allocfail;
}
go->i2c_adapter_online = 1;
}
/* Board strapping indicates tuner model */
if (go7007_usb_vendor_request(go, 0x41, 0, 0, go->usb_buf, 3, 1) < 0) {
printk(KERN_ERR "go7007-usb: GPIO read failed!\n");
- goto initfail;
+ goto allocfail;
}
switch (go->usb_buf[0] >> 6) {
case 1:
if (go7007_usb_vendor_request(go, 0x40, 0x7f02, 0,
NULL, 0, 0) < 0) {
printk(KERN_ERR "go7007-usb: GPIO write failed!\n");
- goto initfail;
+ goto allocfail;
}
}
"port will result in stream corruption, even "
"at low bitrates!\n");
- /* Do any final GO7007 initialization, then register the
- * V4L2 and ALSA interfaces */
- if (go7007_register_encoder(go, num_i2c_devs) < 0)
- goto initfail;
-
/* Allocate the URBs and buffers for receiving the video stream */
if (board->flags & GO7007_USB_EZUSB) {
v_urb_len = 1024;
for (i = 0; i < 8; ++i) {
usb->video_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
if (usb->video_urbs[i] == NULL)
- goto initfail;
+ goto allocfail;
usb->video_urbs[i]->transfer_buffer =
kmalloc(v_urb_len, GFP_KERNEL);
if (usb->video_urbs[i]->transfer_buffer == NULL)
- goto initfail;
+ goto allocfail;
usb_fill_bulk_urb(usb->video_urbs[i], usb->usbdev, video_pipe,
usb->video_urbs[i]->transfer_buffer, v_urb_len,
go7007_usb_read_video_pipe_complete, go);
}
/* Allocate the URBs and buffers for receiving the audio stream */
- if ((board->flags & GO7007_USB_EZUSB) && go->audio_enabled)
+ if ((board->flags & GO7007_USB_EZUSB) &&
+ (board->flags & GO7007_BOARD_HAS_AUDIO)) {
for (i = 0; i < 8; ++i) {
usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
if (usb->audio_urbs[i] == NULL)
- goto initfail;
+ goto allocfail;
usb->audio_urbs[i]->transfer_buffer = kmalloc(4096,
GFP_KERNEL);
if (usb->audio_urbs[i]->transfer_buffer == NULL)
- goto initfail;
+ goto allocfail;
usb_fill_bulk_urb(usb->audio_urbs[i], usb->usbdev,
usb_rcvbulkpipe(usb->usbdev, 8),
usb->audio_urbs[i]->transfer_buffer, 4096,
go7007_usb_read_audio_pipe_complete, go);
}
+ }
+ /* Do any final GO7007 initialization, then register the
+ * V4L2 and ALSA interfaces */
+ if (go7007_register_encoder(go, num_i2c_devs) < 0)
+ goto allocfail;
go->status = STATUS_ONLINE;
return 0;
-initfail:
- go->status = STATUS_SHUTDOWN;
- return 0;
-
allocfail:
- if (usb->intr_urb) {
- kfree(usb->intr_urb->transfer_buffer);
- usb_free_urb(usb->intr_urb);
- }
- kfree(usb);
+ go7007_usb_release(go);
+ kfree(go);
return -ENOMEM;
}
printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n");
+ go = go7007_alloc(&board_voyager, &dev->pci->dev);
+ if (go == NULL)
+ return -ENOMEM;
+
saa = kzalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
- if (saa == NULL)
+ if (saa == NULL) {
+ kfree(go);
return -ENOMEM;
+ }
+
+ go->board_id = GO7007_BOARDID_PCI_VOYAGER;
+ snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
+ strncpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
+ go->hpi_ops = &saa7134_go7007_hpi_ops;
+ go->hpi_context = saa;
+ saa->dev = dev;
/* Init the subdevice interface */
sd = &saa->sd;
if (!saa->bottom)
goto allocfail;
- go = go7007_alloc(&board_voyager, &dev->pci->dev);
- if (go == NULL)
- goto allocfail;
- go->board_id = GO7007_BOARDID_PCI_VOYAGER;
- snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
- strncpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
- go->hpi_ops = &saa7134_go7007_hpi_ops;
- go->hpi_context = saa;
- saa->dev = dev;
-
/* Boot the GO7007 */
if (go7007_boot_encoder(go, go->board_info->flags &
GO7007_BOARD_USE_ONBOARD_I2C) < 0)
- goto initfail;
+ goto allocfail;
/* Do any final GO7007 initialization, then register the
* V4L2 and ALSA interfaces */
if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0)
- goto initfail;
+ goto allocfail;
/* Register the subdevice interface with the go7007 device */
if (v4l2_device_register_subdev(&go->v4l2_dev, sd) < 0)
go->status = STATUS_ONLINE;
return 0;
-initfail:
- go->status = STATUS_SHUTDOWN;
- return 0;
-
allocfail:
if (saa->top)
free_page((unsigned long)saa->top);
if (saa->bottom)
free_page((unsigned long)saa->bottom);
kfree(saa);
+ kfree(go);
return -ENOMEM;
}