Skip to content

Commit

Permalink
intelli_plug: unify powersuspend and earlysuspend drivers
Browse files Browse the repository at this point in the history
also minor clean up on the persist logic

bump to version 3.7

Signed-off-by: Paul Reioux <[email protected]>
  • Loading branch information
faux123 committed Nov 26, 2014
1 parent 7073b26 commit ae1cd60
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions arch/arm/hotplug/intelli_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
#include <linux/powersuspend.h>
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif

//#define DEBUG_INTELLI_PLUG
#undef DEBUG_INTELLI_PLUG

#define INTELLI_PLUG_MAJOR_VERSION 3
#define INTELLI_PLUG_MINOR_VERSION 6
#define INTELLI_PLUG_MINOR_VERSION 7

#define DEF_SAMPLING_MS (268)

Expand Down Expand Up @@ -60,7 +64,7 @@ module_param(nr_run_profile_sel, uint, 0644);
//default to something sane rather than zero
static unsigned int sampling_time = DEF_SAMPLING_MS;

static unsigned int persist_count = 0;
static int persist_count = 0;

static bool suspended = false;

Expand Down Expand Up @@ -251,10 +255,12 @@ static void __cpuinit intelli_plug_work_fn(struct work_struct *work)
nr_cpus = num_online_cpus();

if (!suspended) {

if (persist_count > 0)
persist_count--;

switch (cpu_count) {
case 1:
if (persist_count > 0)
persist_count--;
if (persist_count == 0) {
//take down everyone
unplug_cpu(0);
Expand All @@ -264,7 +270,8 @@ static void __cpuinit intelli_plug_work_fn(struct work_struct *work)
#endif
break;
case 2:
persist_count = DUAL_PERSISTENCE;
if (persist_count == 0)
persist_count = DUAL_PERSISTENCE;
if (nr_cpus < 2) {
for (i = 1; i < cpu_count; i++)
cpu_up(i);
Expand All @@ -276,7 +283,8 @@ static void __cpuinit intelli_plug_work_fn(struct work_struct *work)
#endif
break;
case 3:
persist_count = TRI_PERSISTENCE;
if (persist_count == 0)
persist_count = TRI_PERSISTENCE;
if (nr_cpus < 3) {
for (i = 1; i < cpu_count; i++)
cpu_up(i);
Expand All @@ -288,7 +296,8 @@ static void __cpuinit intelli_plug_work_fn(struct work_struct *work)
#endif
break;
case 4:
persist_count = QUAD_PERSISTENCE;
if (persist_count == 0)
persist_count = QUAD_PERSISTENCE;
if (nr_cpus < 4)
for (i = 1; i < cpu_count; i++)
cpu_up(i);
Expand All @@ -310,7 +319,7 @@ static void __cpuinit intelli_plug_work_fn(struct work_struct *work)
msecs_to_jiffies(sampling_time));
}

#ifdef CONFIG_POWERSUSPEND
#if defined(CONFIG_POWERSUSPEND) || defined(CONFIG_HAS_EARLYSUSPEND)
static void screen_off_limit(bool on)
{
unsigned int i, ret;
Expand Down Expand Up @@ -339,7 +348,11 @@ static void screen_off_limit(bool on)
}
}

#ifdef CONFIG_POWERSUSPEND
static void intelli_plug_suspend(struct power_suspend *handler)
#else
static void intelli_plug_suspend(struct early_suspend *handler)
#endif
{
int cpu;

Expand Down Expand Up @@ -372,7 +385,11 @@ static void wakeup_boost(void)
}
}

#ifdef CONFIG_POWERSUSPEND
static void __cpuinit intelli_plug_resume(struct power_suspend *handler)
#else
static void __cpuinit intelli_plug_resume(struct early_suspend *handler)
#endif
{
int num_of_active_cores;
int i;
Expand All @@ -396,13 +413,23 @@ static void __cpuinit intelli_plug_resume(struct power_suspend *handler)
queue_delayed_work_on(0, intelliplug_wq, &intelli_plug_work,
msecs_to_jiffies(10));
}
#endif

#ifdef CONFIG_POWERSUSPEND
static struct power_suspend intelli_plug_power_suspend_driver = {
.suspend = intelli_plug_suspend,
.resume = intelli_plug_resume,
};
#endif /* CONFIG_POWERSUSPEND */

#ifdef CONFIG_HAS_EARLYSUSPEND
static struct early_suspend intelli_plug_early_suspend_driver = {
.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 10,
.suspend = intelli_plug_suspend,
.resume = intelli_plug_resume,
};
#endif /* CONFIG_HAS_EARLYSUSPEND */

static void intelli_plug_input_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
Expand Down Expand Up @@ -499,7 +526,9 @@ int __init intelli_plug_init(void)
#ifdef CONFIG_POWERSUSPEND
register_power_suspend(&intelli_plug_power_suspend_driver);
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
register_early_suspend(&intelli_plug_early_suspend_driver);
#endif
intelliplug_wq = alloc_workqueue("intelliplug",
WQ_HIGHPRI | WQ_UNBOUND, 1);
intelliplug_boost_wq = alloc_workqueue("iplug_boost",
Expand Down

0 comments on commit ae1cd60

Please sign in to comment.