aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/msi-laptop.c
diff options
context:
space:
mode:
authorLee, Chun-Yi <jlee@novell.com>2010-01-26 23:23:00 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:53 -0500
commite22388e71b8787b26dc33d023e5c1eec58865541 (patch)
tree6c1e9a43b19d5a6f74fb47f1f4c3218fed08ae79 /drivers/platform/x86/msi-laptop.c
parentec766278ba927f3d3c75211ea7697aae37f327f0 (diff)
msi-laptop: Detect 3G device exists by standard ec command
Detect 3G device exists by standard ec command. Driver will not create the threeg sysfs file and threeg rfkill interface if there have no internal 3G device in MSI notebook/netbook. Signed-off-by: Lee, Chun-Yi <jlee@novell.com> Cc: Lennart Poettering <mzxreary@0pointer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/platform/x86/msi-laptop.c')
-rw-r--r--drivers/platform/x86/msi-laptop.c44
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
80static int msi_laptop_resume(struct platform_device *device); 80static int msi_laptop_resume(struct platform_device *device);
81 81
82#define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS 0x2f
83
82static int force; 84static int force;
83module_param(force, bool, 0); 85module_param(force, bool, 0);
84MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); 86MODULE_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
90static bool old_ec_model; 92static bool old_ec_model;
91static int wlan_s, bluetooth_s, threeg_s; 93static int wlan_s, bluetooth_s, threeg_s;
94static 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
230static 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
229static int bl_get_brightness(struct backlight_device *b) 246static 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);