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

ipmi: style fixes in the base code

Lots of style fixes for the base IPMI driver. No functional changes.
Basically fixes everything reported by checkpatch and fixes the comment
style.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Corey Minyard and committed by
Linus Torvalds
c70d7499 ba8ff1c6

+613 -460
+580 -413
drivers/char/ipmi/ipmi_msghandler.c
··· 63 63 64 64 #define MAX_EVENTS_IN_QUEUE 25 65 65 66 - /* Don't let a message sit in a queue forever, always time it with at lest 67 - the max message timer. This is in milliseconds. */ 66 + /* 67 + * Don't let a message sit in a queue forever, always time it with at lest 68 + * the max message timer. This is in milliseconds. 69 + */ 68 70 #define MAX_MSG_TIMEOUT 60000 69 71 70 72 /* 71 73 * The main "user" data structure. 72 74 */ 73 - struct ipmi_user 74 - { 75 + struct ipmi_user { 75 76 struct list_head link; 76 77 77 78 /* Set to "0" when the user is destroyed. */ ··· 91 90 int gets_events; 92 91 }; 93 92 94 - struct cmd_rcvr 95 - { 93 + struct cmd_rcvr { 96 94 struct list_head link; 97 95 98 96 ipmi_user_t user; ··· 105 105 * or change any data until the RCU period completes. So we 106 106 * use this next variable during mass deletion so we can have 107 107 * a list and don't have to wait and restart the search on 108 - * every individual deletion of a command. */ 108 + * every individual deletion of a command. 109 + */ 109 110 struct cmd_rcvr *next; 110 111 }; 111 112 112 - struct seq_table 113 - { 113 + struct seq_table { 114 114 unsigned int inuse : 1; 115 115 unsigned int broadcast : 1; 116 116 ··· 118 118 unsigned long orig_timeout; 119 119 unsigned int retries_left; 120 120 121 - /* To verify on an incoming send message response that this is 122 - the message that the response is for, we keep a sequence id 123 - and increment it every time we send a message. */ 121 + /* 122 + * To verify on an incoming send message response that this is 123 + * the message that the response is for, we keep a sequence id 124 + * and increment it every time we send a message. 125 + */ 124 126 long seqid; 125 127 126 - /* This is held so we can properly respond to the message on a 127 - timeout, and it is used to hold the temporary data for 128 - retransmission, too. */ 128 + /* 129 + * This is held so we can properly respond to the message on a 130 + * timeout, and it is used to hold the temporary data for 131 + * retransmission, too. 132 + */ 129 133 struct ipmi_recv_msg *recv_msg; 130 134 }; 131 135 132 - /* Store the information in a msgid (long) to allow us to find a 133 - sequence table entry from the msgid. */ 136 + /* 137 + * Store the information in a msgid (long) to allow us to find a 138 + * sequence table entry from the msgid. 139 + */ 134 140 #define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff)) 135 141 136 142 #define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \ 137 143 do { \ 138 144 seq = ((msgid >> 26) & 0x3f); \ 139 145 seqid = (msgid & 0x3fffff); \ 140 - } while (0) 146 + } while (0) 141 147 142 148 #define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff) 143 149 144 - struct ipmi_channel 145 - { 150 + struct ipmi_channel { 146 151 unsigned char medium; 147 152 unsigned char protocol; 148 153 149 - /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, 150 - but may be changed by the user. */ 154 + /* 155 + * My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, 156 + * but may be changed by the user. 157 + */ 151 158 unsigned char address; 152 159 153 - /* My LUN. This should generally stay the SMS LUN, but just in 154 - case... */ 160 + /* 161 + * My LUN. This should generally stay the SMS LUN, but just in 162 + * case... 163 + */ 155 164 unsigned char lun; 156 165 }; 157 166 158 167 #ifdef CONFIG_PROC_FS 159 - struct ipmi_proc_entry 160 - { 168 + struct ipmi_proc_entry { 161 169 char *name; 162 170 struct ipmi_proc_entry *next; 163 171 }; 164 172 #endif 165 173 166 - struct bmc_device 167 - { 174 + struct bmc_device { 168 175 struct platform_device *dev; 169 176 struct ipmi_device_id id; 170 177 unsigned char guid[16]; ··· 293 286 294 287 #define IPMI_IPMB_NUM_SEQ 64 295 288 #define IPMI_MAX_CHANNELS 16 296 - struct ipmi_smi 297 - { 289 + struct ipmi_smi { 298 290 /* What interface number are we? */ 299 291 int intf_num; 300 292 ··· 302 296 /* Used for a list of interfaces. */ 303 297 struct list_head link; 304 298 305 - /* The list of upper layers that are using me. seq_lock 306 - * protects this. */ 299 + /* 300 + * The list of upper layers that are using me. seq_lock 301 + * protects this. 302 + */ 307 303 struct list_head users; 308 304 309 305 /* Information to supply to users. */ ··· 319 311 char *my_dev_name; 320 312 char *sysfs_name; 321 313 322 - /* This is the lower-layer's sender routine. Note that you 314 + /* 315 + * This is the lower-layer's sender routine. Note that you 323 316 * must either be holding the ipmi_interfaces_mutex or be in 324 317 * an umpreemptible region to use this. You must fetch the 325 - * value into a local variable and make sure it is not NULL. */ 318 + * value into a local variable and make sure it is not NULL. 319 + */ 326 320 struct ipmi_smi_handlers *handlers; 327 321 void *send_info; 328 322 ··· 337 327 /* Driver-model device for the system interface. */ 338 328 struct device *si_dev; 339 329 340 - /* A table of sequence numbers for this interface. We use the 341 - sequence numbers for IPMB messages that go out of the 342 - interface to match them up with their responses. A routine 343 - is called periodically to time the items in this list. */ 330 + /* 331 + * A table of sequence numbers for this interface. We use the 332 + * sequence numbers for IPMB messages that go out of the 333 + * interface to match them up with their responses. A routine 334 + * is called periodically to time the items in this list. 335 + */ 344 336 spinlock_t seq_lock; 345 337 struct seq_table seq_table[IPMI_IPMB_NUM_SEQ]; 346 338 int curr_seq; 347 339 348 - /* Messages that were delayed for some reason (out of memory, 349 - for instance), will go in here to be processed later in a 350 - periodic timer interrupt. */ 340 + /* 341 + * Messages that were delayed for some reason (out of memory, 342 + * for instance), will go in here to be processed later in a 343 + * periodic timer interrupt. 344 + */ 351 345 spinlock_t waiting_msgs_lock; 352 346 struct list_head waiting_msgs; 353 347 354 - /* The list of command receivers that are registered for commands 355 - on this interface. */ 348 + /* 349 + * The list of command receivers that are registered for commands 350 + * on this interface. 351 + */ 356 352 struct mutex cmd_rcvrs_mutex; 357 353 struct list_head cmd_rcvrs; 358 354 359 - /* Events that were queues because no one was there to receive 360 - them. */ 355 + /* 356 + * Events that were queues because no one was there to receive 357 + * them. 358 + */ 361 359 spinlock_t events_lock; /* For dealing with event stuff. */ 362 360 struct list_head waiting_events; 363 361 unsigned int waiting_events_count; /* How many events in queue? */ 364 362 char delivering_events; 365 363 char event_msg_printed; 366 364 367 - /* The event receiver for my BMC, only really used at panic 368 - shutdown as a place to store this. */ 365 + /* 366 + * The event receiver for my BMC, only really used at panic 367 + * shutdown as a place to store this. 368 + */ 369 369 unsigned char event_receiver; 370 370 unsigned char event_receiver_lun; 371 371 unsigned char local_sel_device; ··· 387 367 int auto_maintenance_timeout; 388 368 spinlock_t maintenance_mode_lock; /* Used in a timer... */ 389 369 390 - /* A cheap hack, if this is non-null and a message to an 391 - interface comes in with a NULL user, call this routine with 392 - it. Note that the message will still be freed by the 393 - caller. This only works on the system interface. */ 370 + /* 371 + * A cheap hack, if this is non-null and a message to an 372 + * interface comes in with a NULL user, call this routine with 373 + * it. Note that the message will still be freed by the 374 + * caller. This only works on the system interface. 375 + */ 394 376 void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg); 395 377 396 - /* When we are scanning the channels for an SMI, this will 397 - tell which channel we are scanning. */ 378 + /* 379 + * When we are scanning the channels for an SMI, this will 380 + * tell which channel we are scanning. 381 + */ 398 382 int curr_channel; 399 383 400 384 /* Channel information */ ··· 431 407 static LIST_HEAD(ipmi_interfaces); 432 408 static DEFINE_MUTEX(ipmi_interfaces_mutex); 433 409 434 - /* List of watchers that want to know when smi's are added and 435 - deleted. */ 410 + /* 411 + * List of watchers that want to know when smi's are added and deleted. 412 + */ 436 413 static LIST_HEAD(smi_watchers); 437 414 static DEFINE_MUTEX(smi_watchers_mutex); 438 415 ··· 487 462 488 463 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 489 464 if ((intf->seq_table[i].inuse) 490 - && (intf->seq_table[i].recv_msg)) 491 - { 465 + && (intf->seq_table[i].recv_msg)) 492 466 ipmi_free_recv_msg(intf->seq_table[i].recv_msg); 493 - } 494 467 } 495 468 } 496 469 ··· 555 532 } 556 533 return -ENOMEM; 557 534 } 535 + EXPORT_SYMBOL(ipmi_smi_watcher_register); 558 536 559 537 int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) 560 538 { ··· 564 540 mutex_unlock(&smi_watchers_mutex); 565 541 return 0; 566 542 } 543 + EXPORT_SYMBOL(ipmi_smi_watcher_unregister); 567 544 568 545 /* 569 546 * Must be called with smi_watchers_mutex held. ··· 600 575 } 601 576 602 577 if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE) 603 - || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 604 - { 578 + || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 605 579 struct ipmi_ipmb_addr *ipmb_addr1 606 580 = (struct ipmi_ipmb_addr *) addr1; 607 581 struct ipmi_ipmb_addr *ipmb_addr2 ··· 628 604 629 605 int ipmi_validate_addr(struct ipmi_addr *addr, int len) 630 606 { 631 - if (len < sizeof(struct ipmi_system_interface_addr)) { 607 + if (len < sizeof(struct ipmi_system_interface_addr)) 632 608 return -EINVAL; 633 - } 634 609 635 610 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { 636 611 if (addr->channel != IPMI_BMC_CHANNEL) ··· 643 620 return -EINVAL; 644 621 645 622 if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 646 - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 647 - { 648 - if (len < sizeof(struct ipmi_ipmb_addr)) { 623 + || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 624 + if (len < sizeof(struct ipmi_ipmb_addr)) 649 625 return -EINVAL; 650 - } 651 626 return 0; 652 627 } 653 628 654 629 if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 655 - if (len < sizeof(struct ipmi_lan_addr)) { 630 + if (len < sizeof(struct ipmi_lan_addr)) 656 631 return -EINVAL; 657 - } 658 632 return 0; 659 633 } 660 634 661 635 return -EINVAL; 662 636 } 637 + EXPORT_SYMBOL(ipmi_validate_addr); 663 638 664 639 unsigned int ipmi_addr_length(int addr_type) 665 640 { ··· 665 644 return sizeof(struct ipmi_system_interface_addr); 666 645 667 646 if ((addr_type == IPMI_IPMB_ADDR_TYPE) 668 - || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 669 - { 647 + || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 670 648 return sizeof(struct ipmi_ipmb_addr); 671 - } 672 649 673 650 if (addr_type == IPMI_LAN_ADDR_TYPE) 674 651 return sizeof(struct ipmi_lan_addr); 675 652 676 653 return 0; 677 654 } 655 + EXPORT_SYMBOL(ipmi_addr_length); 678 656 679 657 static void deliver_response(struct ipmi_recv_msg *msg) 680 658 { ··· 706 686 deliver_response(msg); 707 687 } 708 688 709 - /* Find the next sequence number not being used and add the given 710 - message with the given timeout to the sequence table. This must be 711 - called with the interface's seq_lock held. */ 689 + /* 690 + * Find the next sequence number not being used and add the given 691 + * message with the given timeout to the sequence table. This must be 692 + * called with the interface's seq_lock held. 693 + */ 712 694 static int intf_next_seq(ipmi_smi_t intf, 713 695 struct ipmi_recv_msg *recv_msg, 714 696 unsigned long timeout, ··· 722 700 int rv = 0; 723 701 unsigned int i; 724 702 725 - for (i = intf->curr_seq; 726 - (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; 727 - i = (i+1)%IPMI_IPMB_NUM_SEQ) 728 - { 703 + for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; 704 + i = (i+1)%IPMI_IPMB_NUM_SEQ) { 729 705 if (!intf->seq_table[i].inuse) 730 706 break; 731 707 } ··· 731 711 if (!intf->seq_table[i].inuse) { 732 712 intf->seq_table[i].recv_msg = recv_msg; 733 713 734 - /* Start with the maximum timeout, when the send response 735 - comes in we will start the real timer. */ 714 + /* 715 + * Start with the maximum timeout, when the send response 716 + * comes in we will start the real timer. 717 + */ 736 718 intf->seq_table[i].timeout = MAX_MSG_TIMEOUT; 737 719 intf->seq_table[i].orig_timeout = timeout; 738 720 intf->seq_table[i].retries_left = retries; ··· 747 725 } else { 748 726 rv = -EAGAIN; 749 727 } 750 - 728 + 751 729 return rv; 752 730 } 753 731 754 - /* Return the receive message for the given sequence number and 755 - release the sequence number so it can be reused. Some other data 756 - is passed in to be sure the message matches up correctly (to help 757 - guard against message coming in after their timeout and the 758 - sequence number being reused). */ 732 + /* 733 + * Return the receive message for the given sequence number and 734 + * release the sequence number so it can be reused. Some other data 735 + * is passed in to be sure the message matches up correctly (to help 736 + * guard against message coming in after their timeout and the 737 + * sequence number being reused). 738 + */ 759 739 static int intf_find_seq(ipmi_smi_t intf, 760 740 unsigned char seq, 761 741 short channel, ··· 776 752 if (intf->seq_table[seq].inuse) { 777 753 struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg; 778 754 779 - if ((msg->addr.channel == channel) 780 - && (msg->msg.cmd == cmd) 781 - && (msg->msg.netfn == netfn) 782 - && (ipmi_addr_equal(addr, &(msg->addr)))) 783 - { 755 + if ((msg->addr.channel == channel) && (msg->msg.cmd == cmd) 756 + && (msg->msg.netfn == netfn) 757 + && (ipmi_addr_equal(addr, &(msg->addr)))) { 784 758 *recv_msg = msg; 785 759 intf->seq_table[seq].inuse = 0; 786 760 rv = 0; ··· 803 781 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 804 782 805 783 spin_lock_irqsave(&(intf->seq_lock), flags); 806 - /* We do this verification because the user can be deleted 807 - while a message is outstanding. */ 784 + /* 785 + * We do this verification because the user can be deleted 786 + * while a message is outstanding. 787 + */ 808 788 if ((intf->seq_table[seq].inuse) 809 - && (intf->seq_table[seq].seqid == seqid)) 810 - { 789 + && (intf->seq_table[seq].seqid == seqid)) { 811 790 struct seq_table *ent = &(intf->seq_table[seq]); 812 791 ent->timeout = ent->orig_timeout; 813 792 rv = 0; ··· 833 810 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 834 811 835 812 spin_lock_irqsave(&(intf->seq_lock), flags); 836 - /* We do this verification because the user can be deleted 837 - while a message is outstanding. */ 813 + /* 814 + * We do this verification because the user can be deleted 815 + * while a message is outstanding. 816 + */ 838 817 if ((intf->seq_table[seq].inuse) 839 - && (intf->seq_table[seq].seqid == seqid)) 840 - { 818 + && (intf->seq_table[seq].seqid == seqid)) { 841 819 struct seq_table *ent = &(intf->seq_table[seq]); 842 820 843 821 ent->inuse = 0; ··· 864 840 int rv = 0; 865 841 ipmi_smi_t intf; 866 842 867 - /* There is no module usecount here, because it's not 868 - required. Since this can only be used by and called from 869 - other modules, they will implicitly use this module, and 870 - thus this can't be removed unless the other modules are 871 - removed. */ 843 + /* 844 + * There is no module usecount here, because it's not 845 + * required. Since this can only be used by and called from 846 + * other modules, they will implicitly use this module, and 847 + * thus this can't be removed unless the other modules are 848 + * removed. 849 + */ 872 850 873 851 if (handler == NULL) 874 852 return -EINVAL; 875 853 876 - /* Make sure the driver is actually initialized, this handles 877 - problems with initialization order. */ 854 + /* 855 + * Make sure the driver is actually initialized, this handles 856 + * problems with initialization order. 857 + */ 878 858 if (!initialized) { 879 859 rv = ipmi_init_msghandler(); 880 860 if (rv) 881 861 return rv; 882 862 883 - /* The init code doesn't return an error if it was turned 884 - off, but it won't initialize. Check that. */ 863 + /* 864 + * The init code doesn't return an error if it was turned 865 + * off, but it won't initialize. Check that. 866 + */ 885 867 if (!initialized) 886 868 return -ENODEV; 887 869 } ··· 928 898 } 929 899 } 930 900 931 - /* Hold the lock so intf->handlers is guaranteed to be good 932 - * until now */ 901 + /* 902 + * Hold the lock so intf->handlers is guaranteed to be good 903 + * until now 904 + */ 933 905 mutex_unlock(&ipmi_interfaces_mutex); 934 906 935 907 new_user->valid = 1; ··· 948 916 kfree(new_user); 949 917 return rv; 950 918 } 919 + EXPORT_SYMBOL(ipmi_create_user); 951 920 952 921 static void free_user(struct kref *ref) 953 922 { ··· 972 939 973 940 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 974 941 if (intf->seq_table[i].inuse 975 - && (intf->seq_table[i].recv_msg->user == user)) 976 - { 942 + && (intf->seq_table[i].recv_msg->user == user)) { 977 943 intf->seq_table[i].inuse = 0; 978 944 ipmi_free_recv_msg(intf->seq_table[i].recv_msg); 979 945 } ··· 1015 983 1016 984 return 0; 1017 985 } 986 + EXPORT_SYMBOL(ipmi_destroy_user); 1018 987 1019 988 void ipmi_get_version(ipmi_user_t user, 1020 989 unsigned char *major, ··· 1024 991 *major = user->intf->ipmi_version_major; 1025 992 *minor = user->intf->ipmi_version_minor; 1026 993 } 994 + EXPORT_SYMBOL(ipmi_get_version); 1027 995 1028 996 int ipmi_set_my_address(ipmi_user_t user, 1029 997 unsigned int channel, ··· 1035 1001 user->intf->channels[channel].address = address; 1036 1002 return 0; 1037 1003 } 1004 + EXPORT_SYMBOL(ipmi_set_my_address); 1038 1005 1039 1006 int ipmi_get_my_address(ipmi_user_t user, 1040 1007 unsigned int channel, ··· 1046 1011 *address = user->intf->channels[channel].address; 1047 1012 return 0; 1048 1013 } 1014 + EXPORT_SYMBOL(ipmi_get_my_address); 1049 1015 1050 1016 int ipmi_set_my_LUN(ipmi_user_t user, 1051 1017 unsigned int channel, ··· 1057 1021 user->intf->channels[channel].lun = LUN & 0x3; 1058 1022 return 0; 1059 1023 } 1024 + EXPORT_SYMBOL(ipmi_set_my_LUN); 1060 1025 1061 1026 int ipmi_get_my_LUN(ipmi_user_t user, 1062 1027 unsigned int channel, ··· 1068 1031 *address = user->intf->channels[channel].lun; 1069 1032 return 0; 1070 1033 } 1034 + EXPORT_SYMBOL(ipmi_get_my_LUN); 1071 1035 1072 1036 int ipmi_get_maintenance_mode(ipmi_user_t user) 1073 1037 { ··· 1177 1139 1178 1140 return 0; 1179 1141 } 1142 + EXPORT_SYMBOL(ipmi_set_gets_events); 1180 1143 1181 1144 static struct cmd_rcvr *find_cmd_rcvr(ipmi_smi_t intf, 1182 1145 unsigned char netfn, ··· 1243 1204 1244 1205 return rv; 1245 1206 } 1207 + EXPORT_SYMBOL(ipmi_register_for_cmd); 1246 1208 1247 1209 int ipmi_unregister_for_cmd(ipmi_user_t user, 1248 1210 unsigned char netfn, ··· 1281 1241 } 1282 1242 return rv; 1283 1243 } 1244 + EXPORT_SYMBOL(ipmi_unregister_for_cmd); 1284 1245 1285 1246 static unsigned char 1286 1247 ipmb_checksum(unsigned char *data, int size) 1287 1248 { 1288 1249 unsigned char csum = 0; 1289 - 1250 + 1290 1251 for (; size > 0; size--, data++) 1291 1252 csum += *data; 1292 1253 ··· 1329 1288 = ipmb_checksum(&(smi_msg->data[i+6]), 1330 1289 smi_msg->data_size-6); 1331 1290 1332 - /* Add on the checksum size and the offset from the 1333 - broadcast. */ 1291 + /* 1292 + * Add on the checksum size and the offset from the 1293 + * broadcast. 1294 + */ 1334 1295 smi_msg->data_size += 1 + i; 1335 1296 1336 1297 smi_msg->msgid = msgid; ··· 1368 1325 = ipmb_checksum(&(smi_msg->data[7]), 1369 1326 smi_msg->data_size-7); 1370 1327 1371 - /* Add on the checksum size and the offset from the 1372 - broadcast. */ 1328 + /* 1329 + * Add on the checksum size and the offset from the 1330 + * broadcast. 1331 + */ 1373 1332 smi_msg->data_size += 1; 1374 1333 1375 1334 smi_msg->msgid = msgid; 1376 1335 } 1377 1336 1378 - /* Separate from ipmi_request so that the user does not have to be 1379 - supplied in certain circumstances (mainly at panic time). If 1380 - messages are supplied, they will be freed, even if an error 1381 - occurs. */ 1337 + /* 1338 + * Separate from ipmi_request so that the user does not have to be 1339 + * supplied in certain circumstances (mainly at panic time). If 1340 + * messages are supplied, they will be freed, even if an error 1341 + * occurs. 1342 + */ 1382 1343 static int i_ipmi_request(ipmi_user_t user, 1383 1344 ipmi_smi_t intf, 1384 1345 struct ipmi_addr *addr, ··· 1404 1357 struct ipmi_smi_handlers *handlers; 1405 1358 1406 1359 1407 - if (supplied_recv) { 1360 + if (supplied_recv) 1408 1361 recv_msg = supplied_recv; 1409 - } else { 1362 + else { 1410 1363 recv_msg = ipmi_alloc_recv_msg(); 1411 - if (recv_msg == NULL) { 1364 + if (recv_msg == NULL) 1412 1365 return -ENOMEM; 1413 - } 1414 1366 } 1415 1367 recv_msg->user_msg_data = user_msg_data; 1416 1368 1417 - if (supplied_smi) { 1369 + if (supplied_smi) 1418 1370 smi_msg = (struct ipmi_smi_msg *) supplied_smi; 1419 - } else { 1371 + else { 1420 1372 smi_msg = ipmi_alloc_smi_msg(); 1421 1373 if (smi_msg == NULL) { 1422 1374 ipmi_free_recv_msg(recv_msg); ··· 1434 1388 if (user) 1435 1389 kref_get(&user->refcount); 1436 1390 recv_msg->msgid = msgid; 1437 - /* Store the message to send in the receive message so timeout 1438 - responses can get the proper response data. */ 1391 + /* 1392 + * Store the message to send in the receive message so timeout 1393 + * responses can get the proper response data. 1394 + */ 1439 1395 recv_msg->msg = *msg; 1440 1396 1441 1397 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { ··· 1461 1413 if ((msg->netfn == IPMI_NETFN_APP_REQUEST) 1462 1414 && ((msg->cmd == IPMI_SEND_MSG_CMD) 1463 1415 || (msg->cmd == IPMI_GET_MSG_CMD) 1464 - || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) 1465 - { 1466 - /* We don't let the user do these, since we manage 1467 - the sequence numbers. */ 1416 + || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) { 1417 + /* 1418 + * We don't let the user do these, since we manage 1419 + * the sequence numbers. 1420 + */ 1468 1421 ipmi_inc_stat(intf, sent_invalid_commands); 1469 1422 rv = -EINVAL; 1470 1423 goto out_err; ··· 1474 1425 if (((msg->netfn == IPMI_NETFN_APP_REQUEST) 1475 1426 && ((msg->cmd == IPMI_COLD_RESET_CMD) 1476 1427 || (msg->cmd == IPMI_WARM_RESET_CMD))) 1477 - || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) 1478 - { 1428 + || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) { 1479 1429 spin_lock_irqsave(&intf->maintenance_mode_lock, flags); 1480 1430 intf->auto_maintenance_timeout 1481 1431 = IPMI_MAINTENANCE_MODE_TIMEOUT; 1482 1432 if (!intf->maintenance_mode 1483 - && !intf->maintenance_mode_enable) 1484 - { 1433 + && !intf->maintenance_mode_enable) { 1485 1434 intf->maintenance_mode_enable = 1; 1486 1435 maintenance_mode_update(intf); 1487 1436 } ··· 1502 1455 smi_msg->data_size = msg->data_len + 2; 1503 1456 ipmi_inc_stat(intf, sent_local_commands); 1504 1457 } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 1505 - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 1506 - { 1458 + || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { 1507 1459 struct ipmi_ipmb_addr *ipmb_addr; 1508 1460 unsigned char ipmb_seq; 1509 1461 long seqid; ··· 1515 1469 } 1516 1470 1517 1471 if (intf->channels[addr->channel].medium 1518 - != IPMI_CHANNEL_MEDIUM_IPMB) 1519 - { 1472 + != IPMI_CHANNEL_MEDIUM_IPMB) { 1520 1473 ipmi_inc_stat(intf, sent_invalid_commands); 1521 1474 rv = -EINVAL; 1522 1475 goto out_err; ··· 1528 1483 retries = 4; 1529 1484 } 1530 1485 if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) { 1531 - /* Broadcasts add a zero at the beginning of the 1532 - message, but otherwise is the same as an IPMB 1533 - address. */ 1486 + /* 1487 + * Broadcasts add a zero at the beginning of the 1488 + * message, but otherwise is the same as an IPMB 1489 + * address. 1490 + */ 1534 1491 addr->addr_type = IPMI_IPMB_ADDR_TYPE; 1535 1492 broadcast = 1; 1536 1493 } ··· 1542 1495 if (retry_time_ms == 0) 1543 1496 retry_time_ms = 1000; 1544 1497 1545 - /* 9 for the header and 1 for the checksum, plus 1546 - possibly one for the broadcast. */ 1498 + /* 1499 + * 9 for the header and 1 for the checksum, plus 1500 + * possibly one for the broadcast. 1501 + */ 1547 1502 if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) { 1548 1503 ipmi_inc_stat(intf, sent_invalid_commands); 1549 1504 rv = -EMSGSIZE; ··· 1562 1513 memcpy(&recv_msg->addr, ipmb_addr, sizeof(*ipmb_addr)); 1563 1514 1564 1515 if (recv_msg->msg.netfn & 0x1) { 1565 - /* It's a response, so use the user's sequence 1566 - from msgid. */ 1516 + /* 1517 + * It's a response, so use the user's sequence 1518 + * from msgid. 1519 + */ 1567 1520 ipmi_inc_stat(intf, sent_ipmb_responses); 1568 1521 format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid, 1569 1522 msgid, broadcast, 1570 1523 source_address, source_lun); 1571 1524 1572 - /* Save the receive message so we can use it 1573 - to deliver the response. */ 1525 + /* 1526 + * Save the receive message so we can use it 1527 + * to deliver the response. 1528 + */ 1574 1529 smi_msg->user_data = recv_msg; 1575 1530 } else { 1576 1531 /* It's a command, so get a sequence for it. */ ··· 1583 1530 1584 1531 ipmi_inc_stat(intf, sent_ipmb_commands); 1585 1532 1586 - /* Create a sequence number with a 1 second 1587 - timeout and 4 retries. */ 1533 + /* 1534 + * Create a sequence number with a 1 second 1535 + * timeout and 4 retries. 1536 + */ 1588 1537 rv = intf_next_seq(intf, 1589 1538 recv_msg, 1590 1539 retry_time_ms, ··· 1595 1540 &ipmb_seq, 1596 1541 &seqid); 1597 1542 if (rv) { 1598 - /* We have used up all the sequence numbers, 1599 - probably, so abort. */ 1543 + /* 1544 + * We have used up all the sequence numbers, 1545 + * probably, so abort. 1546 + */ 1600 1547 spin_unlock_irqrestore(&(intf->seq_lock), 1601 1548 flags); 1602 1549 goto out_err; 1603 1550 } 1604 1551 1605 - /* Store the sequence number in the message, 1606 - so that when the send message response 1607 - comes back we can start the timer. */ 1552 + /* 1553 + * Store the sequence number in the message, 1554 + * so that when the send message response 1555 + * comes back we can start the timer. 1556 + */ 1608 1557 format_ipmb_msg(smi_msg, msg, ipmb_addr, 1609 1558 STORE_SEQ_IN_MSGID(ipmb_seq, seqid), 1610 1559 ipmb_seq, broadcast, 1611 1560 source_address, source_lun); 1612 1561 1613 - /* Copy the message into the recv message data, so we 1614 - can retransmit it later if necessary. */ 1562 + /* 1563 + * Copy the message into the recv message data, so we 1564 + * can retransmit it later if necessary. 1565 + */ 1615 1566 memcpy(recv_msg->msg_data, smi_msg->data, 1616 1567 smi_msg->data_size); 1617 1568 recv_msg->msg.data = recv_msg->msg_data; 1618 1569 recv_msg->msg.data_len = smi_msg->data_size; 1619 1570 1620 - /* We don't unlock until here, because we need 1621 - to copy the completed message into the 1622 - recv_msg before we release the lock. 1623 - Otherwise, race conditions may bite us. I 1624 - know that's pretty paranoid, but I prefer 1625 - to be correct. */ 1571 + /* 1572 + * We don't unlock until here, because we need 1573 + * to copy the completed message into the 1574 + * recv_msg before we release the lock. 1575 + * Otherwise, race conditions may bite us. I 1576 + * know that's pretty paranoid, but I prefer 1577 + * to be correct. 1578 + */ 1626 1579 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1627 1580 } 1628 1581 } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { ··· 1645 1582 } 1646 1583 1647 1584 if ((intf->channels[addr->channel].medium 1648 - != IPMI_CHANNEL_MEDIUM_8023LAN) 1585 + != IPMI_CHANNEL_MEDIUM_8023LAN) 1649 1586 && (intf->channels[addr->channel].medium 1650 - != IPMI_CHANNEL_MEDIUM_ASYNC)) 1651 - { 1587 + != IPMI_CHANNEL_MEDIUM_ASYNC)) { 1652 1588 ipmi_inc_stat(intf, sent_invalid_commands); 1653 1589 rv = -EINVAL; 1654 1590 goto out_err; ··· 1676 1614 memcpy(&recv_msg->addr, lan_addr, sizeof(*lan_addr)); 1677 1615 1678 1616 if (recv_msg->msg.netfn & 0x1) { 1679 - /* It's a response, so use the user's sequence 1680 - from msgid. */ 1617 + /* 1618 + * It's a response, so use the user's sequence 1619 + * from msgid. 1620 + */ 1681 1621 ipmi_inc_stat(intf, sent_lan_responses); 1682 1622 format_lan_msg(smi_msg, msg, lan_addr, msgid, 1683 1623 msgid, source_lun); 1684 1624 1685 - /* Save the receive message so we can use it 1686 - to deliver the response. */ 1625 + /* 1626 + * Save the receive message so we can use it 1627 + * to deliver the response. 1628 + */ 1687 1629 smi_msg->user_data = recv_msg; 1688 1630 } else { 1689 1631 /* It's a command, so get a sequence for it. */ ··· 1696 1630 1697 1631 ipmi_inc_stat(intf, sent_lan_commands); 1698 1632 1699 - /* Create a sequence number with a 1 second 1700 - timeout and 4 retries. */ 1633 + /* 1634 + * Create a sequence number with a 1 second 1635 + * timeout and 4 retries. 1636 + */ 1701 1637 rv = intf_next_seq(intf, 1702 1638 recv_msg, 1703 1639 retry_time_ms, ··· 1708 1640 &ipmb_seq, 1709 1641 &seqid); 1710 1642 if (rv) { 1711 - /* We have used up all the sequence numbers, 1712 - probably, so abort. */ 1643 + /* 1644 + * We have used up all the sequence numbers, 1645 + * probably, so abort. 1646 + */ 1713 1647 spin_unlock_irqrestore(&(intf->seq_lock), 1714 1648 flags); 1715 1649 goto out_err; 1716 1650 } 1717 1651 1718 - /* Store the sequence number in the message, 1719 - so that when the send message response 1720 - comes back we can start the timer. */ 1652 + /* 1653 + * Store the sequence number in the message, 1654 + * so that when the send message response 1655 + * comes back we can start the timer. 1656 + */ 1721 1657 format_lan_msg(smi_msg, msg, lan_addr, 1722 1658 STORE_SEQ_IN_MSGID(ipmb_seq, seqid), 1723 1659 ipmb_seq, source_lun); 1724 1660 1725 - /* Copy the message into the recv message data, so we 1726 - can retransmit it later if necessary. */ 1661 + /* 1662 + * Copy the message into the recv message data, so we 1663 + * can retransmit it later if necessary. 1664 + */ 1727 1665 memcpy(recv_msg->msg_data, smi_msg->data, 1728 1666 smi_msg->data_size); 1729 1667 recv_msg->msg.data = recv_msg->msg_data; 1730 1668 recv_msg->msg.data_len = smi_msg->data_size; 1731 1669 1732 - /* We don't unlock until here, because we need 1733 - to copy the completed message into the 1734 - recv_msg before we release the lock. 1735 - Otherwise, race conditions may bite us. I 1736 - know that's pretty paranoid, but I prefer 1737 - to be correct. */ 1670 + /* 1671 + * We don't unlock until here, because we need 1672 + * to copy the completed message into the 1673 + * recv_msg before we release the lock. 1674 + * Otherwise, race conditions may bite us. I 1675 + * know that's pretty paranoid, but I prefer 1676 + * to be correct. 1677 + */ 1738 1678 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1739 1679 } 1740 1680 } else { ··· 1815 1739 retries, 1816 1740 retry_time_ms); 1817 1741 } 1742 + EXPORT_SYMBOL(ipmi_request_settime); 1818 1743 1819 1744 int ipmi_request_supply_msgs(ipmi_user_t user, 1820 1745 struct ipmi_addr *addr, ··· 1847 1770 lun, 1848 1771 -1, 0); 1849 1772 } 1773 + EXPORT_SYMBOL(ipmi_request_supply_msgs); 1850 1774 1851 1775 #ifdef CONFIG_PROC_FS 1852 1776 static int ipmb_file_read_proc(char *page, char **start, off_t off, ··· 1981 1903 1982 1904 return rv; 1983 1905 } 1906 + EXPORT_SYMBOL(ipmi_smi_add_proc_entry); 1984 1907 1985 1908 static int add_proc_entries(ipmi_smi_t smi, int num) 1986 1909 { ··· 1992 1913 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); 1993 1914 if (!smi->proc_dir) 1994 1915 rv = -ENOMEM; 1995 - else { 1916 + else 1996 1917 smi->proc_dir->owner = THIS_MODULE; 1997 - } 1998 1918 1999 1919 if (rv == 0) 2000 1920 rv = ipmi_smi_add_proc_entry(smi, "stats", ··· 2292 2214 2293 2215 err = device_create_file(&bmc->dev->dev, 2294 2216 &bmc->device_id_attr); 2295 - if (err) goto out; 2217 + if (err) 2218 + goto out; 2296 2219 err = device_create_file(&bmc->dev->dev, 2297 2220 &bmc->provides_dev_sdrs_attr); 2298 - if (err) goto out_devid; 2221 + if (err) 2222 + goto out_devid; 2299 2223 err = device_create_file(&bmc->dev->dev, 2300 2224 &bmc->revision_attr); 2301 - if (err) goto out_sdrs; 2225 + if (err) 2226 + goto out_sdrs; 2302 2227 err = device_create_file(&bmc->dev->dev, 2303 2228 &bmc->firmware_rev_attr); 2304 - if (err) goto out_rev; 2229 + if (err) 2230 + goto out_rev; 2305 2231 err = device_create_file(&bmc->dev->dev, 2306 2232 &bmc->version_attr); 2307 - if (err) goto out_firm; 2233 + if (err) 2234 + goto out_firm; 2308 2235 err = device_create_file(&bmc->dev->dev, 2309 2236 &bmc->add_dev_support_attr); 2310 - if (err) goto out_version; 2237 + if (err) 2238 + goto out_version; 2311 2239 err = device_create_file(&bmc->dev->dev, 2312 2240 &bmc->manufacturer_id_attr); 2313 - if (err) goto out_add_dev; 2241 + if (err) 2242 + goto out_add_dev; 2314 2243 err = device_create_file(&bmc->dev->dev, 2315 2244 &bmc->product_id_attr); 2316 - if (err) goto out_manu; 2245 + if (err) 2246 + goto out_manu; 2317 2247 if (bmc->id.aux_firmware_revision_set) { 2318 2248 err = device_create_file(&bmc->dev->dev, 2319 2249 &bmc->aux_firmware_rev_attr); 2320 - if (err) goto out_prod_id; 2250 + if (err) 2251 + goto out_prod_id; 2321 2252 } 2322 2253 if (bmc->guid_set) { 2323 2254 err = device_create_file(&bmc->dev->dev, 2324 2255 &bmc->guid_attr); 2325 - if (err) goto out_aux_firm; 2256 + if (err) 2257 + goto out_aux_firm; 2326 2258 } 2327 2259 2328 2260 return 0; ··· 2460 2372 "ipmi_msghandler:" 2461 2373 " Unable to register bmc device: %d\n", 2462 2374 rv); 2463 - /* Don't go to out_err, you can only do that if 2464 - the device is registered already. */ 2375 + /* 2376 + * Don't go to out_err, you can only do that if 2377 + * the device is registered already. 2378 + */ 2465 2379 return rv; 2466 2380 } 2467 2381 ··· 2654 2564 2655 2565 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 2656 2566 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) 2657 - && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) 2658 - { 2567 + && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) { 2659 2568 /* It's the one we want */ 2660 2569 if (msg->msg.data[0] != 0) { 2661 2570 /* Got an error from the channel, just go on. */ 2662 2571 2663 2572 if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) { 2664 - /* If the MC does not support this 2665 - command, that is legal. We just 2666 - assume it has one IPMB at channel 2667 - zero. */ 2573 + /* 2574 + * If the MC does not support this 2575 + * command, that is legal. We just 2576 + * assume it has one IPMB at channel 2577 + * zero. 2578 + */ 2668 2579 intf->channels[0].medium 2669 2580 = IPMI_CHANNEL_MEDIUM_IPMB; 2670 2581 intf->channels[0].protocol ··· 2686 2595 intf->channels[chan].medium = msg->msg.data[2] & 0x7f; 2687 2596 intf->channels[chan].protocol = msg->msg.data[3] & 0x1f; 2688 2597 2689 - next_channel: 2598 + next_channel: 2690 2599 intf->curr_channel++; 2691 2600 if (intf->curr_channel >= IPMI_MAX_CHANNELS) 2692 2601 wake_up(&intf->waitq); ··· 2714 2623 if (intf->handlers->poll) 2715 2624 intf->handlers->poll(intf->send_info); 2716 2625 } 2626 + EXPORT_SYMBOL(ipmi_poll_interface); 2717 2627 2718 2628 int ipmi_register_smi(struct ipmi_smi_handlers *handlers, 2719 2629 void *send_info, ··· 2729 2637 ipmi_smi_t tintf; 2730 2638 struct list_head *link; 2731 2639 2732 - /* Make sure the driver is actually initialized, this handles 2733 - problems with initialization order. */ 2640 + /* 2641 + * Make sure the driver is actually initialized, this handles 2642 + * problems with initialization order. 2643 + */ 2734 2644 if (!initialized) { 2735 2645 rv = ipmi_init_msghandler(); 2736 2646 if (rv) 2737 2647 return rv; 2738 - /* The init code doesn't return an error if it was turned 2739 - off, but it won't initialize. Check that. */ 2648 + /* 2649 + * The init code doesn't return an error if it was turned 2650 + * off, but it won't initialize. Check that. 2651 + */ 2740 2652 if (!initialized) 2741 2653 return -ENODEV; 2742 2654 } ··· 2818 2722 get_guid(intf); 2819 2723 2820 2724 if ((intf->ipmi_version_major > 1) 2821 - || ((intf->ipmi_version_major == 1) 2822 - && (intf->ipmi_version_minor >= 5))) 2823 - { 2824 - /* Start scanning the channels to see what is 2825 - available. */ 2725 + || ((intf->ipmi_version_major == 1) 2726 + && (intf->ipmi_version_minor >= 5))) { 2727 + /* 2728 + * Start scanning the channels to see what is 2729 + * available. 2730 + */ 2826 2731 intf->null_user_handler = channel_handler; 2827 2732 intf->curr_channel = 0; 2828 2733 rv = send_channel_info_cmd(intf, 0); ··· 2871 2774 2872 2775 return rv; 2873 2776 } 2777 + EXPORT_SYMBOL(ipmi_register_smi); 2874 2778 2875 2779 static void cleanup_smi_msgs(ipmi_smi_t intf) 2876 2780 { ··· 2906 2808 2907 2809 remove_proc_entries(intf); 2908 2810 2909 - /* Call all the watcher interfaces to tell them that 2910 - an interface is gone. */ 2811 + /* 2812 + * Call all the watcher interfaces to tell them that 2813 + * an interface is gone. 2814 + */ 2911 2815 list_for_each_entry(w, &smi_watchers, link) 2912 2816 w->smi_gone(intf_num); 2913 2817 mutex_unlock(&smi_watchers_mutex); ··· 2917 2817 kref_put(&intf->refcount, intf_free); 2918 2818 return 0; 2919 2819 } 2820 + EXPORT_SYMBOL(ipmi_unregister_smi); 2920 2821 2921 2822 static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, 2922 2823 struct ipmi_smi_msg *msg) ··· 2925 2824 struct ipmi_ipmb_addr ipmb_addr; 2926 2825 struct ipmi_recv_msg *recv_msg; 2927 2826 2928 - 2929 - /* This is 11, not 10, because the response must contain a 2930 - * completion code. */ 2827 + /* 2828 + * This is 11, not 10, because the response must contain a 2829 + * completion code. 2830 + */ 2931 2831 if (msg->rsp_size < 11) { 2932 2832 /* Message not big enough, just ignore it. */ 2933 2833 ipmi_inc_stat(intf, invalid_ipmb_responses); ··· 2945 2843 ipmb_addr.channel = msg->rsp[3] & 0x0f; 2946 2844 ipmb_addr.lun = msg->rsp[7] & 3; 2947 2845 2948 - /* It's a response from a remote entity. Look up the sequence 2949 - number and handle the response. */ 2846 + /* 2847 + * It's a response from a remote entity. Look up the sequence 2848 + * number and handle the response. 2849 + */ 2950 2850 if (intf_find_seq(intf, 2951 2851 msg->rsp[7] >> 2, 2952 2852 msg->rsp[3] & 0x0f, 2953 2853 msg->rsp[8], 2954 2854 (msg->rsp[4] >> 2) & (~1), 2955 2855 (struct ipmi_addr *) &(ipmb_addr), 2956 - &recv_msg)) 2957 - { 2958 - /* We were unable to find the sequence number, 2959 - so just nuke the message. */ 2856 + &recv_msg)) { 2857 + /* 2858 + * We were unable to find the sequence number, 2859 + * so just nuke the message. 2860 + */ 2960 2861 ipmi_inc_stat(intf, unhandled_ipmb_responses); 2961 2862 return 0; 2962 2863 } ··· 2967 2862 memcpy(recv_msg->msg_data, 2968 2863 &(msg->rsp[9]), 2969 2864 msg->rsp_size - 9); 2970 - /* THe other fields matched, so no need to set them, except 2971 - for netfn, which needs to be the response that was 2972 - returned, not the request value. */ 2865 + /* 2866 + * The other fields matched, so no need to set them, except 2867 + * for netfn, which needs to be the response that was 2868 + * returned, not the request value. 2869 + */ 2973 2870 recv_msg->msg.netfn = msg->rsp[4] >> 2; 2974 2871 recv_msg->msg.data = recv_msg->msg_data; 2975 2872 recv_msg->msg.data_len = msg->rsp_size - 10; ··· 3027 2920 msg->data[1] = IPMI_SEND_MSG_CMD; 3028 2921 msg->data[2] = msg->rsp[3]; 3029 2922 msg->data[3] = msg->rsp[6]; 3030 - msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); 2923 + msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); 3031 2924 msg->data[5] = ipmb_checksum(&(msg->data[3]), 2); 3032 2925 msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address; 3033 - /* rqseq/lun */ 3034 - msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); 2926 + /* rqseq/lun */ 2927 + msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); 3035 2928 msg->data[8] = msg->rsp[8]; /* cmd */ 3036 2929 msg->data[9] = IPMI_INVALID_CMD_COMPLETION_CODE; 3037 2930 msg->data[10] = ipmb_checksum(&(msg->data[6]), 4); ··· 3050 2943 handlers = intf->handlers; 3051 2944 if (handlers) { 3052 2945 handlers->sender(intf->send_info, msg, 0); 3053 - /* We used the message, so return the value 3054 - that causes it to not be freed or 3055 - queued. */ 2946 + /* 2947 + * We used the message, so return the value 2948 + * that causes it to not be freed or 2949 + * queued. 2950 + */ 3056 2951 rv = -1; 3057 2952 } 3058 2953 rcu_read_unlock(); ··· 3064 2955 3065 2956 recv_msg = ipmi_alloc_recv_msg(); 3066 2957 if (!recv_msg) { 3067 - /* We couldn't allocate memory for the 3068 - message, so requeue it for handling 3069 - later. */ 2958 + /* 2959 + * We couldn't allocate memory for the 2960 + * message, so requeue it for handling 2961 + * later. 2962 + */ 3070 2963 rv = 1; 3071 2964 kref_put(&user->refcount, free_user); 3072 2965 } else { ··· 3079 2968 ipmb_addr->lun = msg->rsp[7] & 3; 3080 2969 ipmb_addr->channel = msg->rsp[3] & 0xf; 3081 2970 3082 - /* Extract the rest of the message information 3083 - from the IPMB header.*/ 2971 + /* 2972 + * Extract the rest of the message information 2973 + * from the IPMB header. 2974 + */ 3084 2975 recv_msg->user = user; 3085 2976 recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3086 2977 recv_msg->msgid = msg->rsp[7] >> 2; ··· 3090 2977 recv_msg->msg.cmd = msg->rsp[8]; 3091 2978 recv_msg->msg.data = recv_msg->msg_data; 3092 2979 3093 - /* We chop off 10, not 9 bytes because the checksum 3094 - at the end also needs to be removed. */ 2980 + /* 2981 + * We chop off 10, not 9 bytes because the checksum 2982 + * at the end also needs to be removed. 2983 + */ 3095 2984 recv_msg->msg.data_len = msg->rsp_size - 10; 3096 2985 memcpy(recv_msg->msg_data, 3097 2986 &(msg->rsp[9]), ··· 3112 2997 struct ipmi_recv_msg *recv_msg; 3113 2998 3114 2999 3115 - /* This is 13, not 12, because the response must contain a 3116 - * completion code. */ 3000 + /* 3001 + * This is 13, not 12, because the response must contain a 3002 + * completion code. 3003 + */ 3117 3004 if (msg->rsp_size < 13) { 3118 3005 /* Message not big enough, just ignore it. */ 3119 3006 ipmi_inc_stat(intf, invalid_lan_responses); ··· 3135 3018 lan_addr.privilege = msg->rsp[3] >> 4; 3136 3019 lan_addr.lun = msg->rsp[9] & 3; 3137 3020 3138 - /* It's a response from a remote entity. Look up the sequence 3139 - number and handle the response. */ 3021 + /* 3022 + * It's a response from a remote entity. Look up the sequence 3023 + * number and handle the response. 3024 + */ 3140 3025 if (intf_find_seq(intf, 3141 3026 msg->rsp[9] >> 2, 3142 3027 msg->rsp[3] & 0x0f, 3143 3028 msg->rsp[10], 3144 3029 (msg->rsp[6] >> 2) & (~1), 3145 3030 (struct ipmi_addr *) &(lan_addr), 3146 - &recv_msg)) 3147 - { 3148 - /* We were unable to find the sequence number, 3149 - so just nuke the message. */ 3031 + &recv_msg)) { 3032 + /* 3033 + * We were unable to find the sequence number, 3034 + * so just nuke the message. 3035 + */ 3150 3036 ipmi_inc_stat(intf, unhandled_lan_responses); 3151 3037 return 0; 3152 3038 } ··· 3157 3037 memcpy(recv_msg->msg_data, 3158 3038 &(msg->rsp[11]), 3159 3039 msg->rsp_size - 11); 3160 - /* The other fields matched, so no need to set them, except 3161 - for netfn, which needs to be the response that was 3162 - returned, not the request value. */ 3040 + /* 3041 + * The other fields matched, so no need to set them, except 3042 + * for netfn, which needs to be the response that was 3043 + * returned, not the request value. 3044 + */ 3163 3045 recv_msg->msg.netfn = msg->rsp[6] >> 2; 3164 3046 recv_msg->msg.data = recv_msg->msg_data; 3165 3047 recv_msg->msg.data_len = msg->rsp_size - 12; ··· 3212 3090 /* We didn't find a user, just give up. */ 3213 3091 ipmi_inc_stat(intf, unhandled_commands); 3214 3092 3215 - rv = 0; /* Don't do anything with these messages, just 3216 - allow them to be freed. */ 3093 + /* 3094 + * Don't do anything with these messages, just allow 3095 + * them to be freed. 3096 + */ 3097 + rv = 0; 3217 3098 } else { 3218 3099 /* Deliver the message to the user. */ 3219 3100 ipmi_inc_stat(intf, handled_commands); 3220 3101 3221 3102 recv_msg = ipmi_alloc_recv_msg(); 3222 3103 if (!recv_msg) { 3223 - /* We couldn't allocate memory for the 3224 - message, so requeue it for handling 3225 - later. */ 3104 + /* 3105 + * We couldn't allocate memory for the 3106 + * message, so requeue it for handling later. 3107 + */ 3226 3108 rv = 1; 3227 3109 kref_put(&user->refcount, free_user); 3228 3110 } else { ··· 3240 3114 lan_addr->channel = msg->rsp[3] & 0xf; 3241 3115 lan_addr->privilege = msg->rsp[3] >> 4; 3242 3116 3243 - /* Extract the rest of the message information 3244 - from the IPMB header.*/ 3117 + /* 3118 + * Extract the rest of the message information 3119 + * from the IPMB header. 3120 + */ 3245 3121 recv_msg->user = user; 3246 3122 recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3247 3123 recv_msg->msgid = msg->rsp[9] >> 2; ··· 3251 3123 recv_msg->msg.cmd = msg->rsp[10]; 3252 3124 recv_msg->msg.data = recv_msg->msg_data; 3253 3125 3254 - /* We chop off 12, not 11 bytes because the checksum 3255 - at the end also needs to be removed. */ 3126 + /* 3127 + * We chop off 12, not 11 bytes because the checksum 3128 + * at the end also needs to be removed. 3129 + */ 3256 3130 recv_msg->msg.data_len = msg->rsp_size - 12; 3257 3131 memcpy(recv_msg->msg_data, 3258 3132 &(msg->rsp[11]), ··· 3270 3140 struct ipmi_smi_msg *msg) 3271 3141 { 3272 3142 struct ipmi_system_interface_addr *smi_addr; 3273 - 3143 + 3274 3144 recv_msg->msgid = 0; 3275 3145 smi_addr = (struct ipmi_system_interface_addr *) &(recv_msg->addr); 3276 3146 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; ··· 3311 3181 3312 3182 ipmi_inc_stat(intf, events); 3313 3183 3314 - /* Allocate and fill in one message for every user that is getting 3315 - events. */ 3184 + /* 3185 + * Allocate and fill in one message for every user that is 3186 + * getting events. 3187 + */ 3316 3188 rcu_read_lock(); 3317 3189 list_for_each_entry_rcu(user, &intf->users, link) { 3318 3190 if (!user->gets_events) ··· 3328 3196 list_del(&recv_msg->link); 3329 3197 ipmi_free_recv_msg(recv_msg); 3330 3198 } 3331 - /* We couldn't allocate memory for the 3332 - message, so requeue it for handling 3333 - later. */ 3199 + /* 3200 + * We couldn't allocate memory for the 3201 + * message, so requeue it for handling 3202 + * later. 3203 + */ 3334 3204 rv = 1; 3335 3205 goto out; 3336 3206 } ··· 3353 3219 deliver_response(recv_msg); 3354 3220 } 3355 3221 } else if (intf->waiting_events_count < MAX_EVENTS_IN_QUEUE) { 3356 - /* No one to receive the message, put it in queue if there's 3357 - not already too many things in the queue. */ 3222 + /* 3223 + * No one to receive the message, put it in queue if there's 3224 + * not already too many things in the queue. 3225 + */ 3358 3226 recv_msg = ipmi_alloc_recv_msg(); 3359 3227 if (!recv_msg) { 3360 - /* We couldn't allocate memory for the 3361 - message, so requeue it for handling 3362 - later. */ 3228 + /* 3229 + * We couldn't allocate memory for the 3230 + * message, so requeue it for handling 3231 + * later. 3232 + */ 3363 3233 rv = 1; 3364 3234 goto out; 3365 3235 } ··· 3372 3234 list_add_tail(&(recv_msg->link), &(intf->waiting_events)); 3373 3235 intf->waiting_events_count++; 3374 3236 } else if (!intf->event_msg_printed) { 3375 - /* There's too many things in the queue, discard this 3376 - message. */ 3237 + /* 3238 + * There's too many things in the queue, discard this 3239 + * message. 3240 + */ 3377 3241 printk(KERN_WARNING PFX "Event queue full, discarding" 3378 3242 " incoming events\n"); 3379 3243 intf->event_msg_printed = 1; ··· 3394 3254 struct ipmi_user *user; 3395 3255 3396 3256 recv_msg = (struct ipmi_recv_msg *) msg->user_data; 3397 - if (recv_msg == NULL) 3398 - { 3399 - printk(KERN_WARNING"IPMI message received with no owner. This\n" 3400 - "could be because of a malformed message, or\n" 3401 - "because of a hardware error. Contact your\n" 3402 - "hardware vender for assistance\n"); 3257 + if (recv_msg == NULL) { 3258 + printk(KERN_WARNING 3259 + "IPMI message received with no owner. This\n" 3260 + "could be because of a malformed message, or\n" 3261 + "because of a hardware error. Contact your\n" 3262 + "hardware vender for assistance\n"); 3403 3263 return 0; 3404 3264 } 3405 3265 ··· 3433 3293 return 0; 3434 3294 } 3435 3295 3436 - /* Handle a new message. Return 1 if the message should be requeued, 3437 - 0 if the message should be freed, or -1 if the message should not 3438 - be freed or requeued. */ 3296 + /* 3297 + * Handle a new message. Return 1 if the message should be requeued, 3298 + * 0 if the message should be freed, or -1 if the message should not 3299 + * be freed or requeued. 3300 + */ 3439 3301 static int handle_new_recv_msg(ipmi_smi_t intf, 3440 3302 struct ipmi_smi_msg *msg) 3441 3303 { ··· 3462 3320 msg->rsp[1] = msg->data[1]; 3463 3321 msg->rsp[2] = IPMI_ERR_UNSPECIFIED; 3464 3322 msg->rsp_size = 3; 3465 - } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1))/* Netfn */ 3466 - || (msg->rsp[1] != msg->data[1])) /* Command */ 3467 - { 3468 - /* The response is not even marginally correct. */ 3323 + } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1)) 3324 + || (msg->rsp[1] != msg->data[1])) { 3325 + /* 3326 + * The NetFN and Command in the response is not even 3327 + * marginally correct. 3328 + */ 3469 3329 printk(KERN_WARNING PFX "BMC returned incorrect response," 3470 3330 " expected netfn %x cmd %x, got netfn %x cmd %x\n", 3471 3331 (msg->data[0] >> 2) | 1, msg->data[1], ··· 3482 3338 3483 3339 if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3484 3340 && (msg->rsp[1] == IPMI_SEND_MSG_CMD) 3485 - && (msg->user_data != NULL)) 3486 - { 3487 - /* It's a response to a response we sent. For this we 3488 - deliver a send message response to the user. */ 3341 + && (msg->user_data != NULL)) { 3342 + /* 3343 + * It's a response to a response we sent. For this we 3344 + * deliver a send message response to the user. 3345 + */ 3489 3346 struct ipmi_recv_msg *recv_msg = msg->user_data; 3490 3347 3491 3348 requeue = 0; ··· 3512 3367 recv_msg->msg_data[0] = msg->rsp[2]; 3513 3368 deliver_response(recv_msg); 3514 3369 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3515 - && (msg->rsp[1] == IPMI_GET_MSG_CMD)) 3516 - { 3370 + && (msg->rsp[1] == IPMI_GET_MSG_CMD)) { 3517 3371 /* It's from the receive queue. */ 3518 3372 chan = msg->rsp[3] & 0xf; 3519 3373 if (chan >= IPMI_MAX_CHANNELS) { ··· 3524 3380 switch (intf->channels[chan].medium) { 3525 3381 case IPMI_CHANNEL_MEDIUM_IPMB: 3526 3382 if (msg->rsp[4] & 0x04) { 3527 - /* It's a response, so find the 3528 - requesting message and send it up. */ 3383 + /* 3384 + * It's a response, so find the 3385 + * requesting message and send it up. 3386 + */ 3529 3387 requeue = handle_ipmb_get_msg_rsp(intf, msg); 3530 3388 } else { 3531 - /* It's a command to the SMS from some other 3532 - entity. Handle that. */ 3389 + /* 3390 + * It's a command to the SMS from some other 3391 + * entity. Handle that. 3392 + */ 3533 3393 requeue = handle_ipmb_get_msg_cmd(intf, msg); 3534 3394 } 3535 3395 break; ··· 3541 3393 case IPMI_CHANNEL_MEDIUM_8023LAN: 3542 3394 case IPMI_CHANNEL_MEDIUM_ASYNC: 3543 3395 if (msg->rsp[6] & 0x04) { 3544 - /* It's a response, so find the 3545 - requesting message and send it up. */ 3396 + /* 3397 + * It's a response, so find the 3398 + * requesting message and send it up. 3399 + */ 3546 3400 requeue = handle_lan_get_msg_rsp(intf, msg); 3547 3401 } else { 3548 - /* It's a command to the SMS from some other 3549 - entity. Handle that. */ 3402 + /* 3403 + * It's a command to the SMS from some other 3404 + * entity. Handle that. 3405 + */ 3550 3406 requeue = handle_lan_get_msg_cmd(intf, msg); 3551 3407 } 3552 3408 break; 3553 3409 3554 3410 default: 3555 - /* We don't handle the channel type, so just 3556 - * free the message. */ 3411 + /* 3412 + * We don't handle the channel type, so just 3413 + * free the message. 3414 + */ 3557 3415 requeue = 0; 3558 3416 } 3559 3417 3560 3418 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3561 - && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) 3562 - { 3419 + && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) { 3563 3420 /* It's an asyncronous event. */ 3564 3421 requeue = handle_read_event_rsp(intf, msg); 3565 3422 } else { ··· 3588 3435 if ((msg->data_size >= 2) 3589 3436 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) 3590 3437 && (msg->data[1] == IPMI_SEND_MSG_CMD) 3591 - && (msg->user_data == NULL)) 3592 - { 3593 - /* This is the local response to a command send, start 3594 - the timer for these. The user_data will not be 3595 - NULL if this is a response send, and we will let 3596 - response sends just go through. */ 3438 + && (msg->user_data == NULL)) { 3439 + /* 3440 + * This is the local response to a command send, start 3441 + * the timer for these. The user_data will not be 3442 + * NULL if this is a response send, and we will let 3443 + * response sends just go through. 3444 + */ 3597 3445 3598 - /* Check for errors, if we get certain errors (ones 3599 - that mean basically we can try again later), we 3600 - ignore them and start the timer. Otherwise we 3601 - report the error immediately. */ 3446 + /* 3447 + * Check for errors, if we get certain errors (ones 3448 + * that mean basically we can try again later), we 3449 + * ignore them and start the timer. Otherwise we 3450 + * report the error immediately. 3451 + */ 3602 3452 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) 3603 3453 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) 3604 3454 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR) 3605 3455 && (msg->rsp[2] != IPMI_BUS_ERR) 3606 - && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) 3607 - { 3456 + && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) { 3608 3457 int chan = msg->rsp[3] & 0xf; 3609 3458 3610 3459 /* Got an error sending the message, handle it. */ ··· 3620 3465 else 3621 3466 ipmi_inc_stat(intf, sent_ipmb_command_errs); 3622 3467 intf_err_seq(intf, msg->msgid, msg->rsp[2]); 3623 - } else { 3468 + } else 3624 3469 /* The message was sent, start the timer. */ 3625 3470 intf_start_seq_timer(intf, msg->msgid); 3626 - } 3627 3471 3628 3472 ipmi_free_smi_msg(msg); 3629 3473 goto out; 3630 3474 } 3631 3475 3632 - /* To preserve message order, if the list is not empty, we 3633 - tack this message onto the end of the list. */ 3476 + /* 3477 + * To preserve message order, if the list is not empty, we 3478 + * tack this message onto the end of the list. 3479 + */ 3634 3480 run_to_completion = intf->run_to_completion; 3635 3481 if (!run_to_completion) 3636 3482 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); ··· 3643 3487 } 3644 3488 if (!run_to_completion) 3645 3489 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 3646 - 3490 + 3647 3491 rv = handle_new_recv_msg(intf, msg); 3648 3492 if (rv > 0) { 3649 - /* Could not handle the message now, just add it to a 3650 - list to handle later. */ 3493 + /* 3494 + * Could not handle the message now, just add it to a 3495 + * list to handle later. 3496 + */ 3651 3497 run_to_completion = intf->run_to_completion; 3652 3498 if (!run_to_completion) 3653 3499 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); ··· 3663 3505 out: 3664 3506 return; 3665 3507 } 3508 + EXPORT_SYMBOL(ipmi_smi_msg_received); 3666 3509 3667 3510 void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) 3668 3511 { ··· 3678 3519 } 3679 3520 rcu_read_unlock(); 3680 3521 } 3681 - 3522 + EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout); 3682 3523 3683 3524 static struct ipmi_smi_msg * 3684 3525 smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, ··· 3686 3527 { 3687 3528 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg(); 3688 3529 if (!smi_msg) 3689 - /* If we can't allocate the message, then just return, we 3690 - get 4 retries, so this should be ok. */ 3530 + /* 3531 + * If we can't allocate the message, then just return, we 3532 + * get 4 retries, so this should be ok. 3533 + */ 3691 3534 return NULL; 3692 3535 3693 3536 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len); 3694 3537 smi_msg->data_size = recv_msg->msg.data_len; 3695 3538 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); 3696 - 3539 + 3697 3540 #ifdef DEBUG_MSGING 3698 3541 { 3699 3542 int m; ··· 3740 3579 struct ipmi_smi_msg *smi_msg; 3741 3580 /* More retries, send again. */ 3742 3581 3743 - /* Start with the max timer, set to normal 3744 - timer after the message is sent. */ 3582 + /* 3583 + * Start with the max timer, set to normal timer after 3584 + * the message is sent. 3585 + */ 3745 3586 ent->timeout = MAX_MSG_TIMEOUT; 3746 3587 ent->retries_left--; 3747 3588 if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) ··· 3758 3595 3759 3596 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3760 3597 3761 - /* Send the new message. We send with a zero 3762 - * priority. It timed out, I doubt time is 3763 - * that critical now, and high priority 3764 - * messages are really only for messages to the 3765 - * local MC, which don't get resent. */ 3598 + /* 3599 + * Send the new message. We send with a zero 3600 + * priority. It timed out, I doubt time is that 3601 + * critical now, and high priority messages are really 3602 + * only for messages to the local MC, which don't get 3603 + * resent. 3604 + */ 3766 3605 handlers = intf->handlers; 3767 3606 if (handlers) 3768 3607 intf->handlers->sender(intf->send_info, ··· 3795 3630 list_del(&smi_msg->link); 3796 3631 ipmi_free_smi_msg(smi_msg); 3797 3632 } else { 3798 - /* To preserve message order, quit if we 3799 - can't handle a message. */ 3633 + /* 3634 + * To preserve message order, quit if we 3635 + * can't handle a message. 3636 + */ 3800 3637 break; 3801 3638 } 3802 3639 } 3803 3640 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 3804 3641 3805 - /* Go through the seq table and find any messages that 3806 - have timed out, putting them in the timeouts 3807 - list. */ 3642 + /* 3643 + * Go through the seq table and find any messages that 3644 + * have timed out, putting them in the timeouts 3645 + * list. 3646 + */ 3808 3647 INIT_LIST_HEAD(&timeouts); 3809 3648 spin_lock_irqsave(&intf->seq_lock, flags); 3810 3649 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) ··· 3834 3665 intf->auto_maintenance_timeout 3835 3666 -= timeout_period; 3836 3667 if (!intf->maintenance_mode 3837 - && (intf->auto_maintenance_timeout <= 0)) 3838 - { 3668 + && (intf->auto_maintenance_timeout <= 0)) { 3839 3669 intf->maintenance_mode_enable = 0; 3840 3670 maintenance_mode_update(intf); 3841 3671 } ··· 3852 3684 struct ipmi_smi_handlers *handlers; 3853 3685 3854 3686 rcu_read_lock(); 3855 - /* Called from the timer, no need to check if handlers is 3856 - * valid. */ 3687 + /* 3688 + * Called from the timer, no need to check if handlers is 3689 + * valid. 3690 + */ 3857 3691 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 3858 3692 /* No event requests when in maintenance mode. */ 3859 3693 if (intf->maintenance_mode_enable) ··· 3876 3706 /* How many jiffies does it take to get to the timeout time. */ 3877 3707 #define IPMI_TIMEOUT_JIFFIES ((IPMI_TIMEOUT_TIME * HZ) / 1000) 3878 3708 3879 - /* Request events from the queue every second (this is the number of 3880 - IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the 3881 - future, IPMI will add a way to know immediately if an event is in 3882 - the queue and this silliness can go away. */ 3709 + /* 3710 + * Request events from the queue every second (this is the number of 3711 + * IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the 3712 + * future, IPMI will add a way to know immediately if an event is in 3713 + * the queue and this silliness can go away. 3714 + */ 3883 3715 #define IPMI_REQUEST_EV_TIME (1000 / (IPMI_TIMEOUT_TIME)) 3884 3716 3885 3717 static atomic_t stop_operation; ··· 3925 3753 } 3926 3754 return rv; 3927 3755 } 3756 + EXPORT_SYMBOL(ipmi_alloc_smi_msg); 3928 3757 3929 3758 static void free_recv_msg(struct ipmi_recv_msg *msg) 3930 3759 { ··· 3952 3779 kref_put(&msg->user->refcount, free_user); 3953 3780 msg->done(msg); 3954 3781 } 3782 + EXPORT_SYMBOL(ipmi_free_recv_msg); 3955 3783 3956 3784 #ifdef CONFIG_IPMI_PANIC_EVENT 3957 3785 ··· 3970 3796 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 3971 3797 && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE) 3972 3798 && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD) 3973 - && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) 3974 - { 3799 + && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) { 3975 3800 /* A get event receiver command, save it. */ 3976 3801 intf->event_receiver = msg->msg.data[1]; 3977 3802 intf->event_receiver_lun = msg->msg.data[2] & 0x3; ··· 3982 3809 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 3983 3810 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) 3984 3811 && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD) 3985 - && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) 3986 - { 3987 - /* A get device id command, save if we are an event 3988 - receiver or generator. */ 3812 + && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) { 3813 + /* 3814 + * A get device id command, save if we are an event 3815 + * receiver or generator. 3816 + */ 3989 3817 intf->local_sel_device = (msg->msg.data[6] >> 2) & 1; 3990 3818 intf->local_event_generator = (msg->msg.data[6] >> 5) & 1; 3991 3819 } ··· 4019 3845 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */ 4020 3846 data[5] = 0xa1; /* Runtime stop OEM bytes 2 & 3. */ 4021 3847 4022 - /* Put a few breadcrumbs in. Hopefully later we can add more things 4023 - to make the panic events more useful. */ 3848 + /* 3849 + * Put a few breadcrumbs in. Hopefully later we can add more things 3850 + * to make the panic events more useful. 3851 + */ 4024 3852 if (str) { 4025 3853 data[3] = str[0]; 4026 3854 data[6] = str[1]; ··· 4056 3880 } 4057 3881 4058 3882 #ifdef CONFIG_IPMI_PANIC_STRING 4059 - /* On every interface, dump a bunch of OEM event holding the 4060 - string. */ 4061 - if (!str) 3883 + /* 3884 + * On every interface, dump a bunch of OEM event holding the 3885 + * string. 3886 + */ 3887 + if (!str) 4062 3888 return; 4063 3889 4064 3890 /* For every registered interface, send the event. */ ··· 4081 3903 */ 4082 3904 smp_rmb(); 4083 3905 4084 - /* First job here is to figure out where to send the 4085 - OEM events. There's no way in IPMI to send OEM 4086 - events using an event send command, so we have to 4087 - find the SEL to put them in and stick them in 4088 - there. */ 3906 + /* 3907 + * First job here is to figure out where to send the 3908 + * OEM events. There's no way in IPMI to send OEM 3909 + * events using an event send command, so we have to 3910 + * find the SEL to put them in and stick them in 3911 + * there. 3912 + */ 4089 3913 4090 3914 /* Get capabilities from the get device id. */ 4091 3915 intf->local_sel_device = 0; ··· 4135 3955 } 4136 3956 intf->null_user_handler = NULL; 4137 3957 4138 - /* Validate the event receiver. The low bit must not 4139 - be 1 (it must be a valid IPMB address), it cannot 4140 - be zero, and it must not be my address. */ 4141 - if (((intf->event_receiver & 1) == 0) 3958 + /* 3959 + * Validate the event receiver. The low bit must not 3960 + * be 1 (it must be a valid IPMB address), it cannot 3961 + * be zero, and it must not be my address. 3962 + */ 3963 + if (((intf->event_receiver & 1) == 0) 4142 3964 && (intf->event_receiver != 0) 4143 - && (intf->event_receiver != intf->channels[0].address)) 4144 - { 4145 - /* The event receiver is valid, send an IPMB 4146 - message. */ 3965 + && (intf->event_receiver != intf->channels[0].address)) { 3966 + /* 3967 + * The event receiver is valid, send an IPMB 3968 + * message. 3969 + */ 4147 3970 ipmb = (struct ipmi_ipmb_addr *) &addr; 4148 3971 ipmb->addr_type = IPMI_IPMB_ADDR_TYPE; 4149 3972 ipmb->channel = 0; /* FIXME - is this right? */ 4150 3973 ipmb->lun = intf->event_receiver_lun; 4151 3974 ipmb->slave_addr = intf->event_receiver; 4152 3975 } else if (intf->local_sel_device) { 4153 - /* The event receiver was not valid (or was 4154 - me), but I am an SEL device, just dump it 4155 - in my SEL. */ 3976 + /* 3977 + * The event receiver was not valid (or was 3978 + * me), but I am an SEL device, just dump it 3979 + * in my SEL. 3980 + */ 4156 3981 si = (struct ipmi_system_interface_addr *) &addr; 4157 3982 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 4158 3983 si->channel = IPMI_BMC_CHANNEL; ··· 4165 3980 } else 4166 3981 continue; /* No where to send the event. */ 4167 3982 4168 - 4169 3983 msg.netfn = IPMI_NETFN_STORAGE_REQUEST; /* Storage. */ 4170 3984 msg.cmd = IPMI_ADD_SEL_ENTRY_CMD; 4171 3985 msg.data = data; ··· 4181 3997 data[2] = 0xf0; /* OEM event without timestamp. */ 4182 3998 data[3] = intf->channels[0].address; 4183 3999 data[4] = j++; /* sequence # */ 4184 - /* Always give 11 bytes, so strncpy will fill 4185 - it with zeroes for me. */ 4000 + /* 4001 + * Always give 11 bytes, so strncpy will fill 4002 + * it with zeroes for me. 4003 + */ 4186 4004 strncpy(data+5, p, 11); 4187 4005 p += size; 4188 4006 ··· 4201 4015 intf->channels[0].lun, 4202 4016 0, 1); /* no retry, and no wait. */ 4203 4017 } 4204 - } 4018 + } 4205 4019 #endif /* CONFIG_IPMI_PANIC_STRING */ 4206 4020 } 4207 4021 #endif /* CONFIG_IPMI_PANIC_EVENT */ ··· 4210 4024 4211 4025 static int panic_event(struct notifier_block *this, 4212 4026 unsigned long event, 4213 - void *ptr) 4027 + void *ptr) 4214 4028 { 4215 4029 ipmi_smi_t intf; 4216 4030 ··· 4292 4106 4293 4107 atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block); 4294 4108 4295 - /* This can't be called if any interfaces exist, so no worry about 4296 - shutting down the interfaces. */ 4109 + /* 4110 + * This can't be called if any interfaces exist, so no worry 4111 + * about shutting down the interfaces. 4112 + */ 4297 4113 4298 - /* Tell the timer to stop, then wait for it to stop. This avoids 4299 - problems with race conditions removing the timer here. */ 4114 + /* 4115 + * Tell the timer to stop, then wait for it to stop. This 4116 + * avoids problems with race conditions removing the timer 4117 + * here. 4118 + */ 4300 4119 atomic_inc(&stop_operation); 4301 4120 del_timer_sync(&ipmi_timer); 4302 4121 ··· 4328 4137 module_init(ipmi_init_msghandler_mod); 4329 4138 MODULE_LICENSE("GPL"); 4330 4139 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); 4331 - MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); 4140 + MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI" 4141 + " interface."); 4332 4142 MODULE_VERSION(IPMI_DRIVER_VERSION); 4333 - 4334 - EXPORT_SYMBOL(ipmi_create_user); 4335 - EXPORT_SYMBOL(ipmi_destroy_user); 4336 - EXPORT_SYMBOL(ipmi_get_version); 4337 - EXPORT_SYMBOL(ipmi_request_settime); 4338 - EXPORT_SYMBOL(ipmi_request_supply_msgs); 4339 - EXPORT_SYMBOL(ipmi_poll_interface); 4340 - EXPORT_SYMBOL(ipmi_register_smi); 4341 - EXPORT_SYMBOL(ipmi_unregister_smi); 4342 - EXPORT_SYMBOL(ipmi_register_for_cmd); 4343 - EXPORT_SYMBOL(ipmi_unregister_for_cmd); 4344 - EXPORT_SYMBOL(ipmi_smi_msg_received); 4345 - EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout); 4346 - EXPORT_SYMBOL(ipmi_alloc_smi_msg); 4347 - EXPORT_SYMBOL(ipmi_addr_length); 4348 - EXPORT_SYMBOL(ipmi_validate_addr); 4349 - EXPORT_SYMBOL(ipmi_set_gets_events); 4350 - EXPORT_SYMBOL(ipmi_smi_watcher_register); 4351 - EXPORT_SYMBOL(ipmi_smi_watcher_unregister); 4352 - EXPORT_SYMBOL(ipmi_set_my_address); 4353 - EXPORT_SYMBOL(ipmi_get_my_address); 4354 - EXPORT_SYMBOL(ipmi_set_my_LUN); 4355 - EXPORT_SYMBOL(ipmi_get_my_LUN); 4356 - EXPORT_SYMBOL(ipmi_smi_add_proc_entry); 4357 - EXPORT_SYMBOL(ipmi_free_recv_msg);
+30 -42
include/linux/ipmi.h
··· 75 75 * work for sockets. 76 76 */ 77 77 #define IPMI_MAX_ADDR_SIZE 32 78 - struct ipmi_addr 79 - { 78 + struct ipmi_addr { 80 79 /* Try to take these from the "Channel Medium Type" table 81 80 in section 6.5 of the IPMI 1.5 manual. */ 82 81 int addr_type; ··· 89 90 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC. 90 91 */ 91 92 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c 92 - struct ipmi_system_interface_addr 93 - { 93 + struct ipmi_system_interface_addr { 94 94 int addr_type; 95 95 short channel; 96 96 unsigned char lun; ··· 98 100 /* An IPMB Address. */ 99 101 #define IPMI_IPMB_ADDR_TYPE 0x01 100 102 /* Used for broadcast get device id as described in section 17.9 of the 101 - IPMI 1.5 manual. */ 103 + IPMI 1.5 manual. */ 102 104 #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 103 - struct ipmi_ipmb_addr 104 - { 105 + struct ipmi_ipmb_addr { 105 106 int addr_type; 106 107 short channel; 107 108 unsigned char slave_addr; ··· 125 128 * message is a little weird, but this is required. 126 129 */ 127 130 #define IPMI_LAN_ADDR_TYPE 0x04 128 - struct ipmi_lan_addr 129 - { 131 + struct ipmi_lan_addr { 130 132 int addr_type; 131 133 short channel; 132 134 unsigned char privilege; ··· 158 162 * byte of data in the response (as the spec shows the messages laid 159 163 * out). 160 164 */ 161 - struct ipmi_msg 162 - { 165 + struct ipmi_msg { 163 166 unsigned char netfn; 164 167 unsigned char cmd; 165 168 unsigned short data_len; 166 169 unsigned char __user *data; 167 170 }; 168 171 169 - struct kernel_ipmi_msg 170 - { 172 + struct kernel_ipmi_msg { 171 173 unsigned char netfn; 172 174 unsigned char cmd; 173 175 unsigned short data_len; ··· 233 239 * used after the message is delivered, so the upper layer may use the 234 240 * link to build a linked list, if it likes. 235 241 */ 236 - struct ipmi_recv_msg 237 - { 242 + struct ipmi_recv_msg { 238 243 struct list_head link; 239 244 240 245 /* The type of message as defined in the "Receive Types" 241 - defines above. */ 246 + defines above. */ 242 247 int recv_type; 243 248 244 249 ipmi_user_t user; ··· 264 271 /* Allocate and free the receive message. */ 265 272 void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); 266 273 267 - struct ipmi_user_hndl 268 - { 269 - /* Routine type to call when a message needs to be routed to 274 + struct ipmi_user_hndl { 275 + /* Routine type to call when a message needs to be routed to 270 276 the upper layer. This will be called with some locks held, 271 277 the only IPMI routines that can be called are ipmi_request 272 278 and the alloc/free operations. The handler_data is the ··· 425 433 * every existing interface when a new watcher is registered with 426 434 * ipmi_smi_watcher_register(). 427 435 */ 428 - struct ipmi_smi_watcher 429 - { 436 + struct ipmi_smi_watcher { 430 437 struct list_head link; 431 438 432 439 /* You must set the owner to the current module, if you are in ··· 496 505 497 506 498 507 /* Messages sent to the interface are this format. */ 499 - struct ipmi_req 500 - { 508 + struct ipmi_req { 501 509 unsigned char __user *addr; /* Address to send the message to. */ 502 510 unsigned int addr_len; 503 511 ··· 521 531 522 532 /* Messages sent to the interface with timing parameters are this 523 533 format. */ 524 - struct ipmi_req_settime 525 - { 534 + struct ipmi_req_settime { 526 535 struct ipmi_req req; 527 536 528 537 /* See ipmi_request_settime() above for details on these 529 - values. */ 538 + values. */ 530 539 int retries; 531 540 unsigned int retry_time_ms; 532 541 }; ··· 542 553 struct ipmi_req_settime) 543 554 544 555 /* Messages received from the interface are this format. */ 545 - struct ipmi_recv 546 - { 556 + struct ipmi_recv { 547 557 int recv_type; /* Is this a command, response or an 548 558 asyncronous event. */ 549 559 ··· 588 600 struct ipmi_recv) 589 601 590 602 /* Register to get commands from other entities on this interface. */ 591 - struct ipmi_cmdspec 592 - { 603 + struct ipmi_cmdspec { 593 604 unsigned char netfn; 594 605 unsigned char cmd; 595 606 }; 596 607 597 - /* 608 + /* 598 609 * Register to receive a specific command. error values: 599 610 * - EFAULT - an address supplied was invalid. 600 611 * - EBUSY - The netfn/cmd supplied was already in use. ··· 616 629 * else. The chans field is a bitmask, (1 << channel) for each channel. 617 630 * It may be IPMI_CHAN_ALL for all channels. 618 631 */ 619 - struct ipmi_cmdspec_chans 620 - { 632 + struct ipmi_cmdspec_chans { 621 633 unsigned int netfn; 622 634 unsigned int cmd; 623 635 unsigned int chans; ··· 638 652 #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \ 639 653 struct ipmi_cmdspec_chans) 640 654 641 - /* 655 + /* 642 656 * Set whether this interface receives events. Note that the first 643 657 * user registered for events will get all pending events for the 644 658 * interface. error values: ··· 654 668 * things it takes to determine your address (if not the BMC) and set 655 669 * it for everyone else. You should probably leave the LUN alone. 656 670 */ 657 - struct ipmi_channel_lun_address_set 658 - { 671 + struct ipmi_channel_lun_address_set { 659 672 unsigned short channel; 660 673 unsigned char value; 661 674 }; 662 - #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set) 663 - #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set) 664 - #define IPMICTL_SET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set) 665 - #define IPMICTL_GET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set) 675 + #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \ 676 + _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set) 677 + #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \ 678 + _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set) 679 + #define IPMICTL_SET_MY_CHANNEL_LUN_CMD \ 680 + _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set) 681 + #define IPMICTL_GET_MY_CHANNEL_LUN_CMD \ 682 + _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set) 666 683 /* Legacy interfaces, these only set IPMB 0. */ 667 684 #define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int) 668 685 #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int) ··· 676 687 * Get/set the default timing values for an interface. You shouldn't 677 688 * generally mess with these. 678 689 */ 679 - struct ipmi_timing_parms 680 - { 690 + struct ipmi_timing_parms { 681 691 int retries; 682 692 unsigned int retry_time_ms; 683 693 };
+3 -5
include/linux/ipmi_smi.h
··· 60 60 * asynchronous data and messages and request them from the 61 61 * interface. 62 62 */ 63 - struct ipmi_smi_msg 64 - { 63 + struct ipmi_smi_msg { 65 64 struct list_head link; 66 65 67 66 long msgid; ··· 73 74 unsigned char rsp[IPMI_MAX_MSG_LENGTH]; 74 75 75 76 /* Will be called when the system is done with the message 76 - (presumably to free it). */ 77 + (presumably to free it). */ 77 78 void (*done)(struct ipmi_smi_msg *msg); 78 79 }; 79 80 80 - struct ipmi_smi_handlers 81 - { 81 + struct ipmi_smi_handlers { 82 82 struct module *owner; 83 83 84 84 /* The low-level interface cannot start sending messages to