[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT |
Date: |
Tue, 21 Apr 2020 14:16:15 +0200 |
Use a definition instead of a magic value.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/misc/tmp421.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index c0bc150bca..04c3b3ca6e 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -37,6 +37,8 @@
#define TMP422_DEVICE_ID 0x22
#define TMP423_DEVICE_ID 0x23
+#define SENSORS_COUNT 4
+
typedef struct DeviceInfo {
int model;
const char *name;
@@ -53,7 +55,7 @@ typedef struct TMP421State {
I2CSlave i2c;
/*< public >*/
- int16_t temperature[4];
+ int16_t temperature[SENSORS_COUNT];
uint8_t status;
uint8_t config[2];
@@ -124,7 +126,7 @@ static void tmp421_get_temperature(Object *obj, Visitor *v,
const char *name,
return;
}
- if (tempid >= 4 || tempid < 0) {
+ if (tempid >= SENSORS_COUNT || tempid < 0) {
error_setg(errp, "error reading %s", name);
return;
}
@@ -164,7 +166,7 @@ static void tmp421_set_temperature(Object *obj, Visitor *v,
const char *name,
return;
}
- if (tempid >= 4 || tempid < 0) {
+ if (tempid >= SENSORS_COUNT || tempid < 0) {
error_setg(errp, "error reading %s", name);
return;
}
--
2.21.1
- [RFC PATCH 00/17] hw/misc: Introduce a temperature sensor interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 01/17] hw/misc: Introduce the temperature sensor interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 03/17] hw/misc/temp-sensor: Add 'info temp' HMP command, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT,
Philippe Mathieu-Daudé <=
- [RFC PATCH 04/17] hw/misc/tmp105: Extract get_temp_mC() and set_temp_mC() helpers, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 07/17] hw/misc/tmp421: Extract get_temp_mC() helper, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 08/17] hw/misc/tmp421: Extract set_temp_mC() helper, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 05/17] hw/misc/tmp105: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 09/17] hw/misc/tmp421: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 10/17] hw/misc/bcm2835_thermal: Hold the temperature in the device state, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 12/17] hw/misc/bcm2835_property: Hold the temperature in the device state, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 11/17] hw/misc/bcm2835_thermal: Implement the 'temperature-sensor' interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 13/17] hw/misc/bcm2835_property: Implement the 'temperature-sensor' interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 14/17] hw/display/ads7846: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21