diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-13 06:17:32 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-10-13 23:44:17 -0400 |
commit | c12e3be0860652ed1e15c9442adcba44317211d1 (patch) | |
tree | bce864340c0f854b3b05339eaf2953147fe9baae /drivers/media | |
parent | 2444a2fca488fa8e362895a4ca9fdc51f497282a (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')
-rw-r--r-- | drivers/media/video/et61x251/et61x251_core.c | 37 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 41 | ||||
-rw-r--r-- | drivers/media/video/sn9c102/sn9c102_core.c | 71 |
3 files changed, 117 insertions, 32 deletions
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index bc544cc7ccb8..f786ab11d2cd 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c | |||
@@ -973,16 +973,32 @@ static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, | |||
973 | et61x251_show_i2c_val, et61x251_store_i2c_val); | 973 | et61x251_show_i2c_val, et61x251_store_i2c_val); |
974 | 974 | ||
975 | 975 | ||
976 | static void et61x251_create_sysfs(struct et61x251_device* cam) | 976 | static int et61x251_create_sysfs(struct et61x251_device* cam) |
977 | { | 977 | { |
978 | struct video_device *v4ldev = cam->v4ldev; | 978 | struct video_device *v4ldev = cam->v4ldev; |
979 | int rc; | ||
979 | 980 | ||
980 | video_device_create_file(v4ldev, &class_device_attr_reg); | 981 | rc = video_device_create_file(v4ldev, &class_device_attr_reg); |
981 | video_device_create_file(v4ldev, &class_device_attr_val); | 982 | if (rc) goto err; |
983 | rc = video_device_create_file(v4ldev, &class_device_attr_val); | ||
984 | if (rc) goto err_reg; | ||
982 | if (cam->sensor.sysfs_ops) { | 985 | if (cam->sensor.sysfs_ops) { |
983 | video_device_create_file(v4ldev, &class_device_attr_i2c_reg); | 986 | rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg); |
984 | video_device_create_file(v4ldev, &class_device_attr_i2c_val); | 987 | if (rc) goto err_val; |
988 | rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val); | ||
989 | if (rc) goto err_i2c_reg; | ||
985 | } | 990 | } |
991 | |||
992 | return 0; | ||
993 | |||
994 | err_i2c_reg: | ||
995 | video_device_remove_file(v4ldev, &class_device_attr_i2c_reg); | ||
996 | err_val: | ||
997 | video_device_remove_file(v4ldev, &class_device_attr_val); | ||
998 | err_reg: | ||
999 | video_device_remove_file(v4ldev, &class_device_attr_reg); | ||
1000 | err: | ||
1001 | return rc; | ||
986 | } | 1002 | } |
987 | #endif /* CONFIG_VIDEO_ADV_DEBUG */ | 1003 | #endif /* CONFIG_VIDEO_ADV_DEBUG */ |
988 | 1004 | ||
@@ -2534,7 +2550,9 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2534 | dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; | 2550 | dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; |
2535 | 2551 | ||
2536 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 2552 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2537 | et61x251_create_sysfs(cam); | 2553 | err = et61x251_create_sysfs(cam); |
2554 | if (err) | ||
2555 | goto fail2; | ||
2538 | DBG(2, "Optional device control through 'sysfs' interface ready"); | 2556 | DBG(2, "Optional device control through 'sysfs' interface ready"); |
2539 | #endif | 2557 | #endif |
2540 | 2558 | ||
@@ -2544,6 +2562,13 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2544 | 2562 | ||
2545 | return 0; | 2563 | return 0; |
2546 | 2564 | ||
2565 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2566 | fail2: | ||
2567 | video_nr[dev_nr] = -1; | ||
2568 | dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; | ||
2569 | mutex_unlock(&cam->dev_mutex); | ||
2570 | video_unregister_device(cam->v4ldev); | ||
2571 | #endif | ||
2547 | fail: | 2572 | fail: |
2548 | if (cam) { | 2573 | if (cam) { |
2549 | kfree(cam->control_buffer); | 2574 | kfree(cam->control_buffer); |
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 | |||
1024 | static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, | 1024 | static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, |
1025 | NULL); | 1025 | NULL); |
1026 | 1026 | ||
1027 | static void pwc_create_sysfs_files(struct video_device *vdev) | 1027 | static 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 | |||
1042 | err_button: | ||
1043 | video_device_remove_file(vdev, &class_device_attr_button); | ||
1044 | err: | ||
1045 | return rc; | ||
1033 | } | 1046 | } |
1034 | 1047 | ||
1035 | static void pwc_remove_sysfs_files(struct video_device *vdev) | 1048 | static 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 | |||
1748 | err_unreg: | ||
1749 | if (hint < MAX_DEV_HINTS) | ||
1750 | device_hint[hint].pdev = NULL; | ||
1751 | video_unregister_device(pdev->vdev); | ||
1752 | err: | ||
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... */ |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 3e0ff8a78468..a4702d3c2aca 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
@@ -1240,23 +1240,53 @@ static CLASS_DEVICE_ATTR(frame_header, S_IRUGO, | |||
1240 | sn9c102_show_frame_header, NULL); | 1240 | sn9c102_show_frame_header, NULL); |
1241 | 1241 | ||
1242 | 1242 | ||
1243 | static void sn9c102_create_sysfs(struct sn9c102_device* cam) | 1243 | static int sn9c102_create_sysfs(struct sn9c102_device* cam) |
1244 | { | 1244 | { |
1245 | struct video_device *v4ldev = cam->v4ldev; | 1245 | struct video_device *v4ldev = cam->v4ldev; |
1246 | int rc; | ||
1247 | |||
1248 | rc = video_device_create_file(v4ldev, &class_device_attr_reg); | ||
1249 | if (rc) goto err; | ||
1250 | rc = video_device_create_file(v4ldev, &class_device_attr_val); | ||
1251 | if (rc) goto err_reg; | ||
1252 | rc = video_device_create_file(v4ldev, &class_device_attr_frame_header); | ||
1253 | if (rc) goto err_val; | ||
1246 | 1254 | ||
1247 | video_device_create_file(v4ldev, &class_device_attr_reg); | ||
1248 | video_device_create_file(v4ldev, &class_device_attr_val); | ||
1249 | video_device_create_file(v4ldev, &class_device_attr_frame_header); | ||
1250 | if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) | ||
1251 | video_device_create_file(v4ldev, &class_device_attr_green); | ||
1252 | else if (cam->bridge == BRIDGE_SN9C103) { | ||
1253 | video_device_create_file(v4ldev, &class_device_attr_blue); | ||
1254 | video_device_create_file(v4ldev, &class_device_attr_red); | ||
1255 | } | ||
1256 | if (cam->sensor.sysfs_ops) { | 1255 | if (cam->sensor.sysfs_ops) { |
1257 | video_device_create_file(v4ldev, &class_device_attr_i2c_reg); | 1256 | rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg); |
1258 | video_device_create_file(v4ldev, &class_device_attr_i2c_val); | 1257 | if (rc) goto err_frhead; |
1258 | rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val); | ||
1259 | if (rc) goto err_i2c_reg; | ||
1260 | } | ||
1261 | |||
1262 | if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) { | ||
1263 | rc = video_device_create_file(v4ldev, &class_device_attr_green); | ||
1264 | if (rc) goto err_i2c_val; | ||
1265 | } else if (cam->bridge == BRIDGE_SN9C103) { | ||
1266 | rc = video_device_create_file(v4ldev, &class_device_attr_blue); | ||
1267 | if (rc) goto err_i2c_val; | ||
1268 | rc = video_device_create_file(v4ldev, &class_device_attr_red); | ||
1269 | if (rc) goto err_blue; | ||
1259 | } | 1270 | } |
1271 | |||
1272 | return 0; | ||
1273 | |||
1274 | err_blue: | ||
1275 | video_device_remove_file(v4ldev, &class_device_attr_blue); | ||
1276 | err_i2c_val: | ||
1277 | if (cam->sensor.sysfs_ops) | ||
1278 | video_device_remove_file(v4ldev, &class_device_attr_i2c_val); | ||
1279 | err_i2c_reg: | ||
1280 | if (cam->sensor.sysfs_ops) | ||
1281 | video_device_remove_file(v4ldev, &class_device_attr_i2c_reg); | ||
1282 | err_frhead: | ||
1283 | video_device_remove_file(v4ldev, &class_device_attr_frame_header); | ||
1284 | err_val: | ||
1285 | video_device_remove_file(v4ldev, &class_device_attr_val); | ||
1286 | err_reg: | ||
1287 | video_device_remove_file(v4ldev, &class_device_attr_reg); | ||
1288 | err: | ||
1289 | return rc; | ||
1260 | } | 1290 | } |
1261 | #endif /* CONFIG_VIDEO_ADV_DEBUG */ | 1291 | #endif /* CONFIG_VIDEO_ADV_DEBUG */ |
1262 | 1292 | ||
@@ -2809,10 +2839,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2809 | DBG(1, "V4L2 device registration failed"); | 2839 | DBG(1, "V4L2 device registration failed"); |
2810 | if (err == -ENFILE && video_nr[dev_nr] == -1) | 2840 | if (err == -ENFILE && video_nr[dev_nr] == -1) |
2811 | DBG(1, "Free /dev/videoX node not found"); | 2841 | DBG(1, "Free /dev/videoX node not found"); |
2812 | video_nr[dev_nr] = -1; | 2842 | goto fail2; |
2813 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; | ||
2814 | mutex_unlock(&cam->dev_mutex); | ||
2815 | goto fail; | ||
2816 | } | 2843 | } |
2817 | 2844 | ||
2818 | DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); | 2845 | DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); |
@@ -2823,7 +2850,9 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2823 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; | 2850 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; |
2824 | 2851 | ||
2825 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 2852 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2826 | sn9c102_create_sysfs(cam); | 2853 | err = sn9c102_create_sysfs(cam); |
2854 | if (err) | ||
2855 | goto fail3; | ||
2827 | DBG(2, "Optional device control through 'sysfs' interface ready"); | 2856 | DBG(2, "Optional device control through 'sysfs' interface ready"); |
2828 | #endif | 2857 | #endif |
2829 | 2858 | ||
@@ -2833,6 +2862,14 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2833 | 2862 | ||
2834 | return 0; | 2863 | return 0; |
2835 | 2864 | ||
2865 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2866 | fail3: | ||
2867 | video_unregister_device(cam->v4ldev); | ||
2868 | #endif | ||
2869 | fail2: | ||
2870 | video_nr[dev_nr] = -1; | ||
2871 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; | ||
2872 | mutex_unlock(&cam->dev_mutex); | ||
2836 | fail: | 2873 | fail: |
2837 | if (cam) { | 2874 | if (cam) { |
2838 | kfree(cam->control_buffer); | 2875 | kfree(cam->control_buffer); |