bmc150 magnetometer cleanup
cover bmc150 magnetometer cleanup
A couple of small cleanup patches starting from Hartmut's series. There are no conflicts with the rest of Hartmut's patches, so they can be applied in any order.
Irina Tirdea (2):
iio: magn: bmc150_magn: add locking comment for runtime resume
iio: magn: bmc150_magn: do not set power state twice when setting
trigger state
drivers/iio/magnetometer/bmc150_magn.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 iio: magn: bmc150_magn: add locking comment for runtime resume
Runtime resume function is called with the data->mutex lock held. Add a comment to indicate this.
--- drivers/iio/magnetometer/bmc150_magn.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/magnetometer/bmc150_magn.c +3 -0
@@ -1043,6 +1043,9 @@ static int bmc150_magn_runtime_suspend(struct device *dev)return 0 ; } +/* +* Should be called with data->mutex held. +*/ static int bmc150_magn_runtime_resume (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));
Signature · 1 line
1.9.1
PATCH 2/2 iio: magn: bmc150_magn: do not set power state twice when setting trigger state
In reply to Irina TirdeaWhen setting the trigger state, the device power state is set through buffer preenable and postdisable hooks. There is no need to also set it in the trigger set state call.
Remove duplicate set power state from the trigger set state call.
--- drivers/iio/magnetometer/bmc150_magn.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/magnetometer/bmc150_magn.c +2 -8
@@ -783,29 +783,23 @@ static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig,if (state == data->dready_trigger_on) goto err_unlock; - ret =bmc150_magn_set_power_state (data, state); -if (ret <0 ) - goto err_unlock; - ret =regmap_update_bits (data->regmap,BMC150_MAGN_REG_INT_DRDY ,BMC150_MAGN_MASK_DRDY_EN , state <<BMC150_MAGN_SHIFT_DRDY_EN );if (ret <0 ) - goto err_poweroff; + goto err_unlock; data->dready_trigger_on = state;if (state) { ret =bmc150_magn_reset_intr (data);if (ret <0 ) - goto err_poweroff; + goto err_unlock; }mutex_unlock (&data->mutex);return 0 ; -err_poweroff: -bmc150_magn_set_power_state (data, false); err_unlock:mutex_unlock (&data->mutex);return ret;
Signature · 1 line
1.9.1
Re: [PATCH 1/2] iio: magn: bmc150_magn: add locking comment for runtime resume
In reply to Irina TirdeaQuoted 4 lines · Irina Tirdea
Runtime resume function is called with the
data->mutexlock held. Add a comment to indicate this.Signed-off-by Irina Tirdea <[email protected]>
Sensible follow up to Hartmut's patches.
Applied to the togreg branch of iio.git
Thanks,
Jonathan
Quoted 19 lines
--- drivers/iio/magnetometer/bmc150_magn.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/magnetometer/bmc150_magn.c +3
-0@@ -1043,6 +1043,9 @@ static int bmc150_magn_runtime_suspend(struct device *dev)return 0 ; } +/* +* Should be called with data->mutex held. +*/ static int bmc150_magn_runtime_resume (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));
Re: [PATCH 2/2] iio: magn: bmc150_magn: do not set power state twice when setting trigger state
In reply to Irina TirdeaQuoted 8 lines · Irina Tirdea
When setting the trigger state, the device power state is set through buffer preenable and postdisable hooks. There is no need to also set it in the trigger set state call.
Remove duplicate set power state from the trigger set state call.
Signed-off-by Irina Tirdea <[email protected]>
Applied to the togreg branch of iio.git
Thanks,
Jonathan
Quoted 41 lines
--- drivers/iio/magnetometer/bmc150_magn.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)drivers/iio/magnetometer/bmc150_magn.c +2
-8@@ -783,29 +783,23 @@ static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig,if (state == data->dready_trigger_on) goto err_unlock; - ret =bmc150_magn_set_power_state (data, state); -if (ret <0 ) - goto err_unlock; - ret =regmap_update_bits (data->regmap,BMC150_MAGN_REG_INT_DRDY ,BMC150_MAGN_MASK_DRDY_EN , state <<BMC150_MAGN_SHIFT_DRDY_EN );if (ret <0 ) - goto err_poweroff; + goto err_unlock; data->dready_trigger_on = state;if (state) { ret =bmc150_magn_reset_intr (data);if (ret <0 ) - goto err_poweroff; + goto err_unlock; }mutex_unlock (&data->mutex);return 0 ; -err_poweroff: -bmc150_magn_set_power_state (data, false); err_unlock:mutex_unlock (&data->mutex);return ret;