aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/panasonic-laptop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/panasonic-laptop.c')
-rw-r--r--drivers/platform/x86/panasonic-laptop.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index fe7cf0188acc..2fb9a32926f8 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -124,6 +124,7 @@
124#include <linux/ctype.h> 124#include <linux/ctype.h>
125#include <linux/seq_file.h> 125#include <linux/seq_file.h>
126#include <linux/uaccess.h> 126#include <linux/uaccess.h>
127#include <linux/slab.h>
127#include <acpi/acpi_bus.h> 128#include <acpi/acpi_bus.h>
128#include <acpi/acpi_drivers.h> 129#include <acpi/acpi_drivers.h>
129#include <linux/input.h> 130#include <linux/input.h>
@@ -200,7 +201,7 @@ static struct acpi_driver acpi_pcc_driver = {
200}; 201};
201 202
202#define KEYMAP_SIZE 11 203#define KEYMAP_SIZE 11
203static const int initial_keymap[KEYMAP_SIZE] = { 204static const unsigned int initial_keymap[KEYMAP_SIZE] = {
204 /* 0 */ KEY_RESERVED, 205 /* 0 */ KEY_RESERVED,
205 /* 1 */ KEY_BRIGHTNESSDOWN, 206 /* 1 */ KEY_BRIGHTNESSDOWN,
206 /* 2 */ KEY_BRIGHTNESSUP, 207 /* 2 */ KEY_BRIGHTNESSUP,
@@ -222,7 +223,7 @@ struct pcc_acpi {
222 struct acpi_device *device; 223 struct acpi_device *device;
223 struct input_dev *input_dev; 224 struct input_dev *input_dev;
224 struct backlight_device *backlight; 225 struct backlight_device *backlight;
225 int keymap[KEYMAP_SIZE]; 226 unsigned int keymap[KEYMAP_SIZE];
226}; 227};
227 228
228struct pcc_keyinput { 229struct pcc_keyinput {
@@ -352,7 +353,7 @@ static int bl_set_status(struct backlight_device *bd)
352 return acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, bright); 353 return acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, bright);
353} 354}
354 355
355static struct backlight_ops pcc_backlight_ops = { 356static const struct backlight_ops pcc_backlight_ops = {
356 .get_brightness = bl_get, 357 .get_brightness = bl_get,
357 .update_status = bl_set_status, 358 .update_status = bl_set_status,
358}; 359};
@@ -445,7 +446,8 @@ static struct attribute_group pcc_attr_group = {
445 446
446/* hotkey input device driver */ 447/* hotkey input device driver */
447 448
448static int pcc_getkeycode(struct input_dev *dev, int scancode, int *keycode) 449static int pcc_getkeycode(struct input_dev *dev,
450 unsigned int scancode, unsigned int *keycode)
449{ 451{
450 struct pcc_acpi *pcc = input_get_drvdata(dev); 452 struct pcc_acpi *pcc = input_get_drvdata(dev);
451 453
@@ -457,7 +459,7 @@ static int pcc_getkeycode(struct input_dev *dev, int scancode, int *keycode)
457 return 0; 459 return 0;
458} 460}
459 461
460static int keymap_get_by_keycode(struct pcc_acpi *pcc, int keycode) 462static int keymap_get_by_keycode(struct pcc_acpi *pcc, unsigned int keycode)
461{ 463{
462 int i; 464 int i;
463 465
@@ -469,7 +471,8 @@ static int keymap_get_by_keycode(struct pcc_acpi *pcc, int keycode)
469 return 0; 471 return 0;
470} 472}
471 473
472static int pcc_setkeycode(struct input_dev *dev, int scancode, int keycode) 474static int pcc_setkeycode(struct input_dev *dev,
475 unsigned int scancode, unsigned int keycode)
473{ 476{
474 struct pcc_acpi *pcc = input_get_drvdata(dev); 477 struct pcc_acpi *pcc = input_get_drvdata(dev);
475 int oldkeycode; 478 int oldkeycode;
@@ -477,9 +480,6 @@ static int pcc_setkeycode(struct input_dev *dev, int scancode, int keycode)
477 if (scancode >= ARRAY_SIZE(pcc->keymap)) 480 if (scancode >= ARRAY_SIZE(pcc->keymap))
478 return -EINVAL; 481 return -EINVAL;
479 482
480 if (keycode < 0 || keycode > KEY_MAX)
481 return -EINVAL;
482
483 oldkeycode = pcc->keymap[scancode]; 483 oldkeycode = pcc->keymap[scancode];
484 pcc->keymap[scancode] = keycode; 484 pcc->keymap[scancode] = keycode;
485 485
@@ -601,6 +601,7 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
601 601
602static int acpi_pcc_hotkey_add(struct acpi_device *device) 602static int acpi_pcc_hotkey_add(struct acpi_device *device)
603{ 603{
604 struct backlight_properties props;
604 struct pcc_acpi *pcc; 605 struct pcc_acpi *pcc;
605 int num_sifr, result; 606 int num_sifr, result;
606 607
@@ -638,24 +639,25 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
638 if (result) { 639 if (result) {
639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
640 "Error installing keyinput handler\n")); 641 "Error installing keyinput handler\n"));
641 goto out_sinf; 642 goto out_hotkey;
642 } 643 }
643 644
644 /* initialize backlight */
645 pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
646 &pcc_backlight_ops);
647 if (IS_ERR(pcc->backlight))
648 goto out_input;
649
650 if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) { 645 if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) {
651 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 646 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
652 "Couldn't retrieve BIOS data\n")); 647 "Couldn't retrieve BIOS data\n"));
653 goto out_backlight; 648 goto out_input;
649 }
650 /* initialize backlight */
651 memset(&props, 0, sizeof(struct backlight_properties));
652 props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
653 pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
654 &pcc_backlight_ops, &props);
655 if (IS_ERR(pcc->backlight)) {
656 result = PTR_ERR(pcc->backlight);
657 goto out_sinf;
654 } 658 }
655 659
656 /* read the initial brightness setting from the hardware */ 660 /* read the initial brightness setting from the hardware */
657 pcc->backlight->props.max_brightness =
658 pcc->sinf[SINF_AC_MAX_BRIGHT];
659 pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; 661 pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT];
660 662
661 /* read the initial sticky key mode from the hardware */ 663 /* read the initial sticky key mode from the hardware */
@@ -670,12 +672,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
670 672
671out_backlight: 673out_backlight:
672 backlight_device_unregister(pcc->backlight); 674 backlight_device_unregister(pcc->backlight);
675out_sinf:
676 kfree(pcc->sinf);
673out_input: 677out_input:
674 input_unregister_device(pcc->input_dev); 678 input_unregister_device(pcc->input_dev);
675 /* no need to input_free_device() since core input API refcount and 679 /* no need to input_free_device() since core input API refcount and
676 * free()s the device */ 680 * free()s the device */
677out_sinf:
678 kfree(pcc->sinf);
679out_hotkey: 681out_hotkey:
680 kfree(pcc); 682 kfree(pcc);
681 683