From patchwork Fri Jan 12 19:06:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emiliano Ingrassia X-Patchwork-Id: 10161571 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 C8B51602B3 for ; Fri, 12 Jan 2018 19:06:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9D4928715 for ; Fri, 12 Jan 2018 19:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE4DC28A20; Fri, 12 Jan 2018 19:06:06 +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 30B4328715 for ; Fri, 12 Jan 2018 19:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965044AbeALTGG (ORCPT ); Fri, 12 Jan 2018 14:06:06 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:37879 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964998AbeALTGF (ORCPT ); Fri, 12 Jan 2018 14:06:05 -0500 Received: by mail-wm0-f68.google.com with SMTP id f140so13705278wmd.2 for ; Fri, 12 Jan 2018 11:06:04 -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=SUH9CI8LnylK1pijiK3RL+IIUFGEDVLLo9YIVvnHNVs=; b=gax9YMc3tCeFbOYxe/X4/0Wuco74R7haSvkUheFgeJdzy8MWl2AtM4rNnuS/RDQ87r 8DgAXw5vOyzTuN4WrmIxxcam/Maak9NPq92SdCA0iJjEs6VuSGrL/oN1Et0GS94jlmqU lwRrkxyz2rxMJXeGy8H38G1zgKl2H0+gPHZ0k9ML41rMizn5FUVNJpM8jZRolnuZSXvE W+Lznk0FRVC8q18NRWfxQurwENXvOE8xuzflfzFjfYtrqD8nrqKVCY/umIWGLskLTs4a n1lX/0N0rH4G9ZP9AQ7+VAmbyKNJrGUtTHM8tUUfO0vMPrcXSwJuCsDp5ARqHFO5mp/I 8OUw== X-Gm-Message-State: AKwxytcWEjYKrh12fInzCQjSQMi6H87UcDtWhSNC34q0sKWbyjbta5qY e9U8JO1+5gSdJUapMJYSQaApaWdC X-Google-Smtp-Source: ACJfBoswZOKPtA+pgyt/bX5e69wrZ+AxXe5OlLZGNfwxj3GO6SkxJ+yr3hQneThbFofQyK2WBD/jBg== X-Received: by 10.28.159.149 with SMTP id i143mr4909393wme.19.1515783964130; Fri, 12 Jan 2018 11:06:04 -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 x81sm8915305wmd.14.2018.01.12.11.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 11:06:03 -0800 (PST) Date: Fri, 12 Jan 2018 20:06:00 +0100 From: Emiliano Ingrassia To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org Subject: [PATCH v2] hwmon: sht3x: wait predefined limits loading complete before access Message-ID: <20180112190600.GA21207@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 at least 500 us before the first read solves this issue. Signed-off-by: Emiliano Ingrassia --- drivers/hwmon/sht3x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index 6ea99cd6ae79..f2098443df2f 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -732,6 +732,9 @@ static int sht3x_probe(struct i2c_client *client, mutex_init(&data->i2c_lock); mutex_init(&data->data_lock); + /* wait predefined limits loading complete before access */ + usleep_range(500, 600); + ret = limits_update(data); if (ret) return ret;