tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_session.c
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 #include "mali_osk.h"
12 #include "mali_osk_list.h"
13 #include "mali_session.h"
14
15 _MALI_OSK_LIST_HEAD(mali_sessions);
16
17 _mali_osk_lock_t *mali_sessions_lock;
18
19 _mali_osk_errcode_t mali_session_initialize(void)
20 {
21         _MALI_OSK_INIT_LIST_HEAD(&mali_sessions);
22
23         mali_sessions_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_READERWRITER | _MALI_OSK_LOCKFLAG_ORDERED, 0, _MALI_OSK_LOCK_ORDER_SESSIONS);
24
25         if (NULL == mali_sessions_lock) return _MALI_OSK_ERR_NOMEM;
26
27         return _MALI_OSK_ERR_OK;
28 }
29
30 void mali_session_terminate(void)
31 {
32         _mali_osk_lock_term(mali_sessions_lock);
33 }
34
35 void mali_session_add(struct mali_session_data *session)
36 {
37         mali_session_lock();
38         _mali_osk_list_add(&session->link, &mali_sessions);
39         mali_session_unlock();
40 }
41
42 void mali_session_remove(struct mali_session_data *session)
43 {
44         mali_session_lock();
45         _mali_osk_list_delinit(&session->link);
46         mali_session_unlock();
47 }