iio: humidity: hts221: move register definitions to sensor structs

Move some register definitions to hts221_avg_list, hts221_avg_list and
hts221_channels since they are used only there and simplify driver code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Lorenzo Bianconi 2019-12-02 12:23:28 +02:00 committed by Jonathan Cameron
parent cc06e67d8f
commit 09a78f7dfa
1 changed files with 6 additions and 13 deletions

View File

@ -24,13 +24,6 @@
#define HTS221_REG_CNTRL1_ADDR 0x20 #define HTS221_REG_CNTRL1_ADDR 0x20
#define HTS221_REG_CNTRL2_ADDR 0x21 #define HTS221_REG_CNTRL2_ADDR 0x21
#define HTS221_REG_AVG_ADDR 0x10
#define HTS221_REG_H_OUT_L 0x28
#define HTS221_REG_T_OUT_L 0x2a
#define HTS221_HUMIDITY_AVG_MASK 0x07
#define HTS221_TEMP_AVG_MASK 0x38
#define HTS221_ODR_MASK 0x03 #define HTS221_ODR_MASK 0x03
#define HTS221_BDU_MASK BIT(2) #define HTS221_BDU_MASK BIT(2)
#define HTS221_ENABLE_MASK BIT(7) #define HTS221_ENABLE_MASK BIT(7)
@ -66,8 +59,8 @@ static const struct hts221_odr hts221_odr_table[] = {
static const struct hts221_avg hts221_avg_list[] = { static const struct hts221_avg hts221_avg_list[] = {
{ {
.addr = HTS221_REG_AVG_ADDR, .addr = 0x10,
.mask = HTS221_HUMIDITY_AVG_MASK, .mask = 0x07,
.avg_avl = { .avg_avl = {
4, /* 0.4 %RH */ 4, /* 0.4 %RH */
8, /* 0.3 %RH */ 8, /* 0.3 %RH */
@ -80,8 +73,8 @@ static const struct hts221_avg hts221_avg_list[] = {
}, },
}, },
{ {
.addr = HTS221_REG_AVG_ADDR, .addr = 0x10,
.mask = HTS221_TEMP_AVG_MASK, .mask = 0x38,
.avg_avl = { .avg_avl = {
2, /* 0.08 degC */ 2, /* 0.08 degC */
4, /* 0.05 degC */ 4, /* 0.05 degC */
@ -98,7 +91,7 @@ static const struct hts221_avg hts221_avg_list[] = {
static const struct iio_chan_spec hts221_channels[] = { static const struct iio_chan_spec hts221_channels[] = {
{ {
.type = IIO_HUMIDITYRELATIVE, .type = IIO_HUMIDITYRELATIVE,
.address = HTS221_REG_H_OUT_L, .address = 0x28,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SCALE) |
@ -114,7 +107,7 @@ static const struct iio_chan_spec hts221_channels[] = {
}, },
{ {
.type = IIO_TEMP, .type = IIO_TEMP,
.address = HTS221_REG_T_OUT_L, .address = 0x2a,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SCALE) |