From patchwork Fri Jun 16 16:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13282925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 955FFEB64D7 for ; Fri, 16 Jun 2023 16:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345506AbjFPQBW (ORCPT ); Fri, 16 Jun 2023 12:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344193AbjFPQBN (ORCPT ); Fri, 16 Jun 2023 12:01:13 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2035.outbound.protection.outlook.com [40.92.91.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B483AA3; Fri, 16 Jun 2023 09:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=luQ01OMzrUkPqfGR8WOhVbon0RFD4aA6rRQSB8IvkUHuy2K70gVS/fBUxR6DR3V0XEeGUmWnlPpqe94tl4m2mB+MEEyRtMxc9VZxMkKOf0s3FelZZ4wHhZRmS7nQzr+80/XFCGbHlENCMbp1bWdh/SvnCjVGUMl2HWxg0eYT4A4HJ8N4O5aOX1ZW0xw3Tb8dmzYG9TmYCsC9oWYNWo2jBRr4QcN0+myjXxkttYVLqR8U+LBkqEIMYHsJDyFGA7K0LXLwJlGXCUu6mhVAJ0UFoBPJ3KC48bTx/VmrYYiSgtBoKYEBFwr389XtdXaX1HpeZppGxCEET99kB0TEyYg+WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Of3MSRoZQsE4iQhpOZGiEcdvt3oFHJp0hiZHk4tIwPA=; b=B0MFOn093sJkn/1BvrcJCPTgeLc1CIs0WJh30Ld/IjiAJJbyiRRgaW8VI2y5N98qRdoatWyOWqfkwRRv4qnFbUOXkyFU6u1qd3hmevkmoFiHwF/vWWZRRZLEF+WxFOx/wN7kwaHa682pnoJPEDI/1PAmWJZ6YEw4Uxyqn60SBFrEP9YJWm1L9Q+IzLUdjZNqVcGygijp5Yb3B6kVlS1g0F5dHbWsClHx4w6Rxv6GitaOQ/OtpVVHqtWcAX2/8glr/f8FD24CFWz+i88JFjGNEMAZrU5YXaTPwB6hoa4IdtPTwFovNE3wprYgMkF/gymAOQW+pqgyHS7p1d/OPo+Xmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Of3MSRoZQsE4iQhpOZGiEcdvt3oFHJp0hiZHk4tIwPA=; b=ZyGCElTQ8QzbWz6DjbeYrG58sVz7IY/d2tcCsIIJ+FkG1zHReaTOwe5m6qOwkQAaYebIRZcxFzl8QJUG7thZjqhcL98TDZr4hJDeKGsCeL6JA1AJFym+2ajIebm5M1E2cVAvzRFwEK5fOyApxSndnZEuyNCayczA5EaHJlmLH+GlvSZKGZ7ljSrszpi1oEDulPHqS+zWien8vczsyih+U0aSNQlFqZGu6sho9UbenDaTcG182tXnTiUgdTEyI7hRe73AxFqgzQP7LJVbDO++LQxTvM14Fpv5NbSDw76LRLeG0Kv+kEjAEDWAUh85FfB+EmFcFwkHBf8B8RF/YzjISA== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by AS1PR10MB7959.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:471::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29; Fri, 16 Jun 2023 16:01:04 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%7]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 16:01:04 +0000 From: JuenKit Yip To: linux@roeck-us.net, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH v2 3/6] hwmon: (sht3x)replace "high-precision" property to "repeatability" Date: Sat, 17 Jun 2023 00:00:14 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616160017.21228-1-JuenKit_Yip@hotmail.com> References: <20230616160017.21228-1-JuenKit_Yip@hotmail.com> X-TMN: [7yZHOyOLKKKM+A8Y6kXBSA496cuFisWz] X-ClientProxiedBy: TY2PR04CA0009.apcprd04.prod.outlook.com (2603:1096:404:f6::21) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230616160017.21228-3-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|AS1PR10MB7959:EE_ X-MS-Office365-Filtering-Correlation-Id: d39db6f2-4a1b-42d4-9508-08db6e82e35f X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmrST/aUJU0/QQB6BlKfxJxwIUDlqYXA3VDxPZ0UqcuxpJun1s8ED3wRvwfzqA/OCz4lJZ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eMjaQpRNMRMYZgWrWJQqhk4MI1dJ2qE/HrawN0CJ2b8tA7yXSimHWjuLah1Mi6ZashdZr+AUI7efRmISSD6rVPyh8Cn4b1gKl6ag2/wFCJWiB4rGcmc2O0BUYSj5N9kA2lEHdPdClQQcP3HnLWktNWsaCnWiquVjx+n8+IAeAVMo9vNXrjrSxvMrv83qW5eFn51uzWmlbD2h3SjgPb8aQjOFXeFZuMUOd1VnYo6T9PAxWEAMnLw+cZH/b6y3RsUDXgpvdtEOFX+FNaM2jqAjlqZM0/QKhCqQTghO88LoWxXCqzsJtTcJUASrMbuGru7E4NP7W3WZX6f3383jPQRyGLJHvEikclUlmE8kOV0dOF6qK7tszSvNdePQsDJL/tZuiDv2zrLnP45ridZVl9Kqr6QpvbMfh5zG6WrtT/RZE3tn3BIc2caC9aVGncpsk5KGLc/VYUVNtB9aQRAc3BJ797EcsE5qgHJPkQEJY6ioOjV91wdxVfMIL5dPy8CB3wvcg0i3FsWSL7PU= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: d39db6f2-4a1b-42d4-9508-08db6e82e35f X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 16:01:04.6662 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR10MB7959 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Signed-off-by: JuenKit Yip --- Documentation/hwmon/sht3x.rst | 2 +- drivers/hwmon/sht3x.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Documentation/hwmon/sht3x.rst b/Documentation/hwmon/sht3x.rst index be70e2543..b4aa561f0 100644 --- a/Documentation/hwmon/sht3x.rst +++ b/Documentation/hwmon/sht3x.rst @@ -30,7 +30,7 @@ Documentation/i2c/instantiating-devices.rst for methods to instantiate the devic There is only one option configurable by means of sht3x_data: - high or low accuracy. High accuracy is used by default and using it is + repeatability: high repeatability is used by default and using it is strongly recommended. Even if sht3x sensor supports clock-strech(blocking mode) and non-strench diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index bbe556f44..ecc64febc 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -21,10 +21,10 @@ #include #include -/* commands (high precision mode) */ +/* commands (high repeatability mode) */ static const unsigned char sht3x_cmd_measure_single_hpm[] = { 0x24, 0x00 }; -/* commands (low power mode) */ +/* commands (low repeatability mode) */ static const unsigned char sht3x_cmd_measure_single_lpm[] = { 0x24, 0x16 }; /* commands for periodic mode */ @@ -66,9 +66,14 @@ enum sht3x_limits { limit_min_hyst, }; +enum sht3x_repeatability { + low_repeatability, + high_repeatability, +}; + DECLARE_CRC8_TABLE(sht3x_crc8_table); -/* periodic measure commands (high precision mode) */ +/* periodic measure commands (high repeatability mode) */ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ {0x20, 0x32}, @@ -82,7 +87,7 @@ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { {0x27, 0x37}, }; -/* periodic measure commands (low power mode) */ +/* periodic measure commands (low repeatability mode) */ static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ {0x20, 0x2f}, @@ -132,7 +137,7 @@ struct sht3x_data { const unsigned char *command; u32 wait_time; /* in us*/ unsigned long last_update; /* last update in periodic mode*/ - bool high_precision; + enum sht3x_repeatability repeatability; /* * cached values for temperature and humidity and limits @@ -436,7 +441,7 @@ static void sht3x_select_command(struct sht3x_data *data) data->command = sht3x_cmd_measure_periodic_mode; data->wait_time = 0; } else { - if (data->high_precision) { + if (data->repeatability == high_repeatability) { data->command = sht3x_cmd_measure_single_hpm; data->wait_time = SHT3X_SINGLE_WAIT_TIME_HPM; } else { @@ -584,7 +589,7 @@ static ssize_t update_interval_store(struct device *dev, } if (mode > 0) { - if (data->high_precision) + if (data->repeatability == high_repeatability) command = periodic_measure_commands_hpm[mode - 1]; else command = periodic_measure_commands_lpm[mode - 1]; @@ -679,7 +684,7 @@ static int sht3x_probe(struct i2c_client *client) if (!data) return -ENOMEM; - data->high_precision = true; + data->repeatability = high_repeatability; data->mode = 0; data->last_update = jiffies - msecs_to_jiffies(3000); data->client = client;