]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: magnetometer: bmc150_magn: use automated cleanup for mutex
authorNeel Bullywon <neelb2403@gmail.com>
Sat, 28 Feb 2026 17:23:20 +0000 (12:23 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 2 Mar 2026 21:15:28 +0000 (21:15 +0000)
commit7031ee94438469732754cfdb23ae097adfe9336e
tree246be21d0ff40e948d4d7624931c98c516724ef7
parentcd04646c0f3eefdde87538f6ff932420cedc9ba0
iio: magnetometer: bmc150_magn: use automated cleanup for mutex

Use guard() and scoped_guard() to replace manual mutex lock/unlock
calls. This simplifies error handling and ensures RAII-style cleanup.

guard() is used in read_raw, write_raw, trig_reen, and
trigger_set_state. Case blocks using guard() in read_raw and write_raw
are wrapped in braces at the case label level to ensure clear scope for
the cleanup guards.

A bmc150_magn_set_power_mode_locked() helper is added to deduplicate
the lock-call-unlock pattern used by remove, runtime_suspend, suspend,
and resume.

The trigger_handler function is left unchanged as mixing guard() with
goto error paths can be fragile.

Signed-off-by: Neel Bullywon <neelb2403@gmail.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/magnetometer/bmc150_magn.c