From: Wook Song Date: Fri, 3 Mar 2017 01:15:52 +0000 (+0900) Subject: pmqos: Move registration of booting-done callback to probe X-Git-Tag: submit/tizen/20170328.004502~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9d097706e7f922bfd99fa81c6f298700bd7887c;p=platform%2Fcore%2Fsystem%2Fpass.git pmqos: Move registration of booting-done callback to probe This patch moves the registration of a callback for the booting-done event from the pmqos_init() function to the pmqos_probe() function, which is newly added. This booting-done callback is renamed to pmqos_init_done and slightly modified. Change-Id: If8b1de698ab03257b5fd67081cad1101c06e47d7 Signed-off-by: Wook Song Reviewed-by: Chanwoo Choi --- diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index baaf748..1ade574 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -418,17 +418,21 @@ static const struct edbus_method edbus_methods[] = { { "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, @@ -449,13 +453,13 @@ static int booting_done(void *data, void *user_data) 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) @@ -480,14 +484,40 @@ 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)