Skip to content

Commit

Permalink
ksmbd: Remove usage of the deprecated ida_simple_xx() API
Browse files Browse the repository at this point in the history
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

This is less verbose.

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range() is inclusive. So change a 0xFFFFFFFF into a 0xFFFFFFFE in
order to keep the same behavior.

Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
tititiou36 authored and namjaejeon committed Dec 15, 2023
1 parent 7a22827 commit 8869ec0
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions mgmt/ksmbd_ida.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,48 @@

#include "ksmbd_ida.h"

static inline int __acquire_id(struct ida *ida, int from, int to)
{
return ida_simple_get(ida, from, to, GFP_KERNEL);
}

#ifdef CONFIG_SMB_INSECURE_SERVER
int ksmbd_acquire_smb1_tid(struct ida *ida)
{
return __acquire_id(ida, 1, 0xFFFF);
return ida_alloc_range(ida, 1, 0xFFFE, GFP_KERNEL);
}
#endif

int ksmbd_acquire_smb2_tid(struct ida *ida)
{
return __acquire_id(ida, 1, 0xFFFFFFFF);
return ida_alloc_range(ida, 1, 0xFFFFFFFE, GFP_KERNEL);

}

#ifdef CONFIG_SMB_INSECURE_SERVER
int ksmbd_acquire_smb1_uid(struct ida *ida)
{
return __acquire_id(ida, 1, 0xFFFE);
return ida_alloc_range(ida, 1, 0xFFFE, GFP_KERNEL);
}
#endif

int ksmbd_acquire_smb2_uid(struct ida *ida)
{
int id;

id = __acquire_id(ida, 1, 0);
id = ida_alloc_min(ida, 1, GFP_KERNEL);
if (id == 0xFFFE)
id = __acquire_id(ida, 1, 0);
id = ida_alloc_min(ida, 1, GFP_KERNEL);

return id;
}

int ksmbd_acquire_async_msg_id(struct ida *ida)
{
return __acquire_id(ida, 1, 0);
return ida_alloc_min(ida, 1, GFP_KERNEL);
}

int ksmbd_acquire_id(struct ida *ida)
{
return __acquire_id(ida, 0, 0);
return ida_alloc(ida, GFP_KERNEL);
}

void ksmbd_release_id(struct ida *ida, int id)
{
ida_simple_remove(ida, id);
ida_free(ida, id);
}

0 comments on commit 8869ec0

Please sign in to comment.