From patchwork Fri Jan 12 17:29:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emiliano Ingrassia X-Patchwork-Id: 10161481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AF22602B3 for ; Fri, 12 Jan 2018 17:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E1C288DE for ; Fri, 12 Jan 2018 17:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 340B228A0F; Fri, 12 Jan 2018 17:29:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8775288DE for ; Fri, 12 Jan 2018 17:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934121AbeALR3I (ORCPT ); Fri, 12 Jan 2018 12:29:08 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38270 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933771AbeALR3G (ORCPT ); Fri, 12 Jan 2018 12:29:06 -0500 Received: by mail-wr0-f194.google.com with SMTP id x1so1773972wrb.5 for ; Fri, 12 Jan 2018 09:29:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=zc4ksEPu27zR/GD1p9BblnZPL/xo7U2TSrAmBTlreOU=; b=R4l7JvxFkxmO9nkvG/KdK6jKZ4zkOsCj0GYw2PXrnSyPXwVqCcP8w8leY7Koxg/06o XVLmSQyKRc8+xSLX7dQkh/ETe0Jzj3wFlcFYG8T4P+UUnUVkd5URifR0RrgSsJWdyeJz Q3qeSZ34XGBJXeUy46bxhuc5hAXJbyuq5B27t0IpW2p2SXfezOi+J++F6Rw0QOMgdPpu xmXgcmt7RZVdGdWjtv0SlD9VDbfYwVSgIWjhPfiDzD8LJy6FdYXsC73ewT7+kh8f2hDK xLs7yKUyMaY5pmCdvsmXGXP8ksJ+EQ1b6GOy6uO4Bf3adwNu3ouqY4Li/vtDGxBmVrmx 1rEw== X-Gm-Message-State: AKGB3mKw7RNP02ID+pIST2UtoveTwBTvL7rU2tSv84doRRcbDeX5kJ7Y +rnqj57pI2iR8EFw8bre6QA76cJG X-Google-Smtp-Source: ACJfBovBNenwG+YnYSb2hRW55h72l/WuNJ2Udxo7Oqoy4tuRDzuqoNaFd1PoxjeCHjDa6v6xQlXXow== X-Received: by 10.223.157.201 with SMTP id q9mr24538730wre.205.1515778145118; Fri, 12 Jan 2018 09:29:05 -0800 (PST) Received: from ingrassia.epigenesys.com (host194-85-static.3-79-b.business.telecomitalia.it. [79.3.85.194]) by smtp.gmail.com with ESMTPSA id e8sm5856448wmc.1.2018.01.12.09.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 09:29:04 -0800 (PST) Date: Fri, 12 Jan 2018 18:29:01 +0100 From: Emiliano Ingrassia To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org Subject: [PATCH] hwmon: sht3x: wait predefined limits loading complete before access Message-ID: <20180112172901.GA15784@ingrassia.epigenesys.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP An sht3x sensor include limits register which contains temperature and humidity limit values. After a reset, pre-defined values are loaded into that register. During the probe function, the driver reads the limits register. However, if the reads are made too early, for example because the I2C bus frequency is high (e.g. 400 kHz), the loading could be not completed and the sensor returns a NACK which causes the probe to fail. A delay of 500 us before the first read solves this issue. Signed-off-by: Emiliano Ingrassia --- drivers/hwmon/sht3x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index 6ea99cd6ae79..cec06b76656e 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -732,6 +732,8 @@ static int sht3x_probe(struct i2c_client *client, mutex_init(&data->i2c_lock); mutex_init(&data->data_lock); + udelay(500); + ret = limits_update(data); if (ret) return ret;