Staging: comedi: kcomedilib: make it typesafe
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 3 May 2010 22:01:50 +0000 (15:01 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 11 May 2010 18:36:02 +0000 (11:36 -0700)
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>
drivers/staging/comedi/comedilib.h
drivers/staging/comedi/drivers/comedi_bond.c
drivers/staging/comedi/kcomedilib/kcomedilib_main.c

index 23ec58d..ca92c43 100644 (file)
 #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
index 429ec70..22a0f99 100644 (file)
@@ -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;
 
index fa0db41..863aae4 100644 (file)
@@ -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;