aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Achirica <jachirica@gmail.com>2014-03-20 19:01:14 -0400
committerMatthew Garrett <matthew.garrett@nebula.com>2014-04-06 12:58:12 -0400
commit9e04c9080dfadd9bc254ffaa738f39e4796d0ab7 (patch)
treef9bdfb1a9474c91aee872eb34730573458ce475e
parent353120760599c565e2d0a4174a0f3faeeb2e56ae (diff)
sony-laptop: add panel_id function
Signed-off-by: Javier Achirica <jachirica@gmail.com> Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
-rw-r--r--drivers/platform/x86/sony-laptop.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index de173909257a..d1f712e368ce 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void);
164static int sony_nc_highspeed_charging_setup(struct platform_device *pd); 164static int sony_nc_highspeed_charging_setup(struct platform_device *pd);
165static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd); 165static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd);
166 166
167static int sony_nc_panelid_setup(struct platform_device *pd);
168static void sony_nc_panelid_cleanup(struct platform_device *pd);
169
167static int sony_nc_touchpad_setup(struct platform_device *pd, 170static int sony_nc_touchpad_setup(struct platform_device *pd,
168 unsigned int handle); 171 unsigned int handle);
169static void sony_nc_touchpad_cleanup(struct platform_device *pd); 172static void sony_nc_touchpad_cleanup(struct platform_device *pd);
@@ -1385,6 +1388,12 @@ static void sony_nc_function_setup(struct acpi_device *device,
1385 pr_err("couldn't set up keyboard backlight function (%d)\n", 1388 pr_err("couldn't set up keyboard backlight function (%d)\n",
1386 result); 1389 result);
1387 break; 1390 break;
1391 case 0x011D:
1392 result = sony_nc_panelid_setup(pf_device);
1393 if (result)
1394 pr_err("couldn't set up panel ID function (%d)\n",
1395 result);
1396 break;
1388 default: 1397 default:
1389 continue; 1398 continue;
1390 } 1399 }
@@ -1449,6 +1458,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
1449 case 0x0163: 1458 case 0x0163:
1450 sony_nc_kbd_backlight_cleanup(pd, handle); 1459 sony_nc_kbd_backlight_cleanup(pd, handle);
1451 break; 1460 break;
1461 case 0x011D:
1462 sony_nc_panelid_cleanup(pd);
1463 break;
1452 default: 1464 default:
1453 continue; 1465 continue;
1454 } 1466 }
@@ -2540,6 +2552,53 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
2540 } 2552 }
2541} 2553}
2542 2554
2555/* Panel ID function */
2556static struct device_attribute *panel_handle;
2557
2558static ssize_t sony_nc_panelid_show(struct device *dev,
2559 struct device_attribute *attr, char *buffer)
2560{
2561 unsigned int result;
2562
2563 if (sony_call_snc_handle(0x011D, 0x0000, &result))
2564 return -EIO;
2565
2566 return snprintf(buffer, PAGE_SIZE, "%d\n", result);
2567}
2568
2569static int sony_nc_panelid_setup(struct platform_device *pd)
2570{
2571 unsigned int result;
2572
2573 panel_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2574 if (!panel_handle)
2575 return -ENOMEM;
2576
2577 sysfs_attr_init(&panel_handle->attr);
2578 panel_handle->attr.name = "panel_id";
2579 panel_handle->attr.mode = S_IRUGO;
2580 panel_handle->show = sony_nc_panelid_show;
2581 panel_handle->store = NULL;
2582
2583 result = device_create_file(&pd->dev, panel_handle);
2584 if (result) {
2585 kfree(panel_handle);
2586 panel_handle = NULL;
2587 return result;
2588 }
2589
2590 return 0;
2591}
2592
2593static void sony_nc_panelid_cleanup(struct platform_device *pd)
2594{
2595 if (panel_handle) {
2596 device_remove_file(&pd->dev, panel_handle);
2597 kfree(panel_handle);
2598 panel_handle = NULL;
2599 }
2600}
2601
2543/* Touchpad enable/disable */ 2602/* Touchpad enable/disable */
2544struct touchpad_control { 2603struct touchpad_control {
2545 struct device_attribute attr; 2604 struct device_attribute attr;