staging: comedi: add bus-type-specific attach hooks for PCI and USB
authorIan Abbott <abbotti@mev.co.uk>
Fri, 30 Mar 2012 16:15:01 +0000 (17:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 18:22:01 +0000 (11:22 -0700)
commitf4011670023f28cf9081904f8986c0c1be5c9f1e
tree95fa6251525edcc6d4091f77fe20de7609181e78
parent3902a370281d2f2b130f141e8cf94eab40125769
staging: comedi: add bus-type-specific attach hooks for PCI and USB

The Comedi auto-configuration mechanism used to bind hardware devices to
comedi devices automatically is pretty kludgy.  It fakes a "manual"
configuration of the comedi device as though the COMEDI_DEVCONFIG ioctl
(or the 'comedi_config' utility) were used.  In particular, the
low-level comedi driver's '->attach()' routine is called with a pointer
to the struct comedi_device being attached and a pointer to a 'struct
devconfig' containing a device name string and a few integer options to
help the attach routine locate the device being attached.  In the case
of PCI devices, these integer options are the PCI bus and slot numbers.
In the case of USB devices, there are no integer options and it relies
more on pot luck to attach the correct device.

This patch adds a couple of bus-type-specific attach routine hooks to
the struct comedi_driver, which a low-level driver can optionally fill
in if it supports auto-configuration.

A low-level driver that supports auto-configuration of {PCI,USB} devices
calls the existing comedi_{pci,usb}_auto_config() when it wishes to
auto-configure a freshly probed device (maybe after loading firmware).
This will call the new '->attach_{pci,usb}()' hook if the driver has
defined it, otherwise it will fall back to calling the '->attach()' hook
as before.  The '->attach_{pci,usb}()' hook gets a pointer to the struct
comedi_device and a pointer to the struct {pci_dev,usb_interface} and
can figure out the {PCI,USB} device details for itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c