diff options
Diffstat (limited to 'drivers/net/ppp_generic.c')
-rw-r--r-- | drivers/net/ppp_generic.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index f608c12e3e8b..b2073fce8216 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/rwsem.h> | 46 | #include <linux/rwsem.h> |
47 | #include <linux/stddef.h> | 47 | #include <linux/stddef.h> |
48 | #include <linux/device.h> | 48 | #include <linux/device.h> |
49 | #include <linux/mutex.h> | ||
49 | #include <net/slhc_vj.h> | 50 | #include <net/slhc_vj.h> |
50 | #include <asm/atomic.h> | 51 | #include <asm/atomic.h> |
51 | 52 | ||
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map); | |||
198 | static void cardmap_destroy(struct cardmap **map); | 199 | static void cardmap_destroy(struct cardmap **map); |
199 | 200 | ||
200 | /* | 201 | /* |
201 | * all_ppp_sem protects the all_ppp_units mapping. | 202 | * all_ppp_mutex protects the all_ppp_units mapping. |
202 | * It also ensures that finding a ppp unit in the all_ppp_units map | 203 | * It also ensures that finding a ppp unit in the all_ppp_units map |
203 | * and updating its file.refcnt field is atomic. | 204 | * and updating its file.refcnt field is atomic. |
204 | */ | 205 | */ |
205 | static DECLARE_MUTEX(all_ppp_sem); | 206 | static DEFINE_MUTEX(all_ppp_mutex); |
206 | static struct cardmap *all_ppp_units; | 207 | static struct cardmap *all_ppp_units; |
207 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); | 208 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); |
208 | 209 | ||
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
804 | /* Attach to an existing ppp unit */ | 805 | /* Attach to an existing ppp unit */ |
805 | if (get_user(unit, p)) | 806 | if (get_user(unit, p)) |
806 | break; | 807 | break; |
807 | down(&all_ppp_sem); | 808 | mutex_lock(&all_ppp_mutex); |
808 | err = -ENXIO; | 809 | err = -ENXIO; |
809 | ppp = ppp_find_unit(unit); | 810 | ppp = ppp_find_unit(unit); |
810 | if (ppp != 0) { | 811 | if (ppp != 0) { |
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
812 | file->private_data = &ppp->file; | 813 | file->private_data = &ppp->file; |
813 | err = 0; | 814 | err = 0; |
814 | } | 815 | } |
815 | up(&all_ppp_sem); | 816 | mutex_unlock(&all_ppp_mutex); |
816 | break; | 817 | break; |
817 | 818 | ||
818 | case PPPIOCATTCHAN: | 819 | case PPPIOCATTCHAN: |
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp) | |||
2446 | dev->do_ioctl = ppp_net_ioctl; | 2447 | dev->do_ioctl = ppp_net_ioctl; |
2447 | 2448 | ||
2448 | ret = -EEXIST; | 2449 | ret = -EEXIST; |
2449 | down(&all_ppp_sem); | 2450 | mutex_lock(&all_ppp_mutex); |
2450 | if (unit < 0) | 2451 | if (unit < 0) |
2451 | unit = cardmap_find_first_free(all_ppp_units); | 2452 | unit = cardmap_find_first_free(all_ppp_units); |
2452 | else if (cardmap_get(all_ppp_units, unit) != NULL) | 2453 | else if (cardmap_get(all_ppp_units, unit) != NULL) |
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp) | |||
2465 | 2466 | ||
2466 | atomic_inc(&ppp_unit_count); | 2467 | atomic_inc(&ppp_unit_count); |
2467 | cardmap_set(&all_ppp_units, unit, ppp); | 2468 | cardmap_set(&all_ppp_units, unit, ppp); |
2468 | up(&all_ppp_sem); | 2469 | mutex_unlock(&all_ppp_mutex); |
2469 | *retp = 0; | 2470 | *retp = 0; |
2470 | return ppp; | 2471 | return ppp; |
2471 | 2472 | ||
2472 | out2: | 2473 | out2: |
2473 | up(&all_ppp_sem); | 2474 | mutex_unlock(&all_ppp_mutex); |
2474 | free_netdev(dev); | 2475 | free_netdev(dev); |
2475 | out1: | 2476 | out1: |
2476 | kfree(ppp); | 2477 | kfree(ppp); |
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2500 | { | 2501 | { |
2501 | struct net_device *dev; | 2502 | struct net_device *dev; |
2502 | 2503 | ||
2503 | down(&all_ppp_sem); | 2504 | mutex_lock(&all_ppp_mutex); |
2504 | ppp_lock(ppp); | 2505 | ppp_lock(ppp); |
2505 | dev = ppp->dev; | 2506 | dev = ppp->dev; |
2506 | ppp->dev = NULL; | 2507 | ppp->dev = NULL; |
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2514 | ppp->file.dead = 1; | 2515 | ppp->file.dead = 1; |
2515 | ppp->owner = NULL; | 2516 | ppp->owner = NULL; |
2516 | wake_up_interruptible(&ppp->file.rwait); | 2517 | wake_up_interruptible(&ppp->file.rwait); |
2517 | up(&all_ppp_sem); | 2518 | mutex_unlock(&all_ppp_mutex); |
2518 | } | 2519 | } |
2519 | 2520 | ||
2520 | /* | 2521 | /* |
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp) | |||
2556 | 2557 | ||
2557 | /* | 2558 | /* |
2558 | * Locate an existing ppp unit. | 2559 | * Locate an existing ppp unit. |
2559 | * The caller should have locked the all_ppp_sem. | 2560 | * The caller should have locked the all_ppp_mutex. |
2560 | */ | 2561 | */ |
2561 | static struct ppp * | 2562 | static struct ppp * |
2562 | ppp_find_unit(int unit) | 2563 | ppp_find_unit(int unit) |
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2601 | int ret = -ENXIO; | 2602 | int ret = -ENXIO; |
2602 | int hdrlen; | 2603 | int hdrlen; |
2603 | 2604 | ||
2604 | down(&all_ppp_sem); | 2605 | mutex_lock(&all_ppp_mutex); |
2605 | ppp = ppp_find_unit(unit); | 2606 | ppp = ppp_find_unit(unit); |
2606 | if (ppp == 0) | 2607 | if (ppp == 0) |
2607 | goto out; | 2608 | goto out; |
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2626 | outl: | 2627 | outl: |
2627 | write_unlock_bh(&pch->upl); | 2628 | write_unlock_bh(&pch->upl); |
2628 | out: | 2629 | out: |
2629 | up(&all_ppp_sem); | 2630 | mutex_unlock(&all_ppp_mutex); |
2630 | return ret; | 2631 | return ret; |
2631 | } | 2632 | } |
2632 | 2633 | ||