From ee9bd619746cb0425905baf354e7f52130bb2ef8 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liew Date: Sun, 26 Jun 2016 11:37:59 +0800 Subject: power: Use ARRAY_SIZE macro where possible Change-Id: Ie47d0e6b91b7bba378b0fdf53a345a021b0c2d48 --- power-660.c | 9 ++++----- power-8084.c | 2 +- power-8226.c | 2 +- power-845.c | 2 +- power-8610.c | 2 +- power-8909.c | 2 +- power-8916.c | 6 +++--- power-8952.c | 13 +++++-------- power-8953.c | 12 ++++-------- power-8974.c | 2 +- power-8992.c | 4 ++-- power-8994.c | 4 ++-- power-8996.c | 4 ++-- power-common.h | 1 + power-msmnile.c | 2 +- 15 files changed, 30 insertions(+), 37 deletions(-) diff --git a/power-660.c b/power-660.c index 5c87fe8..15f9d02 100644 --- a/power-660.c +++ b/power-660.c @@ -120,7 +120,7 @@ int set_interactive_override(int on) { if (is_target_SDM630()) { int res[] = {0x41414000, 0x459, 0x41410000, 0x5F, 0x41400000, 0x4, 0x41820000, 0xA}; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); + num_resources = ARRAY_SIZE(res); } /* 1. CPUfreq params @@ -135,7 +135,7 @@ int set_interactive_override(int on) { int res[] = {0x41414100, 0x386, 0x41410100, 0x5F, 0x41400100, 0x4, 0x41820000, 0xA, 0x40C54000, 0x1F4}; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); + num_resources = ARRAY_SIZE(res); } perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, num_resources); } @@ -199,8 +199,7 @@ static void process_video_encode_hint(void* metadata) { int res[] = {0x41414000, 0x459, 0x41410000, 0x5F, 0x41400000, 0x4, 0x41420000, 0x5F, 0x40C2C000, 0X5, 0x41820000, 0xA}; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); - + num_resources = ARRAY_SIZE(res); } /* 1. CPUfreq params @@ -213,7 +212,7 @@ static void process_video_encode_hint(void* metadata) { else { int res[] = {0x41414100, 0x386, 0x41410100, 0x5F, 0x41400100, 0x4, 0x41820000, 0xA}; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); + num_resources = ARRAY_SIZE(res); } camera_hint_ref_count++; if (camera_hint_ref_count == 1) { diff --git a/power-8084.c b/power-8084.c index 04f202c..2fd49ab 100644 --- a/power-8084.c +++ b/power-8084.c @@ -74,7 +74,7 @@ int set_interactive_override(int on) { /* Display on */ int resource_values2[] = {CPUS_ONLINE_MIN_2}; perform_hint_action(DISPLAY_STATE_HINT_ID_2, resource_values2, - sizeof(resource_values2) / sizeof(resource_values2[0])); + ARRAY_SIZE(resource_values2)); } return HINT_NONE; diff --git a/power-8226.c b/power-8226.c index 310a3db..7ac90ea 100644 --- a/power-8226.c +++ b/power-8226.c @@ -53,7 +53,7 @@ int power_hint_override(power_hint_t hint, void* data) { 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-845.c b/power-845.c index b081915..3c464d9 100644 --- a/power-845.c +++ b/power-845.c @@ -198,7 +198,7 @@ int power_hint_override(power_hint_t hint, void* data) { case POWER_HINT_INTERACTION: { int resources[] = {0x40800100, 0x514}; int duration = 100; - interaction(duration, sizeof(resources) / sizeof(resources[0]), resources); + interaction(duration, ARRAY_SIZE(resources), resources); ret_val = HINT_HANDLED; } break; default: diff --git a/power-8610.c b/power-8610.c index 310a3db..7ac90ea 100644 --- a/power-8610.c +++ b/power-8610.c @@ -53,7 +53,7 @@ int power_hint_override(power_hint_t hint, void* data) { 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-8909.c b/power-8909.c index a523be5..4c1506a 100644 --- a/power-8909.c +++ b/power-8909.c @@ -76,7 +76,7 @@ static void process_video_encode_hint(void* metadata) { if (is_interactive_governor(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])); + ARRAY_SIZE(resource_values)); } } else if (video_encode_metadata.state == 0) { if (is_interactive_governor(governor)) { diff --git a/power-8916.c b/power-8916.c index cde0f28..3774418 100644 --- a/power-8916.c +++ b/power-8916.c @@ -81,7 +81,7 @@ int power_hint_override(power_hint_t hint, void* data) { int resources[] = {0x702, 0x20F, 0x30F}; int duration = 3000; - interaction(duration, sizeof(resources) / sizeof(resources[0]), resources); + interaction(duration, ARRAY_SIZE(resources), resources); } return HINT_HANDLED; case POWER_HINT_VIDEO_ENCODE: /* Do nothing for encode case */ @@ -119,7 +119,7 @@ int set_interactive_override(int on) { int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF}; perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); } /* Perf time rate set for 8916 target*/ /* End of display hint for 8916 */ } else { @@ -143,7 +143,7 @@ int set_interactive_override(int on) { } perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); } /* Perf time rate set for CORE0,CORE4 8939 target*/ /* End of display hint for 8939 */ } diff --git a/power-8952.c b/power-8952.c index d666700..4918bf0 100644 --- a/power-8952.c +++ b/power-8952.c @@ -117,7 +117,7 @@ int set_interactive_override(int on) { INT_OP_NOTIFY_ON_MIGRATE, 0x00}; perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); } /* Perf time rate set for CORE0,CORE4 8952 target*/ } else { @@ -162,7 +162,6 @@ int set_interactive_override(int on) { static void process_video_encode_hint(void* metadata) { char governor[80] = {0}; int resource_values[20] = {0}; - int num_resources = 0; struct video_encode_metadata_t video_encode_metadata; ALOGI("Got process_video_encode_hint"); @@ -208,12 +207,11 @@ static void process_video_encode_hint(void* metadata) { 0x41440100, 0x5f, 0x4143c100, 0x3e6, }; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (camera_hint_ref_count == 1) { if (!video_encode_hint_sent) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - num_resources); + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } @@ -224,12 +222,11 @@ static void process_video_encode_hint(void* metadata) { 0xa, }; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (camera_hint_ref_count == 1) { if (!video_encode_hint_sent) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - num_resources); + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } @@ -243,10 +240,10 @@ static void process_video_encode_hint(void* metadata) { INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_40, INT_OP_CLUSTER1_TIMER_RATE, BIG_LITTLE_TR_MS_40}; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (!video_encode_hint_sent) { - perform_hint_action(video_encode_metadata.hint_id, resource_values, num_resources); + perform_hint_action(video_encode_metadata.hint_id, resource_values, + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } diff --git a/power-8953.c b/power-8953.c index 3b85a04..f0d2d6f 100644 --- a/power-8953.c +++ b/power-8953.c @@ -122,7 +122,7 @@ int set_interactive_override(int on) { 0x28, }; perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); } /* Perf time rate set for CORE0,CORE4 8952 target*/ } else { @@ -167,7 +167,6 @@ int set_interactive_override(int on) { static void process_video_encode_hint(void* metadata) { char governor[80] = {0}; int resource_values[20] = {0}; - int num_resources = 0; struct video_encode_metadata_t video_encode_metadata; ALOGI("Got process_video_encode_hint"); @@ -213,12 +212,11 @@ static void process_video_encode_hint(void* metadata) { 0x41440100, 0x5f, 0x4143c100, 0x40c, }; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (camera_hint_ref_count == 1) { if (!video_encode_hint_sent) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - num_resources); + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } @@ -229,12 +227,11 @@ static void process_video_encode_hint(void* metadata) { 0xa, }; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (camera_hint_ref_count == 1) { if (!video_encode_hint_sent) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - num_resources); + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } @@ -246,12 +243,11 @@ static void process_video_encode_hint(void* metadata) { 0x41430000, 0x1, 0x41434000, 0x1, 0x41424000, 0x28, }; memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res))); - num_resources = sizeof(res) / sizeof(res[0]); camera_hint_ref_count++; if (camera_hint_ref_count == 1) { if (!video_encode_hint_sent) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - num_resources); + ARRAY_SIZE(res)); video_encode_hint_sent = 1; } } diff --git a/power-8974.c b/power-8974.c index 1b171e1..226ee74 100644 --- a/power-8974.c +++ b/power-8974.c @@ -92,7 +92,7 @@ int set_interactive_override(int on) { if (is_target_8974pro()) { int resource_values2[] = {CPUS_ONLINE_MIN_2}; perform_hint_action(DISPLAY_STATE_HINT_ID_2, resource_values2, - sizeof(resource_values2) / sizeof(resource_values2[0])); + ARRAY_SIZE(resource_values2)); } } diff --git a/power-8992.c b/power-8992.c index f41d537..e914d7f 100644 --- a/power-8992.c +++ b/power-8992.c @@ -82,7 +82,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])); + ARRAY_SIZE(resource_values)); return HINT_HANDLED; } } else if (video_encode_metadata.state == 0) { @@ -120,7 +120,7 @@ int set_interactive_override(int on) { if (is_interactive_governor(governor)) { int resource_values[] = {0x777}; /* 4+0 core config in display off */ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); return HINT_HANDLED; } } else { diff --git a/power-8994.c b/power-8994.c index 89dd11c..84737ff 100644 --- a/power-8994.c +++ b/power-8994.c @@ -82,7 +82,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])); + ARRAY_SIZE(resource_values)); return HINT_HANDLED; } } else if (video_encode_metadata.state == 0) { @@ -120,7 +120,7 @@ int set_interactive_override(int on) { if (is_interactive_governor(governor)) { int resource_values[] = {0x777}; /* 4+0 core config in display off */ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); return HINT_HANDLED; } } else { diff --git a/power-8996.c b/power-8996.c index f5b20d0..0f64559 100644 --- a/power-8996.c +++ b/power-8996.c @@ -100,7 +100,7 @@ static int process_video_encode_hint(void* metadata) { camera_hint_ref_count++; if (camera_hint_ref_count == 1) { perform_hint_action(video_encode_metadata.hint_id, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); } ALOGI("Video Encode hint start"); return HINT_HANDLED; @@ -146,7 +146,7 @@ int set_interactive_override(int on) { if (is_interactive_governor(governor)) { int resource_values[] = {}; /* dummy node */ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); + ARRAY_SIZE(resource_values)); ALOGI("Display Off hint start"); return HINT_HANDLED; } diff --git a/power-common.h b/power-common.h index d731039..2707a64 100644 --- a/power-common.h +++ b/power-common.h @@ -51,6 +51,7 @@ void power_init(void); void power_hint(power_hint_t hint, void* data); void set_interactive(int on); +#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0])) #define UNUSED(x) UNUSED_##x __attribute__((__unused__)) #ifdef __cplusplus diff --git a/power-msmnile.c b/power-msmnile.c index 85f04a9..2888f73 100644 --- a/power-msmnile.c +++ b/power-msmnile.c @@ -92,7 +92,7 @@ int power_hint_override(power_hint_t hint, void* data) { case POWER_HINT_INTERACTION: { int resources[] = {0x40800100, 0x514}; int duration = 100; - interaction(duration, sizeof(resources) / sizeof(resources[0]), resources); + interaction(duration, ARRAY_SIZE(resources), resources); ret_val = HINT_HANDLED; } default: -- cgit v1.2.3