staging: comedi: drivers: refactor comedi_request_region()
Split comedi_request_region() into two helper functions. __comedi_request_region() Handles the actual request_region() call. comedi_request_region() Calls __comedi_request_region() and then sets dev->iobase if the request was successful. This allows drivers to use the __comedi_request_region() helper to handle the request without setting the dev->iobase. 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>
This commit is contained in:
parent
07e6ed00b1
commit
ca8b296409
2 changed files with 24 additions and 4 deletions
|
@ -348,6 +348,8 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
|
||||||
|
|
||||||
int comedi_alloc_subdevices(struct comedi_device *, int);
|
int comedi_alloc_subdevices(struct comedi_device *, int);
|
||||||
|
|
||||||
|
int __comedi_request_region(struct comedi_device *,
|
||||||
|
unsigned long start, unsigned long len);
|
||||||
int comedi_request_region(struct comedi_device *,
|
int comedi_request_region(struct comedi_device *,
|
||||||
unsigned long start, unsigned long len);
|
unsigned long start, unsigned long len);
|
||||||
|
|
||||||
|
|
|
@ -338,13 +338,13 @@ static void comedi_report_boards(struct comedi_driver *driv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* comedi_request_region() - Request an I/O reqion for a legacy driver.
|
* __comedi_request_region() - Request an I/O reqion for a legacy driver.
|
||||||
* @dev: comedi_device struct
|
* @dev: comedi_device struct
|
||||||
* @start: base address of the I/O reqion
|
* @start: base address of the I/O reqion
|
||||||
* @len: length of the I/O region
|
* @len: length of the I/O region
|
||||||
*/
|
*/
|
||||||
int comedi_request_region(struct comedi_device *dev,
|
int __comedi_request_region(struct comedi_device *dev,
|
||||||
unsigned long start, unsigned long len)
|
unsigned long start, unsigned long len)
|
||||||
{
|
{
|
||||||
if (!start) {
|
if (!start) {
|
||||||
dev_warn(dev->class_dev,
|
dev_warn(dev->class_dev,
|
||||||
|
@ -358,10 +358,28 @@ int comedi_request_region(struct comedi_device *dev,
|
||||||
dev->board_name, start, len);
|
dev->board_name, start, len);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
dev->iobase = start;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(__comedi_request_region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = __comedi_request_region(dev, start, len);
|
||||||
|
if (ret == 0)
|
||||||
|
dev->iobase = start;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(comedi_request_region);
|
EXPORT_SYMBOL_GPL(comedi_request_region);
|
||||||
|
|
||||||
int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
|
|
Loading…
Add table
Reference in a new issue