mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 02:20:48 +00:00
We've been declaring a bunch of statically-sized arrays:
extern struct foo_t foo[FOO_COUNT];
And then initializing them like so:
struct foo_t foo[FOO_COUNT] = {
/* blah */
};
That only catches cases where we initialize with too many entries. It
doesn't catch cases where we haven't initialized enough. This change tests
for both cases like so:
extern struct foo_t foo[];
struct foo_t foo[] = {
/* blah */
};
BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT);
The affected arrays are:
adc_channels[ADC_CH_COUNT]
gpio_list[GPIO_COUNT]
temp_sensors[TEMP_SENSOR_COUNT]
x86_signal_list[X86_SIGNAL_COUNT]
i2c_ports[I2C_PORTS_USED]
BUG=chrome-os-partner:18343
BRANCH=falco,peppy
TEST=build all platforms
All platforms should still build, all tests should still pass.
Change-Id: Ibb16dc3201f32df7cdc875648e89ba4ffb09f733
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63833
Reviewed-by: Randall Spangler <rspangler@chromium.org>
77 lines
1.5 KiB
C
77 lines
1.5 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Mock temperature sensor module for Chrome EC */
|
|
|
|
#include "common.h"
|
|
#include "console.h"
|
|
#include "temp_sensor.h"
|
|
#include "timer.h"
|
|
#include "util.h"
|
|
|
|
static int temp_val[TEMP_SENSOR_TYPE_COUNT];
|
|
|
|
int temp_sensor_powered(enum temp_sensor_id id)
|
|
{
|
|
/* Always powered */
|
|
return 1;
|
|
}
|
|
|
|
|
|
int temp_sensor_read(enum temp_sensor_id id)
|
|
{
|
|
return temp_val[temp_sensors[id].type];
|
|
}
|
|
|
|
|
|
void temp_sensor_task(void)
|
|
{
|
|
/* Do nothing */
|
|
while (1)
|
|
sleep(5);
|
|
}
|
|
|
|
|
|
static int command_set_temp(int argc, char **argv, int type)
|
|
{
|
|
char *e;
|
|
int t;
|
|
|
|
ASSERT(argc == 2);
|
|
t = strtoi(argv[1], &e, 0);
|
|
temp_val[type] = t;
|
|
return EC_SUCCESS;
|
|
}
|
|
|
|
|
|
static int command_set_cpu_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CPU);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setcputemp, command_set_cpu_temp,
|
|
"value",
|
|
"Set mock CPU temperature value",
|
|
NULL);
|
|
|
|
|
|
static int command_set_board_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_BOARD);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setboardtemp, command_set_board_temp,
|
|
"value",
|
|
"Set mock board temperature value",
|
|
NULL);
|
|
|
|
|
|
static int command_set_case_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CASE);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setcasetemp, command_set_case_temp,
|
|
"value",
|
|
"Set mock case temperature value",
|
|
NULL);
|