From: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
To: lanzano.alex@gmail.com, jic23@kernel.org, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, gustavograzs@gmail.com
Cc: ~lkcamp/patches@lists.sr.ht, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] iio: imu: bmi270: use dev_warn for unexpected chip id
Date: Mon, 16 Mar 2026 20:11:48 -0300 [thread overview]
Message-ID: <20260316232007.22887-1-rodrigo.gobbi.7@gmail.com> (raw)
An unexpected chip id read from hardware indicates a potential
failure for detecting id, which needs a more appropriate level
of verbosity.
Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
---
I was exploring Bosch BMI270 driver and noticed a possible dev_info usage that might
not be appropriate it regarding its verbosity level. Let's consider that probe definition
at [1], used by [2] spi version and [3] i2 version.
The i2c or spi callers will fill chip_info and then, probe will try to validate it at _init function:
// drivers/iio/imu/bmi270/bmi270_core.c
int bmi270_core_probe(struct device *dev, struct regmap *regmap,
const struct bmi270_chip_info *chip_info)
data->chip_info = chip_info;
...
ret = bmi270_chip_init(data);
....
static int bmi270_chip_init(struct bmi270_data *data)
{
int ret;
ret = bmi270_validate_chip_id(data);
if (ret)
return ret;
....
from init, chipid will be read from hardware but if the value is not expected with
the one from the caller, i2c or spi, it will trigger a dev_info and not a warning:
// valid ids for i2c and spi
#define BMI260_CHIP_ID_VAL 0x27
#define BMI270_CHIP_ID_VAL 0x24
static int bmi270_validate_chip_id(struct bmi270_data *data)
{
int chip_id;
int ret;
struct device *dev = data->dev;
struct regmap *regmap = data->regmap;
ret = regmap_read(regmap, BMI270_CHIP_ID_REG, &chip_id);
if (ret)
return dev_err_probe(dev, ret, "Failed to read chip id");
....
if (chip_id != data->chip_info->chip_id)
dev_info(dev, "Unexpected chip id 0x%x", chip_id);
if (chip_id == bmi260_chip_info.chip_id)
data->chip_info = &bmi260_chip_info;
else if (chip_id == bmi270_chip_info.chip_id)
data->chip_info = &bmi270_chip_info;
return 0;
}
The chip_info will be correct due the caller matching DT or ACPI before, and here,
driver is only double-checking the value at hardware and printing if it is not matching.
Printing as info can be confusing, since this is more like a warning than info.
I don't have the hw here to test it, but I'm suggesting to just change the level
of that msg.
Tks and regards.
[1] https://github.com/torvalds/linux/blob/2d1373e4246da3b58e1df058374ed6b101804e07/drivers/iio/imu/bmi270/bmi270_core.c#L1599
[2] https://github.com/torvalds/linux/blob/2d1373e4246da3b58e1df058374ed6b101804e07/drivers/iio/imu/bmi270/bmi270_spi.c#L65
[3] https://github.com/torvalds/linux/blob/2d1373e4246da3b58e1df058374ed6b101804e07/drivers/iio/imu/bmi270/bmi270_i2c.c#L32
---
drivers/iio/imu/bmi270/bmi270_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
index 2ad230788532..a2f90ac22873 100644
--- a/drivers/iio/imu/bmi270/bmi270_core.c
+++ b/drivers/iio/imu/bmi270/bmi270_core.c
@@ -1473,7 +1473,7 @@ static int bmi270_validate_chip_id(struct bmi270_data *data)
return -ENODEV;
if (chip_id != data->chip_info->chip_id)
- dev_info(dev, "Unexpected chip id 0x%x", chip_id);
+ dev_warn(dev, "Unexpected chip id 0x%x", chip_id);
if (chip_id == bmi260_chip_info.chip_id)
data->chip_info = &bmi260_chip_info;
--
2.48.1
next reply other threads:[~2026-03-16 23:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 23:11 Rodrigo Gobbi [this message]
2026-03-17 7:14 ` [PATCH] iio: imu: bmi270: use dev_warn for unexpected chip id Andy Shevchenko
2026-03-17 20:47 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260316232007.22887-1-rodrigo.gobbi.7@gmail.com \
--to=rodrigo.gobbi.7@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gustavograzs@gmail.com \
--cc=jic23@kernel.org \
--cc=lanzano.alex@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=~lkcamp/patches@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox