Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Felipe Ribeiro de Souza <felipers@ime.usp.br>
Cc: andy@kernel.org, dlechner@baylibre.com, jic23@kernel.org,
	nuno.sa@analog.com, paul@crapouillou.net,
	Lucas Ivars Cadima Ciziks <lucas@ciziks.com>,
	linux-iio@vger.kernel.org, linux-mips@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: adc: ingenic-adc: use guard()() to handle synchronisation
Date: Fri, 24 Apr 2026 11:14:07 +0300	[thread overview]
Message-ID: <aesmT26uMeGygV_y@ashevche-desk.local> (raw)
In-Reply-To: <20260423012011.41001-3-felipers@ime.usp.br>

On Wed, Apr 22, 2026 at 10:18:31PM -0300, Felipe Ribeiro de Souza wrote:
> Replace mutex_lock() and mutex_unlock() calls with guard()()
> in functions ingenic_adc_set_adcmd(), ingenic_adc_set_config(),
> ingenic_adc_enable(), ingenic_adc_capture() and
> ingenic_adc_read_chan_locked().
> 
> This removes the need to call the unlock function, as the lock is
> automatically released when the function return or the scope exits
> for any other case.

...

> static int ingenic_adc_read_chan_locked(struct ingenic_adc *adc,

>  	switch (chan->channel) {
>  	case INGENIC_ADC_AUX0:

>  		break;
>  	}
>  
> -	ret = IIO_VAL_INT;
> -out:
> -	mutex_unlock(&adc->aux_lock);
> -
> -	return ret;
> +	return IIO_VAL_INT;
>  }

Just a side note (it was already like this in the original code).
The switch-case has no default case and in unlikely event of code
modification or run-time flow we will return this instead of some
error code. That said, I think it's better to return directly from
each of the cases and add default case with an error code returned
(probably in a preparatory patch?). In any case it's up to you and
maintainers, since your patch doesn't change the state of affairs.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-04-24  8:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23  1:18 [PATCH v4 0/2] use guard()() to handle synchronisation Felipe Ribeiro de Souza
2026-04-23  1:18 ` [PATCH v4 1/2] iio: adc: ingenic-adc: refactor ingenic_adc_read_chan_info_raw() Felipe Ribeiro de Souza
2026-04-23  1:18 ` [PATCH v4 2/2] iio: adc: ingenic-adc: use guard()() to handle synchronisation Felipe Ribeiro de Souza
2026-04-24  8:14   ` Andy Shevchenko [this message]
2026-04-24  8:15 ` [PATCH v4 0/2] " Andy Shevchenko
2026-04-24 11:25   ` Jonathan Cameron

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=aesmT26uMeGygV_y@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=felipers@ime.usp.br \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lucas@ciziks.com \
    --cc=nuno.sa@analog.com \
    --cc=paul@crapouillou.net \
    /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