summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/comedidev.h
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2012-03-30 16:15:01 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-10 18:22:01 (GMT)
commitf4011670023f28cf9081904f8986c0c1be5c9f1e (patch)
tree95fa6251525edcc6d4091f77fe20de7609181e78 /drivers/staging/comedi/comedidev.h
parent3902a370281d2f2b130f141e8cf94eab40125769 (diff)
downloadlinux-fsl-qoriq-f4011670023f28cf9081904f8986c0c1be5c9f1e.tar.xz
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>
Diffstat (limited to 'drivers/staging/comedi/comedidev.h')
-rw-r--r--drivers/staging/comedi/comedidev.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index e4626b6..300fd84 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -180,6 +180,9 @@ struct comedi_async {
unsigned int x);
};
+struct pci_dev;
+struct usb_interface;
+
struct comedi_driver {
struct comedi_driver *next;
@@ -187,6 +190,8 @@ struct comedi_driver {
struct module *module;
int (*attach) (struct comedi_device *, struct comedi_devconfig *);
int (*detach) (struct comedi_device *);
+ int (*attach_pci) (struct comedi_device *, struct pci_dev *);
+ int (*attach_usb) (struct comedi_device *, struct usb_interface *);
/* number of elements in board_name and board_id arrays */
unsigned int num_names;
@@ -460,7 +465,6 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s);
int comedi_pci_auto_config(struct pci_dev *pcidev,
struct comedi_driver *driver);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
-struct usb_interface; /* forward declaration */
int comedi_usb_auto_config(struct usb_interface *intf,
struct comedi_driver *driver);
void comedi_usb_auto_unconfig(struct usb_interface *intf);