The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
@ 2026-05-05  0:55 Maxwell Doose
  2026-05-05  4:46 ` Maxwell Doose
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Maxwell Doose @ 2026-05-05  0:55 UTC (permalink / raw)
  To: jic23
  Cc: David Lechner, Nuno Sá, Andy Shevchenko,
	open list:IIO SUBSYSTEM AND DRIVERS, open list

Include linux/cleanup.h to take advantage of new macros.

Replace manual mutex_lock() and mutex_unlock() calls across the file
with guard(mutex)() and scoped_guard() where appropriate. This will help
modernize the driver with up-to-date functions/macros.

Remove now redundant gotos and ret variables, as the new RAII macros
make them unneeded.

Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
 v2:
 - Remove redundant blank line per Andy.
 - Put kmx61_set_mode() function call in kmx61_runtime_suspend() on one
   line per Andy.

 drivers/iio/imu/kmx61.c | 76 ++++++++++++++---------------------------
 1 file changed, 25 insertions(+), 51 deletions(-)

diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index 3cd91d8a89ee..6d2e98607d35 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -7,6 +7,7 @@
  * IIO driver for KMX61 (7-bit I2C slave address 0x0E or 0x0F).
  */
 
+#include <linux/cleanup.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/mod_devicetable.h>
@@ -794,25 +795,20 @@ static int kmx61_read_raw(struct iio_dev *indio_dev,
 		default:
 			return -EINVAL;
 		}
-		mutex_lock(&data->lock);
+		guard(mutex)(&data->lock);
 
 		ret = kmx61_set_power_state(data, true, chan->address);
-		if (ret) {
-			mutex_unlock(&data->lock);
+		if (ret)
 			return ret;
-		}
 
 		ret = kmx61_read_measurement(data, base_reg, chan->scan_index);
 		if (ret < 0) {
 			kmx61_set_power_state(data, false, chan->address);
-			mutex_unlock(&data->lock);
 			return ret;
 		}
 		*val = sign_extend32(ret >> chan->scan_type.shift,
 				     chan->scan_type.realbits - 1);
 		ret = kmx61_set_power_state(data, false, chan->address);
-
-		mutex_unlock(&data->lock);
 		if (ret)
 			return ret;
 		return IIO_VAL_INT;
@@ -834,9 +830,8 @@ static int kmx61_read_raw(struct iio_dev *indio_dev,
 		if (chan->type != IIO_ACCEL && chan->type != IIO_MAGN)
 			return -EINVAL;
 
-		mutex_lock(&data->lock);
-		ret = kmx61_get_odr(data, val, val2, chan->address);
-		mutex_unlock(&data->lock);
+		scoped_guard(mutex, &data->lock)
+			ret = kmx61_get_odr(data, val, val2, chan->address);
 		if (ret)
 			return -EINVAL;
 		return IIO_VAL_INT_PLUS_MICRO;
@@ -856,19 +851,15 @@ static int kmx61_write_raw(struct iio_dev *indio_dev,
 		if (chan->type != IIO_ACCEL && chan->type != IIO_MAGN)
 			return -EINVAL;
 
-		mutex_lock(&data->lock);
-		ret = kmx61_set_odr(data, val, val2, chan->address);
-		mutex_unlock(&data->lock);
-		return ret;
+		guard(mutex)(&data->lock);
+		return kmx61_set_odr(data, val, val2, chan->address);
 	case IIO_CHAN_INFO_SCALE:
 		switch (chan->type) {
 		case IIO_ACCEL:
 			if (val != 0)
 				return -EINVAL;
-			mutex_lock(&data->lock);
-			ret = kmx61_set_scale(data, val2);
-			mutex_unlock(&data->lock);
-			return ret;
+			guard(mutex)(&data->lock);
+			return kmx61_set_scale(data, val2);
 		default:
 			return -EINVAL;
 		}
@@ -945,28 +936,25 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,
 	if (state && data->ev_enable_state)
 		return 0;
 
-	mutex_lock(&data->lock);
+	guard(mutex)(&data->lock);
 
 	if (!state && data->motion_trig_on) {
 		data->ev_enable_state = false;
-		goto err_unlock;
+		return ret;
 	}
 
 	ret = kmx61_set_power_state(data, state, KMX61_ACC);
 	if (ret < 0)
-		goto err_unlock;
+		return ret;
 
 	ret = kmx61_setup_any_motion_interrupt(data, state);
 	if (ret < 0) {
 		kmx61_set_power_state(data, false, KMX61_ACC);
-		goto err_unlock;
+		return ret;
 	}
 
 	data->ev_enable_state = state;
 
-err_unlock:
-	mutex_unlock(&data->lock);
-
 	return ret;
 }
 
@@ -1020,11 +1008,11 @@ static int kmx61_data_rdy_trigger_set_state(struct iio_trigger *trig,
 	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
 	struct kmx61_data *data = kmx61_get_data(indio_dev);
 
-	mutex_lock(&data->lock);
+	guard(mutex)(&data->lock);
 
 	if (!state && data->ev_enable_state && data->motion_trig_on) {
 		data->motion_trig_on = false;
-		goto err_unlock;
+		return ret;
 	}
 
 	if (data->acc_dready_trig == trig || data->motion_trig == trig)
@@ -1034,7 +1022,7 @@ static int kmx61_data_rdy_trigger_set_state(struct iio_trigger *trig,
 
 	ret = kmx61_set_power_state(data, state, device);
 	if (ret < 0)
-		goto err_unlock;
+		return ret;
 
 	if (data->acc_dready_trig == trig || data->mag_dready_trig == trig)
 		ret = kmx61_setup_new_data_interrupt(data, state, device);
@@ -1042,7 +1030,7 @@ static int kmx61_data_rdy_trigger_set_state(struct iio_trigger *trig,
 		ret = kmx61_setup_any_motion_interrupt(data, state);
 	if (ret < 0) {
 		kmx61_set_power_state(data, false, device);
-		goto err_unlock;
+		return ret;
 	}
 
 	if (data->acc_dready_trig == trig)
@@ -1051,8 +1039,6 @@ static int kmx61_data_rdy_trigger_set_state(struct iio_trigger *trig,
 		data->mag_dready_trig_on = state;
 	else
 		data->motion_trig_on = state;
-err_unlock:
-	mutex_unlock(&data->lock);
 
 	return ret;
 }
@@ -1195,19 +1181,17 @@ static irqreturn_t kmx61_trigger_handler(int irq, void *p)
 	else
 		base = KMX61_MAG_XOUT_L;
 
-	mutex_lock(&data->lock);
+	guard(mutex)(&data->lock);
 	iio_for_each_active_channel(indio_dev, bit) {
 		ret = kmx61_read_measurement(data, base, bit);
 		if (ret < 0) {
-			mutex_unlock(&data->lock);
-			goto err;
+			iio_trigger_notify_done(indio_dev->trig);
+			return IRQ_HANDLED;
 		}
 		buffer[i++] = ret;
 	}
-	mutex_unlock(&data->lock);
 
 	iio_push_to_buffers(indio_dev, buffer);
-err:
 	iio_trigger_notify_done(indio_dev->trig);
 
 	return IRQ_HANDLED;
@@ -1419,22 +1403,16 @@ static void kmx61_remove(struct i2c_client *client)
 		iio_trigger_unregister(data->motion_trig);
 	}
 
-	mutex_lock(&data->lock);
+	guard(mutex)(&data->lock);
 	kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG, true);
-	mutex_unlock(&data->lock);
 }
 
 static int kmx61_suspend(struct device *dev)
 {
-	int ret;
 	struct kmx61_data *data = i2c_get_clientdata(to_i2c_client(dev));
 
-	mutex_lock(&data->lock);
-	ret = kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG,
-			     false);
-	mutex_unlock(&data->lock);
-
-	return ret;
+	guard(mutex)(&data->lock);
+	return kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG, false);
 }
 
 static int kmx61_resume(struct device *dev)
@@ -1453,13 +1431,9 @@ static int kmx61_resume(struct device *dev)
 static int kmx61_runtime_suspend(struct device *dev)
 {
 	struct kmx61_data *data = i2c_get_clientdata(to_i2c_client(dev));
-	int ret;
 
-	mutex_lock(&data->lock);
-	ret = kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG, true);
-	mutex_unlock(&data->lock);
-
-	return ret;
+	guard(mutex)(&data->lock);
+	return kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG, true);
 }
 
 static int kmx61_runtime_resume(struct device *dev)

base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
  2026-05-05  0:55 [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking Maxwell Doose
@ 2026-05-05  4:46 ` Maxwell Doose
  2026-05-05  7:25   ` Andy Shevchenko
  2026-05-05  7:56 ` Markus Elfring
  2026-05-14  3:44 ` kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Maxwell Doose @ 2026-05-05  4:46 UTC (permalink / raw)
  To: jic23
  Cc: David Lechner, Nuno Sá, Andy Shevchenko,
	open list:IIO SUBSYSTEM AND DRIVERS, open list

Hi,

On Mon, May 4, 2026 at 7:55 PM Maxwell Doose <m32285159@gmail.com> wrote:
>
> Include linux/cleanup.h to take advantage of new macros.
>
> Replace manual mutex_lock() and mutex_unlock() calls across the file
> with guard(mutex)() and scoped_guard() where appropriate. This will help
> modernize the driver with up-to-date functions/macros.
>
> Remove now redundant gotos and ret variables, as the new RAII macros
> make them unneeded.
>
> Signed-off-by: Maxwell Doose <m32285159@gmail.com>
> ---
>  v2:
>  - Remove redundant blank line per Andy.
>  - Put kmx61_set_mode() function call in kmx61_runtime_suspend() on one
>    line per Andy.
>
>  drivers/iio/imu/kmx61.c | 76 ++++++++++++++---------------------------
>  1 file changed, 25 insertions(+), 51 deletions(-)
[snip]

I just got the report in from the CI bot on the v1, and there are
still things in this patch that need to be fixed, consider this
superseded. I'm going to be writing a v3 in the morning (my time) to
resolve this.

best regards,
max

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
  2026-05-05  4:46 ` Maxwell Doose
