Commit 439ce896 authored by Vasileios Amoiridis's avatar Vasileios Amoiridis Committed by Jonathan Cameron

iio: pressure: bmp280: Improve indentation and line wrapping

Fix indentations that are not following the standards, remove
extra white lines and add missing white lines.
Signed-off-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240429190046.24252-2-vassilisamir@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 6de2f3a1
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
*/ */
enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD }; enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD };
enum bmp380_odr { enum bmp380_odr {
BMP380_ODR_200HZ, BMP380_ODR_200HZ,
BMP380_ODR_100HZ, BMP380_ODR_100HZ,
...@@ -181,18 +180,19 @@ static int bmp280_read_calib(struct bmp280_data *data) ...@@ -181,18 +180,19 @@ static int bmp280_read_calib(struct bmp280_data *data)
struct bmp280_calib *calib = &data->calib.bmp280; struct bmp280_calib *calib = &data->calib.bmp280;
int ret; int ret;
/* Read temperature and pressure calibration values. */ /* Read temperature and pressure calibration values. */
ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START, ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START,
data->bmp280_cal_buf, sizeof(data->bmp280_cal_buf)); data->bmp280_cal_buf,
sizeof(data->bmp280_cal_buf));
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(data->dev,
"failed to read temperature and pressure calibration parameters\n"); "failed to read calibration parameters\n");
return ret; return ret;
} }
/* Toss the temperature and pressure calibration data into the entropy pool */ /* Toss calibration data into the entropy pool */
add_device_randomness(data->bmp280_cal_buf, sizeof(data->bmp280_cal_buf)); add_device_randomness(data->bmp280_cal_buf,
sizeof(data->bmp280_cal_buf));
/* Parse temperature calibration values. */ /* Parse temperature calibration values. */
calib->T1 = le16_to_cpu(data->bmp280_cal_buf[T1]); calib->T1 = le16_to_cpu(data->bmp280_cal_buf[T1]);
...@@ -223,7 +223,7 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -223,7 +223,7 @@ static int bme280_read_calib(struct bmp280_data *data)
/* Load shared calibration params with bmp280 first */ /* Load shared calibration params with bmp280 first */
ret = bmp280_read_calib(data); ret = bmp280_read_calib(data);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to read common bmp280 calibration parameters\n"); dev_err(dev, "failed to read calibration parameters\n");
return ret; return ret;
} }
...@@ -283,6 +283,7 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -283,6 +283,7 @@ static int bme280_read_calib(struct bmp280_data *data)
return 0; return 0;
} }
/* /*
* Returns humidity in percent, resolution is 0.01 percent. Output value of * Returns humidity in percent, resolution is 0.01 percent. Output value of
* "47445" represents 47445/1024 = 46.333 %RH. * "47445" represents 47445/1024 = 46.333 %RH.
...@@ -305,7 +306,7 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data, ...@@ -305,7 +306,7 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
var = clamp_val(var, 0, 419430400); var = clamp_val(var, 0, 419430400);
return var >> 12; return var >> 12;
}; }
/* /*
* Returns temperature in DegC, resolution is 0.01 DegC. Output value of * Returns temperature in DegC, resolution is 0.01 DegC. Output value of
...@@ -777,8 +778,7 @@ static int bmp280_chip_config(struct bmp280_data *data) ...@@ -777,8 +778,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
BMP280_MODE_MASK, BMP280_MODE_MASK,
osrs | BMP280_MODE_NORMAL); osrs | BMP280_MODE_NORMAL);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(data->dev, "failed to write ctrl_meas register\n");
"failed to write ctrl_meas register\n");
return ret; return ret;
} }
...@@ -786,8 +786,7 @@ static int bmp280_chip_config(struct bmp280_data *data) ...@@ -786,8 +786,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
BMP280_FILTER_MASK, BMP280_FILTER_MASK,
BMP280_FILTER_4X); BMP280_FILTER_4X);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(data->dev, "failed to write config register\n");
"failed to write config register\n");
return ret; return ret;
} }
...@@ -926,8 +925,8 @@ static int bmp380_cmd(struct bmp280_data *data, u8 cmd) ...@@ -926,8 +925,8 @@ static int bmp380_cmd(struct bmp280_data *data, u8 cmd)
} }
/* /*
* Returns temperature in Celsius degrees, resolution is 0.01º C. Output value of * Returns temperature in Celsius degrees, resolution is 0.01º C. Output value
* "5123" equals 51.2º C. t_fine carries fine temperature as global value. * of "5123" equals 51.2º C. t_fine carries fine temperature as global value.
* *
* Taken from datasheet, Section Appendix 9, "Compensation formula" and repo * Taken from datasheet, Section Appendix 9, "Compensation formula" and repo
* https://github.com/BoschSensortec/BMP3-Sensor-API. * https://github.com/BoschSensortec/BMP3-Sensor-API.
...@@ -1069,7 +1068,8 @@ static int bmp380_read_calib(struct bmp280_data *data) ...@@ -1069,7 +1068,8 @@ static int bmp380_read_calib(struct bmp280_data *data)
/* Read temperature and pressure calibration data */ /* Read temperature and pressure calibration data */
ret = regmap_bulk_read(data->regmap, BMP380_REG_CALIB_TEMP_START, ret = regmap_bulk_read(data->regmap, BMP380_REG_CALIB_TEMP_START,
data->bmp380_cal_buf, sizeof(data->bmp380_cal_buf)); data->bmp380_cal_buf,
sizeof(data->bmp380_cal_buf));
if (ret) { if (ret) {
dev_err(data->dev, dev_err(data->dev,
"failed to read temperature calibration parameters\n"); "failed to read temperature calibration parameters\n");
...@@ -1077,7 +1077,8 @@ static int bmp380_read_calib(struct bmp280_data *data) ...@@ -1077,7 +1077,8 @@ static int bmp380_read_calib(struct bmp280_data *data)
} }
/* Toss the temperature calibration data into the entropy pool */ /* Toss the temperature calibration data into the entropy pool */
add_device_randomness(data->bmp380_cal_buf, sizeof(data->bmp380_cal_buf)); add_device_randomness(data->bmp380_cal_buf,
sizeof(data->bmp380_cal_buf));
/* Parse calibration values */ /* Parse calibration values */
calib->T1 = get_unaligned_le16(&data->bmp380_cal_buf[BMP380_T1]); calib->T1 = get_unaligned_le16(&data->bmp380_cal_buf[BMP380_T1]);
...@@ -1159,7 +1160,8 @@ static int bmp380_chip_config(struct bmp280_data *data) ...@@ -1159,7 +1160,8 @@ static int bmp380_chip_config(struct bmp280_data *data)
/* Configure output data rate */ /* Configure output data rate */
ret = regmap_update_bits_check(data->regmap, BMP380_REG_ODR, ret = regmap_update_bits_check(data->regmap, BMP380_REG_ODR,
BMP380_ODRS_MASK, data->sampling_freq, &aux); BMP380_ODRS_MASK, data->sampling_freq,
&aux);
if (ret) { if (ret) {
dev_err(data->dev, "failed to write ODR selection register\n"); dev_err(data->dev, "failed to write ODR selection register\n");
return ret; return ret;
...@@ -1178,12 +1180,13 @@ static int bmp380_chip_config(struct bmp280_data *data) ...@@ -1178,12 +1180,13 @@ static int bmp380_chip_config(struct bmp280_data *data)
if (change) { if (change) {
/* /*
* The configurations errors are detected on the fly during a measurement * The configurations errors are detected on the fly during a
* cycle. If the sampling frequency is too low, it's faster to reset * measurement cycle. If the sampling frequency is too low, it's
* the measurement loop than wait until the next measurement is due. * faster to reset the measurement loop than wait until the next
* measurement is due.
* *
* Resets sensor measurement loop toggling between sleep and normal * Resets sensor measurement loop toggling between sleep and
* operating modes. * normal operating modes.
*/ */
ret = regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL, ret = regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL,
BMP380_MODE_MASK, BMP380_MODE_MASK,
...@@ -1201,17 +1204,16 @@ static int bmp380_chip_config(struct bmp280_data *data) ...@@ -1201,17 +1204,16 @@ static int bmp380_chip_config(struct bmp280_data *data)
return ret; return ret;
} }
/* /*
* Waits for measurement before checking configuration error flag. * Waits for measurement before checking configuration error
* Selected longest measure time indicated in section 3.9.1 * flag. Selected longest measure time indicated in
* in the datasheet. * section 3.9.1 in the datasheet.
*/ */
msleep(80); msleep(80);
/* Check config error flag */ /* Check config error flag */
ret = regmap_read(data->regmap, BMP380_REG_ERROR, &tmp); ret = regmap_read(data->regmap, BMP380_REG_ERROR, &tmp);
if (ret) { if (ret) {
dev_err(data->dev, dev_err(data->dev, "failed to read error register\n");
"failed to read error register\n");
return ret; return ret;
} }
if (tmp & BMP380_ERR_CONF_MASK) { if (tmp & BMP380_ERR_CONF_MASK) {
...@@ -1317,9 +1319,11 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write) ...@@ -1317,9 +1319,11 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
} }
/* Start NVM operation sequence */ /* Start NVM operation sequence */
ret = regmap_write(data->regmap, BMP580_REG_CMD, BMP580_CMD_NVM_OP_SEQ_0); ret = regmap_write(data->regmap, BMP580_REG_CMD,
BMP580_CMD_NVM_OP_SEQ_0);
if (ret) { if (ret) {
dev_err(data->dev, "failed to send nvm operation's first sequence\n"); dev_err(data->dev,
"failed to send nvm operation's first sequence\n");
return ret; return ret;
} }
if (is_write) { if (is_write) {
...@@ -1327,7 +1331,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write) ...@@ -1327,7 +1331,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
ret = regmap_write(data->regmap, BMP580_REG_CMD, ret = regmap_write(data->regmap, BMP580_REG_CMD,
BMP580_CMD_NVM_WRITE_SEQ_1); BMP580_CMD_NVM_WRITE_SEQ_1);
if (ret) { if (ret) {
dev_err(data->dev, "failed to send nvm write sequence\n"); dev_err(data->dev,
"failed to send nvm write sequence\n");
return ret; return ret;
} }
/* Datasheet says on 4.8.1.2 it takes approximately 10ms */ /* Datasheet says on 4.8.1.2 it takes approximately 10ms */
...@@ -1338,7 +1343,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write) ...@@ -1338,7 +1343,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
ret = regmap_write(data->regmap, BMP580_REG_CMD, ret = regmap_write(data->regmap, BMP580_REG_CMD,
BMP580_CMD_NVM_READ_SEQ_1); BMP580_CMD_NVM_READ_SEQ_1);
if (ret) { if (ret) {
dev_err(data->dev, "failed to send nvm read sequence\n"); dev_err(data->dev,
"failed to send nvm read sequence\n");
return ret; return ret;
} }
/* Datasheet says on 4.8.1.1 it takes approximately 200us */ /* Datasheet says on 4.8.1.1 it takes approximately 200us */
...@@ -1501,8 +1507,8 @@ static int bmp580_nvmem_read(void *priv, unsigned int offset, void *val, ...@@ -1501,8 +1507,8 @@ static int bmp580_nvmem_read(void *priv, unsigned int offset, void *val,
if (ret) if (ret)
goto exit; goto exit;
ret = regmap_bulk_read(data->regmap, BMP580_REG_NVM_DATA_LSB, &data->le16, ret = regmap_bulk_read(data->regmap, BMP580_REG_NVM_DATA_LSB,
sizeof(data->le16)); &data->le16, sizeof(data->le16));
if (ret) { if (ret) {
dev_err(data->dev, "error reading nvm data regs\n"); dev_err(data->dev, "error reading nvm data regs\n");
goto exit; goto exit;
...@@ -1546,7 +1552,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val, ...@@ -1546,7 +1552,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
while (bytes >= sizeof(*buf)) { while (bytes >= sizeof(*buf)) {
addr = bmp580_nvmem_addrs[offset / sizeof(*buf)]; addr = bmp580_nvmem_addrs[offset / sizeof(*buf)];
ret = regmap_write(data->regmap, BMP580_REG_NVM_ADDR, BMP580_NVM_PROG_EN | ret = regmap_write(data->regmap, BMP580_REG_NVM_ADDR,
BMP580_NVM_PROG_EN |
FIELD_PREP(BMP580_NVM_ROW_ADDR_MASK, addr)); FIELD_PREP(BMP580_NVM_ROW_ADDR_MASK, addr));
if (ret) { if (ret) {
dev_err(data->dev, "error writing nvm address\n"); dev_err(data->dev, "error writing nvm address\n");
...@@ -1554,8 +1561,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val, ...@@ -1554,8 +1561,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
} }
data->le16 = cpu_to_le16(*buf++); data->le16 = cpu_to_le16(*buf++);
ret = regmap_bulk_write(data->regmap, BMP580_REG_NVM_DATA_LSB, &data->le16, ret = regmap_bulk_write(data->regmap, BMP580_REG_NVM_DATA_LSB,
sizeof(data->le16)); &data->le16, sizeof(data->le16));
if (ret) { if (ret) {
dev_err(data->dev, "error writing LSB NVM data regs\n"); dev_err(data->dev, "error writing LSB NVM data regs\n");
goto exit; goto exit;
...@@ -1662,7 +1669,8 @@ static int bmp580_chip_config(struct bmp280_data *data) ...@@ -1662,7 +1669,8 @@ static int bmp580_chip_config(struct bmp280_data *data)
BMP580_OSR_PRESS_EN; BMP580_OSR_PRESS_EN;
ret = regmap_update_bits_check(data->regmap, BMP580_REG_OSR_CONFIG, ret = regmap_update_bits_check(data->regmap, BMP580_REG_OSR_CONFIG,
BMP580_OSR_TEMP_MASK | BMP580_OSR_PRESS_MASK | BMP580_OSR_TEMP_MASK |
BMP580_OSR_PRESS_MASK |
BMP580_OSR_PRESS_EN, BMP580_OSR_PRESS_EN,
reg_val, &aux); reg_val, &aux);
if (ret) { if (ret) {
...@@ -1713,7 +1721,8 @@ static int bmp580_chip_config(struct bmp280_data *data) ...@@ -1713,7 +1721,8 @@ static int bmp580_chip_config(struct bmp280_data *data)
*/ */
ret = regmap_read(data->regmap, BMP580_REG_EFF_OSR, &tmp); ret = regmap_read(data->regmap, BMP580_REG_EFF_OSR, &tmp);
if (ret) { if (ret) {
dev_err(data->dev, "error reading effective OSR register\n"); dev_err(data->dev,
"error reading effective OSR register\n");
return ret; return ret;
} }
if (!(tmp & BMP580_EFF_OSR_VALID_ODR)) { if (!(tmp & BMP580_EFF_OSR_VALID_ODR)) {
...@@ -1848,7 +1857,8 @@ static int bmp180_read_calib(struct bmp280_data *data) ...@@ -1848,7 +1857,8 @@ static int bmp180_read_calib(struct bmp280_data *data)
} }
/* Toss the calibration data into the entropy pool */ /* Toss the calibration data into the entropy pool */
add_device_randomness(data->bmp180_cal_buf, sizeof(data->bmp180_cal_buf)); add_device_randomness(data->bmp180_cal_buf,
sizeof(data->bmp180_cal_buf));
calib->AC1 = be16_to_cpu(data->bmp180_cal_buf[AC1]); calib->AC1 = be16_to_cpu(data->bmp180_cal_buf[AC1]);
calib->AC2 = be16_to_cpu(data->bmp180_cal_buf[AC2]); calib->AC2 = be16_to_cpu(data->bmp180_cal_buf[AC2]);
...@@ -1963,8 +1973,7 @@ static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press) ...@@ -1963,8 +1973,7 @@ static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press)
return p + ((x1 + x2 + 3791) >> 4); return p + ((x1 + x2 + 3791) >> 4);
} }
static int bmp180_read_press(struct bmp280_data *data, static int bmp180_read_press(struct bmp280_data *data, int *val, int *val2)
int *val, int *val2)
{ {
u32 comp_press; u32 comp_press;
s32 adc_press; s32 adc_press;
...@@ -2241,6 +2250,7 @@ static int bmp280_runtime_resume(struct device *dev) ...@@ -2241,6 +2250,7 @@ static int bmp280_runtime_resume(struct device *dev)
ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies); ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies);
if (ret) if (ret)
return ret; return ret;
usleep_range(data->start_up_time, data->start_up_time + 100); usleep_range(data->start_up_time, data->start_up_time + 100);
return data->chip_info->chip_config(data); return data->chip_info->chip_config(data);
} }
......
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