Skip to content

Commit b0e9aaa

Browse files
committed
ipmi:ssif: Ignore spaces when comparing I2C adapter names
Some of the adapters have spaces in their names, but that's really hard to pass in as a module or kernel parameters. So ignore the spaces. Signed-off-by: Corey Minyard <cminyard@mvista.com>
1 parent d467f7a commit b0e9aaa

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Documentation/IPMI.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,10 @@ at module load time (for a module) with:
505505

506506
The addresses are normal I2C addresses. The adapter is the string
507507
name of the adapter, as shown in /sys/class/i2c-adapter/i2c-<n>/name.
508-
It is *NOT* i2c-<n> itself.
508+
It is *NOT* i2c-<n> itself. Also, the comparison is done ignoring
509+
spaces, so if the name is "This is an I2C chip" you can say
510+
adapter_name=ThisisanI2cchip. This is because it's hard to pass in
511+
spaces in kernel parameters.
509512

510513
The debug flags are bit flags for each BMC found, they are:
511514
IPMI messages: 1, driver state: 2, timing: 4, I2C probe: 8

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,23 @@ static const struct file_operations smi_stats_proc_ops = {
12581258
.release = single_release,
12591259
};
12601260

1261+
static int strcmp_nospace(char *s1, char *s2)
1262+
{
1263+
while (*s1 && *s2) {
1264+
while (isspace(*s1))
1265+
s1++;
1266+
while (isspace(*s2))
1267+
s2++;
1268+
if (*s1 > *s2)
1269+
return 1;
1270+
if (*s1 < *s2)
1271+
return -1;
1272+
s1++;
1273+
s2++;
1274+
}
1275+
return 0;
1276+
}
1277+
12611278
static struct ssif_addr_info *ssif_info_find(unsigned short addr,
12621279
char *adapter_name,
12631280
bool match_null_name)
@@ -1272,8 +1289,10 @@ static struct ssif_addr_info *ssif_info_find(unsigned short addr,
12721289
/* One is NULL and one is not */
12731290
continue;
12741291
}
1275-
if (strcmp(info->adapter_name, adapter_name))
1276-
/* Names to not match */
1292+
if (adapter_name &&
1293+
strcmp_nospace(info->adapter_name,
1294+
adapter_name))
1295+
/* Names do not match */
12771296
continue;
12781297
}
12791298
found = info;
@@ -1407,7 +1426,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
14071426
} else {
14081427
no_support:
14091428
/* Assume no multi-part or PEC support */
1410-
pr_info(PFX "Error fetching SSIF: %d %d %2.2x, your system probably doesn't support this command so using defaults\n",
1429+
pr_info(PFX "Error fetching SSIF: %d %d %2.2x, your system probably doesn't support this command so using defaults\n",
14111430
rv, len, resp[2]);
14121431

14131432
ssif_info->max_xmit_msg_size = 32;

0 commit comments

Comments
 (0)