aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cnic.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-01-26 14:28:23 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-27 18:02:57 -0500
commit13707f9e5e46342b7b16c58be91ad93a476c3ffd (patch)
tree025764fd464f83300cab236da2ce4b26c5b9703c /drivers/net/cnic.c
parentccf434380d1a67df2dcb9113206b77d0cb0a1cef (diff)
drivers/net: remove some rcu sparse warnings
Add missing __rcu annotations and helpers. minor : Fix some rcu_dereference() calls in macvtap Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r--drivers/net/cnic.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 7ff170cbc7d..c8204963513 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -65,7 +65,14 @@ static LIST_HEAD(cnic_udev_list);
65static DEFINE_RWLOCK(cnic_dev_lock); 65static DEFINE_RWLOCK(cnic_dev_lock);
66static DEFINE_MUTEX(cnic_lock); 66static DEFINE_MUTEX(cnic_lock);
67 67
68static struct cnic_ulp_ops *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE]; 68static struct cnic_ulp_ops __rcu *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE];
69
70/* helper function, assuming cnic_lock is held */
71static inline struct cnic_ulp_ops *cnic_ulp_tbl_prot(int type)
72{
73 return rcu_dereference_protected(cnic_ulp_tbl[type],
74 lockdep_is_held(&cnic_lock));
75}
69 76
70static int cnic_service_bnx2(void *, void *); 77static int cnic_service_bnx2(void *, void *);
71static int cnic_service_bnx2x(void *, void *); 78static int cnic_service_bnx2x(void *, void *);
@@ -435,7 +442,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
435 return -EINVAL; 442 return -EINVAL;
436 } 443 }
437 mutex_lock(&cnic_lock); 444 mutex_lock(&cnic_lock);
438 if (cnic_ulp_tbl[ulp_type]) { 445 if (cnic_ulp_tbl_prot(ulp_type)) {
439 pr_err("%s: Type %d has already been registered\n", 446 pr_err("%s: Type %d has already been registered\n",
440 __func__, ulp_type); 447 __func__, ulp_type);
441 mutex_unlock(&cnic_lock); 448 mutex_unlock(&cnic_lock);
@@ -478,7 +485,7 @@ int cnic_unregister_driver(int ulp_type)
478 return -EINVAL; 485 return -EINVAL;
479 } 486 }
480 mutex_lock(&cnic_lock); 487 mutex_lock(&cnic_lock);
481 ulp_ops = cnic_ulp_tbl[ulp_type]; 488 ulp_ops = cnic_ulp_tbl_prot(ulp_type);
482 if (!ulp_ops) { 489 if (!ulp_ops) {
483 pr_err("%s: Type %d has not been registered\n", 490 pr_err("%s: Type %d has not been registered\n",
484 __func__, ulp_type); 491 __func__, ulp_type);
@@ -529,7 +536,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
529 return -EINVAL; 536 return -EINVAL;
530 } 537 }
531 mutex_lock(&cnic_lock); 538 mutex_lock(&cnic_lock);
532 if (cnic_ulp_tbl[ulp_type] == NULL) { 539 if (cnic_ulp_tbl_prot(ulp_type) == NULL) {
533 pr_err("%s: Driver with type %d has not been registered\n", 540 pr_err("%s: Driver with type %d has not been registered\n",
534 __func__, ulp_type); 541 __func__, ulp_type);
535 mutex_unlock(&cnic_lock); 542 mutex_unlock(&cnic_lock);
@@ -544,7 +551,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
544 551
545 clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]); 552 clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]);
546 cp->ulp_handle[ulp_type] = ulp_ctx; 553 cp->ulp_handle[ulp_type] = ulp_ctx;
547 ulp_ops = cnic_ulp_tbl[ulp_type]; 554 ulp_ops = cnic_ulp_tbl_prot(ulp_type);
548 rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops); 555 rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops);
549 cnic_hold(dev); 556 cnic_hold(dev);
550 557
@@ -2953,7 +2960,8 @@ static void cnic_ulp_stop(struct cnic_dev *dev)
2953 struct cnic_ulp_ops *ulp_ops; 2960 struct cnic_ulp_ops *ulp_ops;
2954 2961
2955 mutex_lock(&cnic_lock); 2962 mutex_lock(&cnic_lock);
2956 ulp_ops = cp->ulp_ops[if_type]; 2963 ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
2964 lockdep_is_held(&cnic_lock));
2957 if (!ulp_ops) { 2965 if (!ulp_ops) {
2958 mutex_unlock(&cnic_lock); 2966 mutex_unlock(&cnic_lock);
2959 continue; 2967 continue;
@@ -2977,7 +2985,8 @@ static void cnic_ulp_start(struct cnic_dev *dev)
2977 struct cnic_ulp_ops *ulp_ops; 2985 struct cnic_ulp_ops *ulp_ops;
2978 2986
2979 mutex_lock(&cnic_lock); 2987 mutex_lock(&cnic_lock);
2980 ulp_ops = cp->ulp_ops[if_type]; 2988 ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
2989 lockdep_is_held(&cnic_lock));
2981 if (!ulp_ops || !ulp_ops->cnic_start) { 2990 if (!ulp_ops || !ulp_ops->cnic_start) {
2982 mutex_unlock(&cnic_lock); 2991 mutex_unlock(&cnic_lock);
2983 continue; 2992 continue;
@@ -3041,7 +3050,7 @@ static void cnic_ulp_init(struct cnic_dev *dev)
3041 struct cnic_ulp_ops *ulp_ops; 3050 struct cnic_ulp_ops *ulp_ops;
3042 3051
3043 mutex_lock(&cnic_lock); 3052 mutex_lock(&cnic_lock);
3044 ulp_ops = cnic_ulp_tbl[i]; 3053 ulp_ops = cnic_ulp_tbl_prot(i);
3045 if (!ulp_ops || !ulp_ops->cnic_init) { 3054 if (!ulp_ops || !ulp_ops->cnic_init) {
3046 mutex_unlock(&cnic_lock); 3055 mutex_unlock(&cnic_lock);
3047 continue; 3056 continue;
@@ -3065,7 +3074,7 @@ static void cnic_ulp_exit(struct cnic_dev *dev)
3065 struct cnic_ulp_ops *ulp_ops; 3074 struct cnic_ulp_ops *ulp_ops;
3066 3075
3067 mutex_lock(&cnic_lock); 3076 mutex_lock(&cnic_lock);
3068 ulp_ops = cnic_ulp_tbl[i]; 3077 ulp_ops = cnic_ulp_tbl_prot(i);
3069 if (!ulp_ops || !ulp_ops->cnic_exit) { 3078 if (!ulp_ops || !ulp_ops->cnic_exit) {
3070 mutex_unlock(&cnic_lock); 3079 mutex_unlock(&cnic_lock);
3071 continue; 3080 continue;