1 /* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30 /* This file is a slave copy from /vendor/qcom/propreitary/mm-cammera/common,
31 * Please do not modify it directly here. */
32
33 #ifndef __CAMLIST_H
34 #define __CAMLIST_H
35
36 // System dependency
37 #include <stdlib.h>
38
39 #define member_of(ptr, type, member) ({ \
40 const typeof(((type *)0)->member) *__mptr = (ptr); \
41 (type *)((char *)__mptr - offsetof(type,member));})
42
43 struct cam_list {
44 struct cam_list *next, *prev;
45 };
46
cam_list_init(struct cam_list * ptr)47 static inline void cam_list_init(struct cam_list *ptr)
48 {
49 ptr->next = ptr;
50 ptr->prev = ptr;
51 }
52
cam_list_add_tail_node(struct cam_list * item,struct cam_list * head)53 static inline void cam_list_add_tail_node(struct cam_list *item,
54 struct cam_list *head)
55 {
56 struct cam_list *prev = head->prev;
57
58 head->prev = item;
59 item->next = head;
60 item->prev = prev;
61 prev->next = item;
62 }
63
cam_list_insert_before_node(struct cam_list * item,struct cam_list * node)64 static inline void cam_list_insert_before_node(struct cam_list *item,
65 struct cam_list *node)
66 {
67 item->next = node;
68 item->prev = node->prev;
69 item->prev->next = item;
70 node->prev = item;
71 }
72
cam_list_del_node(struct cam_list * ptr)73 static inline void cam_list_del_node(struct cam_list *ptr)
74 {
75 struct cam_list *prev = ptr->prev;
76 struct cam_list *next = ptr->next;
77
78 next->prev = ptr->prev;
79 prev->next = ptr->next;
80 ptr->next = ptr;
81 ptr->prev = ptr;
82 }
83
84 #endif /* __CAMLIST_H */
85