summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-23 14:12:25 -0700
committerGerrit <chrome-bot@google.com>2012-10-23 16:49:29 -0700
commite72788ef96e83ef9d6ac0b2593c7edd8139c9376 (patch)
tree8eab899042c277b835310e9c35d9ee8180b14837 /common
parent7cd4d4391d3abbd2272bf9b7459677a4fa99cd0c (diff)
downloadchrome-ec-e72788ef96e83ef9d6ac0b2593c7edd8139c9376.tar.gz
Hook functions no longer return values
Previously, all hook functions returned EC_SUCCESS, which was meaningless because nothing ever looked at the return value. Changing the return value to void saves ~100 bytes of code size and an equal amount of source code size. BUG=none BRANCH=none TEST=code still builds; link still boots Change-Id: I2a636339894e5a804831244967a9c9d134df7d13 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36372
Diffstat (limited to 'common')
-rw-r--r--common/charge_state.c3
-rw-r--r--common/gaia_power.c10
-rw-r--r--common/hooks.c21
-rw-r--r--common/ir357x.c6
-rw-r--r--common/keyboard.c16
-rw-r--r--common/lightbar.c16
-rw-r--r--common/main.c2
-rw-r--r--common/pmu_tps65090.c21
-rw-r--r--common/pmu_tps65090_charger.c5
-rw-r--r--common/system_common.c9
-rw-r--r--common/thermal.c3
-rw-r--r--common/tmp006.c10
-rw-r--r--common/usb_charge.c15
-rw-r--r--common/x86_power.c29
14 files changed, 65 insertions, 101 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index 3aaad3b153..a09c664c0b 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -792,11 +792,10 @@ void charge_state_machine_task(void)
* This is triggered when the AC state changes or the system boots, so that
* we can update our charging state.
*/
-static int charge_hook(void)
+static void charge_hook(void)
{
/* Wake up the task now */
task_wake(TASK_ID_POWERSTATE);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, charge_hook, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_AC_CHANGE, charge_hook, HOOK_PRIO_DEFAULT);
diff --git a/common/gaia_power.c b/common/gaia_power.c
index ab40cdc560..922b07afbb 100644
--- a/common/gaia_power.c
+++ b/common/gaia_power.c
@@ -226,10 +226,10 @@ void gaia_suspend_event(enum gpio_signal signal)
else
powerled_set_state(POWERLED_STATE_OFF);
/* Call hooks here since we don't know it prior to AP suspend */
- hook_notify(HOOK_CHIPSET_SUSPEND, 0);
+ hook_notify(HOOK_CHIPSET_SUSPEND);
} else {
powerled_set_state(POWERLED_STATE_ON);
- hook_notify(HOOK_CHIPSET_RESUME, 0);
+ hook_notify(HOOK_CHIPSET_RESUME);
}
}
@@ -362,7 +362,7 @@ static int power_on(void)
if (gpio_get_level(GPIO_SOC1V8_XPSHOLD) == 0) {
/* Initialize non-AP components */
- hook_notify(HOOK_CHIPSET_PRE_INIT, 0);
+ hook_notify(HOOK_CHIPSET_PRE_INIT);
/*
* Initiate PMIC power-on sequence only if cold booting AP to
@@ -396,7 +396,7 @@ static int power_on(void)
powerled_set_state(POWERLED_STATE_ON);
/* Call hooks now that AP is running */
- hook_notify(HOOK_CHIPSET_STARTUP, 0);
+ hook_notify(HOOK_CHIPSET_STARTUP);
CPRINTF("[%T AP running ...]\n");
return 0;
@@ -449,7 +449,7 @@ static void power_off(void)
int pmu_shutdown_retries = 3;
/* Call hooks before we drop power rails */
- hook_notify(HOOK_CHIPSET_SHUTDOWN, 0);
+ hook_notify(HOOK_CHIPSET_SHUTDOWN);
/* switch off all rails */
gpio_set_level(GPIO_EN_PP3300, 0);
gpio_set_level(GPIO_EN_PP1350, 0);
diff --git a/common/hooks.c b/common/hooks.c
index e51503ed31..81d84b3d00 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -14,8 +14,10 @@ struct hook_ptrs {
const struct hook_data *end;
};
-/* Hook data start and end pointers for each type of hook. Must be in same
- * order as enum hook_type. */
+/*
+ * Hook data start and end pointers for each type of hook. Must be in same
+ * order as enum hook_type.
+ */
static const struct hook_ptrs hook_list[] = {
{__hooks_init, __hooks_init_end},
{__hooks_freq_change, __hooks_freq_change_end},
@@ -29,13 +31,11 @@ static const struct hook_ptrs hook_list[] = {
{__hooks_lid_change, __hooks_lid_change_end},
};
-
-int hook_notify(enum hook_type type, int stop_on_error)
+void hook_notify(enum hook_type type)
{
const struct hook_data *start, *end, *p;
int count, called = 0;
int last_prio = HOOK_PRIO_FIRST - 1, prio;
- int rv_error = EC_SUCCESS, rv;
start = hook_list[type].start;
end = hook_list[type].end;
@@ -54,17 +54,8 @@ int hook_notify(enum hook_type type, int stop_on_error)
for (p = start; p < end; p++) {
if (p->priority == prio) {
called++;
- rv = p->routine();
- if (rv != EC_SUCCESS) {
- if (stop_on_error)
- return rv;
- else if (rv_error == EC_SUCCESS)
- rv_error = rv;
- }
+ p->routine();
}
}
}
-
- /* Return the first error seen, if any */
- return rv_error;
}
diff --git a/common/ir357x.c b/common/ir357x.c
index 02c6dcc5cf..c6966b7e31 100644
--- a/common/ir357x.c
+++ b/common/ir357x.c
@@ -5,7 +5,7 @@
* IR357x driver.
*/
-#include "board.h"
+#include "common.h"
#include "console.h"
#include "hooks.h"
#include "i2c.h"
@@ -239,11 +239,9 @@ DECLARE_CONSOLE_COMMAND(ir357x, command_ir357x,
"IR357x core regulator control",
NULL);
-static int ir357x_hot_settings(void)
+static void ir357x_hot_settings(void)
{
/* dynamically apply settings to workaround issue */
ir357x_prog();
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, ir357x_hot_settings, HOOK_PRIO_DEFAULT);
diff --git a/common/keyboard.c b/common/keyboard.c
index 059e41b389..38535df1bd 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -941,7 +941,8 @@ DECLARE_HOST_COMMAND(EC_CMD_MKBP_SIMULATE_KEY,
/*****************************************************************************/
/* Hooks */
-/* Preserves the states of keyboard controller to keep the initialized states
+/**
+ * Preserve the states of keyboard controller to keep the initialized states
* between reboot_ec commands. Saving info include:
*
* - code set
@@ -950,7 +951,7 @@ DECLARE_HOST_COMMAND(EC_CMD_MKBP_SIMULATE_KEY,
* - KB/TP disabled
* - KB/TP IRQ enabled
*/
-static int keyboard_preserve_state(void)
+static void keyboard_preserve_state(void)
{
struct kb_state state;
@@ -959,14 +960,13 @@ static int keyboard_preserve_state(void)
system_add_jump_tag(KB_SYSJUMP_TAG, KB_HOOK_VERSION,
sizeof(state), &state);
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_SYSJUMP, keyboard_preserve_state, HOOK_PRIO_DEFAULT);
-
-/* Restores the keyboard states after reboot_ec command. See above function. */
-static int keyboard_restore_state(void)
+/**
+ * Restore the keyboard states after reboot_ec command. See above function.
+ */
+static void keyboard_restore_state(void)
{
const struct kb_state *prev;
int version, size;
@@ -978,7 +978,5 @@ static int keyboard_restore_state(void)
scancode_set = prev->codeset;
update_ctl_ram(0, prev->ctlram);
}
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_INIT, keyboard_restore_state, HOOK_PRIO_DEFAULT);
diff --git a/common/lightbar.c b/common/lightbar.c
index bdf3211304..c6e971e77a 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -219,10 +219,9 @@ static const struct lightbar_params default_params = {
};
#define LB_SYSJUMP_TAG 0x4c42 /* "LB" */
-static int lb_preserve_state(void)
+static void lb_preserve_state(void)
{
system_add_jump_tag(LB_SYSJUMP_TAG, 0, sizeof(st), &st);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_SYSJUMP, lb_preserve_state, HOOK_PRIO_DEFAULT);
@@ -1029,35 +1028,30 @@ void lightbar_sequence(enum lightbar_sequence num)
/****************************************************************************/
/* Get notifications from other parts of the system */
-static int lightbar_startup(void)
+static void lightbar_startup(void)
{
lightbar_sequence(LIGHTBAR_S5S3);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, lightbar_startup, HOOK_PRIO_DEFAULT);
-static int lightbar_resume(void)
+static void lightbar_resume(void)
{
lightbar_sequence(LIGHTBAR_S3S0);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, lightbar_resume, HOOK_PRIO_DEFAULT);
-static int lightbar_suspend(void)
+static void lightbar_suspend(void)
{
lightbar_sequence(LIGHTBAR_S0S3);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, lightbar_suspend, HOOK_PRIO_DEFAULT);
-static int lightbar_shutdown(void)
+static void lightbar_shutdown(void)
{
lightbar_sequence(LIGHTBAR_S3S5);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, lightbar_shutdown, HOOK_PRIO_DEFAULT);
-
/****************************************************************************/
/* Generic command-handling (should work the same for both console & LPC) */
/****************************************************************************/
diff --git a/common/main.c b/common/main.c
index b38b862f91..eb02ce8005 100644
--- a/common/main.c
+++ b/common/main.c
@@ -122,7 +122,7 @@ int main(void)
* Non-driver modules with tasks do their inits from their task
* functions, not here.
*/
- hook_notify(HOOK_INIT, 0);
+ hook_notify(HOOK_INIT);
/*
* Print the init time. Not completely accurate because it can't take
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c
index 2afe7aa585..d825cd028c 100644
--- a/common/pmu_tps65090.c
+++ b/common/pmu_tps65090.c
@@ -5,7 +5,6 @@
* TI TPS65090 PMU driver.
*/
-#include "board.h"
#include "clock.h"
#include "console.h"
#include "common.h"
@@ -433,7 +432,7 @@ int pmu_shutdown(void)
* Fill all of the pmu registers with known good values, this allows the
* pmu to recover by rebooting the system if its registers were trashed.
*/
-static int pmu_init_registers(void)
+static void pmu_init_registers(void)
{
const struct {
uint8_t index;
@@ -460,15 +459,14 @@ static int pmu_init_registers(void)
{AD_CTRL, 0x00},
{IRQ1_REG, 0x00}
};
- uint8_t i, rv;
+ uint8_t i;
- for (i = 0; i < ARRAY_SIZE(reg); i++) {
- rv = pmu_write(reg[i].index, reg[i].value);
- if (rv)
- return rv;
- }
-
- return EC_SUCCESS;
+ /*
+ * Write all PMU registers. Ignore return value from pmu_write()
+ * because there's nothing we can reasonably do if it fails.
+ */
+ for (i = 0; i < ARRAY_SIZE(reg); i++)
+ pmu_write(reg[i].index, reg[i].value);
}
DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, pmu_init_registers, HOOK_PRIO_DEFAULT);
@@ -531,10 +529,9 @@ void pmu_init(void)
/* Initializes PMU when power is turned on. This is necessary because the TPS'
* 3.3V rail is not powered until the power is turned on. */
-static int pmu_chipset_startup(void)
+static void pmu_chipset_startup(void)
{
pmu_init();
- return 0;
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pmu_chipset_startup, HOOK_PRIO_DEFAULT);
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index d710262954..cfc218d7e5 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -5,9 +5,9 @@
* TI TPS65090 PMU charging task.
*/
-#include "board.h"
#include "clock.h"
#include "chipset.h"
+#include "common.h"
#include "console.h"
#include "hooks.h"
#include "gpio.h"
@@ -482,10 +482,9 @@ void pmu_charger_task(void)
}
/* Wake charging task on chipset events */
-static int pmu_chipset_events(void)
+static void pmu_chipset_events(void)
{
task_wake(TASK_ID_PMU_TPS65090_CHARGER);
- return 0;
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pmu_chipset_events, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pmu_chipset_events, HOOK_PRIO_DEFAULT);
diff --git a/common/system_common.c b/common/system_common.c
index 979e934a12..7db000758d 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -5,9 +5,8 @@
/* System module for Chrome EC : common functions */
-#include "board.h"
#include "clock.h"
-#include "config.h"
+#include "common.h"
#include "console.h"
#include "ec_commands.h"
#include "flash.h"
@@ -323,7 +322,7 @@ static void jump_to_image(uint32_t init_addr)
jdata->struct_size = sizeof(struct jump_data);
/* Call other hooks; these may add tags */
- hook_notify(HOOK_SYSJUMP, 0);
+ hook_notify(HOOK_SYSJUMP);
/* Jump to the reset vector */
resetvec();
@@ -559,9 +558,9 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd)
/*****************************************************************************/
/* Hooks */
-static int system_common_shutdown(void)
+static void system_common_shutdown(void)
{
- return handle_pending_reboot(reboot_at_shutdown);
+ handle_pending_reboot(reboot_at_shutdown);
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, system_common_shutdown, HOOK_PRIO_DEFAULT);
diff --git a/common/thermal.c b/common/thermal.c
index 6aa8209848..780b9c2042 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -210,11 +210,10 @@ void thermal_task(void)
}
}
-static int thermal_shutdown(void)
+static void thermal_shutdown(void)
{
/* Take back fan control when the processor shuts down */
thermal_control_fan(1);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, thermal_shutdown, HOOK_PRIO_DEFAULT);
diff --git a/common/tmp006.c b/common/tmp006.c
index 42d21e75d6..cd1bdb0c10 100644
--- a/common/tmp006.c
+++ b/common/tmp006.c
@@ -5,8 +5,7 @@
/* TMP006 temperature sensor module for Chrome EC */
-#include "board.h"
-#include "config.h"
+#include "common.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
@@ -248,7 +247,10 @@ int tmp006_poll(void)
return rv1;
}
-static int tmp006_init(void)
+/*****************************************************************************/
+/* Hooks */
+
+static void tmp006_init(void)
{
int i;
@@ -263,8 +265,6 @@ static int tmp006_init(void)
tdata->b1 = B1;
tdata->b2 = B2;
}
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_INIT, tmp006_init, HOOK_PRIO_DEFAULT);
diff --git a/common/usb_charge.c b/common/usb_charge.c
index 6f95d91101..c7332fab49 100644
--- a/common/usb_charge.c
+++ b/common/usb_charge.c
@@ -168,7 +168,7 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_CHARGE_SET_MODE,
/*****************************************************************************/
/* Hooks */
-static int usb_charge_preserve_state(void)
+static void usb_charge_preserve_state(void)
{
struct usb_state state;
@@ -177,11 +177,10 @@ static int usb_charge_preserve_state(void)
system_add_jump_tag(USB_SYSJUMP_TAG, USB_HOOK_VERSION,
sizeof(state), &state);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_SYSJUMP, usb_charge_preserve_state, HOOK_PRIO_DEFAULT);
-static int usb_charge_init(void)
+static void usb_charge_init(void)
{
const struct usb_state *prev;
int version, size;
@@ -194,25 +193,19 @@ static int usb_charge_init(void)
}
else
usb_charge_all_ports_off();
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_INIT, usb_charge_init, HOOK_PRIO_DEFAULT);
-
-static int usb_charge_resume(void)
+static void usb_charge_resume(void)
{
/* Turn on USB ports on as we go into S0 from S3 or S5. */
usb_charge_all_ports_on();
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, usb_charge_resume, HOOK_PRIO_DEFAULT);
-
-static int usb_charge_shutdown(void)
+static void usb_charge_shutdown(void)
{
/* Turn on USB ports off as we go back to S5. */
usb_charge_all_ports_off();
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_charge_shutdown, HOOK_PRIO_DEFAULT);
diff --git a/common/x86_power.c b/common/x86_power.c
index 567af54f77..829139ea10 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -318,32 +318,31 @@ void chipset_throttle_cpu(int throttle)
/*****************************************************************************/
/* Hooks */
-/* Hook notified when lid state changes. */
-static int x86_lid_change(void)
+/**
+ * Hook notified when lid state changes.
+ */
+static void x86_lid_change(void)
{
/* Wake up the task to update power state */
task_wake(TASK_ID_X86POWER);
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_LID_CHANGE, x86_lid_change, HOOK_PRIO_DEFAULT);
-/* Hook notified when AC state changes. */
-static int x86_power_ac_change(void)
+/**
+ * Hook notified when AC state changes.
+ */
+static void x86_power_ac_change(void)
{
if (power_ac_present()) {
CPRINTF("[%T x86 AC on]\n");
- /* TODO: (crosbug.com/p/9609) re-enable turbo? */
} else {
CPRINTF("[%T x86 AC off]\n");
- /* TODO: (crosbug.com/p/9609) disable turbo */
if (state == X86_G3) {
last_shutdown_time = get_time().val;
task_wake(TASK_ID_X86POWER);
}
}
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_AC_CHANGE, x86_power_ac_change, HOOK_PRIO_DEFAULT);
@@ -362,7 +361,7 @@ void x86_power_interrupt(enum gpio_signal signal)
/*****************************************************************************/
/* Initialization */
-static int x86_power_init(void)
+static void x86_power_init(void)
{
/* Update input state */
update_in_signals();
@@ -412,8 +411,6 @@ static int x86_power_init(void)
gpio_enable_interrupt(GPIO_PGOOD_VCCP);
gpio_enable_interrupt(GPIO_PGOOD_VCCSA);
gpio_enable_interrupt(GPIO_PGOOD_VGFX_CORE);
-
- return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_INIT, x86_power_init, HOOK_PRIO_INIT_CHIPSET);
@@ -551,7 +548,7 @@ void x86_power_task(void)
gpio_set_level(GPIO_ENABLE_TOUCHPAD, 1);
/* Call hooks now that rails are up */
- hook_notify(HOOK_CHIPSET_STARTUP, 0);
+ hook_notify(HOOK_CHIPSET_STARTUP);
state = X86_S3;
break;
@@ -582,7 +579,7 @@ void x86_power_task(void)
gpio_set_level(GPIO_ENABLE_VCORE, 1);
/* Call hooks now that rails are up */
- hook_notify(HOOK_CHIPSET_RESUME, 0);
+ hook_notify(HOOK_CHIPSET_RESUME);
/* Wait 99ms after all voltages good */
usleep(99000);
@@ -601,7 +598,7 @@ void x86_power_task(void)
case X86_S0S3:
/* Call hooks before we remove power rails */
- hook_notify(HOOK_CHIPSET_SUSPEND, 0);
+ hook_notify(HOOK_CHIPSET_SUSPEND);
/* Clear PCH_PWROK */
gpio_set_level(GPIO_PCH_PWROK, 0);
@@ -631,7 +628,7 @@ void x86_power_task(void)
case X86_S3S5:
/* Call hooks before we remove power rails */
- hook_notify(HOOK_CHIPSET_SHUTDOWN, 0);
+ hook_notify(HOOK_CHIPSET_SHUTDOWN);
/* Disable touchpad power */
gpio_set_level(GPIO_ENABLE_TOUCHPAD, 0);