aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-11-28 10:36:09 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2018-02-06 16:41:26 -0500
commit05af0ebb0810ba3f9669649134b4b4ad42540eba (patch)
tree88275c5ed31f272f70d0d9f4e1fa2bfb3d69e6bc
parent9ce75499ac140af71f0003322c99b6e58f39dfbe (diff)
cls_basic: Convert to use idr_alloc_u32
Use the new helper which saves a temporary variable and a few lines of code. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
-rw-r--r--net/sched/cls_basic.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 588c635f195e..6b7ab3512f5b 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -185,7 +185,6 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
185 struct nlattr *tb[TCA_BASIC_MAX + 1]; 185 struct nlattr *tb[TCA_BASIC_MAX + 1];
186 struct basic_filter *fold = (struct basic_filter *) *arg; 186 struct basic_filter *fold = (struct basic_filter *) *arg;
187 struct basic_filter *fnew; 187 struct basic_filter *fnew;
188 unsigned long idr_index;
189 188
190 if (tca[TCA_OPTIONS] == NULL) 189 if (tca[TCA_OPTIONS] == NULL)
191 return -EINVAL; 190 return -EINVAL;
@@ -208,21 +207,17 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
208 if (err < 0) 207 if (err < 0)
209 goto errout; 208 goto errout;
210 209
211 if (handle) { 210 if (!handle) {
212 fnew->handle = handle; 211 handle = 1;
213 if (!fold) { 212 err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
214 err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index, 213 INT_MAX, GFP_KERNEL);
215 handle, handle + 1, GFP_KERNEL); 214 } else if (!fold) {
216 if (err) 215 err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
217 goto errout; 216 handle, GFP_KERNEL);
218 }
219 } else {
220 err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
221 1, 0x7FFFFFFF, GFP_KERNEL);
222 if (err)
223 goto errout;
224 fnew->handle = idr_index;
225 } 217 }
218 if (err)
219 goto errout;
220 fnew->handle = handle;
226 221
227 err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr, 222 err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr,
228 extack); 223 extack);