forked from luck/tmp_suning_uos_patched
[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>
This commit is contained in:
parent
0c8204b380
commit
1d5636cc07
@ -2142,8 +2142,7 @@ cleanup_bmc_device(struct kref *ref)
|
|||||||
bmc = container_of(ref, struct bmc_device, refcount);
|
bmc = container_of(ref, struct bmc_device, refcount);
|
||||||
|
|
||||||
remove_files(bmc);
|
remove_files(bmc);
|
||||||
if (bmc->dev)
|
platform_device_unregister(bmc->dev);
|
||||||
platform_device_unregister(bmc->dev);
|
|
||||||
kfree(bmc);
|
kfree(bmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2341,8 +2340,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
|
|||||||
|
|
||||||
while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
|
while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
|
||||||
bmc->id.product_id,
|
bmc->id.product_id,
|
||||||
bmc->id.device_id))
|
bmc->id.device_id)) {
|
||||||
{
|
|
||||||
if (!warn_printed) {
|
if (!warn_printed) {
|
||||||
printk(KERN_WARNING PFX
|
printk(KERN_WARNING PFX
|
||||||
"This machine has two different BMCs"
|
"This machine has two different BMCs"
|
||||||
|
@ -1028,7 +1028,7 @@ static int num_slave_addrs;
|
|||||||
|
|
||||||
#define IPMI_IO_ADDR_SPACE 0
|
#define IPMI_IO_ADDR_SPACE 0
|
||||||
#define IPMI_MEM_ADDR_SPACE 1
|
#define IPMI_MEM_ADDR_SPACE 1
|
||||||
static char *addr_space_to_str[] = { "I/O", "mem" };
|
static char *addr_space_to_str[] = { "i/o", "mem" };
|
||||||
|
|
||||||
static int hotmod_handler(const char *val, struct kernel_param *kp);
|
static int hotmod_handler(const char *val, struct kernel_param *kp);
|
||||||
|
|
||||||
@ -1397,20 +1397,7 @@ static struct hotmod_vals hotmod_as[] = {
|
|||||||
{ "i/o", IPMI_IO_ADDR_SPACE },
|
{ "i/o", IPMI_IO_ADDR_SPACE },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
static int ipmi_strcasecmp(const char *s1, const char *s2)
|
|
||||||
{
|
|
||||||
while (*s1 || *s2) {
|
|
||||||
if (!*s1)
|
|
||||||
return -1;
|
|
||||||
if (!*s2)
|
|
||||||
return 1;
|
|
||||||
if (*s1 != *s2)
|
|
||||||
return *s1 - *s2;
|
|
||||||
s1++;
|
|
||||||
s2++;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
|
static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
@ -1424,7 +1411,7 @@ static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
s++;
|
s++;
|
||||||
for (i = 0; hotmod_ops[i].name; i++) {
|
for (i = 0; hotmod_ops[i].name; i++) {
|
||||||
if (ipmi_strcasecmp(*curr, v[i].name) == 0) {
|
if (strcmp(*curr, v[i].name) == 0) {
|
||||||
*val = v[i].val;
|
*val = v[i].val;
|
||||||
*curr = s;
|
*curr = s;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1435,10 +1422,34 @@ static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int check_hotmod_int_op(const char *curr, const char *option,
|
||||||
|
const char *name, int *val)
|
||||||
|
{
|
||||||
|
char *n;
|
||||||
|
|
||||||
|
if (strcmp(curr, name) == 0) {
|
||||||
|
if (!option) {
|
||||||
|
printk(KERN_WARNING PFX
|
||||||
|
"No option given for '%s'\n",
|
||||||
|
curr);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
*val = simple_strtoul(option, &n, 0);
|
||||||
|
if ((*n != '\0') || (*option == '\0')) {
|
||||||
|
printk(KERN_WARNING PFX
|
||||||
|
"Bad option given for '%s'\n",
|
||||||
|
curr);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int hotmod_handler(const char *val, struct kernel_param *kp)
|
static int hotmod_handler(const char *val, struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
char *str = kstrdup(val, GFP_KERNEL);
|
char *str = kstrdup(val, GFP_KERNEL);
|
||||||
int rv = -EINVAL;
|
int rv;
|
||||||
char *next, *curr, *s, *n, *o;
|
char *next, *curr, *s, *n, *o;
|
||||||
enum hotmod_op op;
|
enum hotmod_op op;
|
||||||
enum si_type si_type;
|
enum si_type si_type;
|
||||||
@ -1450,13 +1461,15 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
|
|||||||
int irq;
|
int irq;
|
||||||
int ipmb;
|
int ipmb;
|
||||||
int ival;
|
int ival;
|
||||||
|
int len;
|
||||||
struct smi_info *info;
|
struct smi_info *info;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Kill any trailing spaces, as we can get a "\n" from echo. */
|
/* Kill any trailing spaces, as we can get a "\n" from echo. */
|
||||||
ival = strlen(str) - 1;
|
len = strlen(str);
|
||||||
|
ival = len - 1;
|
||||||
while ((ival >= 0) && isspace(str[ival])) {
|
while ((ival >= 0) && isspace(str[ival])) {
|
||||||
str[ival] = '\0';
|
str[ival] = '\0';
|
||||||
ival--;
|
ival--;
|
||||||
@ -1513,35 +1526,37 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
|
|||||||
*o = '\0';
|
*o = '\0';
|
||||||
o++;
|
o++;
|
||||||
}
|
}
|
||||||
#define HOTMOD_INT_OPT(name, val) \
|
rv = check_hotmod_int_op(curr, o, "rsp", ®spacing);
|
||||||
if (ipmi_strcasecmp(curr, name) == 0) { \
|
if (rv < 0)
|
||||||
if (!o) { \
|
|
||||||
printk(KERN_WARNING PFX \
|
|
||||||
"No option given for '%s'\n", \
|
|
||||||
curr); \
|
|
||||||
goto out; \
|
|
||||||
} \
|
|
||||||
val = simple_strtoul(o, &n, 0); \
|
|
||||||
if ((*n != '\0') || (*o == '\0')) { \
|
|
||||||
printk(KERN_WARNING PFX \
|
|
||||||
"Bad option given for '%s'\n", \
|
|
||||||
curr); \
|
|
||||||
goto out; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
HOTMOD_INT_OPT("rsp", regspacing)
|
|
||||||
else HOTMOD_INT_OPT("rsi", regsize)
|
|
||||||
else HOTMOD_INT_OPT("rsh", regshift)
|
|
||||||
else HOTMOD_INT_OPT("irq", irq)
|
|
||||||
else HOTMOD_INT_OPT("ipmb", ipmb)
|
|
||||||
else {
|
|
||||||
printk(KERN_WARNING PFX
|
|
||||||
"Invalid hotmod option '%s'\n",
|
|
||||||
curr);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
else if (rv)
|
||||||
#undef HOTMOD_INT_OPT
|
continue;
|
||||||
|
rv = check_hotmod_int_op(curr, o, "rsi", ®size);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out;
|
||||||
|
else if (rv)
|
||||||
|
continue;
|
||||||
|
rv = check_hotmod_int_op(curr, o, "rsh", ®shift);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out;
|
||||||
|
else if (rv)
|
||||||
|
continue;
|
||||||
|
rv = check_hotmod_int_op(curr, o, "irq", &irq);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out;
|
||||||
|
else if (rv)
|
||||||
|
continue;
|
||||||
|
rv = check_hotmod_int_op(curr, o, "ipmb", &ipmb);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out;
|
||||||
|
else if (rv)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rv = -EINVAL;
|
||||||
|
printk(KERN_WARNING PFX
|
||||||
|
"Invalid hotmod option '%s'\n",
|
||||||
|
curr);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == HM_ADD) {
|
if (op == HM_ADD) {
|
||||||
@ -1590,6 +1605,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
|
|||||||
mutex_unlock(&smi_infos_lock);
|
mutex_unlock(&smi_infos_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rv = len;
|
||||||
out:
|
out:
|
||||||
kfree(str);
|
kfree(str);
|
||||||
return rv;
|
return rv;
|
||||||
@ -1610,11 +1626,11 @@ static __devinit void hardcode_find_bmc(void)
|
|||||||
|
|
||||||
info->addr_source = "hardcoded";
|
info->addr_source = "hardcoded";
|
||||||
|
|
||||||
if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) {
|
if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
|
||||||
info->si_type = SI_KCS;
|
info->si_type = SI_KCS;
|
||||||
} else if (ipmi_strcasecmp(si_type[i], "smic") == 0) {
|
} else if (strcmp(si_type[i], "smic") == 0) {
|
||||||
info->si_type = SI_SMIC;
|
info->si_type = SI_SMIC;
|
||||||
} else if (ipmi_strcasecmp(si_type[i], "bt") == 0) {
|
} else if (strcmp(si_type[i], "bt") == 0) {
|
||||||
info->si_type = SI_BT;
|
info->si_type = SI_BT;
|
||||||
} else {
|
} else {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
@ -1779,7 +1795,6 @@ struct SPMITable {
|
|||||||
static __devinit int try_init_acpi(struct SPMITable *spmi)
|
static __devinit int try_init_acpi(struct SPMITable *spmi)
|
||||||
{
|
{
|
||||||
struct smi_info *info;
|
struct smi_info *info;
|
||||||
char *io_type;
|
|
||||||
u8 addr_space;
|
u8 addr_space;
|
||||||
|
|
||||||
if (spmi->IPMIlegacy != 1) {
|
if (spmi->IPMIlegacy != 1) {
|
||||||
@ -1843,11 +1858,9 @@ static __devinit int try_init_acpi(struct SPMITable *spmi)
|
|||||||
info->io.regshift = spmi->addr.register_bit_offset;
|
info->io.regshift = spmi->addr.register_bit_offset;
|
||||||
|
|
||||||
if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
|
if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
|
||||||
io_type = "memory";
|
|
||||||
info->io_setup = mem_setup;
|
info->io_setup = mem_setup;
|
||||||
info->io.addr_type = IPMI_IO_ADDR_SPACE;
|
info->io.addr_type = IPMI_IO_ADDR_SPACE;
|
||||||
} else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
|
} else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
|
||||||
io_type = "I/O";
|
|
||||||
info->io_setup = port_setup;
|
info->io_setup = port_setup;
|
||||||
info->io.addr_type = IPMI_MEM_ADDR_SPACE;
|
info->io.addr_type = IPMI_MEM_ADDR_SPACE;
|
||||||
} else {
|
} else {
|
||||||
@ -2773,8 +2786,7 @@ static __devinit int init_ipmi_si(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI
|
#ifdef CONFIG_ACPI
|
||||||
if (si_trydefaults)
|
acpi_find_bmc();
|
||||||
acpi_find_bmc();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
|
Loading…
Reference in New Issue
Block a user