diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 15:39:07 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-01 07:50:27 +0000 |
commit | 2546846c3ff4263b4d70ef5c0f2179fcfa0a9dd8 (patch) | |
tree | fdc65c2edf378c1fc3fbd0ecc7a3c2984171280f | |
parent | 8c1746c38879b2db38f8df2c465a536a56e00d10 (diff) | |
download | chrome-ec-2546846c3ff4263b4d70ef5c0f2179fcfa0a9dd8.tar.gz |
zephyr/shim/src/temp_sensors.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: Ie6711266b9c95c77c9d1a0369a4b971c9ab86073
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730917
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/shim/src/temp_sensors.c | 124 |
1 files changed, 59 insertions, 65 deletions
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c index 4d8ff28945..e8332c16e5 100644 --- a/zephyr/shim/src/temp_sensors.c +++ b/zephyr/shim/src/temp_sensors.c @@ -15,20 +15,18 @@ #define GET_POWER_GOOD_PROP(node_id) DT_PROP(node_id, power_good_pin) -#define GET_POWER_GOOD_DEV(node_id) \ - DEVICE_DT_GET(DT_GPIO_CTLR(GET_POWER_GOOD_PROP(node_id), \ - gpios)) +#define GET_POWER_GOOD_DEV(node_id) \ + DEVICE_DT_GET(DT_GPIO_CTLR(GET_POWER_GOOD_PROP(node_id), gpios)) -#define GET_POWER_GOOD_PIN(node_id) DT_GPIO_PIN(GET_POWER_GOOD_PROP(node_id), \ - gpios) +#define GET_POWER_GOOD_PIN(node_id) \ + DT_GPIO_PIN(GET_POWER_GOOD_PROP(node_id), gpios) #if ANY_INST_HAS_POWER_GOOD_PIN -#define FILL_POWER_GOOD(node_id) \ -COND_CODE_1(DT_NODE_HAS_PROP(node_id, power_good_pin), \ - (.power_good_dev = GET_POWER_GOOD_DEV(node_id), \ - .power_good_pin = GET_POWER_GOOD_PIN(node_id), ), \ - (.power_good_dev = NULL, \ - .power_good_pin = 0, )) +#define FILL_POWER_GOOD(node_id) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, power_good_pin), \ + (.power_good_dev = GET_POWER_GOOD_DEV(node_id), \ + .power_good_pin = GET_POWER_GOOD_PIN(node_id), ), \ + (.power_good_dev = NULL, .power_good_pin = 0, )) #else #define FILL_POWER_GOOD(node_id) #endif /* ANY_INST_HAS_POWER_GOOD_PIN */ @@ -58,20 +56,19 @@ static int thermistor_get_temp(const struct temp_sensor_t *sensor, .data = DT_CAT(node_id, _thermistor_data), \ }) -#define GET_ZEPHYR_TEMP_SENSOR_THERMISTOR(node_id) \ - (&(struct zephyr_temp_sensor){ \ - .read = &thermistor_get_temp, \ +#define GET_ZEPHYR_TEMP_SENSOR_THERMISTOR(node_id) \ + (&(struct zephyr_temp_sensor){ \ + .read = &thermistor_get_temp, \ .thermistor = \ GET_THERMISTOR_INFO(DT_PHANDLE(node_id, thermistor)), \ - FILL_POWER_GOOD(node_id) \ - }) - -#define TEMP_THERMISTOR(node_id) \ - [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ - .name = DT_LABEL(node_id), \ - .idx = ZSHIM_ADC_ID(DT_PHANDLE(node_id, adc)), \ - .type = TEMP_SENSOR_TYPE_BOARD, \ - .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_THERMISTOR(node_id), \ + FILL_POWER_GOOD(node_id) }) + +#define TEMP_THERMISTOR(node_id) \ + [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ + .name = DT_LABEL(node_id), \ + .idx = ZSHIM_ADC_ID(DT_PHANDLE(node_id, adc)), \ + .type = TEMP_SENSOR_TYPE_BOARD, \ + .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_THERMISTOR(node_id), \ }, DT_FOREACH_STATUS_OKAY(cros_ec_thermistor, DEFINE_THERMISTOR_DATA) @@ -89,19 +86,17 @@ static int pct2075_get_temp(const struct temp_sensor_t *sensor, int *temp_ptr) .i2c_addr_flags = DT_STRING_TOKEN(node_id, i2c_addr_flags), \ }, -#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(node_id) \ - (&(struct zephyr_temp_sensor){ \ - .read = &pct2075_get_temp, \ - .thermistor = NULL, \ - FILL_POWER_GOOD(node_id) \ - }) - -#define TEMP_PCT2075(node_id) \ - [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ - .name = DT_LABEL(node_id), \ - .idx = ZSHIM_PCT2075_SENSOR_ID(node_id), \ - .type = TEMP_SENSOR_TYPE_BOARD, \ - .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_PCT2075(node_id), \ +#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(node_id) \ + (&(struct zephyr_temp_sensor){ .read = &pct2075_get_temp, \ + .thermistor = NULL, \ + FILL_POWER_GOOD(node_id) }) + +#define TEMP_PCT2075(node_id) \ + [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ + .name = DT_LABEL(node_id), \ + .idx = ZSHIM_PCT2075_SENSOR_ID(node_id), \ + .type = TEMP_SENSOR_TYPE_BOARD, \ + .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_PCT2075(node_id), \ }, const struct pct2075_sensor_t pct2075_sensors[PCT2075_COUNT] = { @@ -121,19 +116,17 @@ static int sb_tsi_get_temp(const struct temp_sensor_t *sensor, int *temp_ptr) #endif /* cros_ec_temp_sensor_sb_tsi */ -#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(node_id) \ - (&(struct zephyr_temp_sensor){ \ - .read = &sb_tsi_get_temp, \ - .thermistor = NULL, \ - FILL_POWER_GOOD(node_id) \ - }) - -#define TEMP_SB_TSI(node_id) \ - [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ - .name = DT_LABEL(node_id), \ - .idx = 0, \ - .type = TEMP_SENSOR_TYPE_CPU, \ - .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_SB_TSI(node_id), \ +#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(node_id) \ + (&(struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \ + .thermistor = NULL, \ + FILL_POWER_GOOD(node_id) }) + +#define TEMP_SB_TSI(node_id) \ + [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ + .name = DT_LABEL(node_id), \ + .idx = 0, \ + .type = TEMP_SENSOR_TYPE_CPU, \ + .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_SB_TSI(node_id), \ }, #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_temp_sensor_tmp112) @@ -149,19 +142,17 @@ static int tmp112_get_temp(const struct temp_sensor_t *sensor, int *temp_ptr) .i2c_addr_flags = DT_STRING_TOKEN(node_id, i2c_addr_flags), \ }, -#define GET_ZEPHYR_TEMP_SENSOR_TMP112(node_id) \ - (&(struct zephyr_temp_sensor){ \ - .read = &tmp112_get_temp, \ - .thermistor = NULL, \ - FILL_POWER_GOOD(node_id) \ - }) - -#define TEMP_TMP112(node_id) \ - [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ - .name = DT_LABEL(node_id), \ - .idx = ZSHIM_TMP112_SENSOR_ID(node_id), \ - .type = TEMP_SENSOR_TYPE_BOARD, \ - .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_TMP112(node_id), \ +#define GET_ZEPHYR_TEMP_SENSOR_TMP112(node_id) \ + (&(struct zephyr_temp_sensor){ .read = &tmp112_get_temp, \ + .thermistor = NULL, \ + FILL_POWER_GOOD(node_id) }) + +#define TEMP_TMP112(node_id) \ + [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \ + .name = DT_LABEL(node_id), \ + .idx = ZSHIM_TMP112_SENSOR_ID(node_id), \ + .type = TEMP_SENSOR_TYPE_BOARD, \ + .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_TMP112(node_id), \ }, const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = { @@ -170,9 +161,12 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = { const struct temp_sensor_t temp_sensors[] = { DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_thermistor, TEMP_THERMISTOR) - DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_pct2075, TEMP_PCT2075) - DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_sb_tsi, TEMP_SB_TSI) - DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_tmp112, TEMP_TMP112) + DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_pct2075, + TEMP_PCT2075) + DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_sb_tsi, + TEMP_SB_TSI) + DT_FOREACH_STATUS_OKAY( + cros_ec_temp_sensor_tmp112, TEMP_TMP112) }; int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) |