Re: iio: accel: sca3000: dead code issue

From: Andy Shevchenko
Date: Thu Jul 03 2025 - 04:02:33 EST


Wed, Jul 02, 2025 at 04:40:22PM +0100, Jonathan Cameron kirjoitti:
> On Wed, 2 Jul 2025 15:11:26 +0300
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> > On Wed, Jul 02, 2025 at 10:00:55AM +0100, Colin King (gmail) wrote:
> >
> > > ret = spi_w8r8(st->us,
> > > SCA3000_READ_REG(SCA3000_REG_BUF_COUNT_ADDR));
> > >
> > > >>> the call to spi_w8r8 returns 0 on success or -ve on an error
> >
> > Where did you get this from, please? Any link to elixir or Git repo?
>
> Hmm. Just for reference the docs of spi_w8r8 are:
>
> * Return: the (unsigned) eight bit number returned by the
> * device, or else a negative error code.
>
> Not 0 on success (well not unless it is zero.

Right. My point was that the comment is misleading. With the adjusted comment
the rest becomes immediately clear.

> So the check indeed looks wrong as should be if (ret < 0)

Exactly. Report is valid, the comment in the analysis is not.

> https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=ca66d8208762492df8442a503db568d9aab65f2f
> It's in my tree.

I was asking for the link to the spi_w8r8() where it's written like '0 on
success and -ve on error'. Not needed anymore as you cited the documentation.

> I'll drop the patch when I'm on the right machine. Andrew, could
> you do a new version fixing this up? If not can make the changes
> but will be at least the weekend before I get a chance.
>
> Looks like there are a couple of instances of this.
>
> > > if (ret)
> > > goto error_ret;

--
With Best Regards,
Andy Shevchenko