Commit e22388e7 authored by Lee, Chun-Yi's avatar Lee, Chun-Yi Committed by Greg Kroah-Hartman
Browse files

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: default avatarLee, Chun-Yi <jlee@novell.com>
Cc: Lennart Poettering <mzxreary@0pointer.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ec766278
...@@ -79,6 +79,8 @@ ...@@ -79,6 +79,8 @@
static int msi_laptop_resume(struct platform_device *device); static int msi_laptop_resume(struct platform_device *device);
#define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS 0x2f
static int force; static int force;
module_param(force, bool, 0); module_param(force, bool, 0);
MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); 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,6 +91,7 @@ MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disab
static bool old_ec_model; static bool old_ec_model;
static int wlan_s, bluetooth_s, threeg_s; static int wlan_s, bluetooth_s, threeg_s;
static int threeg_exists;
/* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G, /* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G,
* those netbook will load the SCM (windows app) to disable the original * 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,6 +227,20 @@ static int get_wireless_state_ec_standard(void)
return 0; return 0;
} }
static int get_threeg_exists(void)
{
u8 rdata;
int result;
result = ec_read(MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS, &rdata);
if (result < 0)
return -1;
threeg_exists = !!(rdata & MSI_STANDARD_EC_3G_MASK);
return 0;
}
/* Backlight device stuff */ /* Backlight device stuff */
static int bl_get_brightness(struct backlight_device *b) static int bl_get_brightness(struct backlight_device *b)
...@@ -561,8 +578,9 @@ static int rfkill_init(struct platform_device *sdev) ...@@ -561,8 +578,9 @@ static int rfkill_init(struct platform_device *sdev)
if (retval) if (retval)
goto err_wlan; goto err_wlan;
rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev, RFKILL_TYPE_WWAN, if (threeg_exists) {
&rfkill_threeg_ops, NULL); rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev,
RFKILL_TYPE_WWAN, &rfkill_threeg_ops, NULL);
if (!rfk_threeg) { if (!rfk_threeg) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_threeg; goto err_threeg;
...@@ -570,6 +588,7 @@ static int rfkill_init(struct platform_device *sdev) ...@@ -570,6 +588,7 @@ static int rfkill_init(struct platform_device *sdev)
retval = rfkill_register(rfk_threeg); retval = rfkill_register(rfk_threeg);
if (retval) if (retval)
goto err_threeg; goto err_threeg;
}
return 0; return 0;
...@@ -649,6 +668,9 @@ static int __init msi_init(void) ...@@ -649,6 +668,9 @@ static int __init msi_init(void)
if (force || dmi_check_system(msi_dmi_table)) if (force || dmi_check_system(msi_dmi_table))
old_ec_model = 1; old_ec_model = 1;
if (!old_ec_model)
get_threeg_exists();
if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table)) if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table))
load_scm_model = 1; load_scm_model = 1;
...@@ -694,7 +716,9 @@ static int __init msi_init(void) ...@@ -694,7 +716,9 @@ static int __init msi_init(void)
goto fail_platform_device2; goto fail_platform_device2;
if (!old_ec_model) { if (!old_ec_model) {
ret = device_create_file(&msipf_device->dev, &dev_attr_threeg); if (threeg_exists)
ret = device_create_file(&msipf_device->dev,
&dev_attr_threeg);
if (ret) if (ret)
goto fail_platform_device2; goto fail_platform_device2;
} }
...@@ -733,7 +757,7 @@ static void __exit msi_cleanup(void) ...@@ -733,7 +757,7 @@ static void __exit msi_cleanup(void)
{ {
sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
if (!old_ec_model) if (!old_ec_model && threeg_exists)
device_remove_file(&msipf_device->dev, &dev_attr_threeg); device_remove_file(&msipf_device->dev, &dev_attr_threeg);
platform_device_unregister(msipf_device); platform_device_unregister(msipf_device);
platform_driver_unregister(&msipf_driver); platform_driver_unregister(&msipf_driver);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment