diff options
Diffstat (limited to 'arch/um/drivers/mconsole_kern.c')
-rw-r--r-- | arch/um/drivers/mconsole_kern.c | 36 |
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) | |||
419 | void mconsole_remove(struct mc_request *req) | 419 | void 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 |