aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-17 08:23:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-25 07:10:55 -0400
commit59aea928d57f171453474a883f087e4fccb83e94 (patch)
tree6d2db66c770eee543c24155e1169f7595aaaa266
parent7118b4431b185a101e700ac79fa011000b2b71c3 (diff)
[media] go7007: don't continue if firmware can't be loaded
The go7007 driver would continue during probe if no firmware could be loaded. Without firmware the probe() should return an error, so do that. Also move the registration of devices to the end of the probe() sequence: once devices appear the full driver functionality should be available. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/staging/media/go7007/go7007-usb.c76
-rw-r--r--drivers/staging/media/go7007/saa7134-go7007.c34
2 files changed, 55 insertions, 55 deletions
diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c
index 08235069bde7..a734ead8fc64 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -930,7 +930,11 @@ static void go7007_usb_release(struct go7007 *go)
930 struct urb *vurb, *aurb; 930 struct urb *vurb, *aurb;
931 int i; 931 int i;
932 932
933 usb_kill_urb(usb->intr_urb); 933 if (usb->intr_urb) {
934 usb_kill_urb(usb->intr_urb);
935 kfree(usb->intr_urb->transfer_buffer);
936 usb_free_urb(usb->intr_urb);
937 }
934 938
935 /* Free USB-related structs */ 939 /* Free USB-related structs */
936 for (i = 0; i < 8; ++i) { 940 for (i = 0; i < 8; ++i) {
@@ -947,8 +951,6 @@ static void go7007_usb_release(struct go7007 *go)
947 usb_free_urb(aurb); 951 usb_free_urb(aurb);
948 } 952 }
949 } 953 }
950 kfree(usb->intr_urb->transfer_buffer);
951 usb_free_urb(usb->intr_urb);
952 954
953 kfree(go->hpi_context); 955 kfree(go->hpi_context);
954} 956}
@@ -1141,21 +1143,16 @@ static int go7007_usb_probe(struct usb_interface *intf,
1141 return 0; 1143 return 0;
1142 } 1144 }
1143 1145
1144 usb = kzalloc(sizeof(struct go7007_usb), GFP_KERNEL); 1146 go = go7007_alloc(&board->main_info, &intf->dev);
1145 if (usb == NULL) 1147 if (go == NULL)
1146 return -ENOMEM; 1148 return -ENOMEM;
1147 1149
1148 /* Allocate the URB and buffer for receiving incoming interrupts */ 1150 usb = kzalloc(sizeof(struct go7007_usb), GFP_KERNEL);
1149 usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL); 1151 if (usb == NULL) {
1150 if (usb->intr_urb == NULL) 1152 kfree(go);
1151 goto allocfail; 1153 return -ENOMEM;
1152 usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL); 1154 }
1153 if (usb->intr_urb->transfer_buffer == NULL)
1154 goto allocfail;
1155 1155
1156 go = go7007_alloc(&board->main_info, &intf->dev);
1157 if (go == NULL)
1158 goto allocfail;
1159 usb->board = board; 1156 usb->board = board;
1160 usb->usbdev = usbdev; 1157 usb->usbdev = usbdev;
1161 usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info)); 1158 usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info));
@@ -1166,6 +1163,15 @@ static int go7007_usb_probe(struct usb_interface *intf,
1166 else 1163 else
1167 go->hpi_ops = &go7007_usb_onboard_hpi_ops; 1164 go->hpi_ops = &go7007_usb_onboard_hpi_ops;
1168 go->hpi_context = usb; 1165 go->hpi_context = usb;
1166
1167 /* Allocate the URB and buffer for receiving incoming interrupts */
1168 usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1169 if (usb->intr_urb == NULL)
1170 goto allocfail;
1171 usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL);
1172 if (usb->intr_urb->transfer_buffer == NULL)
1173 goto allocfail;
1174
1169 if (go->board_id == GO7007_BOARDID_SENSORAY_2250) 1175 if (go->board_id == GO7007_BOARDID_SENSORAY_2250)
1170 usb_fill_bulk_urb(usb->intr_urb, usb->usbdev, 1176 usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
1171 usb_rcvbulkpipe(usb->usbdev, 4), 1177 usb_rcvbulkpipe(usb->usbdev, 4),
@@ -1181,7 +1187,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
1181 /* Boot the GO7007 */ 1187 /* Boot the GO7007 */
1182 if (go7007_boot_encoder(go, go->board_info->flags & 1188 if (go7007_boot_encoder(go, go->board_info->flags &
1183 GO7007_BOARD_USE_ONBOARD_I2C) < 0) 1189 GO7007_BOARD_USE_ONBOARD_I2C) < 0)
1184 goto initfail; 1190 goto allocfail;
1185 1191
1186 /* Register the EZ-USB I2C adapter, if we're using it */ 1192 /* Register the EZ-USB I2C adapter, if we're using it */
1187 if (board->flags & GO7007_USB_EZUSB_I2C) { 1193 if (board->flags & GO7007_USB_EZUSB_I2C) {
@@ -1193,7 +1199,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
1193 if (i2c_add_adapter(&go->i2c_adapter) < 0) { 1199 if (i2c_add_adapter(&go->i2c_adapter) < 0) {
1194 printk(KERN_ERR 1200 printk(KERN_ERR
1195 "go7007-usb: error: i2c_add_adapter failed\n"); 1201 "go7007-usb: error: i2c_add_adapter failed\n");
1196 goto initfail; 1202 goto allocfail;
1197 } 1203 }
1198 go->i2c_adapter_online = 1; 1204 go->i2c_adapter_online = 1;
1199 } 1205 }
@@ -1244,7 +1250,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
1244 /* Board strapping indicates tuner model */ 1250 /* Board strapping indicates tuner model */
1245 if (go7007_usb_vendor_request(go, 0x41, 0, 0, go->usb_buf, 3, 1) < 0) { 1251 if (go7007_usb_vendor_request(go, 0x41, 0, 0, go->usb_buf, 3, 1) < 0) {
1246 printk(KERN_ERR "go7007-usb: GPIO read failed!\n"); 1252 printk(KERN_ERR "go7007-usb: GPIO read failed!\n");
1247 goto initfail; 1253 goto allocfail;
1248 } 1254 }
1249 switch (go->usb_buf[0] >> 6) { 1255 switch (go->usb_buf[0] >> 6) {
1250 case 1: 1256 case 1:
@@ -1276,7 +1282,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
1276 if (go7007_usb_vendor_request(go, 0x40, 0x7f02, 0, 1282 if (go7007_usb_vendor_request(go, 0x40, 0x7f02, 0,
1277 NULL, 0, 0) < 0) { 1283 NULL, 0, 0) < 0) {
1278 printk(KERN_ERR "go7007-usb: GPIO write failed!\n"); 1284 printk(KERN_ERR "go7007-usb: GPIO write failed!\n");
1279 goto initfail; 1285 goto allocfail;
1280 } 1286 }
1281 } 1287 }
1282 1288
@@ -1290,11 +1296,6 @@ static int go7007_usb_probe(struct usb_interface *intf,
1290 "port will result in stream corruption, even " 1296 "port will result in stream corruption, even "
1291 "at low bitrates!\n"); 1297 "at low bitrates!\n");
1292 1298
1293 /* Do any final GO7007 initialization, then register the
1294 * V4L2 and ALSA interfaces */
1295 if (go7007_register_encoder(go, num_i2c_devs) < 0)
1296 goto initfail;
1297
1298 /* Allocate the URBs and buffers for receiving the video stream */ 1299 /* Allocate the URBs and buffers for receiving the video stream */
1299 if (board->flags & GO7007_USB_EZUSB) { 1300 if (board->flags & GO7007_USB_EZUSB) {
1300 v_urb_len = 1024; 1301 v_urb_len = 1024;
@@ -1306,46 +1307,45 @@ static int go7007_usb_probe(struct usb_interface *intf,
1306 for (i = 0; i < 8; ++i) { 1307 for (i = 0; i < 8; ++i) {
1307 usb->video_urbs[i] = usb_alloc_urb(0, GFP_KERNEL); 1308 usb->video_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
1308 if (usb->video_urbs[i] == NULL) 1309 if (usb->video_urbs[i] == NULL)
1309 goto initfail; 1310 goto allocfail;
1310 usb->video_urbs[i]->transfer_buffer = 1311 usb->video_urbs[i]->transfer_buffer =
1311 kmalloc(v_urb_len, GFP_KERNEL); 1312 kmalloc(v_urb_len, GFP_KERNEL);
1312 if (usb->video_urbs[i]->transfer_buffer == NULL) 1313 if (usb->video_urbs[i]->transfer_buffer == NULL)
1313 goto initfail; 1314 goto allocfail;
1314 usb_fill_bulk_urb(usb->video_urbs[i], usb->usbdev, video_pipe, 1315 usb_fill_bulk_urb(usb->video_urbs[i], usb->usbdev, video_pipe,
1315 usb->video_urbs[i]->transfer_buffer, v_urb_len, 1316 usb->video_urbs[i]->transfer_buffer, v_urb_len,
1316 go7007_usb_read_video_pipe_complete, go); 1317 go7007_usb_read_video_pipe_complete, go);
1317 } 1318 }
1318 1319
1319 /* Allocate the URBs and buffers for receiving the audio stream */ 1320 /* Allocate the URBs and buffers for receiving the audio stream */
1320 if ((board->flags & GO7007_USB_EZUSB) && go->audio_enabled) 1321 if ((board->flags & GO7007_USB_EZUSB) &&
1322 (board->flags & GO7007_BOARD_HAS_AUDIO)) {
1321 for (i = 0; i < 8; ++i) { 1323 for (i = 0; i < 8; ++i) {
1322 usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL); 1324 usb->audio_urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
1323 if (usb->audio_urbs[i] == NULL) 1325 if (usb->audio_urbs[i] == NULL)
1324 goto initfail; 1326 goto allocfail;
1325 usb->audio_urbs[i]->transfer_buffer = kmalloc(4096, 1327 usb->audio_urbs[i]->transfer_buffer = kmalloc(4096,
1326 GFP_KERNEL); 1328 GFP_KERNEL);
1327 if (usb->audio_urbs[i]->transfer_buffer == NULL) 1329 if (usb->audio_urbs[i]->transfer_buffer == NULL)
1328 goto initfail; 1330 goto allocfail;
1329 usb_fill_bulk_urb(usb->audio_urbs[i], usb->usbdev, 1331 usb_fill_bulk_urb(usb->audio_urbs[i], usb->usbdev,
1330 usb_rcvbulkpipe(usb->usbdev, 8), 1332 usb_rcvbulkpipe(usb->usbdev, 8),
1331 usb->audio_urbs[i]->transfer_buffer, 4096, 1333 usb->audio_urbs[i]->transfer_buffer, 4096,
1332 go7007_usb_read_audio_pipe_complete, go); 1334 go7007_usb_read_audio_pipe_complete, go);
1333 } 1335 }
1336 }
1334 1337
1338 /* Do any final GO7007 initialization, then register the
1339 * V4L2 and ALSA interfaces */
1340 if (go7007_register_encoder(go, num_i2c_devs) < 0)
1341 goto allocfail;
1335 1342
1336 go->status = STATUS_ONLINE; 1343 go->status = STATUS_ONLINE;
1337 return 0; 1344 return 0;
1338 1345
1339initfail:
1340 go->status = STATUS_SHUTDOWN;
1341 return 0;
1342
1343allocfail: 1346allocfail:
1344 if (usb->intr_urb) { 1347 go7007_usb_release(go);
1345 kfree(usb->intr_urb->transfer_buffer); 1348 kfree(go);
1346 usb_free_urb(usb->intr_urb);
1347 }
1348 kfree(usb);
1349 return -ENOMEM; 1349 return -ENOMEM;
1350} 1350}
1351 1351
diff --git a/drivers/staging/media/go7007/saa7134-go7007.c b/drivers/staging/media/go7007/saa7134-go7007.c
index 7ccbfe7784cf..d35d5c2ea1c3 100644
--- a/drivers/staging/media/go7007/saa7134-go7007.c
+++ b/drivers/staging/media/go7007/saa7134-go7007.c
@@ -454,9 +454,22 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
454 454
455 printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n"); 455 printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n");
456 456
457 go = go7007_alloc(&board_voyager, &dev->pci->dev);
458 if (go == NULL)
459 return -ENOMEM;
460
457 saa = kzalloc(sizeof(struct saa7134_go7007), GFP_KERNEL); 461 saa = kzalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
458 if (saa == NULL) 462 if (saa == NULL) {
463 kfree(go);
459 return -ENOMEM; 464 return -ENOMEM;
465 }
466
467 go->board_id = GO7007_BOARDID_PCI_VOYAGER;
468 snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
469 strncpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
470 go->hpi_ops = &saa7134_go7007_hpi_ops;
471 go->hpi_context = saa;
472 saa->dev = dev;
460 473
461 /* Init the subdevice interface */ 474 /* Init the subdevice interface */
462 sd = &saa->sd; 475 sd = &saa->sd;
@@ -472,25 +485,15 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
472 if (!saa->bottom) 485 if (!saa->bottom)
473 goto allocfail; 486 goto allocfail;
474 487
475 go = go7007_alloc(&board_voyager, &dev->pci->dev);
476 if (go == NULL)
477 goto allocfail;
478 go->board_id = GO7007_BOARDID_PCI_VOYAGER;
479 snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
480 strncpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
481 go->hpi_ops = &saa7134_go7007_hpi_ops;
482 go->hpi_context = saa;
483 saa->dev = dev;
484
485 /* Boot the GO7007 */ 488 /* Boot the GO7007 */
486 if (go7007_boot_encoder(go, go->board_info->flags & 489 if (go7007_boot_encoder(go, go->board_info->flags &
487 GO7007_BOARD_USE_ONBOARD_I2C) < 0) 490 GO7007_BOARD_USE_ONBOARD_I2C) < 0)
488 goto initfail; 491 goto allocfail;
489 492
490 /* Do any final GO7007 initialization, then register the 493 /* Do any final GO7007 initialization, then register the
491 * V4L2 and ALSA interfaces */ 494 * V4L2 and ALSA interfaces */
492 if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0) 495 if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0)
493 goto initfail; 496 goto allocfail;
494 497
495 /* Register the subdevice interface with the go7007 device */ 498 /* Register the subdevice interface with the go7007 device */
496 if (v4l2_device_register_subdev(&go->v4l2_dev, sd) < 0) 499 if (v4l2_device_register_subdev(&go->v4l2_dev, sd) < 0)
@@ -501,16 +504,13 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
501 go->status = STATUS_ONLINE; 504 go->status = STATUS_ONLINE;
502 return 0; 505 return 0;
503 506
504initfail:
505 go->status = STATUS_SHUTDOWN;
506 return 0;
507
508allocfail: 507allocfail:
509 if (saa->top) 508 if (saa->top)
510 free_page((unsigned long)saa->top); 509 free_page((unsigned long)saa->top);
511 if (saa->bottom) 510 if (saa->bottom)
512 free_page((unsigned long)saa->bottom); 511 free_page((unsigned long)saa->bottom);
513 kfree(saa); 512 kfree(saa);
513 kfree(go);
514 return -ENOMEM; 514 return -ENOMEM;
515} 515}
516 516