mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Crestez Dan Leonard <leonard.crestez@intel.com>,
	linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Daniel Baluta <daniel.baluta@intel.com>,
	Ge Gao <GGao@invensense.com>
Subject: Re: [PATCH 2/7] iio: inv_mpu6050: Initial regcache support
Date: Sun, 1 May 2016 18:12:35 +0100	[thread overview]
Message-ID: <f693ed38-a214-554a-7bf1-40793475a5dd@kernel.org> (raw)
In-Reply-To: <f2950ebbb5468c8b7fbcfb8213ba9ebfd2133b8a.1461953982.git.leonard.crestez@intel.com>

On 29/04/16 20:02, Crestez Dan Leonard wrote:
> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Looks fine to me.

Jonathan
> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 47 ++++++++++++++++++++++++++++++
>  drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  5 ----
>  drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  1 +
>  drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  |  5 ----
>  4 files changed, 48 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index b269b37..5918c23 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -116,6 +116,53 @@ static const struct inv_mpu6050_hw hw_info[] = {
>  	},
>  };
>  
> +static bool inv_mpu6050_volatile_reg(struct device *dev, unsigned int reg)
> +{
> +	if (reg >= INV_MPU6050_REG_RAW_ACCEL && reg < INV_MPU6050_REG_RAW_ACCEL + 6)
> +		return true;
> +	if (reg >= INV_MPU6050_REG_RAW_GYRO && reg < INV_MPU6050_REG_RAW_GYRO + 6)
> +		return true;
> +	switch (reg) {
> +	case INV_MPU6050_REG_TEMPERATURE:
> +	case INV_MPU6050_REG_TEMPERATURE + 1:
> +	case INV_MPU6050_REG_USER_CTRL:
> +	case INV_MPU6050_REG_PWR_MGMT_1:
> +	case INV_MPU6050_REG_FIFO_COUNT_H:
> +	case INV_MPU6050_REG_FIFO_COUNT_H + 1:
> +	case INV_MPU6050_REG_FIFO_R_W:
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +static bool inv_mpu6050_precious_reg(struct device *dev, unsigned int reg)
> +{
> +	switch (reg) {
> +	case INV_MPU6050_REG_FIFO_R_W:
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +/*
> + * Common regmap config for inv_mpu devices
> + *
> + * The current volatile/precious registers are common among supported devices.
> + * When that changes the volatile/precious callbacks should go through the
> + * inv_mpu6050_reg_map structs.
> + */
> +const struct regmap_config inv_mpu_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +
> +	.cache_type = REGCACHE_RBTREE,
> +	.volatile_reg = inv_mpu6050_volatile_reg,
> +	.precious_reg = inv_mpu6050_precious_reg,
> +};
> +EXPORT_SYMBOL_GPL(inv_mpu_regmap_config);
> +
>  int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
>  {
>  	unsigned int d, mgmt_1;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index 1a424a6..1a8d1a5 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -20,11 +20,6 @@
>  #include <linux/module.h>
>  #include "inv_mpu_iio.h"
>  
> -static const struct regmap_config inv_mpu_regmap_config = {
> -	.reg_bits = 8,
> -	.val_bits = 8,
> -};
> -
>  /*
>   * The i2c read/write needs to happen in unlocked mode. As the parent
>   * adapter is common. If we use locked versions, it will fail as
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 47ca25b..297b0ef 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -291,3 +291,4 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
>  int inv_mpu_core_remove(struct device *dev);
>  int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
>  extern const struct dev_pm_ops inv_mpu_pmops;
> +extern const struct regmap_config inv_mpu_regmap_config;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> index 190a4a5..b3bd977 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -17,11 +17,6 @@
>  #include <linux/iio/iio.h>
>  #include "inv_mpu_iio.h"
>  
> -static const struct regmap_config inv_mpu_regmap_config = {
> -	.reg_bits = 8,
> -	.val_bits = 8,
> -};
> -
>  static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
>  {
>  	struct inv_mpu6050_state *st = iio_priv(indio_dev);
> 

  reply	other threads:[~2016-05-01 21:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 19:02 [RFC 0/7] iio: inv_mpu6050: Support i2c master and external readings Crestez Dan Leonard
2016-04-29 19:02 ` [PATCH 1/7] iio: inv_mpu6050: Do burst reads using spi/i2c directly Crestez Dan Leonard
2016-05-01 17:11   ` Jonathan Cameron
2016-05-02 15:24     ` Mark Brown
2016-04-29 19:02 ` [PATCH 2/7] iio: inv_mpu6050: Initial regcache support Crestez Dan Leonard
2016-05-01 17:12   ` Jonathan Cameron [this message]
2016-04-29 19:02 ` [PATCH 3/7] iio: inv_mpu6050: Only toggle DATA_RDY_EN in inv_reset_fifo Crestez Dan Leonard
2016-05-01 17:13   ` Jonathan Cameron
2016-04-29 19:02 ` [PATCH 4/7] iio: inv_mpu6050: Cache non-volatile bits of user_ctrl Crestez Dan Leonard
2016-05-01 17:14   ` Jonathan Cameron
2016-04-29 19:02 ` [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Crestez Dan Leonard
2016-05-01 17:27   ` Jonathan Cameron
2016-05-05 12:38     ` Crestez Dan Leonard
2016-05-05 13:10       ` Rob Herring
2016-05-02 15:31   ` Peter Rosin
2016-04-29 19:02 ` [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on preenable Crestez Dan Leonard
2016-05-01 17:34   ` Jonathan Cameron
2016-05-03 13:01     ` Crestez Dan Leonard
2016-05-04  9:01       ` Jonathan Cameron
2016-05-04 15:34         ` Crestez Dan Leonard
2016-05-04 18:22           ` Jonathan Cameron
2016-04-29 19:02 ` [RFC 7/7] iio: inv_mpu6050: Add support for external sensors Crestez Dan Leonard
2016-05-01 17:54   ` Jonathan Cameron
2016-05-01 17:04 ` [RFC 0/7] iio: inv_mpu6050: Support i2c master and external readings Jonathan Cameron
2016-05-02 15:23   ` Mark Brown
2016-05-03 11:21     ` Crestez Dan Leonard
2016-05-03 11:32       ` Mark Brown

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=f693ed38-a214-554a-7bf1-40793475a5dd@kernel.org \
    --to=jic23@kernel.org \
    --cc=GGao@invensense.com \
    --cc=daniel.baluta@intel.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=leonard.crestez@intel.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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

Powered by JetHome