From 4085e93b9fecfad454159694c19efc36e7ac1cdf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 12 Aug 2014 11:41:26 -0700 Subject: staging: comedi: 8255: refactor how the (*io) function works Currently, all users of is module that use the default (*io) function pass an 'iobase' to subdev_8255_init() of the form: dev->iobase + OFFSET_TO_8255_BASE_REG Now that the (*io) callback includes the comedi_device 'dev' pointer the 'dev->iobase' does not need to be included. Modify the default (*io) function, subdev_8255_io(), to automatically add the dev->iobase to the address when reading/writing the port. For aesthetics, rename the subdevice private data member to 'regbase'. Also, rename the local variables in this module that are used to access this member. Add a comment in dev_8255_attach() about the 'iobase' that is passed to subdev_8255_init(). For manually attached 8255 devices the io region is requested with __comedi_request_region() which does not set dev->iobase. For these devices the 'regbase' is actually the 'iobase'. Remove the, now unnecessary, dev->iobase from all the callers of subdev_8255_init(). There are a couple drivers that only passed the dev->iobase. For those drivers pass a 'regbase' of 0x00. Note that the das16m1 driver is a bit goofy. The devpriv->extra_iobase is requested using __comedi_request_region() which does not set the dev->iobase. But the starting address passed is dev->iobase + DAS16M1_82C55 so a 'regbase' of DAS16M1_82C55 is passed to subdev_8255_init(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/aio_aio12_8.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/aio_aio12_8.c') diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 324746b14931..848b95decabe 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -244,8 +244,7 @@ static int aio_aio12_8_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* 8255 Digital i/o subdevice */ - ret = subdev_8255_init(dev, s, NULL, - dev->iobase + AIO12_8_8255_BASE_REG); + ret = subdev_8255_init(dev, s, NULL, AIO12_8_8255_BASE_REG); if (ret) return ret; -- cgit