• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <stddef.h>
37 // System dependency
38 #include <stdlib.h>
39 
40 #define member_of(ptr, type, member) ({ \
41   const typeof(((type *)0)->member) *__mptr = (ptr); \
42   (type *)((char *)__mptr - offsetof(type,member));})
43 
44 struct cam_list {
45   struct cam_list *next, *prev;
46 };
47 
cam_list_init(struct cam_list * ptr)48 static inline void cam_list_init(struct cam_list *ptr)
49 {
50   ptr->next = ptr;
51   ptr->prev = ptr;
52 }
53 
cam_list_add_tail_node(struct cam_list * item,struct cam_list * head)54 static inline void cam_list_add_tail_node(struct cam_list *item,
55   struct cam_list *head)
56 {
57   struct cam_list *prev = head->prev;
58 
59   head->prev = item;
60   item->next = head;
61   item->prev = prev;
62   prev->next = item;
63 }
64 
cam_list_insert_before_node(struct cam_list * item,struct cam_list * node)65 static inline void cam_list_insert_before_node(struct cam_list *item,
66   struct cam_list *node)
67 {
68   item->next = node;
69   item->prev = node->prev;
70   item->prev->next = item;
71   node->prev = item;
72 }
73 
cam_list_del_node(struct cam_list * ptr)74 static inline void cam_list_del_node(struct cam_list *ptr)
75 {
76   struct cam_list *prev = ptr->prev;
77   struct cam_list *next = ptr->next;
78 
79   next->prev = ptr->prev;
80   prev->next = ptr->next;
81   ptr->next = ptr;
82   ptr->prev = ptr;
83 }
84 
85 #endif /* __CAMLIST_H */
86