예제 #1
0
/**
 * usb_acpi_power_manageable - check whether usb port has
 * acpi power resource.
 * @hdev: USB device belonging to the usb hub
 * @index: port index based zero
 *
 * Return true if the port has acpi power resource and false if no.
 */
bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
{
	acpi_handle port_handle;
	int port1 = index + 1;

	port_handle = usb_get_hub_port_acpi_handle(hdev,
		port1);
	if (port_handle)
		return acpi_bus_power_manageable(port_handle);
	else
		return false;
}
예제 #2
0
파일: core.c 프로젝트: mecke/linux-2.6
static int pnpacpi_disable_resources(struct pnp_dev *dev)
{
	acpi_handle handle = dev->data;
	int ret;

	dev_dbg(&dev->dev, "disable resources\n");

	/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
	ret = 0;
	if (acpi_bus_power_manageable(handle)) {
		ret = acpi_bus_set_power(handle, ACPI_STATE_D3);
		if (ret)
			return ret;
	}
	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
		ret = -ENODEV;
	return ret;
}
예제 #3
0
파일: core.c 프로젝트: mecke/linux-2.6
static int pnpacpi_set_resources(struct pnp_dev *dev)
{
	acpi_handle handle = dev->data;
	struct acpi_buffer buffer;
	int ret;

	pnp_dbg(&dev->dev, "set resources\n");
	ret = pnpacpi_build_resource_template(dev, &buffer);
	if (ret)
		return ret;
	ret = pnpacpi_encode_resources(dev, &buffer);
	if (ret) {
		kfree(buffer.pointer);
		return ret;
	}
	if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
		ret = -EINVAL;
	else if (acpi_bus_power_manageable(handle))
		ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
	kfree(buffer.pointer);
	return ret;
}
예제 #4
0
static bool acpi_pci_power_manageable(struct pci_dev *dev)
{
	acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);

	return handle ? acpi_bus_power_manageable(handle) : false;
}
예제 #5
0
파일: power.c 프로젝트: hoangduit/reactos
NTSTATUS
Bus_PDO_Power (
    PPDO_DEVICE_DATA    PdoData,
    PIRP                Irp
)
{
    NTSTATUS            status;
    PIO_STACK_LOCATION  stack;
    POWER_STATE         powerState;
    POWER_STATE_TYPE    powerType;
    ULONG               error;

    stack = IoGetCurrentIrpStackLocation (Irp);
    powerType = stack->Parameters.Power.Type;
    powerState = stack->Parameters.Power.State;

    switch (stack->MinorFunction) {
    case IRP_MN_SET_POWER:

        DPRINT("\tSetting %s power state to %s\n",
               ((powerType == SystemPowerState) ?  "System" : "Device"),
               ((powerType == SystemPowerState) ? \
                DbgSystemPowerString(powerState.SystemState) : \
                DbgDevicePowerString(powerState.DeviceState)));

        switch (powerType) {
        case DevicePowerState:
            if (!PdoData->AcpiHandle || !acpi_bus_power_manageable(PdoData->AcpiHandle))
            {
                PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState);
                PdoData->Common.DevicePowerState = powerState.DeviceState;
                status = STATUS_SUCCESS;
                break;
            }

            switch (powerState.DeviceState)
            {
            case PowerDeviceD0:
                error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D0);
                break;

            case PowerDeviceD1:
                error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D1);
                break;

            case PowerDeviceD2:
                error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D2);
                break;

            case PowerDeviceD3:
                error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D3);
                break;

            default:
                error = 0;
                break;
            }

            if (ACPI_SUCCESS(error))
            {
                PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState);
                PdoData->Common.DevicePowerState = powerState.DeviceState;
                status = STATUS_SUCCESS;
            }
            else
                status = STATUS_UNSUCCESSFUL;
            break;

        case SystemPowerState:
            PdoData->Common.SystemPowerState = powerState.SystemState;
            status = STATUS_SUCCESS;
            break;

        default:
            status = STATUS_NOT_SUPPORTED;
            break;
        }
        break;

    case IRP_MN_QUERY_POWER:
        status = STATUS_SUCCESS;
        break;

    case IRP_MN_WAIT_WAKE:
    //
    // We cannot support wait-wake because we are root-enumerated
    // driver, and our parent, the PnP manager, doesn't support wait-wake.
    //
    case IRP_MN_POWER_SEQUENCE:
    default:
        status = STATUS_NOT_SUPPORTED;
        break;
    }

    if (status != STATUS_NOT_SUPPORTED) {

        Irp->IoStatus.Status = status;
    }

    PoStartNextPowerIrp(Irp);
    status = Irp->IoStatus.Status;
    IoCompleteRequest (Irp, IO_NO_INCREMENT);

    return status;
}