1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
4  */
5 
6 #include "ksmbd_ida.h"
7 
ksmbd_acquire_smb2_tid(struct ida * ida)8 int ksmbd_acquire_smb2_tid(struct ida *ida)
9 {
10 	return ida_alloc_range(ida, 1, 0xFFFFFFFE, GFP_KERNEL);
11 }
12 
ksmbd_acquire_smb2_uid(struct ida * ida)13 int ksmbd_acquire_smb2_uid(struct ida *ida)
14 {
15 	int id;
16 
17 	id = ida_alloc_min(ida, 1, GFP_KERNEL);
18 	if (id == 0xFFFE)
19 		id = ida_alloc_min(ida, 1, GFP_KERNEL);
20 
21 	return id;
22 }
23 
ksmbd_acquire_async_msg_id(struct ida * ida)24 int ksmbd_acquire_async_msg_id(struct ida *ida)
25 {
26 	return ida_alloc_min(ida, 1, GFP_KERNEL);
27 }
28 
ksmbd_acquire_id(struct ida * ida)29 int ksmbd_acquire_id(struct ida *ida)
30 {
31 	return ida_alloc(ida, GFP_KERNEL);
32 }
33 
ksmbd_release_id(struct ida * ida,int id)34 void ksmbd_release_id(struct ida *ida, int id)
35 {
36 	ida_free(ida, id);
37 }
38