summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Wei Liew <zhaoweiliew@gmail.com>2016-06-26 11:37:59 +0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-07-09 15:45:00 -0700
commit97f2320e44a205031bf4fa2c4724cc2341829f0a (patch)
tree0f00baddcc743ae37b3430c7bc75a7e64126e0fa
parent94c7d1919a40e1e3ea0f0202f9633b4e97f2acb2 (diff)
power: Use ARRAY_SIZE macro where possible
The common macro was introduced in the commit: 8fe35cc7dd88bbb82a7732591fac4b8ecd935970 So use it. Change-Id: Ie47d0e6b91b7bba378b0fdf53a345a021b0c2d48
-rw-r--r--power/power-8084.c10
-rw-r--r--power/power-8226.c8
-rw-r--r--power/power-8610.c8
-rw-r--r--power/power-8909.c2
-rw-r--r--power/power-8916.c24
-rw-r--r--power/power-8952.c2
-rw-r--r--power/power-8960.c4
-rw-r--r--power/power-8974.c18
-rw-r--r--power/power-8992.c22
-rw-r--r--power/power-8994.c20
-rw-r--r--power/power-common.h2
-rw-r--r--power/power.c12
12 files changed, 64 insertions, 68 deletions
diff --git a/power/power-8084.c b/power/power-8084.c
index 8c65f10..eca3b84 100644
--- a/power/power-8084.c
+++ b/power/power-8084.c
@@ -75,7 +75,7 @@ static void set_power_profile(int profile) {
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
@@ -83,7 +83,7 @@ static void set_power_profile(int profile) {
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
@@ -110,7 +110,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { CPUS_ONLINE_MIN_2, 0x20B, 0x30B, 0x1C00};
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -152,7 +152,7 @@ int set_interactive_override(struct power_module *module, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
@@ -163,7 +163,7 @@ int set_interactive_override(struct power_module *module, int on)
if (display_boost && display_hint2_sent) {
int resource_values2[] = {CPUS_ONLINE_MIN_2};
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
- resource_values2, sizeof(resource_values2)/sizeof(resource_values2[0]));
+ resource_values2, ARRAY_SIZE(resource_values2));
display_hint2_sent = 0;
}
diff --git a/power/power-8226.c b/power/power-8226.c
index 2cbfad6..452972d 100644
--- a/power/power-8226.c
+++ b/power/power-8226.c
@@ -73,14 +73,14 @@ static void set_power_profile(int profile) {
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_2,
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
@@ -107,13 +107,13 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { CPUS_ONLINE_MIN_2, 0x20F, 0x30F};
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
} else if (hint == POWER_HINT_INTERACTION) {
int resources[] = {0x702, 0x20B, 0x30B};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
diff --git a/power/power-8610.c b/power/power-8610.c
index 2e64083..0e5b82f 100644
--- a/power/power-8610.c
+++ b/power/power-8610.c
@@ -72,13 +72,13 @@ static void set_power_profile(int profile) {
int resource_values[] = { CPUS_ONLINE_MIN_2,
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_2,
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
@@ -105,13 +105,13 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { CPUS_ONLINE_MIN_2, 0x20F, 0x30F};
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
} else if (hint == POWER_HINT_INTERACTION) {
int resources[] = {0x702, 0x20B, 0x30B};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
diff --git a/power/power-8909.c b/power/power-8909.c
index 8de6543..6127f02 100644
--- a/power/power-8909.c
+++ b/power/power-8909.c
@@ -80,7 +80,7 @@ static void process_video_encode_hint(void *metadata)
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {HS_FREQ_800, THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_encode_metadata.state == 0) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
diff --git a/power/power-8916.c b/power/power-8916.c
index 47dfff2..efef960 100644
--- a/power/power-8916.c
+++ b/power/power-8916.c
@@ -134,7 +134,7 @@ static void set_power_profile(int profile) {
profile_high_performance_8916 : profile_high_performance_8939;
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
@@ -142,7 +142,7 @@ static void set_power_profile(int profile) {
profile_power_save_8916 : profile_power_save_8939;
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
@@ -185,13 +185,13 @@ static void process_video_decode_hint(void *metadata)
int resource_values[] = {THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_decode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026};
perform_hint_action(video_decode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_decode_metadata.state == 0) {
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
@@ -235,13 +235,13 @@ static void process_video_encode_hint(void *metadata)
int resource_values[] = {IO_BUSY_OFF, SAMPLING_DOWN_FACTOR_1, THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {HS_FREQ_800, 0x1C00};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_encode_metadata.state == 0) {
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
@@ -293,7 +293,7 @@ int set_interactive_override(struct power_module *module __unused, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
} /* Perf time rate set for 8916 target*/
@@ -324,7 +324,7 @@ int set_interactive_override(struct power_module *module __unused, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
} /* Perf time rate set for CORE0,CORE4 8939 target*/
@@ -418,14 +418,14 @@ int power_hint_override(struct power_module *module __unused, power_hint_t hint,
SCHED_PREFER_IDLE_DIS,
0x20D
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
} else {
int resources[] = {
ALL_CPUS_PWR_CLPS_DIS,
SCHED_PREFER_IDLE_DIS,
0x20D
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
}
return HINT_HANDLED;
}
@@ -443,7 +443,7 @@ int power_hint_override(struct power_module *module __unused, power_hint_t hint,
0x4201
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -458,7 +458,7 @@ int power_hint_override(struct power_module *module __unused, power_hint_t hint,
};
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
diff --git a/power/power-8952.c b/power/power-8952.c
index 69b0e42..67cde9a 100644
--- a/power/power-8952.c
+++ b/power/power-8952.c
@@ -48,8 +48,6 @@
#include "performance.h"
#include "power-common.h"
-#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))
-
static int display_hint_sent;
static int video_encode_hint_sent;
static int current_power_profile = PROFILE_BALANCED;
diff --git a/power/power-8960.c b/power/power-8960.c
index bfff734..23d7b14 100644
--- a/power/power-8960.c
+++ b/power/power-8960.c
@@ -118,14 +118,14 @@ static void set_power_profile(int profile) {
profile_high_performance_8064 : profile_high_performance_8960;
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
int* resource_values = is_target_8064() ?
profile_power_save_8064 : profile_power_save_8960;
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
diff --git a/power/power-8974.c b/power/power-8974.c
index aa0da4b..1d7731c 100644
--- a/power/power-8974.c
+++ b/power/power-8974.c
@@ -76,28 +76,28 @@ static void set_power_profile(int profile) {
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
int resource_values[] = {
CPU0_MIN_FREQ_NONTURBO_MAX + 1, CPU1_MIN_FREQ_NONTURBO_MAX + 1,
CPU2_MIN_FREQ_NONTURBO_MAX + 1, CPU2_MIN_FREQ_NONTURBO_MAX + 1 };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias perf mode", __func__);
} else if (profile == PROFILE_BIAS_POWER) {
int resource_values[] = { 0x0A03,
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
CPU1_MAX_FREQ_NONTURBO_MAX, CPU2_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias power mode", __func__);
} else if (profile == PROFILE_POWER_SAVE) {
int resource_values[] = { 0x0A03, CPUS_ONLINE_MAX_LIMIT_2,
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
}
@@ -126,7 +126,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -137,7 +137,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
0x20F, 0x30F, 0x40F, 0x50F };
if (duration)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -170,7 +170,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
0x20F, 0x30F, 0x40F, 0x50F };
if (duration)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -213,7 +213,7 @@ int set_interactive_override(struct power_module *module __unused, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
@@ -224,7 +224,7 @@ int set_interactive_override(struct power_module *module __unused, int on)
if (display_boost && display_hint2_sent) {
int resource_values2[] = {CPUS_ONLINE_MIN_2};
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
- resource_values2, sizeof(resource_values2)/sizeof(resource_values2[0]));
+ resource_values2, ARRAY_SIZE(resource_values2));
display_hint2_sent = 0;
}
diff --git a/power/power-8992.c b/power/power-8992.c
index 24efcfc..99208ed 100644
--- a/power/power-8992.c
+++ b/power/power-8992.c
@@ -47,8 +47,6 @@
#include "performance.h"
#include "power-common.h"
-#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))
-
static int display_hint_sent;
int get_number_of_profiles() {
@@ -75,7 +73,7 @@ static void set_power_profile(int profile) {
CPU2_MAX_FREQ_NONTURBO_MAX - 2, CPU3_MAX_FREQ_NONTURBO_MAX - 2,
CPU4_MAX_FREQ_NONTURBO_MAX - 2, CPU5_MAX_FREQ_NONTURBO_MAX - 2 };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
int resource_values[] = { SCHED_BOOST_ON, CPUS_ONLINE_MAX,
@@ -84,7 +82,7 @@ static void set_power_profile(int profile) {
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX,
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_BIAS_POWER) {
int resource_values[] = { 0x0A03, 0x0902,
@@ -92,13 +90,13 @@ static void set_power_profile(int profile) {
CPU1_MAX_FREQ_NONTURBO_MAX - 2, CPU2_MAX_FREQ_NONTURBO_MAX - 2,
CPU4_MAX_FREQ_NONTURBO_MAX, CPU5_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias power mode", __func__);
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_MAX,
CPU4_MIN_FREQ_NONTURBO_MAX + 1, CPU5_MIN_FREQ_NONTURBO_MAX + 1 };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias perf mode", __func__);
}
@@ -145,7 +143,7 @@ static int process_video_encode_hint(void *metadata)
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
@@ -201,13 +199,13 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
SCHED_BOOST_ON,
SCHED_PREFER_IDLE_DIS
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
} else {
int resources[] = {
ALL_CPUS_PWR_CLPS_DIS,
SCHED_PREFER_IDLE_DIS
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
}
return HINT_HANDLED;
}
@@ -225,7 +223,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { SCHED_BOOST_ON, 0x20C };
start_prefetch(info->pid, info->packageName);
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -235,7 +233,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { SCHED_BOOST_ON };
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -266,7 +264,7 @@ int set_interactive_override(__attribute__((unused)) struct power_module *module
int resource_values[] = { 0x4E63, 0x4F5F };
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
return HINT_HANDLED;
}
diff --git a/power/power-8994.c b/power/power-8994.c
index 791ad3a..fb171dd 100644
--- a/power/power-8994.c
+++ b/power/power-8994.c
@@ -74,7 +74,7 @@ static void set_power_profile(int profile) {
CPU4_MAX_FREQ_NONTURBO_MAX - 2, CPU5_MAX_FREQ_NONTURBO_MAX - 2,
CPU6_MAX_FREQ_NONTURBO_MAX - 2, CPU7_MAX_FREQ_NONTURBO_MAX - 2 };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set powersave", __func__);
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
int resource_values[] = { SCHED_BOOST_ON, CPUS_ONLINE_MAX,
@@ -84,7 +84,7 @@ static void set_power_profile(int profile) {
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX,
CPU6_MIN_FREQ_TURBO_MAX, CPU7_MIN_FREQ_TURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set performance mode", __func__);
} else if (profile == PROFILE_BIAS_POWER) {
int resource_values[] = { 0x0A03, 0x0902,
@@ -93,14 +93,14 @@ static void set_power_profile(int profile) {
CPU4_MAX_FREQ_NONTURBO_MAX, CPU5_MAX_FREQ_NONTURBO_MAX,
CPU6_MAX_FREQ_NONTURBO_MAX, CPU7_MAX_FREQ_NONTURBO_MAX };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias power mode", __func__);
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_MAX,
CPU4_MIN_FREQ_NONTURBO_MAX + 1, CPU5_MIN_FREQ_NONTURBO_MAX + 1,
CPU6_MIN_FREQ_NONTURBO_MAX + 1, CPU7_MIN_FREQ_NONTURBO_MAX + 1 };
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
ALOGD("%s: set bias perf mode", __func__);
}
@@ -153,7 +153,7 @@ static int process_video_encode_hint(void *metadata)
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
@@ -209,13 +209,13 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
SCHED_BOOST_ON,
SCHED_PREFER_IDLE_DIS
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
} else {
int resources[] = {
ALL_CPUS_PWR_CLPS_DIS,
SCHED_PREFER_IDLE_DIS
};
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
}
return HINT_HANDLED;
}
@@ -233,7 +233,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { SCHED_BOOST_ON, 0x20C };
start_prefetch(info->pid, info->packageName);
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -243,7 +243,7 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
int resources[] = { SCHED_BOOST_ON };
if (duration > 0)
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, ARRAY_SIZE(resources), resources);
return HINT_HANDLED;
}
@@ -274,7 +274,7 @@ int set_interactive_override(__attribute__((unused)) struct power_module *module
int resource_values[] = { 0x4E63, 0x4F5F };
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
return HINT_HANDLED;
}
diff --git a/power/power-common.h b/power/power-common.h
index 35450d3..68d1341 100644
--- a/power/power-common.h
+++ b/power/power-common.h
@@ -42,7 +42,7 @@
#define HINT_HANDLED (0)
#define HINT_NONE (-1)
-#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
enum CPU_GOV_CHECK {
CPU0 = 0,
diff --git a/power/power.c b/power/power.c
index 1c2b84f..6275c50 100644
--- a/power/power.c
+++ b/power/power.c
@@ -123,13 +123,13 @@ static void process_video_decode_hint(void *metadata)
int resource_values[] = {THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_decode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026, THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_decode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_decode_metadata.state == 0) {
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
@@ -173,14 +173,14 @@ static void process_video_encode_hint(void *metadata)
int resource_values[] = {IO_BUSY_OFF, SAMPLING_DOWN_FACTOR_1, THREAD_MIGRATION_SYNC_OFF};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026, THREAD_MIGRATION_SYNC_OFF,
INTERACTIVE_IO_BUSY_OFF};
perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_encode_metadata.state == 0) {
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
@@ -285,7 +285,7 @@ void set_interactive(struct power_module *module, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
@@ -294,7 +294,7 @@ void set_interactive(struct power_module *module, int on)
if (!display_hint_sent) {
perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ resource_values, ARRAY_SIZE(resource_values));
display_hint_sent = 1;
}
} else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&