The devices supported by this driver report the model name in their register space. The way this is evaluated allows longer strings than the driver's model list. Document this behaviour in a code comment to lessen the surprise for the next reader. Additionally emit the reported model name in case of a mismatch. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx> --- drivers/hwmon/pmbus/ltc4286.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/pmbus/ltc4286.c b/drivers/hwmon/pmbus/ltc4286.c index 9e7ceeb7e789..2e5532300eff 100644 --- a/drivers/hwmon/pmbus/ltc4286.c +++ b/drivers/hwmon/pmbus/ltc4286.c @@ -95,13 +95,19 @@ static int ltc4286_probe(struct i2c_client *client) "Failed to read manufacturer model\n"); } - for (mid = ltc4286_id; mid->name[0]; mid++) { + for (mid = ltc4286_id; mid->name[0]; mid++) + /* + * Note that by limiting the comparison to strlen(mid->name) + * chars, the device reporting "lTc4286chocolade" is accepted, + * too. + */ if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) break; - } + if (!mid->name[0]) return dev_err_probe(&client->dev, -ENODEV, - "Unsupported device\n"); + "Unsupported device (reported: \"%*pE\")\n", + ret, block_buffer); if (of_property_read_u32(client->dev.of_node, "shunt-resistor-micro-ohms", &rsense)) -- 2.43.0