diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-10-23 14:12:25 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-10-23 16:49:29 -0700 |
commit | e72788ef96e83ef9d6ac0b2593c7edd8139c9376 (patch) | |
tree | 8eab899042c277b835310e9c35d9ee8180b14837 /chip | |
parent | 7cd4d4391d3abbd2272bf9b7459677a4fa99cd0c (diff) | |
download | chrome-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 'chip')
-rw-r--r-- | chip/lm4/adc.c | 4 | ||||
-rw-r--r-- | chip/lm4/chip_temp_sensor.c | 14 | ||||
-rw-r--r-- | chip/lm4/clock.c | 9 | ||||
-rw-r--r-- | chip/lm4/gpio.c | 6 | ||||
-rw-r--r-- | chip/lm4/hwtimer.c | 4 | ||||
-rw-r--r-- | chip/lm4/i2c.c | 14 | ||||
-rw-r--r-- | chip/lm4/lpc.c | 18 | ||||
-rw-r--r-- | chip/lm4/onewire.c | 7 | ||||
-rw-r--r-- | chip/lm4/peci.c | 11 | ||||
-rw-r--r-- | chip/lm4/power_button.c | 11 | ||||
-rw-r--r-- | chip/lm4/pwm.c | 17 | ||||
-rw-r--r-- | chip/lm4/watchdog.c | 6 | ||||
-rw-r--r-- | chip/stm32/adc.c | 6 | ||||
-rw-r--r-- | chip/stm32/flash-stm32f100.c | 3 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32f100.c | 8 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32l15x.c | 8 | ||||
-rw-r--r-- | chip/stm32/i2c.c | 6 |
17 files changed, 44 insertions, 108 deletions
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c index 57604d1204..254b0903af 100644 --- a/chip/lm4/adc.c +++ b/chip/lm4/adc.c @@ -205,7 +205,7 @@ DECLARE_CONSOLE_COMMAND(adc, command_adc, /*****************************************************************************/ /* Initialization */ -static int adc_init(void) +static void adc_init(void) { int i; const struct adc_t *adc; @@ -252,7 +252,5 @@ static int adc_init(void) adc = adc_channels + i; lm4_adc_configure(adc->sequencer, adc->channel, adc->flag); } - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/chip_temp_sensor.c b/chip/lm4/chip_temp_sensor.c index 54e8a3c6ea..077806ba73 100644 --- a/chip/lm4/chip_temp_sensor.c +++ b/chip/lm4/chip_temp_sensor.c @@ -6,12 +6,12 @@ /* Temperature sensor module for Chrome EC */ #include "adc.h" -#include "config.h" -#include "hooks.h" +#include "common.h" #include "lm4_adc.h" #include "temp_sensor.h" -static int last_val; +/* Initialize temperature reading to a sane value (27 C) */ +static int last_val = 300; int chip_temp_sensor_poll(void) { @@ -29,11 +29,3 @@ int chip_temp_sensor_get_val(int idx, int *temp_ptr) return EC_SUCCESS; } - -static int chip_temp_sensor_init(void) -{ - /* Initialize temperature reading to a sane value. */ - last_val = 300; /* 27 C */ - return EC_SUCCESS; -} -DECLARE_HOOK(HOOK_INIT, chip_temp_sensor_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/clock.c b/chip/lm4/clock.c index 65dc62d069..c23dc68b29 100644 --- a/chip/lm4/clock.c +++ b/chip/lm4/clock.c @@ -63,7 +63,6 @@ static void enable_pll(void) freq = PLL_CLOCK; } - int clock_enable_pll(int enable, int notify) { if (enable) @@ -72,9 +71,11 @@ int clock_enable_pll(int enable, int notify) disable_pll(); /* Notify modules of frequency change */ - return notify ? hook_notify(HOOK_FREQ_CHANGE, 0) : EC_SUCCESS; -} + if (notify) + hook_notify(HOOK_FREQ_CHANGE); + return EC_SUCCESS; +} void clock_wait_cycles(uint32_t cycles) { @@ -230,7 +231,7 @@ static int command_pll(int argc, char **argv) freq = INTERNAL_CLOCK / div; /* Notify modules of frequency change */ - hook_notify(HOOK_FREQ_CHANGE, 0); + hook_notify(HOOK_FREQ_CHANGE); } } diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c index f5eca38a79..23cedd52c3 100644 --- a/chip/lm4/gpio.c +++ b/chip/lm4/gpio.c @@ -88,8 +88,7 @@ int gpio_pre_init(void) return EC_SUCCESS; } - -static int gpio_init(void) +static void gpio_init(void) { /* Enable IRQs now that pins are set up */ task_enable_irq(LM4_IRQ_GPIOA); @@ -109,12 +108,9 @@ static int gpio_init(void) #endif task_enable_irq(LM4_IRQ_GPIOP); task_enable_irq(LM4_IRQ_GPIOQ); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT); - void gpio_set_alternate_function(int port, int mask, int func) { int port_index = find_gpio_port_index(port); diff --git a/chip/lm4/hwtimer.c b/chip/lm4/hwtimer.c index 9c23cbf961..45166f2194 100644 --- a/chip/lm4/hwtimer.c +++ b/chip/lm4/hwtimer.c @@ -64,13 +64,11 @@ static void __hw_clock_source_irq(void) DECLARE_IRQ(LM4_IRQ_TIMERW0A, __hw_clock_source_irq, 1); -static int update_prescaler(void) +static void update_prescaler(void) { /* Set the prescaler to increment every microsecond. This takes * effect immediately, because the TAILD bit in TAMR is clear. */ LM4_TIMER_TAPR(6) = clock_get_freq() / US_PER_SECOND; - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_FREQ_CHANGE, update_prescaler, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index 94ae391712..de04bcf727 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -5,15 +5,15 @@ /* I2C port module for Chrome EC */ -#include "board.h" #include "clock.h" +#include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "registers.h" #include "task.h" #include "timer.h" -#include "registers.h" #include "util.h" #define CPUTS(outstr) cputs(CC_I2C, outstr) @@ -279,8 +279,7 @@ exit: return rv; } - -static int i2c_freq_changed(void) +static void i2c_freq_changed(void) { int freq = clock_get_freq(); int i; @@ -308,8 +307,6 @@ static int i2c_freq_changed(void) LM4_I2C_MTPR(i2c_ports[i].port) = tpr; } - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_FREQ_CHANGE, i2c_freq_changed, HOOK_PRIO_DEFAULT + 1); @@ -475,8 +472,7 @@ static void configure_gpio(void) #endif } - -static int i2c_init(void) +static void i2c_init(void) { volatile uint32_t scratch __attribute__((unused)); uint32_t mask = 0; @@ -510,7 +506,5 @@ static int i2c_init(void) task_enable_irq(LM4_IRQ_I2C3); task_enable_irq(LM4_IRQ_I2C4); task_enable_irq(LM4_IRQ_I2C5); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index c22b967661..d34793cc80 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -607,13 +607,13 @@ static void lpc_interrupt(void) DECLARE_IRQ(LM4_IRQ_LPC, lpc_interrupt, 2); -/* Preserve event masks across a sysjump */ -static int lpc_sysjump(void) +/** + * Preserve event masks across a sysjump. + */ +static void lpc_sysjump(void) { system_add_jump_tag(LPC_SYSJUMP_TAG, 1, sizeof(event_mask), event_mask); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_SYSJUMP, lpc_sysjump, HOOK_PRIO_DEFAULT); @@ -632,8 +632,7 @@ static void lpc_post_sysjump(void) memcpy(event_mask, prev_mask, sizeof(event_mask)); } - -static int lpc_init(void) +static void lpc_init(void) { volatile uint32_t scratch __attribute__((unused)); @@ -784,8 +783,6 @@ static int lpc_init(void) /* Update host events now that we can copy them to memmap */ update_host_event_status(); - - return EC_SUCCESS; } /* * Set prio to higher than default so other inits can initialize their @@ -793,8 +790,7 @@ static int lpc_init(void) */ DECLARE_HOOK(HOOK_INIT, lpc_init, HOOK_PRIO_INIT_LPC); - -static int lpc_resume(void) +static void lpc_resume(void) { /* Mask all host events until the host unmasks them itself. */ lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, 0); @@ -803,8 +799,6 @@ static int lpc_resume(void) /* Store port 80 event so we know where resume happened */ port_80_write(PORT_80_EVENT_RESUME); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, lpc_resume, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/onewire.c b/chip/lm4/onewire.c index d505ff5c08..08fa66a372 100644 --- a/chip/lm4/onewire.c +++ b/chip/lm4/onewire.c @@ -5,7 +5,7 @@ /* 1-wire interface module for Chrome EC */ -#include "board.h" +#include "common.h" #include "gpio.h" #include "hooks.h" #include "registers.h" @@ -131,12 +131,9 @@ static void configure_gpio(void) LM4_GPIO_ODR(LM4_GPIO_H) |= ONEWIRE_PIN; } - -static int onewire_init(void) +static void onewire_init(void) { /* Configure GPIOs */ configure_gpio(); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, onewire_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c index ddbb1a9a6c..ff56f7ec47 100644 --- a/chip/lm4/peci.c +++ b/chip/lm4/peci.c @@ -7,7 +7,7 @@ #include "chipset.h" #include "clock.h" -#include "config.h" +#include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" @@ -93,8 +93,7 @@ int peci_temp_sensor_get_val(int idx, int *temp_ptr) return EC_SUCCESS; } - -static int peci_freq_changed(void) +static void peci_freq_changed(void) { int freq = clock_get_freq(); int baud; @@ -115,8 +114,6 @@ static int peci_freq_changed(void) LM4_PECI_CTL = ((PECI_TJMAX + 273) << 22) | 0x0001 | (PECI_RETRY_COUNT << 12) | (PECI_ERROR_BYPASS << 11); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_FREQ_CHANGE, peci_freq_changed, HOOK_PRIO_DEFAULT - 1); @@ -141,7 +138,7 @@ DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp, /*****************************************************************************/ /* Initialization */ -static int peci_init(void) +static void peci_init(void) { volatile uint32_t scratch __attribute__((unused)); int i; @@ -159,7 +156,5 @@ static int peci_init(void) /* Initialize temperature reading buffer to a sane value. */ for (i = 0; i < TEMP_AVG_LENGTH; ++i) temp_vals[i] = 300; /* 27 C */ - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, peci_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index a928f4895b..12e02e96b5 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -216,7 +216,7 @@ static void lid_switch_open(uint64_t tnow) CPRINTF("[%T PB lid open]\n"); debounced_lid_open = 1; *memmap_switches |= EC_SWITCH_LID_OPEN; - hook_notify(HOOK_LID_CHANGE, 0); + hook_notify(HOOK_LID_CHANGE); update_backlight(); host_set_single_event(EC_HOST_EVENT_LID_OPEN); @@ -242,7 +242,7 @@ static void lid_switch_close(uint64_t tnow) CPRINTF("[%T PB lid close]\n"); debounced_lid_open = 0; *memmap_switches &= ~EC_SWITCH_LID_OPEN; - hook_notify(HOOK_LID_CHANGE, 0); + hook_notify(HOOK_LID_CHANGE); update_backlight(); host_set_single_event(EC_HOST_EVENT_LID_CLOSED); } @@ -462,7 +462,7 @@ void power_button_task(void) /* Handle AC state changes */ if (ac_changed) { ac_changed = 0; - hook_notify(HOOK_AC_CHANGE, 0); + hook_notify(HOOK_AC_CHANGE); } /* Handle debounce timeouts for power button and lid switch */ @@ -522,7 +522,7 @@ void power_button_task(void) /*****************************************************************************/ /* Hooks */ -static int power_button_init(void) +static void power_button_init(void) { /* Set up memory-mapped switch positions */ memmap_switches = host_get_memmap(EC_MEMMAP_SWITCHES); @@ -545,12 +545,9 @@ static int power_button_init(void) gpio_enable_interrupt(GPIO_POWER_BUTTONn); gpio_enable_interrupt(GPIO_RECOVERYn); gpio_enable_interrupt(GPIO_WRITE_PROTECT); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, power_button_init, HOOK_PRIO_DEFAULT); - void power_button_interrupt(enum gpio_signal signal) { /* Reset debounce time for the changed signal */ diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c index c3c8be73a4..1ed448b74e 100644 --- a/chip/lm4/pwm.c +++ b/chip/lm4/pwm.c @@ -308,7 +308,7 @@ DECLARE_CONSOLE_COMMAND(kblight, command_kblight, /*****************************************************************************/ /* Initialization */ -static int pwm_init(void) +static void pwm_init(void) { volatile uint32_t scratch __attribute__((unused)); const struct pwm_state *prev; @@ -378,12 +378,10 @@ static int pwm_init(void) mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_FAN); for (i = 0; i < EC_FAN_SPEED_ENTRIES; i++) mapped[i] = EC_FAN_SPEED_NOT_PRESENT; - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT); -static int pwm_preserve_state(void) +static void pwm_preserve_state(void) { struct pwm_state state; @@ -394,30 +392,25 @@ static int pwm_preserve_state(void) system_add_jump_tag(PWM_SYSJUMP_TAG, PWM_HOOK_VERSION, sizeof(state), &state); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_SYSJUMP, pwm_preserve_state, HOOK_PRIO_DEFAULT); -static int pwm_resume(void) +static void pwm_resume(void) { pwm_enable_fan(1); - return EC_SUCCESS; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, pwm_resume, HOOK_PRIO_DEFAULT); -static int pwm_suspend(void) +static void pwm_suspend(void) { pwm_enable_fan(0); pwm_set_fan_target_rpm(0); pwm_set_keyboard_backlight(0); - return EC_SUCCESS; } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, pwm_suspend, HOOK_PRIO_DEFAULT); -static int pwm_shutdown(void) +static void pwm_shutdown(void) { pwm_set_keyboard_backlight(0); - return EC_SUCCESS; } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pwm_shutdown, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/watchdog.c b/chip/lm4/watchdog.c index e86cb15852..58cabf80f9 100644 --- a/chip/lm4/watchdog.c +++ b/chip/lm4/watchdog.c @@ -80,20 +80,16 @@ void watchdog_reload(void) LM4_WATCHDOG_LOCK(0) = 0xdeaddead; } - -static int watchdog_freq_changed(void) +static void watchdog_freq_changed(void) { /* Set the timeout period */ watchdog_period = WATCHDOG_PERIOD_MS * (clock_get_freq() / 1000); /* Reload the watchdog timer now */ watchdog_reload(); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_FREQ_CHANGE, watchdog_freq_changed, HOOK_PRIO_DEFAULT); - int watchdog_init(void) { volatile uint32_t scratch __attribute__((unused)); diff --git a/chip/stm32/adc.c b/chip/stm32/adc.c index 12247477b9..c91a5148cb 100644 --- a/chip/stm32/adc.c +++ b/chip/stm32/adc.c @@ -4,7 +4,7 @@ */ #include "adc.h" -#include "board.h" +#include "common.h" #include "console.h" #include "dma.h" #include "hooks.h" @@ -141,7 +141,7 @@ int adc_read_all_channels(int *data) return EC_SUCCESS; } -static int adc_init(void) +static void adc_init(void) { /* * Enable ADC clock. @@ -174,8 +174,6 @@ static int adc_init(void) */ STM32_ADC_SMPR1 = 0; STM32_ADC_SMPR2 = 0; - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT); diff --git a/chip/stm32/flash-stm32f100.c b/chip/stm32/flash-stm32f100.c index 2d2b3647b3..88284d247d 100644 --- a/chip/stm32/flash-stm32f100.c +++ b/chip/stm32/flash-stm32f100.c @@ -696,7 +696,7 @@ DECLARE_CONSOLE_COMMAND(fakewp, command_set_fake_wp, /*****************************************************************************/ /* Hooks */ -static int flash_preserve_state(void) +static void flash_preserve_state(void) { struct flash_wp_state state; @@ -704,6 +704,5 @@ static int flash_preserve_state(void) system_add_jump_tag(FLASH_SYSJUMP_TAG, FLASH_HOOK_VERSION, sizeof(state), &state); - return EC_SUCCESS; } DECLARE_HOOK(HOOK_SYSJUMP, flash_preserve_state, HOOK_PRIO_DEFAULT); diff --git a/chip/stm32/gpio-stm32f100.c b/chip/stm32/gpio-stm32f100.c index 2641db612c..5d91ff343e 100644 --- a/chip/stm32/gpio-stm32f100.c +++ b/chip/stm32/gpio-stm32f100.c @@ -5,7 +5,7 @@ /* GPIO module for Chrome EC */ -#include "board.h" +#include "config.h" #include "console.h" #include "gpio.h" #include "hooks.h" @@ -136,8 +136,7 @@ int gpio_pre_init(void) return EC_SUCCESS; } - -int gpio_init(void) +void gpio_init(void) { /* Enable IRQs now that pins are set up */ task_enable_irq(STM32_IRQ_EXTI0); @@ -147,12 +146,9 @@ int gpio_init(void) task_enable_irq(STM32_IRQ_EXTI4); task_enable_irq(STM32_IRQ_EXTI9_5); task_enable_irq(STM32_IRQ_EXTI15_10); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT); - uint16_t *gpio_get_level_reg(enum gpio_signal signal, uint32_t *mask) { *mask = gpio_list[signal].mask; diff --git a/chip/stm32/gpio-stm32l15x.c b/chip/stm32/gpio-stm32l15x.c index fcf2a66e13..3984eccaf6 100644 --- a/chip/stm32/gpio-stm32l15x.c +++ b/chip/stm32/gpio-stm32l15x.c @@ -5,7 +5,7 @@ /* GPIO module for Chrome EC */ -#include "board.h" +#include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" @@ -94,8 +94,7 @@ int gpio_pre_init(void) return EC_SUCCESS; } - -static int gpio_init(void) +static void gpio_init(void) { /* Enable IRQs now that pins are set up */ task_enable_irq(STM32_IRQ_EXTI0); @@ -105,12 +104,9 @@ static int gpio_init(void) task_enable_irq(STM32_IRQ_EXTI4); task_enable_irq(STM32_IRQ_EXTI9_5); task_enable_irq(STM32_IRQ_EXTI15_10); - - return EC_SUCCESS; } DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT); - void gpio_set_alternate_function(int port, int mask, int func) { int bit; diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 5acd5c40f9..fe8655968c 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -3,13 +3,11 @@ * found in the LICENSE file. */ -#include "board.h" #include "chipset.h" #include "clock.h" #include "common.h" #include "console.h" #include "dma.h" -#include "ec_commands.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" @@ -496,7 +494,7 @@ static int i2c_init_port(unsigned int port) return EC_SUCCESS; } -static int i2c_init(void) +static void i2c_init(void) { int rc = 0; @@ -511,8 +509,6 @@ static int i2c_init(void) task_enable_irq(STM32_IRQ_I2C2_EV); task_enable_irq(STM32_IRQ_I2C2_ER); } - - return rc; } DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT); |