diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-03 22:01:50 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-11 18:36:02 (GMT) |
commit | 472dfe77b91d8026c3ccda22c60db0e92bc27863 (patch) | |
tree | 8b3e7d5062921c59e710c770a368a3d26858e47f | |
parent | 3781bc5425f985c2ceffa3b2111e1d0eeb38cc24 (diff) | |
download | linux-472dfe77b91d8026c3ccda22c60db0e92bc27863.tar.xz |
Staging: comedi: kcomedilib: make it typesafe
If we really are passing in a struct comedi_device, then say we are,
don't mess around with void pointers for no reason.
This also fixes up the comedi_bond.c driver, which is the only
user of the kcomedilib code.
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/comedi/comedilib.h | 17 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/comedi_bond.c | 6 | ||||
-rw-r--r-- | drivers/staging/comedi/kcomedilib/kcomedilib_main.c | 22 |
3 files changed, 22 insertions, 23 deletions
diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 23ec58d..ca92c43 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -24,13 +24,14 @@ #ifndef _LINUX_COMEDILIB_H #define _LINUX_COMEDILIB_H -void *comedi_open(const char *path); -int comedi_close(void *dev); -int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, - unsigned int io); -int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, - unsigned int *bits); -int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); -int comedi_get_n_channels(void *dev, unsigned int subdevice); +struct comedi_device *comedi_open(const char *path); +int comedi_close(struct comedi_device *dev); +int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, + unsigned int chan, unsigned int io); +int comedi_dio_bitfield(struct comedi_device *dev, unsigned int subdev, + unsigned int mask, unsigned int *bits); +int comedi_find_subdevice_by_type(struct comedi_device *dev, int type, + unsigned int subd); +int comedi_get_n_channels(struct comedi_device *dev, unsigned int subdevice); #endif diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 429ec70..22a0f99 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -142,7 +142,7 @@ static const struct BondingBoard bondingBoards[] = { #define thisboard ((const struct BondingBoard *)dev->board_ptr) struct BondedDevice { - void *dev; + struct comedi_device *dev; unsigned minor; unsigned subdev; unsigned subdev_type; @@ -404,7 +404,7 @@ static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen) static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) { int i; - void *devs_opened[COMEDI_NUM_BOARD_MINORS]; + struct comedi_device *devs_opened[COMEDI_NUM_BOARD_MINORS]; memset(devs_opened, 0, sizeof(devs_opened)); devpriv->name[0] = 0;; @@ -413,7 +413,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) for (i = 0; i < COMEDI_NDEVCONFOPTS && (!i || it->options[i]); ++i) { char file[] = "/dev/comediXXXXXX"; int minor = it->options[i]; - void *d; + struct comedi_device *d; int sdev = -1, nchans, tmp; struct BondedDevice *bdev = NULL; diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index fa0db41..863aae4 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -41,7 +41,7 @@ MODULE_AUTHOR("David Schleef <ds@schleef.org>"); MODULE_DESCRIPTION("Comedi kernel library"); MODULE_LICENSE("GPL"); -void *comedi_open(const char *filename) +struct comedi_device *comedi_open(const char *filename) { struct comedi_device_file_info *dev_file_info; struct comedi_device *dev; @@ -66,11 +66,11 @@ void *comedi_open(const char *filename) if (!try_module_get(dev->driver->module)) return NULL; - return (void *)dev; + return dev; } EXPORT_SYMBOL(comedi_open); -int comedi_close(void *d) +int comedi_close(struct comedi_device *d) { struct comedi_device *dev = (struct comedi_device *)d; @@ -132,8 +132,8 @@ error: return ret; } -int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, - unsigned int io) +int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, + unsigned int chan, unsigned int io) { struct comedi_insn insn; @@ -148,8 +148,8 @@ int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, } EXPORT_SYMBOL(comedi_dio_config); -int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, - unsigned int *bits) +int comedi_dio_bitfield(struct comedi_device *dev, unsigned int subdev, + unsigned int mask, unsigned int *bits) { struct comedi_insn insn; unsigned int data[2]; @@ -172,10 +172,9 @@ int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, } EXPORT_SYMBOL(comedi_dio_bitfield); -int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd) +int comedi_find_subdevice_by_type(struct comedi_device *dev, int type, + unsigned int subd) { - struct comedi_device *dev = (struct comedi_device *)d; - if (subd > dev->n_subdevices) return -ENODEV; @@ -187,9 +186,8 @@ int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd) } EXPORT_SYMBOL(comedi_find_subdevice_by_type); -int comedi_get_n_channels(void *d, unsigned int subdevice) +int comedi_get_n_channels(struct comedi_device *dev, unsigned int subdevice) { - struct comedi_device *dev = (struct comedi_device *)d; struct comedi_subdevice *s = dev->subdevices + subdevice; return s->n_chan; |