Date: Sun, 31 May 2009 10:02:20 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r193159 - head/sys/powerpc/powermac Message-ID: <200905311002.n4VA2K6c037776@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905311002.n4VA2K6c037776>