4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include "feedback-str.h"
25 #include "feedback-log.h"
27 #define DD_LIST_PREPEND(a, b) \
28 a = g_list_prepend(a, b)
29 #define DD_LIST_APPEND(a, b) \
30 a = g_list_append(a, b)
31 #define DD_LIST_REMOVE(a, b) \
32 a = g_list_remove(a, b)
33 #define DD_LIST_FOREACH(head, elem, node) \
34 for (elem = head; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL)
36 typedef GList dd_list;
37 static dd_list *dev_head;
39 void add_device(const struct device_ops *dev)
41 DD_LIST_APPEND(dev_head, (struct device_ops*)dev);
44 void remove_device(const struct device_ops *dev)
46 DD_LIST_REMOVE(dev_head, (struct device_ops*)dev);
49 const struct device_ops *find_device(int type)
52 const struct device_ops *dev;
54 DD_LIST_FOREACH(dev_head, elem, dev) {
55 if (dev->type == type)
61 void devices_init(void)
64 const struct device_ops *dev;
66 DD_LIST_FOREACH(dev_head, elem, dev) {
67 FEEDBACK_LOG("[%s] initialize", str_type[dev->type]);
73 void devices_exit(void)
76 const struct device_ops *dev;
78 DD_LIST_FOREACH(dev_head, elem, dev) {
79 FEEDBACK_LOG("[%s] deinitialize", str_type[dev->type]);
85 void devices_play(int pattern)
88 const struct device_ops *dev;
90 DD_LIST_FOREACH(dev_head, elem, dev) {