{ "UltraPowerSaving", "i", "i", dbus_pmqos_handler },
};
-static int booting_done(void *data, void *user_data)
+static int pmqos_init_done(void *data, void *user_data)
{
- static int done;
struct edbus_method *methods = NULL;
+ int booting_done;
int ret, size;
- if (data == NULL)
- goto out;
- done = (int)data;
- if (!done)
- goto out;
+ /*
+ * As a callback function for the booting-done event, it is notified
+ * with the result of the booting_finished() function by using the
+ * first argument, void *data. When it is successfully booted up, 1 is
+ * passed with the first argument.
+ */
+ booting_done = (int)data;
+ if (!booting_done)
+ return -EINVAL;
/* register edbus methods */
ret = register_edbus_method(PASS_PATH_PMQOS, edbus_methods,
free(methods);
}
-out:
- return done;
+ return ret;
}
static void pmqos_init(void *data)
{
- register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done, NULL);
+ /* This is the case of daemon creation: DO NOTHING */
+ return;
}
static void pmqos_free(void)
static void pmqos_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
+ unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, pmqos_init_done);
pmqos_free();
}
+/*
+ * pmqos_probe - Probe PMQOS
+ *
+ * @data: the data passed from pass_main(), currently NULL
+ */
+static int pmqos_probe(void *data)
+{
+ int ret = 0;
+
+ /*
+ * Register a notifier for the booting-done event. The actual
+ * initialization of the daemon is performed by this notifier after
+ * booting is completely done.
+ */
+ ret = register_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ pmqos_init_done, NULL);
+ if (ret < 0) {
+ _E("cannot register a callback function \
+ for the booting-done event (%d)\n", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
static const struct device_ops pmqos_device_ops = {
- .name = "pmqos",
- .init = pmqos_init,
- .exit = pmqos_exit,
+ .name = "pmqos",
+ .probe = pmqos_probe,
+ .init = pmqos_init,
+ .exit = pmqos_exit,
};
DEVICE_OPS_REGISTER(&pmqos_device_ops)