Esempio n. 1
0
static int usb_acpi_check_port_connect_type(struct usb_device *hdev,
	acpi_handle handle, int port1)
{
	enum usb_port_connect_type connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN;
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
	struct acpi_pld_info *pld;
	union acpi_object *upc;
	acpi_status status;
	int ret = 0;

	if (!hub)
		return 0;

	/*
	 * According to ACPI Spec 9.13. PLD indicates whether usb port is
	 * user visible and _UPC indicates whether it is connectable. If
	 * the port was visible and connectable, it could be freely connected
	 * and disconnected with USB devices. If no visible and connectable,
	 * a usb device is directly hard-wired to the port. If no visible and
	 * no connectable, the port would be not used.
	 */
	status = acpi_get_physical_device_location(handle, &pld);
	if (ACPI_FAILURE(status))
		return -ENODEV;

	status = acpi_evaluate_object(handle, "_UPC", NULL, &buffer);
	upc = buffer.pointer;
	if (!upc || (upc->type != ACPI_TYPE_PACKAGE)
		|| upc->package.count != 4) {
		ret = -EINVAL;
		goto out;
	}

	if (upc->package.elements[0].integer.value)
		if (pld->user_visible)
			connect_type = USB_PORT_CONNECT_TYPE_HOT_PLUG;
		else
			connect_type = USB_PORT_CONNECT_TYPE_HARD_WIRED;
	else if (!pld->user_visible)
		connect_type = USB_PORT_NOT_USED;
	hub->ports[port1 - 1]->connect_type = connect_type;

out:
	ACPI_FREE(pld);
	kfree(upc);
	return ret;
}
Esempio n. 2
0
static int usb_acpi_check_pld(struct usb_device *udev, acpi_handle handle)
{
	acpi_status status;
	struct acpi_pld pld;

	status = acpi_get_physical_device_location(handle, &pld);

	if (ACPI_FAILURE(status))
		return -ENODEV;

	if (pld.user_visible)
		udev->removable = USB_DEVICE_REMOVABLE;
	else
		udev->removable = USB_DEVICE_FIXED;

	return 0;
}