Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4437108rdb; Fri, 29 Dec 2023 01:26:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IG81ofXCD1MsDrWmUd8AWLQvp6PLHA3mguFi0WHZ/pjjNhNFM8V5bjP5zrNVfFn3KZJEot8 X-Received: by 2002:ad4:5c4b:0:b0:67a:359:a82c with SMTP id a11-20020ad45c4b000000b0067a0359a82cmr21135603qva.22.1703842004782; Fri, 29 Dec 2023 01:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842004; cv=none; d=google.com; s=arc-20160816; b=vRuasKOFhlF5DyFRVobbSBSdv6y6KxACGD0eOjW5fuArZdz0K+bA4CotLRh6nZNmoF jK1EoACxlPe4uGGwEwIbdV7pS3y6Ai2CY4kzApwJhQIn0y9aiGwM1EwZH7XKpZn4QtU2 2TnqS/ZH8dji5bDnvnfhvGsMK/VvwjLDs7JW37t/bHDXdxD2/040DfEzBF5QeojVQkdC EEGlnHUNW6WCuPiPU/KOBaJoHeCMx7NGVhABj23DcHLD+6k2yev2RFuS0pes3hZl0odO UzjYGJo1f1CcNHig6J8rG+qguNLwhDNSV8Pgumr9uZGgJRG7KJbSyCExv3ezXRG08Ydf RULg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8UnxNb10S0yXPkPLRZ/mgeEJI3f6GIksHWzAJ6/qZ3U=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=iBzNuYJ2B3KXmDE7Ra2OLvnFaW/D/14ir07X9Oy7Uqz/bTRsg1Y9CQ3C+hijjP+glv wWCOYypAN5RkCMGqvjIVUwyFAgMHvLvbKaaXhVi+SMVObG7Fyjd0qMBzE3Yhh1tVsJWh Z/VIDzktfmn7xOT/DZfuZ30ggItRRwHEuYgVOjasba8ABoxSW1Xtr8zuXdDH2e3ZAkJf ZPs22mmWcv19rp2qDBrBCZrBXVulQy2xGwKIjWsUMz9XIWxwxPvTPn3NiZ8UN+0Um+86 O4ugi6iUX/lizLMzQXDjHIDYrK8x6w5QuqE6oSAcnLDEWeuKz+EiW5JyiLETBphnJGV4 WylQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=mIaJW9MP; spf=pass (google.com: domain of linux-kernel+bounces-13032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p20-20020a0cf554000000b0067f29a19dd9si18111452qvm.120.2023.12.29.01.26.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=mIaJW9MP; spf=pass (google.com: domain of linux-kernel+bounces-13032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 87D101C2238D for ; Fri, 29 Dec 2023 09:26:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 337FD125D9; Fri, 29 Dec 2023 09:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="mIaJW9MP" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD29611707; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 581A028B587; Fri, 29 Dec 2023 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841907; bh=WDPOUW7eIikkHeG8X4wBbQ+EIdwGrEaQcqnAsLeHEGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mIaJW9MPIiNCMyBoEfJRjdEiuJ4AhJe0o9TNUvAraFysQ+wSv77fr7hU1NTmS6Usj 74htdF0yGWbcKsPFMKoGHbG0CFJBfYNxzwlRoR9wPSHYKAJUGpp2CV+M9wrI9UdFQ8 7u03koibqsE3BNczxn3udLHD5v1Ajp6dksPUKHwA= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 05/10] iio: pressure: mprls0025pa improve driver error resilience Date: Fri, 29 Dec 2023 11:24:33 +0200 Message-ID: <20231229092445.30180-6-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Improve driver error resilience by ignoring the measurement if any of the 3 error flags gets set while interacting with the sensor. Based on the datasheet, in table 14 on page 14, the status byte contains: bit 5 busy flag - 1 if device is busy bit 2 memory integrity/error flag - 1 if integrity test failed bit 0 math saturation - 1 if internal math saturation has occurred Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 no changes drivers/iio/pressure/mprls0025pa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index e3f0de020a40..233cc1dc38ad 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -39,6 +39,8 @@ #define MPR_I2C_MEMORY BIT(2) /* integrity test passed */ #define MPR_I2C_MATH BIT(0) /* internal math saturation */ +#define MPR_I2C_ERR_FLAG (MPR_I2C_BUSY | MPR_I2C_MEMORY | MPR_I2C_MATH) + /* * support _RAW sysfs interface: * @@ -213,7 +215,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) status); return status; } - if (!(status & MPR_I2C_BUSY)) + if (!(status & MPR_I2C_ERR_FLAG)) break; } if (i == nloops) { @@ -233,7 +235,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) return -EIO; } - if (buf[0] & MPR_I2C_BUSY) { + if (buf[0] & MPR_I2C_ERR_FLAG) { /* * it should never be the case that status still indicates * business -- 2.41.0