Commit 6fa09d31 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-5.13-1' of git://github.com/cminyard/linux-ipmi

Pull IPMI updates from Corey Minyard:
 "A bunch of little cleanups

  Nothing major, no functional changes"

* tag 'for-linus-5.13-1' of git://github.com/cminyard/linux-ipmi:
  ipmi_si: Join string literals back
  ipmi_si: Drop redundant check before calling put_device()
  ipmi_si: Use strstrip() to remove surrounding spaces
  ipmi_si: Get rid of ->addr_source_cleanup()
  ipmi_si: Reuse si_to_str[] array in ipmi_hardcode_init_one()
  ipmi_si: Introduce ipmi_panic_event_str[] array
  ipmi_si: Use proper ACPI macros to check error code for failures
  ipmi_si: Utilize temporary variable to hold device pointer
  ipmi_si: Remove bogus err_free label
  ipmi_si: Switch to use platform_get_mem_or_io()
  ipmi: Handle device properties with software node API
  ipmi:ssif: make ssif_i2c_send() void
  ipmi: Refine retry conditions for getting device id
parents 0080665f 07cbd87b
...@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf, ...@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
static bool initialized; static bool initialized;
static bool drvregistered; static bool drvregistered;
/* Numbers in this enumerator should be mapped to ipmi_panic_event_str */
enum ipmi_panic_event_op { enum ipmi_panic_event_op {
IPMI_SEND_PANIC_EVENT_NONE, IPMI_SEND_PANIC_EVENT_NONE,
IPMI_SEND_PANIC_EVENT, IPMI_SEND_PANIC_EVENT,
IPMI_SEND_PANIC_EVENT_STRING IPMI_SEND_PANIC_EVENT_STRING,
IPMI_SEND_PANIC_EVENT_MAX
}; };
/* Indices in this array should be mapped to enum ipmi_panic_event_op */
static const char *const ipmi_panic_event_str[] = { "none", "event", "string", NULL };
#ifdef CONFIG_IPMI_PANIC_STRING #ifdef CONFIG_IPMI_PANIC_STRING
#define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING #define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING
#elif defined(CONFIG_IPMI_PANIC_EVENT) #elif defined(CONFIG_IPMI_PANIC_EVENT)
...@@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val, ...@@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
char valcp[16]; char valcp[16];
char *s; int e;
strncpy(valcp, val, 15);
valcp[15] = '\0';
s = strstrip(valcp); strscpy(valcp, val, sizeof(valcp));
e = match_string(ipmi_panic_event_str, -1, strstrip(valcp));
if (strcmp(s, "none") == 0) if (e < 0)
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE; return e;
else if (strcmp(s, "event") == 0)
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT;
else if (strcmp(s, "string") == 0)
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_STRING;
else
return -EINVAL;
ipmi_send_panic_event = e;
return 0; return 0;
} }
static int panic_op_read_handler(char *buffer, const struct kernel_param *kp) static int panic_op_read_handler(char *buffer, const struct kernel_param *kp)
{ {
switch (ipmi_send_panic_event) { const char *event_str;
case IPMI_SEND_PANIC_EVENT_NONE:
strcpy(buffer, "none\n");
break;
case IPMI_SEND_PANIC_EVENT:
strcpy(buffer, "event\n");
break;
case IPMI_SEND_PANIC_EVENT_STRING:
strcpy(buffer, "string\n");
break;
default: if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX)
strcpy(buffer, "???\n"); event_str = "???";
break; else
} event_str = ipmi_panic_event_str[ipmi_send_panic_event];
return strlen(buffer); return sprintf(buffer, "%s\n", event_str);
} }
static const struct kernel_param_ops panic_op_ops = { static const struct kernel_param_ops panic_op_ops = {
...@@ -2447,10 +2434,8 @@ static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) ...@@ -2447,10 +2434,8 @@ static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc)
wait_event(intf->waitq, bmc->dyn_id_set != 2); wait_event(intf->waitq, bmc->dyn_id_set != 2);
if (!bmc->dyn_id_set) { if (!bmc->dyn_id_set) {
if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR if (bmc->cc != IPMI_CC_NO_ERROR &&
|| bmc->cc == IPMI_DEVICE_IN_INIT_ERR ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
|| bmc->cc == IPMI_NOT_IN_MY_STATE_ERR)
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
msleep(500); msleep(500);
dev_warn(intf->si_dev, dev_warn(intf->si_dev,
"BMC returned 0x%2.2x, retry get bmc device id\n", "BMC returned 0x%2.2x, retry get bmc device id\n",
...@@ -5224,7 +5209,6 @@ module_exit(cleanup_ipmi); ...@@ -5224,7 +5209,6 @@ module_exit(cleanup_ipmi);
module_init(ipmi_init_msghandler_mod); module_init(ipmi_init_msghandler_mod);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI" MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface.");
" interface.");
MODULE_VERSION(IPMI_DRIVER_VERSION); MODULE_VERSION(IPMI_DRIVER_VERSION);
MODULE_SOFTDEP("post: ipmi_devintf"); MODULE_SOFTDEP("post: ipmi_devintf");
...@@ -102,7 +102,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst, ...@@ -102,7 +102,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst,
goto err; goto err;
} }
add_properties: add_properties:
rv = platform_device_add_properties(pdev, pr); rv = device_create_managed_software_node(&pdev->dev, pr, NULL);
if (rv) { if (rv) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to add hard-code properties: %d\n", rv); "Unable to add hard-code properties: %d\n", rv);
......
...@@ -18,10 +18,14 @@ ...@@ -18,10 +18,14 @@
#define DEFAULT_REGSPACING 1 #define DEFAULT_REGSPACING 1
#define DEFAULT_REGSIZE 1 #define DEFAULT_REGSIZE 1
/* Numbers in this enumerator should be mapped to si_to_str[] */
enum si_type { enum si_type {
SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
}; };
/* Array is defined in the ipmi_si_intf.c */
extern const char *const si_to_str[];
enum ipmi_addr_space { enum ipmi_addr_space {
IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
}; };
...@@ -48,8 +52,6 @@ struct si_sm_io { ...@@ -48,8 +52,6 @@ struct si_sm_io {
enum ipmi_addr_space addr_space; enum ipmi_addr_space addr_space;
unsigned long addr_data; unsigned long addr_data;
enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */ enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
void (*addr_source_cleanup)(struct si_sm_io *io);
void *addr_source_data;
union ipmi_smi_info_union addr_info; union ipmi_smi_info_union addr_info;
int (*io_setup)(struct si_sm_io *info); int (*io_setup)(struct si_sm_io *info);
......
...@@ -32,47 +32,29 @@ static int slave_addrs[SI_MAX_PARMS] __initdata; ...@@ -32,47 +32,29 @@ static int slave_addrs[SI_MAX_PARMS] __initdata;
static unsigned int num_slave_addrs __initdata; static unsigned int num_slave_addrs __initdata;
module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0); module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0);
MODULE_PARM_DESC(type, "Defines the type of each interface, each" MODULE_PARM_DESC(type,
" interface separated by commas. The types are 'kcs'," "Defines the type of each interface, each interface separated by commas. The types are 'kcs', 'smic', and 'bt'. For example si_type=kcs,bt will set the first interface to kcs and the second to bt");
" 'smic', and 'bt'. For example si_type=kcs,bt will set"
" the first interface to kcs and the second to bt");
module_param_hw_array(addrs, ulong, iomem, &num_addrs, 0); module_param_hw_array(addrs, ulong, iomem, &num_addrs, 0);
MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the" MODULE_PARM_DESC(addrs,
" addresses separated by commas. Only use if an interface" "Sets the memory address of each interface, the addresses separated by commas. Only use if an interface is in memory. Otherwise, set it to zero or leave it blank.");
" is in memory. Otherwise, set it to zero or leave"
" it blank.");
module_param_hw_array(ports, uint, ioport, &num_ports, 0); module_param_hw_array(ports, uint, ioport, &num_ports, 0);
MODULE_PARM_DESC(ports, "Sets the port address of each interface, the" MODULE_PARM_DESC(ports,
" addresses separated by commas. Only use if an interface" "Sets the port address of each interface, the addresses separated by commas. Only use if an interface is a port. Otherwise, set it to zero or leave it blank.");
" is a port. Otherwise, set it to zero or leave"
" it blank.");
module_param_hw_array(irqs, int, irq, &num_irqs, 0); module_param_hw_array(irqs, int, irq, &num_irqs, 0);
MODULE_PARM_DESC(irqs, "Sets the interrupt of each interface, the" MODULE_PARM_DESC(irqs,
" addresses separated by commas. Only use if an interface" "Sets the interrupt of each interface, the addresses separated by commas. Only use if an interface has an interrupt. Otherwise, set it to zero or leave it blank.");
" has an interrupt. Otherwise, set it to zero or leave"
" it blank.");
module_param_hw_array(regspacings, int, other, &num_regspacings, 0); module_param_hw_array(regspacings, int, other, &num_regspacings, 0);
MODULE_PARM_DESC(regspacings, "The number of bytes between the start address" MODULE_PARM_DESC(regspacings,
" and each successive register used by the interface. For" "The number of bytes between the start address and each successive register used by the interface. For instance, if the start address is 0xca2 and the spacing is 2, then the second address is at 0xca4. Defaults to 1.");
" instance, if the start address is 0xca2 and the spacing"
" is 2, then the second address is at 0xca4. Defaults"
" to 1.");
module_param_hw_array(regsizes, int, other, &num_regsizes, 0); module_param_hw_array(regsizes, int, other, &num_regsizes, 0);
MODULE_PARM_DESC(regsizes, "The size of the specific IPMI register in bytes." MODULE_PARM_DESC(regsizes,
" This should generally be 1, 2, 4, or 8 for an 8-bit," "The size of the specific IPMI register in bytes. This should generally be 1, 2, 4, or 8 for an 8-bit, 16-bit, 32-bit, or 64-bit register. Use this if you the 8-bit IPMI register has to be read from a larger register.");
" 16-bit, 32-bit, or 64-bit register. Use this if you"
" the 8-bit IPMI register has to be read from a larger"
" register.");
module_param_hw_array(regshifts, int, other, &num_regshifts, 0); module_param_hw_array(regshifts, int, other, &num_regshifts, 0);
MODULE_PARM_DESC(regshifts, "The amount to shift the data read from the." MODULE_PARM_DESC(regshifts,
" IPMI register, in bits. For instance, if the data" "The amount to shift the data read from the. IPMI register, in bits. For instance, if the data is read from a 32-bit word and the IPMI data is in bit 8-15, then the shift would be 8");
" is read from a 32-bit word and the IPMI data is in"
" bit 8-15, then the shift would be 8");
module_param_hw_array(slave_addrs, int, other, &num_slave_addrs, 0); module_param_hw_array(slave_addrs, int, other, &num_slave_addrs, 0);
MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for" MODULE_PARM_DESC(slave_addrs,
" the controller. Normally this is 0x20, but can be" "Set the default IPMB slave address for the controller. Normally this is 0x20, but can be overridden by this parm. This is an array indexed by interface number.");
" overridden by this parm. This is an array indexed"
" by interface number.");
static void __init ipmi_hardcode_init_one(const char *si_type_str, static void __init ipmi_hardcode_init_one(const char *si_type_str,
unsigned int i, unsigned int i,
...@@ -80,26 +62,21 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str, ...@@ -80,26 +62,21 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
enum ipmi_addr_space addr_space) enum ipmi_addr_space addr_space)
{ {
struct ipmi_plat_data p; struct ipmi_plat_data p;
int t;
memset(&p, 0, sizeof(p)); memset(&p, 0, sizeof(p));
p.iftype = IPMI_PLAT_IF_SI; p.iftype = IPMI_PLAT_IF_SI;
if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) { if (!si_type_str || !*si_type_str) {
p.type = SI_KCS; p.type = SI_KCS;
} else if (strcmp(si_type_str, "smic") == 0) {
p.type = SI_SMIC;
} else if (strcmp(si_type_str, "bt") == 0) {
p.type = SI_BT;
} else if (strcmp(si_type_str, "invalid") == 0) {
/*
* Allow a firmware-specified interface to be
* disabled.
*/
p.type = SI_TYPE_INVALID;
} else { } else {
pr_warn("Interface type specified for interface %d, was invalid: %s\n", t = match_string(si_to_str, -1, si_type_str);
i, si_type_str); if (t < 0) {
return; pr_warn("Interface type specified for interface %d, was invalid: %s\n",
i, si_type_str);
return;
}
p.type = t;
} }
p.regsize = regsizes[i]; p.regsize = regsizes[i];
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
static int hotmod_handler(const char *val, const struct kernel_param *kp); static int hotmod_handler(const char *val, const struct kernel_param *kp);
module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200); module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
MODULE_PARM_DESC(hotmod, "Add and remove interfaces. See" MODULE_PARM_DESC(hotmod,
" Documentation/driver-api/ipmi.rst in the kernel sources for the" "Add and remove interfaces. See Documentation/driver-api/ipmi.rst in the kernel sources for the gory details.");
" gory details.");
/* /*
* Parms come in as <op1>[:op2[:op3...]]. ops are: * Parms come in as <op1>[:op2[:op3...]]. ops are:
...@@ -185,24 +184,16 @@ static atomic_t hotmod_nr; ...@@ -185,24 +184,16 @@ static atomic_t hotmod_nr;
static int hotmod_handler(const char *val, const struct kernel_param *kp) static int hotmod_handler(const char *val, const struct kernel_param *kp)
{ {
char *str = kstrdup(val, GFP_KERNEL), *curr, *next;
int rv; int rv;
struct ipmi_plat_data h; struct ipmi_plat_data h;
unsigned int len; char *str, *curr, *next;
int ival;
str = kstrdup(val, GFP_KERNEL);
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. */
len = strlen(str); for (curr = strstrip(str); curr; curr = next) {
ival = len - 1;
while ((ival >= 0) && isspace(str[ival])) {
str[ival] = '\0';
ival--;
}
for (curr = str; curr; curr = next) {
enum hotmod_op op; enum hotmod_op op;
next = strchr(curr, ':'); next = strchr(curr, ':');
...@@ -231,11 +222,10 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp) ...@@ -231,11 +222,10 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
if (strcmp(pdev->name, "hotmod-ipmi-si") == 0) if (strcmp(pdev->name, "hotmod-ipmi-si") == 0)
platform_device_unregister(pdev); platform_device_unregister(pdev);
} }
if (dev) put_device(dev);
put_device(dev);
} }
} }
rv = len; rv = strlen(val);
out: out:
kfree(str); kfree(str);
return rv; return rv;
......
...@@ -70,7 +70,8 @@ enum si_intf_state { ...@@ -70,7 +70,8 @@ enum si_intf_state {
#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2 #define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
#define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1 #define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
static const char * const si_to_str[] = { "invalid", "kcs", "smic", "bt" }; /* 'invalid' to allow a firmware-specified interface to be disabled */
const char *const si_to_str[] = { "invalid", "kcs", "smic", "bt", NULL };
static bool initialized; static bool initialized;
...@@ -1169,9 +1170,8 @@ static int smi_start_processing(void *send_info, ...@@ -1169,9 +1170,8 @@ static int smi_start_processing(void *send_info,
new_smi->thread = kthread_run(ipmi_thread, new_smi, new_smi->thread = kthread_run(ipmi_thread, new_smi,
"kipmi%d", new_smi->si_num); "kipmi%d", new_smi->si_num);
if (IS_ERR(new_smi->thread)) { if (IS_ERR(new_smi->thread)) {
dev_notice(new_smi->io.dev, "Could not start" dev_notice(new_smi->io.dev,
" kernel thread due to error %ld, only using" "Could not start kernel thread due to error %ld, only using timers to drive the interface\n",
" timers to drive the interface\n",
PTR_ERR(new_smi->thread)); PTR_ERR(new_smi->thread));
new_smi->thread = NULL; new_smi->thread = NULL;
} }
...@@ -1223,18 +1223,14 @@ static int smi_num; /* Used to sequence the SMIs */ ...@@ -1223,18 +1223,14 @@ static int smi_num; /* Used to sequence the SMIs */
static const char * const addr_space_to_str[] = { "i/o", "mem" }; static const char * const addr_space_to_str[] = { "i/o", "mem" };
module_param_array(force_kipmid, int, &num_force_kipmid, 0); module_param_array(force_kipmid, int, &num_force_kipmid, 0);
MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or" MODULE_PARM_DESC(force_kipmid,
" disabled(0). Normally the IPMI driver auto-detects" "Force the kipmi daemon to be enabled (1) or disabled(0). Normally the IPMI driver auto-detects this, but the value may be overridden by this parm.");
" this, but the value may be overridden by this parm.");
module_param(unload_when_empty, bool, 0); module_param(unload_when_empty, bool, 0);
MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" MODULE_PARM_DESC(unload_when_empty,
" specified or found, default is 1. Setting to 0" "Unload the module if no interfaces are specified or found, default is 1. Setting to 0 is useful for hot add of devices using hotmod.");
" is useful for hot add of devices using hotmod.");
module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644);
MODULE_PARM_DESC(kipmid_max_busy_us, MODULE_PARM_DESC(kipmid_max_busy_us,
"Max time (in microseconds) to busy-wait for IPMI data before" "Max time (in microseconds) to busy-wait for IPMI data before sleeping. 0 (default) means to wait forever. Set to 100-500 if kipmid is using up a lot of CPU time.");
" sleeping. 0 (default) means to wait forever. Set to 100-500"
" if kipmid is using up a lot of CPU time.");
void ipmi_irq_finish_setup(struct si_sm_io *io) void ipmi_irq_finish_setup(struct si_sm_io *io)
{ {
...@@ -1270,8 +1266,7 @@ int ipmi_std_irq_setup(struct si_sm_io *io) ...@@ -1270,8 +1266,7 @@ int ipmi_std_irq_setup(struct si_sm_io *io)
SI_DEVICE_NAME, SI_DEVICE_NAME,
io->irq_handler_data); io->irq_handler_data);
if (rv) { if (rv) {
dev_warn(io->dev, "%s unable to claim interrupt %d," dev_warn(io->dev, "%s unable to claim interrupt %d, running polled\n",
" running polled\n",
SI_DEVICE_NAME, io->irq); SI_DEVICE_NAME, io->irq);
io->irq = 0; io->irq = 0;
} else { } else {
...@@ -1346,10 +1341,8 @@ static int try_get_dev_id(struct smi_info *smi_info) ...@@ -1346,10 +1341,8 @@ static int try_get_dev_id(struct smi_info *smi_info)
/* record completion code */ /* record completion code */
unsigned char cc = *(resp + 2); unsigned char cc = *(resp + 2);
if ((cc == IPMI_DEVICE_IN_FW_UPDATE_ERR if (cc != IPMI_CC_NO_ERROR &&
|| cc == IPMI_DEVICE_IN_INIT_ERR ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
|| cc == IPMI_NOT_IN_MY_STATE_ERR)
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
dev_warn(smi_info->io.dev, dev_warn(smi_info->io.dev,
"BMC returned 0x%2.2x, retry get bmc device id\n", "BMC returned 0x%2.2x, retry get bmc device id\n",
cc); cc);
...@@ -2207,10 +2200,6 @@ static void shutdown_smi(void *send_info) ...@@ -2207,10 +2200,6 @@ static void shutdown_smi(void *send_info)
if (smi_info->handlers) if (smi_info->handlers)
smi_info->handlers->cleanup(smi_info->si_sm); smi_info->handlers->cleanup(smi_info->si_sm);
if (smi_info->io.addr_source_cleanup) {
smi_info->io.addr_source_cleanup(&smi_info->io);
smi_info->io.addr_source_cleanup = NULL;
}
if (smi_info->io.io_cleanup) { if (smi_info->io.io_cleanup) {
smi_info->io.io_cleanup(&smi_info->io); smi_info->io.io_cleanup(&smi_info->io);
smi_info->io.io_cleanup = NULL; smi_info->io.io_cleanup = NULL;
...@@ -2306,5 +2295,4 @@ module_exit(cleanup_ipmi_si); ...@@ -2306,5 +2295,4 @@ module_exit(cleanup_ipmi_si);
MODULE_ALIAS("platform:dmi-ipmi-si"); MODULE_ALIAS("platform:dmi-ipmi-si");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT" MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces.");
" system interfaces.");
...@@ -16,18 +16,11 @@ static bool pci_registered; ...@@ -16,18 +16,11 @@ static bool pci_registered;
static bool si_trypci = true; static bool si_trypci = true;
module_param_named(trypci, si_trypci, bool, 0); module_param_named(trypci, si_trypci, bool, 0);
MODULE_PARM_DESC(trypci, "Setting this to zero will disable the" MODULE_PARM_DESC(trypci,
" default scan of the interfaces identified via pci"); "Setting this to zero will disable the default scan of the interfaces identified via pci");
#define PCI_DEVICE_ID_HP_MMC 0x121A #define PCI_DEVICE_ID_HP_MMC 0x121A
static void ipmi_pci_cleanup(struct si_sm_io *io)
{
struct pci_dev *pdev = io->addr_source_data;
pci_disable_device(pdev);
}
static int ipmi_pci_probe_regspacing(struct si_sm_io *io) static int ipmi_pci_probe_regspacing(struct si_sm_io *io)
{ {
if (io->si_type == SI_KCS) { if (io->si_type == SI_KCS) {
...@@ -97,15 +90,12 @@ static int ipmi_pci_probe(struct pci_dev *pdev, ...@@ -97,15 +90,12 @@ static int ipmi_pci_probe(struct pci_dev *pdev,
return -ENOMEM; return -ENOMEM;
} }
rv = pci_enable_device(pdev); rv = pcim_enable_device(pdev);
if (rv) { if (rv) {
dev_err(&pdev->dev, "couldn't enable PCI device\n"); dev_err(&pdev->dev, "couldn't enable PCI device\n");
return rv; return rv;
} }
io.addr_source_cleanup = ipmi_pci_cleanup;
io.addr_source_data = pdev;
if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) { if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
io.addr_space = IPMI_IO_ADDR_SPACE; io.addr_space = IPMI_IO_ADDR_SPACE;
io.io_setup = ipmi_si_port_setup; io.io_setup = ipmi_si_port_setup;
...@@ -128,11 +118,7 @@ static int ipmi_pci_probe(struct pci_dev *pdev, ...@@ -128,11 +118,7 @@ static int ipmi_pci_probe(struct pci_dev *pdev,
dev_info(&pdev->dev, "%pR regsize %d spacing %d irq %d\n", dev_info(&pdev->dev, "%pR regsize %d spacing %d irq %d\n",
&pdev->resource[0], io.regsize, io.regspacing, io.irq); &pdev->resource[0], io.regsize, io.regspacing, io.irq);
rv = ipmi_si_add_smi(&io); return ipmi_si_add_smi(&io);
if (rv)
pci_disable_device(pdev);
return rv;
} }
static void ipmi_pci_remove(struct pci_dev *pdev) static void ipmi_pci_remove(struct pci_dev *pdev)
......
...@@ -34,23 +34,22 @@ static bool si_trydmi = false; ...@@ -34,23 +34,22 @@ static bool si_trydmi = false;
#endif #endif
module_param_named(tryplatform, si_tryplatform, bool, 0); module_param_named(tryplatform, si_tryplatform, bool, 0);
MODULE_PARM_DESC(tryplatform, "Setting this to zero will disable the" MODULE_PARM_DESC(tryplatform,
" default scan of the interfaces identified via platform" "Setting this to zero will disable the default scan of the interfaces identified via platform interfaces besides ACPI, OpenFirmware, and DMI");
" interfaces besides ACPI, OpenFirmware, and DMI");
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
module_param_named(tryacpi, si_tryacpi, bool, 0); module_param_named(tryacpi, si_tryacpi, bool, 0);
MODULE_PARM_DESC(tryacpi, "Setting this to zero will disable the" MODULE_PARM_DESC(tryacpi,
" default scan of the interfaces identified via ACPI"); "Setting this to zero will disable the default scan of the interfaces identified via ACPI");
#endif #endif
#ifdef CONFIG_OF #ifdef CONFIG_OF
module_param_named(tryopenfirmware, si_tryopenfirmware, bool, 0); module_param_named(tryopenfirmware, si_tryopenfirmware, bool, 0);
MODULE_PARM_DESC(tryopenfirmware, "Setting this to zero will disable the" MODULE_PARM_DESC(tryopenfirmware,
" default scan of the interfaces identified via OpenFirmware"); "Setting this to zero will disable the default scan of the interfaces identified via OpenFirmware");
#endif #endif
#ifdef CONFIG_DMI #ifdef CONFIG_DMI
module_param_named(trydmi, si_trydmi, bool, 0); module_param_named(trydmi, si_trydmi, bool, 0);
MODULE_PARM_DESC(trydmi, "Setting this to zero will disable the" MODULE_PARM_DESC(trydmi,
" default scan of the interfaces identified via DMI"); "Setting this to zero will disable the default scan of the interfaces identified via DMI");
#endif #endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -85,47 +84,46 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io) ...@@ -85,47 +84,46 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io)
ACPI_GPE_LEVEL_TRIGGERED, ACPI_GPE_LEVEL_TRIGGERED,
&ipmi_acpi_gpe, &ipmi_acpi_gpe,
io); io);
if (status != AE_OK) { if (ACPI_FAILURE(status)) {
dev_warn(io->dev, dev_warn(io->dev,
"Unable to claim ACPI GPE %d, running polled\n", "Unable to claim ACPI GPE %d, running polled\n",
io->irq); io->irq);
io->irq = 0; io->irq = 0;
return -EINVAL; return -EINVAL;
} else {
io->irq_cleanup = acpi_gpe_irq_cleanup;
ipmi_irq_finish_setup(io);
dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
return 0;
} }
io->irq_cleanup = acpi_gpe_irq_cleanup;
ipmi_irq_finish_setup(io);
dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
return 0;
} }
#endif #endif
static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io)
{
if (resource_type(r) == IORESOURCE_IO)
io->addr_space = IPMI_IO_ADDR_SPACE;
else
io->addr_space = IPMI_MEM_ADDR_SPACE;
io->addr_data = r->start;
}
static struct resource * static struct resource *
ipmi_get_info_from_resources(struct platform_device *pdev, ipmi_get_info_from_resources(struct platform_device *pdev,
struct si_sm_io *io) struct si_sm_io *io)
{ {
struct resource *res, *res_second; struct resource *res, *res_second;
res = platform_get_resource(pdev, IORESOURCE_IO, 0); res = platform_get_mem_or_io(pdev, 0);
if (res) {
io->addr_space = IPMI_IO_ADDR_SPACE;
} else {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res)
io->addr_space = IPMI_MEM_ADDR_SPACE;
}
if (!res) { if (!res) {
dev_err(&pdev->dev, "no I/O or memory address\n"); dev_err(&pdev->dev, "no I/O or memory address\n");
return NULL; return NULL;
} }
io->addr_data = res->start; ipmi_set_addr_data_and_space(res, io);
io->regspacing = DEFAULT_REGSPACING; io->regspacing = DEFAULT_REGSPACING;
res_second = platform_get_resource(pdev, res_second = platform_get_mem_or_io(pdev, 1);
(io->addr_space == IPMI_IO_ADDR_SPACE) ? if (res_second && resource_type(res_second) == resource_type(res)) {
IORESOURCE_IO : IORESOURCE_MEM,
1);
if (res_second) {
if (res_second->start > io->addr_data) if (res_second->start > io->addr_data)
io->regspacing = res_second->start - io->addr_data; io->regspacing = res_second->start - io->addr_data;
} }
...@@ -275,12 +273,7 @@ static int of_ipmi_probe(struct platform_device *pdev) ...@@ -275,12 +273,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
io.addr_source = SI_DEVICETREE; io.addr_source = SI_DEVICETREE;
io.irq_setup = ipmi_std_irq_setup; io.irq_setup = ipmi_std_irq_setup;
if (resource.flags & IORESOURCE_IO) ipmi_set_addr_data_and_space(&resource, &io);
io.addr_space = IPMI_IO_ADDR_SPACE;
else
io.addr_space = IPMI_MEM_ADDR_SPACE;
io.addr_data = resource.start;
io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE; io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING; io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING;
...@@ -317,32 +310,31 @@ static int find_slave_address(struct si_sm_io *io, int slave_addr) ...@@ -317,32 +310,31 @@ static int find_slave_address(struct si_sm_io *io, int slave_addr)
static int acpi_ipmi_probe(struct platform_device *pdev) static int acpi_ipmi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct si_sm_io io; struct si_sm_io io;
acpi_handle handle; acpi_handle handle;
acpi_status status; acpi_status status;
unsigned long long tmp; unsigned long long tmp;
struct resource *res; struct resource *res;
int rv = -EINVAL;
if (!si_tryacpi) if (!si_tryacpi)
return -ENODEV; return -ENODEV;
handle = ACPI_HANDLE(&pdev->dev); handle = ACPI_HANDLE(dev);
if (!handle) if (!handle)
return -ENODEV; return -ENODEV;
memset(&io, 0, sizeof(io)); memset(&io, 0, sizeof(io));
io.addr_source = SI_ACPI; io.addr_source = SI_ACPI;
dev_info(&pdev->dev, "probing via ACPI\n"); dev_info(dev, "probing via ACPI\n");
io.addr_info.acpi_info.acpi_handle = handle; io.addr_info.acpi_info.acpi_handle = handle;
/* _IFT tells us the interface type: KCS, BT, etc */ /* _IFT tells us the interface type: KCS, BT, etc */
status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp); status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
dev_err(&pdev->dev, dev_err(dev, "Could not find ACPI IPMI interface type\n");
"Could not find ACPI IPMI interface type\n"); return -EINVAL;
goto err_free;
} }
switch (tmp) { switch (tmp) {
...@@ -356,21 +348,19 @@ static int acpi_ipmi_probe(struct platform_device *pdev) ...@@ -356,21 +348,19 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
io.si_type = SI_BT; io.si_type = SI_BT;
break; break;
case 4: /* SSIF, just ignore */ case 4: /* SSIF, just ignore */
rv = -ENODEV; return -ENODEV;
goto err_free;
default: default:
dev_info(&pdev->dev, "unknown IPMI type %lld\n", tmp); dev_info(dev, "unknown IPMI type %lld\n", tmp);
goto err_free; return -EINVAL;
} }
io.dev = dev;
io.regsize = DEFAULT_REGSIZE; io.regsize = DEFAULT_REGSIZE;
io.regshift = 0; io.regshift = 0;
res = ipmi_get_info_from_resources(pdev, &io); res = ipmi_get_info_from_resources(pdev, &io);
if (!res) { if (!res)
rv = -EINVAL; return -EINVAL;
goto err_free;
}
/* If _GPE exists, use it; otherwise use standard interrupts */ /* If _GPE exists, use it; otherwise use standard interrupts */
status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp); status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp);
...@@ -388,17 +378,12 @@ static int acpi_ipmi_probe(struct platform_device *pdev) ...@@ -388,17 +378,12 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
io.slave_addr = find_slave_address(&io, io.slave_addr); io.slave_addr = find_slave_address(&io, io.slave_addr);
io.dev = &pdev->dev; dev_info(dev, "%pR regsize %d spacing %d irq %d\n",
dev_info(io.dev, "%pR regsize %d spacing %d irq %d\n",
res, io.regsize, io.regspacing, io.irq); res, io.regsize, io.regspacing, io.irq);
request_module("acpi_ipmi"); request_module("acpi_ipmi");
return ipmi_si_add_smi(&io); return ipmi_si_add_smi(&io);
err_free:
return rv;
} }
static const struct acpi_device_id acpi_ipmi_match[] = { static const struct acpi_device_id acpi_ipmi_match[] = {
......
...@@ -510,7 +510,7 @@ static int ipmi_ssif_thread(void *data) ...@@ -510,7 +510,7 @@ static int ipmi_ssif_thread(void *data)
return 0; return 0;
} }
static int ssif_i2c_send(struct ssif_info *ssif_info, static void ssif_i2c_send(struct ssif_info *ssif_info,
ssif_i2c_done handler, ssif_i2c_done handler,
int read_write, int command, int read_write, int command,
unsigned char *data, unsigned int size) unsigned char *data, unsigned int size)
...@@ -522,7 +522,6 @@ static int ssif_i2c_send(struct ssif_info *ssif_info, ...@@ -522,7 +522,6 @@ static int ssif_i2c_send(struct ssif_info *ssif_info,
ssif_info->i2c_data = data; ssif_info->i2c_data = data;
ssif_info->i2c_size = size; ssif_info->i2c_size = size;
complete(&ssif_info->wake_thread); complete(&ssif_info->wake_thread);
return 0;
} }
...@@ -531,22 +530,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -531,22 +530,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
static void start_get(struct ssif_info *ssif_info) static void start_get(struct ssif_info *ssif_info)
{ {
int rv;
ssif_info->rtc_us_timer = 0; ssif_info->rtc_us_timer = 0;
ssif_info->multi_pos = 0; ssif_info->multi_pos = 0;
rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
SSIF_IPMI_RESPONSE, SSIF_IPMI_RESPONSE,
ssif_info->recv, I2C_SMBUS_BLOCK_DATA); ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
if (rv < 0) {
/* request failed, just return the error. */
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
dev_dbg(&ssif_info->client->dev,
"Error from i2c_non_blocking_op(5)\n");
msg_done_handler(ssif_info, -EIO, NULL, 0);
}
} }
static void retry_timeout(struct timer_list *t) static void retry_timeout(struct timer_list *t)
...@@ -620,7 +609,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -620,7 +609,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
{ {
struct ipmi_smi_msg *msg; struct ipmi_smi_msg *msg;
unsigned long oflags, *flags; unsigned long oflags, *flags;
int rv;
/* /*
* We are single-threaded here, so no need for a lock until we * We are single-threaded here, so no need for a lock until we
...@@ -666,17 +654,10 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -666,17 +654,10 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
ssif_info->multi_len = len; ssif_info->multi_len = len;
ssif_info->multi_pos = 1; ssif_info->multi_pos = 1;
rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
ssif_info->recv, I2C_SMBUS_BLOCK_DATA); ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
if (rv < 0) { return;
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
dev_dbg(&ssif_info->client->dev,
"Error from i2c_non_blocking_op(1)\n");
result = -EIO;
} else
return;
} else if (ssif_info->multi_pos) { } else if (ssif_info->multi_pos) {
/* Middle of multi-part read. Start the next transaction. */ /* Middle of multi-part read. Start the next transaction. */
int i; int i;
...@@ -738,19 +719,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -738,19 +719,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
ssif_info->multi_pos++; ssif_info->multi_pos++;
rv = ssif_i2c_send(ssif_info, msg_done_handler, ssif_i2c_send(ssif_info, msg_done_handler,
I2C_SMBUS_READ, I2C_SMBUS_READ,
SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
ssif_info->recv, ssif_info->recv,
I2C_SMBUS_BLOCK_DATA); I2C_SMBUS_BLOCK_DATA);
if (rv < 0) { return;
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
dev_dbg(&ssif_info->client->dev,
"Error from ssif_i2c_send\n");
result = -EIO;
} else
return;
} }
} }
...@@ -908,8 +882,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, ...@@ -908,8 +882,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
static void msg_written_handler(struct ssif_info *ssif_info, int result, static void msg_written_handler(struct ssif_info *ssif_info, int result,
unsigned char *data, unsigned int len) unsigned char *data, unsigned int len)
{ {
int rv;
/* We are single-threaded here, so no need for a lock. */ /* We are single-threaded here, so no need for a lock. */
if (result < 0) { if (result < 0) {
ssif_info->retries_left--; ssif_info->retries_left--;
...@@ -972,18 +944,9 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result, ...@@ -972,18 +944,9 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
ssif_info->multi_data = NULL; ssif_info->multi_data = NULL;
} }
rv = ssif_i2c_send(ssif_info, msg_written_handler, ssif_i2c_send(ssif_info, msg_written_handler,
I2C_SMBUS_WRITE, cmd, I2C_SMBUS_WRITE, cmd,
data_to_send, I2C_SMBUS_BLOCK_DATA); data_to_send, I2C_SMBUS_BLOCK_DATA);
if (rv < 0) {
/* request failed, just return the error. */
ssif_inc_stat(ssif_info, send_errors);
if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
dev_dbg(&ssif_info->client->dev,
"Error from i2c_non_blocking_op(3)\n");
msg_done_handler(ssif_info, -EIO, NULL, 0);
}
} else { } else {
/* Ready to request the result. */ /* Ready to request the result. */
unsigned long oflags, *flags; unsigned long oflags, *flags;
...@@ -1012,7 +975,6 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result, ...@@ -1012,7 +975,6 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
static int start_resend(struct ssif_info *ssif_info) static int start_resend(struct ssif_info *ssif_info)
{ {
int rv;
int command; int command;
ssif_info->got_alert = false; ssif_info->got_alert = false;
...@@ -1034,12 +996,9 @@ static int start_resend(struct ssif_info *ssif_info) ...@@ -1034,12 +996,9 @@ static int start_resend(struct ssif_info *ssif_info)
ssif_info->data[0] = ssif_info->data_len; ssif_info->data[0] = ssif_info->data_len;
} }
rv = ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE, ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE,
command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); command, ssif_info->data, I2C_SMBUS_BLOCK_DATA);
if (rv && (ssif_info->ssif_debug & SSIF_DEBUG_MSG)) return 0;
dev_dbg(&ssif_info->client->dev,
"Error from i2c_non_blocking_op(4)\n");
return rv;
} }
static int start_send(struct ssif_info *ssif_info, static int start_send(struct ssif_info *ssif_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment