From owner-svn-src-head@FreeBSD.ORG Sun May 31 10:02:20 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80D4E106566C; Sun, 31 May 2009 10:02:20 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E9628FC17; Sun, 31 May 2009 10:02:20 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4VA2Kg3037777; Sun, 31 May 2009 10:02:20 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4VA2K6c037776; Sun, 31 May 2009 10:02:20 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200905311002.n4VA2K6c037776@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 31 May 2009 10:02:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193159 - head/sys/powerpc/powermac X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2009 10:02:20 -0000 Author: nwhitehorn Date: Sun May 31 10:02:20 2009 New Revision: 193159 URL: http://svn.freebsd.org/changeset/base/193159 Log: Provide an analogous sysctl to hw.acpi.acline (dev.pmu.0.acline) to determine whether the computer is plugged in to mains power. Modified: head/sys/powerpc/powermac/pmu.c Modified: head/sys/powerpc/powermac/pmu.c ============================================================================== --- head/sys/powerpc/powermac/pmu.c Sun May 31 09:22:26 2009 (r193158) +++ head/sys/powerpc/powermac/pmu.c Sun May 31 10:02:20 2009 (r193159) @@ -72,6 +72,7 @@ static void pmu_poll(device_t dev); static void pmu_set_sleepled(void *xsc, int onoff); static int pmu_server_mode(SYSCTL_HANDLER_ARGS); +static int pmu_acline_state(SYSCTL_HANDLER_ARGS); static int pmu_query_battery(struct pmu_softc *sc, int batt, struct pmu_battstate *info); static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS); @@ -393,6 +394,10 @@ pmu_attach(device_t dev) struct sysctl_oid *oid, *battroot; char battnum[2]; + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "acline", CTLTYPE_INT | CTLFLAG_RD, sc, 0, + pmu_acline_state, "I", "AC Line Status"); + battroot = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "batteries", CTLFLAG_RD, 0, "Battery Information"); @@ -843,6 +848,27 @@ pmu_query_battery(struct pmu_softc *sc, } static int +pmu_acline_state(SYSCTL_HANDLER_ARGS) +{ + struct pmu_softc *sc; + struct pmu_battstate batt; + int error, result; + + sc = arg1; + + /* The PMU treats the AC line status as a property of the battery */ + error = pmu_query_battery(sc, 0, &batt); + + if (error != 0) + return (error); + + result = (batt.state & PMU_PWR_AC_PRESENT) ? 1 : 0; + error = sysctl_handle_int(oidp, &result, 0, req); + + return (error); +} + +static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS) { struct pmu_softc *sc;