Skip to content

Commit 6fa09d3

Browse files
committed
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
2 parents 0080665 + 07cbd87 commit 6fa09d3

File tree

9 files changed

+137
-266
lines changed

9 files changed

+137
-266
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
4949
static bool initialized;
5050
static bool drvregistered;
5151

52+
/* Numbers in this enumerator should be mapped to ipmi_panic_event_str */
5253
enum ipmi_panic_event_op {
5354
IPMI_SEND_PANIC_EVENT_NONE,
5455
IPMI_SEND_PANIC_EVENT,
55-
IPMI_SEND_PANIC_EVENT_STRING
56+
IPMI_SEND_PANIC_EVENT_STRING,
57+
IPMI_SEND_PANIC_EVENT_MAX
5658
};
59+
60+
/* Indices in this array should be mapped to enum ipmi_panic_event_op */
61+
static const char *const ipmi_panic_event_str[] = { "none", "event", "string", NULL };
62+
5763
#ifdef CONFIG_IPMI_PANIC_STRING
5864
#define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING
5965
#elif defined(CONFIG_IPMI_PANIC_EVENT)
@@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val,
6874
const struct kernel_param *kp)
6975
{
7076
char valcp[16];
71-
char *s;
72-
73-
strncpy(valcp, val, 15);
74-
valcp[15] = '\0';
77+
int e;
7578

76-
s = strstrip(valcp);
77-
78-
if (strcmp(s, "none") == 0)
79-
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE;
80-
else if (strcmp(s, "event") == 0)
81-
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT;
82-
else if (strcmp(s, "string") == 0)
83-
ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_STRING;
84-
else
85-
return -EINVAL;
79+
strscpy(valcp, val, sizeof(valcp));
80+
e = match_string(ipmi_panic_event_str, -1, strstrip(valcp));
81+
if (e < 0)
82+
return e;
8683

84+
ipmi_send_panic_event = e;
8785
return 0;
8886
}
8987

9088
static int panic_op_read_handler(char *buffer, const struct kernel_param *kp)
9189
{
92-
switch (ipmi_send_panic_event) {
93-
case IPMI_SEND_PANIC_EVENT_NONE:
94-
strcpy(buffer, "none\n");
95-
break;
96-
97-
case IPMI_SEND_PANIC_EVENT:
98-
strcpy(buffer, "event\n");
99-
break;
100-
101-
case IPMI_SEND_PANIC_EVENT_STRING:
102-
strcpy(buffer, "string\n");
103-
break;
90+
const char *event_str;
10491

105-
default:
106-
strcpy(buffer, "???\n");
107-
break;
108-
}
92+
if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX)
93+
event_str = "???";
94+
else
95+
event_str = ipmi_panic_event_str[ipmi_send_panic_event];
10996

110-
return strlen(buffer);
97+
return sprintf(buffer, "%s\n", event_str);
11198
}
11299

113100
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)
24472434
wait_event(intf->waitq, bmc->dyn_id_set != 2);
24482435

