From: "Nuno Sá" <noname.nuno@gmail.com>
To: Andrew Ijano <andrew.ijano@gmail.com>, jic23@kernel.org
Cc: 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 1/3] iio: accel: sca3000: replace error_ret labels by simple returns
Date: Thu, 12 Jun 2025 07:41:40 +0100 [thread overview]
Message-ID: <304d3bcef438a78564650edd52f7570f0bd30c95.camel@gmail.com> (raw)
In-Reply-To: <028710c4e4494285bee82ae811147b03cfa612f2.camel@gmail.com>
On Thu, 2025-06-12 at 07:20 +0100, Nuno Sá wrote:
> On Wed, 2025-06-11 at 16:39 -0300, Andrew Ijano wrote:
> > Replace usage of error_ret labels by returning directly when handling
> > errors. Cases that do a mutex unlock were not changed.
> >
> > Signed-off-by: Andrew Ijano <andrew.lopes@alumni.usp.br>
> > Co-developed-by: Gustavo Bastos <gustavobastos@usp.br>
> > Signed-off-by: Gustavo Bastos <gustavobastos@usp.br>
> > Suggested-by: Jonathan Cameron <jic23@kernel.org>
> > ---
>
> Code looks good. But since you're doing this you could cleanup some of the switch()
> cases. Some return in every case statement while other don't (even think I saw one
> one place where 'return' in the end was not needed). IIRC, there's preference for
> returning in place.
>
I see the above could be a bit cumbersome in cases there's locking (which get's
cleaned up in patch 3). So, nevermind the above. If there's any leftover, you can
send a follow up patch or introduce a new patch if you need to re-spin.
For this one:
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
>
> > drivers/iio/accel/sca3000.c | 29 +++++++++++------------------
> > 1 file changed, 11 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> > index aabe4491efd7..bfa8a3f5a92f 100644
> > --- a/drivers/iio/accel/sca3000.c
> > +++ b/drivers/iio/accel/sca3000.c
> > @@ -369,23 +369,20 @@ static int sca3000_write_ctrl_reg(struct sca3000_state *st,
> >
> > ret = sca3000_reg_lock_on(st);
> > if (ret < 0)
> > - goto error_ret;
> > + return ret;
> > if (ret) {
> > ret = __sca3000_unlock_reg_lock(st);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> > }
> >
> > /* Set the control select register */
> > ret = sca3000_write_reg(st, SCA3000_REG_CTRL_SEL_ADDR, sel);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> >
> > /* Write the actual value into the register */
> > - ret = sca3000_write_reg(st, SCA3000_REG_CTRL_DATA_ADDR, val);
> > -
> > -error_ret:
> > - return ret;
> > + return sca3000_write_reg(st, SCA3000_REG_CTRL_DATA_ADDR, val);
> > }
> >
> > /**
> > @@ -402,22 +399,20 @@ static int sca3000_read_ctrl_reg(struct sca3000_state *st,
> >
> > ret = sca3000_reg_lock_on(st);
> > if (ret < 0)
> > - goto error_ret;
> > + return ret;
> > if (ret) {
> > ret = __sca3000_unlock_reg_lock(st);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> > }
> > /* Set the control select register */
> > ret = sca3000_write_reg(st, SCA3000_REG_CTRL_SEL_ADDR, ctrl_reg);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> > ret = sca3000_read_data_short(st, SCA3000_REG_CTRL_DATA_ADDR, 1);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> > return st->rx[0];
> > -error_ret:
> > - return ret;
> > }
> >
> > /**
> > @@ -577,7 +572,8 @@ static inline int __sca3000_get_base_freq(struct
> > sca3000_state
> > *st,
> >
> > ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> > +
> > switch (SCA3000_REG_MODE_MODE_MASK & st->rx[0]) {
> > case SCA3000_REG_MODE_MEAS_MODE_NORMAL:
> > *base_freq = info->measurement_mode_freq;
> > @@ -591,7 +587,6 @@ static inline int __sca3000_get_base_freq(struct
> > sca3000_state
> > *st,
> > default:
> > ret = -EINVAL;
> > }
> > -error_ret:
> > return ret;
> > }
> >
> > @@ -834,7 +829,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
> > val = st->rx[0];
> > mutex_unlock(&st->lock);
> > if (ret)
> > - goto error_ret;
> > + return ret;
> >
> > switch (val & SCA3000_REG_MODE_MODE_MASK) {
> > case SCA3000_REG_MODE_MEAS_MODE_NORMAL:
> > @@ -857,8 +852,6 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
> > break;
> > }
> > return len;
> > -error_ret:
> > - return ret;
> > }
> >
> > /*
>
next prev parent reply other threads:[~2025-06-12 7:41 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á [this message]
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
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=304d3bcef438a78564650edd52f7570f0bd30c95.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=andrew.ijano@gmail.com \
--cc=andrew.lopes@alumni.usp.br \
--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
all inboxes | Powered by JetHome®