From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexandru Ardelean <alexandru.ardelean@analog.com>,
Michael Hennerich <Michael.Hennerich@analog.com>
Subject: [PATCH v2 4/6] iio: adis: Add burst_max_len variable
Date: Mon, 16 Mar 2020 13:53:10 +0100 [thread overview]
Message-ID: <20200316125312.39178-5-nuno.sa@analog.com> (raw)
In-Reply-To: <20200316125312.39178-1-nuno.sa@analog.com>
Add burst_max_len to `adis_burst`. This is useful for devices which
support different burst modes with different sizes. The buffer to be
used in the spi transfer is allocated with this variable making sure
that has space for all burst modes. The spi transfer length should hold
the "real" burst length depending on the current burst mode configured
in the device.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/imu/adis_buffer.c | 11 ++++++++---
include/linux/iio/imu/adis.h | 3 +++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index 7871b468e9e9..ddf4bdca7e72 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -23,25 +23,30 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
{
struct adis *adis = iio_device_get_drvdata(indio_dev);
- unsigned int burst_length;
+ unsigned int burst_length, burst_max_length;
u8 *tx;
/* All but the timestamp channel */
burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
burst_length += adis->burst->extra_len;
+ if (adis->burst->burst_max_len)
+ burst_max_length = adis->burst->burst_max_len;
+ else
+ burst_max_length = burst_length;
+
adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
if (!adis->xfer)
return -ENOMEM;
- adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
+ adis->buffer = kzalloc(burst_max_length + sizeof(u16), GFP_KERNEL);
if (!adis->buffer) {
kfree(adis->xfer);
adis->xfer = NULL;
return -ENOMEM;
}
- tx = adis->buffer + burst_length;
+ tx = adis->buffer + burst_max_length;
tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);
tx[1] = 0;
diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
index 94031b3fc9d5..5bdd6f457e78 100644
--- a/include/linux/iio/imu/adis.h
+++ b/include/linux/iio/imu/adis.h
@@ -502,11 +502,14 @@ int adis_single_conversion(struct iio_dev *indio_dev,
* @en burst mode enabled
* @reg_cmd register command that triggers burst
* @extra_len extra length to account in the SPI RX buffer
+ * @burst_max_len holds the maximum burst size when the device supports
+ * more than one burst mode with different sizes
*/
struct adis_burst {
bool en;
unsigned int reg_cmd;
unsigned int extra_len;
+ const u32 burst_max_len;
};
int
--
2.25.1
next prev parent reply other threads:[~2020-03-16 12:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-16 12:53 [PATCH v2 0/6] Support ADIS16475 and similar IMUs Nuno Sá
2020-03-16 12:53 ` [PATCH v2 1/6] iio: imu: adis: Add Managed device functions Nuno Sá
2020-03-16 14:27 ` Lars-Peter Clausen
2020-03-16 12:53 ` [PATCH v2 2/6] iio: imu: adis: Add irq mask variable Nuno Sá
2020-03-16 13:31 ` Lars-Peter Clausen
2020-03-16 12:53 ` [PATCH v2 3/6] iio: adis: Add adis_update_bits() APIs Nuno Sá
2020-03-22 18:15 ` Jonathan Cameron
2020-03-16 12:53 ` Nuno Sá [this message]
2020-03-16 12:53 ` [PATCH v2 5/6] iio: imu: Add support for adis16475 Nuno Sá
2020-03-16 14:26 ` Lars-Peter Clausen
2020-03-17 16:40 ` Sa, Nuno
2020-03-16 12:53 ` [PATCH v2 6/6] dt-bindings: iio: Add adis16475 documentation Nuno Sá
2020-03-22 18:23 ` Jonathan Cameron
2020-03-30 20:32 ` Rob Herring
2020-03-31 9:11 ` Sa, Nuno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200316125312.39178-5-nuno.sa@analog.com \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).