Commit 64da392a authored by Mike Frysinger's avatar Mike Frysinger Committed by David Woodhouse

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: default avatarMike Frysinger <vapier@gentoo.org>
Acked-by: default avatarJoern Engel <joern@logfs.org>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent aa3651e4
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
* Example: * Example:
* phram=swap,64Mi,128Mi phram=test,900Mi,1Mi * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi
*/ */
#define pr_fmt(fmt) "phram: " fmt
#include <asm/io.h> #include <asm/io.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -23,8 +26,6 @@ ...@@ -23,8 +26,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#define ERROR(fmt, args...) printk(KERN_ERR "phram: " fmt , ## args)
struct phram_mtd_list { struct phram_mtd_list {
struct mtd_info mtd; struct mtd_info mtd;
struct list_head list; struct list_head list;
...@@ -132,7 +133,7 @@ static int register_device(char *name, unsigned long start, unsigned long len) ...@@ -132,7 +133,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
ret = -EIO; ret = -EIO;
new->mtd.priv = ioremap(start, len); new->mtd.priv = ioremap(start, len);
if (!new->mtd.priv) { if (!new->mtd.priv) {
ERROR("ioremap failed\n"); pr_err("ioremap failed\n");
goto out1; goto out1;
} }
...@@ -152,7 +153,7 @@ static int register_device(char *name, unsigned long start, unsigned long len) ...@@ -152,7 +153,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
ret = -EAGAIN; ret = -EAGAIN;
if (add_mtd_device(&new->mtd)) { if (add_mtd_device(&new->mtd)) {
ERROR("Failed to register new device\n"); pr_err("Failed to register new device\n");
goto out2; goto out2;
} }
...@@ -227,8 +228,8 @@ static inline void kill_final_newline(char *str) ...@@ -227,8 +228,8 @@ static inline void kill_final_newline(char *str)
#define parse_err(fmt, args...) do { \ #define parse_err(fmt, args...) do { \
ERROR(fmt , ## args); \ pr_err(fmt , ## args); \
return 0; \ return 1; \
} while (0) } while (0)
static int phram_setup(const char *val, struct kernel_param *kp) 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,12 +257,8 @@ static int phram_setup(const char *val, struct kernel_param *kp)
parse_err("not enough arguments\n"); parse_err("not enough arguments\n");
ret = parse_name(&name, token[0]); ret = parse_name(&name, token[0]);
if (ret == -ENOMEM)
parse_err("out of memory\n");
if (ret == -ENOSPC)
parse_err("name too long\n");
if (ret) if (ret)
return 0; return ret;
ret = parse_num32(&start, token[1]); ret = parse_num32(&start, token[1]);
if (ret) { if (ret) {
...@@ -275,9 +272,11 @@ static int phram_setup(const char *val, struct kernel_param *kp) ...@@ -275,9 +272,11 @@ static int phram_setup(const char *val, struct kernel_param *kp)
parse_err("illegal device length\n"); parse_err("illegal device length\n");
} }
register_device(name, start, len); ret = register_device(name, start, len);
if (!ret)
pr_info("%s device: %#x at %#x\n", name, len, start);
return 0; return ret;
} }
module_param_call(phram, phram_setup, NULL, NULL, 000); module_param_call(phram, phram_setup, NULL, NULL, 000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment