diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/msi-laptop.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c index af1b62f76117..c2b05da4289a 100644 --- a/drivers/platform/x86/msi-laptop.c +++ b/drivers/platform/x86/msi-laptop.c | |||
@@ -79,6 +79,8 @@ | |||
79 | 79 | ||
80 | static int msi_laptop_resume(struct platform_device *device); | 80 | static int msi_laptop_resume(struct platform_device *device); |
81 | 81 | ||
82 | #define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS 0x2f | ||
83 | |||
82 | static int force; | 84 | static int force; |
83 | module_param(force, bool, 0); | 85 | module_param(force, bool, 0); |
84 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); | 86 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); |
@@ -89,6 +91,7 @@ MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disab | |||
89 | 91 | ||
90 | static bool old_ec_model; | 92 | static bool old_ec_model; |
91 | static int wlan_s, bluetooth_s, threeg_s; | 93 | static int wlan_s, bluetooth_s, threeg_s; |
94 | static int threeg_exists; | ||
92 | 95 | ||
93 | /* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G, | 96 | /* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G, |
94 | * those netbook will load the SCM (windows app) to disable the original | 97 | * those netbook will load the SCM (windows app) to disable the original |
@@ -224,6 +227,20 @@ static int get_wireless_state_ec_standard(void) | |||
224 | return 0; | 227 | return 0; |
225 | } | 228 | } |
226 | 229 | ||
230 | static int get_threeg_exists(void) | ||
231 | { | ||
232 | u8 rdata; | ||
233 | int result; | ||
234 | |||
235 | result = ec_read(MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS, &rdata); | ||
236 | if (result < 0) | ||
237 | return -1; | ||
238 | |||
239 | threeg_exists = !!(rdata & MSI_STANDARD_EC_3G_MASK); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
227 | /* Backlight device stuff */ | 244 | /* Backlight device stuff */ |
228 | 245 | ||
229 | static int bl_get_brightness(struct backlight_device *b) | 246 | static int bl_get_brightness(struct backlight_device *b) |
@@ -561,15 +578,17 @@ static int rfkill_init(struct platform_device *sdev) | |||
561 | if (retval) | 578 | if (retval) |
562 | goto err_wlan; | 579 | goto err_wlan; |
563 | 580 | ||
564 | rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev, RFKILL_TYPE_WWAN, | 581 | if (threeg_exists) { |
565 | &rfkill_threeg_ops, NULL); | 582 | rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev, |
566 | if (!rfk_threeg) { | 583 | RFKILL_TYPE_WWAN, &rfkill_threeg_ops, NULL); |
567 | retval = -ENOMEM; | 584 | if (!rfk_threeg) { |
568 | goto err_threeg; | 585 | retval = -ENOMEM; |
586 | goto err_threeg; | ||
587 | } | ||
588 | retval = rfkill_register(rfk_threeg); | ||
589 | if (retval) | ||
590 | goto err_threeg; | ||
569 | } | 591 | } |
570 | retval = rfkill_register(rfk_threeg); | ||
571 | if (retval) | ||
572 | goto err_threeg; | ||
573 | 592 | ||
574 | return 0; | 593 | return 0; |
575 | 594 | ||
@@ -649,6 +668,9 @@ static int __init msi_init(void) | |||
649 | if (force || dmi_check_system(msi_dmi_table)) | 668 | if (force || dmi_check_system(msi_dmi_table)) |
650 | old_ec_model = 1; | 669 | old_ec_model = 1; |
651 | 670 | ||
671 | if (!old_ec_model) | ||
672 | get_threeg_exists(); | ||
673 | |||
652 | if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table)) | 674 | if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table)) |
653 | load_scm_model = 1; | 675 | load_scm_model = 1; |
654 | 676 | ||
@@ -694,7 +716,9 @@ static int __init msi_init(void) | |||
694 | goto fail_platform_device2; | 716 | goto fail_platform_device2; |
695 | 717 | ||
696 | if (!old_ec_model) { | 718 | if (!old_ec_model) { |
697 | ret = device_create_file(&msipf_device->dev, &dev_attr_threeg); | 719 | if (threeg_exists) |
720 | ret = device_create_file(&msipf_device->dev, | ||
721 | &dev_attr_threeg); | ||
698 | if (ret) | 722 | if (ret) |
699 | goto fail_platform_device2; | 723 | goto fail_platform_device2; |
700 | } | 724 | } |
@@ -733,7 +757,7 @@ static void __exit msi_cleanup(void) | |||
733 | { | 757 | { |
734 | 758 | ||
735 | sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); | 759 | sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); |
736 | if (!old_ec_model) | 760 | if (!old_ec_model && threeg_exists) |
737 | device_remove_file(&msipf_device->dev, &dev_attr_threeg); | 761 | device_remove_file(&msipf_device->dev, &dev_attr_threeg); |
738 | platform_device_unregister(msipf_device); | 762 | platform_device_unregister(msipf_device); |
739 | platform_driver_unregister(&msipf_driver); | 763 | platform_driver_unregister(&msipf_driver); |