aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ipmi/ipmi_poweroff.c
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2008-04-29 04:01:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:15 -0400
commit36c7dc44409ecc4631de25a66f13d67873cfd563 (patch)
treefc86c1df3b33b0933aaa246221d129d8f31906af /drivers/char/ipmi/ipmi_poweroff.c
parentc305e3d38e5f54a48a4618496cdc1ada970ebf68 (diff)
IPMI: Style fixes in the misc code
Lots of style fixes for the miscellaneous IPMI files. 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>
Diffstat (limited to 'drivers/char/ipmi/ipmi_poweroff.c')
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c184
1 files changed, 94 insertions, 90 deletions
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index b065a53d1ca..f776df78879 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -87,7 +87,10 @@ MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
87 87
88/* parameter definition to allow user to flag power cycle */ 88/* parameter definition to allow user to flag power cycle */
89module_param(poweroff_powercycle, int, 0644); 89module_param(poweroff_powercycle, int, 0644);
90MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); 90MODULE_PARM_DESC(poweroff_powercycle,
91 " Set to non-zero to enable power cycle instead of power"
92 " down. Power cycle is contingent on hardware support,"
93 " otherwise it defaults back to power down.");
91 94
92/* Stuff from the get device id command. */ 95/* Stuff from the get device id command. */
93static unsigned int mfg_id; 96static unsigned int mfg_id;
@@ -95,10 +98,12 @@ static unsigned int prod_id;
95static unsigned char capabilities; 98static unsigned char capabilities;
96static unsigned char ipmi_version; 99static unsigned char ipmi_version;
97 100
98/* We use our own messages for this operation, we don't let the system 101/*
99 allocate them, since we may be in a panic situation. The whole 102 * We use our own messages for this operation, we don't let the system
100 thing is single-threaded, anyway, so multiple messages are not 103 * allocate them, since we may be in a panic situation. The whole
101 required. */ 104 * thing is single-threaded, anyway, so multiple messages are not
105 * required.
106 */
102static atomic_t dummy_count = ATOMIC_INIT(0); 107static atomic_t dummy_count = ATOMIC_INIT(0);
103static void dummy_smi_free(struct ipmi_smi_msg *msg) 108static void dummy_smi_free(struct ipmi_smi_msg *msg)
104{ 109{
@@ -108,12 +113,10 @@ static void dummy_recv_free(struct ipmi_recv_msg *msg)
108{ 113{
109 atomic_dec(&dummy_count); 114 atomic_dec(&dummy_count);
110} 115}
111static struct ipmi_smi_msg halt_smi_msg = 116static struct ipmi_smi_msg halt_smi_msg = {
112{
113 .done = dummy_smi_free 117 .done = dummy_smi_free
114}; 118};
115static struct ipmi_recv_msg halt_recv_msg = 119static struct ipmi_recv_msg halt_recv_msg = {
116{
117 .done = dummy_recv_free 120 .done = dummy_recv_free
118}; 121};
119 122
@@ -130,8 +133,7 @@ static void receive_handler(struct ipmi_recv_msg *recv_msg, void *handler_data)
130 complete(comp); 133 complete(comp);
131} 134}
132 135
133static struct ipmi_user_hndl ipmi_poweroff_handler = 136static struct ipmi_user_hndl ipmi_poweroff_handler = {
134{
135 .ipmi_recv_hndl = receive_handler 137 .ipmi_recv_hndl = receive_handler
136}; 138};
137 139
@@ -198,47 +200,47 @@ static int ipmi_request_in_rc_mode(ipmi_user_t user,
198 200
199static void (*atca_oem_poweroff_hook)(ipmi_user_t user); 201static void (*atca_oem_poweroff_hook)(ipmi_user_t user);
200 202
201static void pps_poweroff_atca (ipmi_user_t user) 203static void pps_poweroff_atca(ipmi_user_t user)
202{ 204{
203 struct ipmi_system_interface_addr smi_addr; 205 struct ipmi_system_interface_addr smi_addr;
204 struct kernel_ipmi_msg send_msg; 206 struct kernel_ipmi_msg send_msg;
205 int rv; 207 int rv;
206 /* 208 /*
207 * Configure IPMI address for local access 209 * Configure IPMI address for local access
208 */ 210 */
209 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 211 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
210 smi_addr.channel = IPMI_BMC_CHANNEL; 212 smi_addr.channel = IPMI_BMC_CHANNEL;
211 smi_addr.lun = 0; 213 smi_addr.lun = 0;
212 214
213 printk(KERN_INFO PFX "PPS powerdown hook used"); 215 printk(KERN_INFO PFX "PPS powerdown hook used");
214 216
215 send_msg.netfn = IPMI_NETFN_OEM; 217 send_msg.netfn = IPMI_NETFN_OEM;
216 send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART; 218 send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
217 send_msg.data = IPMI_ATCA_PPS_IANA; 219 send_msg.data = IPMI_ATCA_PPS_IANA;
218 send_msg.data_len = 3; 220 send_msg.data_len = 3;
219 rv = ipmi_request_in_rc_mode(user, 221 rv = ipmi_request_in_rc_mode(user,
220 (struct ipmi_addr *) &smi_addr, 222 (struct ipmi_addr *) &smi_addr,
221 &send_msg); 223 &send_msg);
222 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { 224 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
223 printk(KERN_ERR PFX "Unable to send ATCA ," 225 printk(KERN_ERR PFX "Unable to send ATCA ,"
224 " IPMI error 0x%x\n", rv); 226 " IPMI error 0x%x\n", rv);
225 } 227 }
226 return; 228 return;
227} 229}
228 230
229static int ipmi_atca_detect (ipmi_user_t user) 231static int ipmi_atca_detect(ipmi_user_t user)
230{ 232{
231 struct ipmi_system_interface_addr smi_addr; 233 struct ipmi_system_interface_addr smi_addr;
232 struct kernel_ipmi_msg send_msg; 234 struct kernel_ipmi_msg send_msg;
233 int rv; 235 int rv;
234 unsigned char data[1]; 236 unsigned char data[1];
235 237
236 /* 238 /*
237 * Configure IPMI address for local access 239 * Configure IPMI address for local access
238 */ 240 */
239 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 241 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
240 smi_addr.channel = IPMI_BMC_CHANNEL; 242 smi_addr.channel = IPMI_BMC_CHANNEL;
241 smi_addr.lun = 0; 243 smi_addr.lun = 0;
242 244
243 /* 245 /*
244 * Use get address info to check and see if we are ATCA 246 * Use get address info to check and see if we are ATCA
@@ -252,28 +254,30 @@ static int ipmi_atca_detect (ipmi_user_t user)
252 (struct ipmi_addr *) &smi_addr, 254 (struct ipmi_addr *) &smi_addr,
253 &send_msg); 255 &send_msg);
254 256
255 printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id); 257 printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n",
256 if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID) 258 mfg_id, prod_id);
257 && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) { 259 if ((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
258 printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n"); 260 && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
261 printk(KERN_INFO PFX
262 "Installing Pigeon Point Systems Poweroff Hook\n");
259 atca_oem_poweroff_hook = pps_poweroff_atca; 263 atca_oem_poweroff_hook = pps_poweroff_atca;
260 } 264 }
261 return !rv; 265 return !rv;
262} 266}
263 267
264static void ipmi_poweroff_atca (ipmi_user_t user) 268static void ipmi_poweroff_atca(ipmi_user_t user)
265{ 269{
266 struct ipmi_system_interface_addr smi_addr; 270 struct ipmi_system_interface_addr smi_addr;
267 struct kernel_ipmi_msg send_msg; 271 struct kernel_ipmi_msg send_msg;
268 int rv; 272 int rv;
269 unsigned char data[4]; 273 unsigned char data[4];
270 274
271 /* 275 /*
272 * Configure IPMI address for local access 276 * Configure IPMI address for local access
273 */ 277 */
274 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 278 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
275 smi_addr.channel = IPMI_BMC_CHANNEL; 279 smi_addr.channel = IPMI_BMC_CHANNEL;
276 smi_addr.lun = 0; 280 smi_addr.lun = 0;
277 281
278 printk(KERN_INFO PFX "Powering down via ATCA power command\n"); 282 printk(KERN_INFO PFX "Powering down via ATCA power command\n");
279 283
@@ -287,22 +291,23 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
287 data[2] = 0; /* Power Level */ 291 data[2] = 0; /* Power Level */
288 data[3] = 0; /* Don't change saved presets */ 292 data[3] = 0; /* Don't change saved presets */
289 send_msg.data = data; 293 send_msg.data = data;
290 send_msg.data_len = sizeof (data); 294 send_msg.data_len = sizeof(data);
291 rv = ipmi_request_in_rc_mode(user, 295 rv = ipmi_request_in_rc_mode(user,
292 (struct ipmi_addr *) &smi_addr, 296 (struct ipmi_addr *) &smi_addr,
293 &send_msg); 297 &send_msg);
294 /** At this point, the system may be shutting down, and most 298 /*
295 ** serial drivers (if used) will have interrupts turned off 299 * At this point, the system may be shutting down, and most
296 ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE 300 * serial drivers (if used) will have interrupts turned off
297 ** return code 301 * it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE
298 **/ 302 * return code
299 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { 303 */
304 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
300 printk(KERN_ERR PFX "Unable to send ATCA powerdown message," 305 printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
301 " IPMI error 0x%x\n", rv); 306 " IPMI error 0x%x\n", rv);
302 goto out; 307 goto out;
303 } 308 }
304 309
305 if(atca_oem_poweroff_hook) 310 if (atca_oem_poweroff_hook)
306 return atca_oem_poweroff_hook(user); 311 return atca_oem_poweroff_hook(user);
307 out: 312 out:
308 return; 313 return;
@@ -324,13 +329,13 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
324#define IPMI_CPI1_PRODUCT_ID 0x000157 329#define IPMI_CPI1_PRODUCT_ID 0x000157
325#define IPMI_CPI1_MANUFACTURER_ID 0x0108 330#define IPMI_CPI1_MANUFACTURER_ID 0x0108
326 331
327static int ipmi_cpi1_detect (ipmi_user_t user) 332static int ipmi_cpi1_detect(ipmi_user_t user)
328{ 333{
329 return ((mfg_id == IPMI_CPI1_MANUFACTURER_ID) 334 return ((mfg_id == IPMI_CPI1_MANUFACTURER_ID)
330 && (prod_id == IPMI_CPI1_PRODUCT_ID)); 335 && (prod_id == IPMI_CPI1_PRODUCT_ID));
331} 336}
332 337
333static void ipmi_poweroff_cpi1 (ipmi_user_t user) 338static void ipmi_poweroff_cpi1(ipmi_user_t user)
334{ 339{
335 struct ipmi_system_interface_addr smi_addr; 340 struct ipmi_system_interface_addr smi_addr;
336 struct ipmi_ipmb_addr ipmb_addr; 341 struct ipmi_ipmb_addr ipmb_addr;
@@ -342,12 +347,12 @@ static void ipmi_poweroff_cpi1 (ipmi_user_t user)
342 unsigned char aer_addr; 347 unsigned char aer_addr;
343 unsigned char aer_lun; 348 unsigned char aer_lun;
344 349
345 /* 350 /*
346 * Configure IPMI address for local access 351 * Configure IPMI address for local access
347 */ 352 */
348 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 353 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
349 smi_addr.channel = IPMI_BMC_CHANNEL; 354 smi_addr.channel = IPMI_BMC_CHANNEL;
350 smi_addr.lun = 0; 355 smi_addr.lun = 0;
351 356
352 printk(KERN_INFO PFX "Powering down via CPI1 power command\n"); 357 printk(KERN_INFO PFX "Powering down via CPI1 power command\n");
353 358
@@ -439,7 +444,7 @@ static void ipmi_poweroff_cpi1 (ipmi_user_t user)
439 */ 444 */
440 445
441#define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} 446#define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00}
442static int ipmi_dell_chassis_detect (ipmi_user_t user) 447static int ipmi_dell_chassis_detect(ipmi_user_t user)
443{ 448{
444 const char ipmi_version_major = ipmi_version & 0xF; 449 const char ipmi_version_major = ipmi_version & 0xF;
445 const char ipmi_version_minor = (ipmi_version >> 4) & 0xF; 450 const char ipmi_version_minor = (ipmi_version >> 4) & 0xF;
@@ -458,25 +463,25 @@ static int ipmi_dell_chassis_detect (ipmi_user_t user)
458#define IPMI_NETFN_CHASSIS_REQUEST 0 463#define IPMI_NETFN_CHASSIS_REQUEST 0
459#define IPMI_CHASSIS_CONTROL_CMD 0x02 464#define IPMI_CHASSIS_CONTROL_CMD 0x02
460 465
461static int ipmi_chassis_detect (ipmi_user_t user) 466static int ipmi_chassis_detect(ipmi_user_t user)
462{ 467{
463 /* Chassis support, use it. */ 468 /* Chassis support, use it. */
464 return (capabilities & 0x80); 469 return (capabilities & 0x80);
465} 470}
466 471
467static void ipmi_poweroff_chassis (ipmi_user_t user) 472static void ipmi_poweroff_chassis(ipmi_user_t user)
468{ 473{
469 struct ipmi_system_interface_addr smi_addr; 474 struct ipmi_system_interface_addr smi_addr;
470 struct kernel_ipmi_msg send_msg; 475 struct kernel_ipmi_msg send_msg;
471 int rv; 476 int rv;
472 unsigned char data[1]; 477 unsigned char data[1];
473 478
474 /* 479 /*
475 * Configure IPMI address for local access 480 * Configure IPMI address for local access
476 */ 481 */
477 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 482 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
478 smi_addr.channel = IPMI_BMC_CHANNEL; 483 smi_addr.channel = IPMI_BMC_CHANNEL;
479 smi_addr.lun = 0; 484 smi_addr.lun = 0;
480 485
481 powercyclefailed: 486 powercyclefailed:
482 printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n", 487 printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n",
@@ -539,7 +544,7 @@ static struct poweroff_function poweroff_functions[] = {
539 544
540 545
541/* Called on a powerdown request. */ 546/* Called on a powerdown request. */
542static void ipmi_poweroff_function (void) 547static void ipmi_poweroff_function(void)
543{ 548{
544 if (!ready) 549 if (!ready)
545 return; 550 return;
@@ -573,13 +578,13 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
573 578
574 ipmi_ifnum = if_num; 579 ipmi_ifnum = if_num;
575 580
576 /* 581 /*
577 * Do a get device ide and store some results, since this is 582 * Do a get device ide and store some results, since this is
578 * used by several functions. 583 * used by several functions.
579 */ 584 */
580 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 585 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
581 smi_addr.channel = IPMI_BMC_CHANNEL; 586 smi_addr.channel = IPMI_BMC_CHANNEL;
582 smi_addr.lun = 0; 587 smi_addr.lun = 0;
583 588
584 send_msg.netfn = IPMI_NETFN_APP_REQUEST; 589 send_msg.netfn = IPMI_NETFN_APP_REQUEST;
585 send_msg.cmd = IPMI_GET_DEVICE_ID_CMD; 590 send_msg.cmd = IPMI_GET_DEVICE_ID_CMD;
@@ -644,8 +649,7 @@ static void ipmi_po_smi_gone(int if_num)
644 pm_power_off = old_poweroff_func; 649 pm_power_off = old_poweroff_func;
645} 650}
646 651
647static struct ipmi_smi_watcher smi_watcher = 652static struct ipmi_smi_watcher smi_watcher = {
648{
649 .owner = THIS_MODULE, 653 .owner = THIS_MODULE,
650 .new_smi = ipmi_po_new_smi, 654 .new_smi = ipmi_po_new_smi,
651 .smi_gone = ipmi_po_smi_gone 655 .smi_gone = ipmi_po_smi_gone
@@ -687,12 +691,12 @@ static struct ctl_table_header *ipmi_table_header;
687/* 691/*
688 * Startup and shutdown functions. 692 * Startup and shutdown functions.
689 */ 693 */
690static int ipmi_poweroff_init (void) 694static int ipmi_poweroff_init(void)
691{ 695{
692 int rv; 696 int rv;
693 697
694 printk (KERN_INFO "Copyright (C) 2004 MontaVista Software -" 698 printk(KERN_INFO "Copyright (C) 2004 MontaVista Software -"
695 " IPMI Powerdown via sys_reboot.\n"); 699 " IPMI Powerdown via sys_reboot.\n");
696 700
697 if (poweroff_powercycle) 701 if (poweroff_powercycle)
698 printk(KERN_INFO PFX "Power cycle is enabled.\n"); 702 printk(KERN_INFO PFX "Power cycle is enabled.\n");