[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE-0n50T9uqcB9EK-RnGXPGhd6RWdrsE9pA5FJY9yC58xd=05A@mail.gmail.com>
Date: Tue, 29 Mar 2022 22:25:31 +0200
From: Stephen Boyd <swboyd@...omium.org>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Lars-Peter Clausen <lars@...afoo.de>, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, Gwendal Grignou <gwendal@...omium.org>
Subject: Re: [PATCH v2] iio:proximity:sx9324: Fix hardware gain read/write
Quoting Jonathan Cameron (2022-03-27 07:51:47)
> On Thu, 24 Mar 2022 15:29:28 -0700
> Stephen Boyd <swboyd@...omium.org> wrote:
>
> > There are four possible gain values according to 'sx9324_gain_vals[]':
> >
> > 1, 2, 4, and 8
> >
> > The values are off by one when writing and reading the register. The
> > bits should be set according to this equation:
> >
> > ilog2(<gain>) + 1
> >
> > so that a gain of 8 is 0x3 in the register field and a gain of 4 is 0x2
> > in the register field, etc
>
> Example seems wrong...
>
> ilog2(8) + 1 = 3 + 1 = 0x4
> ilog2(4) + 1 = 2 + 1 = 0x3
> ilog2(2) + 1 = 1 + 1 = 0x2
> ilog2(1) + 1 = 0 + 1 = 0x1
> 0x0 reserved.
>
> or have I misunderstood?
Nope. I hit the wrong key but your table is correct. Can you fix it when
applying?
Powered by blists - more mailing lists