All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>, <jic23@kernel.org>,
	<linux-iio@vger.kernel.org>, <knaack.h@gmx.de>, <lars@metafoo.de>,
	<pmeerw@pmeerw.net>
Subject: Re: [PATCH v3] iio: accel: Add support for the Bosch-Sensortec BMI088
Date: Mon, 23 Mar 2020 16:40:21 +0000	[thread overview]
Message-ID: <20200323164021.0000601f@Huawei.com> (raw)
In-Reply-To: <20200323104543.GH1922688@smile.fi.intel.com>

On Mon, 23 Mar 2020 12:45:43 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Mar 23, 2020 at 10:21:07AM +0100, Mike Looijmans wrote:
> > On 22-03-2020 01:16, Andy Shevchenko wrote:  
> > > On Thu, Mar 19, 2020 at 04:48:42PM +0100, Mike Looijmans wrote:  
> 
> ...
> 
> > > > +static int bmi088_accel_get_temp(struct bmi088_accel_data *data, int *val)
> > > > +{
> > > > +	int ret;
> > > > +	__s16 temp;
> > > > +
> > > > +	mutex_lock(&data->mutex);  
> > >   
> > > > +	ret = regmap_bulk_read(data->regmap, BMI088_ACCEL_REG_TEMP,
> > > > +			       &data->buffer, 2);  
> > > 
> > > sizeof() ?  
> > 
> > The buffer is a shared buffer, it will grow to accommodate reading all axis
> > and timestamp in a single read (9 bytes) and for FIFO reads in foreseeable
> > future.
> > 
> > I could use sizeof(temp) here though, but that wouldn't that be more
> > confusing?  
> 
> Yeah, perhaps comment explaining why 2 is being used there and why you write
> directly to the buffer (no temporary variable being involved)?

This is all about ensuring it's a dma safe buffer without having to explicit
kmallocs on eveyr read.  buffer is the temporary variable.

I would suggest using sizeof(__be16) which would make it clearer perhaps.

Jonathan


> 
> > > > +	temp = get_unaligned_be16(data->buffer);
> > > > +
> > > > +	mutex_unlock(&data->mutex);
> > > > +
> > > > +	if (ret < 0)
> > > > +		return ret;
> > > > +
> > > > +	*val = temp >> 5;
> > > > +
> > > > +	return IIO_VAL_INT;
> > > > +}  
> 



  reply	other threads:[~2020-03-23 16:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 14:04 [PATCH] iio: accel: Add support for the Bosch-Sensortec BMI088 Mike Looijmans
2020-03-15 12:02 ` Jonathan Cameron
2020-03-16  6:27   ` Mike Looijmans
2020-03-16 12:49     ` Jonathan Cameron
2020-03-16  7:32   ` [PATCH v2] " Mike Looijmans
2020-03-16 14:54     ` Lars-Peter Clausen
2020-03-17 13:58       ` Mike Looijmans
2020-03-19 15:48     ` [PATCH v3] " Mike Looijmans
2020-03-22  0:16       ` Andy Shevchenko
2020-03-23  9:21         ` Mike Looijmans
2020-03-23 10:45           ` Andy Shevchenko
2020-03-23 16:40             ` Jonathan Cameron [this message]
2020-03-22 17:47       ` Jonathan Cameron
2020-03-17 13:55   ` [PATCH] " Mike Looijmans

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=20200323164021.0000601f@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=mike.looijmans@topic.nl \
    --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 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.