From patchwork Wed Sep 27 19:29:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 9974603 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 5E35C60375 for ; Wed, 27 Sep 2017 19:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EBC9292E5 for ; Wed, 27 Sep 2017 19:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 439F5292EA; Wed, 27 Sep 2017 19:29:36 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 E6E8C292E5 for ; Wed, 27 Sep 2017 19:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750805AbdI0T3f (ORCPT ); Wed, 27 Sep 2017 15:29:35 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37916 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbdI0T3e (ORCPT ); Wed, 27 Sep 2017 15:29:34 -0400 Received: by mail-wr0-f195.google.com with SMTP id p37so6182201wrb.5 for ; Wed, 27 Sep 2017 12:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mBOK2DT3DqsmM/vF7KEpAZfiguRPCXSluHohaiWCURk=; b=DI3AynsT9H/3MCLZHrqOdk+ubNQkXUG6YAEexuimKLeLZanMSnzRcU2yK1IK9cDwiZ E4aKxcYwB32GOVDp65rdi9G+Fav9bsoIYd7CIj2zFWK59DJzTiADe5Iwi9ngKQTpyJuh xWo//wniAKtV22Z/8sJeBCvLYyi9aGVylCfZHFHjHRkIl+ctiVclet5DC5sXuO+qg14a wkyMcl/U5ebr8z2gALCW84xbBOAPih0BcWv2sUtWX1U91FmPxENMjAfQYghYwpCD0ysQ bcvLsYY9uyqTAlXK/R1LOEhrzuWbR6Qhq7b7DauoPfUz1VfLXhVUfN3m4gpk9APadfSB 9XKw== 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=mBOK2DT3DqsmM/vF7KEpAZfiguRPCXSluHohaiWCURk=; b=DGnkbZvDVGyHe9924f/O/DtJDIfpjxsEhgdxF9V03WYU0unsxo7zewma7tph+cxS1K /HdA4kq1PZDMBA8qakV33sS9Hk4MjArediesAaJ3QkvqtliJN+e+I0CQg7mvPJ+tyZAA Sapr9jjxbKvrLFt/u8SPqTQhPbcVAqbhhDouu/9uro7A04JAVPwX/RY2AFZ9BliAmrGq yNcdih+1Z0amLo6eo5GXvUQqwk/LtuMu8ySkivAmtqH4MuyUAQ31PcPp6hV6smv3Hj3K hbD7iR6W8mzm9Bw/7E1G/Xiox4D7GfRs4hx77YfhJPrhQxd1tBNmG/eSk7iMuqTfBCfS vJkQ== X-Gm-Message-State: AHPjjUjR9nTkZDgyh2J8J6SiIswvwSgODJ5p8xirYSx+nS7256rFxl4G kR8y18Ihpec5Mnue6Uy9ymM= X-Google-Smtp-Source: AOwi7QDnkzMmGB0ArtT1+PU6V41vB2PxcLcZcUTCdsS3rZxVDkpupNMqyuKealpJMwFME2jGhFywWA== X-Received: by 10.223.164.22 with SMTP id d22mr2615988wra.7.1506540573559; Wed, 27 Sep 2017 12:29:33 -0700 (PDT) Received: from localhost.localdomain ([151.66.56.134]) by smtp.gmail.com with ESMTPSA id k52sm20702238wrf.62.2017.09.27.12.29.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 12:29:32 -0700 (PDT) From: Lorenzo Bianconi X-Google-Original-From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, lorenzo.bianconi@st.com Subject: [PATCH 2/4] iio: imu: st_lsm6dsx: split fifo mode and fifo odr configuration Date: Wed, 27 Sep 2017 21:29:26 +0200 Message-Id: <20170927192928.16160-3-lorenzo.bianconi@st.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170927192928.16160-1-lorenzo.bianconi@st.com> References: <20170927192928.16160-1-lorenzo.bianconi@st.com> 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 Separate fifo mode and max fifo sample rate configuration. That change will be necessary to reuse st_lsm6dsx_set_fifo_mode() routine and to support more devices in st_lsm6dsx driver Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index e2737dc71b67..26fb970aed15 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -139,23 +139,10 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw) int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, enum st_lsm6dsx_fifo_mode fifo_mode) { - u8 data; int err; - switch (fifo_mode) { - case ST_LSM6DSX_FIFO_BYPASS: - data = fifo_mode; - break; - case ST_LSM6DSX_FIFO_CONT: - data = (ST_LSM6DSX_MAX_FIFO_ODR_VAL << - __ffs(ST_LSM6DSX_FIFO_ODR_MASK)) | fifo_mode; - break; - default: - return -EINVAL; - } - - err = hw->tf->write(hw->dev, ST_LSM6DSX_REG_FIFO_MODE_ADDR, - sizeof(data), &data); + err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_FIFO_MODE_ADDR, + ST_LSM6DSX_FIFO_MODE_MASK, fifo_mode); if (err < 0) return err; @@ -164,6 +151,17 @@ int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, return 0; } +static int st_lsm6dsx_set_fifo_odr(struct st_lsm6dsx_sensor *sensor, + bool enable) +{ + struct st_lsm6dsx_hw *hw = sensor->hw; + u8 data; + + data = hw->enable_mask ? ST_LSM6DSX_MAX_FIFO_ODR_VAL : 0; + return st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_FIFO_MODE_ADDR, + ST_LSM6DSX_FIFO_ODR_MASK, data); +} + int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) { u16 fifo_watermark = ~0, cur_watermark, sip = 0; @@ -345,6 +343,10 @@ static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable) return err; } + err = st_lsm6dsx_set_fifo_odr(sensor, enable); + if (err < 0) + return err; + err = st_lsm6dsx_update_decimators(hw); if (err < 0) return err;