From c7c69e8540895be5d09bf023f1b48db3cab7a78b Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Tue, 19 Aug 2014 23:43:00 +0100 Subject: [PATCH] iio:bma180: Use bool instead of int for state Signed-off-by: Peter Meerwald Cc: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bma180.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 284598d7cc94..aa7566fc031f 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -62,11 +62,8 @@ #define BMA180_LOW_NOISE 0x00 #define BMA180_LOW_POWER 0x03 -#define BMA180_LOW_NOISE_STR "low_noise" -#define BMA180_LOW_POWER_STR "low_power" - /* Defaults values */ -#define BMA180_DEF_PMODE 0 +#define BMA180_DEF_PMODE false #define BMA180_DEF_BW 20 #define BMA180_DEF_SCALE 2452 @@ -80,10 +77,10 @@ struct bma180_data { struct i2c_client *client; struct iio_trigger *trig; struct mutex mutex; - int sleep_state; + bool sleep_state; int scale; int bw; - int pmode; + bool pmode; char *buff; }; @@ -133,7 +130,7 @@ static int bma180_reset_intr(struct bma180_data *data) return ret; } -static int bma180_set_new_data_intr_state(struct bma180_data *data, int state) +static int bma180_set_new_data_intr_state(struct bma180_data *data, bool state) { u8 reg_val = state ? BMA180_NEW_DATA_INT : 0x00; int ret = i2c_smbus_write_byte_data(data->client, BMA180_CTRL_REG3, @@ -153,7 +150,7 @@ err: return ret; } -static int bma180_set_sleep_state(struct bma180_data *data, int state) +static int bma180_set_sleep_state(struct bma180_data *data, bool state) { int ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_SLEEP, state); @@ -167,7 +164,7 @@ static int bma180_set_sleep_state(struct bma180_data *data, int state) return 0; } -static int bma180_set_ee_writing_state(struct bma180_data *data, int state) +static int bma180_set_ee_writing_state(struct bma180_data *data, bool state) { int ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_EE_W, state); @@ -225,7 +222,7 @@ static int bma180_set_scale(struct bma180_data *data, int val) return -EINVAL; } -static int bma180_set_pmode(struct bma180_data *data, int mode) +static int bma180_set_pmode(struct bma180_data *data, bool mode) { u8 reg_val = mode ? BMA180_LOW_POWER : BMA180_LOW_NOISE; int ret = bma180_set_bits(data, BMA180_TCO_Z, BMA180_MODE_CONFIG, @@ -275,10 +272,10 @@ static int bma180_chip_init(struct bma180_data *data) ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_DIS_WAKE_UP, 1); if (ret) goto err; - ret = bma180_set_ee_writing_state(data, 1); + ret = bma180_set_ee_writing_state(data, true); if (ret) goto err; - ret = bma180_set_new_data_intr_state(data, 0); + ret = bma180_set_new_data_intr_state(data, false); if (ret) goto err; ret = bma180_set_bits(data, BMA180_OFFSET_LSB1, BMA180_SMP_SKIP, 1); @@ -303,11 +300,11 @@ err: static void bma180_chip_disable(struct bma180_data *data) { - if (bma180_set_new_data_intr_state(data, 0)) + if (bma180_set_new_data_intr_state(data, false)) goto err; - if (bma180_set_ee_writing_state(data, 0)) + if (bma180_set_ee_writing_state(data, false)) goto err; - if (bma180_set_sleep_state(data, 1)) + if (bma180_set_sleep_state(data, true)) goto err; return; @@ -410,10 +407,7 @@ static const struct iio_info bma180_info = { .driver_module = THIS_MODULE, }; -static const char * const bma180_power_modes[] = { - BMA180_LOW_NOISE_STR, - BMA180_LOW_POWER_STR, -}; +static const char * const bma180_power_modes[] = { "low_noise", "low_power" }; static int bma180_get_power_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) @@ -633,7 +627,7 @@ static int bma180_suspend(struct device *dev) int ret; mutex_lock(&data->mutex); - ret = bma180_set_sleep_state(data, 1); + ret = bma180_set_sleep_state(data, true); mutex_unlock(&data->mutex); return ret; @@ -646,7 +640,7 @@ static int bma180_resume(struct device *dev) int ret; mutex_lock(&data->mutex); - ret = bma180_set_sleep_state(data, 0); + ret = bma180_set_sleep_state(data, false); mutex_unlock(&data->mutex); return ret;