24492436
if (!bmc->dyn_id_set) {
2450-
if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
2451-
|| bmc->cc == IPMI_DEVICE_IN_INIT_ERR
2452-
|| bmc->cc == IPMI_NOT_IN_MY_STATE_ERR)
2453-
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
2437+
if (bmc->cc != IPMI_CC_NO_ERROR &&
2438+
++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
24542439
msleep(500);
24552440
dev_warn(intf->si_dev,
24562441
"BMC returned 0x%2.2x, retry get bmc device id\n",
@@ -5224,7 +5209,6 @@ module_exit(cleanup_ipmi);
52245209
module_init(ipmi_init_msghandler_mod);
52255210
MODULE_LICENSE("GPL");
52265211
MODULE_AUTHOR("Corey Minyard <[email protected]>");
5227-
MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI"
5228-
" interface.");
5212+
MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface.");
52295213
MODULE_VERSION(IPMI_DRIVER_VERSION);
52305214
MODULE_SOFTDEP("post: ipmi_devintf");

drivers/char/ipmi/ipmi_plat_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst,
102102
goto err;
103103
}
104104
add_properties:
105-
rv = platform_device_add_properties(pdev, pr);
105+
rv = device_create_managed_software_node(&pdev->dev, pr, NULL);
106106
if (rv) {
107107
dev_err(&pdev->dev,
108108
"Unable to add hard-code properties: %d\n", rv);

drivers/char/ipmi/ipmi_si.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
#define DEFAULT_REGSPACING 1
1919
#define DEFAULT_REGSIZE 1
2020

21+
/* Numbers in this enumerator should be mapped to si_to_str[] */
2122
enum si_type {
22-
SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT
23+
SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
2324
};
2425

26+
/* Array is defined in the ipmi_si_intf.c */
27+
extern const char *const si_to_str[];
28+
2529
enum ipmi_addr_space {
2630
IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
2731
};
@@ -48,8 +52,6 @@ struct si_sm_io {
4852
enum ipmi_addr_space addr_space;
4953
unsigned long addr_data;
5054
enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
51-
void (*addr_source_cleanup)(struct si_sm_io *io);
52-
void *addr_source_data;
5355
union ipmi_smi_info_union addr_info;
5456

5557
int (*io_setup)(struct si_sm_io *info);

drivers/char/ipmi/ipmi_si_hardcode.c

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,74 +32,51 @@ static int slave_addrs[SI_MAX_PARMS] __initdata;
3232
static unsigned int num_slave_addrs __initdata;
3333

3434
module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0);
35-
MODULE_PARM_DESC(type, "Defines the type of each interface, each"
36-
" interface separated by commas. The types are 'kcs',"
37-
" 'smic', and 'bt'. For example si_type=kcs,bt will set"
38-
" the first interface to kcs and the second to bt");
35+
MODULE_PARM_DESC(type,
36+
"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");
3937
module_param_hw_array(addrs, ulong, iomem, &num_addrs, 0);
40-
MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the"
41-
" addresses separated by commas. Only use if an interface"
42-
" is in memory. Otherwise, set it to zero or leave"
43-
" it blank.");
38+
MODULE_PARM_DESC(addrs,
39+
"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.");
4440
module_param_hw_array(ports, uint, ioport, &num_ports, 0);
45-
MODULE_PARM_DESC(ports, "Sets the port address of each interface, the"
46-
" addresses separated by commas. Only use if an interface"
47-
" is a port. Otherwise, set it to zero or leave"
48-
" it blank.");
41+
MODULE_PARM_DESC(ports,
42+
"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.");
4943
module_param_hw_array(irqs, int, irq, &num_irqs, 0);
50-
MODULE_PARM_DESC(irqs, "Sets the interrupt of each interface, the"
51-
" addresses separated by commas. Only use if an interface"
52-
" has an interrupt. Otherwise, set it to zero or leave"
53-
" it blank.");
44+
MODULE_PARM_DESC(irqs,
45+
"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.");
5446
module_param_hw_array(regspacings, int, other, &num_regspacings, 0);
55-
MODULE_PARM_DESC(regspacings, "The number of bytes between the start address"
56-
" and each successive register used by the interface. For"
57-
" instance, if the start address is 0xca2 and the spacing"
58-
" is 2, then the second address is at 0xca4. Defaults"
59-
" to 1.");
47+
MODULE_PARM_DESC(regspacings,
48+
"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.");
6049
module_param_hw_array(regsizes, int, other, &num_regsizes, 0);
61-
MODULE_PARM_DESC(regsizes, "The size of the specific IPMI register in bytes."
62-
" This should generally be 1, 2, 4, or 8 for an 8-bit,"
63-
" 16-bit, 32-bit, or 64-bit register. Use this if you"
64-
" the 8-bit IPMI register has to be read from a larger"
65-
" register.");
50+
MODULE_PARM_DESC(regsizes,
51+
"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.");
6652
module_param_hw_array(regshifts, int, other, &num_regshifts, 0);
67-
MODULE_PARM_DESC(regshifts, "The amount to shift the data read from the."
68-
" IPMI register, in bits. For instance, if the data"
69-
" is read from a 32-bit word and the IPMI data is in"
70-
" bit 8-15, then the shift would be 8");
53+
MODULE_PARM_DESC(regshifts,
54+
"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");
7155
module_param_hw_array(slave_addrs, int, other, &num_slave_addrs, 0);
72-
MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for"
73-
" the controller. Normally this is 0x20, but can be"
74-
" overridden by this parm. This is an array indexed"
75-
" by interface number.");
56+
MODULE_PARM_DESC(slave_addrs,
57+
"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.");
7658

