From 981bdf41ea7bbeece1f08045e0456c725a4d8f2f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Apr 2010 15:25:53 -0700 Subject: Staging: comedi: fix up coding style issues in comedilib.h This resolves some issues with comedilib.h Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 3918d53b3040..27dd3bec88af 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -164,10 +164,10 @@ int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice); int comedi_find_subdevice_by_type(unsigned int minor, int type, unsigned int subd); int comedi_get_n_channels(unsigned int minor, unsigned int subdevice); -unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned - int chan); -int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int - chan); +unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, + unsigned int chan); +int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, + unsigned int chan); int comedi_do_insn(unsigned int minor, struct comedi_insn *insn); int comedi_poll(unsigned int minor, unsigned int subdev); -- cgit v1.2.3 From 703f5936e2a4a31a5b2596d47c1504a472d4ab85 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 1 May 2010 13:42:37 -0700 Subject: Staging: comedi: clean up comedilib.h Remove a whole #ifdef section that is not needed anymore. Cc: Ian Abbott Cc: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 82 -------------------------------------- 1 file changed, 82 deletions(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 27dd3bec88af..deb28cb234a9 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -26,16 +26,6 @@ #include "comedi.h" -/* Kernel internal stuff. Needed by real-time modules and such. */ - -#ifndef __KERNEL__ -#error linux/comedilib.h should not be included by non-kernel-space code -#endif - -/* exported functions */ - -#ifndef KCOMEDILIB_DEPRECATED - /* these functions may not be called at real-time priority */ void *comedi_open(const char *path); @@ -117,77 +107,5 @@ int comedi_mark_buffer_written(void *d, unsigned int subdevice, int comedi_get_buffer_contents(void *dev, unsigned int subdevice); int comedi_get_buffer_offset(void *dev, unsigned int subdevice); -#else - -/* these functions may not be called at real-time priority */ - -int comedi_open(unsigned int minor); -void comedi_close(unsigned int minor); - -/* these functions may be called at any priority, but may fail at - real-time priority */ - -int comedi_lock(unsigned int minor, unsigned int subdev); -int comedi_unlock(unsigned int minor, unsigned int subdev); - -/* these functions may be called at any priority, but you must hold - the lock for the subdevice */ - -int comedi_cancel(unsigned int minor, unsigned int subdev); -int comedi_register_callback(unsigned int minor, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, - void *), void *arg); - -int comedi_command(unsigned int minor, struct comedi_cmd *cmd); -int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd); -int comedi_trigger(unsigned int minor, unsigned int subdev, - struct comedi_trig *it); -int __comedi_trigger(unsigned int minor, unsigned int subdev, - struct comedi_trig *it); -int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); -int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); -int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int io); -int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int *val); -int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int val); -int comedi_dio_bitfield(unsigned int dev, unsigned int subdev, - unsigned int mask, unsigned int *bits); -int comedi_get_n_subdevices(unsigned int dev); -int comedi_get_version_code(unsigned int dev); -char *comedi_get_driver_name(unsigned int dev); -char *comedi_get_board_name(unsigned int minor); -int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice); -int comedi_find_subdevice_by_type(unsigned int minor, int type, - unsigned int subd); -int comedi_get_n_channels(unsigned int minor, unsigned int subdevice); -unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, - unsigned int chan); -int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, - unsigned int chan); -int comedi_do_insn(unsigned int minor, struct comedi_insn *insn); -int comedi_poll(unsigned int minor, unsigned int subdev); - -/* DEPRECATED functions */ -int comedi_get_rangetype(unsigned int minor, unsigned int subdevice, - unsigned int chan); - -/* ALPHA functions */ -unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int - subdevice); -int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice); -int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); -unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int - subdevice); -int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice, - unsigned int buf_user_count); -int comedi_map(unsigned int minor, unsigned int subdev, void **ptr); -int comedi_unmap(unsigned int minor, unsigned int subdev); - -#endif #endif -- cgit v1.2.3 From e2a0eab0a121a95be60a81911df07cc21e4ee429 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 1 May 2010 13:44:56 -0700 Subject: Staging: comedi: move an include file out of comedlib.h The one .c file that needs it can properly include it. Cc: Ian Abbott Cc: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 2 -- drivers/staging/comedi/drivers/comedi_bond.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index deb28cb234a9..4f86964835a9 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -24,8 +24,6 @@ #ifndef _LINUX_COMEDILIB_H #define _LINUX_COMEDILIB_H -#include "comedi.h" - /* these functions may not be called at real-time priority */ void *comedi_open(const char *path); diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 4e6797a0b1e2..429ec703d596 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -87,6 +87,7 @@ Configuration Options: * options that are used with comedi_config. */ +#include "../comedi.h" #include "../comedilib.h" #include "../comedidev.h" #include -- cgit v1.2.3 From 027d53bc2f223544a18f1b760378ca0566d13f2e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 1 May 2010 13:51:58 -0700 Subject: Staging: comedi: remove unused functions from comedilib.h Remove the functions that are not used from this file. Now it will be easier to determine what code can be removed from kcomedilib by using sparse. Cc: Ian Abbott Cc: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 74 ++------------------------------------ 1 file changed, 2 insertions(+), 72 deletions(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 4f86964835a9..00414359138d 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -24,86 +24,16 @@ #ifndef _LINUX_COMEDILIB_H #define _LINUX_COMEDILIB_H -/* these functions may not be called at real-time priority */ - void *comedi_open(const char *path); int comedi_close(void *dev); - -/* these functions may be called at any priority, but may fail at - real-time priority */ - -int comedi_lock(void *dev, unsigned int subdev); -int comedi_unlock(void *dev, unsigned int subdev); - -/* these functions may be called at any priority, but you must hold - the lock for the subdevice */ - -int comedi_loglevel(int loglevel); -void comedi_perror(const char *s); -char *comedi_strerror(int errnum); -int comedi_errno(void); -int comedi_fileno(void *dev); - -int comedi_cancel(void *dev, unsigned int subdev); -int comedi_register_callback(void *dev, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, - void *), void *arg); - -int comedi_command(void *dev, struct comedi_cmd *cmd); -int comedi_command_test(void *dev, struct comedi_cmd *cmd); -int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); -int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); -int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); -int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); -int comedi_data_read_hint(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, - unsigned int aref); -int comedi_data_read_delayed(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, - unsigned int *data, unsigned int nano_sec); int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, unsigned int io); -int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int *val); -int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int val); int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, unsigned int *bits); -int comedi_get_n_subdevices(void *dev); -int comedi_get_version_code(void *dev); -const char *comedi_get_driver_name(void *dev); -const char *comedi_get_board_name(void *dev); -int comedi_get_subdevice_type(void *dev, unsigned int subdevice); int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); int comedi_get_n_channels(void *dev, unsigned int subdevice); -unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned - int chan); -int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int chan); -int comedi_do_insn(void *dev, struct comedi_insn *insn); -int comedi_poll(void *dev, unsigned int subdev); - -/* DEPRECATED functions */ -int comedi_get_rangetype(void *dev, unsigned int subdevice, unsigned int chan); - -/* ALPHA functions */ -unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice); -int comedi_get_len_chanlist(void *dev, unsigned int subdevice); -int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); -unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice); -int comedi_set_user_int_count(void *dev, unsigned int subdevice, - unsigned int buf_user_count); -int comedi_map(void *dev, unsigned int subdev, void *ptr); -int comedi_unmap(void *dev, unsigned int subdev); -int comedi_get_buffer_size(void *dev, unsigned int subdev); -int comedi_mark_buffer_read(void *dev, unsigned int subdevice, - unsigned int num_bytes); -int comedi_mark_buffer_written(void *d, unsigned int subdevice, - unsigned int num_bytes); -int comedi_get_buffer_contents(void *dev, unsigned int subdevice); -int comedi_get_buffer_offset(void *dev, unsigned int subdevice); +/* internal to kcomedilb */ +int comedi_do_insn(void *dev, struct comedi_insn *insn); #endif -- cgit v1.2.3 From 88cccef0193a7f8c6a73326404c0b2f9ad27f71a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 May 2010 14:49:54 -0700 Subject: Staging: comedi: kcomedilib: comedi_do_insn is now static No one else calls this function, so mark it static. Now we can strip out the unneeded functionality in here as well. Cc: Ian Abbott Cc: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 3 --- drivers/staging/comedi/kcomedilib/kcomedilib_main.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 00414359138d..23ec58d2e239 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -33,7 +33,4 @@ int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); int comedi_get_n_channels(void *dev, unsigned int subdevice); -/* internal to kcomedilb */ -int comedi_do_insn(void *dev, struct comedi_insn *insn); - #endif diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index 7cb29f2bc862..d27de93ff4dd 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -84,7 +84,7 @@ EXPORT_SYMBOL(comedi_close); * COMEDI_INSN * perform an instruction */ -int comedi_do_insn(void *d, struct comedi_insn *insn) +static int comedi_do_insn(void *d, struct comedi_insn *insn) { struct comedi_device *dev = (struct comedi_device *)d; struct comedi_subdevice *s; -- cgit v1.2.3 From 472dfe77b91d8026c3ccda22c60db0e92bc27863 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 May 2010 15:01:50 -0700 Subject: 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 Cc: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- 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(-) (limited to 'drivers/staging/comedi/comedilib.h') diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 23ec58d2e239..ca92c43fdb38 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 429ec703d596..22a0f996eeb0 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 fa0db41292da..863aae40edeb 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 "); 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; -- cgit v1.2.3