From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871035; cv=none; d=zohomail.com; s=zohoarc; b=HKEmllEI47qr97GbnOav98J/qa+w0f5A6w07swYqdoCmNWiT7x+F27snxLB4Q0cijDVGD915zooIKERNOsZY4UTuRhBONyv4N+eak0+rgDJTpQCmyFpeFf8DBc9U8ZEqPbN7u5X9VtTAs/WMcaKP3I62aVHxMldxofi8JqrOCB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871035; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=YPLH85BN1FQ6/VjPz8nyN4WwRSjc/tOK4cGRVQRwlAA=; b=irhn072HVUtiyeWyG2Q2ONo4483OPIpklmVoEfXGiaqsdnSJkpVQUijF2me2JkoP3gVZvTF7JyGbouNdYsbOSyFb8hZVVXOQCluuc+6fo8g8UBwVlM9G5bNt9kNzdlhULcjiGLb8viKqKcUyvZLxWGGUV/h/rtoTc+a8S09uVr8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871035310544.4343010547449; Thu, 5 Nov 2026 01:30:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtll-0006jG-4W; Thu, 05 Nov 2026 04:28:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtlI-0006c6-U7 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:01 -0500 Received: from mail-pf1-f174.google.com ([209.85.210.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtlG-0006uN-Pm for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:00 -0500 Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8a07078200fso730210b3a.2 for ; Thu, 05 Nov 2026 01:27:58 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8b09c024a45sm1790162b3a.56.2026.11.05.01.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:27:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870877; x=1794475677; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YPLH85BN1FQ6/VjPz8nyN4WwRSjc/tOK4cGRVQRwlAA=; b=LqfBM4Ie3IXEAGr6wy4UttaWSvL9nKAV9B891y+YeeTOWWvmOeRu5N8hvqrV/NPCXt zjnIAndqpCfhaqTYC0NdVY1XQE1GajRjpwL1AAN7WkXCvOVKHHRhOK7iuX5tJ8s3vy7u wXqhQN1aHBSyIfklGBO43+GQss5Yb3cMel2yXwsESTGMmw2vvRWJV5WsSozsSJPvNmIk Sbj8C/sCIXbUDmJ22R7QyhDFvQua2XpDqIioF1w0TVBQ0AJ8Aa2jcQOvCUmRX1yY7pGr EuMURibPoLCU7XvsQtDdYLHwczrV+pLRrFXwHdfNeGyV3Tox6zIod335xOF+Z9f7CD+Y 3HjQ== X-Gm-Message-State: APuU4Z/ko9CkYIvpMdzHZ1xRI+OcDym4J2iAo9mhDu0H1L6lPQhLPUjk pSgcGrKcR1sNdciAKtJhUG7dxElHmhgZV4Rt6i0LV8UxAZXHj+CaHVXdDU2+tYQJ3kA= X-Gm-Gg: AYBFou0iIpyEmq1Z/1O1hAZm4vHlptMmIdcm6ydgtjuJUhDHGawxhRTqNiUtliQJqbB m4krAw+INBsKsEuw0lVcMqjQfv8zR6II+MYIlcuO07S1aVfJQJsAu6pqXhllkrSayE2c5hCayTZ bpwEl48A8rJ2cMVvhO+wqQ+hIu+551+LAywUJ3OkYWLHj3IpqAiLBo6lznZXrp6gqJho8h0tUXL Uo6d+E7eoAzXWhM1W2wVPmHmWk3wip6K5jrcwng28PgHeNPjEuOJlK/Xxcr34cgeY5/26X3ThcX NXtFSniFeS9185ho61zre222l2AYs4n9vaoEbB24F1QrU3dtuCbkwLO8SZAHmWQSLuPcvLSPedE ofjM0fugBJCu8EnQsDnrUYkJcWB0c8ULhMMi7hcVmp1Q95EuELdh6cv13vCX7xNXy+sQ+/kwoG9 thKe+2L/tE39HKBRBBpvM3W/YnntxFz+Z1sRtbBFqOWJnA2A/xdM4+wNmLXgQB6GuWi7DOZ4V5T GBvXDAIJNBydPnhuU6vqCpq7PBM/eRBJZ/9CweYNFV6ZRbXybSZQo/tTF+jeclTf3GxzZP5hNYF pDvvb4rNdeNGn7oQrHhM5m6Ae5m2cSImR+g79xkW8PcIB4KZxp9xaesN6VZCjkxAKgMAC3U/81g 3 X-Received: by 2002:a05:6a00:6301:b0:8ac:3a71:38a6 with SMTP id d2e1a72fcca58-8ac3a71603dmr8841515b3a.52.1793870877117; Thu, 05 Nov 2026 01:27:57 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:40 +0800 Subject: [PATCH 01/16] hw/sensor: tmp421: do not report a stale errno on a parse failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-1-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870742; l=1336; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=GFEfhIFJh8BOQmlbaRUAQhaRBhXcQfPvzbeClZRBxBk=; b=SnUnMVbEDiOUUppxJSOZyrhMoIdPtXywSWLyUL3FSZ5SGalDeO3g4fEqZ7VOcLdlRarxUjrrS bqxyYgtDqFPDBVOzS8OQSE+LpVw23ryDYEF2OZjxhok5xds19WX3DIp X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.174; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f174.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871036594158500 The temperature property accessors decode the channel index out of the property name and report a failure with error_setg_errno(). sscanf() does not set errno when it matches fewer items than expected, so the message is suffixed with whatever unrelated error was left behind by an earlier call. The bounds check right below already uses plain error_setg() for the same condition. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 0e4d0d0ec2..84c6ebec41 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -118,7 +118,7 @@ static void tmp421_get_temperature(Object *obj, Visitor= *v, const char *name, int tempid; =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg_errno(errp, errno, "error reading %s", name); + error_setg(errp, "error reading %s", name); return; } =20 @@ -155,7 +155,7 @@ static void tmp421_set_temperature(Object *obj, Visitor= *v, const char *name, } =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg_errno(errp, errno, "error reading %s", name); + error_setg(errp, "error reading %s", name); return; } =20 --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870931; cv=none; d=zohomail.com; s=zohoarc; b=lLxP4mzbSo7n7SiIP+dP5QCbRGgfBEWsCwieFRQm9BVlXTFn/fwa2WUIJ5wl7DTfL+86+b0iw+/hGYKXZq3tWzKkJGes7hs61pfHE6k3Gqg2YL1tRN028/wz5p+NBAJRRXEOQLDBY0L8mE8+7DhO0NylNBLg/vXWbHBjoXQb8fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870931; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=xROCpkWUYC71TnBZuGFxVWBBqmZSEffjxEv7jnCU0Jc=; b=iXw9LJLpztew1YtPEDNCR7Cxqho17+f9dByf/H/L3vEkWs+KDAWNfcoYwSaQo/5/e1zMcqf9jAw6CqznBanOQirTiyKDe9+0OxRLdon0MqfwWeG3p/WFx9VSHa4VI3oig/DcWl6DUrqeTypHNo+dHSPVh8IfScaSpIMPalEgQY8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793870931678735.3260496828308; Thu, 5 Nov 2026 01:28:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtlg-0006gO-O0; Thu, 05 Nov 2026 04:28:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtlV-0006du-Ee for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:15 -0500 Received: from mail-pj1-f50.google.com ([209.85.216.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtlS-0006v4-Lz for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:12 -0500 Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3adac5c10e3so1054017a91.0 for ; Thu, 05 Nov 2026 01:28:05 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b90def97sm2554833a91.7.2026.11.05.01.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870884; x=1794475684; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xROCpkWUYC71TnBZuGFxVWBBqmZSEffjxEv7jnCU0Jc=; b=aRdolb06urkNAn4PBwiumBt1vj4TGE9AQmXw+ToQTb63O6MqnYSaqn6fSNIFLHLg+N 6rkXdCuotEhHhfV7/uqGRaybQRGEmmUr+KD3Gn9+Zxdzfu+klXqmG+hDCyXznIkQ8R/z 3XXKkV1Ri0inWApsJR4A+2BfeicSHUvDQ2pYlFTiFLa36y587YQcvwKmAQjCOJKeNZU4 Z7/s9dX5Ab23xUWU1u/0w5jI93c3C9Esv2bgZkd7UU6EoD++Sc4sTkgOS8oXe5SWcO1j F0A9U8uUOdp2AUNm0hT/x6RJslIqotpQw6t0ARtDAaG7z0shVzReRRNrYYQQXc0IF327 NLIA== X-Gm-Message-State: APuU4Z+2whxk2Y83XTEpPVreuR3t1sUV77S2IWnVw9Yw5KKyOqJKBxci R6Dca9II3f6Ey5rzgM8edmd58XADlqVqgTQuH1FdogZqlOQlkjKydjboE+p3M2QTttc= X-Gm-Gg: AYBFou26OqiJhvKbHbcqWoczdlvHjy9B2169jpUHOFwncb35XNGQ5Os6VGOloyAbokh gV7czb6jQePlvxLuOIdYXpUntbajiaJp9GqaFLTXxRreFP1oK9UvshySrSgVX7cQvwrkAPZ7/hB o5g3p+nlne92PsBB36yXGf0eyBF2gmoQNWfN2iIdieXMhea7d97yAELYJJxfMKnYfRzc3kXBITL 1t35dsp9bYi5sSOdkLeEjfBb6iUJiJ2l00VNcqQ96i7xyB5NvQ1H4k3SDHpyii8dyNZxWrt3zHE j+MZYNSj58qUM4GOxqw/l+bj+bBmrGfwGDytskBoaF3SZxFWbq3yS7YVfFS9TPv3aV2hDYmblLp pDFgM5H5VO1rL7UAM2nWNnEzcnGt1QQwBXGoVhLdzaxMirrtEa1/k2jyEFge1BEmlvGlIwaF6QK Aw+RSzitz/kfuCldetuyYWIIWD4ijdFtvpILCbzhkGZ9nop1NiGN8k1FU5YTpHyUBO/XmwQCVR4 rtb/hpggf/ibK9qXuzdicmXXSBis1mguySfqjHoZM6olSVUt8Rs+fRQkN3DgvZlJUFwDKvIgmme yrZNV94OCBf06z2jB7pesQeq5aH3c8ntX3BIzqhsSaTb8Mk4UWg/uxAjf1wfMgp9SU9R2XtH+n3 s X-Received: by 2002:a17:90b:28c7:b0:3a0:a912:e759 with SMTP id 98e67ed59e1d1-3ae897ee62amr15881143a91.25.1793870884072; Thu, 05 Nov 2026 01:28:04 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:41 +0800 Subject: [PATCH 02/16] hw/sensor: tmp421: name the parent object field parent_obj MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-2-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870742; l=1266; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=LKRPZEbS+SgjV2hPOICiQGuvSWwSj93umhoLaBNzCtE=; b=x3tqdVLnIyF3m70IKnZE6uQ5qNKI7Xb7kTy/lCMZBC54TqGMDRLW5VOh4Q6/Zc41p5fGLjrz/ uoWD2wPsGnvCHsPdxs7sIUnlxa/OzbcaNiY+u3TzyMUsc7qxuyGTeG+ X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.216.50; envelope-from=eblot.ml@gmail.com; helo=mail-pj1-f50.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870932610158500 Follow the QOM convention for the embedded I2CSlave, matching the other hw/sensor I2C devices. No functional change. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 84c6ebec41..55e261a090 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -52,7 +52,7 @@ static const DeviceInfo devices[] =3D { =20 struct TMP421State { /*< private >*/ - I2CSlave i2c; + I2CSlave parent_obj; /*< public >*/ =20 int16_t temperature[4]; @@ -299,7 +299,7 @@ static const VMStateDescription vmstate_tmp421 =3D { VMSTATE_UINT8(status, TMP421State), VMSTATE_UINT8(rate, TMP421State), VMSTATE_INT16_ARRAY(temperature, TMP421State, 4), - VMSTATE_I2C_SLAVE(i2c, TMP421State), + VMSTATE_I2C_SLAVE(parent_obj, TMP421State), VMSTATE_END_OF_LIST() } }; @@ -335,7 +335,7 @@ static void tmp421_realize(DeviceState *dev, Error **er= rp) { TMP421State *s =3D TMP421(dev); =20 - tmp421_reset(&s->i2c); + tmp421_reset(&s->parent_obj); } =20 static void tmp421_class_init(ObjectClass *klass, const void *data) --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871041; cv=none; d=zohomail.com; s=zohoarc; b=OGStWETZEH5HEuos1Gh+NWSRi603ZTil8TvpJajlEz+qhk5hEDRoL3MwMjRnvxVNXrIspbus16kdf+vQ033P/xSDvvA7G90EnOq5dfVpF9lrSwq2p5jHdwVKQygAdigVaTsYusv4SszJyUEBz3G29MawVllMCU6I/G8+QUCjio8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871041; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=retw+hCi5vVKjipTQvsUltaajOcauTJ+Xp/W71jLDVc=; b=H74hU48c653zwbqRlJ//OmAEiUE2AZZsTdIuf71GHFR11BWotY/HHgcs9C+h4LPcDEuD5Cc9J0adW0c6R+7KBSx3lTr6i1s26jnFR137TlFTch+8u8Xl0K5pxexGmQy9Zp2/CVR6pHSp0eDpF1uBoWn4Q/y6nxXwoOHZ8gg6XZU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871041578717.6731390452902; Thu, 5 Nov 2026 01:30:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtll-0006jQ-6n; Thu, 05 Nov 2026 04:28:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtlX-0006eM-CG for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:16 -0500 Received: from mail-pl1-f174.google.com ([209.85.214.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtlV-0006vK-Fe for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:15 -0500 Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2eb18f4da15so5676895ad.1 for ; Thu, 05 Nov 2026 01:28:13 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ed2c79ea15sm3709255ad.63.2026.11.05.01.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870892; x=1794475692; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=retw+hCi5vVKjipTQvsUltaajOcauTJ+Xp/W71jLDVc=; b=Uu/BjLbCPWoieQVgAtWPCvLG06xLvvRLV07qxalmUD8xAzskfelsnZVl28Gt1cCpRy 2Ci/jAnotsgTSzb/56dz9ZiQ+N+MYdWtxjpJ4kyo5Ufi9xOSOzyIMmOKfeoZfFteCVrb tvLDIR+YvCHTN0VmBxOjJ9L5qBlDXGc+HnIyyPZdo5S9CHCLgI1YZ9GPlvLcSdu3oaGa WXbXgmoFN9CLSBJeRO0CJV/r801xATas+gYkZfmV35nfYLRIROozNHMkF9yTEayVKdJf hm8Bn9sMi2YwnMVahVsNXhbD8EPhuJtrMVGZQ1R29bBClr1QF8P01wq47RetJ2kDWhXt DOVg== X-Gm-Message-State: APuU4Z/SfwCLyEpZGZVEEAa5cmziZFWTysVVzq5snbIzxeM2bj2AC/kL bN6esZf5jamsRQaMknbs9P0RUe9IUBERb3/Qj457IYy4f/Kpt6B7jSFHhehyXyxhdYY= X-Gm-Gg: AYBFou3WDQD9gBf1RxeMc7MHZulhHEtXvsIgw/weXcX7C/3ClcsBA4gjhpWoQktqcyE uzI/Rnau/hpLN9xdO4dZ7BioVeaakNlBP2wdLidPdl0WSftEqKBka5QrH3JxXCmBB68JwJDkimk gZ+t+Xoh20br5WxkDfLIAE4CRI3MCoon2xMrHjnIqJX1oNXQ5T48Q8to9TQnImYrulfir7zCnJn R+h4Pc0g0c2JNBBnRwQ4V15AUJ3hMijM28zYVd0GURCjxqJxNvgz7cAPRmYBLqFaCNlJJuARP6c ClWMXshBUmdF9fzK/Ow9HNsHozgBNz5udw8kQq64uvlLoG8+1neue1jBvtNPe4pibTw49iyc/3F ELebew8B8My0nDGkUuNfZi1TvUR9/5ud2vFLvQQr7ECx1/X//XCINw+ozYUMMH0gJnX/W89rgWF kgyExFgZiAU9tMlrn5aukohdQkkxVLgQCC6j2HXu0fFc4DNseOYgDdq45q4953t7xfXR3KR5Xyr /vwQJailN1JoXrqe6TPWkOgfpPHbBEc/vGqDuEgqYqjyyxM5W7sQ0wFJsnNfnE93xzesN3IInk6 3Bc+hZeOfxVnUZlQSetTFk5QC6XrPmAy9fpdnQtrqfVcD8PI95af3pGFhe70mPR/QzmeHwObKPy U X-Received: by 2002:a17:902:ce05:b0:2dd:ad73:5b6f with SMTP id d9443c01a7336-2eb364b55camr171857535ad.31.1793870891693; Thu, 05 Nov 2026 01:28:11 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:42 +0800 Subject: [PATCH 03/16] hw/sensor: tmp421: implement Resettable reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-3-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870742; l=2741; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jjLzkdYMOkO0VP5ki4S9XNixanshbfj1QWCH+5pzHwI=; b=0d1GjFHyw0hNWxqlmXuYkjR853Y2s95/pA0FYQQP9fymiJtvfp71ubFKf5/uLSIfbaaQ2imIj jbN+OcGdoIIBDWtuKclwNKFtNDTXCNRilAmcI0/g6sHdpLk/99BGruL X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.214.174; envelope-from=eblot.ml@gmail.com; helo=mail-pl1-f174.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871042640158500 Wire the reset through the Resettable hold phase instead of only calling it from realize, so bus and system resets re-initialise the device. The measured temperatures are no longer cleared on reset: they represent the physical input the ADC re-samples, and boards may preset them before the machine-wide power-on reset. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 55e261a090..4b93d42b14 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -225,7 +225,7 @@ static void tmp421_read(TMP421State *s) } } =20 -static void tmp421_reset(I2CSlave *i2c); +static void tmp421_reset(TMP421State *s); =20 static void tmp421_write(TMP421State *s) { @@ -240,7 +240,7 @@ static void tmp421_write(TMP421State *s) s->config[1] =3D s->buf[0]; break; case TMP421_RESET: - tmp421_reset(I2C_SLAVE(s)); + tmp421_reset(s); break; } } @@ -304,17 +304,18 @@ static const VMStateDescription vmstate_tmp421 =3D { } }; =20 -static void tmp421_reset(I2CSlave *i2c) +static void tmp421_reset(TMP421State *s) { - TMP421State *s =3D TMP421(i2c); TMP421Class *sc =3D TMP421_GET_CLASS(s); =20 - memset(s->temperature, 0, sizeof(s->temperature)); + /* + * The measured temperatures are not cleared: they model the physical + * input the ADC re-samples after reset, and boards may preset them. + */ s->pointer =3D 0; + s->config[0] =3D 0; =20 - s->config[0] =3D 0; /* TMP421_CONFIG_RANGE */ - - /* resistance correction and channel enablement */ + /* resistance correction and channel enablement */ switch (sc->dev->model) { case TMP421_DEVICE_ID: s->config[1] =3D 0x1c; @@ -331,23 +332,22 @@ static void tmp421_reset(I2CSlave *i2c) s->status =3D 0; } =20 -static void tmp421_realize(DeviceState *dev, Error **errp) +static void tmp421_reset_hold(Object *obj, ResetType type) { - TMP421State *s =3D TMP421(dev); - - tmp421_reset(&s->parent_obj); + tmp421_reset(TMP421(obj)); } =20 static void tmp421_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); TMP421Class *sc =3D TMP421_CLASS(klass); =20 - dc->realize =3D tmp421_realize; k->event =3D tmp421_event; k->recv =3D tmp421_rx; k->send =3D tmp421_tx; + rc->phases.hold =3D tmp421_reset_hold; dc->vmsd =3D &vmstate_tmp421; sc->dev =3D (DeviceInfo *) data; =20 --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870994; cv=none; d=zohomail.com; s=zohoarc; b=jWDtaN/hFTAVq6YEYHfEypB1mdZM4dMX7ksZ7AXWsODWMm9I79MgXruH65UhBzLa1qJJ3565pTXwWhFbmOMk5wS/OdZCl896xnqN7Kg+4nZolhn8Y5UQM2BksfOdJHab6Zx38J9FGirjRlMvNIYgc0QgbnhgVb3XrPjGw/Hse00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870994; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=UjYfulFHyJfR33AHhkVMSYX3bW2RiBBj5I0jLkWcpgI=; b=XlHZw4N110V0BMSwNxkjix2+UMAW0lWMCPXTTwXLFGSovDLNabcoT3SneiftMq1R+Naoyv2+6Lz7cWgBHZyrvGqp8JrjLcg3oMsN0BVBRO8JC5ieZRUiDU8XtGlNijVh6yCF8EdCz3UZ4vOqyl3rsF5uQx8oaMLI98FFAZvlxts= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179387099398228.82587579480571; Thu, 5 Nov 2026 01:29:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtlm-0006kD-4y; Thu, 05 Nov 2026 04:28:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtlg-0006gg-Nt for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:25 -0500 Received: from mail-pj1-f41.google.com ([209.85.216.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtld-0006vv-La for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:23 -0500 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3ae1b34e0d2so239925a91.1 for ; Thu, 05 Nov 2026 01:28:21 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdb46974b71sm2019700a12.23.2026.11.05.01.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870900; x=1794475700; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UjYfulFHyJfR33AHhkVMSYX3bW2RiBBj5I0jLkWcpgI=; b=xN/Q/aePFlX5v5nO0FEDYxVe/xRDQWuWbBAyjQ3G0C3K3S1cmkwMmvdGgGG64CUeSg 8ck1aaLv3znzM6locXCIrtOJxgD4wL9ZiQV1mlf1cWrPD/xTnO16a/Akg0Y1VOVWE0Yt dQGF1DOF65RkhTt/sTtmslVhmyo7GaklAeu7ZCp46NVl5mSyM9idkSRjRwd+uN7Phvvr FnvpHOO21I3h6o2kxlxP2Vja2vZdgj9/BbGLGyJTSA0mAAF8BPiXVn3+DafH9ZBNWTF5 XegaNrzW/ROwk0LllMXCpNIRuwrqt3OTTj14J6GrX02Tx4SKn0nNO1h6yzRFf3nwUspC zguQ== X-Gm-Message-State: APuU4Z+D3Dkx860347JJ2I4hSp+/lK8MhDFBNGtWQmcZ5/LOTO/6zTSd UgsauyFDb34Jw9p8wlMeyOJHQkD2pe2A5vY8kKIB3tzGoWhqvROlCyNVKos3my33Quk= X-Gm-Gg: AYBFou1JR1Tl6ZXnzf2xMerz/Xsf1jkg/j+SFQ68ZcBkdiikvpQF9vZ7dIq9kqX6Xla ZjI8WopKiEGVhEt1MLWJppPyW+kh0in3vMCyKFJW0kS4rJGo/uJNDi2QfsBFv5Bxo818k+VBH5V 6svx6O2ZqqE1wstJXp23Iuu8NnWGXLsyEwfso+h5ScZva5el4wszEMykMV2WAmPSW6uSDvFaK3w k5onpuBVXvNhvJxJMAKUhQ+N/fomrV0A+BV1v9UVQqbXwVjrZ5M6doMiEa1wdxBaMsTP3J12FEf 0DrTiTxp0ngURd/5+L6AUV5PZY0hjMXQMUvlt0nFmEEQMoZd4L6DWj1EFBrABG36Yl9czEA4v5P M1SiFwzOFAbOD9kITruDiYPMPZsx3nV9/ZLgmku2Vsa6F5XwnYbaT5Y/ZrElafiB0/Ot1Yr2GUE L/xxVEX1pHw43fdmdCpP+eyMG5oNEEJUPf1LKfXkoTQ8sC1GUXa7OvV7tRgdPTHqSFcJbhEnjKy jKpnXMcWghXWKw2LPgWZ/xY2kMflz4w+eYTJcF+yJuN36aF34M5JE53lduurNMtT54b2mbbxWIW LuhsaGdd+IvDzN2Ka0EL87xUXLBsg9u8jxo5LpaI2jR/A/0iG4t2LzNWpxMNfHnvr747GLa7rrP D X-Received: by 2002:a17:90b:4c8b:b0:3ac:9785:4c31 with SMTP id 98e67ed59e1d1-3b0afe019d2mr1406354a91.27.1793870899727; Thu, 05 Nov 2026 01:28:19 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:43 +0800 Subject: [PATCH 04/16] hw/sensor: tmp421: model device variants with a class descriptor MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-4-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870742; l=4921; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=hSZTxm4I3qUs71e4HVoKOMQNOX84Cl1z8VgaKmWCp30=; b=SK3nwkCebWzeftPfvl/g7aOu/JfLj+e7MUI/MeyW+WNQaIGYI5aBFK9fcOzbB9ngi/ZrZ2NsE nl39xBLO8UDDGDohGKlOsqv/Vl+D5qqlYYOnqEFvOMFOJKpKXDFML3v X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.216.41; envelope-from=eblot.ml@gmail.com; helo=mail-pj1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870995812158500 Replace the ad-hoc DeviceInfo table and its manual type-registration loop with per-variant fields on the device class, set by a dedicated class_init for each part and registered through DEFINE_TYPES. This drops the abstract base type in favour of the TMP421 acting as the base for its TMP422/TMP423 supersets. The three instantiable type names are unchanged, but TYPE_TMP421 now spells "tmp421" rather than the abstract "tmp421-generic", which no longer exists, and a TMP421 cast now succeeds for the two supersets. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 98 +++++++++++++++++++++++++-------------------------= ---- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 4b93d42b14..ef738b821e 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -39,17 +39,6 @@ #define TMP422_DEVICE_ID 0x22 #define TMP423_DEVICE_ID 0x23 =20 -typedef struct DeviceInfo { - int model; - const char *name; -} DeviceInfo; - -static const DeviceInfo devices[] =3D { - { TMP421_DEVICE_ID, "tmp421" }, - { TMP422_DEVICE_ID, "tmp422" }, - { TMP423_DEVICE_ID, "tmp423" }, -}; - struct TMP421State { /*< private >*/ I2CSlave parent_obj; @@ -69,10 +58,14 @@ struct TMP421State { =20 struct TMP421Class { I2CSlaveClass parent_class; - const DeviceInfo *dev; + + uint8_t device_id; + uint8_t config2_reset; }; =20 -#define TYPE_TMP421 "tmp421-generic" +#define TYPE_TMP421 "tmp421" +#define TYPE_TMP422 "tmp422" +#define TYPE_TMP423 "tmp423" OBJECT_DECLARE_TYPE(TMP421State, TMP421Class, TMP421) =20 =20 @@ -178,7 +171,7 @@ static void tmp421_read(TMP421State *s) s->buf[s->len++] =3D TMP421_MANUFACTURER_ID; break; case TMP421_DEVICE_ID_REG: - s->buf[s->len++] =3D sc->dev->model; + s->buf[s->len++] =3D sc->device_id; break; case TMP421_CONFIG_REG_1: s->buf[s->len++] =3D s->config[0]; @@ -314,20 +307,7 @@ static void tmp421_reset(TMP421State *s) */ s->pointer =3D 0; s->config[0] =3D 0; - - /* resistance correction and channel enablement */ - switch (sc->dev->model) { - case TMP421_DEVICE_ID: - s->config[1] =3D 0x1c; - break; - case TMP422_DEVICE_ID: - s->config[1] =3D 0x3c; - break; - case TMP423_DEVICE_ID: - s->config[1] =3D 0x7c; - break; - } - + s->config[1] =3D sc->config2_reset; s->rate =3D 0x7; /* 8Hz */ s->status =3D 0; } @@ -349,7 +329,9 @@ static void tmp421_class_init(ObjectClass *klass, const= void *data) k->send =3D tmp421_tx; rc->phases.hold =3D tmp421_reset_hold; dc->vmsd =3D &vmstate_tmp421; - sc->dev =3D (DeviceInfo *) data; + + sc->device_id =3D TMP421_DEVICE_ID; + sc->config2_reset =3D 0x1c; =20 object_class_property_add(klass, "temperature0", "int", &int_type_info, tmp421_get_temperature, @@ -365,28 +347,40 @@ static void tmp421_class_init(ObjectClass *klass, con= st void *data) tmp421_set_temperature, NULL, NULL); } =20 -static const TypeInfo tmp421_info =3D { - .name =3D TYPE_TMP421, - .parent =3D TYPE_I2C_SLAVE, - .instance_size =3D sizeof(TMP421State), - .class_size =3D sizeof(TMP421Class), - .abstract =3D true, +static void tmp422_class_init(ObjectClass *klass, const void *data) +{ + TMP421Class *sc =3D TMP421_CLASS(klass); + + sc->device_id =3D TMP422_DEVICE_ID; + sc->config2_reset =3D 0x3c; +} + +static void tmp423_class_init(ObjectClass *klass, const void *data) +{ + TMP421Class *sc =3D TMP421_CLASS(klass); + + sc->device_id =3D TMP423_DEVICE_ID; + sc->config2_reset =3D 0x7c; +} + +static const TypeInfo tmp421_types[] =3D { + { + .name =3D TYPE_TMP421, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(TMP421State), + .class_size =3D sizeof(TMP421Class), + .class_init =3D tmp421_class_init, + }, + { + .name =3D TYPE_TMP422, + .parent =3D TYPE_TMP421, + .class_init =3D tmp422_class_init, + }, + { + .name =3D TYPE_TMP423, + .parent =3D TYPE_TMP421, + .class_init =3D tmp423_class_init, + }, }; =20 -static void tmp421_register_types(void) -{ - int i; - - type_register_static(&tmp421_info); - for (i =3D 0; i < ARRAY_SIZE(devices); ++i) { - TypeInfo ti =3D { - .name =3D devices[i].name, - .parent =3D TYPE_TMP421, - .class_init =3D tmp421_class_init, - .class_data =3D &devices[i], - }; - type_register_static(&ti); - } -} - -type_init(tmp421_register_types) +DEFINE_TYPES(tmp421_types) --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870949; cv=none; d=zohomail.com; s=zohoarc; b=WRWLtEbKy4O2+jdZ5A7lzNVZiTk6S+xVZ26AHLCjCQRqoufZa92md9kygid/sM9YfPA7fjDhvLIzOtaD/3RdWCX0/SkWMgiW14dSXpNHJdD/ldEYH1ebq+Ks2EpIMPR0Lb7u2fAcRTHdd5e4c6RRyu8FBMp1pcm+aCfWdtc+ZnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870949; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=+suPbMsR1vu1zaODmsUiMWxPqqQ6tFYXADKAIU1mPbw=; b=GYVtv/f2RzsA1+2IEGVfWLY1C3Ehh/n5vyA1b6XAUx2Gc/rrlW1n5UNjCtFAoXzNjESe2zxiffl58yd5BsGvi/9YyB/We6Sbje5/a4Xj2J3RUFK2w5WsC6vp0tRuSrxcLtQ7rVVWKNE6OkVqblKBLuc0rIApa2mdJBKXgn+6ZPY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179387094953572.0822090869134; Thu, 5 Nov 2026 01:29:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtlp-0006mX-8K; Thu, 05 Nov 2026 04:28:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtln-0006la-8E for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:31 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtll-0006wV-8R for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:31 -0500 Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8a06ca6e8f4so1194603b3a.1 for ; Thu, 05 Nov 2026 01:28:28 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdb4696e816sm1932872a12.21.2026.11.05.01.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870908; x=1794475708; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+suPbMsR1vu1zaODmsUiMWxPqqQ6tFYXADKAIU1mPbw=; b=kW/BPmZ7HHB2HkcSujE10ONcVE9S/Qn3Svqg6jhlMxsgQcoHyENhbviEyY8A7dHPCH 0LBl0qnLpxlfrQytfzHYYiqvK66WWCeAALKeamIYDr810nY8Ukmfc7TVzaLVKGZes01/ h9UqF6qDkt7+qq9f8CSGEA5T2Vxu1WLDA2HQBtPVLBW+A9Nk2LVbSif+A16uK22WDZjp y/m+UwJo55/ZqdmA92NfE3k/o5Mt+hAqKXiZyN3RfrNHVmvTPebCUlrF88wTMfupM0dO rH0QsY9XELgGmgbkrKi/wKNlN5GOSNqnhgYsNhwiyIlI1E6io7Trm0tl3cDSrdLg3WqJ 2/kQ== X-Gm-Message-State: APuU4Z/gRgDSnUzFT0i7Gprqj8N/pD8qnXfqFDSdNOvvD5rAolxvhTLv GD4HV121rgX0L1f1BYEUAQLe/bvBdBhOoRiBJj09ZOxRjMYsxa+qhap4ipE0Irry12U= X-Gm-Gg: AYBFou3safU6I+pEXE0jP4k1MmIfQi/EXkXPxJbZMXqUaBusY3FhsGbsB1qik3gD0pk CKcxMM0rQB2cdCUvwdOlHj87Mj2D5aQZ1WKMjx3HhoD1Gm3rAKpjzOao1daWsXTuT3aGje3E7FQ mdPsqhneHdDPRqcKBnN2zc75by0GGxuD16oTQqwxypypNeMmtVSV/vCjlvHA+DlKbu07FqVT18X QOlXoe9F9lZ1YuhCPCbliMi+AF+NK+Wd3x9oOhl+mBf1fWIFCFniQrh/GVe7QUH4Sjpzd1WMaBx 1wqIrJRNwHBtPseU+r92BwWEU5nUywHoj0HQD9yYZLjztCVi2WFsE59UkiQ8l90OR+gkxe+cAjz FI7Wvt7A5wVoa9wv7Zu6LlpdB8qsGZ0F2kzJl/BVb5AITvimhxwSSDzudTcoO696OCsDE50b0lu PtcH6AjPsG/WHCcpZ4l+7/8c3J9ObSfuP7rnNXndeM33vUaKttLNWBvQEEyUChs2DcqvXD/oxvf k73esWCEkC0oX+mVA1tEGdq7E3tpBkzodVEkCGRfWGGo5MjJUHSvw/2F2JZeVOX6DGDbBvUUb7/ yFMUqFI047eguB+QBD46W3N1Ed1H2zJEZl8jahDJaxPupSwVMxZrl4CEAgvUOMKkPky32yDC7YN f0A== X-Received: by 2002:a05:6a21:8809:b0:3e1:4527:6350 with SMTP id adf61e73a8af0-3e928e16ca9mr13721379637.64.1793870907760; Thu, 05 Nov 2026 01:28:27 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:44 +0800 Subject: [PATCH 05/16] hw/sensor: tmp421: honor per-variant channels and channel enablement MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-5-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870742; l=6685; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=+W2zIGfj7hBkjPmQ3jaAWE9dEU5f8/eNZKicFOoIYr0=; b=XwPMkxH+yZR+KZ6WEj57vPk3hiNYNKwA3ZJ1781t+taXKEAwcu2FwhQrvfiz8bQqtOpFdfn+7 K4Av9f9d3hBC/u0F+y8fESd9Takik9fjpHPPhN1olQY4WVIuWGhA6ny X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.170; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f170.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870951340158500 Each part exposes a different number of temperature channels; register only the temperature properties that exist and gate the temperature register reads on both channel presence and the configuration enable bits. A disabled or absent channel now reads back zero instead of stale data, resolving the long-standing FIXME. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 100 +++++++++++++++++++++++++++++++------------------= ---- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index ef738b821e..5bb5043839 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -60,6 +60,7 @@ struct TMP421Class { I2CSlaveClass parent_class; =20 uint8_t device_id; + uint8_t nchannels; /* local + remote */ uint8_t config2_reset; }; =20 @@ -160,12 +161,50 @@ static void tmp421_set_temperature(Object *obj, Visit= or *v, const char *name, s->temperature[tempid] =3D (int16_t) ((temp * 256 - 128) / 1000) + off= set; } =20 +static bool tmp421_channel_enabled(TMP421State *s, unsigned channel) +{ + TMP421Class *sc =3D TMP421_GET_CLASS(s); + + return channel < sc->nchannels && + (s->config[1] & (1 << (3 + channel))); +} + +/* + * A disabled or absent channel reads back zero. The low byte carries the + * temperature fraction in its upper nibble. + */ +static uint8_t tmp421_temp_high(TMP421State *s, unsigned channel) +{ + uint16_t reg =3D s->temperature[channel]; + + return tmp421_channel_enabled(s, channel) ? reg >> 8 : 0; +} + +static uint8_t tmp421_temp_low(TMP421State *s, unsigned channel) +{ + uint16_t reg =3D s->temperature[channel]; + + return tmp421_channel_enabled(s, channel) ? reg & 0xf0 : 0; +} + static void tmp421_read(TMP421State *s) { TMP421Class *sc =3D TMP421_GET_CLASS(s); =20 s->len =3D 0; =20 + if (s->pointer <=3D TMP421_TEMP_MSB3) { + /* high byte read latches the paired low byte from one conversion = */ + unsigned channel =3D s->pointer - TMP421_TEMP_MSB0; + s->buf[s->len++] =3D tmp421_temp_high(s, channel); + s->buf[s->len++] =3D tmp421_temp_low(s, channel); + return; + } + if (s->pointer >=3D TMP421_TEMP_LSB0 && s->pointer <=3D TMP421_TEMP_LS= B3) { + s->buf[s->len++] =3D tmp421_temp_low(s, s->pointer - TMP421_TEMP_L= SB0); + return; + } + switch (s->pointer) { case TMP421_MANUFACTURER_ID_REG: s->buf[s->len++] =3D TMP421_MANUFACTURER_ID; @@ -185,35 +224,8 @@ static void tmp421_read(TMP421State *s) case TMP421_STATUS_REG: s->buf[s->len++] =3D s->status; break; - - /* FIXME: check for channel enablement in config registers */ - case TMP421_TEMP_MSB0: - s->buf[s->len++] =3D (((uint16_t) s->temperature[0]) >> 8); - s->buf[s->len++] =3D (((uint16_t) s->temperature[0]) >> 0) & 0xf0; - break; - case TMP421_TEMP_MSB1: - s->buf[s->len++] =3D (((uint16_t) s->temperature[1]) >> 8); - s->buf[s->len++] =3D (((uint16_t) s->temperature[1]) >> 0) & 0xf0; - break; - case TMP421_TEMP_MSB2: - s->buf[s->len++] =3D (((uint16_t) s->temperature[2]) >> 8); - s->buf[s->len++] =3D (((uint16_t) s->temperature[2]) >> 0) & 0xf0; - break; - case TMP421_TEMP_MSB3: - s->buf[s->len++] =3D (((uint16_t) s->temperature[3]) >> 8); - s->buf[s->len++] =3D (((uint16_t) s->temperature[3]) >> 0) & 0xf0; - break; - case TMP421_TEMP_LSB0: - s->buf[s->len++] =3D (((uint16_t) s->temperature[0]) >> 0) & 0xf0; - break; - case TMP421_TEMP_LSB1: - s->buf[s->len++] =3D (((uint16_t) s->temperature[1]) >> 0) & 0xf0; - break; - case TMP421_TEMP_LSB2: - s->buf[s->len++] =3D (((uint16_t) s->temperature[2]) >> 0) & 0xf0; - break; - case TMP421_TEMP_LSB3: - s->buf[s->len++] =3D (((uint16_t) s->temperature[3]) >> 0) & 0xf0; + default: + s->buf[s->len++] =3D 0; break; } } @@ -317,6 +329,19 @@ static void tmp421_reset_hold(Object *obj, ResetType t= ype) tmp421_reset(TMP421(obj)); } =20 +static void tmp421_initfn(Object *obj) +{ + TMP421Class *sc =3D TMP421_GET_CLASS(obj); + + for (unsigned channel =3D 0; channel < sc->nchannels; channel++) { + g_autofree char *name =3D g_strdup_printf("temperature%u", channel= ); + + object_property_add(obj, name, "int", &int_type_info, + tmp421_get_temperature, + tmp421_set_temperature, NULL, NULL); + } +} + static void tmp421_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -332,19 +357,7 @@ static void tmp421_class_init(ObjectClass *klass, cons= t void *data) =20 sc->device_id =3D TMP421_DEVICE_ID; sc->config2_reset =3D 0x1c; - - object_class_property_add(klass, "temperature0", "int", &int_type_info, - tmp421_get_temperature, - tmp421_set_temperature, NULL, NULL); - object_class_property_add(klass, "temperature1", "int", &int_type_info, - tmp421_get_temperature, - tmp421_set_temperature, NULL, NULL); - object_class_property_add(klass, "temperature2", "int", &int_type_info, - tmp421_get_temperature, - tmp421_set_temperature, NULL, NULL); - object_class_property_add(klass, "temperature3", "int", &int_type_info, - tmp421_get_temperature, - tmp421_set_temperature, NULL, NULL); + sc->nchannels =3D 2; } =20 static void tmp422_class_init(ObjectClass *klass, const void *data) @@ -353,6 +366,7 @@ static void tmp422_class_init(ObjectClass *klass, const= void *data) =20 sc->device_id =3D TMP422_DEVICE_ID; sc->config2_reset =3D 0x3c; + sc->nchannels =3D 3; } =20 static void tmp423_class_init(ObjectClass *klass, const void *data) @@ -361,6 +375,7 @@ static void tmp423_class_init(ObjectClass *klass, const= void *data) =20 sc->device_id =3D TMP423_DEVICE_ID; sc->config2_reset =3D 0x7c; + sc->nchannels =3D 4; } =20 static const TypeInfo tmp421_types[] =3D { @@ -368,6 +383,7 @@ static const TypeInfo tmp421_types[] =3D { .name =3D TYPE_TMP421, .parent =3D TYPE_I2C_SLAVE, .instance_size =3D sizeof(TMP421State), + .instance_init =3D tmp421_initfn, .class_size =3D sizeof(TMP421Class), .class_init =3D tmp421_class_init, }, --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870942; cv=none; d=zohomail.com; s=zohoarc; b=PEIIwZqpFlGNMzVQt/vHwgc0gZCkNz93DkI0PsTO6KTff7NVGMQj070VD8pIIQM5KL0aGsfvKV/BQAmLrCOZGeuYwDFO+I14TmaLmoDhjYnvbtb19KEVvN4DTsvqTSeM6YQzI0seXpXg416mfNbP0i1kXU1RTRpfDfeYAvPgNug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870942; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=81LMFnXNkVBsPiHYzPBdhJHEHa6ngHS1FUyReoYZJfU=; b=X2Hty/1CZhhtfgCt2I8kslQa9h5TH/rq0TP3AeNlHdp0mqpbXwRz2HLSsuaeATR2g3xddKbAhn3o8ljEiQHL+YjW8xlrvtFmPE/P/UiK7uRSVEkr3uGqr2BX3pqZvf/hAZfCdZ2NeO4PxY5nbC6oDqVKDlM0K9Jwea+hyqlgbQA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793870942259995.6419358601811; Thu, 5 Nov 2026 01:29:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtlw-0006oN-6i; Thu, 05 Nov 2026 04:28:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtlu-0006nw-UE for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:38 -0500 Received: from mail-pg1-f170.google.com ([209.85.215.170]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtls-0006x1-Fs for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:38 -0500 Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-cc147d86bebso292540a12.0 for ; Thu, 05 Nov 2026 01:28:36 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b31638fdsm3090889a91.8.2026.11.05.01.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870915; x=1794475715; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=81LMFnXNkVBsPiHYzPBdhJHEHa6ngHS1FUyReoYZJfU=; b=j65YyirimvhqP+e2I5eyNyNXTCSa9CnEQjUu1gKNupFZy0lVJy61N7286xwHXe3TOv UrPTCqQSJeNVWfRzS1S3+qi8Wsyz9IbP5vpqyueiIQugYizjY7fXmX6P6WQNLvUuImaf 9s8z/xD8b4h3U7WzXZd1wvPAyyrywLjPv/zIZYXmoko2MYrGHk3tZJwtQW9XraEZV1X4 iObl1SmZNFhWtvNauh+KeVxU/856boi33PsWhpiahLJbOxclFF2ku9G2DJNDd0K1wtV2 0ijfJL5TX8jUIySYtwdOHZbQP6AEiAL0Z8us2lsS9ic1PNJ50qVAon3vsYPlSxvdiObZ wm+Q== X-Gm-Message-State: APuU4Z9SAdP5CouXmwVuXyStuGmitfHvu2ApmwVFEmsswGQ4eOsxIvwq n2RVkfdh9M3mXEoUP5IhQirRbWspBJVPDRIDB9Iibq6I25k6CrKPAjRJ4q4jg6mxQDI= X-Gm-Gg: AYBFou0a7ZiJ8dK8uI7v5pd5RGoLW9y/3qon+XAtIPgVpopwF1A2SZlmhM1wvQV0CnG 51+/MFujc+/thOcCB8nRyMDT1Nnm3Ditmbo7Hcu1/9DyiJ6vW8vx18GfHc74xNlhBumCPbIwQcC 7HbVfgfOyMsIGsXlg65zCzdzukEBtvVj46AgDUObh1Q5PCXqf8blYPEF5lruH5M78W9bPiY+sUA 9+p/VdgkKfqZnneLTK1AnIYU6eVEWsWMIRiJUhKP0LmBN3k9guxyaH3MHp86+GGeFS93anrHM9S T5J73nnRgF+0Aa6ZqKal44ybprvKOnZ8983uYs2hAbj/y9wrPIJXoZ2NWebPlQS8fov/IZIHpAw Z2aOtXYqWlorxKPPIyMM30kr1cZOkaGwgWuJf18L7gr2VkrLFCe8pxX2fZUQhp4TrsPojCn947R iJHzdp5I6rgwG4YjHm+rOhFXOodMoZorQ2ShVw/r66OKsoO0NG/hUe941dFCPtac/Le4m5ejiVg qOVu6MMPVAqK4hoPl+DluMJUpRhLebN4/DMvqwgpxwDK9MlI1bkvlgQd0LEgE6daJefbrnaM61Y cRZ9r6FEnldmBNDhr9H8Sq9tA+N5tvCYCfSbSStUQtkMIuWgJHXGrX8FTiNUmF22+cFk7ChOqI8 d X-Received: by 2002:a17:90b:3cc7:b0:3ae:3b3d:c617 with SMTP id 98e67ed59e1d1-3b0afc64579mr1671344a91.29.1793870914894; Thu, 05 Nov 2026 01:28:34 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:45 +0800 Subject: [PATCH 06/16] hw/sensor: tmp421: implement register write masks, one-shot and N-factor MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-6-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=5041; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=th0BNPuLtBgK0HCmTvU0Ku8z2E6KSY0kShjV+vGaOoA=; b=GEqE7/FhvctPDBGn5D4B7rKpWjumCg+M3j6SCP8ecrq6NXYMBCSKrMW2fzQnn25JOLirPbIXa K3EDj9ovzRtDCOFTXH7GnOQZejq9BFsnCbJKAv8noG/p9ri58XoG7NL X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.215.170; envelope-from=eblot.ml@gmail.com; helo=mail-pg1-f170.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870942845158500 Mask out reserved and absent-channel bits on writes to the two configuration registers and the conversion rate, accept the one-shot trigger, and back the per-remote-channel N-factor correction registers with real storage. The N-factor state migrates through an optional subsection. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 5bb5043839..8c789a2a09 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -22,6 +22,16 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, see . + * + * Limitations: + * - Conversions are instantaneous. The conversion-rate register and the + * shutdown bit are stored but do not decide when a measurement appears, + * and a one-shot write is accepted without scheduling anything: a read + * always returns a fresh value. + * - The N-factor correction registers are stored and never applied. The m= odel + * has no ideality factor to correct for. + * - The sensor-fault OPEN bit and the PVLD bit of the temperature low byt= e are + * never set, so neither an open circuit nor a low supply is reported. */ =20 #include "qemu/osdep.h" @@ -45,6 +55,7 @@ struct TMP421State { /*< public >*/ =20 int16_t temperature[4]; + uint8_t n_correct[3]; /* remote channels only */ =20 uint8_t status; uint8_t config[2]; @@ -86,6 +97,8 @@ OBJECT_DECLARE_TYPE(TMP421State, TMP421Class, TMP421) #define TMP421_CONVERSION_RATE_REG 0x0B #define TMP421_ONE_SHOT 0x0F =20 +#define TMP421_N_CORRECT 0x21 + #define TMP421_RESET 0xFC #define TMP421_MANUFACTURER_ID_REG 0xFE #define TMP421_DEVICE_ID_REG 0xFF @@ -204,6 +217,11 @@ static void tmp421_read(TMP421State *s) s->buf[s->len++] =3D tmp421_temp_low(s, s->pointer - TMP421_TEMP_L= SB0); return; } + if (s->pointer >=3D TMP421_N_CORRECT && s->pointer < TMP421_N_CORRECT = + 3) { + unsigned idx =3D s->pointer - TMP421_N_CORRECT; + s->buf[s->len++] =3D idx + 1 < sc->nchannels ? s->n_correct[idx] := 0; + return; + } =20 switch (s->pointer) { case TMP421_MANUFACTURER_ID_REG: @@ -234,15 +252,29 @@ static void tmp421_reset(TMP421State *s); =20 static void tmp421_write(TMP421State *s) { + TMP421Class *sc =3D TMP421_GET_CLASS(s); + + if (s->pointer >=3D TMP421_N_CORRECT && s->pointer < TMP421_N_CORRECT = + 3) { + unsigned idx =3D s->pointer - TMP421_N_CORRECT; + if (idx + 1 < sc->nchannels) { + s->n_correct[idx] =3D s->buf[0]; + } + return; + } + switch (s->pointer) { - case TMP421_CONVERSION_RATE_REG: - s->rate =3D s->buf[0]; - break; case TMP421_CONFIG_REG_1: - s->config[0] =3D s->buf[0]; + s->config[0] =3D s->buf[0] & + (TMP421_CONFIG_RANGE | TMP421_CONFIG_SHUTDOWN); break; case TMP421_CONFIG_REG_2: - s->config[1] =3D s->buf[0]; + s->config[1] =3D s->buf[0] & sc->config2_reset; + break; + case TMP421_CONVERSION_RATE_REG: + s->rate =3D s->buf[0] & 0x07; + break; + case TMP421_ONE_SHOT: + /* starts a conversion in shutdown; conversions are immediate here= */ break; case TMP421_RESET: tmp421_reset(s); @@ -292,6 +324,24 @@ static int tmp421_event(I2CSlave *i2c, enum i2c_event = event) return 0; } =20 +static bool tmp421_n_correct_needed(void *opaque) +{ + TMP421State *s =3D opaque; + + return s->n_correct[0] || s->n_correct[1] || s->n_correct[2]; +} + +static const VMStateDescription vmstate_tmp421_n_correct =3D { + .name =3D "TMP421/n-correct", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D tmp421_n_correct_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT8_ARRAY(n_correct, TMP421State, 3), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_tmp421 =3D { .name =3D "TMP421", .version_id =3D 0, @@ -306,6 +356,10 @@ static const VMStateDescription vmstate_tmp421 =3D { VMSTATE_INT16_ARRAY(temperature, TMP421State, 4), VMSTATE_I2C_SLAVE(parent_obj, TMP421State), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_tmp421_n_correct, + NULL } }; =20 @@ -317,6 +371,7 @@ static void tmp421_reset(TMP421State *s) * The measured temperatures are not cleared: they model the physical * input the ADC re-samples after reset, and boards may preset them. */ + memset(s->n_correct, 0, sizeof(s->n_correct)); s->pointer =3D 0; s->config[0] =3D 0; s->config[1] =3D sc->config2_reset; --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871045; cv=none; d=zohomail.com; s=zohoarc; b=BuvxajPZTGxz9qodO+qH9C4ejKp5BdwSx5MxhV7BZEYU3otas5fqWFLeJmK6wR9K0hDp/h5TFCrErPNyRGAKJYGxZ3BQXrC269G/Ap1K99IaHll8DMoO6X/KH+Ve83bhC/WZePKqmw+hsnRzQkvVDvoQMKxeIOZLdCjhM12G12o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871045; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=1BfKbNBFOgpv4Y4gegCRNCEDAhIiNTLP3qGg6/c2kSc=; b=Mw0LUJmgQV6ukZ855FXHYh7lS38pse/9WBXb19gDrwJGjGU2FvEanLbna2Rz8E7h4PZ7F5XC+xv6zTRAr6m5jnJPlJK5/2Y4dBWS4B5SHq2rzsUcBs7HRJdjmGoslHK8tkWS73Z+i3aZR8GNuT46DCoxGCxgcutmV5hUra65eSc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871044980388.01184794202686; Thu, 5 Nov 2026 01:30:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtm7-0006xu-9D; Thu, 05 Nov 2026 04:28:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtm2-0006sn-FD for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:46 -0500 Received: from mail-pg1-f181.google.com ([209.85.215.181]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtm0-0006xP-7M for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:45 -0500 Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cc4c02ddd62so1071729a12.0 for ; Thu, 05 Nov 2026 01:28:43 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b32812a6sm2905960a91.11.2026.11.05.01.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870922; x=1794475722; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1BfKbNBFOgpv4Y4gegCRNCEDAhIiNTLP3qGg6/c2kSc=; b=KWWkdJDYeUZXyT77aPEfi2q6u+ITwomuySeUT2blk14gKnL3EPdGcGWGfiIe3zCTCM E7gUkyXwd1Vo4jxnhzHYasi0d7sRJKiomKyJDIncsSJT+ZdT9Qxxg5EYzU7bDb8u7oBY jFzvtVDdof+BZgyOWd4nMwAHig7LxAu7N2ipq0EXojahXN4y3bhzE9h3l0nwDlYuLUrU WQZKUOYVtREZHzNO2MM7N0X9/Rp5YlVBBCvd+ThwA6R6uIQS5wLFGKNvgJslvEtdzUW6 nSSUCi3vIMIh5qs5F0eaQPyH1qnW5znbGDwXf4z3kB+ipfrDkSQ+JGVvG00Mfn+Jni5y hYpA== X-Gm-Message-State: APuU4Z91M+v+MAyXjsB3/oRsVh0Mnr/fG9G8ALdDinvTZTNIsgKnjx// rU/VaGH0A1wCzeQlPplyQMxcEUgiSc9QgSuSh8XKALLIpebLfWrLD2bNk/aUIw== X-Gm-Gg: AYBFou3NubKSqoBKq+hu62oBC65Cov0T4sVjNrhl8yW1M+hNUAI4ecZ5zfhfF7kdIm0 O5r77G44gfxGHS1ZzuKq3ei9t1JRKD5Zd4LtV5Sv8SDgIos9SLq3EegtxUThOUxgpIjWH2IjjNC UeXXSfAiliERO3VZVmckOuXq++9YTt1n3uDUyuyYOu3pEfzfv1BF6C1UGvwdDSNoRLcYn5k30Da SYvGnLdEgvHcN0ypc6Pd+tmYkzFUpIU6F4eSjoFtX96o8upmMMsNi3k/GOvISZ2/wXNVEI3+WjK hLYirsbDSWNESfY1CKxmgFspowl2xPwrsDuK5+F1ceoEY3cfyx5Mr0gDtx5eEcO74U8J1QRpOrm eQ5iPmWsc1KoWZ55n7kDbxrRe2F8yGL5N4Vecw5utGU73SOhOR6pcLt8ZoPnbqojKNBw4esqc1r TtFFVbEmkuIT7ZmDPHXvVE4sMVUgU7fuGTB4w3A6Ec7SVCuuYzcdpzc0aGmD65oZaGUiFnQUKs/ EjY1tIcASAZ4i7qOVvO/tg3SYN5O5PLNsMpZ+/9YSbYK9nsdH8b3saZKpMNP27aAgV5ucWZ0Mar ATcQH2jI+CMHNGcRFN85tybN32ReMayJkiJ0GesvTbYWTQUdRBjKDjqVBvkEPsAWVCghh3md2OZ u X-Received: by 2002:a17:90b:2d04:b0:3a7:82ef:bcdd with SMTP id 98e67ed59e1d1-3ae898392c2mr15401312a91.41.1793870922455; Thu, 05 Nov 2026 01:28:42 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:46 +0800 Subject: [PATCH 07/16] hw/sensor: tmp421: describe the temperature properties MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-7-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=763; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=rdU7Q4ra6hFL/RukQf2lAq3++tTLRvjIbFGIs0BPyVk=; b=gHy6jygsujU3TkBwYzMUu50wtfF+0PSbeqDLhd0/lsBaXVnEZGGP/k3MIVvZKNgBcC9+ifQ6w wpEcfwTeFETCkS9fdzKjI7Gmk2xAE6pr84pjXYLOScuNQT6fOGoFhfD X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.215.181; envelope-from=eblot.ml@gmail.com; helo=mail-pg1-f181.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871046686158500 Attach a description to each temperature property so it shows up in qom-list-properties. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 8c789a2a09..87cbd9dd4b 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -394,6 +394,8 @@ static void tmp421_initfn(Object *obj) object_property_add(obj, name, "int", &int_type_info, tmp421_get_temperature, tmp421_set_temperature, NULL, NULL); + object_property_set_description(obj, name, + "Temperature, in millidegrees Celsius"); } } =20 --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870972; cv=none; d=zohomail.com; s=zohoarc; b=K6EdptFodbfrBsgkqlgJD0XVbbTBmtuBkkmxIAHd7eQ/b1c293bCXvyoapiP4LTgJ40ais0BwRM6YVF6gbH9+lCNBkV5eg/gi84mXMqaUhvpARoJLy0eLydAlh+qhFAuq2EJCnBa4OSF09Qk94Ffa/Q77RmyG74OlQBfhEA9HX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870972; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=mKxKyo4fCuncIjIg3ptOGVyWIQnIG439vq+7oNa+8Mg=; b=cPJpa++UVWr0rrNdiNOwNSAwgGFF6s+5Ox9BjCyOx+GIt+GE5My+1L2w9wB5D/A1As8CeaQ89gxp2JQ9cn4hhRSh7mwSWRImSuTGDM84vvYL5N+YRI1RHyhGY571fTB3F9WauW1m6DzH1IxKCE4R/nDXt+G0FWhsQSDvSy0cqoY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793870972809837.794009787134; Thu, 5 Nov 2026 01:29:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmH-00077z-KH; Thu, 05 Nov 2026 04:29:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmB-00072L-35 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:56 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtm7-0006xr-C4 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:28:53 -0500 Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-8a39e5161c1so1371113b3a.3 for ; Thu, 05 Nov 2026 01:28:50 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8b09a8c303dsm1720886b3a.20.2026.11.05.01.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870930; x=1794475730; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mKxKyo4fCuncIjIg3ptOGVyWIQnIG439vq+7oNa+8Mg=; b=W/Yc1PSoAO/URUcntBKsJNbvVKyaEzlLjRjlEwT+Q31qwYacFUePHR/f4nRWbmDTgh NbRgGteofLZSPisrASFQVi7ky5yOkDOrqSd2phEnE2N/qOalwj2I99p/9TqyS03w9RUj +/qiJRVRc5TX2l/F0Y8iEFXYWWWvqL2ENjBk3+xnfBp3Bwv5sxLjAz1UVEdKj7xWeHC1 IZ4WJvwTfVvTtXFMACGxoeGadt/+SLiNN+4wJaDJZjHpAJ2RWEfsh7jjDL52IWOVqanR ykOZYKMVyZbPJNIHp3Ve1devBD4c/W3xej+16dugsPGBySLNgpzuizpRJEuzW1LD0q/X WbGg== X-Gm-Message-State: APuU4Z+VsGd0pGLtpoXQtV7Hmi31h1VZOPfp+biG3eOUFVcWqn/I9Oy1 KflLIW6AGXN2pns/o7YD34yhW+af+ySflcboPkwE1Vs+QG2bvkDkZPnBAs5OVyfPxbc= X-Gm-Gg: AYBFou1y0ByUxnUD6uwg89Jt/4QJ3yHsnpyUTQudbt2vSV6VTamAGoqh08uOzKZxeGF A+c2WaTw2yk5Xl1DjIB0ahxLbCXfQrez4IelUEegnyAm/Y53X0EE6+N7g9N6O+ia6EM28pHlCV1 MPFJf8c5J6DEQOD7QdHl4yCFiGIsbhA4BtMJZuH214AhXzX29qz2/VBDD304gU/jWQE0NEFQowT YX4DPoG6KS5meAMR9G2PdwEhFPKD7+0O2EBP9+6bswI1fqYcW3gVhp0ibRfLHz9/ERVIMznW9A7 7Ae6t15R+G4sdgQfFR/9yzmdM1Tvc6vyMYV+ltc8MHrat5R6ZEfwEBydvmRO/wPty/QjQZ+KCP/ kE5AY/EmPjrcy5+vGmsWIIZl9PO+iVVf71DylNmDlo1D5aMGoht0FWLpX9OlhxQ6boea5E4XoSE 7UT7wLScyAmNjuELi4V9Bc2h3G9Twt26MFigbsGZZRNfsCDfePsSDYqMMQllK0wuGHuizGT484X k8F3v7C0/zOMw/NejnvomCtTq8qGa0ZSMWCLAIQUlrLKzSkYsv6wLU40Q+KvPjAgKTc61nkWQ8t TdbQAgD2hkheznVK/b6DGcOhTk/vwUR+DUYgkte45nbt71WhJab9KYCFk+lqiSEXy4v2poHySFC d X-Received: by 2002:a05:6a00:2e8f:b0:8a0:1c79:b442 with SMTP id d2e1a72fcca58-8a9b69872fbmr16762945b3a.0.1793870929824; Thu, 05 Nov 2026 01:28:49 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:47 +0800 Subject: [PATCH 08/16] hw/sensor: tmp421: keep the measurement across a range change MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-8-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=6919; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=qoPYlE2KGeqUXqEXuY48ROoEFeJ8AsOvINnq4nphwJk=; b=qq0WB1SHrobf5sZ5jZDqQ2ARcuPd9ctGUgou38hVw2o322Q8stvB+Vob7RxELr6f1L6jHnzHX NmfOje17jK4BBF++TGqTkpfGUdmj/G9dXk5WVYZR2+luzJIn627FHgB X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.180; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f180.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870973403158500 The model stored temperatures in their register form, which carries the extended-range offset. Leaving that range therefore reinterpreted the stored value and shifted the reported temperature by 64 degrees, whether the range bit was cleared by a configuration write or by a reset. The encoding was wrong at both ends too: the extended range is offset binary, so it does not fit a signed register above +64 C, and neither range saturated where the datasheet says it should. Hold the measurement in millidegrees and derive the register from it on each read, which is what the range bit selects: an encoding, not a new measurement. The stream keeps carrying the register form, which is what a released QEMU writes and expects, so it stays loadable both ways; the measurement is converted to and from it on save and load. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 96 +++++++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 81 insertions(+), 15 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 87cbd9dd4b..943295240d 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -54,9 +54,13 @@ struct TMP421State { I2CSlave parent_obj; /*< public >*/ =20 - int16_t temperature[4]; + /* Measured temperature, millidegrees Celsius */ + int32_t temp_mc[4]; uint8_t n_correct[3]; /* remote channels only */ =20 + /* migration only: the register form the stream carries */ + int16_t temperature[4]; + uint8_t status; uint8_t config[2]; uint8_t rate; @@ -115,12 +119,51 @@ OBJECT_DECLARE_TYPE(TMP421State, TMP421Class, TMP421) static const int32_t mins[2] =3D { -40000, -55000 }; static const int32_t maxs[2] =3D { 127000, 150000 }; =20 +/* + * Register form of a measurement (datasheet Table 1): whole degrees in the + * high byte, the fraction in the upper nibble of the low byte. The standa= rd + * range is two's complement and saturates at -64 C (C0h) and +127 C (7Fh); + * the extended range is unsigned with a -64 C offset, spanning -64 C (00h= ) to + * +191 C (FFh). The range only selects an encoding: the measurement itsel= f is + * held apart, so switching range re-reads the same temperature. + */ +#define TMP421_EXT_OFFSET (64 * 256) +#define TMP421_STD_REG_MIN (-64 * 256) /* C0h, -64 C */ +#define TMP421_STD_REG_MAX (127 * 256 + 0xf0) /* 7Fh, +127 C */ +#define TMP421_EXT_REG_MAX (255 * 256 + 0xf0) /* FFh, +191 C offset */ + +static uint16_t tmp421_encode(const TMP421State *s, unsigned channel) +{ + bool ext_range =3D s->config[0] & TMP421_CONFIG_RANGE; + int raw =3D s->temp_mc[channel] * 256 / 1000; + + if (ext_range) { + raw =3D MAX(0, MIN(TMP421_EXT_REG_MAX, raw + TMP421_EXT_OFFSET)); + } else { + raw =3D MAX(TMP421_STD_REG_MIN, MIN(TMP421_STD_REG_MAX, raw)); + } + + return raw; +} + +/* + * The inverse of tmp421_encode(). Only the standard range is signed: the + * extended one spans the whole byte, so its top bit is a temperature, not= a + * sign. Rounding follows the sign so that every register value the encoder + * can produce decodes back to the measurement it came from. + */ +static int32_t tmp421_decode(const TMP421State *s, int16_t reg) +{ + bool ext_range =3D s->config[0] & TMP421_CONFIG_RANGE; + int32_t raw =3D ext_range ? (uint16_t)reg - TMP421_EXT_OFFSET : reg; + + return (raw * 1000 + (raw < 0 ? -128 : 128)) / 256; +} + static void tmp421_get_temperature(Object *obj, Visitor *v, const char *na= me, void *opaque, Error **errp) { TMP421State *s =3D TMP421(obj); - bool ext_range =3D (s->config[0] & TMP421_CONFIG_RANGE); - int offset =3D ext_range * 64 * 256; int64_t value; int tempid; =20 @@ -134,21 +177,18 @@ static void tmp421_get_temperature(Object *obj, Visit= or *v, const char *name, return; } =20 - value =3D ((s->temperature[tempid] - offset) * 1000 + 128) / 256; + value =3D s->temp_mc[tempid]; =20 visit_type_int(v, name, &value, errp); } =20 -/* Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8 - * fixed point, so units are 1/256 centigrades. A simple ratio will do. - */ +/* Units are 0.001 centigrades relative to 0 C. */ static void tmp421_set_temperature(Object *obj, Visitor *v, const char *na= me, void *opaque, Error **errp) { TMP421State *s =3D TMP421(obj); int64_t temp; bool ext_range =3D (s->config[0] & TMP421_CONFIG_RANGE); - int offset =3D ext_range * 64 * 256; int tempid; =20 if (!visit_type_int(v, name, &temp, errp)) { @@ -171,7 +211,7 @@ static void tmp421_set_temperature(Object *obj, Visitor= *v, const char *name, return; } =20 - s->temperature[tempid] =3D (int16_t) ((temp * 256 - 128) / 1000) + off= set; + s->temp_mc[tempid] =3D temp; } =20 static bool tmp421_channel_enabled(TMP421State *s, unsigned channel) @@ -188,16 +228,14 @@ static bool tmp421_channel_enabled(TMP421State *s, un= signed channel) */ static uint8_t tmp421_temp_high(TMP421State *s, unsigned channel) { - uint16_t reg =3D s->temperature[channel]; - - return tmp421_channel_enabled(s, channel) ? reg >> 8 : 0; + return tmp421_channel_enabled(s, channel) ? + tmp421_encode(s, channel) >> 8 : 0; } =20 static uint8_t tmp421_temp_low(TMP421State *s, unsigned channel) { - uint16_t reg =3D s->temperature[channel]; - - return tmp421_channel_enabled(s, channel) ? reg & 0xf0 : 0; + return tmp421_channel_enabled(s, channel) ? + tmp421_encode(s, channel) & 0xf0 : 0; } =20 static void tmp421_read(TMP421State *s) @@ -342,10 +380,38 @@ static const VMStateDescription vmstate_tmp421_n_corr= ect =3D { } }; =20 +/* + * The stream carries the register form of the measurement: that is what a + * QEMU predating the millidegree state writes, and what it expects back. + */ +static int tmp421_pre_save(void *opaque) +{ + TMP421State *s =3D opaque; + + for (unsigned channel =3D 0; channel < ARRAY_SIZE(s->temp_mc); channel= ++) { + s->temperature[channel] =3D tmp421_encode(s, channel); + } + + return 0; +} + +static int tmp421_post_load(void *opaque, int version_id) +{ + TMP421State *s =3D opaque; + + for (unsigned channel =3D 0; channel < ARRAY_SIZE(s->temp_mc); channel= ++) { + s->temp_mc[channel] =3D tmp421_decode(s, s->temperature[channel]); + } + + return 0; +} + static const VMStateDescription vmstate_tmp421 =3D { .name =3D "TMP421", .version_id =3D 0, .minimum_version_id =3D 0, + .pre_save =3D tmp421_pre_save, + .post_load =3D tmp421_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT8(len, TMP421State), VMSTATE_UINT8_ARRAY(buf, TMP421State, 2), --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870968; cv=none; d=zohomail.com; s=zohoarc; b=GqFfPd/mvClYuj4cc8wOhRGsvM34YLsxJkgxdr+XSMXAKGgFtMLu9dqk+yPe1Z2EHuOTeSSU8sEmLb6wJofajbfjJYKnYw2T16DT4zDoZgiPDzgeKgdMpIMiEIQBeG01XfCr//9imc5jigkBrbMj5Gb8IRSw8OurmZorA9MLRWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870968; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=m9zQSOewUBeGGhmPONHFHebxBVsiYOdk+rPiNV2Yw/M=; b=Be/Vccb3cFs1evED93DzCXzzLfARRP+S+sYRNOkRCn3BZbXkmyrpWhl1SIwO4rKFTnk5eoFTCKryZPSVbCALndMk19aLaOB3GKhuQpmyS8WNAWTf3yT7s8pVrk141RJh8XomlGYlsLLV5sxSXbOEIqbVc9gJYs97vNoCCkzpY00= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179387096799154.95211775067719; Thu, 5 Nov 2026 01:29:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmJ-0007AL-Nu; Thu, 05 Nov 2026 04:29:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmH-00076N-1j for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:01 -0500 Received: from mail-pg1-f182.google.com ([209.85.215.182]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmF-0006yI-47 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:00 -0500 Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-cdb628232d2so24633a12.0 for ; Thu, 05 Nov 2026 01:28:58 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b094dec0e3sm3395847a91.1.2026.11.05.01.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:28:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870937; x=1794475737; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=m9zQSOewUBeGGhmPONHFHebxBVsiYOdk+rPiNV2Yw/M=; b=VQ5/DgDRN7XmaiIe51HpdrNfajwqqf6A4l6zIoR1TAh31jQnSDppdpoe3hfA7RonQk sie7hggo9LNw2jbRfuAW/kAD3/NTTwIn8mT/nT2UTVdMIauXg/xz8x5A/s8ExtAmQcOk VddPOWp7rGccn5SbGdJQJ/+vW9Jmq0gbWXKdjBE3KThhiqwUItiTM24z7vPDEUPwCK+K Rfk8PoxXaHbA3vyv4M1g4U9hBGMqcRhzolmXsVnzIdZgx2qKcuV7DdWu4NUyUsjQ67Ai E7Bf8fhg8/G9hXqDDgIDZ+9TkktEkvhVqE5H2MHT93D9WCIBG5rZxSlfVLrvjIMZE6bH P5ug== X-Gm-Message-State: APuU4Z8TcXbmXpN46m1gP899hv9iP7IGoWu8YgGdqOq1yMQQNNc+7WG7 l3CcrSdgqVlpd2OPAYpafaKjgzS9NZpxVCaUvCxri4UZB4pjrxXD80uys6gGemipCV8= X-Gm-Gg: AYBFou34aHtemDXWh55HKhMYUnwBRxV0Za1WB5IqlI1k3aUbMSwPuFnTaHl73y+G7Gz w2shGq/73cUA6wLCW7aed4XCBicbdM1tmyPPwnbvSJ9eWxgmxxBSti4PWu7W5qcp03x5+n1gmq5 gIzcsZ5gfsHjnUkTAw+dvNoccUClJbVe3Z+O5e4qZizY2QcIId58zLTezQdhqIyMEx7W+Jw7rI2 asUGl2wd3yhI3zYNNNoNI57fwIMn7tjbQ3C4mGrEgO14DzhiMxqiKW12YEyqHtIuo/BJlghQjzo iPaLS6ggqH8lizvEaclY+UNK0K41XRSA50Hy1p1ZAWqKnog7zASXpCk+Bd8pkAIdEpGCo1uNSC0 0R5twYVMkPGzqzUW2EHr9V4Lh0YrroBa+ravWzicqpuVbe+p7cgV6wtk6Hp/Db+59qtbs/9QEX7 4FJbR+6GQUaKsuhlT2knKLpB2gCCVAv/+ysvzHbNOydYq+cMEnNWjNFvGKIsrEXIuOUiFeq4Tag yo2kQ/lkJ4NzBZr9ZZOyzpjkeDMMifDr5q013JFX20tDiHlZN6ySW0lY0DdNAKKyFhF0jxpZp3q UdDiUcYe9XSnAXFxR5YlXoE7oaGKFriV0NFmQrCvSSm+9ujGl56UESx7jGRL9U14JTjASAxXqTn r X-Received: by 2002:a17:90b:2ecc:b0:3ac:6fcf:91d2 with SMTP id 98e67ed59e1d1-3ae897c64fbmr16442723a91.19.1793870937365; Thu, 05 Nov 2026 01:28:57 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:48 +0800 Subject: [PATCH 09/16] hw/sensor: tmp421: migrate the exact measurement MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-9-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=3784; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=s1Fn+bQ71xnXmSCzvqiaHUL+siL1Ys4lowpPQMHLKzs=; b=3FvekpxYMe4VR/ANlwP5iRX3fI30QPDBLKgXmyV5rAG/xkCUSnh0H5gT6X1Rb5xI8NUJ7Bvy9 Un2c0ll6GKLDc3CsXoorIotp6ru0WgS/2lOlGtfwmrq7DwVSrQEHkxO X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.215.182; envelope-from=eblot.ml@gmail.com; helo=mail-pg1-f182.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870969338158500 The register form the stream carries only resolves a sixteenth of a degree, so a temperature set through the property does not survive a round trip unless it happens to fall on that grid. Add a subsection holding the measurement itself, sent only when the register form cannot reproduce it. A stream from a sensor holding an expressible value -- the usual case, boards preset whole degrees -- therefore stays loadable by a QEMU that knows nothing of it. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 943295240d..1966301d7a 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -60,6 +60,7 @@ struct TMP421State { =20 /* migration only: the register form the stream carries */ int16_t temperature[4]; + bool temp_mc_loaded; =20 uint8_t status; uint8_t config[2]; @@ -380,6 +381,56 @@ static const VMStateDescription vmstate_tmp421_n_corre= ct =3D { } }; =20 +/* + * That form only resolves a sixteenth of a degree, so the measurement its= elf + * travels in a subsection -- sent only when the register form cannot + * reproduce it, which leaves the usual stream loadable by a QEMU that does + * not know the subsection. + */ +static bool tmp421_temp_mc_needed(void *opaque) +{ + TMP421State *s =3D opaque; + bool ext_range =3D s->config[0] & TMP421_CONFIG_RANGE; + int32_t offset =3D ext_range ? TMP421_EXT_OFFSET : 0; + + /* + * The register form reproduces a measurement when the conversion divi= des + * exactly and the encoder had nothing to clamp. Asking the decoder + * instead would settle the question with the function whose result the + * subsection exists to protect, and hide any error it has. + */ + for (unsigned channel =3D 0; channel < ARRAY_SIZE(s->temp_mc); channel= ++) { + int32_t scaled =3D s->temp_mc[channel] * 256; + + if (scaled % 1000 || + (uint16_t)(scaled / 1000 + offset) !=3D tmp421_encode(s, chann= el)) { + return true; + } + } + + return false; +} + +static int tmp421_temp_mc_post_load(void *opaque, int version_id) +{ + TMP421State *s =3D opaque; + + s->temp_mc_loaded =3D true; + return 0; +} + +static const VMStateDescription vmstate_tmp421_temp_mc =3D { + .name =3D "TMP421/temperature-mc", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D tmp421_temp_mc_needed, + .post_load =3D tmp421_temp_mc_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_INT32_ARRAY(temp_mc, TMP421State, 4), + VMSTATE_END_OF_LIST() + } +}; + /* * The stream carries the register form of the measurement: that is what a * QEMU predating the millidegree state writes, and what it expects back. @@ -399,9 +450,13 @@ static int tmp421_post_load(void *opaque, int version_= id) { TMP421State *s =3D opaque; =20 - for (unsigned channel =3D 0; channel < ARRAY_SIZE(s->temp_mc); channel= ++) { - s->temp_mc[channel] =3D tmp421_decode(s, s->temperature[channel]); + if (!s->temp_mc_loaded) { + for (unsigned channel =3D 0; channel < ARRAY_SIZE(s->temp_mc); + channel++) { + s->temp_mc[channel] =3D tmp421_decode(s, s->temperature[channe= l]); + } } + s->temp_mc_loaded =3D false; =20 return 0; } @@ -424,6 +479,7 @@ static const VMStateDescription vmstate_tmp421 =3D { VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription * const []) { + &vmstate_tmp421_temp_mc, &vmstate_tmp421_n_correct, NULL } --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793870977; cv=none; d=zohomail.com; s=zohoarc; b=HoM4iddS9zj71emiH3QLyprXNuP8ET2gd0eP128EcchhqukP+zuo64AGFuPH2krZkrA+VGqLsSGcQG5lPWlrOAPRpK0iARJgxStb1DLw4Pa20m+tJxF2GpsmQ2xN04cz5pUHpyvwK5JEUp/B8OcKI9RsghdJhUx4AV/CeDqCFaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793870977; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=4Ikq5dso/tV2KB9ZjIepHD6lIEC4kho5MyhHbP8Uxvg=; b=Td0EpMYs4XfbJvchDWgGpaQJqPhmXoolOMTiPe5rfiacat2um5msslL52ayFCI9CudGJiWfX5CTK9HFpCZpQviRniSPHniFz9NKkwGGJLqPE4e9UUW9KsIRin6v/EECr2ojsIWTjwFNeBtab4hjuKcCjgoshL4/C1tILKn7aFL4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793870977666735.3085707837846; Thu, 5 Nov 2026 01:29:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmS-0007fb-Gi; Thu, 05 Nov 2026 04:29:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmP-0007T8-9T for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:09 -0500 Received: from mail-pf1-f174.google.com ([209.85.210.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmM-0006yn-W5 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:08 -0500 Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8a058315c79so912780b3a.3 for ; Thu, 05 Nov 2026 01:29:06 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8b09af91d32sm1791343b3a.25.2026.11.05.01.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870945; x=1794475745; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4Ikq5dso/tV2KB9ZjIepHD6lIEC4kho5MyhHbP8Uxvg=; b=154v9vZ1P8ajOFzlwES2ot3R6yEfgq9Pf5wbPVwOg8zqK0mJXbjGP7rgqmEK1A5mlp OKRp4qNWZg2HwkqGrSoHDfQdXRt7lUURlWbTNViMwQ0rykHxlU2dT8YB3e2JHik9Gsix iGPuKug+ZyOvE5BSkzj6SsNfTBqKmPjk8hyYHrj2JlWWDw66orRuOPiRrTuy479HyZDe PF96VaWoWbxMqa8q2iK9atTO87OUN/wkz4cAwMNV2FESbYR25EZ3POtJA9IRzmv+DGZI XMPovSNOa0VYtAmMaZVVUxfxbna+M1LROU5otNC9pHJJdGHpgQD1UQJbOvuaUQDuvEZB BUUQ== X-Gm-Message-State: APuU4Z+bfpUhQOjk+J1Q9dJocDPCl7t7+TCd0f2ypARrA7kgnWYDzONF B7V6OT11Jvv6DTk6ytJXjiM3yc0ktGONU7gXdhpUWasJ3D0wrZPNQgjFKL6ptOFQnZM= X-Gm-Gg: AYBFou18mcPelUKEAHWMnNdOlddOqFG9Z9BAuXtogiah3sfoWxuX7PoYvbGaIg30VZC HJk3gvVLULt1c3OZ5lFFmvigGh+IayGRZhG8HVe9p1os9b9oV/mGQgrYh37qG9bBdkdGScsBJu2 axCdh9BnO2kcKUNLSXW0SJZcfQZWADw3lV/bTtg7SwuiDC1/xunCHtfiZgsPKOiqlHq3nZMxsJa bPxY18V1/c+bDub0X+8FOOx+de0/6GAz8uCVKsBVuy2Cz+AWew+CzbDvxgcBQUC0mCUqcuLcbFg aNPRoAKF82XyTcQ9HNaLvaCPtM/qUKDiHhuvjbEeqzFI0FIaq8vit8883XHnzW3B/jHx+30PfLj XLX94hSOqBpTZyGiVowT0J+xowPe3LmH+nRpEqECetYoLW/k/K4XvKTzQeNzqtA/CEXJhbWhrI0 A7PYNm3fb6LdoifeLbkHd98Na5IaueiYA+A+m8xhyP9/hZlcpCJdQSkXXBsLmQrtBghbw2QNiOh uMTAyo8UXk28gLeYdSFezmVCkGfoH/zs77zuqamE4qFozcGCbqTxYt4Wld9YCNgSkFZZTQNaj/v yNeiChrmV/gmhDE6X6lHrJb/+ir76GJWZlh0iCfumazFFVt8/O9AP+q/qm975VMciFnXHOs/V/n S X-Received: by 2002:a05:6a00:98c:b0:8a7:917:43a0 with SMTP id d2e1a72fcca58-8a9bcff6a1bmr15696322b3a.15.1793870945064; Thu, 05 Nov 2026 01:29:05 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:49 +0800 Subject: [PATCH 10/16] hw/sensor: tmp421: publish the variant type names MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-10-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=1627; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=SMWdOalFbioPmdcZYsqzKWLV2yaatF5BDs26GQ0sHwM=; b=JVBN6QuDqwdWKorHhNIkWw3kZvVmPBkVQCddKfiSwym3OahJtmobBCAVa8p9XMSn3Y2jkd4oX 7cr4U844s4ODAuOqT9BGh52azuxKX8gWKK3sF+lS1U5ZjObish+Qvlg X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.174; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f174.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793870979561158500 Move TYPE_TMP421/TYPE_TMP422/TYPE_TMP423 from tmp421.c into a new include/hw/sensor/tmp421.h, so boards instantiating the device share one definition instead of repeating the type strings locally. Signed-off-by: Emmanuel Blot --- hw/sensor/tmp421.c | 4 +--- include/hw/sensor/tmp421.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 1966301d7a..1d3d526d4a 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -42,6 +42,7 @@ #include "qapi/visitor.h" #include "qemu/module.h" #include "qom/object.h" +#include "hw/sensor/tmp421.h" =20 /* Manufacturer / Device ID's */ #define TMP421_MANUFACTURER_ID 0x55 @@ -80,9 +81,6 @@ struct TMP421Class { uint8_t config2_reset; }; =20 -#define TYPE_TMP421 "tmp421" -#define TYPE_TMP422 "tmp422" -#define TYPE_TMP423 "tmp423" OBJECT_DECLARE_TYPE(TMP421State, TMP421Class, TMP421) =20 =20 diff --git a/include/hw/sensor/tmp421.h b/include/hw/sensor/tmp421.h new file mode 100644 index 0000000000..fbfdd87b7a --- /dev/null +++ b/include/hw/sensor/tmp421.h @@ -0,0 +1,19 @@ +/* + * Texas Instruments TMP421/TMP422/TMP423 temperature sensor + * + * Browse the data sheet: + * + * https://www.ti.com/lit/gpn/tmp421 + * + * Copyright (c) 2016 IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef HW_SENSOR_TMP421_H +#define HW_SENSOR_TMP421_H + +#define TYPE_TMP421 "tmp421" +#define TYPE_TMP422 "tmp422" +#define TYPE_TMP423 "tmp423" + +#endif --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871048; cv=none; d=zohomail.com; s=zohoarc; b=Use6zti6EMAV/WtjGF05H8sQqzhijI2Fd+OYWHmlxzAVqix8OGXOcCRpVVYeKXbY30iSBqDv0xY8PVL9bm8F+yV27pcRRzVACNQivjKM9qO54L/Pqey/3n26cQnoh7yhtj2dObPWycL4Ym34aUCyNhZMmrKBMqh8LgmGRgnWhXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871048; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=h4Ea09lpKBE0ZuFBlZjAhUPH2YdoO9oGD+k3joTrPS8=; b=mHXcZ/QAnP1yhfZW1jlEeq89gza7q16MHfZeN0v2PoCv55kY2tlRMMQKiMHGBs3Hr5vJsuIyhjqTIy/w70c1ozgZoE0lfit8/bsvX3grf/KT9CinJXrGq3hJqvtJraB/RU4j0RAxjWShjSp4f5vKN629P7WgtArG+CS5ibIlJUU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17938710480231002.6803512525779; Thu, 5 Nov 2026 01:30:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmZ-0007t3-Pq; Thu, 05 Nov 2026 04:29:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmX-0007o5-1J for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:17 -0500 Received: from mail-pg1-f174.google.com ([209.85.215.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmU-0006zY-7c for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:16 -0500 Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-cdab6ae1ee9so752899a12.1 for ; Thu, 05 Nov 2026 01:29:13 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b31f8804sm3046335a91.17.2026.11.05.01.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870953; x=1794475753; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h4Ea09lpKBE0ZuFBlZjAhUPH2YdoO9oGD+k3joTrPS8=; b=bODKfHbEjPcnld/TyIcTIydAu1n7X1kbtiCm18++KHi69debHPYb431sWU2BBu30wY 1lq5dXpfv2y8HZZ/678d4gSF+qsC5+KKW+zvU+JUa1ZUCl+PVMHnFt19PkLz5TxNNnHn FqUN+He1DHcD6QVMdsNjstM6UPV7M4GY86M3Dh+Yzb1jLI7w4fdvjoga/m5r0wOi5cdA o8+KzlEhy4V8Zd0hBG1lBNOCBtjh+OuEBdiJNUdVpy81FjJ4AMrLAUq0ldXxn5LTaEK/ f2jA6E3Uw/w+8wcQXCTQZLHoJ7Qn+JpkcHJd4OFBYBM/CwZYoLgMYtbhMiOU5aTFp38D ULyw== X-Gm-Message-State: APuU4Z/hRGSoFN/7zfNYLKv02qtsYUFQhJlHafG1dnekHbtaB0bHZ1PB 98WnaYOvJTEfZGMjiMAIZHS4+1eVoIVKCt/ILJKcVBa8/D1kXJOpdMRek8apJ993Q10= X-Gm-Gg: AYBFou0YfJYIkmt6GC3L/FAowwPQDxwYuyjWIE62Gqnydkbaf3BCMw2FgAd5rhohV7R WYr/SMTleWmMH/J3JciMVH/Rz/Nn7ln3iURdMXKZf2C9aENgBl1TATYfrMGKeTI8xT6QccPd4j9 KUDXHNpEvjuwv4CgXmtycGu6Dmpw0k61YaSMZSEFBP3rgEOw2v3nw7yN4AXCoPSmBqX2BgKGhBo BX61RXqT4zC6DjeV0ZckgPLpPyXVxFRV5fee5UC3xwz1Vt01bmbj/qVRkuqCucpxBExrNotmawm f/GYdZmvyJnIQWKD9pTaWIJAA7dAb6A2Vv23sKkseeKmvDR9LPaFGSIJZrZIpMg7fzDjBF2mj2a STszVkv9rPb8SAjk8wt58wU47PagEm4Ob41ZQTwFpXhHTusfv86187zZpewgjm7tZyNLkhgRWaE OogRoNb0h/1csbivADqIdvJa3ehz3Wb7U2BENACm4G6NfULbEk5Ti4EmMlixFrpqTsPXGTWQWWe u5gW+Iz6w1ChNBZuoMzEbriQu2+lcsiSojHmYORJqpQI/ETy/6DljJHMme64n56wNaPcSlaa6Uf Sg3Bd0inCoozhVtBYXpCAZa+EtA6gnQEq2lfEP8wZDnZci752d6kY73mur48oIJBWidh1+5MUgM D X-Received: by 2002:a17:90b:5487:b0:3ac:adce:60ad with SMTP id 98e67ed59e1d1-3ae89775250mr13176599a91.22.1793870952592; Thu, 05 Nov 2026 01:29:12 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:50 +0800 Subject: [PATCH 11/16] hw/arm/aspeed: use the TMP421 type-name macros MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-11-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot , Jamin Lin X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=11926; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=4oZwEz5iz9ajkWq5VlThdY36odDZrC08EIwReCORXA8=; b=aUbpPtP64o7T7w80ldbS8eQ4uR960h1yWAe0UwO9dz3xQ3dezY9CJXZSlpFarbNuPsAuzjEy8 qR5MU5vpIuDATOqwwN6nI0m8fgkYjMsTrgJY2xR/oqADJ8Q/GkSXwYx X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.215.174; envelope-from=eblot.ml@gmail.com; helo=mail-pg1-f174.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871048711158500 Include the new tmp421.h and refer to the sensor variants through TYPE_TMP421/TYPE_TMP422/TYPE_TMP423 instead of open-coded string literals and per-board local defines. Reviewed-by: Jamin Lin Signed-off-by: Emmanuel Blot --- hw/arm/aspeed_ast2400_palmetto.c | 3 ++- hw/arm/aspeed_ast2400_supermicrox11.c | 3 ++- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 3 ++- hw/arm/aspeed_ast2500_tiogapass.c | 10 +++++++--- hw/arm/aspeed_ast2500_witherspoon.c | 7 +++++-- hw/arm/aspeed_ast2500_yosemitev2.c | 10 +++++++--- hw/arm/aspeed_ast2600_bletchley.c | 3 +-- hw/arm/aspeed_ast2600_catalina.c | 3 +-- hw/arm/aspeed_ast2600_fby35.c | 2 +- hw/arm/aspeed_ast2600_fuji.c | 3 +-- hw/arm/aspeed_ast2600_rainier.c | 13 +++++++++---- 11 files changed, 38 insertions(+), 22 deletions(-) diff --git a/hw/arm/aspeed_ast2400_palmetto.c b/hw/arm/aspeed_ast2400_palme= tto.c index 185185f0bb..7b165394c2 100644 --- a/hw/arm/aspeed_ast2400_palmetto.c +++ b/hw/arm/aspeed_ast2400_palmetto.c @@ -12,6 +12,7 @@ #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/rtc/ds1338.h" +#include "hw/sensor/tmp421.h" =20 /* Palmetto hardware value: 0x120CE416 */ #define PALMETTO_BMC_HW_STRAP1 ( \ @@ -45,7 +46,7 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) =20 /* add a TMP423 temperature sensor */ dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), - "tmp423", 0x4c)); + TYPE_TMP423, 0x4c)); object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abo= rt); diff --git a/hw/arm/aspeed_ast2400_supermicrox11.c b/hw/arm/aspeed_ast2400_= supermicrox11.c index 051e072c5a..fd2fda9290 100644 --- a/hw/arm/aspeed_ast2400_supermicrox11.c +++ b/hw/arm/aspeed_ast2400_supermicrox11.c @@ -12,6 +12,7 @@ #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/rtc/ds1338.h" +#include "hw/sensor/tmp421.h" =20 /* TODO: Find the actual hardware value */ #define SUPERMICROX11_BMC_HW_STRAP1 ( \ @@ -45,7 +46,7 @@ static void supermicrox11_bmc_i2c_init(AspeedMachineState= *bmc) =20 /* add a TMP423 temperature sensor */ dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), - "tmp423", 0x4c)); + TYPE_TMP423, 0x4c)); object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abo= rt); diff --git a/hw/arm/aspeed_ast2500_supermicro-x11spi.c b/hw/arm/aspeed_ast2= 500_supermicro-x11spi.c index dc0248422d..1ea61348f6 100644 --- a/hw/arm/aspeed_ast2500_supermicro-x11spi.c +++ b/hw/arm/aspeed_ast2500_supermicro-x11spi.c @@ -12,6 +12,7 @@ #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/rtc/ds1338.h" +#include "hw/sensor/tmp421.h" =20 /* TODO: Find the actual hardware value */ #define SUPERMICRO_X11SPI_BMC_HW_STRAP1 ( \ @@ -41,7 +42,7 @@ static void supermicro_x11spi_bmc_i2c_init(AspeedMachineS= tate *bmc) =20 /* add a TMP423 temperature sensor */ dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), - "tmp423", 0x4c)); + TYPE_TMP423, 0x4c)); object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abo= rt); object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abo= rt); diff --git a/hw/arm/aspeed_ast2500_tiogapass.c b/hw/arm/aspeed_ast2500_tiog= apass.c index 6cb567526c..5433198abd 100644 --- a/hw/arm/aspeed_ast2500_tiogapass.c +++ b/hw/arm/aspeed_ast2500_tiogapass.c @@ -11,6 +11,7 @@ #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/sensor/tmp421.h" =20 /* value: 0xF100C2E6 */ #define TIOGAPASS_BMC_HW_STRAP1 (( \ @@ -54,9 +55,12 @@ static void tiogapass_bmc_i2c_init(AspeedMachineState *b= mc) at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * Ki= B, tiogapass_bmc_fruid, tiogapass_bmc_fruid_len); /* TMP421 */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "tmp421", 0x= 1f); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp421", 0x= 4f); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp421", 0x= 4e); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), + TYPE_TMP421, 0x1f); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), + TYPE_TMP421, 0x4f); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), + TYPE_TMP421, 0x4e); } =20 static void aspeed_machine_tiogapass_class_init(ObjectClass *oc, diff --git a/hw/arm/aspeed_ast2500_witherspoon.c b/hw/arm/aspeed_ast2500_wi= therspoon.c index c69065846c..385deb2154 100644 --- a/hw/arm/aspeed_ast2500_witherspoon.c +++ b/hw/arm/aspeed_ast2500_witherspoon.c @@ -12,6 +12,7 @@ #include "hw/arm/aspeed_soc.h" #include "hw/misc/led.h" #include "hw/sensor/tmp105.h" +#include "hw/sensor/tmp421.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/gpio/pca9552.h" #include "hw/rtc/ds1338.h" @@ -60,8 +61,10 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState = *bmc) } i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "dps310", 0x= 76); i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "max31785", = 0x52); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x= 4c); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x= 4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), + TYPE_TMP423, 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), + TYPE_TMP423, 0x4c); =20 /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, diff --git a/hw/arm/aspeed_ast2500_yosemitev2.c b/hw/arm/aspeed_ast2500_yos= emitev2.c index 3ba1ed5f6f..3dd0d37175 100644 --- a/hw/arm/aspeed_ast2500_yosemitev2.c +++ b/hw/arm/aspeed_ast2500_yosemitev2.c @@ -11,6 +11,7 @@ #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/sensor/tmp421.h" =20 /* value: 0xF100C2E6 */ #define YOSEMITEV2_BMC_HW_STRAP1 (( = \ @@ -54,9 +55,12 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *= bmc) at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * Ki= B, yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len); /* TMP421 */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "tmp421", 0= x1f); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp421", 0x= 4e); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp421", 0x= 4f); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), + TYPE_TMP421, 0x1f); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + TYPE_TMP421, 0x4e); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + TYPE_TMP421, 0x4f); =20 } =20 diff --git a/hw/arm/aspeed_ast2600_bletchley.c b/hw/arm/aspeed_ast2600_blet= chley.c index 0e746055a2..536e910229 100644 --- a/hw/arm/aspeed_ast2600_bletchley.c +++ b/hw/arm/aspeed_ast2600_bletchley.c @@ -13,8 +13,7 @@ #include "hw/gpio/pca9552.h" #include "hw/nvram/eeprom_at24c.h" #include "hw/rtc/ds1338.h" - -#define TYPE_TMP421 "tmp421" +#include "hw/sensor/tmp421.h" /* Bletchley hardware value */ #define BLETCHLEY_BMC_HW_STRAP1 0x00002000 #define BLETCHLEY_BMC_HW_STRAP2 0x00000801 diff --git a/hw/arm/aspeed_ast2600_catalina.c b/hw/arm/aspeed_ast2600_catal= ina.c index b15d932086..13dca7a846 100644 --- a/hw/arm/aspeed_ast2600_catalina.c +++ b/hw/arm/aspeed_ast2600_catalina.c @@ -16,14 +16,13 @@ #include "hw/nvram/eeprom_at24c.h" #include "hw/rtc/ds1338.h" #include "hw/sensor/tmp105.h" +#include "hw/sensor/tmp421.h" =20 /* Catalina hardware value */ #define CATALINA_BMC_HW_STRAP1 0x00002002 #define CATALINA_BMC_HW_STRAP2 0x00000800 #define CATALINA_BMC_RAM_SIZE (2 * GiB) =20 -#define TYPE_TMP421 "tmp421" - /* * "BMC Storage Module" FRU data. Generated with frugen. * diff --git a/hw/arm/aspeed_ast2600_fby35.c b/hw/arm/aspeed_ast2600_fby35.c index 28c9c143d8..25f39d5135 100644 --- a/hw/arm/aspeed_ast2600_fby35.c +++ b/hw/arm/aspeed_ast2600_fby35.c @@ -12,10 +12,10 @@ #include "hw/arm/aspeed_soc.h" #include "hw/nvram/eeprom_at24c.h" #include "hw/sensor/tmp105.h" +#include "hw/sensor/tmp421.h" #include "system/reset.h" =20 #define TYPE_LM75 TYPE_TMP105 -#define TYPE_TMP421 "tmp421" #define FBY35_BMC_RAM_SIZE (2 * GiB) =20 static const uint8_t fby35_nic_fruid[] =3D { diff --git a/hw/arm/aspeed_ast2600_fuji.c b/hw/arm/aspeed_ast2600_fuji.c index 08d809b2fd..526494ecfe 100644 --- a/hw/arm/aspeed_ast2600_fuji.c +++ b/hw/arm/aspeed_ast2600_fuji.c @@ -12,10 +12,9 @@ #include "hw/arm/aspeed_soc.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/sensor/tmp105.h" +#include "hw/sensor/tmp421.h" #include "hw/nvram/eeprom_at24c.h" =20 -#define TYPE_TMP422 "tmp422" - /* Fuji hardware value */ #define FUJI_BMC_HW_STRAP1 0x00000000 #define FUJI_BMC_HW_STRAP2 0x00000000 diff --git a/hw/arm/aspeed_ast2600_rainier.c b/hw/arm/aspeed_ast2600_rainie= r.c index 43a8f01a9e..bdbc78aee7 100644 --- a/hw/arm/aspeed_ast2600_rainier.c +++ b/hw/arm/aspeed_ast2600_rainier.c @@ -13,6 +13,7 @@ #include "hw/nvram/eeprom_at24c.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/sensor/tmp105.h" +#include "hw/sensor/tmp421.h" =20 /* Rainier hardware value: (QEMU prototype) */ #define RAINIER_BMC_HW_STRAP1 (0x00422016 | SCU_AST2600_HW_STRAP_BOOT_SRC_= EMMC) @@ -137,12 +138,16 @@ static void rainier_bmc_i2c_init(AspeedMachineState *= bmc) /* Bus 8: ucd90320@b */ /* Bus 8: ucd90320@c */ =20 - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x= 4c); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x= 4d); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + TYPE_TMP423, 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + TYPE_TMP423, 0x4d); at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB); =20 - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0= x4c); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0= x4d); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), + TYPE_TMP423, 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), + TYPE_TMP423, 0x4d); at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB); =20 i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871020; cv=none; d=zohomail.com; s=zohoarc; b=gKchRWrbC0oo/QoHpdMMKhvYHvyDYb1ls21Aw0ASxrTn2GcSLXBdMJArYDF7ypFJ4EfD2T74jy5fQ4Qnsidu2folZYW0S0Fjp+vLVERpkUktbHh03E687bOMZ+Bb/3FbztbOJG3es/Y37ukDBwhdjqHhG/zzontEB5h7Qev+Fiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871020; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=Rkg/rRagot7XXlFirwrvwK6gw3R8aZjpi8YcEvfRzRk=; b=ieV9/FPW0N/m5aTVUZlsKFJYTgq8Spf293BO3z+kKu0n+8QvfE98Gu5NdsP3PhqDhYw0tNR73f+pyXFNLHmXUsDuvP+mPvNKB2H1abVVc+smaqk1j6ix+/UdAYFAslxfaAHynTLSJDKYxVu/2VDOL+3u/dZ30NCr0nm2EU7vHYA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871020593870.6533790364991; Thu, 5 Nov 2026 01:30:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmg-0008EL-GN; Thu, 05 Nov 2026 04:29:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmd-00084w-Ko for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:23 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmb-00071Z-KC for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:23 -0500 Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8a06e79e152so1000079b3a.0 for ; Thu, 05 Nov 2026 01:29:21 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdb46972143sm1876427a12.22.2026.11.05.01.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870960; x=1794475760; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Rkg/rRagot7XXlFirwrvwK6gw3R8aZjpi8YcEvfRzRk=; b=k8fK3iGkqEgntE5eyJ5BsqLFeO8Mzz6jEzH5bvdIVYqmrlpWp0gTDQxeUTfmDJ4xqT /KG2k2+xY8ShMorLL4V+GxhXNisaR2Pf/VtU9T6lPFe1OT65mgFEz4/EIitwbcX8fBUa zas7x8YwOaQ9Qhe6sOvKAqU5aCdXt3GD7Vq5mODDzHWOHtsGhF6tRDb6MqA6hDCzCl7M HzxPd2mHyGnA9zbV5oRiyd9GWI4V3Y9K6yszkRazF2lcvXM8Er1zv3j72iDJmV0Cc+Hx XAsxhyP1tjNpVBIJg0/ifXNL4sbdx0oi/guEMF8zCf8wAAZbmtrZHIofZFwTZIkgEoHx idwA== X-Gm-Message-State: APuU4Z8pIYzXq5jPi7xtSBxS4NrfuVD6bklIIkixzQXb2kt3TEbFnu40 aky0lz9DZbxzlaRgQGKEI59UAkXN9x/gVk78HnVJwOjbWXRmF/AoqpfSQ8nr5A1t3Zk= X-Gm-Gg: AYBFou1dCFYL2V9MitrhLKvBmdgqKlk+h9YqXzCVyMqNMNg3rZG2A9xh/boGLj3k2Q7 HHcyhpSZ1W2hSvh+DWNaX6ek0XuFMQWkeD3oZz4eOB1UrDmZHQo5JmOHQmIoBy7eebn7fcWGzG6 VS2ZVBD0AmTgHUVleTq/VJouSr9x+aftQVcMamVl6CcMPt6ZMM1AHtHgn90rwAALJJHTw9Afqp6 oQArxHnDqkR65b7ay1NU4HdET6p5EQQKNiKBHzocwGaXK8LpHVKYZGYhQchg0R9B5AOflF1JitG jbpnJ8L0hLg0K8vBQJAmfbEzMwuaHKTdSpPDc+/y6uqXA15a7TFRC3VJfPeJ8rTH7DtHTSyde5I JId0TGHSMSUPcYR0zNzqLoXIngjmeSLKepe1GSe2x0LduRDY0Y7PTmtdGllwjuhQRSWxZcXkmCt 4GhTiyBJq9vXPfPMCY/hFgWjzgmYOx4Aj0saZoMnsX3HD+C7r4wX3qj2mKTkAOBHrCwbMoCafVA 1/MsCpmPlX3Y8FkZyw+OUuPNBN+iQ2tYnL9DuYsnmNWatcKklyLd+fnNGP6u5sfYiKswBGXEZZr 5kqEUEmyTOeNH8HBJzJiKhmB8iSmeJV/CW2vy1izq34zWJQvsMTcRCNOgT3YxB0/QBQEJdgSzIj v X-Received: by 2002:a05:6a20:914b:b0:3e2:9470:5303 with SMTP id adf61e73a8af0-3e928953948mr15587729637.15.1793870960156; Thu, 05 Nov 2026 01:29:20 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:51 +0800 Subject: [PATCH 12/16] tests/qtest: tmp421: cover device IDs and reset defaults MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-12-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=3934; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=rxzfEVZP/N2hZ9sXIJbALDO+kJ3vIfs6oxJpOT9g+40=; b=CjZmLeymN9+6smjAB5NAwSTqQfkV6P1WzVKZqj/oXAaYp+TtJ2JtqSooGa2dGXWzLQlurKQtY bro46l0JJNCDQzrO126cHR2otdlC1KBzwmgu6lGAsdklxyCSLhMNwq/ X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.170; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f170.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871022356158500 Add a qgraph test that instantiates each variant and checks the manufacturer and device identification bytes and the reset values of the configuration and conversion-rate registers. Signed-off-by: Emmanuel Blot --- tests/qtest/meson.build | 1 + tests/qtest/tmp421-test.c | 84 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 85 insertions(+) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ff4bf9528a..5c82fdb22c 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -355,6 +355,7 @@ qos_test_ss.add( 'sdhci-test.c', 'spapr-phb-test.c', 'tmp105-test.c', + 'tmp421-test.c', 'emc141x-test.c', 'usb-hcd-ohci-test.c', 'virtio-test.c', diff --git a/tests/qtest/tmp421-test.c b/tests/qtest/tmp421-test.c new file mode 100644 index 0000000000..2307e5f603 --- /dev/null +++ b/tests/qtest/tmp421-test.c @@ -0,0 +1,84 @@ +/* + * QTest testcase for the TMP421/TMP422/TMP423 temperature sensor + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "libqtest-single.h" +#include "libqos/qgraph.h" +#include "libqos/i2c.h" +#include "qobject/qdict.h" + +/* + * TMP421 register map, per the datasheet. Kept here rather than + * shared with the model, so the test states the values it expects + * independently of the implementation it is checking. + */ +#define TMP421_CONFIG_REG_1 0x09 +#define TMP421_CONFIG_REG_2 0x0A +#define TMP421_CONVERSION_RATE_REG 0x0B +#define TMP421_MANUFACTURER_ID_REG 0xFE +#define TMP421_DEVICE_ID_REG 0xFF +#define TMP421_MANUFACTURER_ID 0x55 + +#define TMP421_TEST_ID "tmp421-test" +#define TMP422_TEST_ID "tmp422-test" +#define TMP423_TEST_ID "tmp423-test" + +/* + * Per-variant expectations, passed as the qos test payload so a single te= st + * body can cover all three parts. + */ +typedef struct TMP421Variant { + const char *id; + uint8_t device_id; + uint8_t config2_reset; + unsigned nchannels; +} TMP421Variant; + +static const TMP421Variant tmp421_variant =3D { TMP421_TEST_ID, 0x21, 0x1c= , 2 }; +static const TMP421Variant tmp422_variant =3D { TMP422_TEST_ID, 0x22, 0x3c= , 3 }; +static const TMP421Variant tmp423_variant =3D { TMP423_TEST_ID, 0x23, 0x7c= , 4 }; + +static void test_ids(void *obj, void *data, QGuestAllocator *alloc) +{ + const TMP421Variant *var =3D data; + QI2CDevice *i2cdev =3D obj; + + g_assert_cmphex(i2c_get8(i2cdev, TMP421_MANUFACTURER_ID_REG), =3D=3D, + TMP421_MANUFACTURER_ID); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_DEVICE_ID_REG), =3D=3D, var->d= evice_id); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONFIG_REG_1), =3D=3D, 0); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONFIG_REG_2), =3D=3D, + var->config2_reset); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONVERSION_RATE_REG), =3D=3D, = 0x07); +} + +static void tmp421_register_node(const TMP421Variant *var, const char *typ= e, + uint8_t addr) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D g_strdup_printf("id=3D%s,address=3D0x%02x", + var->id, addr), + }; + + add_qi2c_address(&opts, &(QI2CAddress) { addr }); + qos_node_create_driver(type, i2c_device_create); + qos_node_consumes(type, "i2c-bus", &opts); + + qos_add_test("ids", type, test_ids, + &(QOSGraphTestOptions) { .arg =3D (void *)var }); +} + +static void tmp421_register_nodes(void) +{ + tmp421_register_node(&tmp421_variant, "tmp421", 0x4c); + tmp421_register_node(&tmp422_variant, "tmp422", 0x4d); + tmp421_register_node(&tmp423_variant, "tmp423", 0x4e); +} + +libqos_init(tmp421_register_nodes); --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871035; cv=none; d=zohomail.com; s=zohoarc; b=dx05yvCqiReZt2gCp4WVO1SpdCIm24PlwA7oEKN800aG7PqfY1IT3LerTsq09ElhhyPHZDpISW6UJG7wG3cbemZXwN1Z3dPi/rOZ/evd0gKViNJlLmOtR4Vq/6LalVLhSRkzU334+pXDRKY1a2eB3TFZ0vZax9/EwxV7EK1X0pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871035; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=ZT03pXOUyF1VnCcltW3we9XEJr4ijAWCTIBb53nAbTQ=; b=E+XGaHNEgb7nLRPojqhX5azDyYsV+5G5cThpzqsvlmLYEnab8ghQeGIPpb1KHfRpIAhjRE8CjjErSOBvklyRV/OT5RTf/5x8EXs9M3If4thjnGa7FfBKZBR+HHrUo0PN1uqBkAesbIj8xJxpXRIxsBabqjmUOHHqsI3PPKFlN78= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871035104281.06838635038685; Thu, 5 Nov 2026 01:30:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmn-0000Ch-Ab; Thu, 05 Nov 2026 04:29:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtml-00006V-E5 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:31 -0500 Received: from mail-pj1-f53.google.com ([209.85.216.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmj-000729-3c for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:30 -0500 Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-3b0afe09854so402490a91.3 for ; Thu, 05 Nov 2026 01:29:28 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b323cd3csm2983912a91.3.2026.11.05.01.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870967; x=1794475767; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZT03pXOUyF1VnCcltW3we9XEJr4ijAWCTIBb53nAbTQ=; b=hYGeAeV2MF+mv7hbbw9W67DE0N8mSxHz0Gi+JKVN7+6JXPyqscaj1O9UkFh9SaOuyp NbeuI3p6+ltUInI/cFQEwsSMWpBi6iXqSAcXcfA2TZqMpAavrWRLvpa2iksakv/OZ4Ao iksMI8gdkENJQFZQiNf0i7GQqBdU7/WGYVpMI24kMOfPDInNFZ2nuCo/970DrOW0bFP0 a2oJ2ITTt57RjlyHbP77t5kv/ONRTwQKMO2BHnf1NUxHbU/qyOU8JJETnuq5v3JRGMEm JT+3K761NRuleOTeYaB497Y/p0YWWkNByNbawzLaEh6LUG+BsC5uNhtx/FjtbYHDRqwy lCbQ== X-Gm-Message-State: APuU4Z9k2dmttpWJ/amrh0R0jlTXX/RXL2DEU4rzDu2OvboN4c+n7BD9 G5fPDWkMiYJqdZVjasveKWROb8Nyh486KsaeOxGMUqCzkTwM2RBhqtSiuWPKEDU+i8E= X-Gm-Gg: AYBFou3oZpW4CtefqclVVm4vZfwjxS98HxBNHIb2ME/rEOkY4VWkIaMDlH61wBYo7h8 XAPbjbCJp7iD5Qu0wkC6pWrhTsPaUHP+oExilD4ELy5uFAdZ5wa8KzW/AWHLKziqDrqYXemGNvw RJ1qLpbX1dAXTUP9pqq8adxYSHttOQQgpGp6ZRKaz4QEMoGd0iQNpGk/1c+tVeqsE/nW9oLODLL CIjykRdt6sDklDzqqT8PP++gBqi52b+HK/AaflnZvvcs1ynKXXFIZusSrVapdQgbdmAhQTq/YF9 oQPL2sO1sqhz7Tbu6dvA8ir4dAYVMJeQNSTsLQWYGq9xUhqkPzFl02BnlGsqdoOEBIrJoH9U21Q LaC6sFw0Z345xvw4GBJ5gbbOnFaEP5kH9g+jS3E3wsbpu7jJjjWKwpnRdCLrCzIWoeyCkOM5Aw3 U5sgF15uuygzshOgwimuHdNNcKH/cRzEnCm9H8zepSa++ZS8kh/kLV7ijqoWALSzwXA/wOwAsXo xO9Cvqdwp5H29fU3Jw2sf/1Jd37X6nl4sIdURLzOZexUVBBohIwc8YYPAoEpezYHqRcYzo+a9TZ qnTzrxpeUuwgpnslIERPrr3aO4g4UhRAk/xmCHyBE0qM2VLz7Zx/4M2hs0Yf6Oqp86ySaKCU3Ye F X-Received: by 2002:a17:90a:f985:b0:3ae:a531:4e73 with SMTP id 98e67ed59e1d1-3aea5314ea6mr9070611a91.7.1793870967209; Thu, 05 Nov 2026 01:29:27 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:52 +0800 Subject: [PATCH 13/16] tests/qtest: tmp421: cover temperature encoding and range MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-13-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=6462; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=AEzQURKuJZlDUat8fg72pNeAc6ypqWG6k7Vbs2+CVL0=; b=OPBbQ74oGGc322PyTEZjkQ7TNfNv6htJOeopnXsBYhkXkkpqOh0EEER9Bk6RAYQLDnJlHDTBZ V/g3aLfgo8TCBDzYc982KlrB64zGF4wZFM1T8vkfJghct5UrdZA8ZZS X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.216.53; envelope-from=eblot.ml@gmail.com; helo=mail-pj1-f53.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871036663158500 Set a temperature over QMP and read it back through the two-byte and single-byte register paths, checking the fixed-point encoding and the extended-range offset. A second case pins the saturation: a temperature the standard range cannot express reads back clamped, without harming the measurement itself. Signed-off-by: Emmanuel Blot --- tests/qtest/tmp421-test.c | 102 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 102 insertions(+) diff --git a/tests/qtest/tmp421-test.c b/tests/qtest/tmp421-test.c index 2307e5f603..390f17b6b2 100644 --- a/tests/qtest/tmp421-test.c +++ b/tests/qtest/tmp421-test.c @@ -18,9 +18,13 @@ * shared with the model, so the test states the values it expects * independently of the implementation it is checking. */ +#define TMP421_TEMP_MSB0 0x00 #define TMP421_CONFIG_REG_1 0x09 +#define TMP421_CONFIG_RANGE (1 << 2) #define TMP421_CONFIG_REG_2 0x0A #define TMP421_CONVERSION_RATE_REG 0x0B +#define TMP421_TEMP_LSB0 0x10 +#define TMP421_RESET 0xFC #define TMP421_MANUFACTURER_ID_REG 0xFE #define TMP421_DEVICE_ID_REG 0xFF #define TMP421_MANUFACTURER_ID 0x55 @@ -44,6 +48,36 @@ static const TMP421Variant tmp421_variant =3D { TMP421_T= EST_ID, 0x21, 0x1c, 2 }; static const TMP421Variant tmp422_variant =3D { TMP422_TEST_ID, 0x22, 0x3c= , 3 }; static const TMP421Variant tmp423_variant =3D { TMP423_TEST_ID, 0x23, 0x7c= , 4 }; =20 +static QDict *qmp_get_temperature(const char *id, unsigned channel) +{ + g_autofree char *prop =3D g_strdup_printf("temperature%u", channel); + + return qmp("{ 'execute': 'qom-get', 'arguments': { 'path': %s, " + "'property': %s } }", id, prop); +} + +static int get_temperature(const char *id, unsigned channel) +{ + QDict *response =3D qmp_get_temperature(id, channel); + int ret; + + g_assert(qdict_haskey(response, "return")); + ret =3D qdict_get_int(response, "return"); + qobject_unref(response); + return ret; +} + +static void set_temperature(const char *id, unsigned channel, int value) +{ + g_autofree char *prop =3D g_strdup_printf("temperature%u", channel); + QDict *response; + + response =3D qmp("{ 'execute': 'qom-set', 'arguments': { 'path': %s, " + "'property': %s, 'value': %d } }", id, prop, value); + g_assert(qdict_haskey(response, "return")); + qobject_unref(response); +} + static void test_ids(void *obj, void *data, QGuestAllocator *alloc) { const TMP421Variant *var =3D data; @@ -58,6 +92,70 @@ static void test_ids(void *obj, void *data, QGuestAlloca= tor *alloc) g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONVERSION_RATE_REG), =3D=3D, = 0x07); } =20 +static void test_temperature(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D obj; + + /* A whole degree lands on a whole register value, fraction cleared. */ + set_temperature(TMP421_TEST_ID, 0, 25000); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x1900); + + /* The standard range is two's complement below 0 C. */ + set_temperature(TMP421_TEST_ID, 0, -25000); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xE700); + + /* A temperature the register form represents exactly. */ + set_temperature(TMP421_TEST_ID, 0, 25063); + g_assert_cmpint(get_temperature(TMP421_TEST_ID, 0), =3D=3D, 25063); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x1910); + + /* A lone low-byte read returns the same conversion as the pair. */ + g_assert_cmphex(i2c_get8(i2cdev, TMP421_TEMP_LSB0), =3D=3D, 0x10); + + /* Extended range encodes the same measurement with a +64 C offset. */ + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + set_temperature(TMP421_TEST_ID, 0, 25063); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x5910); + + /* Leaving it, whether by a write or a reset, reports the same value */ + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, 0); + g_assert_cmpint(get_temperature(TMP421_TEST_ID, 0), =3D=3D, 25063); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x1910); + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x5910); + i2c_set8(i2cdev, TMP421_RESET, 0); + g_assert_cmpint(get_temperature(TMP421_TEST_ID, 0), =3D=3D, 25063); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x1910); + + /* The extended range is unsigned: it reaches past +64 C (Table 1). */ + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + set_temperature(TMP421_TEST_ID, 0, 100063); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xA410); +} + +/* + * A temperature the standard range cannot express saturates at +127 C (7F= h) + * instead of wrapping, and the extended range still reports it in full: t= he + * range picks an encoding, it does not alter the measurement. + */ +static void test_range_saturation(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D obj; + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + set_temperature(TMP421_TEST_ID, 0, 149938); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xD5F0); + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, 0); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0x7FF0); + g_assert_cmpint(get_temperature(TMP421_TEST_ID, 0), =3D=3D, 149938); + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xD5F0); +} + static void tmp421_register_node(const TMP421Variant *var, const char *typ= e, uint8_t addr) { @@ -79,6 +177,10 @@ static void tmp421_register_nodes(void) tmp421_register_node(&tmp421_variant, "tmp421", 0x4c); tmp421_register_node(&tmp422_variant, "tmp422", 0x4d); tmp421_register_node(&tmp423_variant, "tmp423", 0x4e); + + /* Temperature encoding is variant-independent; exercise it once. */ + qos_add_test("temperature", "tmp421", test_temperature, NULL); + qos_add_test("range-saturation", "tmp421", test_range_saturation, NULL= ); } =20 libqos_init(tmp421_register_nodes); --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871042; cv=none; d=zohomail.com; s=zohoarc; b=ft88OJhVM1yoQmHy9W0ut8xI0DGfz9l7BwTWeQG5pJGCAmKUfAm+FppDw3YRA9GorSCERyS+XPuPiexZ40WmjaMsHScoSPdT7TujINqg+w1QUEzXPRBn14Ddi5Hd1iICYHFwio81FVFLtJhM1cx7g5ZHqvwM2hLDfMUirnjjAhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871042; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=tMqRetAxiQAIvpDJW998EtamxiidvOknZM6HJPGhQpw=; b=NfAPmcorzYZPx3H8XWRx1qQwAxIdrVXQzBXcVKssNNAlRYdpk/captcLxZQdLDCtxeCSiIHIpirngcZvH/e8JT3hET5G4L8R2oHtGTGhJwvd5m04MCZEuG+an4YBeaj4l2P8wk30w+W2yEcFLMNQjo5iHrhg4DDEpeD2rAr192U= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871042643711.6363356969721; Thu, 5 Nov 2026 01:30:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtmu-0000Zs-RZ; Thu, 05 Nov 2026 04:29:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtmt-0000Wq-FZ for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:39 -0500 Received: from mail-pl1-f171.google.com ([209.85.214.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmr-00072u-69 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:39 -0500 Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2e9995ce866so13341965ad.0 for ; Thu, 05 Nov 2026 01:29:36 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ed0906ebedsm15925785ad.31.2026.11.05.01.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870975; x=1794475775; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tMqRetAxiQAIvpDJW998EtamxiidvOknZM6HJPGhQpw=; b=EPl2DaTPEQim3nZ5KKCodl6pFEssnzTJhql6u0u+VI4zq9PaUdQtH17MRfZsfLVNND ARHE4iITHT8BTWmpqAUlmtKJaIrH8TGGNdDzf1kB8I48lzsJOzvXYA6MbRK+D098qS0T gxpd1X3SBdyRH50krmrmU85/CenRRYcbK9Z9hMmhNkpq7+KNluLoDlNunFHySrAg22yj 2G4qvI8ldTfmCWgNEh4+IihmXyv3yBMrVLQF/YPr11kEAWDZCzcWm3LbhjV55l4iHHPZ cHMmGtAiOxh1/WKLITG84U6/a8eHyzJhAJmwwD2hUGzGuCBu9TIwj3U3k+iQMOxnv9sh fnHQ== X-Gm-Message-State: APuU4Z+sXZeprQJ1rk8kcHQ9eYEgL4BX1hrn5o+KSDWKfiI14l1gJ+xS YkeL498EN9VZg2PyicrXbMKo+nIiWuAGqWTSPyBf91KjCNWRRezh+6gOZ4etKQ6EeG4= X-Gm-Gg: AYBFou2JP8jIvAm1cpGSMOPAM6+2tf4wL+V04jwdjccqWRVz4+OWP27M23+vEaRPnPS bllyt/IEJHNUfcxIbhufmE5w6QPWFOnF184NVNMKGNoGxyXJNSe7L4ERY89bwjnru+CYPmCQmlO 8BAAaUfPxQTVbhIHOgDHqdIchbA95k5vJgXMBNHVX4yTY+wCmAMMLR8apCZc4IRc5RzYQ61JKaz UnbX082UrVmYtcN98JhSsgEdJfV+MSeBcRSZYn9RRk1LrnTJfEMWnM2v1AjjqvfGuPOOsXznyNG QSWyaaIaMVHmeuTYky55NF1H9oRh6zZXpSlF26lWdVOEqeGIFZCd5Klfe+oChop2W2Syskz7fnv erV4UbdCZLwQTBfGpa/t5lrOq7Tc+M15yZJiBQom1TVmIMo5iQ7o2ztiPbtTJcblTJlQ9c9CGf9 PcdrP+aLjmjtgLl/2FgHXuXEoI9tmnEAC/zlIcJUIKb79u+i4OrfPwp9vzZUEiuq8PwTcmrt2Ce wwTmJQzhTi5kiJ0SWdI92wP9Nf3qfDmaFeJpo2ATGbMcNvOJKoNaM8RyPg4qyYsIPJdVacY3xxO m9VAlIMIHS70fM3k7hKhOeZ26/67Xfd/C9lrvhy/smQjZMxhR40CN8SW+2Jom8IhjXu0UKQ6fcp s X-Received: by 2002:a17:902:f712:b0:2ed:acb:aa96 with SMTP id d9443c01a7336-2ed0acbd23fmr42094725ad.24.1793870975358; Thu, 05 Nov 2026 01:29:35 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:53 +0800 Subject: [PATCH 14/16] tests/qtest: tmp421: cover per-variant channels and enablement MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-14-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=3174; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=6nvwu9Ryau4lnUGBjjuEHQaAZ8bpboeH30ZpsRWrAg8=; b=m3LRqZgamggLJweBwY5it6HAEKh0lGseXbug+AaA1/30DIjcGGwmO+gZrjz2kH51GX/F+nwWA Ox5YWsIsjqgBzsc5SXFL9ISASuMvnkVFfmd8EK763+RRWOzRua27DhK X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.214.171; envelope-from=eblot.ml@gmail.com; helo=mail-pl1-f171.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871044772158500 Check that each variant exposes only its own temperature properties, that writing an absent channel's enable bit is ignored, and that disabling a present channel makes it read back as zero. Signed-off-by: Emmanuel Blot --- tests/qtest/tmp421-test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/qtest/tmp421-test.c b/tests/qtest/tmp421-test.c index 390f17b6b2..04f9252188 100644 --- a/tests/qtest/tmp421-test.c +++ b/tests/qtest/tmp421-test.c @@ -22,6 +22,7 @@ #define TMP421_CONFIG_REG_1 0x09 #define TMP421_CONFIG_RANGE (1 << 2) #define TMP421_CONFIG_REG_2 0x0A +#define TMP421_CONFIG_REN (1 << 4) #define TMP421_CONVERSION_RATE_REG 0x0B #define TMP421_TEMP_LSB0 0x10 #define TMP421_RESET 0xFC @@ -78,6 +79,15 @@ static void set_temperature(const char *id, unsigned cha= nnel, int value) qobject_unref(response); } =20 +static bool has_temperature(const char *id, unsigned channel) +{ + QDict *response =3D qmp_get_temperature(id, channel); + bool present =3D qdict_haskey(response, "return"); + + qobject_unref(response); + return present; +} + static void test_ids(void *obj, void *data, QGuestAllocator *alloc) { const TMP421Variant *var =3D data; @@ -156,6 +166,31 @@ static void test_range_saturation(void *obj, void *dat= a, g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xD5F0); } =20 +static void test_channels(void *obj, void *data, QGuestAllocator *alloc) +{ + const TMP421Variant *var =3D data; + QI2CDevice *i2cdev =3D obj; + + /* Only the variant's own channels expose a temperature property. */ + for (unsigned ch =3D 0; ch < 4; ch++) { + g_assert_true(has_temperature(var->id, ch) =3D=3D (ch < var->nchan= nels)); + } + + /* Absent channel enables and reserved bits are dropped on write. */ + i2c_set8(i2cdev, TMP421_CONFIG_REG_2, 0xff); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONFIG_REG_2), =3D=3D, + var->config2_reset); + + /* Disabling remote channel 1 makes it read back as zero. */ + set_temperature(var->id, 1, 25001); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0 + 1), =3D=3D, 0x190= 0); + i2c_set8(i2cdev, TMP421_CONFIG_REG_2, + var->config2_reset & ~TMP421_CONFIG_REN); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0 + 1), =3D=3D, 0); + i2c_set8(i2cdev, TMP421_CONFIG_REG_2, var->config2_reset); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0 + 1), =3D=3D, 0x190= 0); +} + static void tmp421_register_node(const TMP421Variant *var, const char *typ= e, uint8_t addr) { @@ -170,6 +205,8 @@ static void tmp421_register_node(const TMP421Variant *v= ar, const char *type, =20 qos_add_test("ids", type, test_ids, &(QOSGraphTestOptions) { .arg =3D (void *)var }); + qos_add_test("channels", type, test_channels, + &(QOSGraphTestOptions) { .arg =3D (void *)var }); } =20 static void tmp421_register_nodes(void) --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871039; cv=none; d=zohomail.com; s=zohoarc; b=Jj4qD+kPD7suJxTn3OUBTcFqZCXMdjxFujW0j2rD505q4YpADpqLulvWiWFEFSERqxvDcq//j2L5POM27ZEEAH00N0tlbV1JQy5429ZlRKADZ6uORzCMq9Xz/DHQjZAghNKKkdFG/jf65p3683aar5N5/s7nGqWyU3vRPZtUhRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871039; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=ElO83exPm/Nk9fwRFrC4lA4TMItjH/WcdCQDoITT8Is=; b=IVubf7wE+EZWVYqeYZd4DBXsVO1kvJNBAH/Q/q83P0EeYmh1EBd+Q7+GZTvaJ9pOrlDkvMv37XtrP/07/5TpuZ3JzNrp6BK0OQT14PrwfayPrVLjNeiUmM7B+sKLmqlGq8UqTslXhyel1FR6y7zRXiK3rptENhheXVX3p/bA+bc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793871039164581.6416186470532; Thu, 5 Nov 2026 01:30:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtn2-00014O-Po; Thu, 05 Nov 2026 04:29:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtn0-0000wd-D2 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:46 -0500 Received: from mail-pj1-f48.google.com ([209.85.216.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtmy-00073U-Em for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:45 -0500 Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3ab41538192so1376672a91.0 for ; Thu, 05 Nov 2026 01:29:44 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b90def97sm2561852a91.7.2026.11.05.01.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870982; x=1794475782; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ElO83exPm/Nk9fwRFrC4lA4TMItjH/WcdCQDoITT8Is=; b=roCXqzNh/afHYTNjmvJRi9Bqsxj+Gs7fm+FsasgM5SP1aaw9xIC5gO8uItSmtv2nx+ FXpsGT82U6+5jdAhzqxm3IThMC/ejpnp5nhQ3Sy8TN01frYui+mZmmKo9oRP+wuy6scv v2mtRInbdzvRCMaj+Z/FycQilWyEg/+l0j4HlNsfZXnAXE2qn+C02KVNdb0kx4Lw3Bxp Z7rhR/tTAIWh04HIQMvIvf3/Rb9AIh6p3v6cT+3dvWMJNVie+NBPzujwi4C027XMTWHq xgOHHA1g82bHT6r1OYJTpohR4PADoYSyBspn8diipHi1Eoxf4w75FXj6YpjcL0lUaqDs vQGg== X-Gm-Message-State: APuU4Z+7IK66EGibgm0JovhVUQhOADoXTgJX6P47LjPUSW9cipazVgMZ SgW/7+mgi3Ofata9sMkgyDDapvSPPf3RRV5OEEhFMNtbOyKkdJpxHPgqBGNXtg== X-Gm-Gg: AYBFou14jIErc6zgsfuzBnlEgfuff7GIv7UC2nfdruDeFVXOEZQllLqpTXfsyJYN/po AeG+0hVVTSoKHMrh3xyVPfLVfCfozNy7Lwq/bfeGiqfM1tuzcrQHl4x2ELR7a0etRSmTaohOZNk 6Q94stPj0ZIPWa12IAJlSYIZR4KdrrQb2P128LtbunfwLxCBL0v/CpFb2+an47nsJuWzWzFCSrX 89WUOFBswfZkpOkRve6fC3KADfyEFJXIufioMBduqQcrZEOj8Td3pQNb3JWuWkan0g8VXgX0N0U ho5iUZ/Q+UcwrFC840pzbGm/U04ArIKHNXeTDZgss0LhSvTb686ecjmTEDidBCuAXGcgEsIqpQp d8scwS+TKop5rRjpR7Gj8M9PX7qQroJqXU+1TDPuUwBwhQbn1vhhqUQyd66oZIH/lzlvpFyaTOX zltfttKmtLqw5TA+c8Iq/fua0WY9XddwgemFzVS6XsgHWiZMET8iQB6CmogfnZd1FLlH/FNJqD/ TAF+Sg8H0TOFYZ/I7EBl0j5cpgxQsSol+gauqmmEGeU0qefwI3AEMP4GTJYG/H2iR41NkK1hwpl EJmAd/y3cE0fP/cvXhY8t8DxJ86oROzmXxwOztq6bGWXdGRJC6wF1mO1YNYytgU1u+DpVGL/j/K E X-Received: by 2002:a17:90b:4c85:b0:3a4:b418:94ce with SMTP id 98e67ed59e1d1-3ae89574db4mr14679727a91.1.1793870982530; Thu, 05 Nov 2026 01:29:42 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:54 +0800 Subject: [PATCH 15/16] tests/qtest: tmp421: cover software reset and N-factor registers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-15-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=2952; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=sHWJWSoGggCvrRbUN63qwoGmhhEQg3PCcE0NhyHKFWg=; b=yxdcLQU53y+WK88YgfgmoawGLklElF6qvy755iUWTlJxwCuEqcerwvhX2HmTwZsT4FSYLxgX9 mduq/Zd70e8BaQONwD271wabEIf5ZdxGRDM4IQ0BDbvZ+6SFvIUlspH X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.216.48; envelope-from=eblot.ml@gmail.com; helo=mail-pj1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871040564158500 Check that the software-reset register restores the configuration and conversion-rate defaults, and that the N-factor correction registers are writable only on the remote channels each variant provides. Signed-off-by: Emmanuel Blot --- tests/qtest/tmp421-test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/qtest/tmp421-test.c b/tests/qtest/tmp421-test.c index 04f9252188..6c5332211b 100644 --- a/tests/qtest/tmp421-test.c +++ b/tests/qtest/tmp421-test.c @@ -25,6 +25,7 @@ #define TMP421_CONFIG_REN (1 << 4) #define TMP421_CONVERSION_RATE_REG 0x0B #define TMP421_TEMP_LSB0 0x10 +#define TMP421_N_CORRECT 0x21 #define TMP421_RESET 0xFC #define TMP421_MANUFACTURER_ID_REG 0xFE #define TMP421_DEVICE_ID_REG 0xFF @@ -191,6 +192,38 @@ static void test_channels(void *obj, void *data, QGues= tAllocator *alloc) g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0 + 1), =3D=3D, 0x190= 0); } =20 +static void test_soft_reset(void *obj, void *data, QGuestAllocator *alloc) +{ + const TMP421Variant *var =3D data; + QI2CDevice *i2cdev =3D obj; + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + i2c_set8(i2cdev, TMP421_CONFIG_REG_2, 0); + i2c_set8(i2cdev, TMP421_CONVERSION_RATE_REG, 0); + + i2c_set8(i2cdev, TMP421_RESET, 0); + + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONFIG_REG_1), =3D=3D, 0); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONFIG_REG_2), =3D=3D, + var->config2_reset); + g_assert_cmphex(i2c_get8(i2cdev, TMP421_CONVERSION_RATE_REG), =3D=3D, = 0x07); +} + +static void test_n_correct(void *obj, void *data, QGuestAllocator *alloc) +{ + const TMP421Variant *var =3D data; + QI2CDevice *i2cdev =3D obj; + + for (unsigned remote =3D 0; remote < 3; remote++) { + uint8_t reg =3D TMP421_N_CORRECT + remote; + + i2c_set8(i2cdev, reg, 0x7f); + /* Registers exist only for the variant's remote channels. */ + g_assert_cmphex(i2c_get8(i2cdev, reg), =3D=3D, + remote + 1 < var->nchannels ? 0x7f : 0); + } +} + static void tmp421_register_node(const TMP421Variant *var, const char *typ= e, uint8_t addr) { @@ -207,6 +240,10 @@ static void tmp421_register_node(const TMP421Variant *= var, const char *type, &(QOSGraphTestOptions) { .arg =3D (void *)var }); qos_add_test("channels", type, test_channels, &(QOSGraphTestOptions) { .arg =3D (void *)var }); + qos_add_test("soft-reset", type, test_soft_reset, + &(QOSGraphTestOptions) { .arg =3D (void *)var }); + qos_add_test("n-correct", type, test_n_correct, + &(QOSGraphTestOptions) { .arg =3D (void *)var }); } =20 static void tmp421_register_nodes(void) --=20 2.53.0-Meta From nobody Mon Nov 23 04:26:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1793871024; cv=none; d=zohomail.com; s=zohoarc; b=HQdmSLp7bN/4+VrHYv4UqD0DGHN/T2XCELfg++lUxmZV433R0VRj27GdsfzGGSnPZ/lyUY7YWeHDqzYuqlyKzvDIMbtNYy8b68ApQVWPItd4Vz6t7XBQ4jrQu7HPtaBChYs2rm6Tod/y2SrEcJyqDRr+jC/ddIDyodCTHVj2FeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793871024; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=hRQau7jFOLMcW9cDld4PZy7QHA0r3DkmWSHU69Dv0ic=; b=joRBA5chESxYEcsAe3v2EHBBiM6O/IxpWgolUdomD03mjKPCy9Qn086Q7CVIZqx6zkeQOYWYbpV942HsXJ9wAU9/ot8VrLWKxwG02ewHUE67xzeExnDf2LIXiDQHTmgzAwkkZ+hY5XExWIFa8jUn/aIkf8rRrUMDxlOid/9v6N8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179387102401719.721216649913913; Thu, 5 Nov 2026 01:30:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOtn9-0001SU-MH; Thu, 05 Nov 2026 04:29:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOtn7-0001KL-CW for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:53 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xOtn5-00074M-Dq for qemu-devel@nongnu.org; Thu, 05 Nov 2026 04:29:53 -0500 Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-89f639ba307so697909b3a.3 for ; Thu, 05 Nov 2026 01:29:51 -0800 (PST) Received: from localhost (118-163-122-149.hinet-ip.hinet.net. [118.163.122.149]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8b09af91d24sm1759590b3a.29.2026.11.05.01.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 01:29:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793870990; x=1794475790; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hRQau7jFOLMcW9cDld4PZy7QHA0r3DkmWSHU69Dv0ic=; b=rbAepRZiXF7ySgz3NodDsmQUFwOs7CysAmMZaIb6qGfb9YsEO0fkmUxl7B9pH/CYkG R9zg7/qHlY1MEq3BKaVYxoAFNw6N8nyvpOgnvygx/cRI7AHB7sEQ1rFJbTMsArSiPIWv AtQDCglF7PMD7njtGIqZcB/yHnJuHc9hqzV/SLAxOsrS7Cr2hVewbUGda2aTHaHtzRLa GoWDm3wuPwS1+ZaMxAOLmeWJw4mRfytzwhnuTlHP+QByVby2+HtKfxcNFElxGhYE/HJ3 HPlkNmHp3k6eNOHFNhVLdgUtewt6AboOt/ocMMsftbaeegqOrTOleQwCVICuQMfT/I4e Lxyw== X-Gm-Message-State: APuU4Z84E3oYmLr4B2tNgMT+Pi2aboo4qBqB2jFxpA86FvAzSlT+leQ5 SQqMsX2VHIykB7ieuSeoVHdvu5BDv6ZBIJyDJnb1VPTyfXOTnh+ZfPzodgk2zeYyhfM= X-Gm-Gg: AYBFou3F+py083dYCuRraP98KmGjagtPFnbtaUOvGeqJa8EainHvpSXYAwT2cVL0VeN Z7nFzAyte0ZyAMMsRLzVOkAx/XwDhAIi8Tn+V+78FFPsKLKAcGpes64Ss/lgq3DflMQH8Z45Rt2 aiDgGGXKCsHNubu5ome+nptTqDSNK+A13MwKH5nBXSdF+3cgHl6Ve8XnXErwm3Mx5qjsE9lFtYg 0dS12YZGEDlvGt8ETr8ucVsfTMwbHe2vSvn8RITFHjAdthtHVabcl5E0l+as911mFwTjzIJWbmr Fp+za0pN7vtmsLIelk2g5R4jBxhJ1Sbq1VKdrFqqchjmPTEK44t0vPJ47KOtUu9k/lukpJRa77c fSu1E+3SwzARSGwsgGdMZ8n5D2MYrwfFYobHLVqcZKMipVjdk2bFbxeHRMtezu4pzpJyvdhKzuW 8GtrV82+3Zd/qdI9p2eTiyifRcvVKyyYPjS2zqHhjTcY22wiQ+abm70QcADqvd0iOeYKJH0KasZ s0lvJg/K3cI6+ECvzx0FJA1MDypsxkHwtvEEgMTy8uS4bqVwSaJTDIn4jjiNSiHCaapCXvjEhih hPnn0ild5R2FCo1qD2DeeZ4cHz8IUXkG4cfPrLGE7b5euQOzE4nmnFd82ZfoE3wrd1XNVDlJ3PO MLXS7jb1yUmG92q//kwhH5g== X-Received: by 2002:a05:6a00:10d4:b0:89f:28c3:aab0 with SMTP id d2e1a72fcca58-8a9bf61f237mr15188701b3a.40.1793870989976; Thu, 05 Nov 2026 01:29:49 -0800 (PST) Date: Thu, 05 Nov 2026 17:25:55 +0800 Subject: [PATCH 16/16] tests/qtest: tmp421: cover the register form of the migration stream MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261105-sensor-tmp421-v1-16-c46853f5e1f0@free.fr> References: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> In-Reply-To: <20261105-sensor-tmp421-v1-0-c46853f5e1f0@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , eblot@meta.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Jamin Lin , Kane Chen , qemu-arm@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793870743; l=3815; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=KCKssRn/w/mRE8Rh274RLtAfGbpNnr2ePuT78VSY79A=; b=wGcVW44wmQZo44v/sifNQgtTmtsxOF5xTpY9gQkXfi3zHF9TFfOoUE+KOHd/qb9jHe5uWuUih M6AgtLtVbpWBMgv44AYk4XnLhBsqyd/KnwUTi92MdQdcrEC7Wa7fB+c X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.210.170; envelope-from=eblot.ml@gmail.com; helo=mail-pf1-f170.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Emmanuel Blot From: Emmanuel Blot via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793871024342158500 A stream with no measurement subsection has the shape of every stream written before that subsection existed; loading one exercises the conversion back from the register form. The temperature is picked so that form reproduces it exactly, and picked in the extended range, where the top register bit is part of the value rather than a sign. Signed-off-by: Emmanuel Blot --- tests/qtest/tmp421-test.c | 66 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 66 insertions(+) diff --git a/tests/qtest/tmp421-test.c b/tests/qtest/tmp421-test.c index 6c5332211b..5be2abc822 100644 --- a/tests/qtest/tmp421-test.c +++ b/tests/qtest/tmp421-test.c @@ -8,6 +8,8 @@ =20 #include "qemu/osdep.h" =20 +#include +#include "libqtest.h" #include "libqtest-single.h" #include "libqos/qgraph.h" #include "libqos/i2c.h" @@ -224,6 +226,69 @@ static void test_n_correct(void *obj, void *data, QGue= stAllocator *alloc) } } =20 +static int qtest_get_temperature(QTestState *qts, const char *id, + unsigned channel) +{ + g_autofree char *prop =3D g_strdup_printf("temperature%u", channel); + QDict *response; + int ret; + + response =3D qtest_qmp(qts, "{ 'execute': 'qom-get', 'arguments': " + "{ 'path': %s, 'property': %s } }", id, prop); + g_assert(qdict_haskey(response, "return")); + ret =3D qdict_get_int(response, "return"); + qobject_unref(response); + return ret; +} + +/* + * A stream written before the measurement was held in millidegrees carries + * only the register form. The subsection holding the measurement is left = out + * whenever that form can reproduce it, so an exactly representable extend= ed + * range temperature -- whose register value has its top bit set, and is n= ot + * a negative number -- travels the same path such a stream takes. + */ +static void test_migration(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D obj; + g_autofree char *tmpfs =3D NULL; + g_autofree char *mig_path =3D NULL; + g_autofree char *uri =3D NULL; + GString *dest_cmdline; + GError *err =3D NULL; + QTestState *to; + QDict *rsp; + + tmpfs =3D g_dir_make_tmp("tmp421-test-XXXXXX", &err); + g_assert_no_error(err); + g_assert(tmpfs); + + mig_path =3D g_strdup_printf("%s/socket.mig", tmpfs); + uri =3D g_strdup_printf("unix:%s", mig_path); + + i2c_set8(i2cdev, TMP421_CONFIG_REG_1, TMP421_CONFIG_RANGE); + set_temperature(TMP421_TEST_ID, 0, 100000); + g_assert_cmphex(i2c_get16(i2cdev, TMP421_TEMP_MSB0), =3D=3D, 0xA400); + + dest_cmdline =3D g_string_new(qos_get_current_command_line()); + g_string_append_printf(dest_cmdline, " -incoming %s", uri); + to =3D qtest_init(dest_cmdline->str); + + rsp =3D qmp("{ 'execute': 'migrate', 'arguments': { 'uri': %s } }", ur= i); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + + qmp_eventwait("STOP"); + qtest_qmp_eventwait(to, "RESUME"); + + g_assert_cmpint(qtest_get_temperature(to, TMP421_TEST_ID, 0), =3D=3D, = 100000); + + qtest_quit(to); + g_unlink(mig_path); + g_rmdir(tmpfs); + g_string_free(dest_cmdline, true); +} + static void tmp421_register_node(const TMP421Variant *var, const char *typ= e, uint8_t addr) { @@ -255,6 +320,7 @@ static void tmp421_register_nodes(void) /* Temperature encoding is variant-independent; exercise it once. */ qos_add_test("temperature", "tmp421", test_temperature, NULL); qos_add_test("range-saturation", "tmp421", test_range_saturation, NULL= ); + qos_add_test("migration", "tmp421", test_migration, NULL); } =20 libqos_init(tmp421_register_nodes); --=20 2.53.0-Meta