aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sn9c102
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/sn9c102
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/sn9c102')
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c71
1 files changed, 54 insertions, 17 deletions
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
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static 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
1274err_blue:
1275 video_device_remove_file(v4ldev, &class_device_attr_blue);
1276err_i2c_val:
1277 if (cam->sensor.sysfs_ops)
1278 video_device_remove_file(v4ldev, &class_device_attr_i2c_val);
1279err_i2c_reg:
1280 if (cam->sensor.sysfs_ops)
1281 video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
1282err_frhead:
1283 video_device_remove_file(v4ldev, &class_device_attr_frame_header);
1284err_val:
1285 video_device_remove_file(v4ldev, &class_device_attr_val);
1286err_reg:
1287 video_device_remove_file(v4ldev, &class_device_attr_reg);
1288err:
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
2866fail3:
2867 video_unregister_device(cam->v4ldev);
2868#endif
2869fail2:
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);
2836fail: 2873fail:
2837 if (cam) { 2874 if (cam) {
2838 kfree(cam->control_buffer); 2875 kfree(cam->control_buffer);