Re: [PATCH v3 1/2] iio: adc: mcp3564: Use guard() to manage locks
From: Andy Shevchenko
Date: Wed Nov 25 2026 - 06:24:44 EST
On Wed, Nov 25, 2026 at 02:10:53AM +0530, Vaibhav Chahar wrote:
> Use guard(mutex) instead of manual mutex_lock() and mutex_unlock()
> calls to modernize the driver and improve mutex handling.
...
> ret = mcp3564_update_8bits(adc, MCP3564_CONFIG2_REG, MCP3564_CONFIG2_BOOST_CURRENT_MASK,
> FIELD_PREP(MCP3564_CONFIG2_BOOST_CURRENT_MASK, mode));
>
While at it, drop this unneeded blank line (same for other similar places).
> - if (ret)
> + if (ret) {
> dev_err(&indio_dev->dev, "Failed to configure CONFIG2 register\n");
> - else
> - adc->current_boost_mode = mode;
> + return ret;
> + }
...
> case IIO_CHAN_INFO_RAW:
> if (channel->output) {
> - mutex_lock(&adc->lock);
> + guard(mutex)(&adc->lock);
Add a blank line here, so it will be visible at a glance that guard()()
is used. Ditto for other similar places.
> *val = mcp3564_burnout_avail[adc->burnout_mode][0];
> *val2 = mcp3564_burnout_avail[adc->burnout_mode][1];
> - mutex_unlock(&adc->lock);
> return IIO_VAL_INT_PLUS_MICRO;
> }
--
With Best Regards,
Andy Shevchenko