Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
0004  */
0005 
0006 #include "ksmbd_ida.h"
0007 
0008 static inline int __acquire_id(struct ida *ida, int from, int to)
0009 {
0010     return ida_simple_get(ida, from, to, GFP_KERNEL);
0011 }
0012 
0013 int ksmbd_acquire_smb2_tid(struct ida *ida)
0014 {
0015     int id;
0016 
0017     id = __acquire_id(ida, 1, 0xFFFFFFFF);
0018 
0019     return id;
0020 }
0021 
0022 int ksmbd_acquire_smb2_uid(struct ida *ida)
0023 {
0024     int id;
0025 
0026     id = __acquire_id(ida, 1, 0);
0027     if (id == 0xFFFE)
0028         id = __acquire_id(ida, 1, 0);
0029 
0030     return id;
0031 }
0032 
0033 int ksmbd_acquire_async_msg_id(struct ida *ida)
0034 {
0035     return __acquire_id(ida, 1, 0);
0036 }
0037 
0038 int ksmbd_acquire_id(struct ida *ida)
0039 {
0040     return __acquire_id(ida, 0, 0);
0041 }
0042 
0043 void ksmbd_release_id(struct ida *ida, int id)
0044 {
0045     ida_simple_remove(ida, id);
0046 }