Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/acpica/acpi_pci.c
Show First 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | |||||
acpi_pci_bus_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) | acpi_pci_bus_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) | ||||
{ | { | ||||
device_t dev; | device_t dev; | ||||
dev = context; | dev = context; | ||||
switch (notify) { | switch (notify) { | ||||
case ACPI_NOTIFY_BUS_CHECK: | case ACPI_NOTIFY_BUS_CHECK: | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
BUS_RESCAN(dev); | BUS_RESCAN(dev); | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
break; | break; | ||||
default: | default: | ||||
device_printf(dev, "unknown notify %#x\n", notify); | device_printf(dev, "unknown notify %#x\n", notify); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) | acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) | ||||
{ | { | ||||
device_t child, dev; | device_t child, dev; | ||||
ACPI_STATUS status; | ACPI_STATUS status; | ||||
int error; | int error; | ||||
dev = context; | dev = context; | ||||
switch (notify) { | switch (notify) { | ||||
case ACPI_NOTIFY_DEVICE_CHECK: | case ACPI_NOTIFY_DEVICE_CHECK: | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
BUS_RESCAN(dev); | BUS_RESCAN(dev); | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
break; | break; | ||||
case ACPI_NOTIFY_EJECT_REQUEST: | case ACPI_NOTIFY_EJECT_REQUEST: | ||||
child = acpi_get_device(h); | child = acpi_get_device(h); | ||||
if (child == NULL) { | if (child == NULL) { | ||||
device_printf(dev, "no device to eject for %s\n", | device_printf(dev, "no device to eject for %s\n", | ||||
acpi_name(h)); | acpi_name(h)); | ||||
return; | return; | ||||
} | } | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
error = device_detach(child); | error = device_detach(child); | ||||
if (error) { | if (error) { | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
device_printf(dev, "failed to detach %s: %d\n", | device_printf(dev, "failed to detach %s: %d\n", | ||||
device_get_nameunit(child), error); | device_get_nameunit(child), error); | ||||
return; | return; | ||||
} | } | ||||
status = acpi_SetInteger(h, "_EJ0", 1); | status = acpi_SetInteger(h, "_EJ0", 1); | ||||
if (ACPI_FAILURE(status)) { | if (ACPI_FAILURE(status)) { | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
device_printf(dev, "failed to eject %s: %s\n", | device_printf(dev, "failed to eject %s: %s\n", | ||||
acpi_name(h), AcpiFormatException(status)); | acpi_name(h), AcpiFormatException(status)); | ||||
return; | return; | ||||
} | } | ||||
BUS_RESCAN(dev); | BUS_RESCAN(dev); | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
break; | break; | ||||
default: | default: | ||||
device_printf(dev, "unknown notify %#x for %s\n", notify, | device_printf(dev, "unknown notify %#x for %s\n", notify, | ||||
acpi_name(h)); | acpi_name(h)); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |