1/* 2 * comedi_usb.c 3 * Comedi USB driver specific functions. 4 * 5 * COMEDI - Linux Control and Measurement Device Interface 6 * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23#include <linux/usb.h> 24 25#include "comedidev.h" 26 27/** 28 * comedi_to_usb_interface() - comedi_device pointer to usb_interface pointer. 29 * @dev: comedi_device struct 30 */ 31struct usb_interface *comedi_to_usb_interface(struct comedi_device *dev) 32{ 33 return dev->hw_dev ? to_usb_interface(dev->hw_dev) : NULL; 34} 35EXPORT_SYMBOL_GPL(comedi_to_usb_interface); 36 37/** 38 * comedi_usb_auto_config() - Configure/probe a comedi USB driver. 39 * @intf: usb_interface struct 40 * @driver: comedi_driver struct 41 * @context: driver specific data, passed to comedi_auto_config() 42 * 43 * Typically called from the usb_driver (*probe) function. 44 */ 45int comedi_usb_auto_config(struct usb_interface *intf, 46 struct comedi_driver *driver, 47 unsigned long context) 48{ 49 return comedi_auto_config(&intf->dev, driver, context); 50} 51EXPORT_SYMBOL_GPL(comedi_usb_auto_config); 52 53/** 54 * comedi_pci_auto_unconfig() - Unconfigure/disconnect a comedi USB driver. 55 * @intf: usb_interface struct 56 * 57 * Typically called from the usb_driver (*disconnect) function. 58 */ 59void comedi_usb_auto_unconfig(struct usb_interface *intf) 60{ 61 comedi_auto_unconfig(&intf->dev); 62} 63EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig); 64 65/** 66 * comedi_usb_driver_register() - Register a comedi USB driver. 67 * @comedi_driver: comedi_driver struct 68 * @usb_driver: usb_driver struct 69 * 70 * This function is used for the module_init() of comedi USB drivers. 71 * Do not call it directly, use the module_comedi_usb_driver() helper 72 * macro instead. 73 */ 74int comedi_usb_driver_register(struct comedi_driver *comedi_driver, 75 struct usb_driver *usb_driver) 76{ 77 int ret; 78 79 ret = comedi_driver_register(comedi_driver); 80 if (ret < 0) 81 return ret; 82 83 ret = usb_register(usb_driver); 84 if (ret < 0) { 85 comedi_driver_unregister(comedi_driver); 86 return ret; 87 } 88 89 return 0; 90} 91EXPORT_SYMBOL_GPL(comedi_usb_driver_register); 92 93/** 94 * comedi_usb_driver_unregister() - Unregister a comedi USB driver. 95 * @comedi_driver: comedi_driver struct 96 * @usb_driver: usb_driver struct 97 * 98 * This function is used for the module_exit() of comedi USB drivers. 99 * Do not call it directly, use the module_comedi_usb_driver() helper 100 * macro instead. 101 */ 102void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver, 103 struct usb_driver *usb_driver) 104{ 105 usb_deregister(usb_driver); 106 comedi_driver_unregister(comedi_driver); 107} 108EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister); 109