diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-01-30 15:24:38 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-31 10:40:41 +0100 |
commit | 1ae6b20b88737f1828649b6cbe349c83b9f97bf0 (patch) | |
tree | 18b9e8559af054658eeb5186768ca6640eb9e3c3 /drivers | |
parent | 52c9bf4cf51d992b1b88edeaa63e018d178cbc83 (diff) |
staging: comedi: tidy up the general purpose driver functions
Group all the general comedi driver register/config/attach
prototypes into one place in comedidev.h.
Reorder the functions in drivers.c a bit so they are in a more
logical usage order (bottom to top).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 49 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers.c | 94 |
2 files changed, 73 insertions, 70 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ea585ebd07df..0f29dd5287bb 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -258,26 +258,6 @@ static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1; struct comedi_device *comedi_dev_from_minor(unsigned minor); -int comedi_alloc_subdevices(struct comedi_device *, int); - -void comedi_device_detach(struct comedi_device *dev); -int comedi_device_attach(struct comedi_device *dev, - struct comedi_devconfig *it); -int comedi_driver_register(struct comedi_driver *); -int comedi_driver_unregister(struct comedi_driver *); - -/** - * module_comedi_driver() - Helper macro for registering a comedi driver - * @__comedi_driver: comedi_driver struct - * - * Helper macro for comedi drivers which do not do anything special in module - * init/exit. This eliminates a lot of boilerplate. Each module may only use - * this macro once, and calling it replaces module_init() and module_exit(). - */ -#define module_comedi_driver(__comedi_driver) \ - module_driver(__comedi_driver, comedi_driver_register, \ - comedi_driver_unregister) - void init_polling(void); void cleanup_polling(void); void start_polling(struct comedi_device *); @@ -384,9 +364,32 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s); void comedi_free_subdevice_minor(struct comedi_subdevice *s); -int comedi_auto_config(struct device *hardware_device, - struct comedi_driver *driver, unsigned long context); -void comedi_auto_unconfig(struct device *hardware_device); + +/* drivers.c - general comedi driver functions */ + +int comedi_alloc_subdevices(struct comedi_device *, int); + +void comedi_device_detach(struct comedi_device *); +int comedi_device_attach(struct comedi_device *, struct comedi_devconfig *); + +int comedi_auto_config(struct device *, struct comedi_driver *, + unsigned long context); +void comedi_auto_unconfig(struct device *); + +int comedi_driver_register(struct comedi_driver *); +int comedi_driver_unregister(struct comedi_driver *); + +/** + * module_comedi_driver() - Helper macro for registering a comedi driver + * @__comedi_driver: comedi_driver struct + * + * Helper macro for comedi drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only use + * this macro once, and calling it replaces module_init() and module_exit(). + */ +#define module_comedi_driver(__comedi_driver) \ + module_driver(__comedi_driver, comedi_driver_register, \ + comedi_driver_unregister) #ifdef CONFIG_COMEDI_PCI_DRIVERS diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 151e0845569e..fe91e758184f 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -386,53 +386,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) return comedi_device_postconfig(dev); } -int comedi_driver_register(struct comedi_driver *driver) -{ - driver->next = comedi_drivers; - comedi_drivers = driver; - - return 0; -} -EXPORT_SYMBOL(comedi_driver_register); - -int comedi_driver_unregister(struct comedi_driver *driver) -{ - struct comedi_driver *prev; - int i; - - /* check for devices using this driver */ - for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { - struct comedi_device *dev = comedi_dev_from_minor(i); - - if (!dev) - continue; - - mutex_lock(&dev->mutex); - if (dev->attached && dev->driver == driver) { - if (dev->use_count) - dev_warn(dev->class_dev, - "BUG! detaching device with use_count=%d\n", - dev->use_count); - comedi_device_detach(dev); - } - mutex_unlock(&dev->mutex); - } - - if (comedi_drivers == driver) { - comedi_drivers = driver->next; - return 0; - } - - for (prev = comedi_drivers; prev->next; prev = prev->next) { - if (prev->next == driver) { - prev->next = driver->next; - return 0; - } - } - return -EINVAL; -} -EXPORT_SYMBOL(comedi_driver_unregister); - int comedi_auto_config(struct device *hardware_device, struct comedi_driver *driver, unsigned long context) { @@ -492,3 +445,50 @@ void comedi_auto_unconfig(struct device *hardware_device) comedi_free_board_minor(minor); } EXPORT_SYMBOL_GPL(comedi_auto_unconfig); + +int comedi_driver_register(struct comedi_driver *driver) +{ + driver->next = comedi_drivers; + comedi_drivers = driver; + + return 0; +} +EXPORT_SYMBOL(comedi_driver_register); + +int comedi_driver_unregister(struct comedi_driver *driver) +{ + struct comedi_driver *prev; + int i; + + /* check for devices using this driver */ + for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { + struct comedi_device *dev = comedi_dev_from_minor(i); + + if (!dev) + continue; + + mutex_lock(&dev->mutex); + if (dev->attached && dev->driver == driver) { + if (dev->use_count) + dev_warn(dev->class_dev, + "BUG! detaching device with use_count=%d\n", + dev->use_count); + comedi_device_detach(dev); + } + mutex_unlock(&dev->mutex); + } + + if (comedi_drivers == driver) { + comedi_drivers = driver->next; + return 0; + } + + for (prev = comedi_drivers; prev->next; prev = prev->next) { + if (prev->next == driver) { + prev->next = driver->next; + return 0; + } + } + return -EINVAL; +} +EXPORT_SYMBOL(comedi_driver_unregister); |