acpi_battery.c (143002) | acpi_battery.c (143771) |
---|---|
1/*- 2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_battery.c 143002 2005-03-02 09:22:34Z obrien $"); | 28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_battery.c 143771 2005-03-17 22:42:49Z njl $"); |
29 30#include "opt_acpi.h" 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/bus.h> 35#include <sys/ioccom.h> 36#include <sys/sysctl.h> --- 24 unchanged lines hidden (view full) --- 61 62int 63acpi_battery_get_units(void) 64{ 65 return (acpi_batteries_units); 66} 67 68int | 29 30#include "opt_acpi.h" 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/bus.h> 35#include <sys/ioccom.h> 36#include <sys/sysctl.h> --- 24 unchanged lines hidden (view full) --- 61 62int 63acpi_battery_get_units(void) 64{ 65 return (acpi_batteries_units); 66} 67 68int |
69acpi_battery_get_battdesc(int logical_unit, struct acpi_battdesc *battdesc) | 69acpi_battery_get_battdesc(int unit, struct acpi_battdesc *battdesc) |
70{ 71 struct acpi_batteries *bp; 72 int error, i; 73 74 error = ENXIO; 75 ACPI_SERIAL_BEGIN(battery); | 70{ 71 struct acpi_batteries *bp; 72 int error, i; 73 74 error = ENXIO; 75 ACPI_SERIAL_BEGIN(battery); |
76 if (logical_unit < 0 || logical_unit >= acpi_batteries_units) | 76 if (unit < 0 || unit >= acpi_batteries_units) |
77 goto out; 78 79 i = 0; 80 TAILQ_FOREACH(bp, &acpi_batteries, link) { | 77 goto out; 78 79 i = 0; 80 TAILQ_FOREACH(bp, &acpi_batteries, link) { |
81 if (logical_unit == i) { | 81 if (unit == i) { |
82 battdesc->type = bp->battdesc.type; 83 battdesc->phys_unit = bp->battdesc.phys_unit; 84 error = 0; 85 break; 86 } 87 i++; 88 } 89 --- 30 unchanged lines hidden (view full) --- 120out: 121 return (error); 122} 123 124static int 125acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg) 126{ 127 union acpi_battery_ioctl_arg *ioctl_arg; | 82 battdesc->type = bp->battdesc.type; 83 battdesc->phys_unit = bp->battdesc.phys_unit; 84 error = 0; 85 break; 86 } 87 i++; 88 } 89 --- 30 unchanged lines hidden (view full) --- 120out: 121 return (error); 122} 123 124static int 125acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg) 126{ 127 union acpi_battery_ioctl_arg *ioctl_arg; |
128 int error, logical_unit; | 128 int error, unit; |
129 130 ioctl_arg = (union acpi_battery_ioctl_arg *)addr; 131 error = 0; 132 133 /* 134 * No security check required: information retrieval only. If 135 * new functions are added here, a check might be required. 136 */ 137 switch (cmd) { 138 case ACPIIO_BATT_GET_UNITS: 139 *(int *)addr = acpi_battery_get_units(); 140 break; 141 case ACPIIO_BATT_GET_BATTDESC: | 129 130 ioctl_arg = (union acpi_battery_ioctl_arg *)addr; 131 error = 0; 132 133 /* 134 * No security check required: information retrieval only. If 135 * new functions are added here, a check might be required. 136 */ 137 switch (cmd) { 138 case ACPIIO_BATT_GET_UNITS: 139 *(int *)addr = acpi_battery_get_units(); 140 break; 141 case ACPIIO_BATT_GET_BATTDESC: |
142 logical_unit = ioctl_arg->unit; 143 error = acpi_battery_get_battdesc(logical_unit, &ioctl_arg->battdesc); | 142 unit = ioctl_arg->unit; 143 error = acpi_battery_get_battdesc(unit, &ioctl_arg->battdesc); |
144 break; 145 case ACPIIO_BATT_GET_BATTINFO: | 144 break; 145 case ACPIIO_BATT_GET_BATTINFO: |
146 logical_unit = ioctl_arg->unit; 147 error = acpi_battery_get_battinfo(logical_unit, &ioctl_arg->battinfo); | 146 unit = ioctl_arg->unit; 147 error = acpi_battery_get_battinfo(unit, &ioctl_arg->battinfo); |
148 break; 149 default: 150 error = EINVAL; 151 break; 152 } 153 154 return (error); 155} 156 157static int 158acpi_battery_sysctl(SYSCTL_HANDLER_ARGS) 159{ | 148 break; 149 default: 150 error = EINVAL; 151 break; 152 } 153 154 return (error); 155} 156 157static int 158acpi_battery_sysctl(SYSCTL_HANDLER_ARGS) 159{ |
160 int val, error; | 160 int val, error; |
161 162 acpi_battery_get_battinfo(-1, &acpi_battery_battinfo); 163 val = *(u_int *)oidp->oid_arg1; 164 error = sysctl_handle_int(oidp, &val, 0, req); 165 return (error); 166} 167 168static int --- 109 unchanged lines hidden --- | 161 162 acpi_battery_get_battinfo(-1, &acpi_battery_battinfo); 163 val = *(u_int *)oidp->oid_arg1; 164 error = sysctl_handle_int(oidp, &val, 0, req); 165 return (error); 166} 167 168static int --- 109 unchanged lines hidden --- |