aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-13 06:17:32 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-10-13 23:44:17 -0400
commitc12e3be0860652ed1e15c9442adcba44317211d1 (patch)
treebce864340c0f854b3b05339eaf2953147fe9baae /drivers/media/video/pwc
parent2444a2fca488fa8e362895a4ca9fdc51f497282a (diff)
V4L/DVB (4742): Drivers/media/video: handle sysfs errors
Signed-off-by: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pwc')
-rw-r--r--drivers/media/video/pwc/pwc-if.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index c77b85cf3d80..46c114830884 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1024,12 +1024,25 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, 1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status,
1025 NULL); 1025 NULL);
1026 1026
1027static void pwc_create_sysfs_files(struct video_device *vdev) 1027static int pwc_create_sysfs_files(struct video_device *vdev)
1028{ 1028{
1029 struct pwc_device *pdev = video_get_drvdata(vdev); 1029 struct pwc_device *pdev = video_get_drvdata(vdev);
1030 if (pdev->features & FEATURE_MOTOR_PANTILT) 1030 int rc;
1031 video_device_create_file(vdev, &class_device_attr_pan_tilt); 1031
1032 video_device_create_file(vdev, &class_device_attr_button); 1032 rc = video_device_create_file(vdev, &class_device_attr_button);
1033 if (rc)
1034 goto err;
1035 if (pdev->features & FEATURE_MOTOR_PANTILT) {
1036 rc = video_device_create_file(vdev,&class_device_attr_pan_tilt);
1037 if (rc) goto err_button;
1038 }
1039
1040 return 0;
1041
1042err_button:
1043 video_device_remove_file(vdev, &class_device_attr_button);
1044err:
1045 return rc;
1033} 1046}
1034 1047
1035static void pwc_remove_sysfs_files(struct video_device *vdev) 1048static void pwc_remove_sysfs_files(struct video_device *vdev)
@@ -1408,7 +1421,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1408 struct usb_device *udev = interface_to_usbdev(intf); 1421 struct usb_device *udev = interface_to_usbdev(intf);
1409 struct pwc_device *pdev = NULL; 1422 struct pwc_device *pdev = NULL;
1410 int vendor_id, product_id, type_id; 1423 int vendor_id, product_id, type_id;
1411 int i, hint; 1424 int i, hint, rc;
1412 int features = 0; 1425 int features = 0;
1413 int video_nr = -1; /* default: use next available device */ 1426 int video_nr = -1; /* default: use next available device */
1414 char serial_number[30], *name; 1427 char serial_number[30], *name;
@@ -1709,9 +1722,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1709 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); 1722 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
1710 if (i < 0) { 1723 if (i < 0) {
1711 PWC_ERROR("Failed to register as video device (%d).\n", i); 1724 PWC_ERROR("Failed to register as video device (%d).\n", i);
1712 video_device_release(pdev->vdev); /* Drip... drip... drip... */ 1725 rc = i;
1713 kfree(pdev); /* Oops, no memory leaks please */ 1726 goto err;
1714 return -EIO;
1715 } 1727 }
1716 else { 1728 else {
1717 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); 1729 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F);
@@ -1723,13 +1735,24 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1723 1735
1724 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); 1736 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
1725 usb_set_intfdata (intf, pdev); 1737 usb_set_intfdata (intf, pdev);
1726 pwc_create_sysfs_files(pdev->vdev); 1738 rc = pwc_create_sysfs_files(pdev->vdev);
1739 if (rc)
1740 goto err_unreg;
1727 1741
1728 /* Set the leds off */ 1742 /* Set the leds off */
1729 pwc_set_leds(pdev, 0, 0); 1743 pwc_set_leds(pdev, 0, 0);
1730 pwc_camera_power(pdev, 0); 1744 pwc_camera_power(pdev, 0);
1731 1745
1732 return 0; 1746 return 0;
1747
1748err_unreg:
1749 if (hint < MAX_DEV_HINTS)
1750 device_hint[hint].pdev = NULL;
1751 video_unregister_device(pdev->vdev);
1752err:
1753 video_device_release(pdev->vdev); /* Drip... drip... drip... */
1754 kfree(pdev); /* Oops, no memory leaks please */
1755 return rc;
1733} 1756}
1734 1757
1735/* The user janked out the cable... */ 1758/* The user janked out the cable... */