From: Jonathan Cameron <jic23@kernel.org>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Kent Gustavsson <kent@minoris.se>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: adc: mcp3911: simplify code with guard macro
Date: Wed, 6 Dec 2023 18:01:26 +0000 [thread overview]
Message-ID: <20231206180126.6e78ed29@jic23-huawei> (raw)
In-Reply-To: <20231205-mcp3911-guard-v3-1-df83e956d1e9@gmail.com>
On Tue, 05 Dec 2023 12:16:33 +0100
Marcus Folkesson <marcus.folkesson@gmail.com> wrote:
> Use the guard(mutex) macro for handle mutex lock/unlocks.
>
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Hi Marcus,
One follow up issue inline.
> ---
> Changes in v3:
> - Return early in good paths as well
> - Rebase against master
> - Link to v2: https://lore.kernel.org/r/20231127-mcp3911-guard-v2-1-9462630dca1e@gmail.com
>
> Changes in v2:
> - Return directly instead of goto label
> - Link to v1: https://lore.kernel.org/r/20231125-mcp3911-guard-v1-1-2748d16a3f3f@gmail.com
> ---
> drivers/iio/adc/mcp3911.c | 47 +++++++++++++++--------------------------------
> 1 file changed, 15 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> index d864558bc087..f4822ecece89 100644
> --- a/drivers/iio/adc/mcp3911.c
> +++ b/drivers/iio/adc/mcp3911.c
> @@ -7,6 +7,7 @@
> */
> #include <linux/bitfield.h>
> #include <linux/bits.h>
> +#include <linux/cleanup.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> #include <linux/err.h>
> @@ -318,44 +319,34 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
> struct mcp3911 *adc = iio_priv(indio_dev);
> int ret = -EINVAL;
>
> - mutex_lock(&adc->lock);
> + guard(mutex)(&adc->lock);
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> ret = mcp3911_read(adc,
> MCP3911_CHANNEL(channel->channel), val, 3);
> if (ret)
> - goto out;
> + return ret;
>
> *val = sign_extend32(*val, 23);
> -
> - ret = IIO_VAL_INT;
> + return IIO_VAL_INT;
> break;
Why keep the break? It's unreachable code.
Same for other similar cases.
Jonathan
>
prev parent reply other threads:[~2023-12-06 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 11:16 [PATCH v3] iio: adc: mcp3911: simplify code with guard macro Marcus Folkesson
2023-12-06 18:01 ` Jonathan Cameron [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=20231206180126.6e78ed29@jic23-huawei \
--to=jic23@kernel.org \
--cc=kent@minoris.se \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.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