[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aFwHRigf95hPKTE7@smile.fi.intel.com>
Date: Wed, 25 Jun 2025 17:27:18 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cc: jic23@...nel.org, dlechner@...libre.com, nuno.sa@...log.com,
andy@...nel.org, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, matthias.bgg@...il.com,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, kernel@...labora.com
Subject: Re: [PATCH v1 4/5] iio: adc: mt6359: Add support for MediaTek MT6363
PMIC AUXADC
On Wed, Jun 25, 2025 at 03:29:47PM +0200, AngeloGioacchino Del Regno wrote:
> Il 23/06/25 16:30, Andy Shevchenko ha scritto:
> > On Mon, Jun 23, 2025 at 02:00:27PM +0200, AngeloGioacchino Del Regno wrote:
...
> > > + if (MTK_AUXADC_HAS_FLAG(cinfo, IS_SPMI)) {
> > > + /* If the previous read succeeded, this can't fail */
> > > + regmap_read(regmap, reg - 1, &lval);
> >
> > No error check? lval may contain garbage here, right?
>
> No, because if the previous read succeeded, this can't fail, and also cannot ever
> possibly contain garbage (and if it does, - but again, that can't happen - there is
> no way to validate that because valid values are [0x00..0xff] anyway).
Never say never. Any regmap_*() call that performs I/O might fail. You can't
predict with 100% guarantee the HW behaviour in all possible scenarios.
> > > + val = (val << 8) | lval;
> >
> > Is it guaranteed that lval is always less than 256 (if unsigned)?
>
> Yes, with SPMI that is guaranteed.
>
> > > + }
...
> > > + regmap_update_bits(regmap, cinfo->regs[desc->ext_sel_idx],
> > > + MT6363_EXT_PURES_MASK, ext_sel);
> >
> > No error check?
>
> No, because if the previous reads and/or writes succeeded, it is impossible for
> this to fail :-)
Ditto.
I.o.w. the failed regmap_*() call can be a signal that something on the
communication channel with the HW went wrong, Depending on the severity of this
call the device driver may decide what to do next.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists