linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Robertson <dan@dlrobertson.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	devicetree <devicetree@vger.kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH v4 2/2] iio: (bma400) add driver for the BMA400
Date: Mon, 18 Nov 2019 00:25:04 +0000	[thread overview]
Message-ID: <20191118002504.GA29469@nessie> (raw)
In-Reply-To: <20191021162016.531e6a2e@archlinux>

Sorry for the incredibly late reply. Before I submit the next patchset version,
I have a question from the last set of reviews.

On Mon, Oct 21, 2019 at 04:20:16PM +0100, Jonathan Cameron wrote:
> On Sat, 19 Oct 2019 02:43:51 +0000
> Dan Robertson <dan@dlrobertson.com> wrote:
> > On Fri, Oct 18, 2019 at 10:23:38AM +0300, Andy Shevchenko wrote:
> > > On Fri, Oct 18, 2019 at 6:44 AM Dan Robertson <dan@dlrobertson.com> wrote:  
> > > > +static const int bma400_osr_table[] = { 0, 1, 3 };  
> > >   
> > > > +/* See the ACC_CONFIG1 section of the datasheet */
> > > > +static const int bma400_sample_freqs[] = {
> > > > +       12,  500000,
> > > > +       25,  0,
> > > > +       50,  0,
> > > > +       100, 0,
> > > > +       200, 0,
> > > > +       400, 0,
> > > > +       800, 0,
> > > > +};  
> > > 
> > > This can be replaced by a formula(s).  
> > 
> > Yeah I think I can implement the get, set, and read functions for sample_freq
> > with a formula, but the scale and sample frequency tables are needed by the
> > implementation of read_avail. A implementation of read_avail with a range and
> > a step would be ideal, but I couldn't find any documentation on implementing
> > read_avail where the step value of the range is a multiple. Please correct
> > me if I've missed something.
> 
> Indeed. We've only defined it as being fixed intervals.
> I'm not keen to expand the options for the userspace interface any
> further.  
> 
> You could compute the values at startup and store it in your state structure
> I think (or compute them on demand, but you'd need to have the space somewhere
> non volatile).
> 

I ended up writing an implementation that uses a formula for the get/set
functions of the sample frequency and scale, but uses a table for the
implementation of the read_avail function. While it does work, I worry
that this makes the driver less maintainable and would make it harder to
add support for a new hypothetical future BMA4xx device. Also, the majority
of drivers seem to use a table for the raw value to user input conversion,
so a move from this might make the code less "familiar".

If we do stick with the translation table, would it be better to have two
tables (a translation table and a read_avail table) so that we do not have
a step distance of two? This would mean we would need to maintain two
tables, but would simplify the code.

Random workflow question:

The sampling ratio, frequency, etc code seems to be the most complicated part
of the driver. Is it typically recommended to upstream a more minimal driver
that might assume the defaults?

Cheers,

 - Dan


  reply	other threads:[~2019-11-18  0:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18  3:18 [PATCH v3 0/2] iio: add driver for Bosch BMA400 accelerometer Dan Robertson
2019-10-18  3:18 ` [PATCH v4 1/2] dt-bindings: iio: accel: bma400: add bindings Dan Robertson
2019-10-25 16:35   ` Rob Herring
2019-10-18  3:18 ` [PATCH v4 2/2] iio: (bma400) add driver for the BMA400 Dan Robertson
2019-10-18  4:25   ` Randy Dunlap
2019-10-19  1:35     ` Dan Robertson
2019-10-18  7:23   ` Andy Shevchenko
2019-10-19  2:43     ` Dan Robertson
2019-10-21 15:20       ` Jonathan Cameron
2019-11-18  0:25         ` Dan Robertson [this message]
2019-11-23 12:51           ` Jonathan Cameron
2019-11-24 22:37             ` Dan Robertson
2019-10-19  4:25   ` Joe Perches

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=20191118002504.GA29469@nessie \
    --to=dan@dlrobertson.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pmeerw@pmeerw.net \
    --cc=rdunlap@infradead.org \
    --cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).