From nobody Sun Nov 24 04:38:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725637783; cv=none; d=zohomail.com; s=zohoarc; b=hvyDfOmJBIpntzkfpN/OxAQ+nDzHmiX8O8RO/LJmPD5yFYzvozdK5qb1NnFogX8VU5AwJO55jJ+gS+r6117qPGogxWSFpxiTKq97H1UioluGr9FpJHArzF5vQ5Phh8eKaI7svGqZqASTBhicARhUjqMdMPQAwiInJrW4+JjY7Do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725637783; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ub8tZ79/fRaGRCH8Xhob5KBKMKk2ELdx+VDpRNkwtNw=; b=lH7vWcw1mX48vrRqoiiuIElS4nzMAbU32vmfnwArOklhQMcEXOXm89HsxVyTQdZ70DCn6y61yJg5FuIjOPJGmFaQ+/U6IGkrN2uKjjLa/5RvSMSUVTHAP0WjdjgFCyZKE4IqduNkvo6hBM8Vx2pq/u0JpGjx24Ps9T796M7uK9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725637783135690.8216415146588; Fri, 6 Sep 2024 08:49:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smbDA-00088c-Ur; Fri, 06 Sep 2024 11:49:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smbD8-000880-Kf for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:22 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smbD6-0008Aa-SK for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:22 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5c255e3c327so2347984a12.1 for ; Fri, 06 Sep 2024 08:49:20 -0700 (PDT) Received: from localhost.localdomain (225.13.23.93.rev.sfr.net. [93.23.13.225]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3cc529241sm2571799a12.11.2024.09.06.08.49.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 08:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725637759; x=1726242559; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ub8tZ79/fRaGRCH8Xhob5KBKMKk2ELdx+VDpRNkwtNw=; b=vI8mI/FNZEN7vNeyqLFQo5ITlF1dolcsFGJgd7T6c7ZJpn3YeESjM17iGFLK/XL402 jgLLyBApU2EoTji5gifvH9FYvcrLUzBmQx6dRgMyxEXR7C7DfbI51+0Jx2EexgNgvE0y vSsMRiYBSybV8ARwHE9DBVelhF00ZFYWc99ZO2E2wU2QrmDAqPvRfJbgiPxUtqYV0uJd AzX/KwtAChBs6tTY1HlzvLQwhODl2kvdLHHaj6r1+l2+DdhU995Fsud730/veAux+auG hsR5aCwSLUITf/neJhveItjJDeodNzM8XkCpnK1+mp1WTuZkNYdLIJF76h9q7dJs0Gv7 /d3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725637759; x=1726242559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ub8tZ79/fRaGRCH8Xhob5KBKMKk2ELdx+VDpRNkwtNw=; b=NiX+mBpRE9wBujqyhooHRFpQwpmfmhunJ8ZT0OHO/lOErdjUZ4DjSeI1QnB+V9GkaH 01O4240dj8FPIchTolLGIR9bUtzI7Tbn4arZEXQbVa7b4pv3viaopW7j6/ZBtU6/4YUb 6KnmE8VkTpbdHaPjy+kPFKyvXFMrIhUf+PMAmtNG3AyStytojA7uI50UkF0wg1ikULsK bk9BjkV83f6oDDE+XA8I/fSjVBMF+lYA/UqdXGMALqb9PKq0BvAXwHbUdPKJR2oMiMXF LYbKodFom6g2x7/sfHzkcBagAXWBeCbvNDOVjcd/TWDV233XYOyi0p5dj39d+wJj0THg 4dSg== X-Forwarded-Encrypted: i=1; AJvYcCU5fUYCA2jaDWu+mkMouIHBGJBCa2isvNgiPpjO45O1PduJFgf0EMwpg7O6ZJTqwQ2bzyJTxznXFecW@nongnu.org X-Gm-Message-State: AOJu0YwQZt5nAZgOi8ufx/dHSPNeW4G92+YtcOpBB9p7dXjUDcSnDA4w 7VMD2o1ameft0ZXKC3HHhr1SX7NArZf+125/otfo3EeI0dHsmAJbp7WtlT/9UbQ= X-Google-Smtp-Source: AGHT+IF4eGPfOBxwsUAKqlT46HgHb7uaSlU6vBDPuV3cz03+JF21Ql9B6TLmNjRhk4uM7WCG3oLxMA== X-Received: by 2002:a05:6402:348d:b0:5c2:4740:939d with SMTP id 4fb4d7f45d1cf-5c3dc7baf09mr2029890a12.26.1725637759197; Fri, 06 Sep 2024 08:49:19 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 1/5] hw/sensor/tmp105: Coding style fixes Date: Fri, 6 Sep 2024 17:49:07 +0200 Message-ID: <20240906154911.86803-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906154911.86803-1-philmd@linaro.org> References: <20240906154911.86803-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725637803448116600 From: Guenter Roeck Coding style asks for no space between variable and "++". The next patch in this series will change one of those assignments. Instead of changing just one with that patch, change all of them for consistency. While at it, also fix other coding style problems reported by checkpatch. Signed-off-by: Guenter Roeck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/sensor/tmp105.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c index a8730d0b7f..ad97c9684c 100644 --- a/hw/sensor/tmp105.c +++ b/hw/sensor/tmp105.c @@ -29,16 +29,17 @@ =20 static void tmp105_interrupt_update(TMP105State *s) { - qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */ + qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */ } =20 static void tmp105_alarm_update(TMP105State *s) { - if ((s->config >> 0) & 1) { /* SD */ - if ((s->config >> 7) & 1) /* OS */ - s->config &=3D ~(1 << 7); /* OS */ - else + if ((s->config >> 0) & 1) { /* SD */ + if ((s->config >> 7) & 1) { /* OS */ + s->config &=3D ~(1 << 7); /* OS */ + } else { return; + } } =20 if (s->config >> 1 & 1) { @@ -89,7 +90,8 @@ static void tmp105_get_temperature(Object *obj, Visitor *= v, const char *name, visit_type_int(v, name, &value, errp); } =20 -/* Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8 +/* + * 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. */ static void tmp105_set_temperature(Object *obj, Visitor *v, const char *na= me, @@ -118,30 +120,30 @@ static void tmp105_read(TMP105State *s) { s->len =3D 0; =20 - if ((s->config >> 1) & 1) { /* TM */ + if ((s->config >> 1) & 1) { /* TM */ s->alarm =3D 0; tmp105_interrupt_update(s); } =20 switch (s->pointer & 3) { case TMP105_REG_TEMPERATURE: - s->buf[s->len ++] =3D (((uint16_t) s->temperature) >> 8); - s->buf[s->len ++] =3D (((uint16_t) s->temperature) >> 0) & - (0xf0 << ((~s->config >> 5) & 3)); /* R */ + s->buf[s->len++] =3D (((uint16_t) s->temperature) >> 8); + s->buf[s->len++] =3D (((uint16_t) s->temperature) >> 0) & + (0xf0 << ((~s->config >> 5) & 3)); /* R */ break; =20 case TMP105_REG_CONFIG: - s->buf[s->len ++] =3D s->config; + s->buf[s->len++] =3D s->config; break; =20 case TMP105_REG_T_LOW: - s->buf[s->len ++] =3D ((uint16_t) s->limit[0]) >> 8; - s->buf[s->len ++] =3D ((uint16_t) s->limit[0]) >> 0; + s->buf[s->len++] =3D ((uint16_t) s->limit[0]) >> 8; + s->buf[s->len++] =3D ((uint16_t) s->limit[0]) >> 0; break; =20 case TMP105_REG_T_HIGH: - s->buf[s->len ++] =3D ((uint16_t) s->limit[1]) >> 8; - s->buf[s->len ++] =3D ((uint16_t) s->limit[1]) >> 0; + s->buf[s->len++] =3D ((uint16_t) s->limit[1]) >> 8; + s->buf[s->len++] =3D ((uint16_t) s->limit[1]) >> 0; break; } } @@ -153,18 +155,20 @@ static void tmp105_write(TMP105State *s) break; =20 case TMP105_REG_CONFIG: - if (s->buf[0] & ~s->config & (1 << 0)) /* SD */ + if (s->buf[0] & ~s->config & (1 << 0)) { /* SD */ printf("%s: TMP105 shutdown\n", __func__); + } s->config =3D s->buf[0]; - s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ tmp105_alarm_update(s); break; =20 case TMP105_REG_T_LOW: case TMP105_REG_T_HIGH: - if (s->len >=3D 3) + if (s->len >=3D 3) { s->limit[s->pointer & 1] =3D (int16_t) ((((uint16_t) s->buf[0]) << 8) | s->buf[1]); + } tmp105_alarm_update(s); break; } @@ -175,7 +179,7 @@ static uint8_t tmp105_rx(I2CSlave *i2c) TMP105State *s =3D TMP105(i2c); =20 if (s->len < 2) { - return s->buf[s->len ++]; + return s->buf[s->len++]; } else { return 0xff; } @@ -215,7 +219,7 @@ static int tmp105_post_load(void *opaque, int version_i= d) { TMP105State *s =3D opaque; =20 - s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ =20 tmp105_interrupt_update(s); return 0; --=20 2.45.2 From nobody Sun Nov 24 04:38:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725637817; cv=none; d=zohomail.com; s=zohoarc; b=OdRh/RdegJFWPPP9HDyOuQoA3xUp0G8sJem8juhnRMPF/xH6zc+BTv+2Lvx1J65aYdkMh0Ecs/QqCiivJKYulFBVxQvS4Aa7Dr/wfA26xTmtzb65RPVBdUpqKzbLvArms7BP/e0njHLudhM4zEGZ7WG8JB5MhmTqUrQydU2Z0wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725637817; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TW+gKU0Fbu3XeokU7+BEDwC7NasKVljAZ5Retp9xJ60=; b=VUF40Va1u0G50CdmbH8dz0DxsadcfFWOydOto/W/5YIg7HA5dla+/BckzR0y2stWPjHSiD3Oh4rSAMkZGGXgqo6AMb2fE8eUyjtbBCH2nALqqn9Nsz7LT4jAELHbWweMyYR43uKawwZQYP/V9Lt+GBRXIq4mpwya98dMlTG4keE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725637817073646.5574833714569; Fri, 6 Sep 2024 08:50:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smbDF-0008IJ-1S; Fri, 06 Sep 2024 11:49:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smbDE-0008Hl-8q for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:28 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smbDC-0008Av-Jf for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:28 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a89c8db505bso300447366b.0 for ; Fri, 06 Sep 2024 08:49:26 -0700 (PDT) Received: from localhost.localdomain (225.13.23.93.rev.sfr.net. [93.23.13.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a6236d16fsm292217866b.99.2024.09.06.08.49.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 08:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725637765; x=1726242565; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TW+gKU0Fbu3XeokU7+BEDwC7NasKVljAZ5Retp9xJ60=; b=TeaYyO3Fpw34pVk3kE7HRDM8do4Fpwx4UCQ6BJnCIdQtmHZx3eKB/px8GINs5qYGlJ 5T5puCYFVWgxt3GM0ws+0d/DAqK9C/AVIL5KSncibP5IDNSXU8H0VXa2sLK/U7m2nN/M Gh36vhLC3DL7wNogIUXSgIJNwUoYWGRrx0JKB0jdIaQKAocSl4ioWTA4DbJwTsoWoOCU SbNfgt+xdclTJWPwaX3HKa647yrmb94p8F5hJvmBN0ZHHLrEl0AEAV/V0gtFrRHCQpX0 qxlmG2xltLSHfodwHPwm+EuqudvNaIsl9E164ymjHBl9jEyKX4ZxM70daZAyoHdR8NkA S4xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725637765; x=1726242565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TW+gKU0Fbu3XeokU7+BEDwC7NasKVljAZ5Retp9xJ60=; b=PzsLBc5oJHnQt0FVXujXSZ4JJesTg692IDFMPpMrxUjsHaInh4i9/PzqZgCCRXEBvb KsAlSWS0/wj7+WzQmf/yXPC2uRTzNroVHnSg60v0kBgmWse4cDKVP9RGJnNGWpkDTqKI mHt974fulv6Lk/jk3FtIJqUkgzpxDxh2CS2KZtVrhWU0w0fBX5MVBQOJHRMq0dA3WubB kbQVLiyvTiSPl4D7x1afTzsZsfGnqvUpc6FNIKVzCco4KdkOmsP/AOaamqtjRZ4wPBKv 423IhAq7giJHOYqgs3jpAgjWC31mmrGT8mi0D20qLZPEsR6+juwL4YL+b4Hf/RCsc5SU akZQ== X-Forwarded-Encrypted: i=1; AJvYcCUzHHb+DR8bWr3MVLreambaB1sAD08n7/2ufzJwAJstGQwmgaHlyr7E9RPcQgAKmN+3XTlNDUZc9Vpv@nongnu.org X-Gm-Message-State: AOJu0YxzA8yuVbpJZ7dVvoeFToERa1Eel/3YpHyc9XdHFo526hZVEGZd n15Iwz+YMtDLjsfgCxaKN4NruAhUD4hGQqhG1JbjtScOyrrkG/R+51aQu8aUmNs= X-Google-Smtp-Source: AGHT+IFPi+PTmBJ7SaTs/2nCAPb+g9c7BE2U7m/FoWHk1FKsOLdzg5NQYi+r0LLwFwPggXNGMo1dWQ== X-Received: by 2002:a17:907:ea4:b0:a86:99e9:ffa1 with SMTP id a640c23a62f3a-a8a888f11a7mr237329666b.64.1725637764786; Fri, 06 Sep 2024 08:49:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 2/5] hw/sensor/tmp105: Use registerfields API Date: Fri, 6 Sep 2024 17:49:08 +0200 Message-ID: <20240906154911.86803-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906154911.86803-1-philmd@linaro.org> References: <20240906154911.86803-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725637836080116600 To improve readability, use the registerfields API. Define the register bits with FIELD(), and use the FIELD_EX8() and FIELD_DP8() macros. Remove the abbreviations in comments. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Guenter Roeck --- hw/sensor/tmp105.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c index ad97c9684c..150d09b278 100644 --- a/hw/sensor/tmp105.c +++ b/hw/sensor/tmp105.c @@ -26,23 +26,31 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/module.h" +#include "hw/registerfields.h" + +FIELD(CONFIG, SHUTDOWN_MODE, 0, 1) +FIELD(CONFIG, THERMOSTAT_MODE, 1, 1) +FIELD(CONFIG, POLARITY, 2, 1) +FIELD(CONFIG, FAULT_QUEUE, 3, 2) +FIELD(CONFIG, CONVERTER_RESOLUTION, 5, 2) +FIELD(CONFIG, ONE_SHOT, 7, 1) =20 static void tmp105_interrupt_update(TMP105State *s) { - qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */ + qemu_set_irq(s->pin, s->alarm ^ FIELD_EX8(~s->config, CONFIG, POLARITY= )); } =20 static void tmp105_alarm_update(TMP105State *s) { - if ((s->config >> 0) & 1) { /* SD */ - if ((s->config >> 7) & 1) { /* OS */ - s->config &=3D ~(1 << 7); /* OS */ + if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) { + if (FIELD_EX8(s->config, CONFIG, ONE_SHOT)) { + s->config =3D FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0); } else { return; } } =20 - if (s->config >> 1 & 1) { + if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) { /* * TM =3D=3D 1 : Interrupt mode. We signal Alert when the * temperature rises above T_high, and expect the guest to clear @@ -120,7 +128,7 @@ static void tmp105_read(TMP105State *s) { s->len =3D 0; =20 - if ((s->config >> 1) & 1) { /* TM */ + if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) { s->alarm =3D 0; tmp105_interrupt_update(s); } @@ -129,7 +137,7 @@ static void tmp105_read(TMP105State *s) case TMP105_REG_TEMPERATURE: s->buf[s->len++] =3D (((uint16_t) s->temperature) >> 8); s->buf[s->len++] =3D (((uint16_t) s->temperature) >> 0) & - (0xf0 << ((~s->config >> 5) & 3)); /* R */ + (0xf0 << (FIELD_EX8(~s->config, CONFIG, CONVERTER_RESOLUTI= ON))); break; =20 case TMP105_REG_CONFIG: @@ -155,11 +163,11 @@ static void tmp105_write(TMP105State *s) break; =20 case TMP105_REG_CONFIG: - if (s->buf[0] & ~s->config & (1 << 0)) { /* SD */ + if (FIELD_EX8(s->buf[0] & ~s->config, CONFIG, SHUTDOWN_MODE)) { printf("%s: TMP105 shutdown\n", __func__); } s->config =3D s->buf[0]; - s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults =3D tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUE= UE)]; tmp105_alarm_update(s); break; =20 @@ -219,7 +227,7 @@ static int tmp105_post_load(void *opaque, int version_i= d) { TMP105State *s =3D opaque; =20 - s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults =3D tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; =20 tmp105_interrupt_update(s); return 0; @@ -277,7 +285,7 @@ static void tmp105_reset(I2CSlave *i2c) s->temperature =3D 0; s->pointer =3D 0; s->config =3D 0; - s->faults =3D tmp105_faultq[(s->config >> 3) & 3]; + s->faults =3D tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; s->alarm =3D 0; s->detect_falling =3D false; =20 --=20 2.45.2 From nobody Sun Nov 24 04:38:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725637800; cv=none; d=zohomail.com; s=zohoarc; b=Qd3/yL2tBhLe5kfXWr3CcJqLwjuhM4Y6R1QiWJk9TyyRvYcejsvML5vnJYqEl4NnEOP8gxWo1y6Z3nHZsvtFuxbOnJKJcPRt+P/B8P1vp/29Wliz8g0yfgoJoywy/pH9ILvHLv+g+e4NqOwzUP3QQLFwC8ae4f74iDAa4JaQI3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725637800; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=358hg9o1rKr1N4ec0h1JIGJ3AxYmlGZHvU3jCe1X9nY=; b=FINWWfpCQxIUIqcW5yE/cGH8EZ8vPgsFBgkO6ZmiQKKR1P0YJMqr+aP0+2gsBKaKCgHKTBZNMZnW+oaNDN3DmTNedVCBQAY8HFLt+0h7oytyrBQtvFTQicL2djD0Qa2BudJXmuyh1av0gDl+eapweCjsMEisflboO2lPenOvmzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725637800435234.19106850954427; Fri, 6 Sep 2024 08:50:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smbDK-0000GR-P9; Fri, 06 Sep 2024 11:49:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smbDJ-00009G-76 for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:33 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smbDH-0008BC-JK for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:32 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5c3ca32971cso2634435a12.0 for ; Fri, 06 Sep 2024 08:49:31 -0700 (PDT) Received: from localhost.localdomain (225.13.23.93.rev.sfr.net. [93.23.13.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a61fba616sm291846566b.40.2024.09.06.08.49.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 08:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725637770; x=1726242570; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=358hg9o1rKr1N4ec0h1JIGJ3AxYmlGZHvU3jCe1X9nY=; b=UkEufFv74236FXXzMCR//rNtUxs2Nt+ySOiJdqaKqZ10cA7QaPqul+FntJNh8+bBOF Zoo3fB3cdWsKdDUcZO8xCWIH0LLMTkf9e9eN4nptquMCnkUrQWhnVWpICTkTJRtfR5Wh rCDp9nOOnvM1WcF4mr8FGsdpnFW/HUtD6JCob22tGUtkyGmg/YmDeEQ0Cx87NZNJ9jMM lno8snPXaBDTfq85azzkIgL87jXuChoPgDtkfj24V991kvcFG2S3AK0g+efaQwgBTzxM wWUOdDUhpQ84Okz/VhyOb4hrw4g5UPLZikdJnReNL2LBPtVLYHTyEMUwbf6phWLkH8+h ++Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725637770; x=1726242570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=358hg9o1rKr1N4ec0h1JIGJ3AxYmlGZHvU3jCe1X9nY=; b=X8LVHr4UFSXmA0rJ0ahAK86fCPegdujQ6aYl7mPoUK/cMJQn6kGaqVeX7lrHfI1Mqr 3qnwNLLhXYf8l2UuBNepJdmqgNXWicwlStXXU+e5AGwMbw4ukaaXoP2S3FpooIh73EPR nn+2S6UAkiHoJ4GUDpNwrDeOFSnhSzoX3dR9333cRrptwHuL5ITZ2MoFR4lzm1bc/XUX KVKZKpO3Pl550R07RVXBTxVvI5lmugzARfjJfXV2Yk2whnY5MUrZj5mAyR+VCYXVax98 q/VVB7RsmInDGqL3ALCk31FoPx+j9hyvjSqUw9TMnXgxaik8gO/whl0EDTYpc7kKDtRa ip9g== X-Forwarded-Encrypted: i=1; AJvYcCU6TutpES4HhgTGk6IzNvLDMcUkdCmisLTv2kTOov0mZfTNXLdzX/hA221v6HGizYrCN2kZ8oDOcfY5@nongnu.org X-Gm-Message-State: AOJu0YxBJxkiIp8CsrW8jD4CCmn12TuCPkj3Q8S7z3NdxDTF2BqFitN4 NKC56CEZxnQi61VruH3UeBVifxpWcDb3VWbKBB6knn3cwvMo6tilZekm1cVpGlY= X-Google-Smtp-Source: AGHT+IGo2FKxBgmkLi2SWYKzCibP3pG0nVLsEI9aenBA3pDpkk47O+7fCDUVAPU9w9kx9XqdN/iSdA== X-Received: by 2002:a17:907:5cb:b0:a86:a73e:7ec9 with SMTP id a640c23a62f3a-a8a88843cd4mr262830666b.46.1725637770115; Fri, 06 Sep 2024 08:49:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 3/5] hw/sensor/tmp105: Pass 'oneshot' argument to tmp105_alarm_update() Date: Fri, 6 Sep 2024 17:49:09 +0200 Message-ID: <20240906154911.86803-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906154911.86803-1-philmd@linaro.org> References: <20240906154911.86803-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725637818971116600 The next commit will clear the ONE_SHOT bit in the WRITE path (to keep the READ path trivial). As a preliminary step, pass the 'oneshot' value as argument to tmp105_alarm_update(). No logical change intended. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Guenter Roeck --- hw/sensor/tmp105.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c index 150d09b278..6740200aea 100644 --- a/hw/sensor/tmp105.c +++ b/hw/sensor/tmp105.c @@ -40,10 +40,10 @@ static void tmp105_interrupt_update(TMP105State *s) qemu_set_irq(s->pin, s->alarm ^ FIELD_EX8(~s->config, CONFIG, POLARITY= )); } =20 -static void tmp105_alarm_update(TMP105State *s) +static void tmp105_alarm_update(TMP105State *s, bool one_shot) { if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) { - if (FIELD_EX8(s->config, CONFIG, ONE_SHOT)) { + if (one_shot) { s->config =3D FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0); } else { return; @@ -119,7 +119,7 @@ static void tmp105_set_temperature(Object *obj, Visitor= *v, const char *name, =20 s->temperature =3D (int16_t) (temp * 256 / 1000); =20 - tmp105_alarm_update(s); + tmp105_alarm_update(s, false); } =20 static const int tmp105_faultq[4] =3D { 1, 2, 4, 6 }; @@ -168,7 +168,7 @@ static void tmp105_write(TMP105State *s) } s->config =3D s->buf[0]; s->faults =3D tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUE= UE)]; - tmp105_alarm_update(s); + tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT)); break; =20 case TMP105_REG_T_LOW: @@ -177,7 +177,7 @@ static void tmp105_write(TMP105State *s) s->limit[s->pointer & 1] =3D (int16_t) ((((uint16_t) s->buf[0]) << 8) | s->buf[1]); } - tmp105_alarm_update(s); + tmp105_alarm_update(s, false); break; } } --=20 2.45.2 From nobody Sun Nov 24 04:38:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725637798; cv=none; d=zohomail.com; s=zohoarc; b=Dfa32H/wcK4L/rx9dcXN7nzEzpBFIMfJuKLmRmzFKYkz4+b0mJrPv+wgOQX7MZJ0cvdiu84fDVSvpBmuE8tMd2kd6+3ynCQ788iyhNpAuAtJIxTPFKFdBixPqfjRncVmbMz6NO7HAUV159HX19CZnSdFllUnWlfp7WVmPZ56iDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725637798; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W23TnfpgxAN9v1+Vm3iFNdPGKTZYWiFvO/O0vyDC8Bg=; b=LOiVpoyDWtXcuIRka6TFpzkNfroajr0Hh/xYGv/PXmPtHdMq3SZJk0fzyb0AkeZR56Ah60yS9taie71qC20cuCVlr5fYntt52triPX/b4q0CJVk/KHif8V0Lpmtuh9Z1COWrV7dNd8zTCqJ7rnefSYOekrd60aKt/Roy5ncqqYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725637798525975.9138448486052; Fri, 6 Sep 2024 08:49:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smbDP-0000et-DX; Fri, 06 Sep 2024 11:49:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smbDO-0000ab-F8 for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:38 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smbDM-0008BQ-TC for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:38 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a83597ce5beso357632466b.1 for ; Fri, 06 Sep 2024 08:49:36 -0700 (PDT) Received: from localhost.localdomain (225.13.23.93.rev.sfr.net. [93.23.13.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d0e116feesm34907866b.10.2024.09.06.08.49.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 08:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725637775; x=1726242575; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W23TnfpgxAN9v1+Vm3iFNdPGKTZYWiFvO/O0vyDC8Bg=; b=UsljmePJI1FFjDPnTpGBhEryPUvuSMABjPpo10weX1g4fttZcxetTPcnUC44V+vE4k JRXDOnIVEp1yT++1PH1tj0M+nhy/AhnTpyGqKC9lS9zKNO86h7kdwX48Mpl2eLyVuYJx EqopL9mR2e8jwORf0gkd9AvS7CtanyfrfuF2jPuNrA9rXdXJZm5xJ1kb6axMf+GR696T TKBCM90JXkLMRlI37uAIVWwcj35MVVHlNZrb/bQ8qVA/U5yBbjT6E67hn8TOQ1gq9yQc E8Wz3DPcq9ScodMydewfdH2wSHrbeaTVFRNXikO3wmA2bTVctIyOOoxZnloLdkopJ6t5 7+iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725637775; x=1726242575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W23TnfpgxAN9v1+Vm3iFNdPGKTZYWiFvO/O0vyDC8Bg=; b=wmmPQvUqQLErnboD8G0Gl989wRvaFhP/eGMraMq+MdGFXblHrEmuz7rBq6j1qlCKap ZAJVLBZR8x7T/9I+2/DfxgVm5mmYED2z7QjOvUrTVDZaHYxFYdjqGjlFgqT28Exo4N6b 3amFnD29+pqEawej8cM1/M/ft0vWfBHU8IikOwNrxV2k9O15lgiWLqOXCURrFzdWACPq hnAS6oanciv7fK9g7xIDAnKHCH9Nr48U+kJOM65CJiBliT6SNE4CbjcwAONf4vPKegXJ CO0U0qcw42BCII+m5ntVlemamXx/msCsbkVEgm7a1McqBu5ceTalpgg887VfwqufyGgq Z9RQ== X-Forwarded-Encrypted: i=1; AJvYcCX3bm50xLbkYimLySS09hR9SgTpTipbPXi6M8pHzPQrpzn6rEqn8cdscPE9ex74BqJlNgYWSECVgajn@nongnu.org X-Gm-Message-State: AOJu0YwIK0Kzy/Tzk/r0og4MCGqWerP1Ot+X5ZzVw/rPbMDmH4ff4tMY F0/ASOiXj2xOR5K+6Cg9I3Du6dJ++9f2F1ca8NN2yfGf9Gg2ihq3H9qzP4Pv9fw= X-Google-Smtp-Source: AGHT+IGLAPHe1BZaxJywiT5Ah8pICN7s2/dr3WOBJ5u440fGYM5yOTmvt1qVJ8dFdLWOsbqs2rgb6w== X-Received: by 2002:a17:907:3ea0:b0:a86:b9c4:a439 with SMTP id a640c23a62f3a-a8a431c7209mr1128050366b.21.1725637775493; Fri, 06 Sep 2024 08:49:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 4/5] hw/sensor/tmp105: OS (one-shot) bit in config register always returns 0 Date: Fri, 6 Sep 2024 17:49:10 +0200 Message-ID: <20240906154911.86803-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906154911.86803-1-philmd@linaro.org> References: <20240906154911.86803-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725637817203116600 Per datasheet, "ONE-SHOT (OS)", the OS bit always returns 0 when reading the configuration register. Clear the ONE_SHOT bit in the WRITE path. Now than the READ path is simpler, we can also simplify tmp105_alarm_update(). Signed-off-by: Guenter Roeck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/sensor/tmp105.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c index 6740200aea..f5101af919 100644 --- a/hw/sensor/tmp105.c +++ b/hw/sensor/tmp105.c @@ -42,12 +42,8 @@ static void tmp105_interrupt_update(TMP105State *s) =20 static void tmp105_alarm_update(TMP105State *s, bool one_shot) { - if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) { - if (one_shot) { - s->config =3D FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0); - } else { - return; - } + if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE) && !one_shot) { + return; } =20 if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) { @@ -166,7 +162,7 @@ static void tmp105_write(TMP105State *s) if (FIELD_EX8(s->buf[0] & ~s->config, CONFIG, SHUTDOWN_MODE)) { printf("%s: TMP105 shutdown\n", __func__); } - s->config =3D s->buf[0]; + s->config =3D FIELD_DP8(s->buf[0], CONFIG, ONE_SHOT, 0); s->faults =3D tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUE= UE)]; tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT)); break; --=20 2.45.2 From nobody Sun Nov 24 04:38:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725637826; cv=none; d=zohomail.com; s=zohoarc; b=C5/EqdUsyU5vi4MPcrsnay6K57F/7RJlnH6BpUe/mvcHrmSe+BkRL3rhTMRuQ+I4uIZpUzu9+CwJGDU3qCPCtxVhKGzm0diOGbKE+Mgrf4J8NdtMaiR5jKJ3lr4bxz9Ja0bVhGdQZG8iAzpf2j6O0kakRZ3RKPekKD8Gg8iK40Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725637826; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vC9WnbFOdrpXQUX3BWmGZJypN5/VBj5S9SdVEOdGWIc=; b=WrscJ6xe7BfeinDBzkwIySGDEZtdr9N+69PBc92GRYUZTshiozymSHLDGOa7mfkxuYtjmGMJUTXZxrfWpm2pvyd0DFej5/9bMNk/GodWBhukfEiuyprIfcF6EZLKvBgszbYNOy+mlz+qKLsnunmj/mnwX7yTFbs6X1SDCy6KLsc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725637826479489.6338647427574; Fri, 6 Sep 2024 08:50:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smbDV-0001NL-Lt; Fri, 06 Sep 2024 11:49:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smbDU-0001GG-3i for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:44 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smbDS-0008Bn-Ff for qemu-devel@nongnu.org; Fri, 06 Sep 2024 11:49:43 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5c263118780so2446265a12.2 for ; Fri, 06 Sep 2024 08:49:42 -0700 (PDT) Received: from localhost.localdomain (225.13.23.93.rev.sfr.net. [93.23.13.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a8e439feesm98449766b.74.2024.09.06.08.49.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 08:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725637781; x=1726242581; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vC9WnbFOdrpXQUX3BWmGZJypN5/VBj5S9SdVEOdGWIc=; b=jDt1OGHnD8SKd1floQySmZjpOHrHVcOgvpHtQo1QYPePn/n2/N2yka7aS6wikMBs49 LZO/nVrIfcDj0ECe/qE8ABNAn59Hq5ojtzU+Y7hDc7hLw4i/Jlad9i3ZM7XSr7zDVjNw nzp4EYpsIq+KEU1af8ynZN9HLoklmKy00CyaLoiAWNSgJHRwEsCmVJfuq7MA7Pfqu59g 8M1d1r1oBgnXjROlPSXlq3zhK/1Mtp02Y6Mg8Y/T2hFpipMLueorgSs3DrzaoDLAj8Zw aRSbF0ISEeFtCujRkfcfFWIDgv7opwsjo1sowVVRfogd9kk57+3BrQNpHpYKVMR+1EMX QGCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725637781; x=1726242581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vC9WnbFOdrpXQUX3BWmGZJypN5/VBj5S9SdVEOdGWIc=; b=ps4YPZYOHo8xd6GHJgmvKHizDxNWRQq6rXMMEOwiTTuLPxIy34EZt8mC6OCvbr9U69 USAylC/ybSvxuouQgrH+caNiBIwCaHOw1iTVcWJJh8jHcXDC/Oev30iD3K5MTGWwxj+T pnEzOAzPW62SlwOpb8IPPCkK69yKfoqUAlwou+L5W4eABCIm5CURcU7QsrE7kTvYRHwA D2AFByHUpBZuyWmzREgt3NzrlegKaV0W5Pmh1bn4LcmIMvbAEC9hhPaRVN5EXn6IC3yQ 8j8zPDc6WhisKb70bK3l6Kp0epjQB/3nIA1b0ImWnQrl+y7drBGLtza025gxw8JnfApQ mdbA== X-Forwarded-Encrypted: i=1; AJvYcCUmpGmg3RD3bNRnzOc92a10GyKJoIWn5jQwUShFK/rEA2tMXGFaYqrg3T93WdXBAx0aGmuzQWtNregV@nongnu.org X-Gm-Message-State: AOJu0Ywwo8/goS2tYKk9/GqSSxzECFP28He8xJZviYUx54Q+Wwe8wS+4 Zzt5siZGI/eWQeF1QcaHXN4GXQeoa+yMz8l+UQl5pXt8UIj7uZSnjZGuuWVxQlY= X-Google-Smtp-Source: AGHT+IGClyno7/InsWevzZBVn4ySxeMti/CIC5Jov2agpzD6xbGkx8GM4D06oZ099YFcw1qDwVmdFw== X-Received: by 2002:a17:907:3689:b0:a86:7d62:4c28 with SMTP id a640c23a62f3a-a8a886667b6mr252359666b.30.1725637780821; Fri, 06 Sep 2024 08:49:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 5/5] hw/sensor/tmp105: Lower 4 bit of limit registers are always 0 Date: Fri, 6 Sep 2024 17:49:11 +0200 Message-ID: <20240906154911.86803-6-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906154911.86803-1-philmd@linaro.org> References: <20240906154911.86803-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=philmd@linaro.org; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725637844604116600 From: Guenter Roeck Per datasheet, "HIGH AND LOW LIMIT REGISTERS", the lower 4 bit of the limit registers are unused and always report 0. The lower 4 bit should not be used for temperature comparisons, so mask the unused bits before storing the limits. Signed-off-by: Guenter Roeck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/sensor/tmp105.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c index f5101af919..9d7b911f59 100644 --- a/hw/sensor/tmp105.c +++ b/hw/sensor/tmp105.c @@ -171,7 +171,7 @@ static void tmp105_write(TMP105State *s) case TMP105_REG_T_HIGH: if (s->len >=3D 3) { s->limit[s->pointer & 1] =3D (int16_t) - ((((uint16_t) s->buf[0]) << 8) | s->buf[1]); + ((((uint16_t) s->buf[0]) << 8) | (s->buf[1] & 0xf0)); } tmp105_alarm_update(s, false); break; --=20 2.45.2