diff options
author | Rolf Eike Beer <eike-kernel@sf-tec.de> | 2006-09-29 05:00:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 12:18:16 -0400 |
commit | 3e26a423e78c1bb1ebd29c49d4ae4ccbbacd861b (patch) | |
tree | 9ef489f3ec27e1d4325ac2a2ed9f0f0031e63ef7 /drivers/char/raw.c | |
parent | 416bc51292f977b43b010c6dd937522b90062390 (diff) |
[PATCH] Return better error codes if drivers/char/raw.c module init fails
Currently this module just returns 1 if anything on module init fails. Store
the error code of the different function calls and return their error on
problems.
Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
[ Fixed to not unregister twice on error ]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/raw.c')
-rw-r--r-- | drivers/char/raw.c | 19 |
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 = { | |||
288 | static int __init raw_init(void) | 288 | static 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 | ||
315 | error_region: | ||
316 | unregister_chrdev_region(dev, MAX_RAW_MINORS); | ||
313 | error: | 317 | error: |
314 | printk(KERN_ERR "error register raw device\n"); | 318 | return ret; |
315 | return 1; | ||
316 | } | 319 | } |
317 | 320 | ||
318 | static void __exit raw_exit(void) | 321 | static void __exit raw_exit(void) |