Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_idr.c
Context not available. | |||||
mtx_unlock(&idr->lock); | mtx_unlock(&idr->lock); | ||||
} | } | ||||
static void | static void * | ||||
idr_remove_locked(struct idr *idr, int id) | idr_remove_locked(struct idr *idr, int id) | ||||
{ | { | ||||
struct idr_layer *il; | struct idr_layer *il; | ||||
void *res; | |||||
int layer; | int layer; | ||||
int idx; | int idx; | ||||
Context not available. | |||||
il = idr->top; | il = idr->top; | ||||
layer = idr->layers - 1; | layer = idr->layers - 1; | ||||
if (il == NULL || id > idr_max(idr)) | if (il == NULL || id > idr_max(idr)) | ||||
return; | return NULL; | ||||
/* | /* | ||||
* Walk down the tree to this item setting bitmaps along the way | * Walk down the tree to this item setting bitmaps along the way | ||||
* as we know at least one item will be free along this path. | * as we know at least one item will be free along this path. | ||||
Context not available. | |||||
il = il->ary[idx]; | il = il->ary[idx]; | ||||
layer--; | layer--; | ||||
} | } | ||||
res = il->ary[idx]; | |||||
hselasky: I think this "res = " should be after the "idx = " ? | |||||
Not Done Inline ActionsGood catch! Fixed in my local branch. johalun0_gmail.com: Good catch! Fixed in my local branch. | |||||
idx = id & IDR_MASK; | idx = id & IDR_MASK; | ||||
/* | /* | ||||
* At this point we've set free space bitmaps up the whole tree. | * At this point we've set free space bitmaps up the whole tree. | ||||
Context not available. | |||||
id, idr, il); | id, idr, il); | ||||
il->ary[idx] = NULL; | il->ary[idx] = NULL; | ||||
Done Inline ActionsYou might want to put after the if-checks, just before the NULL assignment. hselasky: You might want to put after the if-checks, just before the NULL assignment. | |||||
il->bitmap |= 1 << idx; | il->bitmap |= 1 << idx; | ||||
return (res); | |||||
} | } | ||||
void | void * | ||||
idr_remove(struct idr *idr, int id) | idr_remove(struct idr *idr, int id) | ||||
{ | { | ||||
void *res; | |||||
mtx_lock(&idr->lock); | mtx_lock(&idr->lock); | ||||
idr_remove_locked(idr, id); | res = idr_remove_locked(idr, id); | ||||
mtx_unlock(&idr->lock); | mtx_unlock(&idr->lock); | ||||
return (res); | |||||
} | } | ||||
Context not available. | |||||
int | int | ||||
idr_for_each(struct idr *idp, int (*f)(int id, void *p, void *data), void *data) | idr_for_each(struct idr *idp, int (*f)(int id, void *p, void *data), void *data) | ||||
{ | { | ||||
return (idr_for_each_layer(idp->top, 0, idp->layers - 1, f, data)); | return (idr_for_each_layer(idp->top, 0, idp->layers - 1, f, data)); | ||||
} | } | ||||
static int | |||||
idr_has_entry(int id, void *p, void *data) | |||||
{ | |||||
Not Done Inline ActionsIs this one only used for debugging? hselasky: Is this one only used for debugging? | |||||
Not Done Inline ActionsIs is only used directly by the function below, idr_is_empty. drm_lease is actually not used currently because we lack something it needs but probably will be in the future johalun0_gmail.com: Is is only used directly by the function below, idr_is_empty.
idr_is_empty is used here
https… | |||||
return 1; | |||||
} | |||||
bool | |||||
idr_is_empty(struct idr *idp) | |||||
{ | |||||
return !idr_for_each(idp, idr_has_entry, NULL); | |||||
} | |||||
int | int | ||||
ida_pre_get(struct ida *ida, gfp_t flags) | ida_pre_get(struct ida *ida, gfp_t flags) | ||||
{ | { | ||||
Context not available. |
I think this "res = " should be after the "idx = " ?