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, Mar 12, 2012 at 04:38:57PM -0400, Alan Stern wrote:
> 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?

Kind of? platform_notify gets called whenever a device is registered, 
and on ACPi systems that'll be acpi_platform_notify. It'll take the 
registered device and, if there are glue functions for that bus type, 
pass it to the callback functions. The idea is that we have two 
disparate device trees, the Linux one and the ACPI one. This just gives 
us an opportunity to glue some of the devices together.

> 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.

Ugh. Is there any clean way to distinguish from the device structure? If 
not, the easiest would seem to be to just add another bus type 
structure, even if the members are identical.

-- 
Matthew Garrett | mjg59@xxxxxxxxxxxxx
--
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