Skip to content

Commit 5ca29ea

Browse files
vamoiridjic23
authored andcommitted
iio: pressure: Fixes SPI support for BMP3xx devices
Bosch does not use unique BMPxxx_CHIP_ID for the different versions of the device which leads to misidentification of devices if their ID is used. Use a new value in the chip_info structure instead of the BMPxxx_CHIP_ID, in order to choose the correct regmap_bus to be used. Fixes: a9dd9ba ("iio: pressure: Fixes BMP38x and BMP390 SPI support") Signed-off-by: Vasileios Amoiridis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 546a4f4 commit 5ca29ea

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

drivers/iio/pressure/bmp280-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ const struct bmp280_chip_info bmp380_chip_info = {
12331233
.chip_id = bmp380_chip_ids,
12341234
.num_chip_id = ARRAY_SIZE(bmp380_chip_ids),
12351235
.regmap_config = &bmp380_regmap_config,
1236+
.spi_read_extra_byte = true,
12361237
.start_up_time = 2000,
12371238
.channels = bmp380_channels,
12381239
.num_channels = 2,

drivers/iio/pressure/bmp280-spi.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,10 @@ static int bmp280_spi_probe(struct spi_device *spi)
9696

9797
chip_info = spi_get_device_match_data(spi);
9898

99-
switch (chip_info->chip_id[0]) {
100-
case BMP380_CHIP_ID:
101-
case BMP390_CHIP_ID:
99+
if (chip_info->spi_read_extra_byte)
102100
bmp_regmap_bus = &bmp380_regmap_bus;
103-
break;
104-
default:
101+
else
105102
bmp_regmap_bus = &bmp280_regmap_bus;
106-
break;
107-
}
108103

109104
regmap = devm_regmap_init(&spi->dev,
110105
bmp_regmap_bus,

drivers/iio/pressure/bmp280.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ struct bmp280_chip_info {
423423
int num_chip_id;
424424

425425
const struct regmap_config *regmap_config;
426+
bool spi_read_extra_byte;
426427

427428
const struct iio_chan_spec *channels;
428429
int num_channels;

0 commit comments

Comments
 (0)