diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:15 -0500 |
commit | b051f6edc29c084a6440e9731bc85d95b6b95e14 (patch) | |
tree | 6675b9de4a1b74babf9c450888a9b3495b2ffaa9 /drivers/atm | |
parent | c718aa652d3def382a79c25442c2a830263e52ed (diff) |
atm/nicstar: convert to idr_alloc()
Convert to the much saner new idr interface. The existing code looks
buggy to me - ID 0 is treated as no-ID but allocation specifies 0 as
lower limit and there's no error handling after partial success. This
conversion keeps the bugs unchanged.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Chas Williams <chas@cmf.nrl.navy.mil>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/atm')
-rw-r--r-- | drivers/atm/nicstar.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 628787ed999c..6587dc295eb0 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c | |||
@@ -949,11 +949,10 @@ static void free_scq(ns_dev *card, scq_info *scq, struct atm_vcc *vcc) | |||
949 | static void push_rxbufs(ns_dev * card, struct sk_buff *skb) | 949 | static void push_rxbufs(ns_dev * card, struct sk_buff *skb) |
950 | { | 950 | { |
951 | struct sk_buff *handle1, *handle2; | 951 | struct sk_buff *handle1, *handle2; |
952 | u32 id1 = 0, id2 = 0; | 952 | int id1, id2; |
953 | u32 addr1, addr2; | 953 | u32 addr1, addr2; |
954 | u32 stat; | 954 | u32 stat; |
955 | unsigned long flags; | 955 | unsigned long flags; |
956 | int err; | ||
957 | 956 | ||
958 | /* *BARF* */ | 957 | /* *BARF* */ |
959 | handle2 = NULL; | 958 | handle2 = NULL; |
@@ -1026,23 +1025,12 @@ static void push_rxbufs(ns_dev * card, struct sk_buff *skb) | |||
1026 | card->lbfqc += 2; | 1025 | card->lbfqc += 2; |
1027 | } | 1026 | } |
1028 | 1027 | ||
1029 | do { | 1028 | id1 = idr_alloc(&card->idr, handle1, 0, 0, GFP_ATOMIC); |
1030 | if (!idr_pre_get(&card->idr, GFP_ATOMIC)) { | 1029 | if (id1 < 0) |
1031 | printk(KERN_ERR | 1030 | goto out; |
1032 | "nicstar%d: no free memory for idr\n", | ||
1033 | card->index); | ||
1034 | goto out; | ||
1035 | } | ||
1036 | |||
1037 | if (!id1) | ||
1038 | err = idr_get_new_above(&card->idr, handle1, 0, &id1); | ||
1039 | |||
1040 | if (!id2 && err == 0) | ||
1041 | err = idr_get_new_above(&card->idr, handle2, 0, &id2); | ||
1042 | |||
1043 | } while (err == -EAGAIN); | ||
1044 | 1031 | ||
1045 | if (err) | 1032 | id2 = idr_alloc(&card->idr, handle2, 0, 0, GFP_ATOMIC); |
1033 | if (id2 < 0) | ||
1046 | goto out; | 1034 | goto out; |
1047 | 1035 | ||
1048 | spin_lock_irqsave(&card->res_lock, flags); | 1036 | spin_lock_irqsave(&card->res_lock, flags); |