diff options
author | Ike Panhc <ike.pan@canonical.com> | 2011-06-30 07:50:40 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2011-08-05 14:45:42 -0400 |
commit | 3371f48167e04017125dd08cc1f70fa93d2f2e17 (patch) | |
tree | a45b029f0a64e44f2b731a6fba0954c0f9ce8ba5 /drivers | |
parent | 33009557bd9397c446a59e4cc91059a8e84c046b (diff) |
ideapad: define cfg bits and create sysfs node for cfg
Create /sys/devices/platform/ideapad/cfg for showing cfg value.
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/ideapad-laptop.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index bfdda33feb26..42b9ba7e903c 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c | |||
@@ -35,10 +35,15 @@ | |||
35 | 35 | ||
36 | #define IDEAPAD_RFKILL_DEV_NUM (3) | 36 | #define IDEAPAD_RFKILL_DEV_NUM (3) |
37 | 37 | ||
38 | #define CFG_BT_BIT (16) | ||
39 | #define CFG_3G_BIT (17) | ||
40 | #define CFG_WIFI_BIT (18) | ||
41 | |||
38 | struct ideapad_private { | 42 | struct ideapad_private { |
39 | struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; | 43 | struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; |
40 | struct platform_device *platform_device; | 44 | struct platform_device *platform_device; |
41 | struct input_dev *inputdev; | 45 | struct input_dev *inputdev; |
46 | unsigned long cfg; | ||
42 | }; | 47 | }; |
43 | 48 | ||
44 | static acpi_handle ideapad_handle; | 49 | static acpi_handle ideapad_handle; |
@@ -155,7 +160,7 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) | |||
155 | } | 160 | } |
156 | 161 | ||
157 | /* | 162 | /* |
158 | * camera power | 163 | * sysfs |
159 | */ | 164 | */ |
160 | static ssize_t show_ideapad_cam(struct device *dev, | 165 | static ssize_t show_ideapad_cam(struct device *dev, |
161 | struct device_attribute *attr, | 166 | struct device_attribute *attr, |
@@ -186,6 +191,27 @@ static ssize_t store_ideapad_cam(struct device *dev, | |||
186 | 191 | ||
187 | static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); | 192 | static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); |
188 | 193 | ||
194 | static ssize_t show_ideapad_cfg(struct device *dev, | ||
195 | struct device_attribute *attr, | ||
196 | char *buf) | ||
197 | { | ||
198 | struct ideapad_private *priv = dev_get_drvdata(dev); | ||
199 | |||
200 | return sprintf(buf, "0x%.8lX\n", priv->cfg); | ||
201 | } | ||
202 | |||
203 | static DEVICE_ATTR(cfg, 0444, show_ideapad_cfg, NULL); | ||
204 | |||
205 | static struct attribute *ideapad_attributes[] = { | ||
206 | &dev_attr_camera_power.attr, | ||
207 | &dev_attr_cfg.attr, | ||
208 | NULL | ||
209 | }; | ||
210 | |||
211 | static struct attribute_group ideapad_attribute_group = { | ||
212 | .attrs = ideapad_attributes | ||
213 | }; | ||
214 | |||
189 | /* | 215 | /* |
190 | * Rfkill | 216 | * Rfkill |
191 | */ | 217 | */ |
@@ -197,9 +223,9 @@ struct ideapad_rfk_data { | |||
197 | }; | 223 | }; |
198 | 224 | ||
199 | const struct ideapad_rfk_data ideapad_rfk_data[] = { | 225 | const struct ideapad_rfk_data ideapad_rfk_data[] = { |
200 | { "ideapad_wlan", 18, 0x15, RFKILL_TYPE_WLAN }, | 226 | { "ideapad_wlan", CFG_WIFI_BIT, 0x15, RFKILL_TYPE_WLAN }, |
201 | { "ideapad_bluetooth", 16, 0x17, RFKILL_TYPE_BLUETOOTH }, | 227 | { "ideapad_bluetooth", CFG_BT_BIT, 0x17, RFKILL_TYPE_BLUETOOTH }, |
202 | { "ideapad_3g", 17, 0x20, RFKILL_TYPE_WWAN }, | 228 | { "ideapad_3g", CFG_3G_BIT, 0x20, RFKILL_TYPE_WWAN }, |
203 | }; | 229 | }; |
204 | 230 | ||
205 | static int ideapad_rfk_set(void *data, bool blocked) | 231 | static int ideapad_rfk_set(void *data, bool blocked) |
@@ -280,15 +306,6 @@ static void __devexit ideapad_unregister_rfkill(struct acpi_device *adevice, | |||
280 | /* | 306 | /* |
281 | * Platform device | 307 | * Platform device |
282 | */ | 308 | */ |
283 | static struct attribute *ideapad_attributes[] = { | ||
284 | &dev_attr_camera_power.attr, | ||
285 | NULL | ||
286 | }; | ||
287 | |||
288 | static struct attribute_group ideapad_attribute_group = { | ||
289 | .attrs = ideapad_attributes | ||
290 | }; | ||
291 | |||
292 | static int __devinit ideapad_platform_init(struct ideapad_private *priv) | 309 | static int __devinit ideapad_platform_init(struct ideapad_private *priv) |
293 | { | 310 | { |
294 | int result; | 311 | int result; |
@@ -393,10 +410,11 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids); | |||
393 | 410 | ||
394 | static int __devinit ideapad_acpi_add(struct acpi_device *adevice) | 411 | static int __devinit ideapad_acpi_add(struct acpi_device *adevice) |
395 | { | 412 | { |
396 | int ret, i, cfg; | 413 | int ret, i; |
414 | unsigned long cfg; | ||
397 | struct ideapad_private *priv; | 415 | struct ideapad_private *priv; |
398 | 416 | ||
399 | if (read_method_int(adevice->handle, "_CFG", &cfg)) | 417 | if (read_method_int(adevice->handle, "_CFG", (int *)&cfg)) |
400 | return -ENODEV; | 418 | return -ENODEV; |
401 | 419 | ||
402 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 420 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
@@ -404,6 +422,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice) | |||
404 | return -ENOMEM; | 422 | return -ENOMEM; |
405 | dev_set_drvdata(&adevice->dev, priv); | 423 | dev_set_drvdata(&adevice->dev, priv); |
406 | ideapad_handle = adevice->handle; | 424 | ideapad_handle = adevice->handle; |
425 | priv->cfg = cfg; | ||
407 | 426 | ||
408 | ret = ideapad_platform_init(priv); | 427 | ret = ideapad_platform_init(priv); |
409 | if (ret) | 428 | if (ret) |
@@ -414,7 +433,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice) | |||
414 | goto input_failed; | 433 | goto input_failed; |
415 | 434 | ||
416 | for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { | 435 | for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { |
417 | if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg)) | 436 | if (test_bit(ideapad_rfk_data[i].cfgbit, &cfg)) |
418 | ideapad_register_rfkill(adevice, i); | 437 | ideapad_register_rfkill(adevice, i); |
419 | else | 438 | else |
420 | priv->rfk[i] = NULL; | 439 | priv->rfk[i] = NULL; |