7759
static void __init ipmi_hardcode_init_one(const char *si_type_str,
7860
unsigned int i,
7961
unsigned long addr,
8062
enum ipmi_addr_space addr_space)
8163
{
8264
struct ipmi_plat_data p;
65+
int t;
8366

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

8669
p.iftype = IPMI_PLAT_IF_SI;
87-
if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
70+
if (!si_type_str || !*si_type_str) {
8871
p.type = SI_KCS;
89-
} else if (strcmp(si_type_str, "smic") == 0) {
90-
p.type = SI_SMIC;
91-
} else if (strcmp(si_type_str, "bt") == 0) {
92-
p.type = SI_BT;
93-
} else if (strcmp(si_type_str, "invalid") == 0) {
94-
/*
95-
* Allow a firmware-specified interface to be
96-
* disabled.
97-
*/
98-
p.type = SI_TYPE_INVALID;
9972
} else {
100-
pr_warn("Interface type specified for interface %d, was invalid: %s\n",
101-
i, si_type_str);
102-
return;
73+
t = match_string(si_to_str, -1, si_type_str);
74+
if (t < 0) {
75+
pr_warn("Interface type specified for interface %d, was invalid: %s\n",
76+
i, si_type_str);
77+
return;
78+
}
79+
p.type = t;
10380
}
10481

10582
p.regsize = regsizes[i];

drivers/char/ipmi/ipmi_si_hotmod.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
static int hotmod_handler(const char *val, const struct kernel_param *kp);
1818

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

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

186185
static int hotmod_handler(const char *val, const struct kernel_param *kp)
187186
{
188-
char *str = kstrdup(val, GFP_KERNEL), *curr, *next;
189187
int rv;
190188
struct ipmi_plat_data h;
191-
unsigned int len;
192-
int ival;
189+
char *str, *curr, *next;
193190

191+
str = kstrdup(val, GFP_KERNEL);
194192
if (!str)
195193
return -ENOMEM;
196194

197195
/* Kill any trailing spaces, as we can get a "\n" from echo. */
198-
len = strlen(str);
199-
ival = len - 1;
200-
while ((ival >= 0) && isspace(str[ival])) {
201-
str[ival] = '\0';
202-
ival--;
203-
}
204-
205-
for (curr = str; curr; curr = next) {
196+
for (curr = strstrip(str); curr; curr = next) {
206197
enum hotmod_op op;
207198

208199
next = strchr(curr, ':');
@@ -231,11 +222,10 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
231222
if (strcmp(pdev->name, "hotmod-ipmi-si") == 0)
232223
platform_device_unregister(pdev);
233224
}
234-
if (dev)
235-
put_device(dev);
225+
put_device(dev);
236226
}
237227
}
238-
rv = len;
228+
rv = strlen(val);
239229
out:
240230
kfree(str);
241231
return rv;

drivers/char/ipmi/ipmi_si_intf.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ enum si_intf_state {
7070
#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
7171
#define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
7272

73-
static const char * const si_to_str[] = { "invalid", "kcs", "smic", "bt" };
73+
/* 'invalid' to allow a firmware-specified interface to be disabled */
74+
const char *const si_to_str[] = { "invalid", "kcs", "smic", "bt", NULL };
7475

7576
static bool initialized;
7677

@@ -1169,9 +1170,8 @@ static int smi_start_processing(void *send_info,
11691170
new_smi->thread = kthread_run(ipmi_thread, new_smi,
11701171
"kipmi%d", new_smi->si_num);
11711172
if (IS_ERR(new_smi->thread)) {
1172-
dev_notice(new_smi->io.dev, "Could not start"
1173-
" kernel thread due to error %ld, only using"
1174-
" timers to drive the interface\n",
1173+
dev_notice(new_smi->io.dev,
1174+
"Could not start kernel thread due to error %ld, only using timers to drive the interface\n",
11751175
PTR_ERR(new_smi->thread));
11761176
new_smi->thread = NULL;
11771177
}
@@ -1223,18 +1223,14 @@ static int smi_num; /* Used to sequence the SMIs */
12231223
static const char * const addr_space_to_str[] = { "i/o", "mem" };
12241224

12251225
module_param_array(force_kipmid, int, &num_force_kipmid, 0);
1226-
MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or"
1227-
" disabled(0). Normally the IPMI driver auto-detects"
1228-
" this, but the value may be overridden by this parm.");
1226+
MODULE_PARM_DESC(force_kipmid,
1227+
"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.");
12291228
module_param(unload_when_empty, bool, 0);
1230-
MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
1231-
" specified or found, default is 1. Setting to 0"
1232-
" is useful for hot add of devices using hotmod.");
1229+
MODULE_PARM_DESC(unload_when_empty,
1230+
"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.");
12331231
module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644);
12341232
MODULE_PARM_DESC(kipmid_max_busy_us,
1235-
"Max time (in microseconds) to busy-wait for IPMI data before"
1236-
" sleeping. 0 (default) means to wait forever. Set to 100-500"
1237-
" if kipmid is using up a lot of CPU time.");
1233+
"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.");
12381234

