public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: Richard Tresidder <rtresidd@electromag.com.au>,
	linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	harinath922@gmail.com
Subject: Re: [PATCH v3] iio: accell: mma8452: Reduce sleep time when data not ready
Date: Wed, 9 May 2018 11:57:49 +0200	[thread overview]
Message-ID: <7dc844c6-8666-c381-e6fe-d70dfebf2eeb@posteo.de> (raw)
In-Reply-To: <cd307679-19c5-1132-79dc-b28c96cc537e@electromag.com.au>

[-- Attachment #1: Type: text/plain, Size: 2665 bytes --]

On 2018-05-08 10:19, Richard Tresidder wrote:
> Modified the sleep method when data is not ready to allow for sampling > 50sps to work.
> 
> Signed-off-by: Richard Tresidder <rtresidd@electromag.com.au>
> ---
> v3: Changes from v2
>   * Removed fallthrough fix (will submit separately)
>   * Fixed some blank lines, trailing white spaces.
> 
> v2: Changes from v1
>   * Remove whitespace changes
>   * Added fallthrough fix (subsequently removed)
> 
> drivers/iio/accel/mma8452.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 7a2da7f..5650b59 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -106,6 +106,7 @@ struct mma8452_data {
>  	u8 ctrl_reg1;
>  	u8 data_cfg;
>  	const struct mma_chip_info *chip_info;
> +	int sleep_val;
>  };
>  
>   /**
> @@ -193,7 +194,10 @@ static int mma8452_drdy(struct mma8452_data *data)
>  		if ((ret & MMA8452_STATUS_DRDY) == MMA8452_STATUS_DRDY)
>  			return 0;
>  
> -		msleep(20);
> +		if (data->sleep_val <= 20)
> +			usleep_range(data->sleep_val * 250, data->sleep_val * 500);

line over 80 chars. please use 2 lines.

Also, have you run checkpatch on this? You seem to have DOS line-endlings.

> +		else
> +			msleep(20);
>  	}
>  
>  	dev_err(&data->client->dev, "data not ready\n");
> @@ -544,6 +548,18 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
>  	return -EINVAL;
>  }
>  
> +static int mma8452_calculate_sleep(struct mma8452_data *data)
> +{
> +	int ret, i = mma8452_get_odr_index(data);
> +
> +	if (mma8452_samp_freq[i][0] > 0)
> +		ret = 1000 / mma8452_samp_freq[i][0];
> +	else
> +		ret = 1000;
> +
> +	return ret == 0 ? 1 : ret;
> +}
> +
>  static int mma8452_standby(struct mma8452_data *data)
>  {
>  	return i2c_smbus_write_byte_data(data->client, MMA8452_CTRL_REG1,
> @@ -700,6 +716,8 @@ static int mma8452_write_raw(struct iio_dev *indio_dev,
>  		data->ctrl_reg1 &= ~MMA8452_CTRL_DR_MASK;
>  		data->ctrl_reg1 |= i << MMA8452_CTRL_DR_SHIFT;
>  
> +		data->sleep_val = mma8452_calculate_sleep(data);
> +
>  		ret = mma8452_change_config(data, MMA8452_CTRL_REG1,
>  					    data->ctrl_reg1);
>  		break;
> @@ -1593,6 +1611,9 @@ static int mma8452_probe(struct i2c_client *client,
>  
>  	data->ctrl_reg1 = MMA8452_CTRL_ACTIVE |
>  			  (MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT);
> +
> +	data->sleep_val = mma8452_calculate_sleep(data);
> +
>  	ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1,
>  					data->ctrl_reg1);
>  	if (ret < 0)
> 


[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1795 bytes --]

  reply	other threads:[~2018-05-09  9:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07  3:51 [PATCH v2] iio: accell: mma8452: Reduce sleep time when data not ready Richard Tresidder
2018-05-07  4:13 ` Richard Tresidder
2018-05-07  7:49   ` Martin Kepplinger
2018-05-07  7:59     ` Richard Tresidder
2018-05-07  8:11       ` Martin Kepplinger
2018-05-08  8:19         ` [PATCH v3] " Richard Tresidder
2018-05-09  9:57           ` Martin Kepplinger [this message]
2018-05-10  2:21             ` Richard Tresidder

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=7dc844c6-8666-c381-e6fe-d70dfebf2eeb@posteo.de \
    --to=martink@posteo.de \
    --cc=harinath922@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=rtresidd@electromag.com.au \
    /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