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

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
Loading
Loading
Loading
Loading
+22 −38
Original line number Diff line number Diff line
@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
static bool initialized;
static bool drvregistered;

/* Numbers in this enumerator should be mapped to ipmi_panic_event_str */
enum ipmi_panic_event_op {
	IPMI_SEND_PANIC_EVENT_NONE,
	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
#define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING
#elif defined(CONFIG_IPMI_PANIC_EVENT)
@@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val,
				  const struct kernel_param *kp)
{
	char valcp[16];
	char *s;

	strncpy(valcp, val, 15);
	valcp[15] = '\0';

	s = strstrip(valcp);
	int e;

	if (strcmp(s, "none") == 0)
		ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE;
	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;
	strscpy(valcp, val, sizeof(valcp));
	e = match_string(ipmi_panic_event_str, -1, strstrip(valcp));
	if (e < 0)
		return e;

	ipmi_send_panic_event = e;
	return 0;
}

static int panic_op_read_handler(char *buffer, const struct kernel_param *kp)
{
	switch (ipmi_send_panic_event) {
	case IPMI_SEND_PANIC_EVENT_NONE:
		strcpy(buffer, "none\n");
		break;
	const char *event_str;

	case IPMI_SEND_PANIC_EVENT:
		strcpy(buffer, "event\n");
		break;

	case IPMI_SEND_PANIC_EVENT_STRING:
		strcpy(buffer, "string\n");
		break;

	default:
		strcpy(buffer, "???\n");
		break;
	}
	if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX)
		event_str = "???";
	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 = {
@@ -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);

	if (!bmc->dyn_id_set) {
		if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
		     || bmc->cc ==  IPMI_DEVICE_IN_INIT_ERR
		     || bmc->cc ==  IPMI_NOT_IN_MY_STATE_ERR)
		     && ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
		if (bmc->cc != IPMI_CC_NO_ERROR &&
		    ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
			msleep(500);
			dev_warn(intf->si_dev,
			    "BMC returned 0x%2.2x, retry get bmc device id\n",
@@ -5224,7 +5209,6 @@ module_exit(cleanup_ipmi);
module_init(ipmi_init_msghandler_mod);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI"
		   " interface.");
MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface.");
MODULE_VERSION(IPMI_DRIVER_VERSION);
MODULE_SOFTDEP("post: ipmi_devintf");
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst,
		goto err;
	}
 add_properties:
	rv = platform_device_add_properties(pdev, pr);
	rv = device_create_managed_software_node(&pdev->dev, pr, NULL);
	if (rv) {
		dev_err(&pdev->dev,
			"Unable to add hard-code properties: %d\n", rv);
+5 −3
Original line number Diff line number Diff line
@@ -18,10 +18,14 @@
#define DEFAULT_REGSPACING	1
#define DEFAULT_REGSIZE		1

/* Numbers in this enumerator should be mapped to si_to_str[] */
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 {
	IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
};
@@ -48,8 +52,6 @@ struct si_sm_io {
	enum ipmi_addr_space addr_space;
	unsigned long addr_data;
	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;

	int (*io_setup)(struct si_sm_io *info);
+25 −48
Original line number Diff line number Diff line
@@ -32,47 +32,29 @@ static int slave_addrs[SI_MAX_PARMS] __initdata;
static unsigned int num_slave_addrs __initdata;

module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0);
MODULE_PARM_DESC(type, "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");
MODULE_PARM_DESC(type,
		 "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");
module_param_hw_array(addrs, ulong, iomem, &num_addrs, 0);
MODULE_PARM_DESC(addrs, "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.");
MODULE_PARM_DESC(addrs,
		 "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.");
module_param_hw_array(ports, uint, ioport, &num_ports, 0);
MODULE_PARM_DESC(ports, "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.");
MODULE_PARM_DESC(ports,
		 "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.");
module_param_hw_array(irqs, int, irq, &num_irqs, 0);
MODULE_PARM_DESC(irqs, "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.");
MODULE_PARM_DESC(irqs,
		 "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.");
module_param_hw_array(regspacings, int, other, &num_regspacings, 0);
MODULE_PARM_DESC(regspacings, "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.");
MODULE_PARM_DESC(regspacings,
		 "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.");
module_param_hw_array(regsizes, int, other, &num_regsizes, 0);
MODULE_PARM_DESC(regsizes, "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.");
MODULE_PARM_DESC(regsizes,
		 "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.");
module_param_hw_array(regshifts, int, other, &num_regshifts, 0);
MODULE_PARM_DESC(regshifts, "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");
MODULE_PARM_DESC(regshifts,
		 "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");
module_param_hw_array(slave_addrs, int, other, &num_slave_addrs, 0);
MODULE_PARM_DESC(slave_addrs, "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.");
MODULE_PARM_DESC(slave_addrs,
		 "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.");

static void __init ipmi_hardcode_init_one(const char *si_type_str,
					  unsigned int i,
@@ -80,27 +62,22 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
					  enum ipmi_addr_space addr_space)
{
	struct ipmi_plat_data p;
	int t;

	memset(&p, 0, sizeof(p));

	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;
	} 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 {
		t = match_string(si_to_str, -1, si_type_str);
		if (t < 0) {
			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.slave_addr = slave_addrs[i];
+7 −17
Original line number Diff line number Diff line
@@ -17,9 +17,8 @@
static int hotmod_handler(const char *val, const struct kernel_param *kp);

module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
MODULE_PARM_DESC(hotmod, "Add and remove interfaces.  See"
		 " Documentation/driver-api/ipmi.rst in the kernel sources for the"
		 " gory details.");
MODULE_PARM_DESC(hotmod,
		 "Add and remove interfaces.  See Documentation/driver-api/ipmi.rst in the kernel sources for the gory details.");

/*
 * Parms come in as <op1>[:op2[:op3...]].  ops are:
@@ -185,24 +184,16 @@ static atomic_t hotmod_nr;

static int hotmod_handler(const char *val, const struct kernel_param *kp)
{
	char *str = kstrdup(val, GFP_KERNEL), *curr, *next;
	int  rv;
	struct ipmi_plat_data h;
	unsigned int len;
	int ival;
	char *str, *curr, *next;

	str = kstrdup(val, GFP_KERNEL);
	if (!str)
		return -ENOMEM;

	/* Kill any trailing spaces, as we can get a "\n" from echo. */
	len = strlen(str);
	ival = len - 1;
	while ((ival >= 0) && isspace(str[ival])) {
		str[ival] = '\0';
		ival--;
	}

	for (curr = str; curr; curr = next) {
	for (curr = strstrip(str); curr; curr = next) {
		enum hotmod_op op;

		next = strchr(curr, ':');
@@ -231,11 +222,10 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
				if (strcmp(pdev->name, "hotmod-ipmi-si") == 0)
					platform_device_unregister(pdev);
			}
			if (dev)
			put_device(dev);
		}
	}
	rv = len;
	rv = strlen(val);
out:
	kfree(str);
	return rv;
Loading