Re: [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex)
From: David Lechner
Date: Sat Mar 14 2026 - 15:45:59 EST
On 3/14/26 12:06 PM, Rajveer Chaudhari wrote:
> Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
> sca3000_print_rev(), sca3000_ring_int_process(),
> sca3000_read_event_config(), __sca3000_hw_ring_state_set(),
> sca3000_hw_ring_preenable(), sca3000_hw_ring_postdisable(),
> sca3000_clean_setup(), sca3000_stop_all_interrupts().
> This ensures the mutex is released on all return paths and
> allows returning directly without a goto label.
>
> Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@xxxxxxxxx>
> ---
...
> @@ -1132,24 +1131,18 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
> */
> if ((st->rx[0] & SCA3000_REG_MODE_MODE_MASK)
> != SCA3000_REG_MODE_MEAS_MODE_MOT_DET) {
can drop this { now.
> - ret = 0;
> - } else {
> - ret = sca3000_read_ctrl_reg(st,
> - SCA3000_REG_CTRL_SEL_MD_CTRL);
> - if (ret < 0)
> - goto error_ret;
> - /* only supporting logical or's for now */
> - ret = !!(ret & sca3000_addresses[chan->address][2]);
> + return 0;
> }
> - break;
> +
> + ret = sca3000_read_ctrl_reg(st,
> + SCA3000_REG_CTRL_SEL_MD_CTRL);
> + if (ret < 0)
> + return ret;
> + /* only supporting logical or's for now */
> + return !!(ret & sca3000_addresses[chan->address][2]);
> default:
> - ret = -EINVAL;
> + return -EINVAL;
> }
> -
> -error_ret:
> - mutex_unlock(&st->lock);
> -
> - return ret;
> }
>