From patchwork Sat Jan 27 16:03:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 193031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp558093dyb; Sat, 27 Jan 2024 08:05:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGySGWz4z1rdpJVL9W4SUBsQGxH/K4Bjo0ej+kbx8/gc8j9mK5ltw5cD5OmJm2IPslvsBJg X-Received: by 2002:a17:903:188:b0:1d7:55b1:4a3 with SMTP id z8-20020a170903018800b001d755b104a3mr3041844plg.11.1706371522209; Sat, 27 Jan 2024 08:05:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706371521; cv=pass; d=google.com; s=arc-20160816; b=EuhiDOFu+QUp+L0N8LbW2J6eTOZrLU4eyrfW1Wgy5R0x7gfld6jYFy6AmbFsfh8gDk YpF3d7EZHOys+2wRctDsuihvXK154wY3C7qNBn5BnfaJhoyx7Vh4Qy4FKuaqVJF8VJ88 4kxTF37j/A3WxyuPcFOOE4datVp/i13Y6Mnv351HV8cXU7qncEvsN/S5BDXiEywqQ07p mHBoF+zM+MmpS6iD5Adm5kuqYLeD3h4DVsenIAmvTEP1nY2T9FvdNyjzfMrIuuomZBNP YQrjtv2qgvhoG3aozGcUKTXASlENnZh9wdHLeA4rF1V3oUM6b9kQ/C2G0xhyzGOttXzR b58Q== ARC-Message-Signature: i=2; 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=U+x2SU3hj/nF4qLC/1uxVExrIHdd/La86ejwi0dEPUs=; fh=RpJjGiuDlOjmyoLhPwSzjbPbeK51vYo3I0V3BuRLNmU=; b=HHSXZPIlkoFIziR19qvPyoql361+VwTCPxH5C1fKj+2CUdCakhDcEVzj+PpsUBSlhZ e+liEIwm6w03shnF8iFLO6SXQwXoIdpTgVGTfL9LoL3XPkWAeY1ey+LqENfro+iKSWeI Fy4KYGBm+mSPMdpw+Pol4XPBVLAGHT3foPOrgAhGxzTqK03oDw3hBQolSXhEfcnAF2M7 ptBRFOo2T3uYd6ffQDqiEeYZmTqVN599XGst4TPyG80OkDjxv2l+vbkpw9UQ19OOcNdW hqzpd0tvIkieZIVmEs06focIW2UJKUgSTFnjWc4YQF1lHX7FCQ6pgOrI5fU4kfqu9Z71 d2+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=CUh9o+uT; arc=pass (i=1 spf=pass spfdomain=subdimension.ro dkim=pass dkdomain=subdimension.ro); spf=pass (google.com: domain of linux-kernel+bounces-41262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41262-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k70-20020a638449000000b005d62a0134eesi2959814pgd.889.2024.01.27.08.05.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:05:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=CUh9o+uT; arc=pass (i=1 spf=pass spfdomain=subdimension.ro dkim=pass dkdomain=subdimension.ro); spf=pass (google.com: domain of linux-kernel+bounces-41262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41262-ouuuleilei=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 095B2283F2B for ; Sat, 27 Jan 2024 16:05:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC0042D78A; Sat, 27 Jan 2024 16:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="CUh9o+uT" 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 8DFA529429; Sat, 27 Jan 2024 16:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=172.104.132.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706371462; cv=none; b=d3S2jN2SOU5djUCVXAibu93A2MnEChmmoUwlK8O2LkDNdkLexgUWr6nDoU+se3LP+EySAuGdWVX2W9Me3UPsuoE578onkG61u7WHcianQRmBL5VgoyTMW9TsZYlDr1JZOAdT90P7ehArKssbOc3aKao3wE3/UYU7Aheqjz6it5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706371462; c=relaxed/simple; bh=ckgGjldfa/QMe8AawYQJb7Zfb90P85Y8WeoWJuvHEos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=trCappT2L07M7Wk1hAEWbAchWiHi6nsWtDlGuUt2+4kcBc6HCoaam2B++HtgACean1+VmVfTWnqlAd8DA/B8mTwfTrcBHTOBNumpzekVAWfxXzuBiLydm9rCWnfWCUoHljRq6q+FLD4mdJAhl+vHhMcRSTQ/eY9ISVzOr1zKPvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=subdimension.ro; spf=pass smtp.mailfrom=subdimension.ro; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b=CUh9o+uT; arc=none smtp.client-ip=172.104.132.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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.80.170]) (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 BACDD293A96; Sat, 27 Jan 2024 16:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1706371452; bh=ckgGjldfa/QMe8AawYQJb7Zfb90P85Y8WeoWJuvHEos=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CUh9o+uTnmUJoufQ0WYAnwhjJmT6Hp05pQRZm8wnKawzLSpzmpxHiAsRRLS7S8r/E ndUqY5XHQo+bERBUbmOfr95NPFfJYJ6wKBoHgR4sLH8WJjv4e5/oCB18fiGxZGJesL LxfbLN3cg0gHeDKw0y0d8GqtzzP/v3mlWfz3hLqc= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 3/4] iio: pressure: hsc030pa add mandatory delay Date: Sat, 27 Jan 2024 18:03:57 +0200 Message-ID: <20240127160405.19696-4-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240127160405.19696-1-petre.rodan@subdimension.ro> References: <20240127160405.19696-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789260224166603928 X-GMAIL-MSGID: 1789260224166603928 Add a mandatory 2ms delay between consecutive chip reads. I found a new Technical Note pdf that specifies that the measurement cycle in these chips takes around 1.26ms. By adding this 2ms delay we make sure that we never get stale measurements. For more details, please see "Figure 1" in the pdf below: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf Signed-off-by: Petre Rodan --- v1 -> v2 no change drivers/iio/pressure/hsc030pa.h | 1 + drivers/iio/pressure/hsc030pa_i2c.c | 3 +++ drivers/iio/pressure/hsc030pa_spi.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/iio/pressure/hsc030pa.h b/drivers/iio/pressure/hsc030pa.h index f1079a70799f..56dc8e88194b 100644 --- a/drivers/iio/pressure/hsc030pa.h +++ b/drivers/iio/pressure/hsc030pa.h @@ -13,6 +13,7 @@ #include #define HSC_REG_MEASUREMENT_RD_SIZE 4 +#define HSC_RESP_TIME_MS 2 struct device; diff --git a/drivers/iio/pressure/hsc030pa_i2c.c b/drivers/iio/pressure/hsc030pa_i2c.c index b5810bafef40..b3fd230e71da 100644 --- a/drivers/iio/pressure/hsc030pa_i2c.c +++ b/drivers/iio/pressure/hsc030pa_i2c.c @@ -8,6 +8,7 @@ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf */ +#include #include #include #include @@ -25,6 +26,8 @@ static int hsc_i2c_recv(struct hsc_data *data) struct i2c_msg msg; int ret; + msleep_interruptible(HSC_RESP_TIME_MS); + msg.addr = client->addr; msg.flags = client->flags | I2C_M_RD; msg.len = HSC_REG_MEASUREMENT_RD_SIZE; diff --git a/drivers/iio/pressure/hsc030pa_spi.c b/drivers/iio/pressure/hsc030pa_spi.c index 8d3441f1dcf9..818fa6303454 100644 --- a/drivers/iio/pressure/hsc030pa_spi.c +++ b/drivers/iio/pressure/hsc030pa_spi.c @@ -8,6 +8,7 @@ * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/common/documents/sps-siot-sleep-mode-technical-note-008286-1-en-ciid-155793.pdf */ +#include #include #include #include @@ -28,6 +29,7 @@ static int hsc_spi_recv(struct hsc_data *data) .len = HSC_REG_MEASUREMENT_RD_SIZE, }; + msleep_interruptible(HSC_RESP_TIME_MS); return spi_sync_transfer(spi, &xfer, 1); }