From patchwork Fri Sep 6 15:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825995 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp872682wrb; Fri, 6 Sep 2024 08:49:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzNVNN9WterQcW5NOPZnOu6HWl4cjbWv3fvMSm1jM+szmIiyYtbX4Pkd0tFM3ODLEIZ+fiKA==@linaro.org X-Google-Smtp-Source: AGHT+IF+WtU2AKg5eJe/IQ5J2ZZUR0LZYSNSJZ25RxBVfrNvch6OnNx9DlaZyHlLGmiqz9/ALeCl X-Received: by 2002:a05:6214:5890:b0:6b5:d95c:692d with SMTP id 6a1803df08f44-6c52850fff8mr62033466d6.13.1725637782802; Fri, 06 Sep 2024 08:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725637782; cv=none; d=google.com; s=arc-20240605; b=CkoF6b76rpc+aNyLpTu3MkD7Omwbd4a7XBm5MiPWqORrWLclRyZyMGGUwuCBN0GMRT HlShpIFIZ/66o7scKfYXQYOebmrieLihdIpj99AeOB01kaO7LkR+JUGx0gSYs11T9278 AUqWyt1iir5TYtzD4cREdyXURs0q2Q9ElD/9vVY+PAjPm38lAd0bGSMqaNcDRXA37i3V JazIygPTUGEuqRhhxA/5Wxg0dYpilavUc7is7oNuaN9sk/dqLzJn/5ds+8ZdjxMM+nJd zNSrMmI51GCswNCshFXuhezTHwlfMUF02liSlHHPOAKG4V678vh98t31B9VlbSalOJBf ZTIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ub8tZ79/fRaGRCH8Xhob5KBKMKk2ELdx+VDpRNkwtNw=; fh=GUfNz8m23x71celdWh98+HOq7KNEoq5S47nKDIG9+FQ=; b=fSiLfFgi4YItK8NbYfk03UbaBgeCAZR3a8+Gv9IN8LKF0rYF0BqR7BohMwU6FIi6eX 0zz/SThBFxDPlwrsuggcB2sLBv069CkxDtSJvofvfVnV8WKmmwCCQ4r7dIidS/pJfUu/ zpdJertKFRmi9KJgJm589zi5lq0QCayqcemg2jHPcM3GM/3erk0ks9vzcVE+wn1rnxEa scaR0J4jEZTlPjZ1Uwt9Y876M59M3eqChmhII2vW9ZrQIqe019WkjdWC79cY1Yjjau0L QQxpk5QMw3Zjvtcrcsf++ncrWyO2mps4oapSfEi1iuxFP4kuhNPPZDDdb1gSRz2QUGZn D2Fg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vI8mI/FN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c53062a485si5648336d6.67.2024.09.06.08.49.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 08:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vI8mI/FN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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 @@ 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 */ } static void tmp105_alarm_update(TMP105State *s) { - if ((s->config >> 0) & 1) { /* SD */ - if ((s->config >> 7) & 1) /* OS */ - s->config &= ~(1 << 7); /* OS */ - else + if ((s->config >> 0) & 1) { /* SD */ + if ((s->config >> 7) & 1) { /* OS */ + s->config &= ~(1 << 7); /* OS */ + } else { return; + } } 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); } -/* 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 *name, @@ -118,30 +120,30 @@ static void tmp105_read(TMP105State *s) { s->len = 0; - if ((s->config >> 1) & 1) { /* TM */ + if ((s->config >> 1) & 1) { /* TM */ s->alarm = 0; tmp105_interrupt_update(s); } switch (s->pointer & 3) { case TMP105_REG_TEMPERATURE: - s->buf[s->len ++] = (((uint16_t) s->temperature) >> 8); - s->buf[s->len ++] = (((uint16_t) s->temperature) >> 0) & - (0xf0 << ((~s->config >> 5) & 3)); /* R */ + s->buf[s->len++] = (((uint16_t) s->temperature) >> 8); + s->buf[s->len++] = (((uint16_t) s->temperature) >> 0) & + (0xf0 << ((~s->config >> 5) & 3)); /* R */ break; case TMP105_REG_CONFIG: - s->buf[s->len ++] = s->config; + s->buf[s->len++] = s->config; break; case TMP105_REG_T_LOW: - s->buf[s->len ++] = ((uint16_t) s->limit[0]) >> 8; - s->buf[s->len ++] = ((uint16_t) s->limit[0]) >> 0; + s->buf[s->len++] = ((uint16_t) s->limit[0]) >> 8; + s->buf[s->len++] = ((uint16_t) s->limit[0]) >> 0; break; case TMP105_REG_T_HIGH: - s->buf[s->len ++] = ((uint16_t) s->limit[1]) >> 8; - s->buf[s->len ++] = ((uint16_t) s->limit[1]) >> 0; + s->buf[s->len++] = ((uint16_t) s->limit[1]) >> 8; + s->buf[s->len++] = ((uint16_t) s->limit[1]) >> 0; break; } } @@ -153,18 +155,20 @@ static void tmp105_write(TMP105State *s) break; 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 = s->buf[0]; - s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ tmp105_alarm_update(s); break; case TMP105_REG_T_LOW: case TMP105_REG_T_HIGH: - if (s->len >= 3) + if (s->len >= 3) { s->limit[s->pointer & 1] = (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 = TMP105(i2c); 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_id) { TMP105State *s = opaque; - s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ tmp105_interrupt_update(s); return 0; From patchwork Fri Sep 6 15:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825999 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp872915wrb; Fri, 6 Sep 2024 08:50:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWq0GI02g32WP/Lp3tQkqXluHR8zNkj2c2SfQUFO4X9uWe/+Fx1FAiYfZOnnUHd8NhReXW/jA==@linaro.org X-Google-Smtp-Source: AGHT+IFWiqJRT06ovvE39mQJ3cKoYZ8FrSKqHQIU25VLoeMiKnXg0E2eSyPZSpjQHXpWntssTovq X-Received: by 2002:ac8:7dc7:0:b0:453:7706:75b1 with SMTP id d75a77b69052e-4580c6705a3mr27610731cf.5.1725637816825; Fri, 06 Sep 2024 08:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725637816; cv=none; d=google.com; s=arc-20240605; b=awKpidOkMC9KkvIAZhANDVfyZh7AhVCU0x2Ouh0mholXpWob00aKH7aCprK+RBnKr8 /6NwVHfjz2uTQy7zrSvJmrs643bJUeEz2lAPVplKMYLFJ6SVW/PfxI7ABThcsNoh9bf/ 9PaFCdrYyKin4H8/IDFX7OHL8STZRNr93g2Ui0b3mTC57jzERAX1JqnDM23E/1tF6EnV p4aUSRoRiNzBXjrltsYxAXKTqTWTh7ui+3pBv4/NI19RzBBnOVGX2A9Pg4RDRBoHG4eJ Fp26NSAO4objZnYgvB4J5+k1pu3/pwsOeZmY2kUYiGmPK29igeRAjv6yQXI92+JQ6yl5 yeLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TW+gKU0Fbu3XeokU7+BEDwC7NasKVljAZ5Retp9xJ60=; fh=47msMfzOjBGiKb3INv90kT6VVtfGm4mbiwj44lYpN5M=; b=DYWysikrtycCrZYkxypHlUKvZyY1MCAaFpCiivQyIZm3ohIg6sZQ0IjG5NpLZuiAt/ dQn0d2a6J/ic5QCWTrEstIEL9C6ZbhG0zSeb7qGllDQ3KqqR7K4hs6uiCjLsecmUKD7c SiXiMkuuKDHoyKnSvmho6H8Tr2BSHBUa606Xb8oxBvgm6zFAcAD7hp4RhLRlh42iq7zE xLCs1E9Jm5GhJnlmRcMTuTovjF+9syu7Vjm5R6LIerUMUcEqJ7vcN5hLyElAIPPfES57 09iMYbDvAVz5e0UGlVdZ6qrUGuFAkKl8JJ15TCR4sxs9Ihg9COr2pns662DaqTdsN++w veyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TeaYyO3F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4581d3ae806si4420861cf.42.2024.09.06.08.50.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 08:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TeaYyO3F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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) 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)); } static void tmp105_alarm_update(TMP105State *s) { - if ((s->config >> 0) & 1) { /* SD */ - if ((s->config >> 7) & 1) { /* OS */ - s->config &= ~(1 << 7); /* OS */ + if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) { + if (FIELD_EX8(s->config, CONFIG, ONE_SHOT)) { + s->config = FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0); } else { return; } } - if (s->config >> 1 & 1) { + if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) { /* * TM == 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 = 0; - if ((s->config >> 1) & 1) { /* TM */ + if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) { s->alarm = 0; tmp105_interrupt_update(s); } @@ -129,7 +137,7 @@ static void tmp105_read(TMP105State *s) case TMP105_REG_TEMPERATURE: s->buf[s->len++] = (((uint16_t) s->temperature) >> 8); s->buf[s->len++] = (((uint16_t) s->temperature) >> 0) & - (0xf0 << ((~s->config >> 5) & 3)); /* R */ + (0xf0 << (FIELD_EX8(~s->config, CONFIG, CONVERTER_RESOLUTION))); break; case TMP105_REG_CONFIG: @@ -155,11 +163,11 @@ static void tmp105_write(TMP105State *s) break; 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 = s->buf[0]; - s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; tmp105_alarm_update(s); break; @@ -219,7 +227,7 @@ static int tmp105_post_load(void *opaque, int version_id) { TMP105State *s = opaque; - s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ + s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; tmp105_interrupt_update(s); return 0; @@ -277,7 +285,7 @@ static void tmp105_reset(I2CSlave *i2c) s->temperature = 0; s->pointer = 0; s->config = 0; - s->faults = tmp105_faultq[(s->config >> 3) & 3]; + s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; s->alarm = 0; s->detect_falling = false; From patchwork Fri Sep 6 15:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825998 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp872788wrb; Fri, 6 Sep 2024 08:50:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXaVZVux6zg9gI/JqQK6exLQ3YtmdwQobO/mWjZQmUhb63JLs2YXv89AGcTvff6N80vnr/ojg==@linaro.org X-Google-Smtp-Source: AGHT+IElZ6LNu7viNdulS2CMVWPdiLIFY4nOIdoZIWQXa7tt6L+/OOHaetaEVpUUEJB2FXbQdhWC X-Received: by 2002:a05:620a:370c:b0:79d:8042:cd01 with SMTP id af79cd13be357-7a9973284famr355849485a.7.1725637800083; Fri, 06 Sep 2024 08:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725637800; cv=none; d=google.com; s=arc-20240605; b=WEMeUrbQIhnVzfTbENCwNJGOUMGSrCoYk9U+tCqehM4elUgEzU9kYV838LyBB2grmA Mf+r9Bi8wqUlmhjmrLUzoTn6qRBKdVCOk86C4g+nCAiIwG1yQmYu0Tf9Fcw0/cmYMNEe XIwTG2V30mPDsIrkqzuTX74gsFKvddbBIMesBYJQqycaGU1ceJF0a/mEzvd0Ho3N8maZ tadwwSwLbvIIGV3a3BnRGSiSX3oTldgjVzKZ5L6ZFWdqZMd6nw+TF6uHeALLw2HwIG89 hXzNY++qsxmy1YNGnqhynL9kz6iS96MK4DUHreqPrVDiZHxF25VnDueLeTFOJcnMNb6o 716A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=358hg9o1rKr1N4ec0h1JIGJ3AxYmlGZHvU3jCe1X9nY=; fh=gWRfAZy3ZFJOpFddPkLJMq+dGVXOg9oSUoSEbZlYz1I=; b=GIMhLKJ2wX4Ko14Hr29N3LSM5NJZ93Fzn8SNRR0Ir+mcuX9Pofx3jT9LMrPFbHHmUk 9yXgkwYkQJUOLurqrlahT2FstlRirNYXGBWty2s93o/1bXj1WNcGcVyy6xOcBqU4NHA3 JZDjSV3pCcBE4aoc2A/rqHps43jKvfZeIc6pD4EhMmj7N6HbUtVbmIbmmAbFy54J8Oml w93odP79w29+m6v3kqdGajIcIRFHT/dozXvPrW8COLQeqlJ3yZ5eVH2eD8qXcEW1uV9p tqHhauHOusuPTZQF6ZiItb3ekve79m3hcFZzUJHx8+TG8Orh1cLrS17zZHr0arIURzmC WAjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UkEufFv7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a107b60csi52682785a.575.2024.09.06.08.49.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 08:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UkEufFv7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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)); } -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 = 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, s->temperature = (int16_t) (temp * 256 / 1000); - tmp105_alarm_update(s); + tmp105_alarm_update(s, false); } static const int tmp105_faultq[4] = { 1, 2, 4, 6 }; @@ -168,7 +168,7 @@ static void tmp105_write(TMP105State *s) } s->config = s->buf[0]; s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; - tmp105_alarm_update(s); + tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT)); break; case TMP105_REG_T_LOW: @@ -177,7 +177,7 @@ static void tmp105_write(TMP105State *s) s->limit[s->pointer & 1] = (int16_t) ((((uint16_t) s->buf[0]) << 8) | s->buf[1]); } - tmp105_alarm_update(s); + tmp105_alarm_update(s, false); break; } } From patchwork Fri Sep 6 15:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825997 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp872778wrb; Fri, 6 Sep 2024 08:49:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUk1qLcOlzAHwVqN8CdxytKYN3stsyhRHPP5r3/BpKSqoHNqwUZE5plY/DjVi8QIAGUrvPV1A==@linaro.org X-Google-Smtp-Source: AGHT+IFZNM/XThH+s2+p8BSIhUANjBAeDBoY5a94xIhrGsmgbf4POhVd9mZmtvAK+nrmNsDoyCDj X-Received: by 2002:a05:620a:4591:b0:7a6:7613:3883 with SMTP id af79cd13be357-7a98887363fmr1583996385a.2.1725637798176; Fri, 06 Sep 2024 08:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725637798; cv=none; d=google.com; s=arc-20240605; b=XM7nTZU050LWE0AEetl1u+stRoeEKUs5PHy/sHjxEdCukmx7VTYe+V5tNbYCskFC3I 7DJcr5nNylITPKlC+62qioClMDK1j3xzhzg203Yro/zf4Jkj+uGDpituoJRSvV/wfsUP O8lDCXxDgMBthutaPVpOKlUZGw2Th++bxjUCUXDN4/dQxJs1DWd9PFUqwJZhONReF/Tj /4EpZgI451cqMinEILKeEFeodM0vBuwXKiJ3tqblAN8TRKqx97lDR/fmqilz/pWRx8d4 BiGc4pav72D5VtE2v5RbuAjbcHfa7iiQXpRNyo0FtLEr2cvIE05SE7NvrmJeSM5inEIp C/vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W23TnfpgxAN9v1+Vm3iFNdPGKTZYWiFvO/O0vyDC8Bg=; fh=nRCTEwSYu5MWa72DwGuLg+GZL5vSmuqRKExcQCp4wFk=; b=TpX+AKSwSJSq2GxrywZEWg5/3EUxdIlOjmH9l6Embz+/Ju1llNBLbMegDH/a7DN20o zzxPuyAxmBqYqdxzqCqRav9lmd+wHm/ljuKWp0Y1kfOWBlzgZF2JIkprzW6mhtdw1RMZ CjOvX/cjZ38LRAWmmGrYm8AyzJLmGdsL8kTiT/y3rG9TjLVgQSMF/LgGvpPoo6IbotiM ba1SEhI+Hwj/x2Kch16/IT1h7CUxwMHCC6szW1rzsjHhqpkKjDGTTTHTYImzR0tYl+pc htFTkNzWMiSiAEhHRLDTzTdfqkqfBAA2Kkttx3HzBS5nkpXoYD5rjBlyCV9PCkiOwTlD K12g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UsljmePJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a107d421si52317985a.591.2024.09.06.08.49.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 08:49:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UsljmePJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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) static void tmp105_alarm_update(TMP105State *s, bool one_shot) { - if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) { - if (one_shot) { - s->config = FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0); - } else { - return; - } + if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE) && !one_shot) { + return; } 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 = s->buf[0]; + s->config = FIELD_DP8(s->buf[0], CONFIG, ONE_SHOT, 0); s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)]; tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT)); break; From patchwork Fri Sep 6 15:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 826000 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp872982wrb; Fri, 6 Sep 2024 08:50:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUYILT2HLmx1iLHiLGaidvN2ummSOGaFrLLPsKU3RdKevRRvDvCAvQgZo4HfjLJrYoxp5lasg==@linaro.org X-Google-Smtp-Source: AGHT+IHjn8XdoOqhzrxUQTm33fOXZowuSEyEaaBvIrUczcQTNkwELxj6JQw5YXErhEUf2Jee8YnD X-Received: by 2002:a05:620a:25ce:b0:79f:12fb:ed1 with SMTP id af79cd13be357-7a8041b2bb2mr3194788285a.16.1725637826177; Fri, 06 Sep 2024 08:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725637826; cv=none; d=google.com; s=arc-20240605; b=YFWrWHB3jYj+oJ83HLdRBqSj/HdUdd9pjR7koUghp/tobZJoHYRYWnflIzqTPodX3w JkdyWdOG1/wITmHTZ/N+t55s73uI4o/U1WUB5vx2FreP5zZiwz+TlVPS6duW3tEGavx8 Kl4GtmPrL/sXbcXV5Jj+k97WCGYCyZeuocQzan3Z7uRB+gMtRUHw0dAB3gYlvNH+jKDq sEejp+pihzlCINXBDcnxC9JQnZebSAGP/OJ2g+BjaHXyFjQp1vdVBBld3V+AkybBdCiU glpncAuH6fMa+wujc34VGegQfxz0d9G6qOY52F7Zm+zLcCeCejggDhiPNfAatWL4oMeD kSig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vC9WnbFOdrpXQUX3BWmGZJypN5/VBj5S9SdVEOdGWIc=; fh=XHQmldol60HUOyyUh43aTGymNqmcQlnvhYKBBJVPfXY=; b=WMxNliXx2gjWsL4DWMbHIf8QKYmfgB+9O3NXIkQIm+qwcJG0rrSXzTao+bhSbfET9H 9vVZK515yuac2l4tpcDufyB66MGqqMHbDJCNvlfjJB3T71oat+RDuPJByIVevBJ7DvRS aVWk3YUotfzU0kD+zuo9Yy+XowI4ghdqqxRTTY2CDazn2zzJ3RZDVDD5yaTZhp/R15dT bsrkFoIAXoMJR0C3zOh5W/H8MKJ2SLekuOd2TeORkESuyP8Ecst/TfO34XXT+asrIKuu OOSH3MWJNqjxqnixxOCkTJj3ApzUUnfARSoG83FL+YwRWyQsmswQT2pWOWOjFxtq1Q1n pUEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDt1OGHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a1027519si66945685a.168.2024.09.06.08.50.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 08:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDt1OGHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Guenter Roeck , qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 >= 3) { s->limit[s->pointer & 1] = (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;