From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Marc Titinger" <mtitinger@baylibre.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: ina2xx-adc: fix regmap max_register off-by-one
Date: Wed, 25 Mar 2026 14:36:31 +0200 [thread overview]
Message-ID: <acPWzzmdjmet7i9I@ashevche-desk.local> (raw)
In-Reply-To: <20260325054313.868261-1-harshit.m.mogalapalli@oracle.com>
On Tue, Mar 24, 2026 at 10:43:09PM -0700, Harshit Mogalapalli wrote:
> regmap_config.max_register is supposed to store the highest valid
> register but this driver assigns the number of registers
> INA2XX_MAX_REGISTERS is 8, the highest valid register address is 7.
>
> Fix this by subtracting 1 so max_register is inclusive.
This matches with my understanding of max_register in regmap.
But what I have noticed is that we have two drivers for the same subset
of the chips. Why? Also one may note the differences in max_register.
Taking that into account with the fact that most likely there is nothing wrong
to access that register (in the other driver they allow up to 13), I think you
can rather add a 0x07 register to the ADC driver and change the value of
_MAX_REGISTERS to be equal to 0x07 as done in hwmon driver.
> Fixes: c43a102e67db ("iio: ina2xx: add support for TI INA2xx Power Monitors")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> Found by static analysis using smatch, code review and guess work.
> NOT TESTED. Please review carefully!
Right, see above.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-03-25 12:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 5:43 [PATCH] iio: ina2xx-adc: fix regmap max_register off-by-one Harshit Mogalapalli
2026-03-25 12:36 ` Andy Shevchenko [this message]
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=acPWzzmdjmet7i9I@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=dlechner@baylibre.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtitinger@baylibre.com \
--cc=nuno.sa@analog.com \
/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