global: Fix usage of get_option() to make use of CB_CMOS_ codes

Do not directly check the return value of get_option, but instead compare
the returned value against a CB_CMOS_ error code, or against CB_SUCCESS.

Change-Id: I2fa7761d13ebb5e9b4606076991a43f18ae370ad
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-on: http://review.coreboot.org/4266
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Alexandru Gagniuc 2013-11-23 19:22:53 -06:00 committed by Stefan Reinauer
parent bcfcfa4473
commit 72dccce0c9
18 changed files with 37 additions and 41 deletions

View File

@ -24,6 +24,7 @@
#ifndef __PRE_RAM__ #ifndef __PRE_RAM__
#include <string.h> #include <string.h>
#include <types.h>
/* /*
* FIXME: get_option() needs to be abstracted better so that other non-volatile * FIXME: get_option() needs to be abstracted better so that other non-volatile
@ -33,14 +34,15 @@
#if CONFIG_USE_OPTION_TABLE #if CONFIG_USE_OPTION_TABLE
#include <pc80/mc146818rtc.h> #include <pc80/mc146818rtc.h>
#else #else
static inline int get_option(void *dest, const char *name) { return -1; } static inline enum cb_err get_option(void *dest, const char *name)
{ return CB_CMOS_OTABLE_DISABLED; }
#endif #endif
/* initialize the console */ /* initialize the console */
void console_init(void) void console_init(void)
{ {
struct console_driver *driver; struct console_driver *driver;
if(get_option(&console_loglevel, "debug_level")) if(get_option(&console_loglevel, "debug_level") != CB_SUCCESS)
console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL; console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
for(driver = console_drivers; driver < econsole_drivers; driver++) { for(driver = console_drivers; driver < econsole_drivers; driver++) {

View File

@ -245,10 +245,8 @@ static void init_ecc_memory(unsigned node_id)
/* See if we scrubbing should be enabled */ /* See if we scrubbing should be enabled */
enable_scrubbing = 1; enable_scrubbing = 1;
if( get_option(&enable_scrubbing, "hw_scrubber") < 0 ) if (get_option(&enable_scrubbing, "hw_scrubber") != CB_SUCCESS)
{
enable_scrubbing = CONFIG_HW_SCRUBBER; enable_scrubbing = CONFIG_HW_SCRUBBER;
}
/* Enable cache scrubbing at the lowest possible rate */ /* Enable cache scrubbing at the lowest possible rate */
if (enable_scrubbing) { if (enable_scrubbing) {

View File

@ -172,14 +172,14 @@ static void h8_enable(device_t dev)
h8_trackpoint_enable(conf->trackpoint_enable); h8_trackpoint_enable(conf->trackpoint_enable);
h8_usb_power_enable(1); h8_usb_power_enable(1);
if (!get_option(&val, "volume")) if (get_option(&val, "volume") == CB_SUCCESS)
ec_write(H8_VOLUME_CONTROL, val); ec_write(H8_VOLUME_CONTROL, val);
if (!get_option(&val, "bluetooth")) if (get_option(&val, "bluetooth") == CB_SUCCESS)
h8_bluetooth_enable(val); h8_bluetooth_enable(val);
if (!get_option(&val, "first_battery")) { if (get_option(&val, "first_battery") == CB_SUCCESS) {
tmp = ec_read(H8_CONFIG3); tmp = ec_read(H8_CONFIG3);
tmp &= ~(1 << 4); tmp &= ~(1 << 4);
tmp |= (val & 1)<< 4; tmp |= (val & 1)<< 4;

View File

@ -113,7 +113,7 @@ static void enable_dev(device_t dev)
pmh7_backlight_enable(conf->backlight_enable); pmh7_backlight_enable(conf->backlight_enable);
pmh7_dock_event_enable(conf->dock_event_enable); pmh7_dock_event_enable(conf->dock_event_enable);
if (!get_option(&val, "touchpad")) if (get_option(&val, "touchpad") == CB_SUCCESS)
pmh7_touchpad_enable(val); pmh7_touchpad_enable(val);
} }

View File

@ -123,9 +123,8 @@ void uart_init(void)
b_index &= 7; b_index &= 7;
div = divisor[b_index]; div = divisor[b_index];
#else #else
if (get_option(&b_index, "baud_rate") == 0) { if (get_option(&b_index, "baud_rate") == CB_SUCCESS)
div = divisor[b_index]; div = divisor[b_index];
}
#endif #endif
#endif #endif

View File

@ -118,9 +118,8 @@ u32 uart_mem_init(void)
b_index &= 7; b_index &= 7;
uart_baud = baud[b_index]; uart_baud = baud[b_index];
#else #else
if (get_option(&b_index, "baud_rate") == 0) { if (get_option(&b_index, "baud_rate") == CB_SUCCESS)
uart_baud = baud[b_index]; uart_baud = baud[b_index];
}
#endif #endif
#endif #endif

View File

@ -117,18 +117,18 @@ static void hwm_setup(void)
int cpufan_speed = 0, sysfan_speed = 0; int cpufan_speed = 0, sysfan_speed = 0;
int cpufan_temperature = 0, sysfan_temperature = 0; int cpufan_temperature = 0, sysfan_temperature = 0;
if (get_option(&cpufan_control, "cpufan_cruise_control") < 0) if (get_option(&cpufan_control, "cpufan_cruise_control") != CB_SUCCESS)
cpufan_control = FAN_CRUISE_CONTROL_DISABLED; cpufan_control = FAN_CRUISE_CONTROL_DISABLED;
if (get_option(&cpufan_speed, "cpufan_speed") < 0) if (get_option(&cpufan_speed, "cpufan_speed") != CB_SUCCESS)
cpufan_speed = FAN_SPEED_5625; cpufan_speed = FAN_SPEED_5625;
//if (get_option(&cpufan_temperature, "cpufan_temperature") < 0) //if (get_option(&cpufan_temperature, "cpufan_temperature") != CB_SUCCESS)
// cpufan_temperature = FAN_TEMPERATURE_30DEGC; // cpufan_temperature = FAN_TEMPERATURE_30DEGC;
if (get_option(&sysfan_control, "sysfan_cruise_control") < 0) if (get_option(&sysfan_control, "sysfan_cruise_control") != CB_SUCCESS)
sysfan_control = FAN_CRUISE_CONTROL_DISABLED; sysfan_control = FAN_CRUISE_CONTROL_DISABLED;
if (get_option(&sysfan_speed, "sysfan_speed") < 0) if (get_option(&sysfan_speed, "sysfan_speed") != CB_SUCCESS)
sysfan_speed = FAN_SPEED_5625; sysfan_speed = FAN_SPEED_5625;
//if (get_option(&sysfan_temperature, "sysfan_temperature") < 0) //if (get_option(&sysfan_temperature, "sysfan_temperature") != CB_SUCCESS)
// sysfan_temperature = FAN_TEMPERATURE_30DEGC; // sysfan_temperature = FAN_TEMPERATURE_30DEGC;
// hwm_write(0x31, 0x20); // AVCC high limit // hwm_write(0x31, 0x20); // AVCC high limit

View File

@ -124,18 +124,18 @@ static void hwm_setup(void)
int cpufan_speed = 0, sysfan_speed = 0; int cpufan_speed = 0, sysfan_speed = 0;
int cpufan_temperature = 0, sysfan_temperature = 0; int cpufan_temperature = 0, sysfan_temperature = 0;
if (get_option(&cpufan_control, "cpufan_cruise_control") < 0) if (get_option(&cpufan_control, "cpufan_cruise_control") != CB_SUCCESS)
cpufan_control = FAN_CRUISE_CONTROL_DISABLED; cpufan_control = FAN_CRUISE_CONTROL_DISABLED;
if (get_option(&cpufan_speed, "cpufan_speed") < 0) if (get_option(&cpufan_speed, "cpufan_speed") != CB_SUCCESS)
cpufan_speed = FAN_SPEED_5625; cpufan_speed = FAN_SPEED_5625;
//if (get_option(&cpufan_temperature, "cpufan_temperature") < 0) //if (get_option(&cpufan_temperature, "cpufan_temperature") != CB_SUCCESS)
// cpufan_temperature = FAN_TEMPERATURE_30DEGC; // cpufan_temperature = FAN_TEMPERATURE_30DEGC;
if (get_option(&sysfan_control, "sysfan_cruise_control") < 0) if (get_option(&sysfan_control, "sysfan_cruise_control") != CB_SUCCESS)
sysfan_control = FAN_CRUISE_CONTROL_DISABLED; sysfan_control = FAN_CRUISE_CONTROL_DISABLED;
if (get_option(&sysfan_speed, "sysfan_speed") < 0) if (get_option(&sysfan_speed, "sysfan_speed") != CB_SUCCESS)
sysfan_speed = FAN_SPEED_5625; sysfan_speed = FAN_SPEED_5625;
//if (get_option(&sysfan_temperature, "sysfan_temperature") < 0) //if (get_option(&sysfan_temperature, "sysfan_temperature") != CB_SUCCESS)
// sysfan_temperature = FAN_TEMPERATURE_30DEGC; // sysfan_temperature = FAN_TEMPERATURE_30DEGC;
// hwm_write(0x31, 0x20); // AVCC high limit // hwm_write(0x31, 0x20); // AVCC high limit

View File

@ -163,7 +163,7 @@ static void mainboard_enable(device_t dev)
verb_setup(); verb_setup();
unsigned disable = 0; unsigned disable = 0;
if ((get_option(&disable, "ethernet1") == 0) && disable) { if ((get_option(&disable, "ethernet1") == CB_SUCCESS) && disable) {
device_t nic = dev_find_slot(0, PCI_DEVFN(0x1c, 2)); device_t nic = dev_find_slot(0, PCI_DEVFN(0x1c, 2));
if (nic) { if (nic) {
printk(BIOS_DEBUG, "DISABLE FIRST NIC!\n"); printk(BIOS_DEBUG, "DISABLE FIRST NIC!\n");
@ -171,7 +171,7 @@ static void mainboard_enable(device_t dev)
} }
} }
disable = 0; disable = 0;
if ((get_option(&disable, "ethernet2") == 0) && disable) { if ((get_option(&disable, "ethernet2") == CB_SUCCESS) && disable) {
device_t nic = dev_find_slot(0, PCI_DEVFN(0x1c, 3)); device_t nic = dev_find_slot(0, PCI_DEVFN(0x1c, 3));
if (nic) { if (nic) {
printk(BIOS_DEBUG, "DISABLE SECOND NIC!\n"); printk(BIOS_DEBUG, "DISABLE SECOND NIC!\n");

View File

@ -78,7 +78,7 @@ static void mainboard_enable(device_t dev)
ec_write(0x0c, 0x08); ec_write(0x0c, 0x08);
ec_write(0x0c, inb(0x164c) & 8 ? 0x89 : 0x09); ec_write(0x0c, inb(0x164c) & 8 ? 0x89 : 0x09);
if (get_option(&defaults_loaded, "cmos_defaults_loaded") < 0) { if (get_option(&defaults_loaded, "cmos_defaults_loaded") != CB_SUCCESS) {
printk(BIOS_INFO, "failed to get cmos_defaults_loaded"); printk(BIOS_INFO, "failed to get cmos_defaults_loaded");
defaults_loaded = 0; defaults_loaded = 0;
} }

View File

@ -448,11 +448,11 @@ static void set_thermal_config(void)
cpu_fan_control = cpu_fan_control_defaults; cpu_fan_control = cpu_fan_control_defaults;
case_fan_control = case_fan_control_defaults; case_fan_control = case_fan_control_defaults;
if( get_option(&byte, "cpu_fan_control") == -4 ) { if (get_option(&byte, "cpu_fan_control") == CB_CMOS_CHECKSUM_INVALID) {
printk(BIOS_WARNING, "%s: CMOS checksum invalid, keeping default values\n",__func__); printk(BIOS_WARNING, "%s: CMOS checksum invalid, keeping default values\n",__func__);
} else { } else {
// get all the options needed // get all the options needed
if( get_option(&byte, "cpu_fan_control") == 0 ) if( get_option(&byte, "cpu_fan_control") == CB_SUCCESS )
cpu_fan_control.enable = byte ? 1 : 0; cpu_fan_control.enable = byte ? 1 : 0;
get_option(&cpu_fan_control.polarity, "cpu_fan_polarity"); get_option(&cpu_fan_control.polarity, "cpu_fan_polarity");
@ -461,7 +461,7 @@ static void set_thermal_config(void)
get_option(&cpu_fan_control.pwm_min, "cpu_dutycycle_min"); get_option(&cpu_fan_control.pwm_min, "cpu_dutycycle_min");
get_option(&cpu_fan_control.pwm_max, "cpu_dutycycle_max"); get_option(&cpu_fan_control.pwm_max, "cpu_dutycycle_max");
if( get_option(&byte, "chassis_fan_control") == 0) if( get_option(&byte, "chassis_fan_control") == CB_SUCCESS)
case_fan_control.enable = byte ? 1 : 0; case_fan_control.enable = byte ? 1 : 0;
get_option(&case_fan_control.polarity, "chassis_fan_polarity"); get_option(&case_fan_control.polarity, "chassis_fan_polarity");
get_option(&case_fan_control.t_min, "chassis_t_min"); get_option(&case_fan_control.t_min, "chassis_t_min");
@ -816,7 +816,7 @@ static void mainboard_init(device_t dev)
dev_name(dev), dev_path(dev), dev->subsystem_vendor, dev->subsystem_device, __func__); dev_name(dev), dev_path(dev), dev->subsystem_vendor, dev->subsystem_device, __func__);
#if CONFIG_PCI_OPTION_ROM_RUN_REALMODE #if CONFIG_PCI_OPTION_ROM_RUN_REALMODE
if( get_option(&int15_func.regs.func00_LCD_panel_id, "lcd_panel_id") < 0 ) if (get_option(&int15_func.regs.func00_LCD_panel_id, "lcd_panel_id") != CB_SUCCESS)
int15_func.regs.func00_LCD_panel_id = PANEL_TABLE_ID_NO; int15_func.regs.func00_LCD_panel_id = PANEL_TABLE_ID_NO;
int15_func.regs.func05_TV_standard = TV_MODE_NO; int15_func.regs.func05_TV_standard = TV_MODE_NO;
install_INT15_function_extensions(&int15_func); install_INT15_function_extensions(&int15_func);

View File

@ -48,10 +48,8 @@ static void mcf3_read_resources(device_t dev)
} }
iommu = 1; iommu = 1;
if( get_option(&iommu, "iommu") < 0 ) if (get_option(&iommu, "iommu") != CB_SUCCESS)
{
iommu = CONFIG_IOMMU; iommu = CONFIG_IOMMU;
}
if (iommu) { if (iommu) {
/* Add a GART aperture resource */ /* Add a GART aperture resource */

View File

@ -94,7 +94,7 @@ static void gma_func1_init(struct device *dev)
pci_write_config32(dev, PCI_COMMAND, reg32 | pci_write_config32(dev, PCI_COMMAND, reg32 |
PCI_COMMAND_MASTER | PCI_COMMAND_IO); PCI_COMMAND_MASTER | PCI_COMMAND_IO);
if (!get_option(&val, "tft_brightness")) if (get_option(&val, "tft_brightness") == CB_SUCCESS)
pci_write_config8(dev, 0xf4, val); pci_write_config8(dev, 0xf4, val);
else else
pci_write_config8(dev, 0xf4, 0xff); pci_write_config8(dev, 0xf4, 0xff);

View File

@ -119,7 +119,7 @@ static void sata_init(struct device *dev)
pci_write_config8(dev, 0x40, byte); pci_write_config8(dev, 0x40, byte);
// 1 means IDE, 0 means AHCI // 1 means IDE, 0 means AHCI
if( get_option(&i, "sata_mode") < 0 ) { if (get_option(&i, "sata_mode") != CB_SUCCESS) {
// no cmos option // no cmos option
i = CONFIG_SATA_MODE; i = CONFIG_SATA_MODE;
} }

View File

@ -116,7 +116,7 @@ static void i82801dx_power_options(device_t dev)
* *
* If the option is not existent (Laptops), use MAINBOARD_POWER_ON. * If the option is not existent (Laptops), use MAINBOARD_POWER_ON.
*/ */
if (get_option(&pwr_on, "power_on_after_fail") < 0) if (get_option(&pwr_on, "power_on_after_fail") != CB_SUCCESS)
pwr_on = MAINBOARD_POWER_ON; pwr_on = MAINBOARD_POWER_ON;
reg8 = pci_read_config8(dev, GEN_PMCON_3); reg8 = pci_read_config8(dev, GEN_PMCON_3);

View File

@ -175,7 +175,7 @@ static void i82801gx_power_options(device_t dev)
* *
* If the option is not existent (Laptops), use MAINBOARD_POWER_ON. * If the option is not existent (Laptops), use MAINBOARD_POWER_ON.
*/ */
if (get_option(&pwr_on, "power_on_after_fail") < 0) if (get_option(&pwr_on, "power_on_after_fail") != CB_SUCCESS)
pwr_on = MAINBOARD_POWER_ON; pwr_on = MAINBOARD_POWER_ON;
reg8 = pci_read_config8(dev, GEN_PMCON_3); reg8 = pci_read_config8(dev, GEN_PMCON_3);

View File

@ -181,7 +181,7 @@ static void i82801ix_power_options(device_t dev)
* *
* If the option is not existent (Laptops), use MAINBOARD_POWER_ON. * If the option is not existent (Laptops), use MAINBOARD_POWER_ON.
*/ */
if (get_option(&pwr_on, "power_on_after_fail") < 0) if (get_option(&pwr_on, "power_on_after_fail") != CB_SUCCESS)
pwr_on = MAINBOARD_POWER_ON; pwr_on = MAINBOARD_POWER_ON;
reg8 = pci_read_config8(dev, D31F0_GEN_PMCON_3); reg8 = pci_read_config8(dev, D31F0_GEN_PMCON_3);

View File

@ -543,7 +543,7 @@ static void vt8237_common_init(struct device *dev)
} }
/* configure power state of the board after loss of power */ /* configure power state of the board after loss of power */
if (get_option(&pwr_on, "power_on_after_fail") < 0) if (get_option(&pwr_on, "power_on_after_fail") != CB_SUCCESS)
pwr_on = 1; pwr_on = 1;
enables = pci_read_config8(dev, 0x58); enables = pci_read_config8(dev, 0x58);
pci_write_config8(dev, 0x58, enables & ~0x02); pci_write_config8(dev, 0x58, enables & ~0x02);