@@ -439,18 +439,13 @@ int inv_icm42600_debugfs_reg(struct iio_dev *indio_dev, unsigned int reg,
439439 unsigned int writeval , unsigned int * readval )
440440{
441441 struct inv_icm42600_state * st = iio_device_get_drvdata (indio_dev );
442- int ret ;
443442
444- mutex_lock (& st -> lock );
443+ guard ( mutex ) (& st -> lock );
445444
446445 if (readval )
447- ret = regmap_read (st -> map , reg , readval );
448- else
449- ret = regmap_write (st -> map , reg , writeval );
450-
451- mutex_unlock (& st -> lock );
446+ return regmap_read (st -> map , reg , readval );
452447
453- return ret ;
448+ return regmap_write ( st -> map , reg , writeval ) ;
454449}
455450
456451static int inv_icm42600_set_conf (struct inv_icm42600_state * st ,
@@ -820,22 +815,22 @@ static int inv_icm42600_suspend(struct device *dev)
820815 struct device * accel_dev ;
821816 bool wakeup ;
822817 int accel_conf ;
823- int ret = 0 ;
818+ int ret ;
824819
825- mutex_lock (& st -> lock );
820+ guard ( mutex ) (& st -> lock );
826821
827822 st -> suspended .gyro = st -> conf .gyro .mode ;
828823 st -> suspended .accel = st -> conf .accel .mode ;
829824 st -> suspended .temp = st -> conf .temp_en ;
830825 if (pm_runtime_suspended (dev ))
831- goto out_unlock ;
826+ return 0 ;
832827
833828 /* disable FIFO data streaming */
834829 if (st -> fifo .on ) {
835830 ret = regmap_write (st -> map , INV_ICM42600_REG_FIFO_CONFIG ,
836831 INV_ICM42600_FIFO_CONFIG_BYPASS );
837832 if (ret )
838- goto out_unlock ;
833+ return ret ;
839834 }
840835
841836 /* keep chip on and wake-up capable if APEX and wakeup on */
@@ -851,23 +846,21 @@ static int inv_icm42600_suspend(struct device *dev)
851846 if (st -> apex .wom .enable ) {
852847 ret = inv_icm42600_disable_wom (st );
853848 if (ret )
854- goto out_unlock ;
849+ return ret ;
855850 }
856851 accel_conf = INV_ICM42600_SENSOR_MODE_OFF ;
857852 }
858853
859854 ret = inv_icm42600_set_pwr_mgmt0 (st , INV_ICM42600_SENSOR_MODE_OFF ,
860855 accel_conf , false, NULL );
861856 if (ret )
862- goto out_unlock ;
857+ return ret ;
863858
864859 /* disable vddio regulator if chip is sleeping */
865860 if (!wakeup )
866861 regulator_disable (st -> vddio_supply );
867862
868- out_unlock :
869- mutex_unlock (& st -> lock );
870- return ret ;
863+ return 0 ;
871864}
872865
873866/*
@@ -881,12 +874,12 @@ static int inv_icm42600_resume(struct device *dev)
881874 struct inv_icm42600_sensor_state * accel_st = iio_priv (st -> indio_accel );
882875 struct device * accel_dev ;
883876 bool wakeup ;
884- int ret = 0 ;
877+ int ret ;
885878
886- mutex_lock (& st -> lock );
879+ guard ( mutex ) (& st -> lock );
887880
888881 if (pm_runtime_suspended (dev ))
889- goto out_unlock ;
882+ return 0 ;
890883
891884 /* check wakeup capability */
892885 accel_dev = & st -> indio_accel -> dev ;
@@ -898,21 +891,21 @@ static int inv_icm42600_resume(struct device *dev)
898891 } else {
899892 ret = inv_icm42600_enable_regulator_vddio (st );
900893 if (ret )
901- goto out_unlock ;
894+ return ret ;
902895 }
903896
904897 /* restore sensors state */
905898 ret = inv_icm42600_set_pwr_mgmt0 (st , st -> suspended .gyro ,
906899 st -> suspended .accel ,
907900 st -> suspended .temp , NULL );
908901 if (ret )
909- goto out_unlock ;
902+ return ret ;
910903
911904 /* restore APEX features if disabled */
912905 if (!wakeup && st -> apex .wom .enable ) {
913906 ret = inv_icm42600_enable_wom (st );
914907 if (ret )
915- goto out_unlock ;
908+ return ret ;
916909 }
917910
918911 /* restore FIFO data streaming */
@@ -923,9 +916,7 @@ static int inv_icm42600_resume(struct device *dev)
923916 INV_ICM42600_FIFO_CONFIG_STREAM );
924917 }
925918
926- out_unlock :
927- mutex_unlock (& st -> lock );
928- return ret ;
919+ return 0 ;
929920}
930921
931922/* Runtime suspend will turn off sensors that are enabled by iio devices. */
@@ -934,34 +925,28 @@ static int inv_icm42600_runtime_suspend(struct device *dev)
934925 struct inv_icm42600_state * st = dev_get_drvdata (dev );
935926 int ret ;
936927
937- mutex_lock (& st -> lock );
928+ guard ( mutex ) (& st -> lock );
938929
939930 /* disable all sensors */
940931 ret = inv_icm42600_set_pwr_mgmt0 (st , INV_ICM42600_SENSOR_MODE_OFF ,
941932 INV_ICM42600_SENSOR_MODE_OFF , false,
942933 NULL );
943934 if (ret )
944- goto error_unlock ;
935+ return ret ;
945936
946937 regulator_disable (st -> vddio_supply );
947938
948- error_unlock :
949- mutex_unlock (& st -> lock );
950- return ret ;
939+ return 0 ;
951940}
952941
953942/* Sensors are enabled by iio devices, no need to turn them back on here. */
954943static int inv_icm42600_runtime_resume (struct device * dev )
955944{
956945 struct inv_icm42600_state * st = dev_get_drvdata (dev );
957- int ret ;
958946
959- mutex_lock (& st -> lock );
960-
961- ret = inv_icm42600_enable_regulator_vddio (st );
947+ guard (mutex )(& st -> lock );
962948
963- mutex_unlock (& st -> lock );
964- return ret ;
949+ return inv_icm42600_enable_regulator_vddio (st );
965950}
966951
967952EXPORT_NS_GPL_DEV_PM_OPS (inv_icm42600_pm_ops , IIO_ICM42600 ) = {
0 commit comments