From: Youngjae Cho Date: Mon, 22 Aug 2022 07:52:33 +0000 (+0900) Subject: power: rename callback function X-Git-Tag: accepted/tizen/unified/20220927.132359~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4fb8b1f6309602e13f1f51042495a4b23bbdcb64;p=platform%2Fcore%2Fapi%2Fdevice.git power: rename callback function Change-Id: I72707a9c62b9fbddeb3f03de986b34279c0a8dc9 Signed-off-by: Youngjae Cho --- diff --git a/include/power-internal.h b/include/power-internal.h index ed85e41..48051b8 100644 --- a/include/power-internal.h +++ b/include/power-internal.h @@ -78,12 +78,12 @@ struct device_change_state_info { /** * @brief Called when a device power state is changed - * @details If both change_state_wait_callback and change_state_callback have registered to the same power state, \n - * then the change_state_wait_callback will be invoked first and the change_state_callback will follow. + * @details If both power_change_state_wait_callback and power_change_state_callback have registered to the same power state, \n + * then the power_change_state_wait_callback will be invoked first and the power_change_state_callback will follow. * @param[out] info Information about state change * @param[out] user_data User data passed from the callback registration */ -typedef void (*change_state_wait_callback) (const struct device_change_state_info *info, void *user_data); +typedef void (*power_change_state_wait_callback) (const struct device_change_state_info *info, void *user_data); /** * @brief Add a callback to observe power state change @@ -101,12 +101,12 @@ typedef void (*change_state_wait_callback) (const struct device_change_state_inf * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed */ -int device_power_add_change_state_wait_callback(uint64_t state_bits, change_state_wait_callback cb, void *user_data); +int device_power_add_change_state_wait_callback(uint64_t state_bits, power_change_state_wait_callback cb, void *user_data); /** * @brief Notify the deviced that it is ready for the actual action. * @details Notify the deviced that it is ok to take an actual action of change state. \n - * This API only works on the id received from change_state_wait_callback. + * This API only works on the id received from power_change_state_wait_callback. * @since_tizen 6.5 * @param[in] id Id of a state change * @return 0 on success, @@ -125,14 +125,14 @@ void device_power_remove_change_state_wait_callback(uint64_t state_bits); /** * @brief Async callback of device_power_change_state(). - * @details If both change_state_wait_callback and change_state_callback have registered to the same power state, \n - * then the change_state_wait_callback will be invoked first and the change_state_callback will follow. + * @details If both power_change_state_wait_callback and power_change_state_callback have registered to the same power state, \n + * then the power_change_state_wait_callback will be invoked first and the power_change_state_callback will follow. * @since_tizen 6.5 * @param[out] state State to be changed * @param[out] retval Return of change state * @param[out] user_data The user data passed from the change state function */ -typedef void (*change_state_callback) (uint64_t state, int retval, void *user_data); +typedef void (*power_change_state_callback) (uint64_t state, int retval, void *user_data); /** * @brief Send request for changing power state asynchronously. @@ -146,7 +146,7 @@ typedef void (*change_state_callback) (uint64_t state, int retval, void *user_da * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed */ -int device_power_change_state(uint64_t state, int timeout_sec, change_state_callback cb, void *user_data); +int device_power_change_state(uint64_t state, int timeout_sec, power_change_state_callback cb, void *user_data); /** * @brief Check if reboot is possible on the current device state diff --git a/src/power-internal.c b/src/power-internal.c index 79c1b54..c291aac 100644 --- a/src/power-internal.c +++ b/src/power-internal.c @@ -9,13 +9,13 @@ #define DBUS_METHOD_SYNC_CALL_TIMEOUT_MS 10000 /* 10 second */ -struct change_state_wait_handler { - change_state_wait_callback callback; +struct power_change_state_wait_handler { + power_change_state_wait_callback callback; void *user_data; }; -struct change_state_handler { - change_state_callback callback; +struct power_change_state_handler { + power_change_state_callback callback; void *user_data; uint64_t state; }; @@ -24,7 +24,7 @@ static int change_state_signal_id[POWER_STATE_MAX_INDEX]; static void signal_unsubscribed_callback(void *data) { - struct change_state_wait_handler *h = (struct change_state_wait_handler *) data; + struct power_change_state_wait_handler *h = (struct power_change_state_wait_handler *) data; free(h); } @@ -38,9 +38,9 @@ static void signal_callback(GDBusConnection *connection, gpointer user_data) { struct device_change_state_info info; - struct change_state_wait_handler *h; + struct power_change_state_wait_handler *h; - h = (struct change_state_wait_handler *) user_data; + h = (struct power_change_state_wait_handler *) user_data; if (!h || !h->callback) return; @@ -51,7 +51,7 @@ static void signal_callback(GDBusConnection *connection, } static int __device_power_add_change_state_wait_callback(GDBusConnection *connection, - int index, change_state_wait_callback cb, void *data) + int index, power_change_state_wait_callback cb, void *data) { static const char *signame[POWER_STATE_MAX_INDEX] = { [POWER_STATE_START_INDEX] = SIGNAME_CHANGE_STATE_TO_START, @@ -61,12 +61,12 @@ static int __device_power_add_change_state_wait_callback(GDBusConnection *connec [POWER_STATE_REBOOT_INDEX] = SIGNAME_CHANGE_STATE_TO_REBOOT, [POWER_STATE_EXIT_INDEX] = SIGNAME_CHANGE_STATE_TO_EXIT, }; - struct change_state_wait_handler *h; + struct power_change_state_wait_handler *h; if (change_state_signal_id[index] > 0) return DEVICE_ERROR_ALREADY_IN_PROGRESS; - h = malloc(sizeof(struct change_state_wait_handler)); + h = malloc(sizeof(struct power_change_state_wait_handler)); if (!h) { _E("Failed to alloc user data"); return DEVICE_ERROR_OPERATION_FAILED; @@ -89,7 +89,7 @@ static int __device_power_add_change_state_wait_callback(GDBusConnection *connec return DEVICE_ERROR_NONE; } -int device_power_add_change_state_wait_callback(uint64_t state_bits, change_state_wait_callback cb, void *data) +int device_power_add_change_state_wait_callback(uint64_t state_bits, power_change_state_wait_callback cb, void *data) { GDBusConnection *connection; GVariant *retgv = NULL; @@ -220,9 +220,9 @@ static void change_state_async_callback(GObject *source_object, GAsyncResult *re GDBusConnection *connection; GVariant *retgv; int retval; - struct change_state_handler *h; + struct power_change_state_handler *h; - h = (struct change_state_handler *) user_data; + h = (struct power_change_state_handler *) user_data; if (!h) return; @@ -251,11 +251,11 @@ cleanup: free(h); } -int device_power_change_state(uint64_t state, int timeout_sec, change_state_callback cb, void *user_data) +int device_power_change_state(uint64_t state, int timeout_sec, power_change_state_callback cb, void *user_data) { GError *err = NULL; GDBusConnection *connection; - struct change_state_handler *h = NULL; + struct power_change_state_handler *h = NULL; if (!device_power_check_reboot_allowed()) { if (state == POWER_STATE_POWEROFF) { @@ -270,9 +270,9 @@ int device_power_change_state(uint64_t state, int timeout_sec, change_state_call } if (cb) { - h = (struct change_state_handler *) calloc(1, sizeof(struct change_state_handler)); + h = (struct power_change_state_handler *) calloc(1, sizeof(struct power_change_state_handler)); if (!h) { - _E("Failed to alloc change_state_handler."); + _E("Failed to alloc power_change_state_handler."); return DEVICE_ERROR_OPERATION_FAILED; }