mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Gwendal Grignou" <gwendal@chromium.org>,
	"Stephen Boyd" <swboyd@chromium.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/6] iio: proximity: sx9360: fix hardware gain encoding
Date: Mon, 30 Nov 2026 19:15:05 +0200	[thread overview]
Message-ID: <aw2vGYOxN83acqHM@ashevche-desk.local> (raw)
In-Reply-To: <20261128115534.558478-5-kapoorarnav43@gmail.com>

On Sat, Nov 28, 2026 at 05:24:52PM +0530, Arnav Kapoor wrote:
> The sx9360 PROX_CTRL0 gain handling was copied from the original sx9324
> driver and has the same bug that commit 108e4d4de2b5
> ("iio:proximity:sx9324: Fix hardware gain read/write") fixed there:
> 
>   - The gain field holds ilog2(<gain>) + 1, with 0 reserved, so a gain
>     of 1 is 0x1 and a gain of 8 is 0x4. read_gain() and write_gain()
>     use ilog2(<gain>) instead, so every gain is off by one: writing 1
>     programs the reserved code 0 and writing 8 programs a gain of 4.
>   - SX9360_REG_PROX_CTRL0_GAIN_1 is 0x80, which sets the reserved bit 7
>     and leaves the gain field at the reserved code 0, instead of
>     0x1 << 3.
> 
> Semtech's own SX9360 driver (shipped in Samsung Galaxy kernels) decodes
> the field the same way, codes 1..4 as x1..x8 and 0, 5..7 as reserved,
> and programs 0x09 (gain x1, bit 7 clear) into both PROX_CTRL0
> registers.
> 
> Use the same encoding as sx9324: add one when writing, subtract one
> when reading, return -EINVAL for the reserved codes on read, and build
> the default with FIELD_PREP_CONST(). SX9360_REG_PROX_CTRL0_GAIN_8 used
> by the range check in write_gain() becomes 0x4 accordingly.

> Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support")
> Link: https://github.com/TeamWin/android_kernel_samsung_d2q/blob/master/drivers/sensors/sx9360.c

Do not put unreferred Link tags to the commit messages.
Use the form of Link: $URL [1] and refer with [1] in the
commit message above.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-11-30 17:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 11:54 [PATCH v3 0/6] iio: proximity: sx93xx: fix raw reads, thresholds, hysteresis and gain Arnav Kapoor
2026-11-28 11:54 ` [PATCH v3 1/6] iio: proximity: sx_common: fix raw reads while the trigger is in use Arnav Kapoor
2026-11-28 11:54 ` [PATCH v3 2/6] iio: proximity: sx9324: fix proximity threshold writes Arnav Kapoor
2026-11-28 11:54 ` [PATCH v3 3/6] iio: proximity: sx9324: reject negative hysteresis values Arnav Kapoor
2026-11-30  0:39   ` Jonathan Cameron
2026-11-28 11:54 ` [PATCH v3 4/6] iio: proximity: sx9360: fix hardware gain encoding Arnav Kapoor
2026-11-30 17:15   ` Andy Shevchenko [this message]
2026-11-28 11:54 ` [PATCH v3 5/6] iio: proximity: sx9360: fix proximity threshold writes Arnav Kapoor
2026-11-28 11:54 ` [PATCH v3 6/6] iio: proximity: sx9360: reject negative hysteresis values Arnav Kapoor

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=aw2vGYOxN83acqHM@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=kapoorarnav43@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=swboyd@chromium.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

all inboxes | Powered by JetHome®