@ 2026-05-05  7:25   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-05  7:25 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: jic23, David Lechner, Nuno Sá, Andy Shevchenko,
	open list:IIO SUBSYSTEM AND DRIVERS, open list

On Mon, May 04, 2026 at 11:46:04PM -0500, Maxwell Doose wrote:
> On Mon, May 4, 2026 at 7:55 PM Maxwell Doose <m32285159@gmail.com> wrote:
> >
> > Include linux/cleanup.h to take advantage of new macros.
> >
> > Replace manual mutex_lock() and mutex_unlock() calls across the file
> > with guard(mutex)() and scoped_guard() where appropriate. This will help
> > modernize the driver with up-to-date functions/macros.
> >
> > Remove now redundant gotos and ret variables, as the new RAII macros
> > make them unneeded.

[snip]

> I just got the report in from the CI bot on the v1, and there are
> still things in this patch that need to be fixed, consider this
> superseded. I'm going to be writing a v3 in the morning (my time) to
> resolve this.

Yes, you need to have a dedicated scope for guard()(). So, each case
in the switch that uses guard has to define the scope, id est be like

	case FOO: {
		...
		break; // or return ...;
	}

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
  2026-05-05  0:55 [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking Maxwell Doose
  2026-05-05  4:46 ` Maxwell Doose
@ 2026-05-05  7:56 ` Markus Elfring
  2026-05-14  3:44 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-05-05  7:56 UTC (permalink / raw)
  To: Maxwell Doose, linux-iio, Jonathan Cameron
  Cc: LKML, Andy Shevchenko, David Lechner, Nuno Sá

…
> Replace manual mutex_lock() and mutex_unlock() calls across the file
…

I find the word “family” inappropriate in the summary phrase.

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
  2026-05-05  0:55 [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking Maxwell Doose
  2026-05-05  4:46 ` Maxwell Doose
  2026-05-05  7:56 ` Markus Elfring
@ 2026-05-14  3:44 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-05-14  3:44 UTC (permalink / raw)
  To: Maxwell Doose, jic23
  Cc: oe-kbuild-all, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

Hi Maxwell,

kernel test robot noticed the following build errors:

[auto build test ERROR on 7fd2df204f342fc17d1a0bfcd474b24232fb0f32]

url:    https://github.com/intel-lab-lkp/linux/commits/Maxwell-Doose/iio-imu-kmx61-Use-guard-mutex-family-over-manual-locking/20260514-043249
base:   7fd2df204f342fc17d1a0bfcd474b24232fb0f32
patch link:    https://lore.kernel.org/r/20260505005506.160891-1-m32285159%40gmail.com
patch subject: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking
config: i386-randconfig-141-20260514 (https://download.01.org/0day-ci/archive/20260514/202605141121.82vp1RMY-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
smatch: v0.5.0-9185-gbcc58b9c
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260514/202605141121.82vp1RMY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605141121.82vp1RMY-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/iio/imu/kmx61.c:829:2: error: cannot jump from switch statement to this case label
     829 |         case IIO_CHAN_INFO_SAMP_FREQ:
         |         ^
   drivers/iio/imu/kmx61.c:798:3: note: jump bypasses initialization of variable with __attribute__((cleanup))
     798 |                 guard(mutex)(&data->lock);
         |                 ^
   include/linux/cleanup.h:422:2: note: expanded from macro 'guard'
     422 |         CLASS(_name, __UNIQUE_ID(guard))
         |         ^
   include/linux/cleanup.h:303:3: note: expanded from macro 'CLASS'
     303 |                 class_##_name##_constructor
         |                 ^
   <scratch space>:112:1: note: expanded from here
     112 | class_mutex_constructor
         | ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:16:23: note: expanded from macro '__PASTE'
      16 | #define __PASTE(a, b) ___PASTE(a, b)
         |                       ^
   include/linux/compiler_types.h:15:24: note: expanded from macro '___PASTE'
      15 | #define ___PASTE(a, b) a##b
         |                        ^
   <scratch space>:118:1: note: expanded from here
     118 | __UNIQUE_ID_unlock_385
         | ^
   drivers/iio/imu/kmx61.c:798:3: note: jump bypasses initialization of variable with __attribute__((cleanup))
   include/linux/cleanup.h:422:15: note: expanded from macro 'guard'
     422 |         CLASS(_name, __UNIQUE_ID(guard))
         |                      ^
   include/linux/compiler.h:165:2: note: expanded from macro '__UNIQUE_ID'
     165 |         __PASTE(__UNIQUE_ID_,                                   \
         |         ^
   include/linux/compiler_types.h:16:23: note: expanded from macro '__PASTE'
      16 | #define __PASTE(a, b) ___PASTE(a, b)
         |                       ^
   include/linux/compiler_types.h:15:24: note: expanded from macro '___PASTE'
      15 | #define ___PASTE(a, b) a##b
         |                        ^
   <scratch space>:106:1: note: expanded from here
     106 | __UNIQUE_ID_guard_384
         | ^
   drivers/iio/imu/kmx61.c:815:2: error: cannot jump from switch statement to this case label
     815 |         case IIO_CHAN_INFO_SCALE:
         |         ^
   drivers/iio/imu/kmx61.c:798:3: note: jump bypasses initialization of variable with __attribute__((cleanup))
     798 |                 guard(mutex)(&data->lock);
         |                 ^
   include/linux/cleanup.h:422:2: note: expanded from macro 'guard'
     422 |         CLASS(_name, __UNIQUE_ID(guard))
         |         ^
   include/linux/cleanup.h:303:3: note: expanded from macro 'CLASS'
     303 |                 class_##_name##_constructor
         |                 ^
   <scratch space>:112:1: note: expanded from here
     112 | class_mutex_constructor
         | ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:16:23: note: expanded from macro '__PASTE'
      16 | #define __PASTE(a, b) ___PASTE(a, b)
         |                       ^
   include/linux/compiler_types.h:15:24: note: expanded from macro '___PASTE'
      15 | #define ___PASTE(a, b) a##b
         |                        ^
   <scratch space>:118:1: note: expanded from here
     118 | __UNIQUE_ID_unlock_385
         | ^
   drivers/iio/imu/kmx61.c:798:3: note: jump bypasses initialization of variable with __attribute__((cleanup))
   include/linux/cleanup.h:422:15: note: expanded from macro 'guard'
     422 |         CLASS(_name, __UNIQUE_ID(guard))
         |                      ^
   include/linux/compiler.h:165:2: note: expanded from macro '__UNIQUE_ID'
     165 |         __PASTE(__UNIQUE_ID_,                                   \
         |         ^
   include/linux/compiler_types.h:16:23: note: expanded from macro '__PASTE'
      16 | #define __PASTE(a, b) ___PASTE(a, b)
         |                       ^
   include/linux/compiler_types.h:15:24: note: expanded from macro '___PASTE'
      15 | #define ___PASTE(a, b) a##b
         |                        ^
   <scratch space>:106:1: note: expanded from here
     106 | __UNIQUE_ID_guard_384
         | ^
   drivers/iio/imu/kmx61.c:846:6: warning: unused variable 'ret' [-Wunused-variable]
     846 |         int ret;
         |             ^~~
   drivers/iio/imu/kmx61.c:863:3: error: cannot jump from switch statement to this case label
     863 |                 default:
         |                 ^
   drivers/iio/imu/kmx61.c:861:4: note: jump bypasses initialization of variable with __attribute__((cleanup))
     861 |                         guard(mutex)(&data->lock);
         |                         ^
   include/linux/cleanup.h:422:2: note: expanded from macro 'guard'
     422 |         CLASS(_name, __UNIQUE_ID(guard))
         |         ^
   include/linux/cleanup.h:303:3: note: expanded from macro 'CLASS'
     303 |                 class_##_name##_constructor
         |                 ^
   <scratch space>:170:1: note: expanded from here
     170 | class_mutex_constructor
         | ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)


vim +829 drivers/iio/imu/kmx61.c

20ffac278ebd64 Daniel Baluta 2014-12-03  777  
20ffac278ebd64 Daniel Baluta 2014-12-03  778  static int kmx61_read_raw(struct iio_dev *indio_dev,
20ffac278ebd64 Daniel Baluta 2014-12-03  779  			  struct iio_chan_spec const *chan, int *val,
20ffac278ebd64 Daniel Baluta 2014-12-03  780  			  int *val2, long mask)
20ffac278ebd64 Daniel Baluta 2014-12-03  781  {
20ffac278ebd64 Daniel Baluta 2014-12-03  782  	int ret;
20ffac278ebd64 Daniel Baluta 2014-12-03  783  	u8 base_reg;
20ffac278ebd64 Daniel Baluta 2014-12-03  784  	struct kmx61_data *data = kmx61_get_data(indio_dev);
20ffac278ebd64 Daniel Baluta 2014-12-03  785  
20ffac278ebd64 Daniel Baluta 2014-12-03  786  	switch (mask) {
20ffac278ebd64 Daniel Baluta 2014-12-03  787  	case IIO_CHAN_INFO_RAW:
20ffac278ebd64 Daniel Baluta 2014-12-03  788  		switch (chan->type) {
20ffac278ebd64 Daniel Baluta 2014-12-03  789  		case IIO_ACCEL:
20ffac278ebd64 Daniel Baluta 2014-12-03  790  			base_reg = KMX61_ACC_XOUT_L;
20ffac278ebd64 Daniel Baluta 2014-12-03  791  			break;
20ffac278ebd64 Daniel Baluta 2014-12-03  792  		case IIO_MAGN:
20ffac278ebd64 Daniel Baluta 2014-12-03  793  			base_reg = KMX61_MAG_XOUT_L;
20ffac278ebd64 Daniel Baluta 2014-12-03  794  			break;
20ffac278ebd64 Daniel Baluta 2014-12-03  795  		default:
20ffac278ebd64 Daniel Baluta 2014-12-03  796  			return -EINVAL;
20ffac278ebd64 Daniel Baluta 2014-12-03  797  		}
45e0524c69702c Maxwell Doose 2026-05-04  798  		guard(mutex)(&data->lock);
20ffac278ebd64 Daniel Baluta 2014-12-03  799  
a3da4fa301ae60 Daniel Baluta 2014-12-23  800  		ret = kmx61_set_power_state(data, true, chan->address);
45e0524c69702c Maxwell Doose 2026-05-04  801  		if (ret)
a3da4fa301ae60 Daniel Baluta 2014-12-23  802  			return ret;
a3da4fa301ae60 Daniel Baluta 2014-12-23  803  
20ffac278ebd64 Daniel Baluta 2014-12-03  804  		ret = kmx61_read_measurement(data, base_reg, chan->scan_index);
20ffac278ebd64 Daniel Baluta 2014-12-03  805  		if (ret < 0) {
aff8609addd00e Daniel Baluta 2014-12-03  806  			kmx61_set_power_state(data, false, chan->address);
20ffac278ebd64 Daniel Baluta 2014-12-03  807  			return ret;
20ffac278ebd64 Daniel Baluta 2014-12-03  808  		}
20ffac278ebd64 Daniel Baluta 2014-12-03  809  		*val = sign_extend32(ret >> chan->scan_type.shift,
20ffac278ebd64 Daniel Baluta 2014-12-03  810  				     chan->scan_type.realbits - 1);
a3da4fa301ae60 Daniel Baluta 2014-12-23  811  		ret = kmx61_set_power_state(data, false, chan->address);
a3da4fa301ae60 Daniel Baluta 2014-12-23  812  		if (ret)
a3da4fa301ae60 Daniel Baluta 2014-12-23  813  			return ret;
20ffac278ebd64 Daniel Baluta 2014-12-03  814  		return IIO_VAL_INT;
20ffac278ebd64 Daniel Baluta 2014-12-03  815  	case IIO_CHAN_INFO_SCALE:
20ffac278ebd64 Daniel Baluta 2014-12-03  816  		switch (chan->type) {
20ffac278ebd64 Daniel Baluta 2014-12-03  817  		case IIO_ACCEL:
20ffac278ebd64 Daniel Baluta 2014-12-03  818  			*val = 0;
20ffac278ebd64 Daniel Baluta 2014-12-03  819  			*val2 = kmx61_uscale_table[data->range];
20ffac278ebd64 Daniel Baluta 2014-12-03  820  			return IIO_VAL_INT_PLUS_MICRO;
20ffac278ebd64 Daniel Baluta 2014-12-03  821  		case IIO_MAGN:
20ffac278ebd64 Daniel Baluta 2014-12-03  822  			/* 14 bits res, 1465 microGauss per magn count */
20ffac278ebd64 Daniel Baluta 2014-12-03  823  			*val = 0;
20ffac278ebd64 Daniel Baluta 2014-12-03  824  			*val2 = 1465;
20ffac278ebd64 Daniel Baluta 2014-12-03  825  			return IIO_VAL_INT_PLUS_MICRO;
20ffac278ebd64 Daniel Baluta 2014-12-03  826  		default:
20ffac278ebd64 Daniel Baluta 2014-12-03  827  			return -EINVAL;
20ffac278ebd64 Daniel Baluta 2014-12-03  828  		}
20ffac278ebd64 Daniel Baluta 2014-12-03 @829  	case IIO_CHAN_INFO_SAMP_FREQ:
20ffac278ebd64 Daniel Baluta 2014-12-03  830  		if (chan->type != IIO_ACCEL && chan->type != IIO_MAGN)
20ffac278ebd64 Daniel Baluta 2014-12-03  831  			return -EINVAL;
20ffac278ebd64 Daniel Baluta 2014-12-03  832  
45e0524c69702c Maxwell Doose 2026-05-04  833  		scoped_guard(mutex, &data->lock)
20ffac278ebd64 Daniel Baluta 2014-12-03  834  			ret = kmx61_get_odr(data, val, val2, chan->address);
20ffac278ebd64 Daniel Baluta 2014-12-03  835  		if (ret)
20ffac278ebd64 Daniel Baluta 2014-12-03  836  			return -EINVAL;
20ffac278ebd64 Daniel Baluta 2014-12-03  837  		return IIO_VAL_INT_PLUS_MICRO;
20ffac278ebd64 Daniel Baluta 2014-12-03  838  	}
20ffac278ebd64 Daniel Baluta 2014-12-03  839  	return -EINVAL;
20ffac278ebd64 Daniel Baluta 2014-12-03  840  }
20ffac278ebd64 Daniel Baluta 2014-12-03  841  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-14  3:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05  0:55 [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking Maxwell Doose
2026-05-05  4:46 ` Maxwell Doose
2026-05-05  7:25   ` Andy Shevchenko
2026-05-05  7:56 ` Markus Elfring
2026-05-14  3:44 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox