Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp843222ybl; Wed, 21 Aug 2019 06:27:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJSsAlEmId0qEUkg+SD/O2TG1inivds/7EducdMyeB0UKKFdDQHHJFzmdPJQa/XTkwYPf0 X-Received: by 2002:a63:dd16:: with SMTP id t22mr29264790pgg.140.1566394029747; Wed, 21 Aug 2019 06:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566394029; cv=none; d=google.com; s=arc-20160816; b=S/K4k4oaCN160Esg4CF+WfaAwX6oNXm/Dl+2FbOhdjMJE9ljhLyS0HRi1cZ4YgXIVb akfSFNF5cxJks6gwgdEVMNUfWXZb0l10SEGr0Ao+NWaGX8rVhM4CI1BREtkq6ATf7MtW Xlno0l8A8AJik5ZDyhvEIVceWp5umZktSmVjVPuHrwWSBSI0HqYMgkoMgjm6H6hwn7Zx NKArNEjYrvbIrIofZjy6DlMQ59qlKgvJ1uBO4kbiVj+dRd+27xGyVyt9BgUSI5MlHqIn ZvzEs+gUE3/0xgGcJY/LffrUkXxeHBs3QXie/mfc8pevCeBi1G8D83qko16HaLuBNIpW jIDQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from; bh=5vfmq1Kb+1yUzeVygNYFTJixg8+eYBx/ezCgrHGdkno=; b=CYLpNR9IF33Uhj09BkevmpPApU018NG74Psabaa00piYSxwEdJf6KbjbI7NRazFKqp A7I5KvzS4g9uJ4TspDg5JNAaUCXObFPbPgUKdzvO/uM4x8w3oIiePtmy+XUBaZELJAAd n2ZSPqomZMqE3+FaDtWEiIlEsPjzVxvgmlnEauQzgT+q7pNQmothilwUVs3ywiZ5XVQA gYkIes4dFKxrCSnI/AugrDDUSZkrg2F95t51sb+jlEBJAfNCtUme3kgB6dPYTqCRkN5W kQAXtvEwXVl7WNaN2Pa39QgT6y25OEhv9CUOauNnQmIDwIG3AXXG9xSVmyhVTwj7y31w mbBQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u18si14557849plq.311.2019.08.21.06.26.54; Wed, 21 Aug 2019 06:27:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728850AbfHUNZ5 (ORCPT + 99 others); Wed, 21 Aug 2019 09:25:57 -0400 Received: from comms.puri.sm ([159.203.221.185]:44928 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728007AbfHUNZ4 (ORCPT ); Wed, 21 Aug 2019 09:25:56 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 0B82CDF905; Wed, 21 Aug 2019 06:25:55 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K3mBeymCY0YO; Wed, 21 Aug 2019 06:25:54 -0700 (PDT) From: Martin Kepplinger To: lorenzo.bianconi83@gmail.com, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: robh+dt@kernel.org, mark.rutland@arm.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Bianconi , Martin Kepplinger Subject: [PATCH v5 1/4] iio: imu: st_lsm6dsx: introduce update_fifo function pointer Date: Wed, 21 Aug 2019 15:25:17 +0200 Message-Id: <20190821132520.28225-2-martin.kepplinger@puri.sm> In-Reply-To: <20190821132520.28225-1-martin.kepplinger@puri.sm> References: <20190821132520.28225-1-martin.kepplinger@puri.sm> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi Introduce update_fifo routine pointer in st_lsm6dsx_fifo_ops data structure since we will need a different update FIFO configuration callback adding support for lsm6ds0/lsm9ds1 imu device Signed-off-by: Lorenzo Bianconi Tested-by: Martin Kepplinger --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 4 ++++ .../iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 19 +++++++++++++++---- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 ++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 4e8e67ae1632..055e52dec36a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -75,6 +75,7 @@ struct st_lsm6dsx_reg { u8 mask; }; +struct st_lsm6dsx_sensor; struct st_lsm6dsx_hw; struct st_lsm6dsx_odr { @@ -101,12 +102,14 @@ struct st_lsm6dsx_fs_table_entry { /** * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings + * @update_fifo: Update FIFO configuration callback. * @read_fifo: Read FIFO callback. * @fifo_th: FIFO threshold register info (addr + mask). * @fifo_diff: FIFO diff status register info (addr + mask). * @th_wl: FIFO threshold word length. */ struct st_lsm6dsx_fifo_ops { + int (*update_fifo)(struct st_lsm6dsx_sensor *sensor, bool enable); int (*read_fifo)(struct st_lsm6dsx_hw *hw); struct { u8 addr; @@ -327,6 +330,7 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val); int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark); +int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable); int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, enum st_lsm6dsx_fifo_mode fifo_mode); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 2c03a5b80f80..b0f3da1976e4 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -602,9 +602,8 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) return err; } -static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable) +int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable) { - struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; int err; @@ -676,12 +675,24 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) static int st_lsm6dsx_buffer_preenable(struct iio_dev *iio_dev) { - return st_lsm6dsx_update_fifo(iio_dev, true); + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); + struct st_lsm6dsx_hw *hw = sensor->hw; + + if (!hw->settings->fifo_ops.update_fifo) + return -ENOTSUPP; + + return hw->settings->fifo_ops.update_fifo(sensor, true); } static int st_lsm6dsx_buffer_postdisable(struct iio_dev *iio_dev) { - return st_lsm6dsx_update_fifo(iio_dev, false); + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); + struct st_lsm6dsx_hw *hw = sensor->hw; + + if (!hw->settings->fifo_ops.update_fifo) + return -ENOTSUPP; + + return hw->settings->fifo_ops.update_fifo(sensor, false); } static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = { diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 85824d6739ee..0aa93b45d772 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -154,6 +154,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, @@ -262,6 +263,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, @@ -379,6 +381,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, @@ -490,6 +493,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, .fifo_th = { .addr = 0x07, @@ -616,6 +620,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, .fifo_th = { .addr = 0x07, @@ -719,6 +724,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, .fifo_th = { .addr = 0x07, -- 2.20.1