From patchwork Thu Aug 30 20:52:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10582791 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 8ED6C920 for ; Thu, 30 Aug 2018 20:53:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3FF328685 for ; Thu, 30 Aug 2018 20:53:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8237286BF; Thu, 30 Aug 2018 20:53:21 +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 76B9328685 for ; Thu, 30 Aug 2018 20:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726732AbeHaA5V (ORCPT ); Thu, 30 Aug 2018 20:57:21 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35958 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeHaA5V (ORCPT ); Thu, 30 Aug 2018 20:57:21 -0400 Received: by mail-wr1-f65.google.com with SMTP id m27-v6so9280571wrf.3 for ; Thu, 30 Aug 2018 13:53:19 -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=yrlnKlfQpLqzsnP8BZXnqUOkajsW0VMMa6KDfLDLPes=; b=uVml2KwSJXzKMBbjw0kfX8t7wCm2ZgpFnd9Std3EoA4tL2Fj8P4wKyMFtpZUhqU0oH lvhqgUlFrWkaZ5+UftO4zLLajeCg91ni8roYyvYjY4T/1AITXQcHobL03xgZyAkXhdV4 TdRd/CbZMn038fqoPj1HrOhVKBncT3ky7pbNob4zYut/FE/eWRSRrz4wYUD7XLhQbmWS /o0NdRiSTWvCKobMhaPTJCZocXRwr5IYW4kVVQNXAAxPbdUECDJwiy8ubTD/XJi8tLo5 iLqI3jUPNACknTUoq62QWejzDNHeK4JpdvZBnpr1ll2NcN9NHJ3UnpLBZqFim1ZPfJie ZCOg== X-Gm-Message-State: APzg51DrTocTD3fRthhPOHF8Hp2HoSNEbw8bAQuMijHKhvxhtBZl9J9n HdTAEeC1tvQCsJZCrKX69siRQg== X-Google-Smtp-Source: ANB0VdZl5ahaRauicy+Z0kXpLTExrwGKVOrJsA68jdTV/Juujl5WMCfmlEEf7Po1y7tS0ZipAtF50w== X-Received: by 2002:adf:ef89:: with SMTP id d9-v6mr8805148wro.195.1535662399019; Thu, 30 Aug 2018 13:53:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 13:53:18 -0700 (PDT) From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/5] iio: imu: st_lsm6dsx: add read_fifo callback to fifo_ops Date: Thu, 30 Aug 2018 22:52:55 +0200 Message-Id: <20180830205259.7029-2-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 Remove static qualifier from st_lsm6dsx_read_fifo definition and introduce read_fifo function pointer in fifo_ops data structure in order to run the proper read_fifo routine since other compliant devices will use a different FIFO queueing scheme. Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 5 +++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 +++--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index edcd838037cd..a0a6c07aad62 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -41,13 +41,17 @@ struct st_lsm6dsx_reg { u8 mask; }; +struct st_lsm6dsx_hw; + /** * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings + * @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 (*read_fifo)(struct st_lsm6dsx_hw *hw); struct { u8 addr; u16 mask; @@ -175,5 +179,6 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, 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); +int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw); #endif /* ST_LSM6DSX_H */ diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 2b49d928f4c0..7e02935a4250 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -284,7 +284,7 @@ static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 *data, * * Return: Number of bytes read from the FIFO */ -static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) +int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) { u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE; u16 fifo_diff_mask = hw->settings->fifo_ops.fifo_diff.mask; @@ -408,7 +408,7 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) mutex_lock(&hw->fifo_lock); - st_lsm6dsx_read_fifo(hw); + hw->settings->fifo_ops.read_fifo(hw); err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_BYPASS); mutex_unlock(&hw->fifo_lock); @@ -480,7 +480,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) int count; mutex_lock(&hw->fifo_lock); - count = st_lsm6dsx_read_fifo(hw); + count = hw->settings->fifo_ops.read_fifo(hw); mutex_unlock(&hw->fifo_lock); return !count ? IRQ_NONE : IRQ_HANDLED; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index aebbe0ddd8d8..394bcd3719e0 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -171,6 +171,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, .mask = GENMASK(11, 0), @@ -217,6 +218,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, .mask = GENMASK(11, 0), @@ -265,6 +267,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, .fifo_ops = { + .read_fifo = st_lsm6dsx_read_fifo, .fifo_th = { .addr = 0x06, .mask = GENMASK(10, 0),