aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLior Dotan <liodot@gmail.com>2008-10-14 04:43:57 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-22 12:56:37 -0400
commit9b2126db35bd7546c5998a06dcbac96c6ec21e4f (patch)
tree8cbb4cb6f7bba1558b06b26596a6a5bf9c4a044d
parentf2d86100d95274bd85a36b7b7c0efa9af0d82b2b (diff)
Staging: PCC-ACPI: Fix all checkpatch errors
Fix all complaints that checkpatch had regarding this patch Signed-off-by: Lior Dotan <liodot@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/pcc-acpi/pcc-acpi.c429
1 files changed, 244 insertions, 185 deletions
diff --git a/drivers/staging/pcc-acpi/pcc-acpi.c b/drivers/staging/pcc-acpi/pcc-acpi.c
index e44181ead26d..7715c31f2731 100644
--- a/drivers/staging/pcc-acpi/pcc-acpi.c
+++ b/drivers/staging/pcc-acpi/pcc-acpi.c
@@ -27,11 +27,13 @@
27 * Nov.04, 2006 Hiroshi Miura <miura@da-cha.org> 27 * Nov.04, 2006 Hiroshi Miura <miura@da-cha.org>
28 * -v0.9 remove warning about section reference. 28 * -v0.9 remove warning about section reference.
29 * remove acpi_os_free 29 * remove acpi_os_free
30 * add /proc/acpi/pcc/brightness interface to allow HAL to access. 30 * add /proc/acpi/pcc/brightness interface to
31 * allow HAL to access.
31 * merge dbronaugh's enhancement 32 * merge dbronaugh's enhancement
32 * Aug.17, 2004 David Bronaugh (dbronaugh) 33 * Aug.17, 2004 David Bronaugh (dbronaugh)
33 * - Added screen brightness setting interface 34 * - Added screen brightness setting interface
34 * Thanks to the FreeBSD crew (acpi_panasonic.c authors) 35 * Thanks to the FreeBSD crew
36 * (acpi_panasonic.c authors)
35 * for the ideas I needed to accomplish it 37 * for the ideas I needed to accomplish it
36 * 38 *
37 * May.29, 2006 Hiroshi Miura <miura@da-cha.org> 39 * May.29, 2006 Hiroshi Miura <miura@da-cha.org>
@@ -41,13 +43,15 @@
41 * Hiroshi Yokota for providing solutions. 43 * Hiroshi Yokota for providing solutions.
42 * 44 *
43 * Oct.02, 2004 Hiroshi Miura <miura@da-cha.org> 45 * Oct.02, 2004 Hiroshi Miura <miura@da-cha.org>
44 * -v0.8.2 merge code of YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>. 46 * -v0.8.2 merge code of YOKOTA Hiroshi
47 * <yokota@netlab.is.tsukuba.ac.jp>.
45 * Add sticky key mode interface. 48 * Add sticky key mode interface.
46 * Refactoring acpi_pcc_generete_keyinput(). 49 * Refactoring acpi_pcc_generete_keyinput().
47 * 50 *
48 * Sep.15, 2004 Hiroshi Miura <miura@da-cha.org> 51 * Sep.15, 2004 Hiroshi Miura <miura@da-cha.org>
49 * -v0.8 Generate key input event on input subsystem. 52 * -v0.8 Generate key input event on input subsystem.
50 * This is based on yet another driver written by Ryuta Nakanishi. 53 * This is based on yet another driver
54 * written by Ryuta Nakanishi.
51 * 55 *
52 * Sep.10, 2004 Hiroshi Miura <miura@da-cha.org> 56 * Sep.10, 2004 Hiroshi Miura <miura@da-cha.org>
53 * -v0.7 Change proc interface functions using seq_file 57 * -v0.7 Change proc interface functions using seq_file
@@ -57,7 +61,8 @@
57 * -v0.6.4 Fix a silly error with status checking 61 * -v0.6.4 Fix a silly error with status checking
58 * 62 *
59 * Aug.25, 2004 Hiroshi Miura <miura@da-cha.org> 63 * Aug.25, 2004 Hiroshi Miura <miura@da-cha.org>
60 * -v0.6.3 replace read_acpi_int by standard function acpi_evaluate_integer 64 * -v0.6.3 replace read_acpi_int by standard
65 * function acpi_evaluate_integer
61 * some clean up and make smart copyright notice. 66 * some clean up and make smart copyright notice.
62 * fix return value of pcc_acpi_get_key() 67 * fix return value of pcc_acpi_get_key()
63 * fix checking return value of acpi_bus_register_driver() 68 * fix checking return value of acpi_bus_register_driver()
@@ -96,19 +101,18 @@
96 101
97#define ACPI_PCC_VERSION "0.9+hy" 102#define ACPI_PCC_VERSION "0.9+hy"
98 103
99#include <acpi/acpi_bus.h> 104#include <linux/kernel.h>
100#include <acpi/acpi_drivers.h> 105#include <linux/module.h>
101#include <asm/uaccess.h> 106#include <linux/types.h>
102#include <linux/ctype.h> 107#include <linux/ctype.h>
103#include <linux/init.h> 108#include <linux/init.h>
104#include <linux/input.h> 109#include <linux/input.h>
105#include <linux/kernel.h>
106#include <linux/module.h>
107#include <linux/proc_fs.h> 110#include <linux/proc_fs.h>
108#include <linux/seq_file.h> 111#include <linux/seq_file.h>
109#include <linux/slab.h> 112#include <linux/slab.h>
110#include <linux/types.h> 113#include <linux/uaccess.h>
111#include <linux/version.h> 114#include <acpi/acpi_bus.h>
115#include <acpi/acpi_drivers.h>
112 116
113 117
114/************************************************************************* 118/*************************************************************************
@@ -207,12 +211,18 @@ MODULE_LICENSE("GPL");
207 ENV_STATEs: Normal temp=0x01, High temp=0x81, N/A=0x00 211 ENV_STATEs: Normal temp=0x01, High temp=0x81, N/A=0x00
208*/ 212*/
209enum SINF_BITS { SINF_NUM_BATTERIES = 0, 213enum SINF_BITS { SINF_NUM_BATTERIES = 0,
210 SINF_LCD_TYPE, /* 1 */ 214 SINF_LCD_TYPE,
211 SINF_AC_MAX_BRIGHT, SINF_AC_MIN_BRIGHT, SINF_AC_CUR_BRIGHT, /* 2, 3, 4 */ 215 SINF_AC_MAX_BRIGHT,
212 /* 4 = R1 only handle SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT and don't know AC state */ 216 SINF_AC_MIN_BRIGHT,
213 SINF_DC_MAX_BRIGHT, SINF_DC_MIN_BRIGHT, SINF_DC_CUR_BRIGHT, /* 5, 6, 7 */ 217 SINF_AC_CUR_BRIGHT,
218 /* 4 = R1 only handle SINF_AC_CUR_BRIGHT
219 * as SINF_CUR_BRIGHT and don't know AC state */
220 SINF_DC_MAX_BRIGHT,
221 SINF_DC_MIN_BRIGHT,
222 SINF_DC_CUR_BRIGHT,
214 SINF_MUTE, 223 SINF_MUTE,
215 SINF_RESERVED, SINF_ENV_STATE, /* 9, 10 */ 224 SINF_RESERVED,
225 SINF_ENV_STATE, /* 10 */
216 SINF_STICKY_KEY = 0x80, 226 SINF_STICKY_KEY = 0x80,
217}; 227};
218 228
@@ -227,7 +237,8 @@ MODULE_DEVICE_TABLE(acpi, pcc_device_ids);
227 237
228 238
229static int __devinit acpi_pcc_hotkey_add(struct acpi_device *device); 239static int __devinit acpi_pcc_hotkey_add(struct acpi_device *device);
230static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device, int type); 240static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device,
241 int type);
231static int acpi_pcc_hotkey_resume(struct acpi_device *device); 242static int acpi_pcc_hotkey_resume(struct acpi_device *device);
232 243
233 244
@@ -236,11 +247,11 @@ static struct acpi_driver acpi_pcc_driver = {
236 .class = ACPI_PCC_CLASS, 247 .class = ACPI_PCC_CLASS,
237 .ids = pcc_device_ids, 248 .ids = pcc_device_ids,
238 .ops = { 249 .ops = {
239 .add = acpi_pcc_hotkey_add, 250 .add = acpi_pcc_hotkey_add,
240 .remove = __devexit_p(acpi_pcc_hotkey_remove), 251 .remove = __devexit_p(acpi_pcc_hotkey_remove),
241#ifdef CONFIG_PM 252#ifdef CONFIG_PM
242 /*.suspend = acpi_pcc_hotkey_suspend,*/ 253 /*.suspend = acpi_pcc_hotkey_suspend,*/
243 .resume = acpi_pcc_hotkey_resume, 254 .resume = acpi_pcc_hotkey_resume,
244#endif 255#endif
245 }, 256 },
246}; 257};
@@ -264,7 +275,7 @@ struct pcc_keyinput {
264 Hotkey driver core 275 Hotkey driver core
265 ************************************************************************* */ 276 ************************************************************************* */
266/* ------------------------------------------------------------------------- 277/* -------------------------------------------------------------------------
267 method access functions 278 method access functions
268 ------------------------------------------------------------------------- */ 279 ------------------------------------------------------------------------- */
269static int acpi_pcc_write_sset(struct acpi_hotkey *hotkey, int func, int val) 280static int acpi_pcc_write_sset(struct acpi_hotkey *hotkey, int func, int val)
270{ 281{
@@ -282,7 +293,8 @@ static int acpi_pcc_write_sset(struct acpi_hotkey *hotkey, int func, int val)
282 293
283 ACPI_FUNCTION_TRACE("acpi_pcc_write_sset"); 294 ACPI_FUNCTION_TRACE("acpi_pcc_write_sset");
284 295
285 status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SSET, &params, NULL); 296 status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SSET,
297 &params, NULL);
286 298
287 return_VALUE(status == AE_OK ? AE_OK : AE_ERROR); 299 return_VALUE(status == AE_OK ? AE_OK : AE_ERROR);
288} 300}
@@ -294,7 +306,8 @@ static inline int acpi_pcc_get_sqty(struct acpi_device *device)
294 306
295 ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty"); 307 ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty");
296 308
297 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY, NULL, &s); 309 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY,
310 NULL, &s);
298 if (ACPI_SUCCESS(status)) { 311 if (ACPI_SUCCESS(status)) {
299 return_VALUE(s); 312 return_VALUE(s);
300 } else { 313 } else {
@@ -304,7 +317,7 @@ static inline int acpi_pcc_get_sqty(struct acpi_device *device)
304 } 317 }
305} 318}
306 319
307static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32* sinf) 320static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32 *sinf)
308{ 321{
309 acpi_status status; 322 acpi_status status;
310 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 323 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -313,9 +326,11 @@ static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32* sinf)
313 326
314 ACPI_FUNCTION_TRACE("acpi_pcc_retrieve_biosdata"); 327 ACPI_FUNCTION_TRACE("acpi_pcc_retrieve_biosdata");
315 328
316 status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SINF, 0 , &buffer); 329 status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SINF, 0,
330 &buffer);
317 if (ACPI_FAILURE(status)) { 331 if (ACPI_FAILURE(status)) {
318 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "evaluation error HKEY.SINF\n")); 332 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
333 "evaluation error HKEY.SINF\n"));
319 status = AE_ERROR; 334 status = AE_ERROR;
320 return_VALUE(status); 335 return_VALUE(status);
321 } 336 }
@@ -327,7 +342,8 @@ static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32* sinf)
327 } 342 }
328 343
329 if (hotkey->num_sifr < hkey->package.count) { 344 if (hotkey->num_sifr < hkey->package.count) {
330 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "SQTY reports bad SINF length\n")); 345 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
346 "SQTY reports bad SINF length\n"));
331 status = AE_ERROR; 347 status = AE_ERROR;
332 goto free_buffer; 348 goto free_buffer;
333 } 349 }
@@ -337,7 +353,8 @@ static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32* sinf)
337 if (likely(element->type == ACPI_TYPE_INTEGER)) { 353 if (likely(element->type == ACPI_TYPE_INTEGER)) {
338 sinf[i] = element->integer.value; 354 sinf[i] = element->integer.value;
339 } else { 355 } else {
340 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid HKEY.SINF data\n")); 356 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
357 "Invalid HKEY.SINF data\n"));
341 status = AE_ERROR; 358 status = AE_ERROR;
342 break; 359 break;
343 } 360 }
@@ -356,24 +373,26 @@ static int acpi_pcc_read_sinf_field(struct seq_file *seq, int field)
356 373
357 ACPI_FUNCTION_TRACE("acpi_pcc_read_sinf_field"); 374 ACPI_FUNCTION_TRACE("acpi_pcc_read_sinf_field");
358 375
359 if (ACPI_SUCCESS(acpi_pcc_retrieve_biosdata(hotkey, sinf))) { 376 if (ACPI_SUCCESS(acpi_pcc_retrieve_biosdata(hotkey, sinf)))
360 seq_printf(seq, "%u\n", sinf[field]); 377 seq_printf(seq, "%u\n", sinf[field]);
361 } else { 378 else
362 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't retrieve BIOS data\n")); 379 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
363 } 380 "Couldn't retrieve BIOS data\n"));
364 381
365 return_VALUE(AE_OK); 382 return_VALUE(AE_OK);
366} 383}
367 384
368/* ------------------------------------------------------------------------- 385/* -------------------------------------------------------------------------
369 user interface functions 386 user interface functions
370 ------------------------------------------------------------------------- */ 387 ------------------------------------------------------------------------- */
371/* read methods */ 388/* read methods */
372/* Sinf read methods */ 389/* Sinf read methods */
373#define PCC_SINF_READ_F(_name_, FUNC) \ 390#define PCC_SINF_READ_F(_name_, FUNC) \
374static int _name_ (struct seq_file *seq, void *offset) \ 391static int _name_(struct seq_file *seq, void *offset) \
375{ \ 392{ \
376 return_VALUE(ACPI_SUCCESS(acpi_pcc_read_sinf_field(seq, (FUNC))) ? 0 : -EINVAL); \ 393 return_VALUE(ACPI_SUCCESS(acpi_pcc_read_sinf_field(seq, \
394 (FUNC))) \
395 ? 0 : -EINVAL); \
377} 396}
378 397
379PCC_SINF_READ_F(acpi_pcc_numbatteries_show, SINF_NUM_BATTERIES); 398PCC_SINF_READ_F(acpi_pcc_numbatteries_show, SINF_NUM_BATTERIES);
@@ -393,9 +412,8 @@ static int acpi_pcc_sticky_key_show(struct seq_file *seq, void *offset)
393 412
394 ACPI_FUNCTION_TRACE("acpi_pcc_sticky_key_show"); 413 ACPI_FUNCTION_TRACE("acpi_pcc_sticky_key_show");
395 414
396 if (!hotkey || !hotkey->device) { 415 if (!hotkey || !hotkey->device)
397 return_VALUE(-EINVAL); 416 return_VALUE(-EINVAL);
398 }
399 417
400 seq_printf(seq, "%d\n", hotkey->sticky_mode); 418 seq_printf(seq, "%d\n", hotkey->sticky_mode);
401 419
@@ -404,7 +422,7 @@ static int acpi_pcc_sticky_key_show(struct seq_file *seq, void *offset)
404 422
405static int acpi_pcc_keyinput_show(struct seq_file *seq, void *offset) 423static int acpi_pcc_keyinput_show(struct seq_file *seq, void *offset)
406{ 424{
407 struct acpi_hotkey *hotkey = (struct acpi_hotkey *) seq->private; 425 struct acpi_hotkey *hotkey = seq->private;
408 struct input_dev *hotk_input_dev = hotkey->input_dev; 426 struct input_dev *hotk_input_dev = hotkey->input_dev;
409 struct pcc_keyinput *keyinput = input_get_drvdata(hotk_input_dev); 427 struct pcc_keyinput *keyinput = input_get_drvdata(hotk_input_dev);
410 428
@@ -417,25 +435,25 @@ static int acpi_pcc_keyinput_show(struct seq_file *seq, void *offset)
417 435
418static int acpi_pcc_version_show(struct seq_file *seq, void *offset) 436static int acpi_pcc_version_show(struct seq_file *seq, void *offset)
419{ 437{
420 struct acpi_hotkey *hotkey = (struct acpi_hotkey *) seq->private; 438 struct acpi_hotkey *hotkey = seq->private;
421 439
422 ACPI_FUNCTION_TRACE("acpi_pcc_version_show"); 440 ACPI_FUNCTION_TRACE("acpi_pcc_version_show");
423 441
424 if (!hotkey || !hotkey->device) { 442 if (!hotkey || !hotkey->device)
425 return_VALUE(-EINVAL); 443 return_VALUE(-EINVAL);
426 }
427 444
428 seq_printf(seq, "%s version %s\n", ACPI_PCC_DRIVER_NAME, ACPI_PCC_VERSION); 445 seq_printf(seq, "%s version %s\n", ACPI_PCC_DRIVER_NAME,
446 ACPI_PCC_VERSION);
429 seq_printf(seq, "%li functions\n", hotkey->num_sifr); 447 seq_printf(seq, "%li functions\n", hotkey->num_sifr);
430 448
431 return_VALUE(0); 449 return_VALUE(0);
432} 450}
433 451
434/* write methods */ 452/* write methods */
435static ssize_t acpi_pcc_write_single_flag (struct file *file, 453static ssize_t acpi_pcc_write_single_flag(struct file *file,
436 const char __user *buffer, 454 const char __user *buffer,
437 size_t count, 455 size_t count,
438 int sinf_func) 456 int sinf_func)
439{ 457{
440 struct seq_file *seq = file->private_data; 458 struct seq_file *seq = file->private_data;
441 struct acpi_hotkey *hotkey = seq->private; 459 struct acpi_hotkey *hotkey = seq->private;
@@ -444,24 +462,23 @@ static ssize_t acpi_pcc_write_single_flag (struct file *file,
444 462
445 ACPI_FUNCTION_TRACE("acpi_pcc_write_single_flag"); 463 ACPI_FUNCTION_TRACE("acpi_pcc_write_single_flag");
446 464
447 if (!hotkey || (count > sizeof(write_string) - 1)) { 465 if (!hotkey || (count > sizeof(write_string) - 1))
448 return_VALUE(-EINVAL); 466 return_VALUE(-EINVAL);
449 }
450 467
451 if (copy_from_user(write_string, buffer, count)) { 468 if (copy_from_user(write_string, buffer, count))
452 return_VALUE(-EFAULT); 469 return_VALUE(-EFAULT);
453 } 470
454 write_string[count] = '\0'; 471 write_string[count] = '\0';
455 472
456 if ((sscanf(write_string, "%3i", &val) == 1) && 473 if ((sscanf(write_string, "%3i", &val) == 1) &&
457 (val == 0 || val == 1)) { 474 (val == 0 || val == 1))
458 acpi_pcc_write_sset(hotkey, sinf_func, val); 475 acpi_pcc_write_sset(hotkey, sinf_func, val);
459 }
460 476
461 return_VALUE(count); 477 return_VALUE(count);
462} 478}
463 479
464static unsigned long acpi_pcc_write_brightness(struct file *file, const char __user *buffer, 480static unsigned long acpi_pcc_write_brightness(struct file *file,
481 const char __user *buffer,
465 size_t count, 482 size_t count,
466 int min_index, int max_index, 483 int min_index, int max_index,
467 int cur_index) 484 int cur_index)
@@ -474,33 +491,32 @@ static unsigned long acpi_pcc_write_brightness(struct file *file, const char __u
474 491
475 ACPI_FUNCTION_TRACE("acpi_pcc_write_brightness"); 492 ACPI_FUNCTION_TRACE("acpi_pcc_write_brightness");
476 493
477 if (!hotkey || (count > sizeof(write_string) - 1)) { 494 if (!hotkey || (count > sizeof(write_string) - 1))
478 return_VALUE(-EINVAL); 495 return_VALUE(-EINVAL);
479 }
480 496
481 if (copy_from_user(write_string, buffer, count)) { 497 if (copy_from_user(write_string, buffer, count))
482 return_VALUE(-EFAULT); 498 return_VALUE(-EFAULT);
483 }
484 499
485 write_string[count] = '\0'; 500 write_string[count] = '\0';
486 501
487 if (ACPI_FAILURE(acpi_pcc_retrieve_biosdata(hotkey, sinf))) { 502 if (ACPI_FAILURE(acpi_pcc_retrieve_biosdata(hotkey, sinf))) {
488 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't retrieve BIOS data\n")); 503 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
504 "Couldn't retrieve BIOS data\n"));
489 goto end; 505 goto end;
490 } 506 }
491 507
492 if ((sscanf(write_string, "%4i", &bright) == 1) && 508 if ((sscanf(write_string, "%4i", &bright) == 1) &&
493 (bright >= sinf[min_index] ) && 509 (bright >= sinf[min_index]) &&
494 (bright <= sinf[max_index] )) { 510 (bright <= sinf[max_index]))
495 acpi_pcc_write_sset(hotkey, cur_index, bright); 511 acpi_pcc_write_sset(hotkey, cur_index, bright);
496 }
497 512
498end: 513end:
499 return_VALUE(count); 514 return_VALUE(count);
500} 515}
501 516
502static ssize_t acpi_pcc_write_ac_brightness(struct file *file, const char __user *buffer, 517static ssize_t acpi_pcc_write_ac_brightness(struct file *file,
503 size_t count, loff_t *ppos) 518 const char __user *buffer,
519 size_t count, loff_t *ppos)
504{ 520{
505 return_VALUE(acpi_pcc_write_brightness(file, buffer, count, 521 return_VALUE(acpi_pcc_write_brightness(file, buffer, count,
506 SINF_AC_MIN_BRIGHT, 522 SINF_AC_MIN_BRIGHT,
@@ -508,8 +524,9 @@ static ssize_t acpi_pcc_write_ac_brightness(struct file *file, const char __user
508 SINF_AC_CUR_BRIGHT)); 524 SINF_AC_CUR_BRIGHT));
509} 525}
510 526
511static ssize_t acpi_pcc_write_dc_brightness(struct file *file, const char __user *buffer, 527static ssize_t acpi_pcc_write_dc_brightness(struct file *file,
512 size_t count, loff_t *ppos) 528 const char __user *buffer,
529 size_t count, loff_t *ppos)
513{ 530{
514 return_VALUE(acpi_pcc_write_brightness(file, buffer, count, 531 return_VALUE(acpi_pcc_write_brightness(file, buffer, count,
515 SINF_DC_MIN_BRIGHT, 532 SINF_DC_MIN_BRIGHT,
@@ -517,24 +534,27 @@ static ssize_t acpi_pcc_write_dc_brightness(struct file *file, const char __user
517 SINF_DC_CUR_BRIGHT)); 534 SINF_DC_CUR_BRIGHT));
518} 535}
519 536
520static ssize_t acpi_pcc_write_no_brightness(struct file *file, const char __user *buffer, 537static ssize_t acpi_pcc_write_no_brightness(struct file *file,
521 size_t count, loff_t *ppos) 538 const char __user *buffer,
539 size_t count, loff_t *ppos)
522{ 540{
523 return acpi_pcc_write_brightness(file, buffer, count, SINF_AC_MIN_BRIGHT, 541 return acpi_pcc_write_brightness(file, buffer, count,
542 SINF_AC_MIN_BRIGHT,
524 SINF_AC_MAX_BRIGHT, 543 SINF_AC_MAX_BRIGHT,
525 SINF_AC_CUR_BRIGHT); 544 SINF_AC_CUR_BRIGHT);
526} 545}
527 546
528static ssize_t acpi_pcc_write_mute (struct file *file, 547static ssize_t acpi_pcc_write_mute(struct file *file,
529 const char __user *buffer, 548 const char __user *buffer,
530 size_t count, loff_t *ppos) 549 size_t count, loff_t *ppos)
531{ 550{
532 return_VALUE(acpi_pcc_write_single_flag(file, buffer, count, SINF_MUTE)); 551 return_VALUE(acpi_pcc_write_single_flag(file, buffer, count,
552 SINF_MUTE));
533} 553}
534 554
535static ssize_t acpi_pcc_write_sticky_key (struct file *file, 555static ssize_t acpi_pcc_write_sticky_key(struct file *file,
536 const char __user *buffer, 556 const char __user *buffer,
537 size_t count, loff_t *ppos) 557 size_t count, loff_t *ppos)
538{ 558{
539 struct seq_file *seq = (struct seq_file *)file->private_data; 559 struct seq_file *seq = (struct seq_file *)file->private_data;
540 struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private; 560 struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private;
@@ -543,13 +563,12 @@ static ssize_t acpi_pcc_write_sticky_key (struct file *file,
543 563
544 ACPI_FUNCTION_TRACE("acpi_pcc_write_sticky_key"); 564 ACPI_FUNCTION_TRACE("acpi_pcc_write_sticky_key");
545 565
546 if (!hotkey || (count > sizeof(write_string) - 1)) { 566 if (!hotkey || (count > sizeof(write_string) - 1))
547 return_VALUE(-EINVAL); 567 return_VALUE(-EINVAL);
548 }
549 568
550 if (copy_from_user(write_string, buffer, count)) { 569 if (copy_from_user(write_string, buffer, count))
551 return_VALUE(-EFAULT); 570 return_VALUE(-EFAULT);
552 } 571
553 write_string[count] = '\0'; 572 write_string[count] = '\0';
554 573
555 if ((sscanf(write_string, "%3i", &mode) == 1) && 574 if ((sscanf(write_string, "%3i", &mode) == 1) &&
@@ -561,8 +580,9 @@ static ssize_t acpi_pcc_write_sticky_key (struct file *file,
561 return_VALUE(count); 580 return_VALUE(count);
562} 581}
563 582
564static ssize_t acpi_pcc_write_keyinput(struct file *file, const char __user *buffer, 583static ssize_t acpi_pcc_write_keyinput(struct file *file,
565 size_t count, loff_t *ppos) 584 const char __user *buffer,
585 size_t count, loff_t *ppos)
566{ 586{
567 struct seq_file *seq = (struct seq_file *)file->private_data; 587 struct seq_file *seq = (struct seq_file *)file->private_data;
568 struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private; 588 struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private;
@@ -572,13 +592,11 @@ static ssize_t acpi_pcc_write_keyinput(struct file *file, const char __user *buf
572 592
573 ACPI_FUNCTION_TRACE("acpi_pcc_write_keyinput"); 593 ACPI_FUNCTION_TRACE("acpi_pcc_write_keyinput");
574 594
575 if (!hotkey || (count > (sizeof(write_string) - 1))) { 595 if (!hotkey || (count > (sizeof(write_string) - 1)))
576 return_VALUE(-EINVAL); 596 return_VALUE(-EINVAL);
577 }
578 597
579 if (copy_from_user(write_string, buffer, count)) { 598 if (copy_from_user(write_string, buffer, count))
580 return_VALUE(-EFAULT); 599 return_VALUE(-EFAULT);
581 }
582 600
583 write_string[count] = '\0'; 601 write_string[count] = '\0';
584 602
@@ -592,7 +610,7 @@ static ssize_t acpi_pcc_write_keyinput(struct file *file, const char __user *buf
592} 610}
593 611
594/* ------------------------------------------------------------------------- 612/* -------------------------------------------------------------------------
595 hotkey driver 613 hotkey driver
596 ------------------------------------------------------------------------- */ 614 ------------------------------------------------------------------------- */
597static void acpi_pcc_generete_keyinput(struct acpi_hotkey *hotkey) 615static void acpi_pcc_generete_keyinput(struct acpi_hotkey *hotkey)
598{ 616{
@@ -604,7 +622,8 @@ static void acpi_pcc_generete_keyinput(struct acpi_hotkey *hotkey)
604 /* 0 */ -1, 622 /* 0 */ -1,
605 /* 1 */ KEY_BRIGHTNESSDOWN, 623 /* 1 */ KEY_BRIGHTNESSDOWN,
606 /* 2 */ KEY_BRIGHTNESSUP, 624 /* 2 */ KEY_BRIGHTNESSUP,
607 /* 3 */ -1, /* vga/lcd switch event is not occur on hotkey driver. */ 625 /* 3 */ -1, /* vga/lcd switch event is not occur on
626 hotkey driver. */
608 /* 4 */ KEY_MUTE, 627 /* 4 */ KEY_MUTE,
609 /* 5 */ KEY_VOLUMEDOWN, 628 /* 5 */ KEY_VOLUMEDOWN,
610 /* 6 */ KEY_VOLUMEUP, 629 /* 6 */ KEY_VOLUMEUP,
@@ -616,11 +635,12 @@ static void acpi_pcc_generete_keyinput(struct acpi_hotkey *hotkey)
616 635
617 ACPI_FUNCTION_TRACE("acpi_pcc_generete_keyinput"); 636 ACPI_FUNCTION_TRACE("acpi_pcc_generete_keyinput");
618 637
619 if (keyinput->key_mode == 0) { return_VOID; } 638 if (keyinput->key_mode == 0)
639 return_VOID;
620 640
621 hkey_num = hinf & 0xf; 641 hkey_num = hinf & 0xf;
622 642
623 if (( 0 > hkey_num ) || 643 if ((0 > hkey_num) ||
624 (hkey_num > ARRAY_SIZE(key_map))) { 644 (hkey_num > ARRAY_SIZE(key_map))) {
625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 645 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
626 "hotkey number out of range: %d\n", 646 "hotkey number out of range: %d\n",
@@ -645,12 +665,13 @@ static int acpi_pcc_hotkey_get_key(struct acpi_hotkey *hotkey)
645 665
646 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_get_key"); 666 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_get_key");
647 667
648 status = acpi_evaluate_integer(hotkey->handle, METHOD_HKEY_QUERY, NULL, &result); 668 status = acpi_evaluate_integer(hotkey->handle, METHOD_HKEY_QUERY,
649 if (likely(ACPI_SUCCESS(status))) { 669 NULL, &result);
670 if (likely(ACPI_SUCCESS(status)))
650 hotkey->status = result; 671 hotkey->status = result;
651 } else { 672 else
652 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "error getting hotkey status\n")); 673 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
653 } 674 "error getting hotkey status\n"));
654 675
655 return_VALUE(status == AE_OK); 676 return_VALUE(status == AE_OK);
656} 677}
@@ -661,11 +682,13 @@ void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data)
661 682
662 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_notify"); 683 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_notify");
663 684
664 switch(event) { 685 switch (event) {
665 case HKEY_NOTIFY: 686 case HKEY_NOTIFY:
666 if (acpi_pcc_hotkey_get_key(hotkey)) { 687 if (acpi_pcc_hotkey_get_key(hotkey)) {
667 /* generate event like '"pcc HKEY 00000080 00000084"' when Fn+F4 pressed */ 688 /* generate event like '"pcc HKEY 00000080 00000084"'
668 acpi_bus_generate_proc_event(hotkey->device, event, hotkey->status); 689 * when Fn+F4 pressed */
690 acpi_bus_generate_proc_event(hotkey->device, event,
691 hotkey->status);
669 } 692 }
670 acpi_pcc_generete_keyinput(hotkey); 693 acpi_pcc_generete_keyinput(hotkey);
671 break; 694 break;
@@ -680,75 +703,96 @@ void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data)
680 FS Interface (/proc) 703 FS Interface (/proc)
681 ************************************************************************* */ 704 ************************************************************************* */
682/* oepn proc file fs*/ 705/* oepn proc file fs*/
683SEQ_OPEN_FS(acpi_pcc_dc_brightness_open_fs, acpi_pcc_dc_brightness_show); 706SEQ_OPEN_FS(acpi_pcc_dc_brightness_open_fs, acpi_pcc_dc_brightness_show);
684SEQ_OPEN_FS(acpi_pcc_numbatteries_open_fs, acpi_pcc_numbatteries_show); 707SEQ_OPEN_FS(acpi_pcc_numbatteries_open_fs, acpi_pcc_numbatteries_show);
685SEQ_OPEN_FS(acpi_pcc_lcdtype_open_fs, acpi_pcc_lcdtype_show); 708SEQ_OPEN_FS(acpi_pcc_lcdtype_open_fs, acpi_pcc_lcdtype_show);
686SEQ_OPEN_FS(acpi_pcc_ac_brightness_max_open_fs, acpi_pcc_ac_brightness_max_show); 709SEQ_OPEN_FS(acpi_pcc_ac_brightness_max_open_fs,
687SEQ_OPEN_FS(acpi_pcc_ac_brightness_min_open_fs, acpi_pcc_ac_brightness_min_show); 710 acpi_pcc_ac_brightness_max_show);
688SEQ_OPEN_FS(acpi_pcc_ac_brightness_open_fs, acpi_pcc_ac_brightness_show); 711SEQ_OPEN_FS(acpi_pcc_ac_brightness_min_open_fs,
689SEQ_OPEN_FS(acpi_pcc_dc_brightness_max_open_fs, acpi_pcc_dc_brightness_max_show); 712 acpi_pcc_ac_brightness_min_show);
690SEQ_OPEN_FS(acpi_pcc_dc_brightness_min_open_fs, acpi_pcc_dc_brightness_min_show); 713SEQ_OPEN_FS(acpi_pcc_ac_brightness_open_fs, acpi_pcc_ac_brightness_show);
691SEQ_OPEN_FS(acpi_pcc_brightness_open_fs, acpi_pcc_brightness_show); 714SEQ_OPEN_FS(acpi_pcc_dc_brightness_max_open_fs,
692SEQ_OPEN_FS(acpi_pcc_mute_open_fs, acpi_pcc_mute_show); 715 acpi_pcc_dc_brightness_max_show);
693SEQ_OPEN_FS(acpi_pcc_version_open_fs, acpi_pcc_version_show); 716SEQ_OPEN_FS(acpi_pcc_dc_brightness_min_open_fs,
694SEQ_OPEN_FS(acpi_pcc_keyinput_open_fs, acpi_pcc_keyinput_show); 717 acpi_pcc_dc_brightness_min_show);
695SEQ_OPEN_FS(acpi_pcc_sticky_key_open_fs, acpi_pcc_sticky_key_show); 718SEQ_OPEN_FS(acpi_pcc_brightness_open_fs, acpi_pcc_brightness_show);
696 719SEQ_OPEN_FS(acpi_pcc_mute_open_fs, acpi_pcc_mute_show);
697typedef struct file_operations fops_t; 720SEQ_OPEN_FS(acpi_pcc_version_open_fs, acpi_pcc_version_show);
698static fops_t acpi_pcc_numbatteries_fops = SEQ_FILEOPS_R (acpi_pcc_numbatteries_open_fs); 721SEQ_OPEN_FS(acpi_pcc_keyinput_open_fs, acpi_pcc_keyinput_show);
699static fops_t acpi_pcc_lcdtype_fops = SEQ_FILEOPS_R (acpi_pcc_lcdtype_open_fs); 722SEQ_OPEN_FS(acpi_pcc_sticky_key_open_fs, acpi_pcc_sticky_key_show);
700static fops_t acpi_pcc_mute_fops = SEQ_FILEOPS_RW(acpi_pcc_mute_open_fs, acpi_pcc_write_mute); 723
701static fops_t acpi_pcc_ac_brightness_fops = SEQ_FILEOPS_RW(acpi_pcc_ac_brightness_open_fs, acpi_pcc_write_ac_brightness); 724static struct file_operations acpi_pcc_numbatteries_fops =
702static fops_t acpi_pcc_ac_brightness_max_fops = SEQ_FILEOPS_R (acpi_pcc_ac_brightness_max_open_fs); 725 SEQ_FILEOPS_R(acpi_pcc_numbatteries_open_fs);
703static fops_t acpi_pcc_ac_brightness_min_fops = SEQ_FILEOPS_R (acpi_pcc_ac_brightness_min_open_fs); 726static struct file_operations acpi_pcc_lcdtype_fops =
704static fops_t acpi_pcc_dc_brightness_fops = SEQ_FILEOPS_RW(acpi_pcc_dc_brightness_open_fs, acpi_pcc_write_dc_brightness); 727 SEQ_FILEOPS_R(acpi_pcc_lcdtype_open_fs);
705static fops_t acpi_pcc_dc_brightness_max_fops = SEQ_FILEOPS_R (acpi_pcc_dc_brightness_max_open_fs); 728static struct file_operations acpi_pcc_mute_fops =
706static fops_t acpi_pcc_dc_brightness_min_fops = SEQ_FILEOPS_R (acpi_pcc_dc_brightness_min_open_fs); 729 SEQ_FILEOPS_RW(acpi_pcc_mute_open_fs, acpi_pcc_write_mute);
707static fops_t acpi_pcc_brightness_fops = SEQ_FILEOPS_RW(acpi_pcc_brightness_open_fs, acpi_pcc_write_no_brightness); 730static struct file_operations acpi_pcc_ac_brightness_fops =
708static fops_t acpi_pcc_sticky_key_fops = SEQ_FILEOPS_RW(acpi_pcc_sticky_key_open_fs, acpi_pcc_write_sticky_key); 731 SEQ_FILEOPS_RW(acpi_pcc_ac_brightness_open_fs,
709static fops_t acpi_pcc_keyinput_fops = SEQ_FILEOPS_RW(acpi_pcc_keyinput_open_fs, acpi_pcc_write_keyinput); 732 acpi_pcc_write_ac_brightness);
710static fops_t acpi_pcc_version_fops = SEQ_FILEOPS_R (acpi_pcc_version_open_fs); 733static struct file_operations acpi_pcc_ac_brightness_max_fops =
711 734 SEQ_FILEOPS_R(acpi_pcc_ac_brightness_max_open_fs);
712typedef struct _ProcItem 735static struct file_operations acpi_pcc_ac_brightness_min_fops =
713{ 736 SEQ_FILEOPS_R(acpi_pcc_ac_brightness_min_open_fs);
714 const char* name; 737static struct file_operations acpi_pcc_dc_brightness_fops =
738 SEQ_FILEOPS_RW(acpi_pcc_dc_brightness_open_fs,
739 acpi_pcc_write_dc_brightness);
740static struct file_operations acpi_pcc_dc_brightness_max_fops =
741 SEQ_FILEOPS_R(acpi_pcc_dc_brightness_max_open_fs);
742static struct file_operations acpi_pcc_dc_brightness_min_fops =
743 SEQ_FILEOPS_R(acpi_pcc_dc_brightness_min_open_fs);
744static struct file_operations acpi_pcc_brightness_fops =
745 SEQ_FILEOPS_RW(acpi_pcc_brightness_open_fs,
746 acpi_pcc_write_no_brightness);
747static struct file_operations acpi_pcc_sticky_key_fops =
748 SEQ_FILEOPS_RW(acpi_pcc_sticky_key_open_fs, acpi_pcc_write_sticky_key);
749static struct file_operations acpi_pcc_keyinput_fops =
750 SEQ_FILEOPS_RW(acpi_pcc_keyinput_open_fs, acpi_pcc_write_keyinput);
751static struct file_operations acpi_pcc_version_fops =
752 SEQ_FILEOPS_R(acpi_pcc_version_open_fs);
753
754struct proc_item {
755 const char *name;
715 struct file_operations *fops; 756 struct file_operations *fops;
716 mode_t flag; 757 mode_t flag;
717} ProcItem; 758};
718 759
719/* Note: These functions map *exactly* to the SINF/SSET functions */ 760/* Note: These functions map *exactly* to the SINF/SSET functions */
720ProcItem acpi_pcc_proc_items_sifr[] = { 761struct proc_item acpi_pcc_proc_items_sifr[] = {
721 { "num_batteries", &acpi_pcc_numbatteries_fops, S_IRUGO }, 762 { "num_batteries", &acpi_pcc_numbatteries_fops, S_IRUGO },
722 { "lcd_type", &acpi_pcc_lcdtype_fops, S_IRUGO }, 763 { "lcd_type", &acpi_pcc_lcdtype_fops, S_IRUGO },
723 { "ac_brightness_max" , &acpi_pcc_ac_brightness_max_fops,S_IRUGO }, 764 { "ac_brightness_max", &acpi_pcc_ac_brightness_max_fops, S_IRUGO },
724 { "ac_brightness_min" , &acpi_pcc_ac_brightness_min_fops,S_IRUGO }, 765 { "ac_brightness_min", &acpi_pcc_ac_brightness_min_fops, S_IRUGO },
725 { "ac_brightness" , &acpi_pcc_ac_brightness_fops, S_IFREG | S_IRUGO | S_IWUSR }, 766 { "ac_brightness", &acpi_pcc_ac_brightness_fops,
726 { "dc_brightness_max" , &acpi_pcc_dc_brightness_max_fops,S_IRUGO }, 767 S_IFREG | S_IRUGO | S_IWUSR },
727 { "dc_brightness_min" , &acpi_pcc_dc_brightness_min_fops,S_IRUGO }, 768 { "dc_brightness_max", &acpi_pcc_dc_brightness_max_fops, S_IRUGO },
728 { "dc_brightness" , &acpi_pcc_dc_brightness_fops, S_IFREG | S_IRUGO | S_IWUSR }, 769 { "dc_brightness_min", &acpi_pcc_dc_brightness_min_fops, S_IRUGO },
729 { "brightness" , &acpi_pcc_brightness_fops, S_IFREG | S_IRUGO | S_IWUSR }, 770 { "dc_brightness", &acpi_pcc_dc_brightness_fops,
730 { "mute", &acpi_pcc_mute_fops, S_IFREG | S_IRUGO | S_IWUSR }, 771 S_IFREG | S_IRUGO | S_IWUSR },
772 { "brightness", &acpi_pcc_brightness_fops, S_IFREG | S_IRUGO | S_IWUSR},
773 { "mute", &acpi_pcc_mute_fops, S_IFREG | S_IRUGO | S_IWUSR },
731 { NULL, NULL, 0 }, 774 { NULL, NULL, 0 },
732}; 775};
733 776
734ProcItem acpi_pcc_proc_items[] = { 777struct proc_item acpi_pcc_proc_items[] = {
735 { "sticky_key", &acpi_pcc_sticky_key_fops, S_IFREG | S_IRUGO | S_IWUSR }, 778 { "sticky_key", &acpi_pcc_sticky_key_fops, S_IFREG | S_IRUGO | S_IWUSR},
736 { "keyinput", &acpi_pcc_keyinput_fops, S_IFREG | S_IRUGO | S_IWUSR }, 779 { "keyinput", &acpi_pcc_keyinput_fops, S_IFREG | S_IRUGO | S_IWUSR },
737 { "version", &acpi_pcc_version_fops, S_IRUGO }, 780 { "version", &acpi_pcc_version_fops, S_IRUGO },
738 { NULL, NULL, 0 }, 781 { NULL, NULL, 0 },
739}; 782};
740 783
741static int __devinit acpi_pcc_add_device(struct acpi_device *device, 784static int __devinit acpi_pcc_add_device(struct acpi_device *device,
742 ProcItem *proc_items, 785 struct proc_item *proc_items,
743 int num) 786 int num)
744{ 787{
745 struct acpi_hotkey *hotkey = (struct acpi_hotkey*)acpi_driver_data(device); 788 struct acpi_hotkey *hotkey = acpi_driver_data(device);
746 struct proc_dir_entry* proc; 789 struct proc_dir_entry *proc;
747 ProcItem* item; 790 struct proc_item *item;
748 int i; 791 int i;
749 792
750 for (item = proc_items, i = 0; item->name && i < num; ++item, ++i) { 793 for (item = proc_items, i = 0; item->name && i < num; ++item, ++i) {
751 proc = create_proc_entry(item->name, item->flag, hotkey->proc_dir_entry); 794 proc = create_proc_entry(item->name, item->flag,
795 hotkey->proc_dir_entry);
752 if (likely(proc)) { 796 if (likely(proc)) {
753 proc->proc_fops = item->fops; 797 proc->proc_fops = item->fops;
754 proc->data = hotkey; 798 proc->data = hotkey;
@@ -756,7 +800,8 @@ static int __devinit acpi_pcc_add_device(struct acpi_device *device,
756 } else { 800 } else {
757 while (i-- > 0) { 801 while (i-- > 0) {
758 item--; 802 item--;
759 remove_proc_entry(item->name, hotkey->proc_dir_entry); 803 remove_proc_entry(item->name,
804 hotkey->proc_dir_entry);
760 } 805 }
761 return_VALUE(-ENODEV); 806 return_VALUE(-ENODEV);
762 } 807 }
@@ -767,7 +812,7 @@ static int __devinit acpi_pcc_add_device(struct acpi_device *device,
767static int __devinit acpi_pcc_proc_init(struct acpi_device *device) 812static int __devinit acpi_pcc_proc_init(struct acpi_device *device)
768{ 813{
769 struct proc_dir_entry *acpi_pcc_dir; 814 struct proc_dir_entry *acpi_pcc_dir;
770 struct acpi_hotkey *hotkey = (struct acpi_hotkey*)acpi_driver_data(device); 815 struct acpi_hotkey *hotkey = acpi_driver_data(device);
771 acpi_status status; 816 acpi_status status;
772 817
773 ACPI_FUNCTION_TRACE("acpi_pcc_proc_init"); 818 ACPI_FUNCTION_TRACE("acpi_pcc_proc_init");
@@ -775,15 +820,18 @@ static int __devinit acpi_pcc_proc_init(struct acpi_device *device)
775 acpi_pcc_dir = proc_mkdir(PROC_PCC, acpi_root_dir); 820 acpi_pcc_dir = proc_mkdir(PROC_PCC, acpi_root_dir);
776 821
777 if (unlikely(!acpi_pcc_dir)) { 822 if (unlikely(!acpi_pcc_dir)) {
778 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't create dir in /proc\n")); 823 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
824 "Couldn't create dir in /proc\n"));
779 return_VALUE(-ENODEV); 825 return_VALUE(-ENODEV);
780 } 826 }
781 827
782 acpi_pcc_dir->owner = THIS_MODULE; 828 acpi_pcc_dir->owner = THIS_MODULE;
783 hotkey->proc_dir_entry = acpi_pcc_dir; 829 hotkey->proc_dir_entry = acpi_pcc_dir;
784 830
785 status = acpi_pcc_add_device(device, acpi_pcc_proc_items_sifr, hotkey->num_sifr); 831 status = acpi_pcc_add_device(device, acpi_pcc_proc_items_sifr,
786 status |= acpi_pcc_add_device(device, acpi_pcc_proc_items, ARRAY_SIZE(acpi_pcc_proc_items)); 832 hotkey->num_sifr);
833 status |= acpi_pcc_add_device(device, acpi_pcc_proc_items,
834 ARRAY_SIZE(acpi_pcc_proc_items));
787 if (unlikely(status)) { 835 if (unlikely(status)) {
788 remove_proc_entry(PROC_PCC, acpi_root_dir); 836 remove_proc_entry(PROC_PCC, acpi_root_dir);
789 hotkey->proc_dir_entry = NULL; 837 hotkey->proc_dir_entry = NULL;
@@ -794,14 +842,16 @@ static int __devinit acpi_pcc_proc_init(struct acpi_device *device)
794} 842}
795 843
796static void __devexit acpi_pcc_remove_device(struct acpi_device *device, 844static void __devexit acpi_pcc_remove_device(struct acpi_device *device,
797 ProcItem *proc_items, 845 struct proc_item *proc_items,
798 int num) 846 int num)
799{ 847{
800 struct acpi_hotkey *hotkey = (struct acpi_hotkey*)acpi_driver_data(device); 848 struct acpi_hotkey *hotkey = acpi_driver_data(device);
801 ProcItem* item; 849 struct proc_item *item;
802 int i; 850 int i;
803 851
804 for (item = proc_items, i = 0; item->name != NULL && i < num; ++item, ++i) { 852 for (item = proc_items, i = 0;
853 item->name != NULL && i < num;
854 ++item, ++i) {
805 remove_proc_entry(item->name, hotkey->proc_dir_entry); 855 remove_proc_entry(item->name, hotkey->proc_dir_entry);
806 } 856 }
807 857
@@ -819,14 +869,18 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
819 869
820 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_resume"); 870 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_resume");
821 871
822 if (device == NULL || hotkey == NULL) { return_VALUE(-EINVAL); } 872 if (device == NULL || hotkey == NULL)
873 return_VALUE(-EINVAL);
823 874
824 if (hotkey->num_sifr != 0) { 875 if (hotkey->num_sifr != 0) {
825 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Sticky mode restore: %d\n", hotkey->sticky_mode)); 876 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Sticky mode restore: %d\n",
877 hotkey->sticky_mode));
826 878
827 status = acpi_pcc_write_sset(hotkey, SINF_STICKY_KEY, hotkey->sticky_mode); 879 status = acpi_pcc_write_sset(hotkey, SINF_STICKY_KEY,
880 hotkey->sticky_mode);
828 } 881 }
829 if (status != AE_OK) { return_VALUE(-EINVAL); } 882 if (status != AE_OK)
883 return_VALUE(-EINVAL);
830 884
831 return_VALUE(0); 885 return_VALUE(0);
832} 886}
@@ -848,14 +902,16 @@ static int __devinit acpi_pcc_init_input(struct acpi_hotkey *hotkey)
848 902
849 hotk_input_dev = input_allocate_device(); 903 hotk_input_dev = input_allocate_device();
850 if (hotk_input_dev == NULL) { 904 if (hotk_input_dev == NULL) {
851 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate input device for hotkey")); 905 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
906 "Couldn't allocate input device for hotkey"));
852 goto err_input; 907 goto err_input;
853 } 908 }
854 909
855 pcc_keyinput = kcalloc(1, sizeof(struct pcc_keyinput), GFP_KERNEL); 910 pcc_keyinput = kcalloc(1, sizeof(struct pcc_keyinput), GFP_KERNEL);
856 911
857 if (pcc_keyinput == NULL) { 912 if (pcc_keyinput == NULL) {
858 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate mem for private data")); 913 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
914 "Couldn't allocate mem for private data"));
859 goto err_pcc; 915 goto err_pcc;
860 } 916 }
861 917
@@ -886,9 +942,8 @@ static int __devinit acpi_pcc_init_input(struct acpi_hotkey *hotkey)
886 942
887 error = input_register_device(hotk_input_dev); 943 error = input_register_device(hotk_input_dev);
888 944
889 if (error) { 945 if (error)
890 goto err_pcc; 946 goto err_pcc;
891 }
892 947
893 return_VALUE(0); 948 return_VALUE(0);
894 949
@@ -921,7 +976,7 @@ static void __devexit acpi_pcc_remove_input(struct acpi_hotkey *hotkey)
921/* ------------------------------------------------------------------------- 976/* -------------------------------------------------------------------------
922 ACPI 977 ACPI
923 ------------------------------------------------------------------------- */ 978 ------------------------------------------------------------------------- */
924static int __devinit acpi_pcc_hotkey_add (struct acpi_device *device) 979static int __devinit acpi_pcc_hotkey_add(struct acpi_device *device)
925{ 980{
926 acpi_status status = AE_OK; 981 acpi_status status = AE_OK;
927 struct acpi_hotkey *hotkey = NULL; 982 struct acpi_hotkey *hotkey = NULL;
@@ -929,9 +984,8 @@ static int __devinit acpi_pcc_hotkey_add (struct acpi_device *device)
929 984
930 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_add"); 985 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_add");
931 986
932 if (device == NULL) { 987 if (device == NULL)
933 return_VALUE(-EINVAL); 988 return_VALUE(-EINVAL);
934 }
935 989
936 sifr_status = acpi_pcc_get_sqty(device); 990 sifr_status = acpi_pcc_get_sqty(device);
937 991
@@ -949,7 +1003,8 @@ static int __devinit acpi_pcc_hotkey_add (struct acpi_device *device)
949 1003
950 hotkey = kcalloc(1, sizeof(struct acpi_hotkey), GFP_KERNEL); 1004 hotkey = kcalloc(1, sizeof(struct acpi_hotkey), GFP_KERNEL);
951 if (hotkey == NULL) { 1005 if (hotkey == NULL) {
952 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate mem for hotkey")); 1006 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1007 "Couldn't allocate mem for hotkey"));
953 return_VALUE(-ENOMEM); 1008 return_VALUE(-ENOMEM);
954 } 1009 }
955 1010
@@ -966,14 +1021,16 @@ static int __devinit acpi_pcc_hotkey_add (struct acpi_device *device)
966 hotkey); 1021 hotkey);
967 1022
968 if (ACPI_FAILURE(status)) { 1023 if (ACPI_FAILURE(status)) {
969 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing notify handler\n")); 1024 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1025 "Error installing notify handler\n"));
970 kfree(hotkey); 1026 kfree(hotkey);
971 return_VALUE(-ENODEV); 1027 return_VALUE(-ENODEV);
972 } 1028 }
973 1029
974 result = acpi_pcc_init_input(hotkey); 1030 result = acpi_pcc_init_input(hotkey);
975 if (result != 0) { 1031 if (result != 0) {
976 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing keyinput handler\n")); 1032 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1033 "Error installing keyinput handler\n"));
977 kfree(hotkey); 1034 kfree(hotkey);
978 return_VALUE(result); 1035 return_VALUE(result);
979 } 1036 }
@@ -981,20 +1038,22 @@ static int __devinit acpi_pcc_hotkey_add (struct acpi_device *device)
981 return_VALUE(acpi_pcc_proc_init(device)); 1038 return_VALUE(acpi_pcc_proc_init(device));
982} 1039}
983 1040
984static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device, int type) 1041static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device,
1042 int type)
985{ 1043{
986 acpi_status status = AE_OK; 1044 acpi_status status = AE_OK;
987 struct acpi_hotkey *hotkey = acpi_driver_data(device); 1045 struct acpi_hotkey *hotkey = acpi_driver_data(device);
988 1046
989 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_remove"); 1047 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_remove");
990 1048
991 if (!device || !hotkey) { 1049 if (!device || !hotkey)
992 return_VALUE(-EINVAL); 1050 return_VALUE(-EINVAL);
993 }
994 1051
995 if (hotkey->proc_dir_entry) { 1052 if (hotkey->proc_dir_entry) {
996 acpi_pcc_remove_device(device, acpi_pcc_proc_items_sifr, hotkey->num_sifr); 1053 acpi_pcc_remove_device(device, acpi_pcc_proc_items_sifr,
997 acpi_pcc_remove_device(device, acpi_pcc_proc_items, ARRAY_SIZE(acpi_pcc_proc_items)); 1054 hotkey->num_sifr);
1055 acpi_pcc_remove_device(device, acpi_pcc_proc_items,
1056 ARRAY_SIZE(acpi_pcc_proc_items));
998 remove_proc_entry(PROC_PCC, acpi_root_dir); 1057 remove_proc_entry(PROC_PCC, acpi_root_dir);
999 } 1058 }
1000 1059
@@ -1002,13 +1061,12 @@ static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device, int type
1002 ACPI_DEVICE_NOTIFY, acpi_pcc_hotkey_notify); 1061 ACPI_DEVICE_NOTIFY, acpi_pcc_hotkey_notify);
1003 1062
1004 if (ACPI_FAILURE(status)) { 1063 if (ACPI_FAILURE(status)) {
1005 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); 1064 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1065 "Error removing notify handler\n"));
1006 } 1066 }
1007 1067
1008 acpi_pcc_remove_input(hotkey); 1068 acpi_pcc_remove_input(hotkey);
1009 if (hotkey != NULL) { 1069 kfree(hotkey);
1010 kfree(hotkey);
1011 }
1012 return_VALUE(status == AE_OK); 1070 return_VALUE(status == AE_OK);
1013} 1071}
1014 1072
@@ -1030,7 +1088,8 @@ static int __init acpi_pcc_init(void)
1030 1088
1031 result = acpi_bus_register_driver(&acpi_pcc_driver); 1089 result = acpi_bus_register_driver(&acpi_pcc_driver);
1032 if (result < 0) { 1090 if (result < 0) {
1033 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering hotkey driver\n")); 1091 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1092 "Error registering hotkey driver\n"));
1034 return_VALUE(-ENODEV); 1093 return_VALUE(-ENODEV);
1035 } 1094 }
1036 1095