Skip to contentSkip to conversation

thinkpad_acpi: Make ThinkLight work with suspend / resume

PATCH New Simon Danner 1 participant 1 message Jan 2, 2013 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thinkpad_acpi: Make ThinkLight work with suspend / resume

The status of the ThinkLight was not restored on resume, make it work

---
 drivers/platform/x86/thinkpad_acpi.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +29 -0
index 75dd651..c046909 100644
@@ -4762,6 +4762,8 @@ static struct ibm_struct video_driver_data = {
  * Light (thinklight) subdriver
  */
 
+static int light_resume_status;
+
 TPACPI_HANDLE(lght, root, "\\LGHT");	/* A21e, A2xm/p, T20-22, X20-21 */
 TPACPI_HANDLE(ledb, ec, "LEDB");		/* G4x */
 
@@ -4921,11 +4923,38 @@ static int light_write(char *buf)
 	return light_set_status(newstatus);
 }
 
+static void light_suspend(void)
+{
+	if (!tp_features.light || !tp_features.light_status)
+		return;
+
+	light_resume_status = light_get_status();
+
+	if (light_resume_status < 0)
+		pr_notice("failed to read light status for later restore"
+				"during resume: %d\n", light_resume_status);
+}
+
+static void light_resume(void)
+{
+	int rc;
+
+	if (!tp_features.light || !tp_features.light_status)
+		return;
+
+	rc = light_set_status(light_resume_status);
+	if (rc < 0)
+		pr_notice("failed to restore light status: %d\n", rc);
+
+}
+
 static struct ibm_struct light_driver_data = {
 	.name = "light",
 	.read = light_read,
 	.write = light_write,
 	.exit = light_exit,
+	.suspend = light_suspend,
+	.resume = light_resume,
 };
 
 /*************************************************************************
Signature · 1 line
1.8.0.2