staging: comedi: pcl724: tidy up subdev_8255_init() calls
subdev_8255_init() can fail, make sure to check for it and return the errno. The private function subdev_8255_cb() is identical to the default io callback used by the 8255 driver. Remove it and pass NULL to subdev_8255_init() so the default callback will be used. The private function subdev_8255mapped_cb() is used for the memory memory mapped io of the pet48dio board. Rename this function so it has namespace associated with the driver. Casting the iobase passed to subdev_8255_init() is not needed. Use a local variable for the iobase and remove the casts. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0a0c2cb96b
commit
84f7db9d8f
1 changed files with 11 additions and 20 deletions
|
@ -94,19 +94,7 @@ static const struct pcl724_board boardtypes[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
|
static int pcl724_8255mapped_io(int dir, int port, int data,
|
||||||
{
|
|
||||||
unsigned long iobase = arg;
|
|
||||||
|
|
||||||
if (dir) {
|
|
||||||
outb(data, iobase + port);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return inb(iobase + port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int subdev_8255mapped_cb(int dir, int port, int data,
|
|
||||||
unsigned long iobase)
|
unsigned long iobase)
|
||||||
{
|
{
|
||||||
int movport = SIZE_8255 * (iobase >> 12);
|
int movport = SIZE_8255 * (iobase >> 12);
|
||||||
|
@ -127,6 +115,7 @@ 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 int iorange;
|
unsigned int iorange;
|
||||||
int ret, i, n_subdevices;
|
int ret, i, n_subdevices;
|
||||||
|
|
||||||
|
@ -150,13 +139,15 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
for (i = 0; i < dev->n_subdevices; i++) {
|
for (i = 0; i < dev->n_subdevices; i++) {
|
||||||
s = &dev->subdevices[i];
|
s = &dev->subdevices[i];
|
||||||
if (board->is_pet48) {
|
if (board->is_pet48) {
|
||||||
subdev_8255_init(dev, s, subdev_8255mapped_cb,
|
iobase = dev->iobase + (i * 0x1000);
|
||||||
(unsigned long)(dev->iobase +
|
ret = subdev_8255_init(dev, s, pcl724_8255mapped_io,
|
||||||
i * 0x1000));
|
iobase);
|
||||||
} else
|
} else {
|
||||||
subdev_8255_init(dev, s, subdev_8255_cb,
|
iobase = dev->iobase + (i * SIZE_8255);
|
||||||
(unsigned long)(dev->iobase +
|
ret = subdev_8255_init(dev, s, NULL, iobase);
|
||||||
SIZE_8255 * i));
|
}
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue