Re: [PATCH 3/4] usb: Bind devices to ACPI devices when possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 12 Mar 2012, Matthew Garrett wrote:

> Built-in USB devices will typically have a representation in the system
> ACPI tables. Add support for binding the two together so the USB code can
> make use of the associated methods.

> +static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
> +{
> +	struct usb_device *udev = to_usb_device(dev);
> +	struct device *parent = dev->parent;
> +	acpi_handle *parent_handle = DEVICE_ACPI_HANDLE(parent);
> +
> +	if (!parent_handle)
> +		return -ENODEV;
> +
> +	*handle = acpi_get_child(parent_handle, udev->portnum);
> +
> +	if (!*handle)
> +		return -ENODEV;
> +
> +	return 0;
> +}
> +
> +static struct acpi_bus_type usb_acpi_bus = {
> +	.bus = &usb_bus_type,
> +	.find_bridge = NULL,
> +	.find_device = usb_acpi_find_device,
> +};

I don't understand exactly how this is supposed to work.  Does this 
mean that the ACPI core will call usb_acpi_find_device() for every ACPI 
device whose underlying real device is registered on the usb_bus_type?  
If so, when does this call take place?

Or does it work some other way?

Bear in mind that USB devices aren't the only things registered with 
usb_bus_type.  We also register device structures representing USB 
interfaces and endpoints.  Hence the to_usb_device() call above might 
not always do what you want.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux