Skip to content

Commit 88f65f9

Browse files
committed
ipmi:ssif: Improve detecting during probing
If an IPMI SSIF device is probed and there is something there, but probably not an actual BMC, the code would just issue a lot of errors before it failed. We kind of need these errors to help with certain issues, and some of the failure reports are non-fatal. However, a get device id command should alway work. If that fails, nothing else is going to work and it's a pretty good indication that there's no valid BMC there. So issue and check that command and bail if it fails. Reported-by: Ivan T. Ivanov <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent 0e38f7e commit 88f65f9

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,20 @@ static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
13681368
rv = do_cmd(client, 2, msg, &len, resp);
13691369
if (rv)
13701370
rv = -ENODEV;
1371-
else
1371+
else {
1372+
if (len < 3) {
1373+
rv = -ENODEV;
1374+
} else {
1375+
struct ipmi_device_id id;
1376+
1377+
rv = ipmi_demangle_device_id(resp[0] >> 2, resp[1],
1378+
resp + 2, len - 2, &id);
1379+
if (rv)
1380+
rv = -ENODEV; /* Error means a BMC probably isn't there. */
1381+
}
1382+
if (!rv && info)
13721383
strscpy(info->type, DEVICE_NAME, I2C_NAME_SIZE);
1384+
}
13731385
kfree(resp);
13741386
return rv;
13751387
}
@@ -1704,6 +1716,16 @@ static int ssif_probe(struct i2c_client *client)
17041716
ipmi_addr_src_to_str(ssif_info->addr_source),
17051717
client->addr, client->adapter->name, slave_addr);
17061718

1719+
/*
1720+
* Send a get device id command and validate its response to
1721+
* make sure a valid BMC is there.
1722+
*/
1723+
rv = ssif_detect(client, NULL);
1724+
if (rv) {
1725+
dev_err(&client->dev, "Not present\n");
1726+
goto out;
1727+
}
1728+
17071729
/* Now check for system interface capabilities */
17081730
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
17091731
msg[1] = IPMI_GET_SYSTEM_INTERFACE_CAPABILITIES_CMD;

0 commit comments

Comments
 (0)