From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux
Date: Sat, 21 Apr 2018 16:05:00 +0100 [thread overview]
Message-ID: <20180421160500.65e9c115@archlinux> (raw)
In-Reply-To: <1523949580-18016-2-git-send-email-jmaneyrol@invensense.com>
On Tue, 17 Apr 2018 09:19:40 +0200
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:
> Set power function is rewritten manually inside i2c mux select.
> Better use the already identical existing function.
>
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to paly with it.
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 33 ++++++++++++-------------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index f70e7b9..eca34b9 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -29,25 +29,19 @@ static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
> {
> struct iio_dev *indio_dev = i2c_mux_priv(muxc);
> struct inv_mpu6050_state *st = iio_priv(indio_dev);
> - int ret = 0;
> + int ret;
>
> - /* Use the same mutex which was used everywhere to protect power-op */
> mutex_lock(&st->lock);
> - if (!st->powerup_count) {
> - ret = regmap_write(st->map, st->reg->pwr_mgmt_1, 0);
> - if (ret)
> - goto write_error;
>
> - usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
> - INV_MPU6050_REG_UP_TIME_MAX);
> - }
> - if (!ret) {
> - st->powerup_count++;
> - ret = regmap_write(st->map, st->reg->int_pin_cfg,
> - INV_MPU6050_INT_PIN_CFG |
> - INV_MPU6050_BIT_BYPASS_EN);
> - }
> -write_error:
> + ret = inv_mpu6050_set_power_itg(st, true);
> + if (ret)
> + goto error_unlock;
> +
> + ret = regmap_write(st->map, st->reg->int_pin_cfg,
> + INV_MPU6050_INT_PIN_CFG |
> + INV_MPU6050_BIT_BYPASS_EN);
> +
> +error_unlock:
> mutex_unlock(&st->lock);
>
> return ret;
> @@ -59,12 +53,11 @@ static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id)
> struct inv_mpu6050_state *st = iio_priv(indio_dev);
>
> mutex_lock(&st->lock);
> +
> /* It doesn't really mattter, if any of the calls fails */
> regmap_write(st->map, st->reg->int_pin_cfg, INV_MPU6050_INT_PIN_CFG);
> - st->powerup_count--;
> - if (!st->powerup_count)
> - regmap_write(st->map, st->reg->pwr_mgmt_1,
> - INV_MPU6050_BIT_SLEEP);
> + inv_mpu6050_set_power_itg(st, false);
> +
> mutex_unlock(&st->lock);
>
> return 0;
next prev parent reply other threads:[~2018-04-21 15:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 7:19 [PATCH v4 1/2] iio: imu: inv_mpu6050: clean set_power_itg and fix usage Jean-Baptiste Maneyrol
2018-04-17 7:19 ` [PATCH v4 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux Jean-Baptiste Maneyrol
2018-04-21 15:05 ` Jonathan Cameron [this message]
2018-04-21 15:03 ` [PATCH v4 1/2] iio: imu: inv_mpu6050: clean set_power_itg and fix usage Jonathan Cameron
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=20180421160500.65e9c115@archlinux \
--to=jic23@jic23.retrosnub.co.uk \
--cc=jmaneyrol@invensense.com \
--cc=linux-iio@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.