aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/mconsole_kern.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2005-06-25 17:55:25 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 19:24:36 -0400
commit29d56cfe3ca599ddc3ae9156e7e469c044d97b96 (patch)
tree7790477f5b138c249725fe8ecf9dc07794e9d1eb /arch/um/drivers/mconsole_kern.c
parentfc47a0d18a1994b4a18d2235fcde1b75dfa72552 (diff)
[PATCH] uml: hot-unplug code cleanup
Clean up the hot-unplugging code. There is now an id procedure which is called to figure out what device we're talking to. The error messages from that are now done from mconsole_remove instead of the driver. remove is now called with the device number, after it has been checked, so doesn't need to do sanity checking on it. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/drivers/mconsole_kern.c')
-rw-r--r--arch/um/drivers/mconsole_kern.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index d7c7adcc0a67..404de41a4f67 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -419,8 +419,9 @@ void mconsole_config(struct mc_request *req)
419void mconsole_remove(struct mc_request *req) 419void mconsole_remove(struct mc_request *req)
420{ 420{
421 struct mc_device *dev; 421 struct mc_device *dev;
422 char *ptr = req->request.data; 422 char *ptr = req->request.data, *err_msg = "";
423 int err; 423 char error[256];
424 int err, start, end, n;
424 425
425 ptr += strlen("remove"); 426 ptr += strlen("remove");
426 while(isspace(*ptr)) ptr++; 427 while(isspace(*ptr)) ptr++;
@@ -429,8 +430,35 @@ void mconsole_remove(struct mc_request *req)
429 mconsole_reply(req, "Bad remove option", 1, 0); 430 mconsole_reply(req, "Bad remove option", 1, 0);
430 return; 431 return;
431 } 432 }
432 err = (*dev->remove)(&ptr[strlen(dev->name)]); 433
433 mconsole_reply(req, "", err, 0); 434 ptr = &ptr[strlen(dev->name)];
435
436 err = 1;
437 n = (*dev->id)(&ptr, &start, &end);
438 if(n < 0){
439 err_msg = "Couldn't parse device number";
440 goto out;
441 }
442 else if((n < start) || (n > end)){
443 sprintf(error, "Invalid device number - must be between "
444 "%d and %d", start, end);
445 err_msg = error;
446 goto out;
447 }
448
449 err = (*dev->remove)(n);
450 switch(err){
451 case -ENODEV:
452 err_msg = "Device doesn't exist";
453 break;
454 case -EBUSY:
455 err_msg = "Device is currently open";
456 break;
457 default:
458 break;
459 }
460 out:
461 mconsole_reply(req, err_msg, err, 0);
434} 462}
435 463
436#ifdef CONFIG_MAGIC_SYSRQ 464#ifdef CONFIG_MAGIC_SYSRQ