Commit d67b7496 authored by Vishal Mahaveer's avatar Vishal Mahaveer Committed by Nishanth Menon

Separate wake_lock from Android

Add API to check if OS supports wake_lock and use the same
[COMMON][LIB] for wake_lock operations check.

Fixes: https://github.com/omapconf/omapconf/issues/35Reported-By: default avatarggardet <guillaume.gardet@opensuse.org>
Signed-off-by: default avatarVishal Mahaveer <vishalm@ti.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
parent 31f82b3c
......@@ -83,6 +83,31 @@ static const char workdirs[3][WORKDIR_MAX_NAME_LENGTH] = {
"/tmp/"};
/* ------------------------------------------------------------------------*//**
* @FUNCTION os_supports_wakelock
* @BRIEF check if running OS supports wake_lock.
* @RETURNS 1 if running OS supports wake_lock.
* 0 if running OS does not support wake_lock.
* @DESCRIPTION check if running OS is Android.
*//*------------------------------------------------------------------------ */
unsigned short os_supports_wakelock(void)
{
FILE *fp = NULL;
/*
* Try to open /sys/power/wake_lock file.
* If successfull, OS supports wake_lock
*/
fp = fopen("/sys/power/wake_lock", "r");
if (fp == NULL) {
return 0;
} else {
fclose(fp);
return 1;
}
}
/* ------------------------------------------------------------------------*//**
* @FUNCTION omapconf_revision_show
* @BRIEF show omapconf revision
......
......@@ -164,6 +164,7 @@ static const char int2char_table[11] = "0123456789";
}
unsigned short os_supports_wakelock(void);
void omapconf_revision_show(FILE *stream);
char *product_name_get(char product_name[256]);
void chips_info_show(FILE *stream, unsigned short die_id);
......
......@@ -920,7 +920,7 @@ int main(int argc, char *argv[])
/* Some of the omapconf functions do not support DEVICE OFF Mode,
* so by default acquire a wakelock if OS is Android.
*/
if (os_is_android())
if (os_supports_wakelock())
wakelock_acquire();
/* To be case-insensitive, lowercase all arguments */
......@@ -1199,7 +1199,7 @@ main_platform_specific:
}
main_exit:
if (os_is_android())
if (os_supports_wakelock())
wakelock_release();
/* Unmap last mapped memory page */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment