linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Ijano <andrew.ijano@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: jic23@kernel.org, andrew.lopes@alumni.usp.br,
	gustavobastos@usp.br,  dlechner@baylibre.com, nuno.sa@analog.com,
	andy@kernel.org,  jstephan@baylibre.com,
	linux-iio@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/3] iio: accel: sca3000: replace usages of internal read data helpers by spi helpers
Date: Sat, 14 Jun 2025 18:06:26 -0300	[thread overview]
Message-ID: <CANZih_RTtcHHP80rtJ5gGkmkL1ohoctUBaGm-2Z2=Xo9VvT-Aw@mail.gmail.com> (raw)
In-Reply-To: <aErUqzdFL9nG6Bxc@smile.fi.intel.com>

On Thu, Jun 12, 2025 at 10:22 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> ...
>
> > +     ret |= (mode & SCA3000_REG_MODE_MODE_MASK);
>
> Unneeded parentheses.
>
...
>
> > +                     ret = spi_w8r16be(st->us,
> > +                                             SCA3000_READ_REG(SCA3000_REG_TEMP_MSB_ADDR));
>
> Make it simply one line. The above formatting is ugly.

That's right! I'll fix them.

>
> >       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >       struct sca3000_state *st = iio_priv(indio_dev);
> > -     int len = 0, ret, val;
> > +     int len = 0, ret;
>
> Ideally it's better to split them and len should never be signed.

Nice! I can make this change.

> Moreover, the function  should be switched to sysfs_emit_at() if this is part
> of ABI.

Great! I didn't know that.

In this case, sca3000_read_av_freq() is described as a "sysfs function
to get available frequencies", so I guess it's the case, right?
Is your suggestion to replace cases of sprintf() by sysfs_emit_at()
then? If so, I could do that in a following patch, it seems that
sca3000_show_available_3db_freqs() is also using sprintf().

>
> >       mutex_lock(&st->lock);
> > -     ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
> > -     val = st->rx[0];
> > +     ret = spi_w8r8(st->us, SCA3000_READ_REG(SCA3000_REG_MODE_ADDR));
> >       mutex_unlock(&st->lock);
> >       if (ret)
> >               return ret;
>
> ...
>
> >               }, {
> >                       .len = len,
> > -                     .rx_buf = rx,
> > +                     .rx_buf = st->rx,
> >               }
> >       };
>
> > -
>
> Stray change. Doesn't checkpatch complain on this?

I don't recall getting any warning from checkpatch but I can check
again for this next version.

> > -                     (st->rx[0] | SCA3000_REG_MODE_RING_BUF_ENABLE));
> > +                     (ret | SCA3000_REG_MODE_RING_BUF_ENABLE));
>
> > -                     (st->rx[0] & ~SCA3000_REG_MODE_RING_BUF_ENABLE));
> > +                     (ret & ~SCA3000_REG_MODE_RING_BUF_ENABLE));
>
> In the original code and still now too many parentheses.

Ok! I'll remove them.

Thanks,
Andrew

  reply	other threads:[~2025-06-14 21:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 19:39 [PATCH v5 0/3] iio: accel: sca3000: simplify by using newer infrastructure Andrew Ijano
2025-06-11 19:39 ` [PATCH v5 1/3] iio: accel: sca3000: replace error_ret labels by simple returns Andrew Ijano
2025-06-12  6:20   ` Nuno Sá
2025-06-12  6:41     ` Nuno Sá
2025-06-14 19:12       ` Andrew Ijano
2025-06-12 12:56   ` Andy Shevchenko
2025-06-14 11:48     ` Jonathan Cameron
2025-06-14 19:16       ` Andrew Ijano
2025-06-11 19:39 ` [PATCH v5 2/3] iio: accel: sca3000: replace usages of internal read data helpers by spi helpers Andrew Ijano
2025-06-12  6:29   ` Nuno Sá
2025-06-14 19:33     ` Andrew Ijano
2025-06-18  2:36       ` Andrew Ijano
2025-06-12 13:22   ` Andy Shevchenko
2025-06-14 21:06     ` Andrew Ijano [this message]
2025-06-14 21:50       ` Andy Shevchenko
2025-06-15  3:21         ` Andrew Ijano
2025-06-11 19:39 ` [PATCH v5 3/3] iio: accel: sca3000: use guard(mutex)() for handling mutex lock Andrew Ijano
2025-06-12  6:38   ` Nuno Sá
2025-06-14 11:54     ` Jonathan Cameron
2025-06-14 21:17     ` Andrew Ijano
2025-06-12 14:48   ` kernel test robot
2025-06-12 15:52   ` kernel test robot
2025-06-12 16:06     ` David Lechner
2025-06-14 21:21       ` Andrew Ijano
2025-06-14 12:01   ` Jonathan Cameron
2025-06-14 21:40     ` Andrew Ijano

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='CANZih_RTtcHHP80rtJ5gGkmkL1ohoctUBaGm-2Z2=Xo9VvT-Aw@mail.gmail.com' \
    --to=andrew.ijano@gmail.com \
    --cc=andrew.lopes@alumni.usp.br \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavobastos@usp.br \
    --cc=jic23@kernel.org \
    --cc=jstephan@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).