From 392ceec578ad4cdf77cee24801f8b588274dbd05 Mon Sep 17 00:00:00 2001 From: Ziyann Date: Tue, 7 Oct 2014 21:48:15 +0200 Subject: tuna: PowerHAL: Check that PowerHAL is successfully initialized It doesn't make any sense to do something if PowerHAL couldn't setup initial parameters successfully. Cherry-picked and adjusted for tuna from http://omapzoom.org/?p=device/ti/blaze_tablet.git;a=commit;h=5b250f0dbc8fa43f8ff9e45151730b5b733c5ed0 Change-Id: I4e87f6b7be53e52f21f02cc500c8a1096f70df5f --- power/power_tuna.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'power/power_tuna.c') diff --git a/power/power_tuna.c b/power/power_tuna.c index 34b488f..a544f9a 100644 --- a/power/power_tuna.c +++ b/power/power_tuna.c @@ -40,6 +40,7 @@ struct tuna_power_module { pthread_mutex_t lock; int boostpulse_fd; int boostpulse_warned; + int inited; }; static void sysfs_write(char *path, char *s) @@ -82,6 +83,8 @@ int sysfs_read(const char *path, char *buf, size_t size) static void tuna_power_init(struct power_module *module) { + struct tuna_power_module *tuna = (struct tuna_power_module *) module; + sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", "20000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", @@ -94,6 +97,9 @@ static void tuna_power_init(struct power_module *module) "99"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay", "80000"); + + ALOGI("Initialized successfully"); + tuna->inited = 1; } static int boostpulse_open(struct tuna_power_module *tuna) @@ -120,10 +126,14 @@ static int boostpulse_open(struct tuna_power_module *tuna) static void tuna_power_set_interactive(struct power_module *module, int on) { + struct tuna_power_module *tuna = (struct tuna_power_module *) module; int len; - char buf[MAX_BUF_SZ]; + if (!tuna->inited) { + return; + } + /* * Lower maximum frequency when screen is off. CPU 0 and 1 share a * cpufreq policy. @@ -150,6 +160,10 @@ static void tuna_power_hint(struct power_module *module, power_hint_t hint, char buf[80]; int len; + if (!tuna->inited) { + return; + } + switch (hint) { case POWER_HINT_INTERACTION: if (boostpulse_open(tuna) >= 0) { -- cgit v1.1