diff options
Diffstat (limited to 'drivers/platform/x86/compal-laptop.c')
-rw-r--r-- | drivers/platform/x86/compal-laptop.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c index 097083cac413..8877b836d27c 100644 --- a/drivers/platform/x86/compal-laptop.c +++ b/drivers/platform/x86/compal-laptop.c | |||
@@ -68,6 +68,8 @@ | |||
68 | * only enabled on a JHL90 board until it is verified that they work on the | 68 | * only enabled on a JHL90 board until it is verified that they work on the |
69 | * other boards too. See the extra_features variable. */ | 69 | * other boards too. See the extra_features variable. */ |
70 | 70 | ||
71 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
72 | |||
71 | #include <linux/module.h> | 73 | #include <linux/module.h> |
72 | #include <linux/kernel.h> | 74 | #include <linux/kernel.h> |
73 | #include <linux/init.h> | 75 | #include <linux/init.h> |
@@ -200,8 +202,8 @@ static bool extra_features; | |||
200 | * watching the output of address 0x4F (do an ec_transaction writing 0x33 | 202 | * watching the output of address 0x4F (do an ec_transaction writing 0x33 |
201 | * into 0x4F and read a few bytes from the output, like so: | 203 | * into 0x4F and read a few bytes from the output, like so: |
202 | * u8 writeData = 0x33; | 204 | * u8 writeData = 0x33; |
203 | * ec_transaction(0x4F, &writeData, 1, buffer, 32, 0); | 205 | * ec_transaction(0x4F, &writeData, 1, buffer, 32); |
204 | * That address is labled "fan1 table information" in the service manual. | 206 | * That address is labeled "fan1 table information" in the service manual. |
205 | * It should be clear which value in 'buffer' changes). This seems to be | 207 | * It should be clear which value in 'buffer' changes). This seems to be |
206 | * related to fan speed. It isn't a proper 'realtime' fan speed value | 208 | * related to fan speed. It isn't a proper 'realtime' fan speed value |
207 | * though, because physically stopping or speeding up the fan doesn't | 209 | * though, because physically stopping or speeding up the fan doesn't |
@@ -275,7 +277,7 @@ static int set_backlight_level(int level) | |||
275 | 277 | ||
276 | ec_write(BACKLIGHT_LEVEL_ADDR, level); | 278 | ec_write(BACKLIGHT_LEVEL_ADDR, level); |
277 | 279 | ||
278 | return 1; | 280 | return 0; |
279 | } | 281 | } |
280 | 282 | ||
281 | static int get_backlight_level(void) | 283 | static int get_backlight_level(void) |
@@ -286,7 +288,7 @@ static int get_backlight_level(void) | |||
286 | static void set_backlight_state(bool on) | 288 | static void set_backlight_state(bool on) |
287 | { | 289 | { |
288 | u8 data = on ? BACKLIGHT_STATE_ON_DATA : BACKLIGHT_STATE_OFF_DATA; | 290 | u8 data = on ? BACKLIGHT_STATE_ON_DATA : BACKLIGHT_STATE_OFF_DATA; |
289 | ec_transaction(BACKLIGHT_STATE_ADDR, &data, 1, NULL, 0, 0); | 291 | ec_transaction(BACKLIGHT_STATE_ADDR, &data, 1, NULL, 0); |
290 | } | 292 | } |
291 | 293 | ||
292 | 294 | ||
@@ -294,24 +296,24 @@ static void set_backlight_state(bool on) | |||
294 | static void pwm_enable_control(void) | 296 | static void pwm_enable_control(void) |
295 | { | 297 | { |
296 | unsigned char writeData = PWM_ENABLE_DATA; | 298 | unsigned char writeData = PWM_ENABLE_DATA; |
297 | ec_transaction(PWM_ENABLE_ADDR, &writeData, 1, NULL, 0, 0); | 299 | ec_transaction(PWM_ENABLE_ADDR, &writeData, 1, NULL, 0); |
298 | } | 300 | } |
299 | 301 | ||
300 | static void pwm_disable_control(void) | 302 | static void pwm_disable_control(void) |
301 | { | 303 | { |
302 | unsigned char writeData = PWM_DISABLE_DATA; | 304 | unsigned char writeData = PWM_DISABLE_DATA; |
303 | ec_transaction(PWM_DISABLE_ADDR, &writeData, 1, NULL, 0, 0); | 305 | ec_transaction(PWM_DISABLE_ADDR, &writeData, 1, NULL, 0); |
304 | } | 306 | } |
305 | 307 | ||
306 | static void set_pwm(int pwm) | 308 | static void set_pwm(int pwm) |
307 | { | 309 | { |
308 | ec_transaction(PWM_ADDRESS, &pwm_lookup_table[pwm], 1, NULL, 0, 0); | 310 | ec_transaction(PWM_ADDRESS, &pwm_lookup_table[pwm], 1, NULL, 0); |
309 | } | 311 | } |
310 | 312 | ||
311 | static int get_fan_rpm(void) | 313 | static int get_fan_rpm(void) |
312 | { | 314 | { |
313 | u8 value, data = FAN_DATA; | 315 | u8 value, data = FAN_DATA; |
314 | ec_transaction(FAN_ADDRESS, &data, 1, &value, 1, 0); | 316 | ec_transaction(FAN_ADDRESS, &data, 1, &value, 1); |
315 | return 100 * (int)value; | 317 | return 100 * (int)value; |
316 | } | 318 | } |
317 | 319 | ||
@@ -760,19 +762,17 @@ static struct rfkill *bt_rfkill; | |||
760 | 762 | ||
761 | static int dmi_check_cb(const struct dmi_system_id *id) | 763 | static int dmi_check_cb(const struct dmi_system_id *id) |
762 | { | 764 | { |
763 | printk(KERN_INFO DRIVER_NAME": Identified laptop model '%s'\n", | 765 | pr_info("Identified laptop model '%s'\n", id->ident); |
764 | id->ident); | ||
765 | extra_features = false; | 766 | extra_features = false; |
766 | return 0; | 767 | return 1; |
767 | } | 768 | } |
768 | 769 | ||
769 | static int dmi_check_cb_extra(const struct dmi_system_id *id) | 770 | static int dmi_check_cb_extra(const struct dmi_system_id *id) |
770 | { | 771 | { |
771 | printk(KERN_INFO DRIVER_NAME": Identified laptop model '%s', " | 772 | pr_info("Identified laptop model '%s', enabling extra features\n", |
772 | "enabling extra features\n", | ||
773 | id->ident); | 773 | id->ident); |
774 | extra_features = true; | 774 | extra_features = true; |
775 | return 0; | 775 | return 1; |
776 | } | 776 | } |
777 | 777 | ||
778 | static struct dmi_system_id __initdata compal_dmi_table[] = { | 778 | static struct dmi_system_id __initdata compal_dmi_table[] = { |
@@ -872,6 +872,14 @@ static struct dmi_system_id __initdata compal_dmi_table[] = { | |||
872 | }, | 872 | }, |
873 | .callback = dmi_check_cb_extra | 873 | .callback = dmi_check_cb_extra |
874 | }, | 874 | }, |
875 | { | ||
876 | .ident = "KHLB2", | ||
877 | .matches = { | ||
878 | DMI_MATCH(DMI_BOARD_NAME, "KHLB2"), | ||
879 | DMI_MATCH(DMI_BOARD_VERSION, "REFERENCE"), | ||
880 | }, | ||
881 | .callback = dmi_check_cb_extra | ||
882 | }, | ||
875 | { } | 883 | { } |
876 | }; | 884 | }; |
877 | 885 | ||
@@ -948,20 +956,19 @@ static int __init compal_init(void) | |||
948 | int ret; | 956 | int ret; |
949 | 957 | ||
950 | if (acpi_disabled) { | 958 | if (acpi_disabled) { |
951 | printk(KERN_ERR DRIVER_NAME": ACPI needs to be enabled for " | 959 | pr_err("ACPI needs to be enabled for this driver to work!\n"); |
952 | "this driver to work!\n"); | ||
953 | return -ENODEV; | 960 | return -ENODEV; |
954 | } | 961 | } |
955 | 962 | ||
956 | if (!force && !dmi_check_system(compal_dmi_table)) { | 963 | if (!force && !dmi_check_system(compal_dmi_table)) { |
957 | printk(KERN_ERR DRIVER_NAME": Motherboard not recognized (You " | 964 | pr_err("Motherboard not recognized (You could try the module's force-parameter)\n"); |
958 | "could try the module's force-parameter)"); | ||
959 | return -ENODEV; | 965 | return -ENODEV; |
960 | } | 966 | } |
961 | 967 | ||
962 | if (!acpi_video_backlight_support()) { | 968 | if (!acpi_video_backlight_support()) { |
963 | struct backlight_properties props; | 969 | struct backlight_properties props; |
964 | memset(&props, 0, sizeof(struct backlight_properties)); | 970 | memset(&props, 0, sizeof(struct backlight_properties)); |
971 | props.type = BACKLIGHT_PLATFORM; | ||
965 | props.max_brightness = BACKLIGHT_LEVEL_MAX; | 972 | props.max_brightness = BACKLIGHT_LEVEL_MAX; |
966 | compalbl_device = backlight_device_register(DRIVER_NAME, | 973 | compalbl_device = backlight_device_register(DRIVER_NAME, |
967 | NULL, NULL, | 974 | NULL, NULL, |
@@ -989,8 +996,7 @@ static int __init compal_init(void) | |||
989 | if (ret) | 996 | if (ret) |
990 | goto err_rfkill; | 997 | goto err_rfkill; |
991 | 998 | ||
992 | printk(KERN_INFO DRIVER_NAME": Driver "DRIVER_VERSION | 999 | pr_info("Driver " DRIVER_VERSION " successfully loaded\n"); |
993 | " successfully loaded\n"); | ||
994 | return 0; | 1000 | return 0; |
995 | 1001 | ||
996 | err_rfkill: | 1002 | err_rfkill: |
@@ -1024,8 +1030,10 @@ static int __devinit compal_probe(struct platform_device *pdev) | |||
1024 | initialize_fan_control_data(data); | 1030 | initialize_fan_control_data(data); |
1025 | 1031 | ||
1026 | err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group); | 1032 | err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group); |
1027 | if (err) | 1033 | if (err) { |
1034 | kfree(data); | ||
1028 | return err; | 1035 | return err; |
1036 | } | ||
1029 | 1037 | ||
1030 | data->hwmon_dev = hwmon_device_register(&pdev->dev); | 1038 | data->hwmon_dev = hwmon_device_register(&pdev->dev); |
1031 | if (IS_ERR(data->hwmon_dev)) { | 1039 | if (IS_ERR(data->hwmon_dev)) { |
@@ -1055,7 +1063,7 @@ static void __exit compal_cleanup(void) | |||
1055 | rfkill_destroy(wifi_rfkill); | 1063 | rfkill_destroy(wifi_rfkill); |
1056 | rfkill_destroy(bt_rfkill); | 1064 | rfkill_destroy(bt_rfkill); |
1057 | 1065 | ||
1058 | printk(KERN_INFO DRIVER_NAME": Driver unloaded\n"); | 1066 | pr_info("Driver unloaded\n"); |
1059 | } | 1067 | } |
1060 | 1068 | ||
1061 | static int __devexit compal_remove(struct platform_device *pdev) | 1069 | static int __devexit compal_remove(struct platform_device *pdev) |
@@ -1065,8 +1073,7 @@ static int __devexit compal_remove(struct platform_device *pdev) | |||
1065 | if (!extra_features) | 1073 | if (!extra_features) |
1066 | return 0; | 1074 | return 0; |
1067 | 1075 | ||
1068 | printk(KERN_INFO DRIVER_NAME": Unloading: resetting fan control " | 1076 | pr_info("Unloading: resetting fan control to motherboard\n"); |
1069 | "to motherboard\n"); | ||
1070 | pwm_disable_control(); | 1077 | pwm_disable_control(); |
1071 | 1078 | ||
1072 | data = platform_get_drvdata(pdev); | 1079 | data = platform_get_drvdata(pdev); |