All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	qemu-block@nongnu.org, qemu-trivial@nongnu.org,
	"Michael Tokarev" <mjt@tls.msk.ru>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	"John Snow" <jsnow@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [RFC PATCH 15/17] hw/ide/qdev: Implement the 'temperature-sensor' qdev interface
Date: Tue, 21 Apr 2020 14:16:24 +0200	[thread overview]
Message-ID: <20200421121626.23791-16-f4bug@amsat.org> (raw)
In-Reply-To: <20200421121626.23791-1-f4bug@amsat.org>

IDE drives exposing a SMART interface report the air flow
temperature. Let them implement the 'temperature-sensor'
interface.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 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



  parent reply	other threads:[~2020-04-21 12:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 12:16 [RFC PATCH 00/17] hw/misc: Introduce a temperature sensor interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 01/17] hw/misc: Introduce the " Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command Philippe Mathieu-Daudé
2020-04-21 16:27   ` Dr. David Alan Gilbert
2020-04-21 12:16 ` [RFC PATCH 03/17] hw/misc/temp-sensor: Add 'info temp' HMP command Philippe Mathieu-Daudé
2020-04-21 18:00   ` Dr. David Alan Gilbert
2020-04-21 12:16 ` [RFC PATCH 04/17] hw/misc/tmp105: Extract get_temp_mC() and set_temp_mC() helpers Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 05/17] hw/misc/tmp105: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 07/17] hw/misc/tmp421: Extract get_temp_mC() helper Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 08/17] hw/misc/tmp421: Extract set_temp_mC() helper Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 09/17] hw/misc/tmp421: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 10/17] hw/misc/bcm2835_thermal: Hold the temperature in the device state Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 11/17] hw/misc/bcm2835_thermal: Implement the 'temperature-sensor' interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 12/17] hw/misc/bcm2835_property: Hold the temperature in the device state Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 13/17] hw/misc/bcm2835_property: Implement the 'temperature-sensor' interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 14/17] hw/display/ads7846: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` Philippe Mathieu-Daudé [this message]
2020-04-21 12:16 ` [RFC PATCH 16/17] hw/misc/imx6ul_ccm: " Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorClass Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200421121626.23791-16-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=jcd@tribudubois.net \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.