[PATCH 308/577] Staging: comedi: kcomedilib: make it typesafe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Cc: Frank Mori Hess <fmhess@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
 drivers/staging/comedi/comedilib.h                 |   17 ++++++++-------
 drivers/staging/comedi/drivers/comedi_bond.c       |    6 ++--
 .../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@xxxxxxxxxxx>");
 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;
-- 
1.7.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux