summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/pc80/rtc/option.c22
-rw-r--r--src/include/option.h8
2 files changed, 15 insertions, 15 deletions
diff --git a/src/drivers/pc80/rtc/option.c b/src/drivers/pc80/rtc/option.c
index 5cc5ea558e..cc4138bfd7 100644
--- a/src/drivers/pc80/rtc/option.c
+++ b/src/drivers/pc80/rtc/option.c
@@ -84,7 +84,7 @@ static struct cmos_entries *find_cmos_entry(struct cmos_option_table *ct, const
return NULL;
}
-enum cb_err cmos_get_option(void *dest, const char *name)
+enum cb_err cmos_get_uint_option(unsigned int *dest, const char *name)
{
struct cmos_option_table *ct;
struct cmos_entries *ce;
@@ -99,6 +99,11 @@ enum cb_err cmos_get_option(void *dest, const char *name)
return CB_CMOS_OPTION_NOT_FOUND;
}
+ if (ce->config != 'e' && ce->config != 'h') {
+ printk(BIOS_ERR, "ERROR: CMOS option '%s' is not of integer type.\n", name);
+ return CB_ERR_ARG;
+ }
+
if (!cmos_checksum_valid(LB_CKS_RANGE_START, LB_CKS_RANGE_END, LB_CKS_LOC))
return CB_CMOS_CHECKSUM_INVALID;
@@ -149,11 +154,10 @@ static enum cb_err set_cmos_value(unsigned long bit, unsigned long length,
return CB_SUCCESS;
}
-enum cb_err cmos_set_option(const char *name, void *value)
+enum cb_err cmos_set_uint_option(const char *name, unsigned int *value)
{
struct cmos_option_table *ct;
struct cmos_entries *ce;
- unsigned long length;
ct = get_cmos_layout();
if (!ct)
@@ -165,16 +169,12 @@ enum cb_err cmos_set_option(const char *name, void *value)
return CB_CMOS_OPTION_NOT_FOUND;
}
- length = ce->length;
- if (ce->config == 's') {
- length = MAX(strlen((const char *)value) * 8, ce->length - 8);
- /* make sure the string is null terminated */
- if (set_cmos_value(ce->bit + ce->length - 8, 8, &(u8[]){0})
- != CB_SUCCESS)
- return CB_CMOS_ACCESS_ERROR;
+ if (ce->config != 'e' && ce->config != 'h') {
+ printk(BIOS_ERR, "ERROR: CMOS option '%s' is not of integer type.\n", name);
+ return CB_ERR_ARG;
}
- if (set_cmos_value(ce->bit, length, value) != CB_SUCCESS)
+ if (set_cmos_value(ce->bit, ce->length, value) != CB_SUCCESS)
return CB_CMOS_ACCESS_ERROR;
return CB_SUCCESS;
diff --git a/src/include/option.h b/src/include/option.h
index e7db02e88a..8316bd842c 100644
--- a/src/include/option.h
+++ b/src/include/option.h
@@ -7,13 +7,13 @@
void sanitize_cmos(void);
-enum cb_err cmos_set_option(const char *name, void *val);
-enum cb_err cmos_get_option(void *dest, const char *name);
+enum cb_err cmos_set_uint_option(const char *name, unsigned int *value);
+enum cb_err cmos_get_uint_option(unsigned int *dest, const char *name);
static inline enum cb_err set_uint_option(const char *name, unsigned int value)
{
if (CONFIG(USE_OPTION_TABLE))
- return cmos_set_option(name, &value);
+ return cmos_set_uint_option(name, &value);
return CB_CMOS_OTABLE_DISABLED;
}
@@ -22,7 +22,7 @@ static inline int get_uint_option(const char *name, const unsigned int fallback)
{
if (CONFIG(USE_OPTION_TABLE)) {
unsigned int value = 0;
- if (cmos_get_option(&value, name) == CB_SUCCESS)
+ if (cmos_get_uint_option(&value, name) == CB_SUCCESS)
return value;
}
return fallback;