Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Apr 2007 19:49:53 +0200 (CEST)
From:      Henrik Brix Andersen <henrik@brixandersen.dk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Markus Brueffer <markus@FreeBSD.org>
Subject:   kern/112044: [acpi_ibm] [patch] Preserve the ThinkLight state on driver attach
Message-ID:  <20070423174953.91DA911432@lothlorien.brixandersen.dk>
Resent-Message-ID: <200704231750.l3NHo4mg024640@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         112044
>Category:       kern
>Synopsis:       [acpi_ibm] [patch] Preserve the ThinkLight state on driver attach
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 23 17:50:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Henrik Brix Andersen
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
pil.dk
>Environment:
System: FreeBSD lothlorien.brixandersen.dk 7.0-CURRENT FreeBSD 7.0-CURRENT #17: Mon Apr 23 19:19:08 CEST 2007 root@lothlorien.brixandersen.dk:/usr/obj/usr/src/sys/LOTHLORIEN i386


	
>Description:
The current implementation of acpi_ibm(4) unconditionally turns off
the ThinkLight on driver attach through the call to led_create() in
led(4).

	
>How-To-Repeat:
You need an IBM/Lenovo ThinkPad with a ThinkLight.

Unload the acpi_ibm(4) kernel module if already loaded and turn on the
ThinkLight using the Fn-key combination.

Load acpi_ibm(4) and notice the ThinkLight turns off.
	
>Fix:
The patch below uses the newly added led_create_state() function in
led(4) with the current state of the ThinkLight as argument (if
reading the ThinkLight status is supported on that given model).

User who wish to have the old behavior where the ThinkLight is
automatically turned off at boot can set dev.acpi_ibm.0.thinklight=0
in /etc/sysctl.conf.

This was tested on my ThinkPad X60s.

	

--- acpi_ibm_thinklight.diff begins here ---
--- sys/dev/acpi_support/acpi_ibm.c.orig	Mon Apr 23 19:07:47 2007
+++ sys/dev/acpi_support/acpi_ibm.c	Mon Apr 23 19:09:24 2007
@@ -412,7 +412,7 @@ acpi_ibm_attach(device_t dev)
 
 	/* Hook up light to led(4) */
 	if (sc->light_set_supported)
-		sc->led_dev = led_create(ibm_led, sc, "thinklight");
+		sc->led_dev = led_create_state(ibm_led, sc, "thinklight", sc->light_val);
 
 	return (0);
 }
@@ -810,7 +810,7 @@ acpi_ibm_sysctl_init(struct acpi_ibm_sof
 
 	case ACPI_IBM_METHOD_THINKLIGHT:
 		sc->cmos_handle = NULL;
-		sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &dummy));
+		sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &sc->light_val));
 
 		if ((ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\UCMS", &sc->light_handle)) ||
 		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMOS", &sc->light_handle)) ||
@@ -831,7 +831,10 @@ acpi_ibm_sysctl_init(struct acpi_ibm_sof
 		sc->light_set_supported = (sc->light_handle &&
 		    ACPI_FAILURE(AcpiGetHandle(sc->ec_handle, "LEDB", &ledb_handle)));
 
-		if (sc->light_get_supported || sc->light_set_supported) {
+		if (sc->light_get_supported) {
+			return (TRUE);
+		}
+		else if (sc->light_set_supported) {
 			sc->light_val = 0;
 			return (TRUE);
 		}
--- acpi_ibm_thinklight.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070423174953.91DA911432>