diff options
author | Jeff Dike <jdike@addtoit.com> | 2005-06-25 17:55:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-25 19:24:36 -0400 |
commit | 29d56cfe3ca599ddc3ae9156e7e469c044d97b96 (patch) | |
tree | 7790477f5b138c249725fe8ecf9dc07794e9d1eb /arch/um/drivers/net_kern.c | |
parent | fc47a0d18a1994b4a18d2235fcde1b75dfa72552 (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/net_kern.c')
-rw-r--r-- | arch/um/drivers/net_kern.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 5388a7428691..1495007bf6c0 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -612,25 +612,35 @@ static int net_config(char *str) | |||
612 | return(err); | 612 | return(err); |
613 | } | 613 | } |
614 | 614 | ||
615 | static int net_remove(char *str) | 615 | static int net_id(char **str, int *start_out, int *end_out) |
616 | { | ||
617 | char *end; | ||
618 | int n; | ||
619 | |||
620 | n = simple_strtoul(*str, &end, 0); | ||
621 | if((*end != '\0') || (end == *str)) | ||
622 | return -1; | ||
623 | |||
624 | *start_out = n; | ||
625 | *end_out = n; | ||
626 | *str = end; | ||
627 | return n; | ||
628 | } | ||
629 | |||
630 | static int net_remove(int n) | ||
616 | { | 631 | { |
617 | struct uml_net *device; | 632 | struct uml_net *device; |
618 | struct net_device *dev; | 633 | struct net_device *dev; |
619 | struct uml_net_private *lp; | 634 | struct uml_net_private *lp; |
620 | char *end; | ||
621 | int n; | ||
622 | |||
623 | n = simple_strtoul(str, &end, 0); | ||
624 | if((*end != '\0') || (end == str)) | ||
625 | return(-1); | ||
626 | 635 | ||
627 | device = find_device(n); | 636 | device = find_device(n); |
628 | if(device == NULL) | 637 | if(device == NULL) |
629 | return(0); | 638 | return -ENODEV; |
630 | 639 | ||
631 | dev = device->dev; | 640 | dev = device->dev; |
632 | lp = dev->priv; | 641 | lp = dev->priv; |
633 | if(lp->fd > 0) return(-1); | 642 | if(lp->fd > 0) |
643 | return -EBUSY; | ||
634 | if(lp->remove != NULL) (*lp->remove)(&lp->user); | 644 | if(lp->remove != NULL) (*lp->remove)(&lp->user); |
635 | unregister_netdev(dev); | 645 | unregister_netdev(dev); |
636 | platform_device_unregister(&device->pdev); | 646 | platform_device_unregister(&device->pdev); |
@@ -638,13 +648,14 @@ static int net_remove(char *str) | |||
638 | list_del(&device->list); | 648 | list_del(&device->list); |
639 | kfree(device); | 649 | kfree(device); |
640 | free_netdev(dev); | 650 | free_netdev(dev); |
641 | return(0); | 651 | return 0; |
642 | } | 652 | } |
643 | 653 | ||
644 | static struct mc_device net_mc = { | 654 | static struct mc_device net_mc = { |
645 | .name = "eth", | 655 | .name = "eth", |
646 | .config = net_config, | 656 | .config = net_config, |
647 | .get_config = NULL, | 657 | .get_config = NULL, |
658 | .id = net_id, | ||
648 | .remove = net_remove, | 659 | .remove = net_remove, |
649 | }; | 660 | }; |
650 | 661 | ||