ksmbd_ida.c (761B)
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 8static inline int __acquire_id(struct ida *ida, int from, int to) 9{ 10 return ida_simple_get(ida, from, to, GFP_KERNEL); 11} 12 13int ksmbd_acquire_smb2_tid(struct ida *ida) 14{ 15 int id; 16 17 id = __acquire_id(ida, 1, 0xFFFFFFFF); 18 19 return id; 20} 21 22int ksmbd_acquire_smb2_uid(struct ida *ida) 23{ 24 int id; 25 26 id = __acquire_id(ida, 1, 0); 27 if (id == 0xFFFE) 28 id = __acquire_id(ida, 1, 0); 29 30 return id; 31} 32 33int ksmbd_acquire_async_msg_id(struct ida *ida) 34{ 35 return __acquire_id(ida, 1, 0); 36} 37 38int ksmbd_acquire_id(struct ida *ida) 39{ 40 return __acquire_id(ida, 0, 0); 41} 42 43void ksmbd_release_id(struct ida *ida, int id) 44{ 45 ida_simple_remove(ida, id); 46}