aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/raw.c')
-rw-r--r--drivers/char/raw.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 579868af4a54..c596a08c07b3 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -288,31 +288,34 @@ static struct cdev raw_cdev = {
288static int __init raw_init(void) 288static int __init raw_init(void)
289{ 289{
290 dev_t dev = MKDEV(RAW_MAJOR, 0); 290 dev_t dev = MKDEV(RAW_MAJOR, 0);
291 int ret;
291 292
292 if (register_chrdev_region(dev, MAX_RAW_MINORS, "raw")) 293 ret = register_chrdev_region(dev, MAX_RAW_MINORS, "raw");
294 if (ret)
293 goto error; 295 goto error;
294 296
295 cdev_init(&raw_cdev, &raw_fops); 297 cdev_init(&raw_cdev, &raw_fops);
296 if (cdev_add(&raw_cdev, dev, MAX_RAW_MINORS)) { 298 ret = cdev_add(&raw_cdev, dev, MAX_RAW_MINORS);
299 if (ret) {
297 kobject_put(&raw_cdev.kobj); 300 kobject_put(&raw_cdev.kobj);
298 unregister_chrdev_region(dev, MAX_RAW_MINORS); 301 goto error_region;
299 goto error;
300 } 302 }
301 303
302 raw_class = class_create(THIS_MODULE, "raw"); 304 raw_class = class_create(THIS_MODULE, "raw");
303 if (IS_ERR(raw_class)) { 305 if (IS_ERR(raw_class)) {
304 printk(KERN_ERR "Error creating raw class.\n"); 306 printk(KERN_ERR "Error creating raw class.\n");
305 cdev_del(&raw_cdev); 307 cdev_del(&raw_cdev);
306 unregister_chrdev_region(dev, MAX_RAW_MINORS); 308 ret = PTR_ERR(raw_class);
307 goto error; 309 goto error_region;
308 } 310 }
309 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 311 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
310 312
311 return 0; 313 return 0;
312 314
315error_region:
316 unregister_chrdev_region(dev, MAX_RAW_MINORS);
313error: 317error:
314 printk(KERN_ERR "error register raw device\n"); 318 return ret;
315 return 1;
316} 319}
317 320
318static void __exit raw_exit(void) 321static void __exit raw_exit(void)