diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-06-16 15:20:40 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-09-19 16:11:12 -0400 |
commit | 64da392ab08a88ad83f4c3f60283711ee090c9ef (patch) | |
tree | b9980fa27bb3dd9edb3563a8ccf75ea7ab79a091 /drivers/mtd | |
parent | aa3651e4625e21c2eb8a8e504d9bbc3c2a964be0 (diff) |
phram: cleanup error handling and associated messages
The error handling in the phram driver is pretty bad -- in many places,
errors are silently ignored or logged, but then still ignored in the
return value. So convert all of the code to pass back the correct return
value and log error messages properly (and using the new pr_fmt() helper).
If everything does go smoothly, rather than exit silently, dump a helpful
info message like pretty much every other MTD driver does.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Joern Engel <joern@logfs.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/devices/phram.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 088fbb7595b5..1696bbecaa7e 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -14,6 +14,9 @@ | |||
14 | * Example: | 14 | * Example: |
15 | * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi | 15 | * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi |
16 | */ | 16 | */ |
17 | |||
18 | #define pr_fmt(fmt) "phram: " fmt | ||
19 | |||
17 | #include <asm/io.h> | 20 | #include <asm/io.h> |
18 | #include <linux/init.h> | 21 | #include <linux/init.h> |
19 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
@@ -23,8 +26,6 @@ | |||
23 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
24 | #include <linux/mtd/mtd.h> | 27 | #include <linux/mtd/mtd.h> |
25 | 28 | ||
26 | #define ERROR(fmt, args...) printk(KERN_ERR "phram: " fmt , ## args) | ||
27 | |||
28 | struct phram_mtd_list { | 29 | struct phram_mtd_list { |
29 | struct mtd_info mtd; | 30 | struct mtd_info mtd; |
30 | struct list_head list; | 31 | struct list_head list; |
@@ -132,7 +133,7 @@ static int register_device(char *name, unsigned long start, unsigned long len) | |||
132 | ret = -EIO; | 133 | ret = -EIO; |
133 | new->mtd.priv = ioremap(start, len); | 134 | new->mtd.priv = ioremap(start, len); |
134 | if (!new->mtd.priv) { | 135 | if (!new->mtd.priv) { |
135 | ERROR("ioremap failed\n"); | 136 | pr_err("ioremap failed\n"); |
136 | goto out1; | 137 | goto out1; |
137 | } | 138 | } |
138 | 139 | ||
@@ -152,7 +153,7 @@ static int register_device(char *name, unsigned long start, unsigned long len) | |||
152 | 153 | ||
153 | ret = -EAGAIN; | 154 | ret = -EAGAIN; |
154 | if (add_mtd_device(&new->mtd)) { | 155 | if (add_mtd_device(&new->mtd)) { |
155 | ERROR("Failed to register new device\n"); | 156 | pr_err("Failed to register new device\n"); |
156 | goto out2; | 157 | goto out2; |
157 | } | 158 | } |
158 | 159 | ||
@@ -227,8 +228,8 @@ static inline void kill_final_newline(char *str) | |||
227 | 228 | ||
228 | 229 | ||
229 | #define parse_err(fmt, args...) do { \ | 230 | #define parse_err(fmt, args...) do { \ |
230 | ERROR(fmt , ## args); \ | 231 | pr_err(fmt , ## args); \ |
231 | return 0; \ | 232 | return 1; \ |
232 | } while (0) | 233 | } while (0) |
233 | 234 | ||
234 | static int phram_setup(const char *val, struct kernel_param *kp) | 235 | static int phram_setup(const char *val, struct kernel_param *kp) |
@@ -256,12 +257,8 @@ static int phram_setup(const char *val, struct kernel_param *kp) | |||
256 | parse_err("not enough arguments\n"); | 257 | parse_err("not enough arguments\n"); |
257 | 258 | ||
258 | ret = parse_name(&name, token[0]); | 259 | ret = parse_name(&name, token[0]); |
259 | if (ret == -ENOMEM) | ||
260 | parse_err("out of memory\n"); | ||
261 | if (ret == -ENOSPC) | ||
262 | parse_err("name too long\n"); | ||
263 | if (ret) | 260 | if (ret) |
264 | return 0; | 261 | return ret; |
265 | 262 | ||
266 | ret = parse_num32(&start, token[1]); | 263 | ret = parse_num32(&start, token[1]); |
267 | if (ret) { | 264 | if (ret) { |
@@ -275,9 +272,11 @@ static int phram_setup(const char *val, struct kernel_param *kp) | |||
275 | parse_err("illegal device length\n"); | 272 | parse_err("illegal device length\n"); |
276 | } | 273 | } |
277 | 274 | ||
278 | register_device(name, start, len); | 275 | ret = register_device(name, start, len); |
276 | if (!ret) | ||
277 | pr_info("%s device: %#x at %#x\n", name, len, start); | ||
279 | 278 | ||
280 | return 0; | 279 | return ret; |
281 | } | 280 | } |
282 | 281 | ||
283 | module_param_call(phram, phram_setup, NULL, NULL, 000); | 282 | module_param_call(phram, phram_setup, NULL, NULL, 000); |