diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:18 -0500 |
commit | ec09ebc143818c7bb255cf2b79d97dae02a2e635 (patch) | |
tree | 9ee0f39f75d742927888a09ebec09fba2b2eab5c /drivers/net | |
parent | 589e9c4dace6995440c119486919ce95b180dd38 (diff) |
macvtap: convert to idr_alloc()
Convert to the much saner new idr interface.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/macvtap.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 97243011d319..a449439bd653 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -279,28 +279,17 @@ static int macvtap_receive(struct sk_buff *skb) | |||
279 | static int macvtap_get_minor(struct macvlan_dev *vlan) | 279 | static int macvtap_get_minor(struct macvlan_dev *vlan) |
280 | { | 280 | { |
281 | int retval = -ENOMEM; | 281 | int retval = -ENOMEM; |
282 | int id; | ||
283 | 282 | ||
284 | mutex_lock(&minor_lock); | 283 | mutex_lock(&minor_lock); |
285 | if (idr_pre_get(&minor_idr, GFP_KERNEL) == 0) | 284 | retval = idr_alloc(&minor_idr, vlan, 1, MACVTAP_NUM_DEVS, GFP_KERNEL); |
286 | goto exit; | 285 | if (retval >= 0) { |
287 | 286 | vlan->minor = retval; | |
288 | retval = idr_get_new_above(&minor_idr, vlan, 1, &id); | 287 | } else if (retval == -ENOSPC) { |
289 | if (retval < 0) { | ||
290 | if (retval == -EAGAIN) | ||
291 | retval = -ENOMEM; | ||
292 | goto exit; | ||
293 | } | ||
294 | if (id < MACVTAP_NUM_DEVS) { | ||
295 | vlan->minor = id; | ||
296 | } else { | ||
297 | printk(KERN_ERR "too many macvtap devices\n"); | 288 | printk(KERN_ERR "too many macvtap devices\n"); |
298 | retval = -EINVAL; | 289 | retval = -EINVAL; |
299 | idr_remove(&minor_idr, id); | ||
300 | } | 290 | } |
301 | exit: | ||
302 | mutex_unlock(&minor_lock); | 291 | mutex_unlock(&minor_lock); |
303 | return retval; | 292 | return retval < 0 ? retval : 0; |
304 | } | 293 | } |
305 | 294 | ||
306 | static void macvtap_free_minor(struct macvlan_dev *vlan) | 295 | static void macvtap_free_minor(struct macvlan_dev *vlan) |