diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-04-09 19:05:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-11 15:47:35 -0400 |
commit | f375ac5f197d32aeffe5436e5864525cc14ce44a (patch) | |
tree | b88e0220afd6049b76f2a403109c5bb53fd667ba /drivers/staging | |
parent | aa7a82b9f941f1e299bf9b26dcd8bb76ecce3c8f (diff) |
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')
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 3 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers.c | 27 |
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 060d450179c7..77ea9962dd88 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h | |||
@@ -348,6 +348,9 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, | |||
348 | 348 | ||
349 | int comedi_alloc_subdevices(struct comedi_device *, int); | 349 | int comedi_alloc_subdevices(struct comedi_device *, int); |
350 | 350 | ||
351 | int comedi_request_region(struct comedi_device *, | ||
352 | unsigned long start, unsigned long len); | ||
353 | |||
351 | int comedi_auto_config(struct device *, struct comedi_driver *, | 354 | int comedi_auto_config(struct device *, struct comedi_driver *, |
352 | unsigned long context); | 355 | unsigned long context); |
353 | void comedi_auto_unconfig(struct device *); | 356 | void comedi_auto_unconfig(struct device *); |
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 4a1eb7b7a8da..6456a6422048 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) | |||
337 | pr_info(" %s\n", driv->driver_name); | 337 | pr_info(" %s\n", driv->driver_name); |
338 | } | 338 | } |
339 | 339 | ||
340 | /** | ||
341 | * comedi_request_region() - Request an I/O reqion for a legacy driver. | ||
342 | * @dev: comedi_device struct | ||
343 | * @start: base address of the I/O reqion | ||
344 | * @len: length of the I/O region | ||
345 | */ | ||
346 | int comedi_request_region(struct comedi_device *dev, | ||
347 | unsigned long start, unsigned long len) | ||
348 | { | ||
349 | if (!start) { | ||
350 | dev_warn(dev->class_dev, | ||
351 | "%s: a I/O base address must be specified\n", | ||
352 | dev->board_name); | ||
353 | return -EINVAL; | ||
354 | } | ||
355 | |||
356 | if (!request_region(start, len, dev->board_name)) { | ||
357 | dev_warn(dev->class_dev, "%s: I/O port conflict (%#lx,%lu)\n", | ||
358 | dev->board_name, start, len); | ||
359 | return -EIO; | ||
360 | } | ||
361 | dev->iobase = start; | ||
362 | |||
363 | return 0; | ||
364 | } | ||
365 | EXPORT_SYMBOL_GPL(comedi_request_region); | ||
366 | |||
340 | int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) | 367 | int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) |
341 | { | 368 | { |
342 | struct comedi_driver *driv; | 369 | struct comedi_driver *driv; |