diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-02-10 04:43:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 13:51:21 -0500 |
commit | f28169d2000177e8b72ccc6d72887be779dceca8 (patch) | |
tree | 0ef842014c67d8a136cc26c99113b69e2ede87ea /arch/um/drivers/mconsole_kern.c | |
parent | d79a580936396bbcd2f4fae2c6215f9cf81e3c0d (diff) |
[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.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 96f0189327af..832d5c766ca8 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; | |||
371 | static struct list_head unplugged_pages = LIST_HEAD_INIT(unplugged_pages); | 371 | static struct list_head unplugged_pages = LIST_HEAD_INIT(unplugged_pages); |
372 | static int unplug_index = UNPLUGGED_PER_PAGE; | 372 | static int unplug_index = UNPLUGGED_PER_PAGE; |
373 | 373 | ||
374 | static int mem_config(char *str) | 374 | static int mem_config(char *str, char **error_out) |
375 | { | 375 | { |
376 | unsigned long long diff; | 376 | unsigned long long diff; |
377 | int err = -EINVAL, i, add; | 377 | int err = -EINVAL, i, add; |
378 | char *ret; | 378 | char *ret; |
379 | 379 | ||
380 | if(str[0] != '=') | 380 | if(str[0] != '='){ |
381 | *error_out = "Expected '=' after 'mem'"; | ||
381 | goto out; | 382 | goto out; |
383 | } | ||
382 | 384 | ||
383 | str++; | 385 | str++; |
384 | if(str[0] == '-') | 386 | if(str[0] == '-') |
@@ -386,12 +388,17 @@ static int mem_config(char *str) | |||
386 | else if(str[0] == '+'){ | 388 | else if(str[0] == '+'){ |
387 | add = 1; | 389 | add = 1; |
388 | } | 390 | } |
389 | else goto out; | 391 | else { |
392 | *error_out = "Expected increment to start with '-' or '+'"; | ||
393 | goto out; | ||
394 | } | ||
390 | 395 | ||
391 | str++; | 396 | str++; |
392 | diff = memparse(str, &ret); | 397 | diff = memparse(str, &ret); |
393 | if(*ret != '\0') | 398 | if(*ret != '\0'){ |
399 | *error_out = "Failed to parse memory increment"; | ||
394 | goto out; | 400 | goto out; |
401 | } | ||
395 | 402 | ||
396 | diff /= PAGE_SIZE; | 403 | diff /= PAGE_SIZE; |
397 | 404 | ||
@@ -435,11 +442,14 @@ static int mem_config(char *str) | |||
435 | unplugged = list_entry(entry, | 442 | unplugged = list_entry(entry, |
436 | struct unplugged_pages, | 443 | struct unplugged_pages, |
437 | list); | 444 | list); |
438 | unplugged->pages[unplug_index++] = addr; | ||
439 | err = os_drop_memory(addr, PAGE_SIZE); | 445 | err = os_drop_memory(addr, PAGE_SIZE); |
440 | if(err) | 446 | if(err){ |
441 | printk("Failed to release memory - " | 447 | printk("Failed to release memory - " |
442 | "errno = %d\n", err); | 448 | "errno = %d\n", err); |
449 | *error_out = "Failed to release memory"; | ||
450 | goto out; | ||
451 | } | ||
452 | unplugged->pages[unplug_index++] = addr; | ||
443 | } | 453 | } |
444 | 454 | ||
445 | unplugged_pages_count++; | 455 | unplugged_pages_count++; |
@@ -470,8 +480,9 @@ static int mem_id(char **str, int *start_out, int *end_out) | |||
470 | return 0; | 480 | return 0; |
471 | } | 481 | } |
472 | 482 | ||
473 | static int mem_remove(int n) | 483 | static int mem_remove(int n, char **error_out) |
474 | { | 484 | { |
485 | *error_out = "Memory doesn't support the remove operation"; | ||
475 | return -EBUSY; | 486 | return -EBUSY; |
476 | } | 487 | } |
477 | 488 | ||
@@ -542,7 +553,7 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int, | |||
542 | void mconsole_config(struct mc_request *req) | 553 | void mconsole_config(struct mc_request *req) |
543 | { | 554 | { |
544 | struct mc_device *dev; | 555 | struct mc_device *dev; |
545 | char *ptr = req->request.data, *name; | 556 | char *ptr = req->request.data, *name, *error_string = ""; |
546 | int err; | 557 | int err; |
547 | 558 | ||
548 | ptr += strlen("config"); | 559 | ptr += strlen("config"); |
@@ -559,8 +570,8 @@ void mconsole_config(struct mc_request *req) | |||
559 | ptr++; | 570 | ptr++; |
560 | 571 | ||
561 | if(*ptr == '='){ | 572 | if(*ptr == '='){ |
562 | err = (*dev->config)(name); | 573 | err = (*dev->config)(name, &error_string); |
563 | mconsole_reply(req, "", err, 0); | 574 | mconsole_reply(req, error_string, err, 0); |
564 | } | 575 | } |
565 | else mconsole_get_config(dev->get_config, req, name); | 576 | else mconsole_get_config(dev->get_config, req, name); |
566 | } | 577 | } |
@@ -595,13 +606,16 @@ void mconsole_remove(struct mc_request *req) | |||
595 | goto out; | 606 | goto out; |
596 | } | 607 | } |
597 | 608 | ||
598 | err = (*dev->remove)(n); | 609 | err_msg = NULL; |
610 | err = (*dev->remove)(n, &err_msg); | ||
599 | switch(err){ | 611 | switch(err){ |
600 | case -ENODEV: | 612 | case -ENODEV: |
601 | err_msg = "Device doesn't exist"; | 613 | if(err_msg == NULL) |
614 | err_msg = "Device doesn't exist"; | ||
602 | break; | 615 | break; |
603 | case -EBUSY: | 616 | case -EBUSY: |
604 | err_msg = "Device is currently open"; | 617 | if(err_msg == NULL) |
618 | err_msg = "Device is currently open"; | ||
605 | break; | 619 | break; |
606 | default: | 620 | default: |
607 | break; | 621 | break; |