From patchwork Thu Aug 30 20:52:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10582795 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 73665920 for ; Thu, 30 Aug 2018 20:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6265028704 for ; Thu, 30 Aug 2018 20:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 567C22C3F9; Thu, 30 Aug 2018 20:53:27 +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 03D5628704 for ; Thu, 30 Aug 2018 20:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbeHaA51 (ORCPT ); Thu, 30 Aug 2018 20:57:27 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41579 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbeHaA50 (ORCPT ); Thu, 30 Aug 2018 20:57:26 -0400 Received: by mail-wr1-f67.google.com with SMTP id z96-v6so9266739wrb.8 for ; Thu, 30 Aug 2018 13:53:25 -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; bh=lrR2TfowBl81qU/t72HmdKB9HIfQ/BXATTClANu7CG0=; b=OdZqm7VX3QQjXqscRCWHYvSGyOe9LJSUHOTPKk38METt9Ce3uxa0DaqXvZ9yxt6RH4 wNekrtj7G0e5qWKisCnEvucaUkcb3lJHDDNSa5OGLdEWihapub++NBLQC6FGStJdFz8i HLS72Lvg7zMjDF/IPXhapABhZOQmOaPdjcnB9ehjZRXNspzpYmCW+NbtrU5JnFGXiel1 2uq/ZQcggytlpK5UbHUmn1ZJ87laQVpGfU5H0QGrCugwmgdnsZhFMdekLoAzrAkwva4B EGCGcatAfVWkGZr53yry6W0yhGV/mKqYmvwJfNB9t0eEkcBiyOHUbTA9o/TEgRySe16j 818g== X-Gm-Message-State: APzg51DtI3+cKVlcT84utAyRFyFHG8jvSj/tqGTHcTKZ8DcIzRL+8wpq 783KxtPdOPqIXoerNAFBkN9NCQ== X-Google-Smtp-Source: ANB0VdYIjZ9dyEdkkTIQ9R0mc/3oJEKlhtIqWyEZVITckw+/Zwf4asu7ahqzTNaW+u0RlxQup4h6MQ== X-Received: by 2002:adf:be81:: with SMTP id i1-v6mr8155400wrh.235.1535662404832; Thu, 30 Aug 2018 13:53:24 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id k35-v6sm13178125wrc.14.2018.08.30.13.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 13:53:24 -0700 (PDT) From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/5] iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block() Date: Thu, 30 Aug 2018 22:52:57 +0200 Message-Id: <20180830205259.7029-4-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Add reg addr and max_word_len parameters to st_lsm6dsx_read_block since LSM6DSO will use a different register address to read samples from the FIFO and a different sample len Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 16 +++++++++------- 1 file changed, 9 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 7e02935a4250..2002ba4a1abd 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -255,18 +255,18 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw) * Set max bulk read to ST_LSM6DSX_MAX_WORD_LEN in order to avoid * a kmalloc for each bus access */ -static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 *data, - unsigned int data_len) +static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 addr, + u8 *data, unsigned int data_len, + unsigned int max_word_len) { unsigned int word_len, read_len = 0; int err; while (read_len < data_len) { word_len = min_t(unsigned int, data_len - read_len, - ST_LSM6DSX_MAX_WORD_LEN); - err = regmap_bulk_read(hw->regmap, - ST_LSM6DSX_REG_FIFO_OUTL_ADDR, - data + read_len, word_len); + max_word_len); + err = regmap_bulk_read(hw->regmap, addr, data + read_len, + word_len); if (err < 0) return err; read_len += word_len; @@ -316,7 +316,9 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) gyro_sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_GYRO]); for (read_len = 0; read_len < fifo_len; read_len += pattern_len) { - err = st_lsm6dsx_read_block(hw, hw->buff, pattern_len); + err = st_lsm6dsx_read_block(hw, ST_LSM6DSX_REG_FIFO_OUTL_ADDR, + hw->buff, pattern_len, + ST_LSM6DSX_MAX_WORD_LEN); if (err < 0) { dev_err(hw->dev, "failed to read pattern from fifo (err=%d)\n",