static GList *extcon_list;
static bool extcon_dev_available = false;
+static void extcon_deferred_init(void);
+static int booting_done(void *data);
+
void add_extcon(struct extcon_ops *dev)
{
SYS_G_LIST_APPEND(extcon_list, dev);
char *str;
int ret;
+ if (!booting_done(NULL))
+ extcon_deferred_init();
+
g_variant_get(param, "(s)", &str);
dev = find_extcon(str);
char *device;
int ret;
+ if (!booting_done(NULL))
+ extcon_deferred_init();
+
g_variant_get(param, "(s)", &device);
ret = extcon_update(device, NULL, "1");
char *device;
int ret;
+ if (!booting_done(NULL))
+ extcon_deferred_init();
+
g_variant_get(param, "(s)", &device);
ret = extcon_update(device, NULL, "0");
return 0;
}
-static int booting_done(void *data)
+/* defer extcon init until booting done as it takes long time.
+ * if dbus request is arrived before the booting done,
+ * initialize extcon on arriving that request even though
+ * system booting has not been finished */
+static void extcon_deferred_init(void)
{
- static int done;
- int ret_dbus;
GList *l;
struct extcon_ops *dev;
device_notifier_state_e state = DEVICE_NOTIFIER_STATE_START;
+ static int initialized = false;
- if (!data)
- return done;
- done = *(int *) data;
- if (!done)
- return done;
-
- if (!extcon_list)
- return done;
+ if (initialized)
+ return;
/* initialize extcon devices */
SYS_G_LIST_FOREACH(extcon_list, l, dev) {
_I("Extcon(%s) init.", dev->name);
if (dev->init)
- dev->init(data);
+ dev->init(NULL);
dev->enabled = true;
}
event_handler_state_changed((void *)&state);
+ register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
- ret_dbus = gdbus_add_object(NULL, DEVICED_PATH_EXTCON, &dbus_interface);
- if (ret_dbus < 0)
- _E("Failed to init dbus method: %d", ret_dbus);
+ initialized = true;
+}
- register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+static int booting_done(void *data)
+{
+ static int done;
+
+ if (!data)
+ return done;
+ done = *(int *) data;
+ if (!done)
+ return done;
+
+ if (!extcon_list)
+ return done;
+
+ extcon_deferred_init();
return done;
}
static void extcon_init(void *data)
{
+ int retval;
+
+ retval = gdbus_add_object(NULL, DEVICED_PATH_EXTCON, &dbus_interface);
+ if (retval < 0)
+ _E("Failed to init dbus method: %d", retval);
+
register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
}