12391235
void ipmi_irq_finish_setup(struct si_sm_io *io)
12401236
{
@@ -1270,8 +1266,7 @@ int ipmi_std_irq_setup(struct si_sm_io *io)
12701266
SI_DEVICE_NAME,
12711267
io->irq_handler_data);
12721268
if (rv) {
1273-
dev_warn(io->dev, "%s unable to claim interrupt %d,"
1274-
" running polled\n",
1269+
dev_warn(io->dev, "%s unable to claim interrupt %d, running polled\n",
12751270
SI_DEVICE_NAME, io->irq);
12761271
io->irq = 0;
12771272
} else {
@@ -1346,10 +1341,8 @@ static int try_get_dev_id(struct smi_info *smi_info)
13461341
/* record completion code */
13471342
unsigned char cc = *(resp + 2);
13481343

1349-
if ((cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
1350-
|| cc == IPMI_DEVICE_IN_INIT_ERR
1351-
|| cc == IPMI_NOT_IN_MY_STATE_ERR)
1352-
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
1344+
if (cc != IPMI_CC_NO_ERROR &&
1345+
++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
13531346
dev_warn(smi_info->io.dev,
13541347
"BMC returned 0x%2.2x, retry get bmc device id\n",
13551348
cc);
@@ -2207,10 +2200,6 @@ static void shutdown_smi(void *send_info)
22072200
if (smi_info->handlers)
22082201
smi_info->handlers->cleanup(smi_info->si_sm);
22092202

2210-
if (smi_info->io.addr_source_cleanup) {
2211-
smi_info->io.addr_source_cleanup(&smi_info->io);
2212-
smi_info->io.addr_source_cleanup = NULL;
2213-
}
22142203
if (smi_info->io.io_cleanup) {
22152204
smi_info->io.io_cleanup(&smi_info->io);
22162205
smi_info->io.io_cleanup = NULL;
@@ -2306,5 +2295,4 @@ module_exit(cleanup_ipmi_si);
23062295
MODULE_ALIAS("platform:dmi-ipmi-si");
23072296
MODULE_LICENSE("GPL");
23082297
MODULE_AUTHOR("Corey Minyard <[email protected]>");
2309-
MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT"
2310-
" system interfaces.");
2298+
MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces.");

0 commit comments

Comments
 (0)