Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+137 -266
+22 -38
drivers/char/ipmi/ipmi_msghandler.c
··· 49 49 static bool initialized; 50 50 static bool drvregistered; 51 51 52 + /* Numbers in this enumerator should be mapped to ipmi_panic_event_str */ 52 53 enum ipmi_panic_event_op { 53 54 IPMI_SEND_PANIC_EVENT_NONE, 54 55 IPMI_SEND_PANIC_EVENT, 55 - IPMI_SEND_PANIC_EVENT_STRING 56 + IPMI_SEND_PANIC_EVENT_STRING, 57 + IPMI_SEND_PANIC_EVENT_MAX 56 58 }; 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 + 57 63 #ifdef CONFIG_IPMI_PANIC_STRING 58 64 #define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING 59 65 #elif defined(CONFIG_IPMI_PANIC_EVENT) ··· 74 68 const struct kernel_param *kp) 75 69 { 76 70 char valcp[16]; 77 - char *s; 71 + int e; 78 72 79 - strncpy(valcp, val, 15); 80 - valcp[15] = '\0'; 73 + strscpy(valcp, val, sizeof(valcp)); 74 + e = match_string(ipmi_panic_event_str, -1, strstrip(valcp)); 75 + if (e < 0) 76 + return e; 81 77 82 - s = strstrip(valcp); 83 - 84 - if (strcmp(s, "none") == 0) 85 - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE; 86 - else if (strcmp(s, "event") == 0) 87 - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT; 88 - else if (strcmp(s, "string") == 0) 89 - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_STRING; 90 - else 91 - return -EINVAL; 92 - 78 + ipmi_send_panic_event = e; 93 79 return 0; 94 80 } 95 81 96 82 static int panic_op_read_handler(char *buffer, const struct kernel_param *kp) 97 83 { 98 - switch (ipmi_send_panic_event) { 99 - case IPMI_SEND_PANIC_EVENT_NONE: 100 - strcpy(buffer, "none\n"); 101 - break; 84 + const char *event_str; 102 85 103 - case IPMI_SEND_PANIC_EVENT: 104 - strcpy(buffer, "event\n"); 105 - break; 86 + if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX) 87 + event_str = "???"; 88 + else 89 + event_str = ipmi_panic_event_str[ipmi_send_panic_event]; 106 90 107 - case IPMI_SEND_PANIC_EVENT_STRING: 108 - strcpy(buffer, "string\n"); 109 - break; 110 - 111 - default: 112 - strcpy(buffer, "???\n"); 113 - break; 114 - } 115 - 116 - return strlen(buffer); 91 + return sprintf(buffer, "%s\n", event_str); 117 92 } 118 93 119 94 static const struct kernel_param_ops panic_op_ops = { ··· 2434 2447 wait_event(intf->waitq, bmc->dyn_id_set != 2); 2435 2448 2436 2449 if (!bmc->dyn_id_set) { 2437 - if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR 2438 - || bmc->cc == IPMI_DEVICE_IN_INIT_ERR 2439 - || bmc->cc == IPMI_NOT_IN_MY_STATE_ERR) 2440 - && ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { 2450 + if (bmc->cc != IPMI_CC_NO_ERROR && 2451 + ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { 2441 2452 msleep(500); 2442 2453 dev_warn(intf->si_dev, 2443 2454 "BMC returned 0x%2.2x, retry get bmc device id\n", ··· 5209 5224 module_init(ipmi_init_msghandler_mod); 5210 5225 MODULE_LICENSE("GPL"); 5211 5226 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); 5212 - MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI" 5213 - " interface."); 5227 + MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); 5214 5228 MODULE_VERSION(IPMI_DRIVER_VERSION); 5215 5229 MODULE_SOFTDEP("post: ipmi_devintf");
+1 -1
drivers/char/ipmi/ipmi_plat_data.c
··· 102 102 goto err; 103 103 } 104 104 add_properties: 105 - rv = platform_device_add_properties(pdev, pr); 105 + rv = device_create_managed_software_node(&pdev->dev, pr, NULL); 106 106 if (rv) { 107 107 dev_err(&pdev->dev, 108 108 "Unable to add hard-code properties: %d\n", rv);
+5 -3
drivers/char/ipmi/ipmi_si.h
··· 18 18 #define DEFAULT_REGSPACING 1 19 19 #define DEFAULT_REGSIZE 1 20 20 21 + /* Numbers in this enumerator should be mapped to si_to_str[] */ 21 22 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 23 24 }; 25 + 26 + /* Array is defined in the ipmi_si_intf.c */ 27 + extern const char *const si_to_str[]; 24 28 25 29 enum ipmi_addr_space { 26 30 IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE ··· 52 48 enum ipmi_addr_space addr_space; 53 49 unsigned long addr_data; 54 50 enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */ 55 - void (*addr_source_cleanup)(struct si_sm_io *io); 56 - void *addr_source_data; 57 51 union ipmi_smi_info_union addr_info; 58 52 59 53 int (*io_setup)(struct si_sm_io *info);
+25 -48
drivers/char/ipmi/ipmi_si_hardcode.c
··· 32 32 static unsigned int num_slave_addrs __initdata; 33 33 34 34 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"); 39 37 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."); 44 40 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."); 49 43 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."); 54 46 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."); 60 49 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."); 66 52 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"); 71 55 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."); 76 58 77 59 static void __init ipmi_hardcode_init_one(const char *si_type_str, 78 60 unsigned int i, ··· 62 80 enum ipmi_addr_space addr_space) 63 81 { 64 82 struct ipmi_plat_data p; 83 + int t; 65 84 66 85 memset(&p, 0, sizeof(p)); 67 86 68 87 p.iftype = IPMI_PLAT_IF_SI; 69 - if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) { 88 + if (!si_type_str || !*si_type_str) { 70 89 p.type = SI_KCS; 71 - } else if (strcmp(si_type_str, "smic") == 0) { 72 - p.type = SI_SMIC; 73 - } else if (strcmp(si_type_str, "bt") == 0) { 74 - p.type = SI_BT; 75 - } else if (strcmp(si_type_str, "invalid") == 0) { 76 - /* 77 - * Allow a firmware-specified interface to be 78 - * disabled. 79 - */ 80 - p.type = SI_TYPE_INVALID; 81 90 } else { 82 - pr_warn("Interface type specified for interface %d, was invalid: %s\n", 83 - i, si_type_str); 84 - return; 91 + t = match_string(si_to_str, -1, si_type_str); 92 + if (t < 0) { 93 + pr_warn("Interface type specified for interface %d, was invalid: %s\n", 94 + i, si_type_str); 95 + return; 96 + } 97 + p.type = t; 85 98 } 86 99 87 100 p.regsize = regsizes[i];
+7 -17
drivers/char/ipmi/ipmi_si_hotmod.c
··· 17 17 static int hotmod_handler(const char *val, const struct kernel_param *kp); 18 18 19 19 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."); 23 22 24 23 /* 25 24 * Parms come in as <op1>[:op2[:op3...]]. ops are: ··· 184 185 185 186 static int hotmod_handler(const char *val, const struct kernel_param *kp) 186 187 { 187 - char *str = kstrdup(val, GFP_KERNEL), *curr, *next; 188 188 int rv; 189 189 struct ipmi_plat_data h; 190 - unsigned int len; 191 - int ival; 190 + char *str, *curr, *next; 192 191 192 + str = kstrdup(val, GFP_KERNEL); 193 193 if (!str) 194 194 return -ENOMEM; 195 195 196 196 /* Kill any trailing spaces, as we can get a "\n" from echo. */ 197 - len = strlen(str); 198 - ival = len - 1; 199 - while ((ival >= 0) && isspace(str[ival])) { 200 - str[ival] = '\0'; 201 - ival--; 202 - } 203 - 204 - for (curr = str; curr; curr = next) { 197 + for (curr = strstrip(str); curr; curr = next) { 205 198 enum hotmod_op op; 206 199 207 200 next = strchr(curr, ':'); ··· 222 231 if (strcmp(pdev->name, "hotmod-ipmi-si") == 0) 223 232 platform_device_unregister(pdev); 224 233 } 225 - if (dev) 226 - put_device(dev); 234 + put_device(dev); 227 235 } 228 236 } 229 - rv = len; 237 + rv = strlen(val); 230 238 out: 231 239 kfree(str); 232 240 return rv;
+13 -25
drivers/char/ipmi/ipmi_si_intf.c
··· 70 70 #define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2 71 71 #define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1 72 72 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 }; 74 75 75 76 static bool initialized; 76 77 ··· 1170 1169 new_smi->thread = kthread_run(ipmi_thread, new_smi, 1171 1170 "kipmi%d", new_smi->si_num); 1172 1171 if (IS_ERR(new_smi->thread)) { 1173 - dev_notice(new_smi->io.dev, "Could not start" 1174 - " kernel thread due to error %ld, only using" 1175 - " timers to drive the interface\n", 1172 + dev_notice(new_smi->io.dev, 1173 + "Could not start kernel thread due to error %ld, only using timers to drive the interface\n", 1176 1174 PTR_ERR(new_smi->thread)); 1177 1175 new_smi->thread = NULL; 1178 1176 } ··· 1223 1223 static const char * const addr_space_to_str[] = { "i/o", "mem" }; 1224 1224 1225 1225 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."); 1229 1228 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."); 1233 1231 module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); 1234 1232 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."); 1238 1234 1239 1235 void ipmi_irq_finish_setup(struct si_sm_io *io) 1240 1236 { ··· 1266 1270 SI_DEVICE_NAME, 1267 1271 io->irq_handler_data); 1268 1272 if (rv) { 1269 - dev_warn(io->dev, "%s unable to claim interrupt %d," 1270 - " running polled\n", 1273 + dev_warn(io->dev, "%s unable to claim interrupt %d, running polled\n", 1271 1274 SI_DEVICE_NAME, io->irq); 1272 1275 io->irq = 0; 1273 1276 } else { ··· 1341 1346 /* record completion code */ 1342 1347 unsigned char cc = *(resp + 2); 1343 1348 1344 - if ((cc == IPMI_DEVICE_IN_FW_UPDATE_ERR 1345 - || cc == IPMI_DEVICE_IN_INIT_ERR 1346 - || cc == IPMI_NOT_IN_MY_STATE_ERR) 1347 - && ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { 1349 + if (cc != IPMI_CC_NO_ERROR && 1350 + ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { 1348 1351 dev_warn(smi_info->io.dev, 1349 1352 "BMC returned 0x%2.2x, retry get bmc device id\n", 1350 1353 cc); ··· 2200 2207 if (smi_info->handlers) 2201 2208 smi_info->handlers->cleanup(smi_info->si_sm); 2202 2209 2203 - if (smi_info->io.addr_source_cleanup) { 2204 - smi_info->io.addr_source_cleanup(&smi_info->io); 2205 - smi_info->io.addr_source_cleanup = NULL; 2206 - } 2207 2210 if (smi_info->io.io_cleanup) { 2208 2211 smi_info->io.io_cleanup(&smi_info->io); 2209 2212 smi_info->io.io_cleanup = NULL; ··· 2295 2306 MODULE_ALIAS("platform:dmi-ipmi-si"); 2296 2307 MODULE_LICENSE("GPL"); 2297 2308 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); 2298 - MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT" 2299 - " system interfaces."); 2309 + MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces.");
+4 -18
drivers/char/ipmi/ipmi_si_pci.c
··· 16 16 static bool si_trypci = true; 17 17 18 18 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"); 21 21 22 22 #define PCI_DEVICE_ID_HP_MMC 0x121A 23 - 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 23 31 24 static int ipmi_pci_probe_regspacing(struct si_sm_io *io) 32 25 { ··· 90 97 return -ENOMEM; 91 98 } 92 99 93 - rv = pci_enable_device(pdev); 100 + rv = pcim_enable_device(pdev); 94 101 if (rv) { 95 102 dev_err(&pdev->dev, "couldn't enable PCI device\n"); 96 103 return rv; 97 104 } 98 - 99 - io.addr_source_cleanup = ipmi_pci_cleanup; 100 - io.addr_source_data = pdev; 101 105 102 106 if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) { 103 107 io.addr_space = IPMI_IO_ADDR_SPACE; ··· 118 128 dev_info(&pdev->dev, "%pR regsize %d spacing %d irq %d\n", 119 129 &pdev->resource[0], io.regsize, io.regspacing, io.irq); 120 130 121 - rv = ipmi_si_add_smi(&io); 122 - if (rv) 123 - pci_disable_device(pdev); 124 - 125 - return rv; 131 + return ipmi_si_add_smi(&io); 126 132 } 127 133 128 134 static void ipmi_pci_remove(struct pci_dev *pdev)
+40 -55
drivers/char/ipmi/ipmi_si_platform.c
··· 34 34 #endif 35 35 36 36 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"); 40 39 #ifdef CONFIG_ACPI 41 40 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"); 44 43 #endif 45 44 #ifdef CONFIG_OF 46 45 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"); 49 48 #endif 50 49 #ifdef CONFIG_DMI 51 50 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"); 54 53 #endif 55 54 56 55 #ifdef CONFIG_ACPI ··· 84 85 ACPI_GPE_LEVEL_TRIGGERED, 85 86 &ipmi_acpi_gpe, 86 87 io); 87 - if (status != AE_OK) { 88 + if (ACPI_FAILURE(status)) { 88 89 dev_warn(io->dev, 89 90 "Unable to claim ACPI GPE %d, running polled\n", 90 91 io->irq); 91 92 io->irq = 0; 92 93 return -EINVAL; 93 - } else { 94 - io->irq_cleanup = acpi_gpe_irq_cleanup; 95 - ipmi_irq_finish_setup(io); 96 - dev_info(io->dev, "Using ACPI GPE %d\n", io->irq); 97 - return 0; 98 94 } 95 + 96 + io->irq_cleanup = acpi_gpe_irq_cleanup; 97 + ipmi_irq_finish_setup(io); 98 + dev_info(io->dev, "Using ACPI GPE %d\n", io->irq); 99 + return 0; 99 100 } 100 101 #endif 102 + 103 + static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io) 104 + { 105 + if (resource_type(r) == IORESOURCE_IO) 106 + io->addr_space = IPMI_IO_ADDR_SPACE; 107 + else 108 + io->addr_space = IPMI_MEM_ADDR_SPACE; 109 + io->addr_data = r->start; 110 + } 101 111 102 112 static struct resource * 103 113 ipmi_get_info_from_resources(struct platform_device *pdev, ··· 114 106 { 115 107 struct resource *res, *res_second; 116 108 117 - res = platform_get_resource(pdev, IORESOURCE_IO, 0); 118 - if (res) { 119 - io->addr_space = IPMI_IO_ADDR_SPACE; 120 - } else { 121 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 122 - if (res) 123 - io->addr_space = IPMI_MEM_ADDR_SPACE; 124 - } 109 + res = platform_get_mem_or_io(pdev, 0); 125 110 if (!res) { 126 111 dev_err(&pdev->dev, "no I/O or memory address\n"); 127 112 return NULL; 128 113 } 129 - io->addr_data = res->start; 114 + ipmi_set_addr_data_and_space(res, io); 130 115 131 116 io->regspacing = DEFAULT_REGSPACING; 132 - res_second = platform_get_resource(pdev, 133 - (io->addr_space == IPMI_IO_ADDR_SPACE) ? 134 - IORESOURCE_IO : IORESOURCE_MEM, 135 - 1); 136 - if (res_second) { 117 + res_second = platform_get_mem_or_io(pdev, 1); 118 + if (res_second && resource_type(res_second) == resource_type(res)) { 137 119 if (res_second->start > io->addr_data) 138 120 io->regspacing = res_second->start - io->addr_data; 139 121 } ··· 273 275 io.addr_source = SI_DEVICETREE; 274 276 io.irq_setup = ipmi_std_irq_setup; 275 277 276 - if (resource.flags & IORESOURCE_IO) 277 - io.addr_space = IPMI_IO_ADDR_SPACE; 278 - else 279 - io.addr_space = IPMI_MEM_ADDR_SPACE; 280 - 281 - io.addr_data = resource.start; 278 + ipmi_set_addr_data_and_space(&resource, &io); 282 279 283 280 io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE; 284 281 io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING; ··· 310 317 311 318 static int acpi_ipmi_probe(struct platform_device *pdev) 312 319 { 320 + struct device *dev = &pdev->dev; 313 321 struct si_sm_io io; 314 322 acpi_handle handle; 315 323 acpi_status status; 316 324 unsigned long long tmp; 317 325 struct resource *res; 318 - int rv = -EINVAL; 319 326 320 327 if (!si_tryacpi) 321 328 return -ENODEV; 322 329 323 - handle = ACPI_HANDLE(&pdev->dev); 330 + handle = ACPI_HANDLE(dev); 324 331 if (!handle) 325 332 return -ENODEV; 326 333 327 334 memset(&io, 0, sizeof(io)); 328 335 io.addr_source = SI_ACPI; 329 - dev_info(&pdev->dev, "probing via ACPI\n"); 336 + dev_info(dev, "probing via ACPI\n"); 330 337 331 338 io.addr_info.acpi_info.acpi_handle = handle; 332 339 333 340 /* _IFT tells us the interface type: KCS, BT, etc */ 334 341 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp); 335 342 if (ACPI_FAILURE(status)) { 336 - dev_err(&pdev->dev, 337 - "Could not find ACPI IPMI interface type\n"); 338 - goto err_free; 343 + dev_err(dev, "Could not find ACPI IPMI interface type\n"); 344 + return -EINVAL; 339 345 } 340 346 341 347 switch (tmp) { ··· 348 356 io.si_type = SI_BT; 349 357 break; 350 358 case 4: /* SSIF, just ignore */ 351 - rv = -ENODEV; 352 - goto err_free; 359 + return -ENODEV; 353 360 default: 354 - dev_info(&pdev->dev, "unknown IPMI type %lld\n", tmp); 355 - goto err_free; 361 + dev_info(dev, "unknown IPMI type %lld\n", tmp); 362 + return -EINVAL; 356 363 } 357 364 365 + io.dev = dev; 358 366 io.regsize = DEFAULT_REGSIZE; 359 367 io.regshift = 0; 360 368 361 369 res = ipmi_get_info_from_resources(pdev, &io); 362 - if (!res) { 363 - rv = -EINVAL; 364 - goto err_free; 365 - } 370 + if (!res) 371 + return -EINVAL; 366 372 367 373 /* If _GPE exists, use it; otherwise use standard interrupts */ 368 374 status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp); ··· 378 388 379 389 io.slave_addr = find_slave_address(&io, io.slave_addr); 380 390 381 - io.dev = &pdev->dev; 382 - 383 - dev_info(io.dev, "%pR regsize %d spacing %d irq %d\n", 391 + dev_info(dev, "%pR regsize %d spacing %d irq %d\n", 384 392 res, io.regsize, io.regspacing, io.irq); 385 393 386 394 request_module("acpi_ipmi"); 387 395 388 396 return ipmi_si_add_smi(&io); 389 - 390 - err_free: 391 - return rv; 392 397 } 393 398 394 399 static const struct acpi_device_id acpi_ipmi_match[] = {
+20 -61
drivers/char/ipmi/ipmi_ssif.c
··· 510 510 return 0; 511 511 } 512 512 513 - static int ssif_i2c_send(struct ssif_info *ssif_info, 513 + static void ssif_i2c_send(struct ssif_info *ssif_info, 514 514 ssif_i2c_done handler, 515 515 int read_write, int command, 516 516 unsigned char *data, unsigned int size) ··· 522 522 ssif_info->i2c_data = data; 523 523 ssif_info->i2c_size = size; 524 524 complete(&ssif_info->wake_thread); 525 - return 0; 526 525 } 527 526 528 527 ··· 530 531 531 532 static void start_get(struct ssif_info *ssif_info) 532 533 { 533 - int rv; 534 - 535 534 ssif_info->rtc_us_timer = 0; 536 535 ssif_info->multi_pos = 0; 537 536 538 - rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, 539 - SSIF_IPMI_RESPONSE, 540 - ssif_info->recv, I2C_SMBUS_BLOCK_DATA); 541 - if (rv < 0) { 542 - /* request failed, just return the error. */ 543 - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 544 - dev_dbg(&ssif_info->client->dev, 545 - "Error from i2c_non_blocking_op(5)\n"); 546 - 547 - msg_done_handler(ssif_info, -EIO, NULL, 0); 548 - } 537 + ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, 538 + SSIF_IPMI_RESPONSE, 539 + ssif_info->recv, I2C_SMBUS_BLOCK_DATA); 549 540 } 550 541 551 542 static void retry_timeout(struct timer_list *t) ··· 609 620 { 610 621 struct ipmi_smi_msg *msg; 611 622 unsigned long oflags, *flags; 612 - int rv; 613 623 614 624 /* 615 625 * We are single-threaded here, so no need for a lock until we ··· 654 666 ssif_info->multi_len = len; 655 667 ssif_info->multi_pos = 1; 656 668 657 - rv = 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 - if (rv < 0) { 661 - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 662 - dev_dbg(&ssif_info->client->dev, 663 - "Error from i2c_non_blocking_op(1)\n"); 664 - 665 - result = -EIO; 666 - } else 667 - return; 669 + 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 + return; 668 673 } else if (ssif_info->multi_pos) { 669 674 /* Middle of multi-part read. Start the next transaction. */ 670 675 int i; ··· 719 738 720 739 ssif_info->multi_pos++; 721 740 722 - rv = 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 - if (rv < 0) { 728 - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 729 - dev_dbg(&ssif_info->client->dev, 730 - "Error from ssif_i2c_send\n"); 731 - 732 - result = -EIO; 733 - } else 734 - return; 741 + 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 + return; 735 747 } 736 748 } 737 749 ··· 882 908 static void msg_written_handler(struct ssif_info *ssif_info, int result, 883 909 unsigned char *data, unsigned int len) 884 910 { 885 - int rv; 886 - 887 911 /* We are single-threaded here, so no need for a lock. */ 888 912 if (result < 0) { 889 913 ssif_info->retries_left--; ··· 944 972 ssif_info->multi_data = NULL; 945 973 } 946 974 947 - rv = ssif_i2c_send(ssif_info, msg_written_handler, 948 - I2C_SMBUS_WRITE, cmd, 949 - data_to_send, I2C_SMBUS_BLOCK_DATA); 950 - if (rv < 0) { 951 - /* request failed, just return the error. */ 952 - ssif_inc_stat(ssif_info, send_errors); 953 - 954 - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 955 - dev_dbg(&ssif_info->client->dev, 956 - "Error from i2c_non_blocking_op(3)\n"); 957 - msg_done_handler(ssif_info, -EIO, NULL, 0); 958 - } 975 + ssif_i2c_send(ssif_info, msg_written_handler, 976 + I2C_SMBUS_WRITE, cmd, 977 + data_to_send, I2C_SMBUS_BLOCK_DATA); 959 978 } else { 960 979 /* Ready to request the result. */ 961 980 unsigned long oflags, *flags; ··· 975 1012 976 1013 static int start_resend(struct ssif_info *ssif_info) 977 1014 { 978 - int rv; 979 1015 int command; 980 1016 981 1017 ssif_info->got_alert = false; ··· 996 1034 ssif_info->data[0] = ssif_info->data_len; 997 1035 } 998 1036 999 - rv = ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE, 1000 - command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); 1001 - if (rv && (ssif_info->ssif_debug & SSIF_DEBUG_MSG)) 1002 - dev_dbg(&ssif_info->client->dev, 1003 - "Error from i2c_non_blocking_op(4)\n"); 1004 - return rv; 1037 + ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE, 1038 + command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); 1039 + return 0; 1005 1040 } 1006 1041 1007 1042 static int start_send(struct ssif_info *ssif_info,