Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3112642pxm; Mon, 28 Feb 2022 12:16:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL2qrlYofsbuScPkri3royuBR8YnX1xQVUNW2S/C8Lvon60FcjQYxokUtkmFllTCoJhprP X-Received: by 2002:a63:543:0:b0:374:62b7:8ab0 with SMTP id 64-20020a630543000000b0037462b78ab0mr18938551pgf.384.1646079379587; Mon, 28 Feb 2022 12:16:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079379; cv=none; d=google.com; s=arc-20160816; b=YFmUN6WGs8uk5PRRuxLAR+dM1mOj9H3LznbGZBYXTij0v8oUcHgAbSghjDLKwhO2+B rn56pAwAbiqKin6htCXbz8frBZJYQENmNF/NKzI6mnrMn2Ur+VExdI5PJxWNsef8bXZz v4oWAvdjyyeWUGL/mpp4uHFg1gjSd8erGaToloYWwJrdRlAoR4sOVHoJ6Oe9wN8DXaT3 gecnJgMyRHUGSwbvrK7O3CgaA+9SGwaWv8QelebLZiTxGGzMNJTa7yEDbnSahAmJxqAS mTXgQkq8dEnW6vYmVH7uBBlo8rlSek2Uhz9wFXuXTnb/a10Ldy7ZV4+Pl5qGOdG6VuPH YkSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/mc9lsu+jHqdIABvnwSydo1bGWtGjhwTTc2M8glzIYM=; b=LdKw6xnlHHlcxaLxdHYgq7O/pxS86v2xJ10ZfAXNpH4Hhb5tLFF2RP3+OAQQMCv+pO 9y2dhxah5vM5ZHH0PEyTzMgJbxab/0f5erQJ0awKInzA+leTF4AJgEsiowgfQtqlL2a1 MYbTarg2JmhHoiLtuZ0X4733CCvlbWwxcIRZ0rE17uqRIpLYGtgwZ1RB6uhOXPF+ccw5 Assls8ZrWpIErgVt6RPoQYRjBAAwLA35HHpfRQ8Axgeyqk4I7ECVo0MytUCOPrWmeDD1 TP6a5Mq4G3R9yMsK6fM4GwWhMdxGPCezmaNMX6e13RK1x06lIF01kKaRM3hBG06RDVBs TOyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08p+Cdcp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k20-20020a6568d4000000b00372c1cd9e0esi10697641pgt.579.2022.02.28.12.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:16:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08p+Cdcp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 42C0B17924E; Mon, 28 Feb 2022 11:38:04 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239662AbiB1SLk (ORCPT + 99 others); Mon, 28 Feb 2022 13:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239702AbiB1SFc (ORCPT ); Mon, 28 Feb 2022 13:05:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE9E5418A; Mon, 28 Feb 2022 09:48:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 636BAB81187; Mon, 28 Feb 2022 17:47:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3577C340E7; Mon, 28 Feb 2022 17:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646070467; bh=HtR2CxzOO8ZDLXGj1j6x+l8s1x2I1wdNHqufAAZ25hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08p+Cdcp+OWd1eI5caZe/6Oh8b2mR10xv9BZgc6dc8jGWUC7CIGbcDVivar5oKa4Z VRG0gFdRNKBDpxVGqCnRKumA24xbhTolhwl3og+QwMF0mOxGwg8e09A+T5FixIQJ51 d1EYF16CEhtL5KzAU7S61Qa9NczWwH6bvaOI45Qc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mario Tesi , Lorenzo Bianconi , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.16 119/164] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot Date: Mon, 28 Feb 2022 18:24:41 +0100 Message-Id: <20220228172411.078345606@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172359.567256961@linuxfoundation.org> References: <20220228172359.567256961@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi commit ea85bf906466191b58532bb19f4fbb4591f0a77e upstream. We need to wait for sensor settling time (~ 3/ODR) before reading data in st_lsm6dsx_read_oneshot routine in order to avoid corrupted samples. Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver") Reported-by: Mario Tesi Tested-by: Mario Tesi Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/b41ebda5535895298716c76d939f9f165fcd2d13.1644098120.git.lorenzo@kernel.org Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1374,8 +1374,12 @@ static int st_lsm6dsx_read_oneshot(struc if (err < 0) return err; + /* + * we need to wait for sensor settling time before + * reading data in order to avoid corrupted samples + */ delay = 1000000000 / sensor->odr; - usleep_range(delay, 2 * delay); + usleep_range(3 * delay, 4 * delay); err = st_lsm6dsx_read_locked(hw, addr, &data, sizeof(data)); if (err < 0)