Commit a95ccebd authored by Crt Mori's avatar Crt Mori Committed by Jonathan Cameron

iio: temperature: mlx90632 Style alignment for the driver

Changing and aligning the overall style of the driver with the recent
reviews. There is no functional change, only type generalization and
moving to the reverse Christmas tree for variable declarations.
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarCrt Mori <cmo@melexis.com>
Link: https://lore.kernel.org/r/d59aad00891c1a64e044a0f5bc7d40e42d47e9c7.1666606912.git.cmo@melexis.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 2ca0b16f
...@@ -219,11 +219,11 @@ static const struct regmap_config mlx90632_regmap = { ...@@ -219,11 +219,11 @@ static const struct regmap_config mlx90632_regmap = {
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
}; };
static s32 mlx90632_pwr_set_sleep_step(struct regmap *regmap) static int mlx90632_pwr_set_sleep_step(struct regmap *regmap)
{ {
struct mlx90632_data *data = struct mlx90632_data *data =
iio_priv(dev_get_drvdata(regmap_get_device(regmap))); iio_priv(dev_get_drvdata(regmap_get_device(regmap)));
s32 ret; int ret;
if (data->powerstatus == MLX90632_PWR_STATUS_SLEEP_STEP) if (data->powerstatus == MLX90632_PWR_STATUS_SLEEP_STEP)
return 0; return 0;
...@@ -234,14 +234,14 @@ static s32 mlx90632_pwr_set_sleep_step(struct regmap *regmap) ...@@ -234,14 +234,14 @@ static s32 mlx90632_pwr_set_sleep_step(struct regmap *regmap)
return ret; return ret;
data->powerstatus = MLX90632_PWR_STATUS_SLEEP_STEP; data->powerstatus = MLX90632_PWR_STATUS_SLEEP_STEP;
return ret; return 0;
} }
static s32 mlx90632_pwr_continuous(struct regmap *regmap) static int mlx90632_pwr_continuous(struct regmap *regmap)
{ {
struct mlx90632_data *data = struct mlx90632_data *data =
iio_priv(dev_get_drvdata(regmap_get_device(regmap))); iio_priv(dev_get_drvdata(regmap_get_device(regmap)));
s32 ret; int ret;
if (data->powerstatus == MLX90632_PWR_STATUS_CONTINUOUS) if (data->powerstatus == MLX90632_PWR_STATUS_CONTINUOUS)
return 0; return 0;
...@@ -252,7 +252,7 @@ static s32 mlx90632_pwr_continuous(struct regmap *regmap) ...@@ -252,7 +252,7 @@ static s32 mlx90632_pwr_continuous(struct regmap *regmap)
return ret; return ret;
data->powerstatus = MLX90632_PWR_STATUS_CONTINUOUS; data->powerstatus = MLX90632_PWR_STATUS_CONTINUOUS;
return ret; return 0;
} }
/** /**
...@@ -444,8 +444,8 @@ static int mlx90632_channel_new_select(int perform_ret, uint8_t *channel_new, ...@@ -444,8 +444,8 @@ static int mlx90632_channel_new_select(int perform_ret, uint8_t *channel_new,
static int mlx90632_read_ambient_raw(struct regmap *regmap, static int mlx90632_read_ambient_raw(struct regmap *regmap,
s16 *ambient_new_raw, s16 *ambient_old_raw) s16 *ambient_new_raw, s16 *ambient_old_raw)
{ {
int ret;
unsigned int read_tmp; unsigned int read_tmp;
int ret;
ret = regmap_read(regmap, MLX90632_RAM_3(1), &read_tmp); ret = regmap_read(regmap, MLX90632_RAM_3(1), &read_tmp);
if (ret < 0) if (ret < 0)
...@@ -464,11 +464,11 @@ static int mlx90632_read_object_raw(struct regmap *regmap, ...@@ -464,11 +464,11 @@ static int mlx90632_read_object_raw(struct regmap *regmap,
int perform_measurement_ret, int perform_measurement_ret,
s16 *object_new_raw, s16 *object_old_raw) s16 *object_new_raw, s16 *object_old_raw)
{ {
int ret;
unsigned int read_tmp; unsigned int read_tmp;
s16 read;
u8 channel = 0;
u8 channel_old = 0; u8 channel_old = 0;
u8 channel = 0;
s16 read;
int ret;
ret = mlx90632_channel_new_select(perform_measurement_ret, &channel, ret = mlx90632_channel_new_select(perform_measurement_ret, &channel,
&channel_old); &channel_old);
...@@ -503,7 +503,8 @@ static int mlx90632_read_all_channel(struct mlx90632_data *data, ...@@ -503,7 +503,8 @@ static int mlx90632_read_all_channel(struct mlx90632_data *data,
s16 *ambient_new_raw, s16 *ambient_old_raw, s16 *ambient_new_raw, s16 *ambient_old_raw,
s16 *object_new_raw, s16 *object_old_raw) s16 *object_new_raw, s16 *object_old_raw)
{ {
s32 ret, measurement; s32 measurement;
int ret;
mutex_lock(&data->lock); mutex_lock(&data->lock);
ret = mlx90632_set_meas_type(data, MLX90632_MTYP_MEDICAL); ret = mlx90632_set_meas_type(data, MLX90632_MTYP_MEDICAL);
...@@ -512,24 +513,24 @@ static int mlx90632_read_all_channel(struct mlx90632_data *data, ...@@ -512,24 +513,24 @@ static int mlx90632_read_all_channel(struct mlx90632_data *data,
switch (data->powerstatus) { switch (data->powerstatus) {
case MLX90632_PWR_STATUS_CONTINUOUS: case MLX90632_PWR_STATUS_CONTINUOUS:
measurement = mlx90632_perform_measurement(data); ret = mlx90632_perform_measurement(data);
if (measurement < 0) { if (ret < 0)
ret = measurement;
goto read_unlock; goto read_unlock;
}
break; break;
case MLX90632_PWR_STATUS_SLEEP_STEP: case MLX90632_PWR_STATUS_SLEEP_STEP:
measurement = mlx90632_perform_measurement_burst(data); ret = mlx90632_perform_measurement_burst(data);
if (measurement < 0) { if (ret < 0)
ret = measurement;
goto read_unlock; goto read_unlock;
}
break; break;
default: default:
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto read_unlock; goto read_unlock;
} }
measurement = ret; /* If we came here ret holds the measurement position */
ret = mlx90632_read_ambient_raw(data->regmap, ambient_new_raw, ret = mlx90632_read_ambient_raw(data->regmap, ambient_new_raw,
ambient_old_raw); ambient_old_raw);
if (ret < 0) if (ret < 0)
...@@ -615,15 +616,21 @@ static int mlx90632_read_all_channel_extended(struct mlx90632_data *data, s16 *o ...@@ -615,15 +616,21 @@ static int mlx90632_read_all_channel_extended(struct mlx90632_data *data, s16 *o
if (ret < 0) if (ret < 0)
goto read_unlock; goto read_unlock;
if (data->powerstatus == MLX90632_PWR_STATUS_CONTINUOUS) { switch (data->powerstatus) {
case MLX90632_PWR_STATUS_CONTINUOUS:
ret = read_poll_timeout(mlx90632_perform_measurement, meas, meas == 19, ret = read_poll_timeout(mlx90632_perform_measurement, meas, meas == 19,
50000, 800000, false, data); 50000, 800000, false, data);
if (ret) if (ret)
goto read_unlock; goto read_unlock;
} else if (data->powerstatus == MLX90632_PWR_STATUS_SLEEP_STEP) { break;
case MLX90632_PWR_STATUS_SLEEP_STEP:
ret = mlx90632_perform_measurement_burst(data); ret = mlx90632_perform_measurement_burst(data);
if (ret < 0) if (ret < 0)
goto read_unlock; goto read_unlock;
break;
default:
ret = -EOPNOTSUPP;
goto read_unlock;
} }
ret = mlx90632_read_object_raw_extended(data->regmap, object_new_raw); ret = mlx90632_read_object_raw_extended(data->regmap, object_new_raw);
...@@ -640,9 +647,9 @@ static int mlx90632_read_all_channel_extended(struct mlx90632_data *data, s16 *o ...@@ -640,9 +647,9 @@ static int mlx90632_read_all_channel_extended(struct mlx90632_data *data, s16 *o
static int mlx90632_read_ee_register(struct regmap *regmap, u16 reg_lsb, static int mlx90632_read_ee_register(struct regmap *regmap, u16 reg_lsb,
s32 *reg_value) s32 *reg_value)
{ {
s32 ret;
unsigned int read; unsigned int read;
u32 value; u32 value;
int ret;
ret = regmap_read(regmap, reg_lsb, &read); ret = regmap_read(regmap, reg_lsb, &read);
if (ret < 0) if (ret < 0)
...@@ -806,12 +813,12 @@ static s32 mlx90632_calc_temp_object_extended(s64 object, s64 ambient, s64 refle ...@@ -806,12 +813,12 @@ static s32 mlx90632_calc_temp_object_extended(s64 object, s64 ambient, s64 refle
static int mlx90632_calc_object_dsp105(struct mlx90632_data *data, int *val) static int mlx90632_calc_object_dsp105(struct mlx90632_data *data, int *val)
{ {
s32 ret; s16 ambient_new_raw, ambient_old_raw, object_new_raw, object_old_raw;
s32 Ea, Eb, Fa, Fb, Ga; s32 Ea, Eb, Fa, Fb, Ga;
unsigned int read_tmp; unsigned int read_tmp;
s16 Ha, Hb, Gb, Ka;
s16 ambient_new_raw, ambient_old_raw, object_new_raw, object_old_raw;
s64 object, ambient; s64 object, ambient;
s16 Ha, Hb, Gb, Ka;
int ret;
ret = mlx90632_read_ee_register(data->regmap, MLX90632_EE_Ea, &Ea); ret = mlx90632_read_ee_register(data->regmap, MLX90632_EE_Ea, &Ea);
if (ret < 0) if (ret < 0)
...@@ -885,11 +892,11 @@ static int mlx90632_calc_object_dsp105(struct mlx90632_data *data, int *val) ...@@ -885,11 +892,11 @@ static int mlx90632_calc_object_dsp105(struct mlx90632_data *data, int *val)
static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val) static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
{ {
s32 ret; s16 ambient_new_raw, ambient_old_raw;
unsigned int read_tmp; unsigned int read_tmp;
s32 PT, PR, PG, PO; s32 PT, PR, PG, PO;
int ret;
s16 Gb; s16 Gb;
s16 ambient_new_raw, ambient_old_raw;
ret = mlx90632_read_ee_register(data->regmap, MLX90632_EE_P_R, &PR); ret = mlx90632_read_ee_register(data->regmap, MLX90632_EE_P_R, &PR);
if (ret < 0) if (ret < 0)
...@@ -1164,11 +1171,11 @@ static int mlx90632_enable_regulator(struct mlx90632_data *data) ...@@ -1164,11 +1171,11 @@ static int mlx90632_enable_regulator(struct mlx90632_data *data)
static int mlx90632_probe(struct i2c_client *client, static int mlx90632_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct iio_dev *indio_dev;
struct mlx90632_data *mlx90632; struct mlx90632_data *mlx90632;
struct iio_dev *indio_dev;
struct regmap *regmap; struct regmap *regmap;
int ret;
unsigned int read; unsigned int read;
int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*mlx90632)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*mlx90632));
if (!indio_dev) { if (!indio_dev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment