aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorCorey Minyard <minyard@acm.org>2006-12-10 05:19:08 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-10 12:55:40 -0500
commit1d5636cc078d3750b7f590a20f748aeaa26e2daf (patch)
tree139a8d4ba0e9b93e1cd67ca31c4677447efe6ef1 /drivers
parent0c8204b380f92a6a8533d228c50f0b681daf6121 (diff)
[PATCH] IPMI: misc fixes
Fix various problems pointed out by Andrew Morton and others: * platform_device_unregister checks for NULL, no need to check here. * Formatting fixes. * Remove big macro and convert to a function. * Use strcmp instead of defining a broken case-insensitive comparison, and make the output parameter info match the case of the input one (change "I/O" to "i/o"). * Return the length instead of 0 from the hotmod parameter handler. * Remove some unused cruft. * The trydefaults parameter only has to do with scanning the "standard" addresses, don't check for that on ACPI. Signed-off-by: Corey Minyard <cminyard@acm.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c6
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c120
2 files changed, 68 insertions, 58 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index bfcc6a030a16..4e4691a53890 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2142,8 +2142,7 @@ cleanup_bmc_device(struct kref *ref)
2142 bmc = container_of(ref, struct bmc_device, refcount); 2142 bmc = container_of(ref, struct bmc_device, refcount);
2143 2143
2144 remove_files(bmc); 2144 remove_files(bmc);
2145 if (bmc->dev) 2145 platform_device_unregister(bmc->dev);
2146 platform_device_unregister(bmc->dev);
2147 kfree(bmc); 2146 kfree(bmc);
2148} 2147}
2149 2148
@@ -2341,8 +2340,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
2341 2340
2342 while (ipmi_find_bmc_prod_dev_id(&ipmidriver, 2341 while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
2343 bmc->id.product_id, 2342 bmc->id.product_id,
2344 bmc->id.device_id)) 2343 bmc->id.device_id)) {
2345 {
2346 if (!warn_printed) { 2344 if (!warn_printed) {
2347 printk(KERN_WARNING PFX 2345 printk(KERN_WARNING PFX
2348 "This machine has two different BMCs" 2346 "This machine has two different BMCs"
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 0baa094961a8..f1afd26a509f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1028,7 +1028,7 @@ static int num_slave_addrs;
1028 1028
1029#define IPMI_IO_ADDR_SPACE 0 1029#define IPMI_IO_ADDR_SPACE 0
1030#define IPMI_MEM_ADDR_SPACE 1 1030#define IPMI_MEM_ADDR_SPACE 1
1031static char *addr_space_to_str[] = { "I/O", "mem" }; 1031static char *addr_space_to_str[] = { "i/o", "mem" };
1032 1032
1033static int hotmod_handler(const char *val, struct kernel_param *kp); 1033static int hotmod_handler(const char *val, struct kernel_param *kp);
1034 1034
@@ -1397,20 +1397,7 @@ static struct hotmod_vals hotmod_as[] = {
1397 { "i/o", IPMI_IO_ADDR_SPACE }, 1397 { "i/o", IPMI_IO_ADDR_SPACE },
1398 { NULL } 1398 { NULL }
1399}; 1399};
1400static int ipmi_strcasecmp(const char *s1, const char *s2) 1400
1401{
1402 while (*s1 || *s2) {
1403 if (!*s1)
1404 return -1;
1405 if (!*s2)
1406 return 1;
1407 if (*s1 != *s2)
1408 return *s1 - *s2;
1409 s1++;
1410 s2++;
1411 }
1412 return 0;
1413}
1414static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr) 1401static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1415{ 1402{
1416 char *s; 1403 char *s;
@@ -1424,7 +1411,7 @@ static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1424 *s = '\0'; 1411 *s = '\0';
1425 s++; 1412 s++;
1426 for (i = 0; hotmod_ops[i].name; i++) { 1413 for (i = 0; hotmod_ops[i].name; i++) {
1427 if (ipmi_strcasecmp(*curr, v[i].name) == 0) { 1414 if (strcmp(*curr, v[i].name) == 0) {
1428 *val = v[i].val; 1415 *val = v[i].val;
1429 *curr = s; 1416 *curr = s;
1430 return 0; 1417 return 0;
@@ -1435,10 +1422,34 @@ static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1435 return -EINVAL; 1422 return -EINVAL;
1436} 1423}
1437 1424
1425static int check_hotmod_int_op(const char *curr, const char *option,
1426 const char *name, int *val)
1427{
1428 char *n;
1429
1430 if (strcmp(curr, name) == 0) {
1431 if (!option) {
1432 printk(KERN_WARNING PFX
1433 "No option given for '%s'\n",
1434 curr);
1435 return -EINVAL;
1436 }
1437 *val = simple_strtoul(option, &n, 0);
1438 if ((*n != '\0') || (*option == '\0')) {
1439 printk(KERN_WARNING PFX
1440 "Bad option given for '%s'\n",
1441 curr);
1442 return -EINVAL;
1443 }
1444 return 1;
1445 }
1446 return 0;
1447}
1448
1438static int hotmod_handler(const char *val, struct kernel_param *kp) 1449static int hotmod_handler(const char *val, struct kernel_param *kp)
1439{ 1450{
1440 char *str = kstrdup(val, GFP_KERNEL); 1451 char *str = kstrdup(val, GFP_KERNEL);
1441 int rv = -EINVAL; 1452 int rv;
1442 char *next, *curr, *s, *n, *o; 1453 char *next, *curr, *s, *n, *o;
1443 enum hotmod_op op; 1454 enum hotmod_op op;
1444 enum si_type si_type; 1455 enum si_type si_type;
@@ -1450,13 +1461,15 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
1450 int irq; 1461 int irq;
1451 int ipmb; 1462 int ipmb;
1452 int ival; 1463 int ival;
1464 int len;
1453 struct smi_info *info; 1465 struct smi_info *info;
1454 1466
1455 if (!str) 1467 if (!str)
1456 return -ENOMEM; 1468 return -ENOMEM;
1457 1469
1458 /* Kill any trailing spaces, as we can get a "\n" from echo. */ 1470 /* Kill any trailing spaces, as we can get a "\n" from echo. */
1459 ival = strlen(str) - 1; 1471 len = strlen(str);
1472 ival = len - 1;
1460 while ((ival >= 0) && isspace(str[ival])) { 1473 while ((ival >= 0) && isspace(str[ival])) {
1461 str[ival] = '\0'; 1474 str[ival] = '\0';
1462 ival--; 1475 ival--;
@@ -1513,35 +1526,37 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
1513 *o = '\0'; 1526 *o = '\0';
1514 o++; 1527 o++;
1515 } 1528 }
1516#define HOTMOD_INT_OPT(name, val) \ 1529 rv = check_hotmod_int_op(curr, o, "rsp", &regspacing);
1517 if (ipmi_strcasecmp(curr, name) == 0) { \ 1530 if (rv < 0)
1518 if (!o) { \
1519 printk(KERN_WARNING PFX \
1520 "No option given for '%s'\n", \
1521 curr); \
1522 goto out; \
1523 } \
1524 val = simple_strtoul(o, &n, 0); \
1525 if ((*n != '\0') || (*o == '\0')) { \
1526 printk(KERN_WARNING PFX \
1527 "Bad option given for '%s'\n", \
1528 curr); \
1529 goto out; \
1530 } \
1531 }
1532
1533 HOTMOD_INT_OPT("rsp", regspacing)
1534 else HOTMOD_INT_OPT("rsi", regsize)
1535 else HOTMOD_INT_OPT("rsh", regshift)
1536 else HOTMOD_INT_OPT("irq", irq)
1537 else HOTMOD_INT_OPT("ipmb", ipmb)
1538 else {
1539 printk(KERN_WARNING PFX
1540 "Invalid hotmod option '%s'\n",
1541 curr);
1542 goto out; 1531 goto out;
1543 } 1532 else if (rv)
1544#undef HOTMOD_INT_OPT 1533 continue;
1534 rv = check_hotmod_int_op(curr, o, "rsi", &regsize);
1535 if (rv < 0)
1536 goto out;
1537 else if (rv)
1538 continue;
1539 rv = check_hotmod_int_op(curr, o, "rsh", &regshift);
1540 if (rv < 0)
1541 goto out;
1542 else if (rv)
1543 continue;
1544 rv = check_hotmod_int_op(curr, o, "irq", &irq);
1545 if (rv < 0)
1546 goto out;
1547 else if (rv)
1548 continue;
1549 rv = check_hotmod_int_op(curr, o, "ipmb", &ipmb);
1550 if (rv < 0)
1551 goto out;
1552 else if (rv)
1553 continue;
1554
1555 rv = -EINVAL;
1556 printk(KERN_WARNING PFX
1557 "Invalid hotmod option '%s'\n",
1558 curr);
1559 goto out;
1545 } 1560 }
1546 1561
1547 if (op == HM_ADD) { 1562 if (op == HM_ADD) {
@@ -1590,6 +1605,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
1590 mutex_unlock(&smi_infos_lock); 1605 mutex_unlock(&smi_infos_lock);
1591 } 1606 }
1592 } 1607 }
1608 rv = len;
1593 out: 1609 out:
1594 kfree(str); 1610 kfree(str);
1595 return rv; 1611 return rv;
@@ -1610,11 +1626,11 @@ static __devinit void hardcode_find_bmc(void)
1610 1626
1611 info->addr_source = "hardcoded"; 1627 info->addr_source = "hardcoded";
1612 1628
1613 if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) { 1629 if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
1614 info->si_type = SI_KCS; 1630 info->si_type = SI_KCS;
1615 } else if (ipmi_strcasecmp(si_type[i], "smic") == 0) { 1631 } else if (strcmp(si_type[i], "smic") == 0) {
1616 info->si_type = SI_SMIC; 1632 info->si_type = SI_SMIC;
1617 } else if (ipmi_strcasecmp(si_type[i], "bt") == 0) { 1633 } else if (strcmp(si_type[i], "bt") == 0) {
1618 info->si_type = SI_BT; 1634 info->si_type = SI_BT;
1619 } else { 1635 } else {
1620 printk(KERN_WARNING 1636 printk(KERN_WARNING
@@ -1779,7 +1795,6 @@ struct SPMITable {
1779static __devinit int try_init_acpi(struct SPMITable *spmi) 1795static __devinit int try_init_acpi(struct SPMITable *spmi)
1780{ 1796{
1781 struct smi_info *info; 1797 struct smi_info *info;
1782 char *io_type;
1783 u8 addr_space; 1798 u8 addr_space;
1784 1799
1785 if (spmi->IPMIlegacy != 1) { 1800 if (spmi->IPMIlegacy != 1) {
@@ -1843,11 +1858,9 @@ static __devinit int try_init_acpi(struct SPMITable *spmi)
1843 info->io.regshift = spmi->addr.register_bit_offset; 1858 info->io.regshift = spmi->addr.register_bit_offset;
1844 1859
1845 if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 1860 if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
1846 io_type = "memory";
1847 info->io_setup = mem_setup; 1861 info->io_setup = mem_setup;
1848 info->io.addr_type = IPMI_IO_ADDR_SPACE; 1862 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1849 } else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 1863 } else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
1850 io_type = "I/O";
1851 info->io_setup = port_setup; 1864 info->io_setup = port_setup;
1852 info->io.addr_type = IPMI_MEM_ADDR_SPACE; 1865 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1853 } else { 1866 } else {
@@ -2773,8 +2786,7 @@ static __devinit int init_ipmi_si(void)
2773#endif 2786#endif
2774 2787
2775#ifdef CONFIG_ACPI 2788#ifdef CONFIG_ACPI
2776 if (si_trydefaults) 2789 acpi_find_bmc();
2777 acpi_find_bmc();
2778#endif 2790#endif
2779 2791
2780#ifdef CONFIG_PCI 2792#ifdef CONFIG_PCI