[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 15/17] hw/ide/qdev: Implement the 'temperature-sensor' qdev i
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 15/17] hw/ide/qdev: Implement the 'temperature-sensor' qdev interface |
Date: |
Tue, 21 Apr 2020 14:16:24 +0200 |
IDE drives exposing a SMART interface report the air flow
temperature. Let them implement the 'temperature-sensor'
interface.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/ide/qdev.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index c22afdb8ee..144d6ab533 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -32,6 +32,7 @@
#include "sysemu/sysemu.h"
#include "sysemu/runstate.h"
#include "qapi/visitor.h"
+#include "hw/misc/temp-sensor.h"
/* --------------------------------- */
@@ -270,6 +271,12 @@ static void ide_dev_instance_init(Object *obj)
object_property_set_int(obj, -1, "bootindex", NULL);
}
+static float ide_hd_get_temp(TempSensor *obj, unsigned sensor_id)
+{
+ /* See airflow-temperature-celsius in smart_attributes[] */
+ return 100.f - 0x45;
+}
+
static void ide_hd_realize(IDEDevice *dev, Error **errp)
{
ide_dev_initfn(dev, IDE_HD, errp);
@@ -315,11 +322,14 @@ static void ide_hd_class_init(ObjectClass *klass, void
*data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
IDEDeviceClass *k = IDE_DEVICE_CLASS(klass);
+ TempSensorClass *tc = TEMPSENSOR_INTERFACE_CLASS(klass);
k->realize = ide_hd_realize;
dc->fw_name = "drive";
dc->desc = "virtual IDE disk";
device_class_set_props(dc, ide_hd_properties);
+ tc->sensor_count = 1;
+ tc->get_temperature = ide_hd_get_temp;
}
static const TypeInfo ide_hd_info = {
@@ -327,6 +337,10 @@ static const TypeInfo ide_hd_info = {
.parent = TYPE_IDE_DEVICE,
.instance_size = sizeof(IDEDrive),
.class_init = ide_hd_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_TEMPSENSOR_INTERFACE },
+ { }
+ },
};
static Property ide_cd_properties[] = {
--
2.21.1
- Re: [RFC PATCH 03/17] hw/misc/temp-sensor: Add 'info temp' HMP command, (continued)
- [RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT, 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 04/17] hw/misc/tmp105: Extract get_temp_mC() and set_temp_mC() helpers, 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 11/17] hw/misc/bcm2835_thermal: Implement the 'temperature-sensor' 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 07/17] hw/misc/tmp421: Extract get_temp_mC() helper, 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 15/17] hw/ide/qdev: Implement the 'temperature-sensor' qdev interface,
Philippe Mathieu-Daudé <=
- [RFC PATCH 14/17] hw/display/ads7846: Implement the 'temperature-sensor' qdev 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 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorClass, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 16/17] hw/misc/imx6ul_ccm: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21