static void __uam_clear_ppm_reqs(void)
{
- g_list_free_full(ppm_reqs, g_free);
+ g_slist_free_full(ppm_reqs, g_free);
ppm_reqs = NULL;
}
_uam_remove_timer(con->tid);
con->tid = TIMER_OFF;
- ppm_reqs = g_list_remove(ppm_reqs, con);
+ ppm_reqs = g_slist_remove(ppm_reqs, con);
con = NULL;
return FALSE;
static gboolean __uam_is_busy(uas_plugin_id_e ids)
{
- GList *head = ppm_reqs;
- GList *iter = head;
+ GSList *head = ppm_reqs;
+ GSList *iter = head;
while (NULL != iter) {
- GList *next = iter->next;
+ GSList *next = iter->next;
_uam_req_cb_s *con = iter->data;
- if (con && con->ids == ids) {
+ if (con && con->ids == ids)
return TRUE;
- }
+
iter = next;
}
return FALSE;
}
-int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
+static int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
{
FUNC_ENTRY;
_uam_req_cb_s *con = NULL;
- retv_if(NULL == cb, UAP_STATUS_INVALID_PARAMS);
+ retv_if(NULL == cb, UAP_STATUS_INVALID_PARAMS);
UAM_DBG("Do one time presence check-up %s %d (msec)",
- _uam_get_sensor_str(ids), timeout);
+ _uam_get_sensor_str(ids), timeout);
if (0 >= timeout) {
UAM_ERR("Invalid timeout value %d (msec)", timeout);
con->cb = cb;
con->ids = ids;
con->tid = _uam_add_timer_full(TIMER_RES_MSEC, G_PRIORITY_DEFAULT,
- timeout, __uam_check_presence_timeout, con, NULL);
+ timeout, __uam_check_presence_timeout, con, NULL);
- ppm_reqs = g_list_append(ppm_reqs, con);
+ ppm_reqs = g_slist_append(ppm_reqs, con);
/* To-Do : Need to do one-time presence check */
return UAP_STATUS_SUCCESS;
}
-int stop_presence_check_callback(uas_plugin_id_e ids)
+static void stop_presence_check_callback(uas_plugin_id_e ids)
{
FUNC_ENTRY;
UAM_DBG("Stop one time presence check-up : %s", _uam_get_sensor_str(ids));
- GList *head = NULL;
- GList *iter = NULL;
+ GSList *head = NULL;
+ GSList *iter = NULL;
head = ppm_reqs;
iter = head;
while (NULL != iter) {
- GList *next = iter->next;
+ GSList *next = iter->next;
_uam_req_cb_s *con = iter->data;
if (con && con->ids == ids) {
_uam_remove_timer(con->tid);
con = NULL;
UAM_DBG("[%d] request canceled", ids);
-
- return UAP_STATUS_SUCCESS;
+ return;
}
iter = next;
}
UAM_DBG("[%d] no matching request", ids);
FUNC_EXIT;
-
- return UAP_STATUS_SUCCESS;
-
}
int _uam_ppm_handler_init(void)
{
__uam_clear_ppm_reqs();
+ return UAP_STATUS_SUCCESS;
}
int _uam_ppm_handler_deinit(void)
{
__uam_clear_ppm_reqs();
+ return UAP_STATUS_SUCCESS;
}
uap_callbacks_t power_cbs = {
#include <ua-plugin.h>
#include <ua-power-plugin.h>
#include <ua-plugin-manager.h>
+#include <ua-power-plugin-manager.h>
#include <tzplatform_config.h>
extern const uap_callbacks_t power_cbs;
{
FUNC_ENTRY;
- /* Deinitialize and unload power plugins */
- if (!pwr_plugin) {
+ /* Deinitialize and unload power plugins */
+ if (!pwr_plugin) {
UAM_WARN("Power plugin is NULL");
return;
}
- if (pwr_plugin->api && pwr_plugin->api->deinit)
+ if (pwr_plugin->api && pwr_plugin->api->deinit)
pwr_plugin->api->deinit();
- if (pwr_plugin->module && pwr_plugin->module->deinit)
+ if (pwr_plugin->module && pwr_plugin->module->deinit)
pwr_plugin->module->deinit();
- if (pwr_plugin->handle)
+ if (pwr_plugin->handle)
dlclose(pwr_plugin->handle);
- g_free(pwr_plugin);
+ g_free(pwr_plugin);
pwr_plugin = NULL;
- FUNC_EXIT;
+ FUNC_EXIT;
}
static gboolean __add_power_plugin(void *handle, uap_module_t *module)
uap_api_t *api = NULL;
uam_power_plugin_info_t *plugin = pwr_plugin;
- UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
+ UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
module->id, module->name, module->version);
- if (NULL != pwr_plugin) {
+ if (NULL != pwr_plugin) {
UAM_ERR("Plugin already added");
return FALSE;
}
- if (g_str_equal(module->version, UAM_VERSION) == FALSE) {
+ if (g_str_equal(module->version, UAM_VERSION) == FALSE) {
UAM_ERR("Version (%s) mismatch for %s",
module->version, module->name);
return FALSE;
}
- plugin = g_try_new0(uam_power_plugin_info_t, 1);
+ plugin = g_try_new0(uam_power_plugin_info_t, 1);
if (NULL == plugin) {
UAM_ERR("Memory allocation failed");
return FALSE;
}
- retv_if(NULL == module->init, FALSE);
- module->init(&api);
+ retv_if(NULL == module->init, FALSE);
+ module->init(&api);
if (NULL == api) {
UAM_ERR("API returned is NULL");
return FALSE;
}
- plugin->handle = handle;
+ plugin->handle = handle;
plugin->module = module;
plugin->api = api;
- pwr_plugin = plugin;
+ pwr_plugin = plugin;
- FUNC_EXIT;
+ FUNC_EXIT;
return TRUE;
}
void *handle = NULL;
uap_module_t *module = NULL;
- retv_if(NULL == path, UAM_ERROR_INVALID_PARAM);
+ retv_if(NULL == path, UAM_ERROR_INVALID_PARAM);
retv_if(NULL == name, UAM_ERROR_INVALID_PARAM);
retv_if(NULL == symbol, UAM_ERROR_INVALID_PARAM);
- filename = g_build_filename(path, name, NULL);
+ filename = g_build_filename(path, name, NULL);
UAM_DBG("Loading [%s]", filename);
- handle = dlopen(filename, RTLD_NOW);
+ handle = dlopen(filename, RTLD_NOW);
g_free(filename);
if (handle == NULL) {
UAM_ERR("Can't load plugin %s: %s", filename, dlerror());
return UAM_ERROR_INTERNAL;
}
- module = (uap_module_t *)dlsym(handle, symbol);
+ module = (uap_module_t *)dlsym(handle, symbol);
if (module == NULL) {
UAM_ERR("Can't load power plugin module: %s", dlerror());
dlclose(handle);
return UAM_ERROR_INTERNAL;
}
- if (UAP_PLUGIN_ID_POWER != module->id) {
+ if (UAP_PLUGIN_ID_POWER != module->id) {
dlclose(handle);
handle = NULL;
return UAM_ERROR_INVALID_PARAM;
}
- retv_if(FALSE == __add_power_plugin(handle, module), UAM_ERROR_INTERNAL);
+ retv_if(FALSE == __add_power_plugin(handle, module), UAM_ERROR_INTERNAL);
- FUNC_EXIT;
+ FUNC_EXIT;
return UAM_ERROR_NONE;
}
{
FUNC_ENTRY;
- GDir *dir;
+ GDir *dir;
const char *filename;
int ret = UAM_ERROR_INTERNAL;
- retv_if(0 == strlen(POWER_PLUGIN_DIR), UAM_ERROR_INVALID_PARAM);
- UAM_DBG("Loading power plugin from %s", POWER_PLUGIN_DIR);
+ retv_if(0 == strlen(POWER_PLUGIN_DIR), UAM_ERROR_INVALID_PARAM);
+ UAM_DBG("Loading power plugin from %s", POWER_PLUGIN_DIR);
- dir = g_dir_open(POWER_PLUGIN_DIR, 0, NULL);
+ dir = g_dir_open(POWER_PLUGIN_DIR, 0, NULL);
if (!dir) {
UAM_ERR("Unable to open directory");
return UAM_ERROR_INTERNAL;
}
- while ((filename = g_dir_read_name(dir)) != NULL) {
- if (g_str_has_suffix(filename, ".so") == FALSE)
+ while ((filename = g_dir_read_name(dir)) != NULL) {
+ if (g_str_has_suffix(filename, ".so") == FALSE)
continue;
- /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */
+ /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */
if (UAM_ERROR_NONE == __load_power_plugin(POWER_PLUGIN_DIR, filename, "uap_module"))
ret = UAM_ERROR_NONE;
}
- g_dir_close(dir);
+ g_dir_close(dir);
- FUNC_EXIT;
+ FUNC_EXIT;
return ret;
}
{
FUNC_ENTRY;
- int ret;
+ int ret;
int status;
- /* Initialize loaded power plugins */
+ /* Initialize loaded power plugins */
retv_if(UAM_ERROR_NONE != __load_power_plugins(), UAM_ERROR_INTERNAL);
- uam_power_plugin_info_t *plugin = pwr_plugin;
- if (!plugin || !plugin->api) {
+ uam_power_plugin_info_t *plugin = pwr_plugin;
+ if (!plugin || !plugin->api) {
UAM_WARN("Plugin is NULL");
return UAM_ERROR_INVALID_PARAM;
}
- status = plugin->api->init(&power_cbs);
+ status = plugin->api->init(&power_cbs);
if (UAS_STATUS_SUCCESS != status) {
/* Deinit plugin */
__deinit_power_plugin();
return UAM_ERROR_NOT_IN_OPERATION;
}
- /* If atleast one sensor init is success, return success */
+ /* If atleast one sensor init is success, return success */
ret = UAM_ERROR_NONE;
- FUNC_EXIT;
+ FUNC_EXIT;
return ret;
}
return ret;
FUNC_EXIT;
-
return UAM_ERROR_NONE;
}