Commit 74353ceb authored by Vasileios Amoiridis's avatar Vasileios Amoiridis Committed by Jonathan Cameron

iio: pressure: bmp280: Generalize read_*() functions

Add the coefficients for the IIO standard units and the IIO value
inside the chip_info structure.

Move the calculations for the IIO unit compatibility from inside the
read_{temp,press,humid}() functions and move them to the general
read_raw() function.

In this way, all the data for the calculation of the value are
located in the chip_info structure of the respective sensor.
Signed-off-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Acked-by: default avatarAdam Rizkalla <ajarizzo@gmail.com>
Link: https://patch.msgid.link/20240628171726.124852-2-vassilisamir@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 7c7d9170
This diff is collapsed.
...@@ -446,10 +446,17 @@ struct bmp280_chip_info { ...@@ -446,10 +446,17 @@ struct bmp280_chip_info {
int num_sampling_freq_avail; int num_sampling_freq_avail;
int sampling_freq_default; int sampling_freq_default;
const int *temp_coeffs;
const int temp_coeffs_type;
const int *press_coeffs;
const int press_coeffs_type;
const int *humid_coeffs;
const int humid_coeffs_type;
int (*chip_config)(struct bmp280_data *data); int (*chip_config)(struct bmp280_data *data);
int (*read_temp)(struct bmp280_data *data, int *val, int *val2); int (*read_temp)(struct bmp280_data *data, s32 *adc_temp);
int (*read_press)(struct bmp280_data *data, int *val, int *val2); int (*read_press)(struct bmp280_data *data, u32 *adc_press);
int (*read_humid)(struct bmp280_data *data, int *val, int *val2); int (*read_humid)(struct bmp280_data *data, u32 *adc_humidity);
int (*read_calib)(struct bmp280_data *data); int (*read_calib)(struct bmp280_data *data);
int (*preinit)(struct bmp280_data *data); int (*preinit)(struct bmp280_data *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