Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 7366377

Browse files
vamoiridgregkh
authored andcommittedOct 10, 2024
iio: pressure: bmp280: Fix regmap for BMP280 device
commit b9065b0 upstream. Up to now, the BMP280 device is using the regmap of the BME280 which has registers that exist only in the BME280 device. Fixes: 14e8015 ("iio: pressure: bmp280: split driver in logical parts") Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://patch.msgid.link/20240711211558.106327-2-vassilisamir@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e13c9d commit 7366377

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
 

‎drivers/iio/pressure/bmp280-core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ const struct bmp280_chip_info bme280_chip_info = {
882882
.id_reg = BMP280_REG_ID,
883883
.chip_id = bme280_chip_ids,
884884
.num_chip_id = ARRAY_SIZE(bme280_chip_ids),
885-
.regmap_config = &bmp280_regmap_config,
885+
.regmap_config = &bme280_regmap_config,
886886
.start_up_time = 2000,
887887
.channels = bmp280_channels,
888888
.num_channels = 3,

‎drivers/iio/pressure/bmp280-regmap.c

+42-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const struct regmap_config bmp180_regmap_config = {
4141
};
4242
EXPORT_SYMBOL_NS(bmp180_regmap_config, IIO_BMP280);
4343

44-
static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
44+
static bool bme280_is_writeable_reg(struct device *dev, unsigned int reg)
4545
{
4646
switch (reg) {
4747
case BMP280_REG_CONFIG:
@@ -54,7 +54,35 @@ static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
5454
}
5555
}
5656

57+
static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg)
58+
{
59+
switch (reg) {
60+
case BMP280_REG_CONFIG:
61+
case BMP280_REG_CTRL_MEAS:
62+
case BMP280_REG_RESET:
63+
return true;
64+
default:
65+
return false;
66+
}
67+
}
68+
5769
static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
70+
{
71+
switch (reg) {
72+
case BMP280_REG_TEMP_XLSB:
73+
case BMP280_REG_TEMP_LSB:
74+
case BMP280_REG_TEMP_MSB:
75+
case BMP280_REG_PRESS_XLSB:
76+
case BMP280_REG_PRESS_LSB:
77+
case BMP280_REG_PRESS_MSB:
78+
case BMP280_REG_STATUS:
79+
return true;
80+
default:
81+
return false;
82+
}
83+
}
84+
85+
static bool bme280_is_volatile_reg(struct device *dev, unsigned int reg)
5886
{
5987
switch (reg) {
6088
case BME280_REG_HUMIDITY_LSB:
@@ -71,7 +99,6 @@ static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg)
7199
return false;
72100
}
73101
}
74-
75102
static bool bmp380_is_writeable_reg(struct device *dev, unsigned int reg)
76103
{
77104
switch (reg) {
@@ -167,14 +194,26 @@ const struct regmap_config bmp280_regmap_config = {
167194
.reg_bits = 8,
168195
.val_bits = 8,
169196

170-
.max_register = BME280_REG_HUMIDITY_LSB,
197+
.max_register = BMP280_REG_TEMP_XLSB,
171198
.cache_type = REGCACHE_RBTREE,
172199

173200
.writeable_reg = bmp280_is_writeable_reg,
174201
.volatile_reg = bmp280_is_volatile_reg,
175202
};
176203
EXPORT_SYMBOL_NS(bmp280_regmap_config, IIO_BMP280);
177204

205+
const struct regmap_config bme280_regmap_config = {
206+
.reg_bits = 8,
207+
.val_bits = 8,
208+
209+
.max_register = BME280_REG_HUMIDITY_LSB,
210+
.cache_type = REGCACHE_RBTREE,
211+
212+
.writeable_reg = bme280_is_writeable_reg,
213+
.volatile_reg = bme280_is_volatile_reg,
214+
};
215+
EXPORT_SYMBOL_NS(bme280_regmap_config, IIO_BMP280);
216+
178217
const struct regmap_config bmp380_regmap_config = {
179218
.reg_bits = 8,
180219
.val_bits = 8,

‎drivers/iio/pressure/bmp280.h

+1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ extern const struct bmp280_chip_info bmp580_chip_info;
464464
/* Regmap configurations */
465465
extern const struct regmap_config bmp180_regmap_config;
466466
extern const struct regmap_config bmp280_regmap_config;
467+
extern const struct regmap_config bme280_regmap_config;
467468
extern const struct regmap_config bmp380_regmap_config;
468469
extern const struct regmap_config bmp580_regmap_config;
469470

0 commit comments

Comments
 (0)
This repository has been archived.