Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Linus Torvalds
b051f6ed c718aa65

+6 -18
+6 -18
drivers/atm/nicstar.c
··· 949 949 static void push_rxbufs(ns_dev * card, struct sk_buff *skb) 950 950 { 951 951 struct sk_buff *handle1, *handle2; 952 - u32 id1 = 0, id2 = 0; 952 + int id1, id2; 953 953 u32 addr1, addr2; 954 954 u32 stat; 955 955 unsigned long flags; 956 - int err; 957 956 958 957 /* *BARF* */ 959 958 handle2 = NULL; ··· 1025 1026 card->lbfqc += 2; 1026 1027 } 1027 1028 1028 - do { 1029 - if (!idr_pre_get(&card->idr, GFP_ATOMIC)) { 1030 - printk(KERN_ERR 1031 - "nicstar%d: no free memory for idr\n", 1032 - card->index); 1033 - goto out; 1034 - } 1029 + id1 = idr_alloc(&card->idr, handle1, 0, 0, GFP_ATOMIC); 1030 + if (id1 < 0) 1031 + goto out; 1035 1032 1036 - if (!id1) 1037 - err = idr_get_new_above(&card->idr, handle1, 0, &id1); 1038 - 1039 - if (!id2 && err == 0) 1040 - err = idr_get_new_above(&card->idr, handle2, 0, &id2); 1041 - 1042 - } while (err == -EAGAIN); 1043 - 1044 - if (err) 1033 + id2 = idr_alloc(&card->idr, handle2, 0, 0, GFP_ATOMIC); 1034 + if (id2 < 0) 1045 1035 goto out; 1046 1036 1047 1037 spin_lock_irqsave(&card->res_lock, flags);