aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/mconsole_kern.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-02-10 01:43:53 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 10:51:21 -0800
commitf28169d2000177e8b72ccc6d72887be779dceca8 (patch)
tree0ef842014c67d8a136cc26c99113b69e2ede87ea /arch/um/drivers/mconsole_kern.c
parentd79a580936396bbcd2f4fae2c6215f9cf81e3c0d (diff)
downloadlinux-f28169d2000177e8b72ccc6d72887be779dceca8.tar.gz
[PATCH] uml: return hotplug errors to host
I noticed that errors happening while hotplugging devices from the host were never returned back to the mconsole client. In some cases, success was returned instead of even an information-free error. This patch cleans that up by having the low-level configuration code pass back an error string along with an error code. At the top level, which knows whether it is early boot time or responding to an mconsole request, the string is printk'd or returned to the mconsole client. There are also whitespace and trivial code cleanups in the surrounding code. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/mconsole_kern.c')
-rw-r--r--arch/um/drivers/mconsole_kern.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 96f0189327af58..832d5c766ca88b 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -371,14 +371,16 @@ static unsigned long long unplugged_pages_count = 0;
static struct list_head unplugged_pages = LIST_HEAD_INIT(unplugged_pages);
static int unplug_index = UNPLUGGED_PER_PAGE;
-static int mem_config(char *str)
+static int mem_config(char *str, char **error_out)
{
unsigned long long diff;
int err = -EINVAL, i, add;
char *ret;
- if(str[0] != '=')
+ if(str[0] != '='){
+ *error_out = "Expected '=' after 'mem'";
goto out;
+ }
str++;
if(str[0] == '-')
@@ -386,12 +388,17 @@ static int mem_config(char *str)
else if(str[0] == '+'){
add = 1;
}
- else goto out;
+ else {
+ *error_out = "Expected increment to start with '-' or '+'";
+ goto out;
+ }
str++;
diff = memparse(str, &ret);
- if(*ret != '\0')
+ if(*ret != '\0'){
+ *error_out = "Failed to parse memory increment";
goto out;
+ }
diff /= PAGE_SIZE;
@@ -435,11 +442,14 @@ static int mem_config(char *str)
unplugged = list_entry(entry,
struct unplugged_pages,
list);
- unplugged->pages[unplug_index++] = addr;
err = os_drop_memory(addr, PAGE_SIZE);
- if(err)
+ if(err){
printk("Failed to release memory - "
"errno = %d\n", err);
+ *error_out = "Failed to release memory";
+ goto out;
+ }
+ unplugged->pages[unplug_index++] = addr;
}
unplugged_pages_count++;
@@ -470,8 +480,9 @@ static int mem_id(char **str, int *start_out, int *end_out)
return 0;
}
-static int mem_remove(int n)
+static int mem_remove(int n, char **error_out)
{
+ *error_out = "Memory doesn't support the remove operation";
return -EBUSY;
}
@@ -542,7 +553,7 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
void mconsole_config(struct mc_request *req)
{
struct mc_device *dev;
- char *ptr = req->request.data, *name;
+ char *ptr = req->request.data, *name, *error_string = "";
int err;
ptr += strlen("config");
@@ -559,8 +570,8 @@ void mconsole_config(struct mc_request *req)
ptr++;
if(*ptr == '='){
- err = (*dev->config)(name);
- mconsole_reply(req, "", err, 0);
+ err = (*dev->config)(name, &error_string);
+ mconsole_reply(req, error_string, err, 0);
}
else mconsole_get_config(dev->get_config, req, name);
}
@@ -595,13 +606,16 @@ void mconsole_remove(struct mc_request *req)
goto out;
}
- err = (*dev->remove)(n);
+ err_msg = NULL;
+ err = (*dev->remove)(n, &err_msg);
switch(err){
case -ENODEV:
- err_msg = "Device doesn't exist";
+ if(err_msg == NULL)
+ err_msg = "Device doesn't exist";
break;
case -EBUSY:
- err_msg = "Device is currently open";
+ if(err_msg == NULL)
+ err_msg = "Device is currently open";
break;
default:
break;