public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Luiz Mugnaini <luizmugnaini@usp.br>
Cc: cmo@melexis.com, jic23@kernel.org, dlechner@baylibre.com,
	nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: temperature: mlx90614: use guard(mutex) for EEPROM access locking
Date: Mon, 20 Apr 2026 10:59:46 +0300	[thread overview]
Message-ID: <aeXc8o94OiDRFy0b@ashevche-desk.local> (raw)
In-Reply-To: <20260418205151.172046-1-luizmugnaini@usp.br>

On Sat, Apr 18, 2026 at 05:51:36PM -0300, Luiz Mugnaini wrote:

> Replace mutex_lock()/mutex_unlock() pairs with guard(mutex) from
> cleanup.h for cleaner and safer mutex handling. The lock protects
> EEPROM access across five call sites in mlx90614_read_raw(),
> mlx90614_write_raw(), and mlx90614_sleep().
> 
> In all cases, the code between mutex_unlock() and the end of scope
> is either trivial computation, a return statement, or a call to
> mlx90614_power_put() (which only schedules a deferred autosuspend
> via pm_runtime_put_autosuspend()). The slightly extended lock scope
> is negligible compared to the existing hold times, which include
> EEPROM write cycles with 40ms sleeps.

...

> -		mutex_lock(&data->lock);
> +		guard(mutex)(&data->lock);
>  		ret = i2c_smbus_read_word_data(data->client,
>  					       chip_info->op_eeprom_emissivity);
> -		mutex_unlock(&data->lock);
>  		mlx90614_power_put(data);

How do you sure that the code:
- is not slowed down due to unneeded things in the critical section
- doesn't introduce no deadlocks
?

How did you test this, please?

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2026-04-20  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18 20:51 [PATCH] iio: temperature: mlx90614: use guard(mutex) for EEPROM access locking Luiz Mugnaini
2026-04-19 11:43 ` Jonathan Cameron
2026-04-20 14:11   ` Luiz Mugnaini
2026-04-20  7:59 ` Andy Shevchenko [this message]
2026-04-20 14:12   ` Luiz Mugnaini

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=aeXc8o94OiDRFy0b@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=cmo@melexis.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=luizmugnaini@usp.br \
    --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