power: Update to wakelock blocker driver v1.0.1
- currently active wakelocks on the list are forcefully killed Signed-off-by: djb77 <dwayne.bakewell@gmail.com>
This commit is contained in:
parent
714848b183
commit
e66233ca33
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Author: andip71, 28.08.2017
|
||||
* Author: andip71, 29.08.2017
|
||||
*
|
||||
* Version 1.0.0
|
||||
* Version 1.0.1
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
|
@ -17,6 +17,9 @@
|
|||
/*
|
||||
* Change log:
|
||||
*
|
||||
* 1.0.1 (29.08.2017)
|
||||
* - Add killing wakelock when currently active
|
||||
*
|
||||
* 1.0.0 (28.08.2017)
|
||||
* - Initial version
|
||||
*
|
||||
|
@ -30,7 +33,7 @@
|
|||
#include <linux/printk.h>
|
||||
|
||||
|
||||
#define BOEFFLA_WL_BLOCKER_VERSION "1.0.0"
|
||||
#define BOEFFLA_WL_BLOCKER_VERSION "1.0.1"
|
||||
|
||||
|
||||
/*****************************************/
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
|
||||
|
||||
#ifdef CONFIG_BOEFFLA_WL_BLOCKER
|
||||
char list_wl[255];
|
||||
char list_wl_search[257];
|
||||
char list_wl[255] = {0};
|
||||
char list_wl_search[257] = {0};
|
||||
bool wl_blocker_active = false;
|
||||
bool wl_blocker_debug = false;
|
||||
|
||||
static void wakeup_source_deactivate(struct wakeup_source *ws);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -569,7 +571,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
|
|||
// AP: Function to check if a wakelock is on the wakelock blocker list
|
||||
static bool check_for_block(struct wakeup_source *ws)
|
||||
{
|
||||
char wakelock_name[52];
|
||||
char wakelock_name[52] = {0};
|
||||
|
||||
// if debug mode on, print every wakelock requested
|
||||
if (wl_blocker_debug)
|
||||
|
@ -579,25 +581,38 @@ static bool check_for_block(struct wakeup_source *ws)
|
|||
if (!wl_blocker_active)
|
||||
return false;
|
||||
|
||||
// check if wakelock is in wake lock list to be blocked
|
||||
// only if ws structure is valid
|
||||
if (ws)
|
||||
{
|
||||
// wake lock names which are longer than 50 chars are not handled
|
||||
if (strlen(ws->name) > 50)
|
||||
return false;
|
||||
|
||||
// check if wakelock is in wake lock list to be blocked
|
||||
sprintf(wakelock_name, ";%s;", ws->name);
|
||||
|
||||
if(strstr(list_wl_search, wakelock_name) == NULL)
|
||||
return false;
|
||||
|
||||
// wake lock is in list, print it if debug mode on
|
||||
if (wl_blocker_debug)
|
||||
printk("Boeffla WL blocker: %s blocked\n", ws->name);
|
||||
|
||||
// if it is currently active, deactivate it immediately + log in debug mode
|
||||
if (ws->active)
|
||||
{
|
||||
wakeup_source_deactivate(ws);
|
||||
|
||||
if (wl_blocker_debug)
|
||||
printk("Boeffla WL blocker: %s killed\n", ws->name);
|
||||
}
|
||||
|
||||
// finally block it
|
||||
return true;
|
||||
}
|
||||
|
||||
// wake lock is in list, print it if debug mode on
|
||||
if (wl_blocker_debug)
|
||||
printk("Boeffla WL blocker: %s blocked\n", ws->name);
|
||||
|
||||
// finally block it
|
||||
return true;
|
||||
// there was no valid ws structure, do not block by default
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user