diff options
Diffstat (limited to 'sys/dev/acpica/acpi_battery.c')
-rw-r--r-- | sys/dev/acpica/acpi_battery.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c index dd2b3fa..1ec1413 100644 --- a/sys/dev/acpica/acpi_battery.c +++ b/sys/dev/acpica/acpi_battery.c @@ -329,6 +329,7 @@ acpi_battery_find_dev(u_int logical_unit) dev = NULL; found_unit = 0; + newbus_slock(); batt_dc = devclass_find("battery"); maxunit = devclass_get_maxunit(batt_dc); for (i = 0; i < maxunit; i++) { @@ -340,6 +341,7 @@ acpi_battery_find_dev(u_int logical_unit) found_unit++; dev = NULL; } + newbus_sunlock(); return (dev); } @@ -369,13 +371,17 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg) */ switch (cmd) { case ACPIIO_BATT_GET_UNITS: + newbus_slock(); *(int *)addr = acpi_battery_get_units(); + newbus_sunlock(); error = 0; break; case ACPIIO_BATT_GET_BATTINFO: if (dev != NULL || unit == ACPI_BATTERY_ALL_UNITS) { bzero(&ioctl_arg->battinfo, sizeof(ioctl_arg->battinfo)); + newbus_slock(); error = acpi_battery_get_battinfo(dev, &ioctl_arg->battinfo); + newbus_sunlock(); } break; case ACPIIO_BATT_GET_BIF: @@ -416,6 +422,11 @@ acpi_battery_sysctl(SYSCTL_HANDLER_ARGS) { int val, error; + /* + * Tolerate a race here because newbus lock can't be acquired before + * acpi_battery_get_battinfo() as it can create a LOR with the sysctl + * lock. + */ acpi_battery_get_battinfo(NULL, &acpi_battery_battinfo); val = *(u_int *)oidp->oid_arg1; error = sysctl_handle_int(oidp, &val, 0, req); @@ -427,6 +438,10 @@ acpi_battery_units_sysctl(SYSCTL_HANDLER_ARGS) { int count, error; + /* + * Tolerate a race here in order to avoid a LOR between sysctl lock + * and newbus lock. + */ count = acpi_battery_get_units(); error = sysctl_handle_int(oidp, &count, 0, req); return (error); |