From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 23 17:50:04 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AF13816A407 for ; Mon, 23 Apr 2007 17:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 8DC5413C45D for ; Mon, 23 Apr 2007 17:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l3NHo4DU024644 for ; Mon, 23 Apr 2007 17:50:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l3NHo4mg024640; Mon, 23 Apr 2007 17:50:04 GMT (envelope-from gnats) Resent-Date: Mon, 23 Apr 2007 17:50:04 GMT Resent-Message-Id: <200704231750.l3NHo4mg024640@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Henrik Brix Andersen Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E579116A412; Mon, 23 Apr 2007 17:49:55 +0000 (UTC) (envelope-from brix@lothlorien.brixandersen.dk) Received: from solow.pil.dk (relay.pil.dk [195.41.47.164]) by mx1.freebsd.org (Postfix) with ESMTP id AF01713C45B; Mon, 23 Apr 2007 17:49:55 +0000 (UTC) (envelope-from brix@lothlorien.brixandersen.dk) Received: from lothlorien.brixandersen.dk (osgiliath.brixandersen.dk [87.53.223.189]) by solow.pil.dk (Postfix) with ESMTP id 1D3FD1CC0BE; Mon, 23 Apr 2007 19:49:54 +0200 (CEST) Received: by lothlorien.brixandersen.dk (Postfix, from userid 1001) id 91DA911432; Mon, 23 Apr 2007 19:49:53 +0200 (CEST) Message-Id: <20070423174953.91DA911432@lothlorien.brixandersen.dk> Date: Mon, 23 Apr 2007 19:49:53 +0200 (CEST) From: Henrik Brix Andersen To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Markus Brueffer Subject: kern/112044: [acpi_ibm] [patch] Preserve the ThinkLight state on driver attach X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Henrik Brix Andersen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2007 17:50:04 -0000 >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: