Skip to content

Commit 234a462

Browse files
author
Matthew Wilcox
committed
idr: Delete idr_replace_ext function
Changing idr_replace's 'id' argument to 'unsigned long' works for all callers. Callers which passed a negative ID now get -ENOENT instead of -EINVAL. No callers relied on this error value. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
1 parent 9c16094 commit 234a462

7 files changed

Lines changed: 9 additions & 19 deletions

File tree

‎include/linux/idr.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ int idr_for_each(const struct idr *,
136136
int (*fn)(int id, void *p, void *data), void *data);
137137
void *idr_get_next(struct idr *, int *nextid);
138138
void *idr_get_next_ext(struct idr *idr, unsigned long *nextid);
139-
void *idr_replace(struct idr *, void *, int id);
140-
void *idr_replace_ext(struct idr *idr, void *ptr, unsigned long id);
139+
void *idr_replace(struct idr *, void *, unsigned long id);
141140
void idr_destroy(struct idr *);
142141

143142
static inline void *idr_remove(struct idr *idr, unsigned long id)

‎lib/idr.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,9 @@ EXPORT_SYMBOL(idr_get_next_ext);
147147
* the one being replaced!).
148148
*
149149
* Returns: the old value on success. %-ENOENT indicates that @id was not
150-
* found. %-EINVAL indicates that @id or @ptr were not valid.
150+
* found. %-EINVAL indicates that @ptr was not valid.
151151
*/
152-
void *idr_replace(struct idr *idr, void *ptr, int id)
153-
{
154-
if (id < 0)
155-
return ERR_PTR(-EINVAL);
156-
157-
return idr_replace_ext(idr, ptr, id);
158-
}
159-
EXPORT_SYMBOL(idr_replace);
160-
161-
void *idr_replace_ext(struct idr *idr, void *ptr, unsigned long id)
152+
void *idr_replace(struct idr *idr, void *ptr, unsigned long id)
162153
{
163154
struct radix_tree_node *node;
164155
void __rcu **slot = NULL;
@@ -175,7 +166,7 @@ void *idr_replace_ext(struct idr *idr, void *ptr, unsigned long id)
175166

176167
return entry;
177168
}
178-
EXPORT_SYMBOL(idr_replace_ext);
169+
EXPORT_SYMBOL(idr_replace);
179170

180171
/**
181172
* DOC: IDA description

‎net/sched/act_api.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a)
348348
struct tcf_idrinfo *idrinfo = tn->idrinfo;
349349

350350
spin_lock_bh(&idrinfo->lock);
351-
idr_replace_ext(&idrinfo->action_idr, a, a->tcfa_index);
351+
idr_replace(&idrinfo->action_idr, a, a->tcfa_index);
352352
spin_unlock_bh(&idrinfo->lock);
353353
}
354354
EXPORT_SYMBOL(tcf_idr_insert);

‎net/sched/cls_basic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
235235
*arg = fnew;
236236

237237
if (fold) {
238-
idr_replace_ext(&head->handle_idr, fnew, fnew->handle);
238+
idr_replace(&head->handle_idr, fnew, fnew->handle);
239239
list_replace_rcu(&fold->link, &fnew->link);
240240
tcf_unbind_filter(tp, &fold->res);
241241
tcf_exts_get_net(&fold->exts);

‎net/sched/cls_bpf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
526526
prog->gen_flags |= TCA_CLS_FLAGS_NOT_IN_HW;
527527

528528
if (oldprog) {
529-
idr_replace_ext(&head->handle_idr, prog, handle);
529+
idr_replace(&head->handle_idr, prog, handle);
530530
list_replace_rcu(&oldprog->link, &prog->link);
531531
tcf_unbind_filter(tp, &oldprog->res);
532532
tcf_exts_get_net(&oldprog->exts);

‎net/sched/cls_flower.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
967967

968968
if (fold) {
969969
fnew->handle = handle;
970-
idr_replace_ext(&head->handle_idr, fnew, fnew->handle);
970+
idr_replace(&head->handle_idr, fnew, fnew->handle);
971971
list_replace_rcu(&fold->list, &fnew->list);
972972
tcf_unbind_filter(tp, &fold->res);
973973
tcf_exts_get_net(&fold->exts);

‎net/sched/cls_u32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ static void u32_replace_knode(struct tcf_proto *tp, struct tc_u_common *tp_c,
848848
if (pins->handle == n->handle)
849849
break;
850850

851-
idr_replace_ext(&ht->handle_idr, n, n->handle);
851+
idr_replace(&ht->handle_idr, n, n->handle);
852852
RCU_INIT_POINTER(n->next, pins->next);
853853
rcu_assign_pointer(*ins, n);
854854
}

0 commit comments

Comments
 (0)