summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/videodev.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2006-07-25 09:31:42 -0300
committerTrent Piepho <xyzzy@speakeasy.org>2006-07-25 09:31:42 -0300
commiteae539a732ce1383b14bea7a37e7204cba2805fc (patch)
tree81f68b1edc062bccb01c86c0ba1027c9b807343d /linux/drivers/media/video/videodev.c
parent6b10723421c5d71d041d1dc54cc19d782a290638 (diff)
downloadmediapointer-dvb-s2-eae539a732ce1383b14bea7a37e7204cba2805fc.tar.gz
mediapointer-dvb-s2-eae539a732ce1383b14bea7a37e7204cba2805fc.tar.bz2
videodev: Handle class_device related errors
From: Trent Piepho <xyzzy@speakeasy.org> Add proper error checking and roll-back for failure of class_device_create_file() in videodev.c. Print error messages and unroll partially created sysfs entries. Also, failure of class_device_register() in video_register_device() is handled correctly. It was failing to de-allocate the minor number. This must be done in video_register_device(), since the caller has no way of knowing if failure occurred before or after the class device was registered. Also added an error message if video_register_device() is called with an unknown type, which should never happen. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'linux/drivers/media/video/videodev.c')
-rw-r--r--linux/drivers/media/video/videodev.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c
index a4b2bfd28..d01b2a740 100644
--- a/linux/drivers/media/video/videodev.c
+++ b/linux/drivers/media/video/videodev.c
@@ -1557,6 +1557,8 @@ int video_register_device(struct video_device *vfd, int type, int nr)
name_base = "radio";
break;
default:
+ printk(KERN_ERR "%s called with unknown type: %d\n",
+ __FUNCTION__, type);
return -1;
}
@@ -1597,18 +1599,20 @@ int video_register_device(struct video_device *vfd, int type, int nr)
if (ret) {
printk(KERN_ERR "%s: class_device_register failed\n",
__FUNCTION__);
- return ret;
+ goto fail_minor;
}
- ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
- if (ret < 0) {
- printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret);
- return ret;
+ ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
+ __FUNCTION__);
+ goto fail_classdev;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- ret = class_device_create_file(&vfd->class_dev, &class_device_attr_dev);
- if (ret < 0) {
- printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret);
- return ret;
+ ret = class_device_create_file(&vfd->class_dev, &class_device_attr_dev);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: class_device_create_file 'dev' failed\n",
+ __FUNCTION__);
+ goto fail_classdev;
}
#endif
@@ -1620,6 +1624,15 @@ int video_register_device(struct video_device *vfd, int type, int nr)
"http://lwn.net/Articles/36850/\n", vfd->name);
#endif
return 0;
+
+fail_classdev:
+ class_device_unregister(&vfd->class_dev);
+fail_minor:
+ mutex_lock(&videodev_lock);
+ video_device[vfd->minor] = NULL;
+ vfd->minor = -1;
+ mutex_unlock(&videodev_lock);
+ return ret;
}
/**