Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3928601imm; Mon, 8 Oct 2018 11:50:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV63rYYYvdiO3QEe8hPWmRRYwC25WTjgxAUVSGzbG+cb2gs/BlGugiIRFPxXXwShWZ3RSdDVu X-Received: by 2002:a17:902:16a4:: with SMTP id h33-v6mr17629394plh.3.1539024642550; Mon, 08 Oct 2018 11:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024642; cv=none; d=google.com; s=arc-20160816; b=fBxkxs3+I30l6uD5UbLs0HpnfcQ4+NIUYfuRkVGEB4snsv9AnbYvmQlKXpR1HCrWBJ WqN1C5rhgUJDrRTsviJA0nUFizOW16SN1reUrZjmy11ufXSYiOOweqIZcCHekZUuDmiQ 7GJnXy3s9kLKoVWBKfax8DsJEx/mLUfsdenqqdMqqm20ckfWRH9CMIl63DaJZKys7uPp pYmZgUa18KgpzOfIyqOW3zOfFndHxuxbEKpA0ZsS2q5wMWsr28JY1JULNfrbintsU23f hrselNsXNkFNf+XGlScgNM0X6ns5U+Tz89Nlpdz0pcLEnDrSZkPCHVmO8+wu78cCdkUs 0W1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GmuOniijQjRlV5QGD9fmG0dTNAs+LUoNW2vClzGEx+w=; b=fLHDzqjKMTxTD+9lskVLXHZ3QEUqAGMkM2949LLM60u2rfWEXkWVUHGQC7u5M4g1h+ 29TzQ7EBj5NWTt84Zg0Z6jm6mlG1QLsSwtOzzdFSh1XXYlM1GKtNbeENoEmeCVYhd6QU D1xyR+2B7uMsbMlWnOpcOgZ2l27kZMZhAYJOTppwWtIU7MmTG63VwP+4vyJ1XvHjoxIA c8A8iBtunRCMnDJ4p5Cdn4objd57tMmBOYOZlke/ogddnJIZxq1eJ+BynF21GUVW4g52 1MgWfx5fV3kbZ9mYaMysrvIW55DMVaIIcV9Pg5VdvTHbUpHeQebbliW0QhAzKdm3ToSB 1qpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYTcYb7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11-v6si17089354pgf.587.2018.10.08.11.50.27; Mon, 08 Oct 2018 11:50:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYTcYb7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732046AbeJICDW (ORCPT + 99 others); Mon, 8 Oct 2018 22:03:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726391AbeJICDV (ORCPT ); Mon, 8 Oct 2018 22:03:21 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB35E20645; Mon, 8 Oct 2018 18:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024614; bh=d/ZDRNOj/icCD3qPdOlVQM1xUNNsjlk/BdwdVwPf6kE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYTcYb7SJM+CBgvNukqzxCCKilDE64gU9zqOpBI+JcZrVnGJse9vRQlHGmkDUypDz N5nHwycbeq5t7VIX1vdG/E8EKCGaQ/KnWXHz2ZVvU+0sMIlzy2JG4ahoLiwttO4xcY jSeBcTu0jOEEKIUoZmJoqGoa7qVv40zdDkXYGkOM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.18 097/168] iio: imu: st_lsm6dsx: take into account ts samples in wm configuration Date: Mon, 8 Oct 2018 20:31:17 +0200 Message-Id: <20181008175623.750764084@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lorenzo Bianconi [ Upstream commit a13bf65f3f2e36008ea60b49d3bda2527e09fd9c ] Take into account hw timer samples in pattern length computation done in st_lsm6dsx_update_watermark routine for watermark configuration. Moreover use samples in pattern (sip) already computed in st_lsm6dsx_update_decimators routine Fixes: 213451076bd3 ("iio: imu: st_lsm6dsx: add hw timestamp support") Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -187,12 +187,15 @@ static int st_lsm6dsx_set_fifo_odr(struc int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) { - u16 fifo_watermark = ~0, cur_watermark, sip = 0, fifo_th_mask; + u16 fifo_watermark = ~0, cur_watermark, fifo_th_mask; struct st_lsm6dsx_hw *hw = sensor->hw; struct st_lsm6dsx_sensor *cur_sensor; int i, err, data; __le16 wdata; + if (!hw->sip) + return 0; + for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { cur_sensor = iio_priv(hw->iio_devs[i]); @@ -203,14 +206,10 @@ int st_lsm6dsx_update_watermark(struct s : cur_sensor->watermark; fifo_watermark = min_t(u16, fifo_watermark, cur_watermark); - sip += cur_sensor->sip; } - if (!sip) - return 0; - - fifo_watermark = max_t(u16, fifo_watermark, sip); - fifo_watermark = (fifo_watermark / sip) * sip; + fifo_watermark = max_t(u16, fifo_watermark, hw->sip); + fifo_watermark = (fifo_watermark / hw->sip) * hw->sip; fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl; err = regmap_read(hw->regmap, hw->settings->fifo_ops.fifo_th.addr + 1,