diff options
author | Andrew Morton <akpm@osdl.org> | 2006-12-06 23:37:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:36 -0500 |
commit | 28ec24e23229ae3d333f8d7f0e6b31fa8ea7bf46 (patch) | |
tree | 92b1a54da4d5e4982540b7dffa9525f75005f92a | |
parent | 0d75565f1e8f098b80a34ccf70db450f60618ec8 (diff) |
[PATCH] driver/base/memory.c: handle errors properly
Do proper error-checking and propagation in drivers/base/memory.c, hence fix
__must_check warnings.
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/base/memory.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c6b7d9c4b651..74b96795d2f5 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); | |||
290 | 290 | ||
291 | static int block_size_init(void) | 291 | static int block_size_init(void) |
292 | { | 292 | { |
293 | sysfs_create_file(&memory_sysdev_class.kset.kobj, | 293 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, |
294 | &class_attr_block_size_bytes.attr); | 294 | &class_attr_block_size_bytes.attr); |
295 | return 0; | ||
296 | } | 295 | } |
297 | 296 | ||
298 | /* | 297 | /* |
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store); | |||
323 | 322 | ||
324 | static int memory_probe_init(void) | 323 | static int memory_probe_init(void) |
325 | { | 324 | { |
326 | sysfs_create_file(&memory_sysdev_class.kset.kobj, | 325 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, |
327 | &class_attr_probe.attr); | 326 | &class_attr_probe.attr); |
328 | return 0; | ||
329 | } | 327 | } |
330 | #else | 328 | #else |
331 | #define memory_probe_init(...) do {} while (0) | 329 | static inline int memory_probe_init(void) |
330 | { | ||
331 | return 0; | ||
332 | } | ||
332 | #endif | 333 | #endif |
333 | 334 | ||
334 | /* | 335 | /* |
@@ -431,9 +432,12 @@ int __init memory_dev_init(void) | |||
431 | { | 432 | { |
432 | unsigned int i; | 433 | unsigned int i; |
433 | int ret; | 434 | int ret; |
435 | int err; | ||
434 | 436 | ||
435 | memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; | 437 | memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; |
436 | ret = sysdev_class_register(&memory_sysdev_class); | 438 | ret = sysdev_class_register(&memory_sysdev_class); |
439 | if (ret) | ||
440 | goto out; | ||
437 | 441 | ||
438 | /* | 442 | /* |
439 | * Create entries for memory sections that were found | 443 | * Create entries for memory sections that were found |
@@ -442,11 +446,19 @@ int __init memory_dev_init(void) | |||
442 | for (i = 0; i < NR_MEM_SECTIONS; i++) { | 446 | for (i = 0; i < NR_MEM_SECTIONS; i++) { |
443 | if (!valid_section_nr(i)) | 447 | if (!valid_section_nr(i)) |
444 | continue; | 448 | continue; |
445 | add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); | 449 | err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); |
450 | if (!ret) | ||
451 | ret = err; | ||
446 | } | 452 | } |
447 | 453 | ||
448 | memory_probe_init(); | 454 | err = memory_probe_init(); |
449 | block_size_init(); | 455 | if (!ret) |
450 | 456 | ret = err; | |
457 | err = block_size_init(); | ||
458 | if (!ret) | ||
459 | ret = err; | ||
460 | out: | ||
461 | if (ret) | ||
462 | printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); | ||
451 | return ret; | 463 | return ret; |
452 | } | 464 | } |