void add_device(const struct device_ops *dev)
{
- if (dev->priority == DEVICE_PRIORITY_HIGH)
- SYS_G_LIST_PREPEND(dev_head, dev);
- else
- SYS_G_LIST_APPEND(dev_head, dev);
+ SYS_G_LIST_APPEND(dev_head, dev);
}
void remove_device(const struct device_ops *dev)
.nr_methods = ARRAY_SIZE(dbus_methods),
};
+static gint compare_priority(gconstpointer a, gconstpointer b)
+{
+ /* decreasing order
+ * high priority number will be initialized first */
+ return ((const struct device_ops *)b)->priority - ((const struct device_ops *)a)->priority;
+}
+
void devices_init(void *data)
{
GList *elem, *elem_n;
const struct device_ops *dev;
int ret;
+ dev_head = g_list_sort(dev_head, compare_priority);
+
SYS_G_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) {
if (dev->probe && dev->probe(data) != 0) {
_E("[%s] Failed to probe.", dev->name);
#include "shared/common.h"
-enum device_priority {
- DEVICE_PRIORITY_NORMAL = 0,
- DEVICE_PRIORITY_HIGH,
-};
+#define DEVICE_PRIORITY_NORMAL 0
+#define DEVICE_PRIORITY_HIGH 1
enum device_flags {
NORMAL_MODE = 0x00000001,
};
struct device_ops {
- enum device_priority priority;
+ int priority; /* high number will be initialized first */
char *name;
int len;
int (*probe) (void *data);