History

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

Linus Torvalds committed 5 years ago

Commit 6fa09d32 parents 0080665 07cbd879 files · +137 −266Browse files

Unified · Split

9 files
  1. drivers/char/ipmi/ipmi_msghandler.c +22 −38
  2. drivers/char/ipmi/ipmi_plat_data.c +1 −1
  3. drivers/char/ipmi/ipmi_si.h +5 −3
  4. drivers/char/ipmi/ipmi_si_hardcode.c +25 −48
  5. drivers/char/ipmi/ipmi_si_hotmod.c +7 −17
  6. drivers/char/ipmi/ipmi_si_intf.c +13 −25
  7. drivers/char/ipmi/ipmi_si_pci.c +4 −18
  8. drivers/char/ipmi/ipmi_si_platform.c +40 −55
  9. drivers/char/ipmi/ipmi_ssif.c +20 −61
drivers/char/ipmi/ipmi_msghandler.c+22−38
@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf, · 48 unmodified lines
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, · 8 unmodified lines
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 @@ retry: · 2333 unmodified lines
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); · 2767 unmodified lines
52245209 module_init(ipmi_init_msghandler_mod);
52255210 MODULE_LICENSE("GPL");
52265211 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
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+1−1
@@ -102,7 +102,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst, · 101 unmodified lines
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+5−3
@@ -18,10 +18,14 @@ · 17 unmodified lines
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 { · 20 unmodified lines
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+25−48
@@ -32,47 +32,29 @@ static int slave_addrs[SI_MAX_PARMS] __initdata; · 31 unmodified lines
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,
@@ -80,26 +62,21 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str, · 1 unmodified line
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+7−17
@@ -17,9 +17,8 @@ · 16 unmodified lines
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; · 159 unmodified lines
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) · 22 unmodified lines
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+13−25
@@ -70,7 +70,8 @@ enum si_intf_state { · 69 unmodified lines
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, · 1092 unmodified lines
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 */ · 45 unmodified lines
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) · 29 unmodified lines
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 @@ retry: · 68 unmodified lines
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) · 851 unmodified lines
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); · 89 unmodified lines
23062295 MODULE_ALIAS("platform:dmi-ipmi-si");
23072296 MODULE_LICENSE("GPL");
23082297 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
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.");
drivers/char/ipmi/ipmi_si_pci.c+4−18
@@ -16,18 +16,11 @@ static bool pci_registered; · 15 unmodified lines
1616 static bool si_trypci = true;
1717
1818 module_param_named(trypci, si_trypci, bool, 0);
19−MODULE_PARM_DESC(trypci, "Setting this to zero will disable the"
20− " default scan of the interfaces identified via pci");
19+MODULE_PARM_DESC(trypci,
20+ "Setting this to zero will disable the default scan of the interfaces identified via pci");
2121
2222 #define PCI_DEVICE_ID_HP_MMC 0x121A
2323
24−static void ipmi_pci_cleanup(struct si_sm_io *io)
25−{
26− struct pci_dev *pdev = io->addr_source_data;
27−
28− pci_disable_device(pdev);
29−}
30−
3124 static int ipmi_pci_probe_regspacing(struct si_sm_io *io)
3225 {
3326 if (io->si_type == SI_KCS) {
@@ -97,15 +90,12 @@ static int ipmi_pci_probe(struct pci_dev *pdev, · 63 unmodified lines
9790 return -ENOMEM;
9891 }
9992
100− rv = pci_enable_device(pdev);
93+ rv = pcim_enable_device(pdev);
10194 if (rv) {
10295 dev_err(&pdev->dev, "couldn't enable PCI device\n");
10396 return rv;
10497 }
10598
106− io.addr_source_cleanup = ipmi_pci_cleanup;
107− io.addr_source_data = pdev;
108−
10999 if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
110100 io.addr_space = IPMI_IO_ADDR_SPACE;
111101 io.io_setup = ipmi_si_port_setup;
@@ -128,11 +118,7 @@ static int ipmi_pci_probe(struct pci_dev *pdev, · 16 unmodified lines
128118 dev_info(&pdev->dev, "%pR regsize %d spacing %d irq %d\n",
129119 &pdev->resource[0], io.regsize, io.regspacing, io.irq);
130120
131− rv = ipmi_si_add_smi(&io);
132− if (rv)
133− pci_disable_device(pdev);
134−
135− return rv;
121+ return ipmi_si_add_smi(&io);
136122 }
137123
138124 static void ipmi_pci_remove(struct pci_dev *pdev)
drivers/char/ipmi/ipmi_si_platform.c+40−55
@@ -34,23 +34,22 @@ static bool si_trydmi = false; · 33 unmodified lines
3434 #endif
3535
3636 module_param_named(tryplatform, si_tryplatform, bool, 0);
37−MODULE_PARM_DESC(tryplatform, "Setting this to zero will disable the"
38− " default scan of the interfaces identified via platform"
39− " interfaces besides ACPI, OpenFirmware, and DMI");
37+MODULE_PARM_DESC(tryplatform,
38+ "Setting this to zero will disable the default scan of the interfaces identified via platform interfaces besides ACPI, OpenFirmware, and DMI");
4039 #ifdef CONFIG_ACPI
4140 module_param_named(tryacpi, si_tryacpi, bool, 0);
42−MODULE_PARM_DESC(tryacpi, "Setting this to zero will disable the"
43− " default scan of the interfaces identified via ACPI");
41+MODULE_PARM_DESC(tryacpi,
42+ "Setting this to zero will disable the default scan of the interfaces identified via ACPI");
4443 #endif
4544 #ifdef CONFIG_OF
4645 module_param_named(tryopenfirmware, si_tryopenfirmware, bool, 0);
47−MODULE_PARM_DESC(tryopenfirmware, "Setting this to zero will disable the"
48− " default scan of the interfaces identified via OpenFirmware");
46+MODULE_PARM_DESC(tryopenfirmware,
47+ "Setting this to zero will disable the default scan of the interfaces identified via OpenFirmware");
4948 #endif
5049 #ifdef CONFIG_DMI
5150 module_param_named(trydmi, si_trydmi, bool, 0);
52−MODULE_PARM_DESC(trydmi, "Setting this to zero will disable the"
53− " default scan of the interfaces identified via DMI");
51+MODULE_PARM_DESC(trydmi,
52+ "Setting this to zero will disable the default scan of the interfaces identified via DMI");
5453 #endif
5554
5655 #ifdef CONFIG_ACPI
@@ -85,47 +84,46 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io) · 28 unmodified lines
8584 ACPI_GPE_LEVEL_TRIGGERED,
8685 &ipmi_acpi_gpe,
8786 io);
88− if (status != AE_OK) {
87+ if (ACPI_FAILURE(status)) {
8988 dev_warn(io->dev,
9089 "Unable to claim ACPI GPE %d, running polled\n",
9190 io->irq);
9291 io->irq = 0;
9392 return -EINVAL;
94− } else {
95− io->irq_cleanup = acpi_gpe_irq_cleanup;
96− ipmi_irq_finish_setup(io);
97− dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
98− return 0;
9993 }
94+
95+ io->irq_cleanup = acpi_gpe_irq_cleanup;
96+ ipmi_irq_finish_setup(io);
97+ dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
98+ return 0;
10099 }
101100 #endif
102101
102+static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io)
103+{
104+ if (resource_type(r) == IORESOURCE_IO)
105+ io->addr_space = IPMI_IO_ADDR_SPACE;
106+ else
107+ io->addr_space = IPMI_MEM_ADDR_SPACE;
108+ io->addr_data = r->start;
109+}
110+
103111 static struct resource *
104112 ipmi_get_info_from_resources(struct platform_device *pdev,
105113 struct si_sm_io *io)
106114 {
107115 struct resource *res, *res_second;
108116
109− res = platform_get_resource(pdev, IORESOURCE_IO, 0);
110− if (res) {
111− io->addr_space = IPMI_IO_ADDR_SPACE;
112− } else {
113− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
114− if (res)
115− io->addr_space = IPMI_MEM_ADDR_SPACE;
116− }
117+ res = platform_get_mem_or_io(pdev, 0);
117118 if (!res) {
118119 dev_err(&pdev->dev, "no I/O or memory address\n");
119120 return NULL;
120121 }
121− io->addr_data = res->start;
122+ ipmi_set_addr_data_and_space(res, io);
122123
123124 io->regspacing = DEFAULT_REGSPACING;
124− res_second = platform_get_resource(pdev,
125− (io->addr_space == IPMI_IO_ADDR_SPACE) ?
126− IORESOURCE_IO : IORESOURCE_MEM,
127− 1);
128− if (res_second) {
125+ res_second = platform_get_mem_or_io(pdev, 1);
126+ if (res_second && resource_type(res_second) == resource_type(res)) {
129127 if (res_second->start > io->addr_data)
130128 io->regspacing = res_second->start - io->addr_data;
131129 }
@@ -275,12 +273,7 @@ static int of_ipmi_probe(struct platform_device *pdev) · 143 unmodified lines
275273 io.addr_source = SI_DEVICETREE;
276274 io.irq_setup = ipmi_std_irq_setup;
277275
278− if (resource.flags & IORESOURCE_IO)
279− io.addr_space = IPMI_IO_ADDR_SPACE;
280− else
281− io.addr_space = IPMI_MEM_ADDR_SPACE;
282−
283− io.addr_data = resource.start;
276+ ipmi_set_addr_data_and_space(&resource, &io);
284277
285278 io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
286279 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) · 30 unmodified lines
317310
318311 static int acpi_ipmi_probe(struct platform_device *pdev)
319312 {
313+ struct device *dev = &pdev->dev;
320314 struct si_sm_io io;
321315 acpi_handle handle;
322316 acpi_status status;
323317 unsigned long long tmp;
324318 struct resource *res;
325− int rv = -EINVAL;
326319
327320 if (!si_tryacpi)
328321 return -ENODEV;
329322
330− handle = ACPI_HANDLE(&pdev->dev);
323+ handle = ACPI_HANDLE(dev);
331324 if (!handle)
332325 return -ENODEV;
333326
334327 memset(&io, 0, sizeof(io));
335328 io.addr_source = SI_ACPI;
336− dev_info(&pdev->dev, "probing via ACPI\n");
329+ dev_info(dev, "probing via ACPI\n");
337330
338331 io.addr_info.acpi_info.acpi_handle = handle;
339332
340333 /* _IFT tells us the interface type: KCS, BT, etc */
341334 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp);
342335 if (ACPI_FAILURE(status)) {
343− dev_err(&pdev->dev,
344− "Could not find ACPI IPMI interface type\n");
345− goto err_free;
336+ dev_err(dev, "Could not find ACPI IPMI interface type\n");
337+ return -EINVAL;
346338 }
347339
348340 switch (tmp) {
@@ -356,21 +348,19 @@ static int acpi_ipmi_probe(struct platform_device *pdev) · 7 unmodified lines
356348 io.si_type = SI_BT;
357349 break;
358350 case 4: /* SSIF, just ignore */
359− rv = -ENODEV;
360− goto err_free;
351+ return -ENODEV;
361352 default:
362− dev_info(&pdev->dev, "unknown IPMI type %lld\n", tmp);
363− goto err_free;
353+ dev_info(dev, "unknown IPMI type %lld\n", tmp);
354+ return -EINVAL;
364355 }
365356
357+ io.dev = dev;
366358 io.regsize = DEFAULT_REGSIZE;
367359 io.regshift = 0;
368360
369361 res = ipmi_get_info_from_resources(pdev, &io);
370− if (!res) {
371− rv = -EINVAL;
372− goto err_free;
373− }
362+ if (!res)
363+ return -EINVAL;
374364
375365 /* If _GPE exists, use it; otherwise use standard interrupts */
376366 status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp);
@@ -388,17 +378,12 @@ static int acpi_ipmi_probe(struct platform_device *pdev) · 11 unmodified lines
388378
389379 io.slave_addr = find_slave_address(&io, io.slave_addr);
390380
391− io.dev = &pdev->dev;
392−
393− dev_info(io.dev, "%pR regsize %d spacing %d irq %d\n",
381+ dev_info(dev, "%pR regsize %d spacing %d irq %d\n",
394382 res, io.regsize, io.regspacing, io.irq);
395383
396384 request_module("acpi_ipmi");
397385
398386 return ipmi_si_add_smi(&io);
399−
400−err_free:
401− return rv;
402387 }
403388
404389 static const struct acpi_device_id acpi_ipmi_match[] = {
drivers/char/ipmi/ipmi_ssif.c+20−61
@@ -510,7 +510,7 @@ static int ipmi_ssif_thread(void *data) · 509 unmodified lines
510510 return 0;
511511 }
512512
513−static int ssif_i2c_send(struct ssif_info *ssif_info,
513+static void ssif_i2c_send(struct ssif_info *ssif_info,
514514 ssif_i2c_done handler,
515515 int read_write, int command,
516516 unsigned char *data, unsigned int size)
@@ -522,7 +522,6 @@ static int ssif_i2c_send(struct ssif_info *ssif_info, · 5 unmodified lines
522522 ssif_info->i2c_data = data;
523523 ssif_info->i2c_size = size;
524524 complete(&ssif_info->wake_thread);
525− return 0;
526525 }
527526
528527
@@ -531,22 +530,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, · 2 unmodified lines
531530
532531 static void start_get(struct ssif_info *ssif_info)
533532 {
534− int rv;
535−
536533 ssif_info->rtc_us_timer = 0;
537534 ssif_info->multi_pos = 0;
538535
539− rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
540− SSIF_IPMI_RESPONSE,
541− ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
542− if (rv < 0) {
543− /* request failed, just return the error. */
544− if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
545− dev_dbg(&ssif_info->client->dev,
546− "Error from i2c_non_blocking_op(5)\n");
547−
548− msg_done_handler(ssif_info, -EIO, NULL, 0);
549− }
536+ ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
537+ SSIF_IPMI_RESPONSE,
538+ ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
550539 }
551540
552541 static void retry_timeout(struct timer_list *t)
@@ -620,7 +609,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, · 67 unmodified lines
620609 {
621610 struct ipmi_smi_msg *msg;
622611 unsigned long oflags, *flags;
623− int rv;
624612
625613 /*
626614 * 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, · 39 unmodified lines
666654 ssif_info->multi_len = len;
667655 ssif_info->multi_pos = 1;
668656
669− rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
670− SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
671− ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
672− if (rv < 0) {
673− if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
674− dev_dbg(&ssif_info->client->dev,
675− "Error from i2c_non_blocking_op(1)\n");
676−
677− result = -EIO;
678− } else
679− return;
657+ ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ,
658+ SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
659+ ssif_info->recv, I2C_SMBUS_BLOCK_DATA);
660+ return;
680661 } else if (ssif_info->multi_pos) {
681662 /* Middle of multi-part read. Start the next transaction. */
682663 int i;
@@ -738,19 +719,12 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, · 55 unmodified lines
738719
739720 ssif_info->multi_pos++;
740721
741− rv = ssif_i2c_send(ssif_info, msg_done_handler,
742− I2C_SMBUS_READ,
743− SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
744− ssif_info->recv,
745− I2C_SMBUS_BLOCK_DATA);
746− if (rv < 0) {
747− if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
748− dev_dbg(&ssif_info->client->dev,
749− "Error from ssif_i2c_send\n");
750−
751− result = -EIO;
752− } else
753− return;
722+ ssif_i2c_send(ssif_info, msg_done_handler,
723+ I2C_SMBUS_READ,
724+ SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE,
725+ ssif_info->recv,
726+ I2C_SMBUS_BLOCK_DATA);
727+ return;
754728 }
755729 }
756730
@@ -908,8 +882,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, · 151 unmodified lines
908882 static void msg_written_handler(struct ssif_info *ssif_info, int result,
909883 unsigned char *data, unsigned int len)
910884 {
911− int rv;
912−
913885 /* We are single-threaded here, so no need for a lock. */
914886 if (result < 0) {
915887 ssif_info->retries_left--;
@@ -972,18 +944,9 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result, · 56 unmodified lines
972944 ssif_info->multi_data = NULL;
973945 }
974946
975− rv = ssif_i2c_send(ssif_info, msg_written_handler,
976− I2C_SMBUS_WRITE, cmd,
977− data_to_send, I2C_SMBUS_BLOCK_DATA);
978− if (rv < 0) {
979− /* request failed, just return the error. */
980− ssif_inc_stat(ssif_info, send_errors);
981−
982− if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
983− dev_dbg(&ssif_info->client->dev,
984− "Error from i2c_non_blocking_op(3)\n");
985− msg_done_handler(ssif_info, -EIO, NULL, 0);
986− }
947+ ssif_i2c_send(ssif_info, msg_written_handler,
948+ I2C_SMBUS_WRITE, cmd,
949+ data_to_send, I2C_SMBUS_BLOCK_DATA);
987950 } else {
988951 /* Ready to request the result. */
989952 unsigned long oflags, *flags;
@@ -1012,7 +975,6 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result, · 22 unmodified lines
1012975
1013976 static int start_resend(struct ssif_info *ssif_info)
1014977 {
1015− int rv;
1016978 int command;
1017979
1018980 ssif_info->got_alert = false;
@@ -1034,12 +996,9 @@ static int start_resend(struct ssif_info *ssif_info) · 15 unmodified lines
1034996 ssif_info->data[0] = ssif_info->data_len;
1035997 }
1036998
1037− rv = ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE,
1038− command, ssif_info->data, I2C_SMBUS_BLOCK_DATA);
1039− if (rv && (ssif_info->ssif_debug & SSIF_DEBUG_MSG))
1040− dev_dbg(&ssif_info->client->dev,
1041− "Error from i2c_non_blocking_op(4)\n");
1042− return rv;
999+ ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE,
1000+ command, ssif_info->data, I2C_SMBUS_BLOCK_DATA);
1001+ return 0;
10431002 }
10441003
10451004 static int start_send(struct ssif_info *ssif_info,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t