From patchwork Fri Aug 31 08:51:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10583379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCDAE112B for ; Fri, 31 Aug 2018 08:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC66D2923F for ; Fri, 31 Aug 2018 08:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C07742996F; Fri, 31 Aug 2018 08:51:24 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 706572923F for ; Fri, 31 Aug 2018 08:51:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbeHaM5s (ORCPT ); Fri, 31 Aug 2018 08:57:48 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:41273 "EHLO mail-wr1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727286AbeHaM5s (ORCPT ); Fri, 31 Aug 2018 08:57:48 -0400 Received: by mail-wr1-f47.google.com with SMTP id z96-v6so10462117wrb.8 for ; Fri, 31 Aug 2018 01:51:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dwqe/vB36TlASTbpGkb/T3fE6R0t6vo8GF+ZjL7YL4w=; b=XW5lEFtaEZHPmyDuF2OxEfXWE9N5bmDss8F2Zk8ITPkmBs+XUS4u7R5y4xfFkPCtiS ERtWXHtz06tBb6MJ3FRfK4w4jZQCsOe+MdQszDztOpGWGhYkLpK9H7cXSl+/d/E/Igtg edsJM9ZH1x8RwExBc+aQMIxj6jPW1Ho56LyuRF2JtP0lsypbd6g43er9Z3wqhBEctXEd oi6ryPEAbwqwAIQP9ahXKJgEdQYhDen3V064U2fYMcQxq4uzVVrdEiL9p8Uw8mrQj6Gm qkwjEnuv4v698v8e9H4Mbn9PZYHYTnr6TsCVjhaMa6ukOcz9PVKHPhOaXn3gtYvYbx7a 5tFg== X-Gm-Message-State: APzg51BfqncESQzwO7EU0sRrhLN/L5RAGAedAO9XLD+ykxqkE4lzQBsN xZ6MDusYlWtlRyuztoFGPrRnpQ== X-Google-Smtp-Source: ANB0VdaHxpnEy1W8FR5CSFWrfM4mL5P6CSFFw4R4lAxEhH9sWl6cGjg96z6DzBEDmuM4hSTne1m1Sw== X-Received: by 2002:adf:be81:: with SMTP id i1-v6mr9424450wrh.235.1535705482146; Fri, 31 Aug 2018 01:51:22 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 72-v6sm13010583wrb.48.2018.08.31.01.51.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 01:51:21 -0700 (PDT) From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org Subject: [PATCH v2] iio: imu: st_lsm6dsx: take into account ts samples in wm configuration Date: Fri, 31 Aug 2018 10:51:14 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changes since v1: - use samples in pattern already computed in st_lsm6dsx_update_decimators --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 7589f2ad1dae..631360b14ca7 100644 --- 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(struct st_lsm6dsx_sensor *sensor, 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 st_lsm6dsx_sensor *sensor, u16 watermark) : 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,