cls_u32: Convert to idr_alloc_u32

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/f730cb93db8e640f95ba4acb339d5732e1721730
Commit:     f730cb93db8e640f95ba4acb339d5732e1721730
Parent:     ffdc2d9e1afd20e9f9d205115661481e984542d6
Refname:    refs/heads/master
Author:     Matthew Wilcox <[email protected]>
AuthorDate: Tue Nov 28 13:45:02 2017 -0500
Committer:  Matthew Wilcox <[email protected]>
CommitDate: Tue Feb 6 16:41:27 2018 -0500

    cls_u32: Convert to idr_alloc_u32
    
    No real benefit to this classifier, but since we're allocating a u32
    anyway, we should use this function.
    
    Signed-off-by: Matthew Wilcox <[email protected]>
---
 net/sched/cls_u32.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index d2805f24ddd3..82f85d6a245a 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -740,19 +740,17 @@ ret:
 
 static u32 gen_new_kid(struct tc_u_hnode *ht, u32 htid)
 {
-	unsigned long idr_index;
-	u32 start = htid | 0x800;
+	u32 index = htid | 0x800;
 	u32 max = htid | 0xFFF;
-	u32 min = htid;
 
-	if (idr_alloc_ext(&ht->handle_idr, NULL, &idr_index,
-			  start, max + 1, GFP_KERNEL)) {
-		if (idr_alloc_ext(&ht->handle_idr, NULL, &idr_index,
-				  min + 1, max + 1, GFP_KERNEL))
-			return max;
+	if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max, GFP_KERNEL)) {
+		index = htid + 1;
+		if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max,
+				 GFP_KERNEL))
+			index = max;
 	}
 
-	return (u32)idr_index;
+	return index;
 }
 
 static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = {
@@ -1003,8 +1001,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
 				return -ENOMEM;
 			}
 		} else {
-			err = idr_alloc_ext(&tp_c->handle_idr, ht, NULL,
-					    handle, handle + 1, GFP_KERNEL);
+			err = idr_alloc_u32(&tp_c->handle_idr, ht, &handle,
+					    handle, GFP_KERNEL);
 			if (err) {
 				kfree(ht);
 				return err;
@@ -1060,8 +1058,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
 			return -EINVAL;
 		}
 		handle = htid | TC_U32_NODE(handle);
-		err = idr_alloc_ext(&ht->handle_idr, NULL, NULL,
-				    handle, handle + 1,
+		err = idr_alloc_u32(&ht->handle_idr, NULL, &handle, handle,
 				    GFP_KERNEL);
 		if (err)
 			return err;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.