diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-04-09 23:05:54 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-11 19:47:35 (GMT) |
commit | f375ac5f197d32aeffe5436e5864525cc14ce44a (patch) | |
tree | b88e0220afd6049b76f2a403109c5bb53fd667ba /drivers/staging/comedi/drivers.c | |
parent | aa7a82b9f941f1e299bf9b26dcd8bb76ecce3c8f (diff) | |
download | linux-f375ac5f197d32aeffe5436e5864525cc14ce44a.tar.xz |
staging: comedi: drivers: introduce comedi_request_region()
Introduce a helper function to handle the request_region() for legacy
comedi drivers.
As pointed out by Ian Abbott, legacy devices are configured manually
with the "comedi_config" program. The error messages are useful
diagnostics when trying to attach to these boards.
Providing a helper function allows consolidating the error messages
in the drivers and providing a consistent format for the errors.
This helper also sets the dev->iobase automatically for the driver
if the request_region() is successful.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r-- | drivers/staging/comedi/drivers.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 4a1eb7b..6456a64 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -337,6 +337,33 @@ static void comedi_report_boards(struct comedi_driver *driv) pr_info(" %s\n", driv->driver_name); } +/** + * comedi_request_region() - Request an I/O reqion for a legacy driver. + * @dev: comedi_device struct + * @start: base address of the I/O reqion + * @len: length of the I/O region + */ +int comedi_request_region(struct comedi_device *dev, + unsigned long start, unsigned long len) +{ + if (!start) { + dev_warn(dev->class_dev, + "%s: a I/O base address must be specified\n", + dev->board_name); + return -EINVAL; + } + + if (!request_region(start, len, dev->board_name)) { + dev_warn(dev->class_dev, "%s: I/O port conflict (%#lx,%lu)\n", + dev->board_name, start, len); + return -EIO; + } + dev->iobase = start; + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_request_region); + int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_driver *driv; |