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>,
	Peter Rosin <peda@axentia.se>,
	Matt Ranostay <mranostay@gmail.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <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>,
	linux-i2c@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>
Subject: Re: [PATCH v2 2/7] iio: inv_mpu6050: Initial regcache support
Date: Sun, 29 May 2016 16:27:15 +0100	[thread overview]
Message-ID: <92d40b29-5c44-7307-0f25-93ee66c055ae@kernel.org> (raw)
In-Reply-To: <61c0fb3d-207a-c126-b80c-f1342fda5878@intel.com>

On 20/05/16 12:01, Crestez Dan Leonard wrote:
> On 05/20/2016 09:39 AM, Peter Rosin wrote:
>> On 2016-05-20 04:34, Matt Ranostay wrote:
>>> On Wed, May 18, 2016 at 8:00 AM, Crestez Dan Leonard
>>> <leonard.crestez@intel.com> wrote:
>>>> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
>>>> ---
>>>>  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;
>>>
>>> I think you want to put parenthesis around the addition operations...
>>
>> Maybe.
>>
>>> the condition check probably don't evaluate to what you are expecting.
>>
>> Looks sane to me since + has highest precedence, then < and >=, and && comes
>> in last...
>>
>> ...but even so, I think I would use an ellipsis in the switch statement
>> instead, like so:
>>
>> static bool inv_mpu6050_volatile_reg(struct device *dev, unsigned int reg)
>> {
>> 	switch (reg) {
>> 	case INV_MPU6050_REG_RAW_ACCEL ... INV_MPU6050_REG_RAW_ACCEL + 5:
>> 	case INV_MPU6050_REG_RAW_GYRO ... INV_MPU6050_REG_RAW_GYRO  + 5:
>> 	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;
>> 	}
>> }
> 
> Neat, I didn't know about this extension. It does look nicer in this
> function.
Be careful to use this sparingly as it does make review harder in some
cases as we have to care which registers happen to numerically fall in the
range.

It's good for some cases though such as multiple bytes of the same 'real
register'.

Jonathan
> 

  reply	other threads:[~2016-05-29 15:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 15:00 [PATCH v2 0/7] iio: inv_mpu6050: Support i2c master and external readings Crestez Dan Leonard
2016-05-18 15:00 ` [PATCH v2 1/7] iio: inv_mpu6050: Do burst reads using spi/i2c directly Crestez Dan Leonard
2016-05-29 16:05   ` Jonathan Cameron
2016-05-18 15:00 ` [PATCH v2 2/7] iio: inv_mpu6050: Initial regcache support Crestez Dan Leonard
2016-05-20  2:34   ` Matt Ranostay
2016-05-20  6:39     ` Peter Rosin
2016-05-20 11:01       ` Crestez Dan Leonard
2016-05-29 15:27         ` Jonathan Cameron [this message]
2016-05-18 15:00 ` [PATCH v2 3/7] iio: inv_mpu6050: Only toggle DATA_RDY_EN in inv_reset_fifo Crestez Dan Leonard
2016-05-29 15:29   ` Jonathan Cameron
2016-05-18 15:00 ` [PATCH v2 4/7] iio: inv_mpu6050: Cache non-volatile bits of user_ctrl Crestez Dan Leonard
2016-05-29 15:30   ` Jonathan Cameron
2016-05-18 15:00 ` [RFC v2 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Crestez Dan Leonard
2016-05-18 23:46   ` Rob Herring
2016-05-18 15:00 ` [PATCH v2 6/7] iio: inv_mpu6050: Reformat sample for active scan mask Crestez Dan Leonard
2016-05-29 15:47   ` Jonathan Cameron
2016-05-30 13:44     ` Crestez Dan Leonard
2016-05-30 21:42       ` Jonathan Cameron
2016-05-31  8:56         ` Crestez Dan Leonard
2016-05-31 16:33           ` Jonathan Cameron
2016-05-18 15:00 ` [RFC v2 7/7] iio: inv_mpu6050: Expose channels from slave sensors Crestez Dan Leonard
2016-05-18 23:49   ` Rob Herring
2016-05-29 16:03   ` 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=92d40b29-5c44-7307-0f25-93ee66c055ae@kernel.org \
    --to=jic23@kernel.org \
    --cc=daniel.baluta@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ggao@invensense.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=leonard.crestez@intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mranostay@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=peda@axentia.se \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    --cc=wsa@the-dreams.de \
    /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