Commit 57aade1d authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcl724: tidy up pcl724_attach()

Consolidate the special handling of the 'hoard->can_have96' flag.
This flag overrides the iorange and n_subdevices for the PCL-724
board when it is used in a 96 DIO configuration.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 84f7db9d
...@@ -111,27 +111,31 @@ static int pcl724_8255mapped_io(int dir, int port, int data, ...@@ -111,27 +111,31 @@ static int pcl724_8255mapped_io(int dir, int port, int data,
} }
} }
static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int pcl724_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{ {
const struct pcl724_board *board = comedi_board(dev); const struct pcl724_board *board = comedi_board(dev);
struct comedi_subdevice *s; struct comedi_subdevice *s;
unsigned long iobase; unsigned long iobase;
unsigned int iorange; unsigned int iorange;
int ret, i, n_subdevices; int n_subdevices;
int ret;
int i;
iorange = board->io_range; iorange = board->io_range;
if ((board->can_have96) && n_subdevices = board->numofports;
((it->options[1] == 1) || (it->options[1] == 96)))
iorange = 0x10; /* PCL-724 in 96 DIO configuration */ /* Handle PCL-724 in 96 DIO configuration */
if (board->can_have96 &&
(it->options[1] == 1 || it->options[1] == 96)) {
iorange = 0x10;
n_subdevices = 4;
}
ret = comedi_request_region(dev, it->options[0], iorange); ret = comedi_request_region(dev, it->options[0], iorange);
if (ret) if (ret)
return ret; return ret;
n_subdevices = board->numofports;
if ((board->can_have96) && ((it->options[1] == 1)
|| (it->options[1] == 96)))
n_subdevices = 4; /* PCL-724 in 96 DIO configuration */
ret = comedi_alloc_subdevices(dev, n_subdevices); ret = comedi_alloc_subdevices(dev, n_subdevices);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment