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

ACPI / IPMI: Cleanup coding styles

This patch only introduces indentation cleanups. No functional changes.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Lv Zheng and committed by
Rafael J. Wysocki
50065300 4b88e330

+65 -40
+65 -40
drivers/acpi/acpi_ipmi.c
··· 33 33 MODULE_DESCRIPTION("ACPI IPMI Opregion driver"); 34 34 MODULE_LICENSE("GPL"); 35 35 36 - 37 36 #define ACPI_IPMI_OK 0 38 37 #define ACPI_IPMI_TIMEOUT 0x10 39 38 #define ACPI_IPMI_UNKNOWN 0x07 ··· 43 44 struct acpi_ipmi_device { 44 45 /* the device list attached to driver_data.ipmi_devices */ 45 46 struct list_head head; 47 + 46 48 /* the IPMI request message list */ 47 49 struct list_head tx_msg_list; 48 - spinlock_t tx_msg_lock; 50 + 51 + spinlock_t tx_msg_lock; 49 52 acpi_handle handle; 50 53 struct device *dev; 51 - ipmi_user_t user_interface; 54 + ipmi_user_t user_interface; 52 55 int ipmi_ifnum; /* IPMI interface number */ 53 56 long curr_msgid; 54 57 bool dead; ··· 58 57 }; 59 58 60 59 struct ipmi_driver_data { 61 - struct list_head ipmi_devices; 62 - struct ipmi_smi_watcher bmc_events; 63 - struct ipmi_user_hndl ipmi_hndlrs; 64 - struct mutex ipmi_lock; 60 + struct list_head ipmi_devices; 61 + struct ipmi_smi_watcher bmc_events; 62 + struct ipmi_user_hndl ipmi_hndlrs; 63 + struct mutex ipmi_lock; 64 + 65 65 /* 66 66 * NOTE: IPMI System Interface Selection 67 67 * There is no system interface specified by the IPMI operation ··· 75 73 76 74 struct acpi_ipmi_msg { 77 75 struct list_head head; 76 + 78 77 /* 79 78 * General speaking the addr type should be SI_ADDR_TYPE. And 80 79 * the addr channel should be BMC. ··· 85 82 */ 86 83 struct ipmi_addr addr; 87 84 long tx_msgid; 85 + 88 86 /* it is used to track whether the IPMI message is finished */ 89 87 struct completion tx_complete; 88 + 90 89 struct kernel_ipmi_msg tx_message; 91 - int msg_done; 90 + int msg_done; 91 + 92 92 /* tx/rx data . And copy it from/to ACPI object buffer */ 93 - u8 data[ACPI_IPMI_MAX_MSG_LENGTH]; 94 - u8 rx_len; 93 + u8 data[ACPI_IPMI_MAX_MSG_LENGTH]; 94 + u8 rx_len; 95 + 95 96 struct acpi_ipmi_device *device; 96 - struct kref kref; 97 + struct kref kref; 97 98 }; 98 99 99 100 /* IPMI request/response buffer per ACPI 4.0, sec 5.5.2.4.3.2 */ ··· 139 132 INIT_LIST_HEAD(&ipmi_device->head); 140 133 INIT_LIST_HEAD(&ipmi_device->tx_msg_list); 141 134 spin_lock_init(&ipmi_device->tx_msg_lock); 142 - 143 135 ipmi_device->handle = handle; 144 136 ipmi_device->dev = get_device(dev); 145 137 ipmi_device->ipmi_ifnum = iface; ··· 175 169 list_del(&ipmi_device->head); 176 170 if (driver_data.selected_smi == ipmi_device) 177 171 driver_data.selected_smi = NULL; 172 + 178 173 /* 179 174 * Always setting dead flag after deleting from the list or 180 175 * list_for_each_entry() codes must get changed. ··· 210 203 ipmi = acpi_ipmi_dev_get(); 211 204 if (!ipmi) 212 205 return NULL; 206 + 213 207 ipmi_msg = kzalloc(sizeof(struct acpi_ipmi_msg), GFP_KERNEL); 214 208 if (!ipmi_msg) { 215 209 acpi_ipmi_dev_put(ipmi); 216 210 return NULL; 217 211 } 212 + 218 213 kref_init(&ipmi_msg->kref); 219 214 init_completion(&ipmi_msg->tx_complete); 220 215 INIT_LIST_HEAD(&ipmi_msg->head); 221 216 ipmi_msg->device = ipmi; 222 217 ipmi_msg->msg_done = ACPI_IPMI_UNKNOWN; 218 + 223 219 return ipmi_msg; 224 220 } 225 221 ··· 252 242 kref_put(&tx_msg->kref, ipmi_msg_release_kref); 253 243 } 254 244 255 - #define IPMI_OP_RGN_NETFN(offset) ((offset >> 8) & 0xff) 256 - #define IPMI_OP_RGN_CMD(offset) (offset & 0xff) 245 + #define IPMI_OP_RGN_NETFN(offset) ((offset >> 8) & 0xff) 246 + #define IPMI_OP_RGN_CMD(offset) (offset & 0xff) 257 247 static int acpi_format_ipmi_request(struct acpi_ipmi_msg *tx_msg, 258 - acpi_physical_address address, 259 - acpi_integer *value) 248 + acpi_physical_address address, 249 + acpi_integer *value) 260 250 { 261 251 struct kernel_ipmi_msg *msg; 262 252 struct acpi_ipmi_buffer *buffer; ··· 264 254 unsigned long flags; 265 255 266 256 msg = &tx_msg->tx_message; 257 + 267 258 /* 268 259 * IPMI network function and command are encoded in the address 269 260 * within the IPMI OpRegion; see ACPI 4.0, sec 5.5.2.4.3. ··· 272 261 msg->netfn = IPMI_OP_RGN_NETFN(address); 273 262 msg->cmd = IPMI_OP_RGN_CMD(address); 274 263 msg->data = tx_msg->data; 264 + 275 265 /* 276 266 * value is the parameter passed by the IPMI opregion space handler. 277 267 * It points to the IPMI request message buffer 278 268 */ 279 269 buffer = (struct acpi_ipmi_buffer *)value; 270 + 280 271 /* copy the tx message data */ 281 272 if (buffer->length > ACPI_IPMI_MAX_MSG_LENGTH) { 282 273 dev_WARN_ONCE(tx_msg->device->dev, true, ··· 288 275 } 289 276 msg->data_len = buffer->length; 290 277 memcpy(tx_msg->data, buffer->data, msg->data_len); 278 + 291 279 /* 292 280 * now the default type is SYSTEM_INTERFACE and channel type is BMC. 293 281 * If the netfn is APP_REQUEST and the cmd is SEND_MESSAGE, ··· 302 288 303 289 /* Get the msgid */ 304 290 device = tx_msg->device; 291 + 305 292 spin_lock_irqsave(&device->tx_msg_lock, flags); 306 293 device->curr_msgid++; 307 294 tx_msg->tx_msgid = device->curr_msgid; 308 295 spin_unlock_irqrestore(&device->tx_msg_lock, flags); 296 + 309 297 return 0; 310 298 } 311 299 312 300 static void acpi_format_ipmi_response(struct acpi_ipmi_msg *msg, 313 - acpi_integer *value) 301 + acpi_integer *value) 314 302 { 315 303 struct acpi_ipmi_buffer *buffer; 316 304 ··· 321 305 * IPMI message returned by IPMI command. 322 306 */ 323 307 buffer = (struct acpi_ipmi_buffer *)value; 308 + 324 309 /* 325 310 * If the flag of msg_done is not set, it means that the IPMI command is 326 311 * not executed correctly. ··· 329 312 buffer->status = msg->msg_done; 330 313 if (msg->msg_done != ACPI_IPMI_OK) 331 314 return; 315 + 332 316 /* 333 317 * If the IPMI response message is obtained correctly, the status code 334 318 * will be ACPI_IPMI_OK ··· 397 379 unsigned long flags; 398 380 399 381 if (msg->user != ipmi_device->user_interface) { 400 - dev_warn(dev, "Unexpected response is returned. " 401 - "returned user %p, expected user %p\n", 402 - msg->user, ipmi_device->user_interface); 382 + dev_warn(dev, 383 + "Unexpected response is returned. returned user %p, expected user %p\n", 384 + msg->user, ipmi_device->user_interface); 403 385 goto out_msg; 404 386 } 387 + 405 388 spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags); 406 389 list_for_each_entry_safe(tx_msg, temp, &ipmi_device->tx_msg_list, head) { 407 390 if (msg->msgid == tx_msg->tx_msgid) { ··· 414 395 spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags); 415 396 416 397 if (!msg_found) { 417 - dev_warn(dev, "Unexpected response (msg id %ld) is " 418 - "returned.\n", msg->msgid); 398 + dev_warn(dev, 399 + "Unexpected response (msg id %ld) is returned.\n", 400 + msg->msgid); 419 401 goto out_msg; 420 402 } 421 403 ··· 427 407 msg->msg.data_len); 428 408 goto out_comp; 429 409 } 410 + 430 411 /* response msg is an error msg */ 431 412 msg->recv_type = IPMI_RESPONSE_RECV_TYPE; 432 413 if (msg->recv_type == IPMI_RESPONSE_RECV_TYPE && ··· 439 418 } 440 419 goto out_comp; 441 420 } 421 + 442 422 tx_msg->rx_len = msg->msg.data_len; 443 423 memcpy(tx_msg->data, msg->msg.data, tx_msg->rx_len); 444 424 tx_msg->msg_done = ACPI_IPMI_OK; 425 + 445 426 out_comp: 446 427 complete(&tx_msg->tx_complete); 447 428 acpi_ipmi_msg_put(tx_msg); 448 429 out_msg: 449 430 ipmi_free_recv_msg(msg); 450 - }; 431 + } 451 432 452 433 static void ipmi_register_bmc(int iface, struct device *dev) 453 434 { ··· 459 436 acpi_handle handle; 460 437 461 438 err = ipmi_get_smi_info(iface, &smi_data); 462 - 463 439 if (err) 464 440 return; 465 441 ··· 483 461 if (temp->handle == handle) 484 462 goto err_lock; 485 463 } 486 - 487 464 if (!driver_data.selected_smi) 488 465 driver_data.selected_smi = ipmi_device; 489 466 list_add_tail(&ipmi_device->head, &driver_data.ipmi_devices); 490 467 mutex_unlock(&driver_data.ipmi_lock); 468 + 491 469 put_device(smi_data.dev); 492 470 return; 493 471 ··· 506 484 507 485 mutex_lock(&driver_data.ipmi_lock); 508 486 list_for_each_entry_safe(ipmi_device, temp, 509 - &driver_data.ipmi_devices, head) { 487 + &driver_data.ipmi_devices, head) { 510 488 if (ipmi_device->ipmi_ifnum != iface) { 511 489 dev_found = true; 512 490 __ipmi_dev_kill(ipmi_device); ··· 518 496 &driver_data.ipmi_devices, 519 497 struct acpi_ipmi_device, head); 520 498 mutex_unlock(&driver_data.ipmi_lock); 499 + 521 500 if (dev_found) { 522 501 ipmi_flush_tx_msg(ipmi_device); 523 502 acpi_ipmi_dev_put(ipmi_device); 524 503 } 525 504 } 526 - /* -------------------------------------------------------------------------- 527 - * Address Space Management 528 - * -------------------------------------------------------------------------- */ 505 + 529 506 /* 530 507 * This is the IPMI opregion space handler. 531 508 * @function: indicates the read/write. In fact as the IPMI message is driven ··· 537 516 * the response IPMI message returned by IPMI command. 538 517 * @handler_context: IPMI device context. 539 518 */ 540 - 541 519 static acpi_status 542 520 acpi_ipmi_space_handler(u32 function, acpi_physical_address address, 543 - u32 bits, acpi_integer *value, 544 - void *handler_context, void *region_context) 521 + u32 bits, acpi_integer *value, 522 + void *handler_context, void *region_context) 545 523 { 546 524 struct acpi_ipmi_msg *tx_msg; 547 525 struct acpi_ipmi_device *ipmi_device; 548 526 int err; 549 527 acpi_status status; 550 528 unsigned long flags; 529 + 551 530 /* 552 531 * IPMI opregion message. 553 532 * IPMI message is firstly written to the BMC and system software ··· 560 539 tx_msg = ipmi_msg_alloc(); 561 540 if (!tx_msg) 562 541 return AE_NOT_EXIST; 563 - 564 542 ipmi_device = tx_msg->device; 565 543 566 544 if (acpi_format_ipmi_request(tx_msg, address, value) != 0) { 567 545 ipmi_msg_release(tx_msg); 568 546 return AE_TYPE; 569 547 } 548 + 570 549 acpi_ipmi_msg_get(tx_msg); 571 550 mutex_lock(&driver_data.ipmi_lock); 572 551 /* Do not add a tx_msg that can not be flushed. */ ··· 579 558 list_add_tail(&tx_msg->head, &ipmi_device->tx_msg_list); 580 559 spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags); 581 560 mutex_unlock(&driver_data.ipmi_lock); 561 + 582 562 err = ipmi_request_settime(ipmi_device->user_interface, 583 - &tx_msg->addr, 584 - tx_msg->tx_msgid, 585 - &tx_msg->tx_message, 586 - NULL, 0, 0, IPMI_TIMEOUT); 563 + &tx_msg->addr, 564 + tx_msg->tx_msgid, 565 + &tx_msg->tx_message, 566 + NULL, 0, 0, IPMI_TIMEOUT); 587 567 if (err) { 588 568 status = AE_ERROR; 589 569 goto out_msg; 590 570 } 591 571 wait_for_completion(&tx_msg->tx_complete); 572 + 592 573 acpi_format_ipmi_response(tx_msg, value); 593 574 status = AE_OK; 594 575 ··· 609 586 return 0; 610 587 611 588 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, 612 - ACPI_ADR_SPACE_IPMI, &acpi_ipmi_space_handler, 613 - NULL, NULL); 589 + ACPI_ADR_SPACE_IPMI, 590 + &acpi_ipmi_space_handler, 591 + NULL, NULL); 614 592 if (ACPI_FAILURE(status)) { 615 593 pr_warn("Can't register IPMI opregion space handle\n"); 616 594 return -EINVAL; ··· 653 629 } 654 630 mutex_unlock(&driver_data.ipmi_lock); 655 631 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 656 - ACPI_ADR_SPACE_IPMI, &acpi_ipmi_space_handler); 632 + ACPI_ADR_SPACE_IPMI, 633 + &acpi_ipmi_space_handler); 657 634 } 658 635 659 636 module_init(acpi_ipmi_init);