* [PATCH 3/5] iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block()
@ 2018-08-30 20:52 Lorenzo Bianconi
2018-09-02 20:29 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2018-08-30 20:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, devicetree
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 <lorenzo.bianconi@redhat.com>
---
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",
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/5] iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block()
2018-08-30 20:52 [PATCH 3/5] iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block() Lorenzo Bianconi
@ 2018-09-02 20:29 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-09-02 20:29 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio, devicetree
On Thu, 30 Aug 2018 22:52:57 +0200
Lorenzo Bianconi <lorenzo.bianconi@redhat.com> wrote:
> 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 <lorenzo.bianconi@redhat.com>
Applied. Thanks
> ---
> 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",
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-03 0:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-30 20:52 [PATCH 3/5] iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block() Lorenzo Bianconi
2018-09-02 20:29 ` Jonathan Cameron
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).