diff options
Diffstat (limited to 'drivers/staging/comedi')
192 files changed, 17943 insertions, 17889 deletions
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 2d819d278b0e..af723cb9d08f 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -13,13 +13,6 @@ config COMEDI_DEBUG This is an option for use by developers; most people should say N here. This enables comedi core and driver debugging. -config COMEDI_RT - tristate "Comedi Real-time support" - depends on COMEDI && RT - default N - ---help--- - Enable Real time support for the Comedi core. - config COMEDI_PCI_DRIVERS tristate "Comedi PCI drivers" depends on COMEDI && PCI @@ -29,10 +22,10 @@ config COMEDI_PCI_DRIVERS config COMEDI_PCMCIA_DRIVERS tristate "Comedi PCMCIA drivers" - depends on COMEDI && PCMCIAI + depends on COMEDI && PCMCIA && PCCARD default N ---help--- - Enable lots of comedi PCMCIA drivers to be built + Enable lots of comedi PCMCIA and PCCARD drivers to be built config COMEDI_USB_DRIVERS tristate "Comedi USB drivers" diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index afd1a19c1b87..05811f79d85b 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_COMEDI) += comedi.o -obj-$(CONFIG_COMEDI_RT) += comedi_rt.o obj-$(CONFIG_COMEDI) += kcomedilib/ obj-$(CONFIG_COMEDI) += drivers/ @@ -11,7 +10,3 @@ comedi-objs := \ drivers.o \ comedi_compat32.o \ comedi_ksyms.o \ - -comedi_rt-objs := \ - rt_pend_tq.o \ - rt.o diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index e6b5f16edb02..8101cea84528 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -188,7 +188,6 @@ extern "C" { #define SDF_WRITABLE 0x00020000 /* subdevice can be written (e.g. analog output) */ #define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API */ #define SDF_INTERNAL 0x00040000 /* subdevice does not have externally visible lines */ -#define SDF_RT 0x00080000 /* DEPRECATED: subdevice is RT capable */ #define SDF_GROUND 0x00100000 /* can do aref=ground */ #define SDF_COMMON 0x00200000 /* can do aref=common */ #define SDF_DIFF 0x00400000 /* can do aref=diff */ diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 19dce2ebfc19..9d7c99394ec6 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -44,6 +44,7 @@ #include <linux/fs.h> #include "comedidev.h" #include <linux/cdev.h> +#include <linux/stat.h> #include <linux/io.h> #include <linux/uaccess.h> @@ -92,6 +93,15 @@ static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int comedi_fasync(int fd, struct file *file, int on); static int is_device_busy(struct comedi_device *dev); +static int resize_async_buffer(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_async *async, unsigned new_size); + +/* declarations for sysfs attribute files */ +static struct device_attribute dev_attr_max_read_buffer_kb; +static struct device_attribute dev_attr_read_buffer_kb; +static struct device_attribute dev_attr_max_write_buffer_kb; +static struct device_attribute dev_attr_write_buffer_kb; #ifdef HAVE_UNLOCKED_IOCTL static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, @@ -277,7 +287,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg) struct comedi_bufconfig bc; struct comedi_async *async; struct comedi_subdevice *s; - int ret = 0; + int retval = 0; if (copy_from_user(&bc, arg, sizeof(struct comedi_bufconfig))) return -EFAULT; @@ -303,37 +313,9 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg) } if (bc.size) { - if (bc.size > async->max_bufsize) - return -EPERM; - - if (s->busy) { - DPRINTK("subdevice is busy, cannot resize buffer\n"); - return -EBUSY; - } - if (async->mmap_count) { - DPRINTK("subdevice is mmapped, cannot resize buffer\n"); - return -EBUSY; - } - - if (!async->prealloc_buf) - return -EINVAL; - - /* make sure buffer is an integral number of pages - * (we round up) */ - bc.size = (bc.size + PAGE_SIZE - 1) & PAGE_MASK; - - ret = comedi_buf_alloc(dev, s, bc.size); - if (ret < 0) - return ret; - - if (s->buf_change) { - ret = s->buf_change(dev, s, bc.size); - if (ret < 0) - return ret; - } - - DPRINTK("comedi%i subd %d buffer resized to %i bytes\n", - dev->minor, bc.subdevice, async->prealloc_bufsz); + retval = resize_async_buffer(dev, s, async, bc.size); + if (retval < 0) + return retval; } bc.size = async->prealloc_bufsz; @@ -746,7 +728,7 @@ static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data /* by default we allow the insn since we don't have checks for * all possible cases yet */ default: - rt_printk("comedi: no check for data length of config insn id " + printk("comedi: no check for data length of config insn id " "%i is implemented.\n" " Add a check to %s in %s.\n" " Assuming n=%i is correct.\n", data[0], __func__, @@ -1097,13 +1079,6 @@ static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file) comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING); -#ifdef CONFIG_COMEDI_RT - if (async->cmd.flags & TRIG_RT) { - if (comedi_switch_to_rt(dev) == 0) - comedi_set_subdevice_runflags(s, SRF_RT, SRF_RT); - } -#endif - ret = s->do_cmd(dev, s); if (ret == 0) return 0; @@ -1237,12 +1212,12 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file return -EINVAL; s = dev->subdevices + arg; - comedi_spin_lock_irqsave(&s->spin_lock, flags); + spin_lock_irqsave(&s->spin_lock, flags); if (s->busy || s->lock) ret = -EBUSY; else s->lock = file; - comedi_spin_unlock_irqrestore(&s->spin_lock, flags); + spin_unlock_irqrestore(&s->spin_lock, flags); if (ret < 0) return ret; @@ -1738,12 +1713,6 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_async *async = s->async; comedi_set_subdevice_runflags(s, SRF_RUNNING, 0); -#ifdef CONFIG_COMEDI_RT - if (comedi_get_subdevice_runflags(s) & SRF_RT) { - comedi_switch_to_non_rt(dev); - comedi_set_subdevice_runflags(s, SRF_RT, 0); - } -#endif if (async) { comedi_reset_async_buf(async); async->inttrig = NULL; @@ -1970,8 +1939,6 @@ static int __init comedi_init(void) } } - comedi_rt_init(); - comedi_register_ioctl32(); return 0; @@ -1992,8 +1959,6 @@ static void __exit comedi_cleanup(void) comedi_proc_cleanup(); - comedi_rt_cleanup(); - comedi_unregister_ioctl32(); } @@ -2002,8 +1967,7 @@ module_exit(comedi_cleanup); void comedi_error(const struct comedi_device *dev, const char *s) { - rt_printk("comedi%d: %s: %s\n", dev->minor, dev->driver->driver_name, - s); + printk("comedi%d: %s: %s\n", dev->minor, dev->driver->driver_name, s); } void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) @@ -2034,34 +1998,18 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) if (async->cb_mask & s->async->events) { if (comedi_get_subdevice_runflags(s) & SRF_USER) { - - if (dev->rt) { -#ifdef CONFIG_COMEDI_RT - /* pend wake up */ - comedi_rt_pend_wakeup(&async->wait_head); -#else - printk - ("BUG: comedi_event() code unreachable\n"); -#endif - } else { - wake_up_interruptible(&async->wait_head); - if (s->subdev_flags & SDF_CMD_READ) { - kill_fasync(&dev->async_queue, SIGIO, - POLL_IN); - } - if (s->subdev_flags & SDF_CMD_WRITE) { - kill_fasync(&dev->async_queue, SIGIO, - POLL_OUT); - } + wake_up_interruptible(&async->wait_head); + if (s->subdev_flags & SDF_CMD_READ) { + kill_fasync(&dev->async_queue, SIGIO, + POLL_IN); + } + if (s->subdev_flags & SDF_CMD_WRITE) { + kill_fasync(&dev->async_queue, SIGIO, + POLL_OUT); } } else { if (async->cb_func) async->cb_func(s->async->events, async->cb_arg); - /* XXX bug here. If subdevice A is rt, and - * subdevice B tries to callback to a normal - * linux kernel function, it will be at the - * wrong priority. Since this isn't very - * common, I'm not going to worry about it. */ } } s->async->events = 0; @@ -2072,10 +2020,10 @@ void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask, { unsigned long flags; - comedi_spin_lock_irqsave(&s->spin_lock, flags); + spin_lock_irqsave(&s->spin_lock, flags); s->runflags &= ~mask; s->runflags |= (bits & mask); - comedi_spin_unlock_irqrestore(&s->spin_lock, flags); + spin_unlock_irqrestore(&s->spin_lock, flags); } unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) @@ -2083,9 +2031,9 @@ unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) unsigned long flags; unsigned runflags; - comedi_spin_lock_irqsave(&s->spin_lock, flags); + spin_lock_irqsave(&s->spin_lock, flags); runflags = s->runflags; - comedi_spin_unlock_irqrestore(&s->spin_lock, flags); + spin_unlock_irqrestore(&s->spin_lock, flags); return runflags; } @@ -2132,6 +2080,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) struct comedi_device_file_info *info; struct device *csdev; unsigned i; + int retval; info = kzalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL); if (info == NULL) @@ -2142,20 +2091,19 @@ int comedi_alloc_board_minor(struct device *hardware_device) return -ENOMEM; } comedi_device_init(info->device); - comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags); + spin_lock_irqsave(&comedi_file_info_table_lock, flags); for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) { if (comedi_file_info_table[i] == NULL) { comedi_file_info_table[i] = info; break; } } - comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); + spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); if (i == COMEDI_NUM_BOARD_MINORS) { comedi_device_cleanup(info->device); kfree(info->device); kfree(info); - rt_printk - ("comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } info->device->minor = i; @@ -2164,7 +2112,35 @@ int comedi_alloc_board_minor(struct device *hardware_device) hardware_device, "comedi%i", i); if (!IS_ERR(csdev)) info->device->class_dev = csdev; - + dev_set_drvdata(csdev, info); + retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_read_buffer_kb.attr.name); + comedi_free_board_minor(i); + return retval; + } + retval = device_create_file(csdev, &dev_attr_read_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_read_buffer_kb.attr.name); + comedi_free_board_minor(i); + return retval; + } + retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_write_buffer_kb.attr.name); + comedi_free_board_minor(i); + return retval; + } + retval = device_create_file(csdev, &dev_attr_write_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_write_buffer_kb.attr.name); + comedi_free_board_minor(i); + return retval; + } return i; } @@ -2174,10 +2150,10 @@ void comedi_free_board_minor(unsigned minor) struct comedi_device_file_info *info; BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS); - comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags); + spin_lock_irqsave(&comedi_file_info_table_lock, flags); info = comedi_file_info_table[minor]; comedi_file_info_table[minor] = NULL; - comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); + spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); if (info) { struct comedi_device *dev = info->device; @@ -2193,12 +2169,14 @@ void comedi_free_board_minor(unsigned minor) } } -int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s) +int comedi_alloc_subdevice_minor(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long flags; struct comedi_device_file_info *info; struct device *csdev; unsigned i; + int retval; info = kmalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL); if (info == NULL) @@ -2206,18 +2184,17 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdev info->device = dev; info->read_subdevice = s; info->write_subdevice = s; - comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags); + spin_lock_irqsave(&comedi_file_info_table_lock, flags); for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) { if (comedi_file_info_table[i] == NULL) { comedi_file_info_table[i] = info; break; } } - comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); + spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); if (i == COMEDI_NUM_MINORS) { kfree(info); - rt_printk - ("comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } s->minor = i; @@ -2227,7 +2204,35 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdev (int)(s - dev->subdevices)); if (!IS_ERR(csdev)) s->class_dev = csdev; - + dev_set_drvdata(csdev, info); + retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_read_buffer_kb.attr.name); + comedi_free_subdevice_minor(s); + return retval; + } + retval = device_create_file(csdev, &dev_attr_read_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_read_buffer_kb.attr.name); + comedi_free_subdevice_minor(s); + return retval; + } + retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_write_buffer_kb.attr.name); + comedi_free_subdevice_minor(s); + return retval; + } + retval = device_create_file(csdev, &dev_attr_write_buffer_kb); + if (retval) { + printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_write_buffer_kb.attr.name); + comedi_free_subdevice_minor(s); + return retval; + } return i; } @@ -2244,10 +2249,10 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s) BUG_ON(s->minor >= COMEDI_NUM_MINORS); BUG_ON(s->minor < COMEDI_FIRST_SUBDEVICE_MINOR); - comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags); + spin_lock_irqsave(&comedi_file_info_table_lock, flags); info = comedi_file_info_table[s->minor]; comedi_file_info_table[s->minor] = NULL; - comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); + spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); if (s->class_dev) { device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, s->minor)); @@ -2262,8 +2267,309 @@ struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor) struct comedi_device_file_info *info; BUG_ON(minor >= COMEDI_NUM_MINORS); - comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags); + spin_lock_irqsave(&comedi_file_info_table_lock, flags); info = comedi_file_info_table[minor]; - comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); + spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); return info; } + +static int resize_async_buffer(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_async *async, unsigned new_size) +{ + int retval; + + if (new_size > async->max_bufsize) + return -EPERM; + + if (s->busy) { + DPRINTK("subdevice is busy, cannot resize buffer\n"); + return -EBUSY; + } + if (async->mmap_count) { + DPRINTK("subdevice is mmapped, cannot resize buffer\n"); + return -EBUSY; + } + + if (!async->prealloc_buf) + return -EINVAL; + + /* make sure buffer is an integral number of pages + * (we round up) */ + new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK; + + retval = comedi_buf_alloc(dev, s, new_size); + if (retval < 0) + return retval; + + if (s->buf_change) { + retval = s->buf_change(dev, s, new_size); + if (retval < 0) + return retval; + } + + DPRINTK("comedi%i subd %d buffer resized to %i bytes\n", + dev->minor, s - dev->subdevices, async->prealloc_bufsz); + return 0; +} + +/* sysfs attribute files */ + +static const unsigned bytes_per_kibi = 1024; + +static ssize_t show_max_read_buffer_kb(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t retval; + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned max_buffer_size_kb = 0; + struct comedi_subdevice *const read_subdevice = + comedi_get_read_subdevice(info); + + mutex_lock(&info->device->mutex); + if (read_subdevice && + (read_subdevice->subdev_flags & SDF_CMD_READ) && + read_subdevice->async) { + max_buffer_size_kb = read_subdevice->async->max_bufsize / + bytes_per_kibi; + } + retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); + mutex_unlock(&info->device->mutex); + + return retval; +} + +static ssize_t store_max_read_buffer_kb(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned long new_max_size_kb; + uint64_t new_max_size; + struct comedi_subdevice *const read_subdevice = + comedi_get_read_subdevice(info); + + if (strict_strtoul(buf, 10, &new_max_size_kb)) + return -EINVAL; + if (new_max_size_kb != (uint32_t)new_max_size_kb) + return -EINVAL; + new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi; + if (new_max_size != (uint32_t)new_max_size) + return -EINVAL; + + mutex_lock(&info->device->mutex); + if (read_subdevice == NULL || + (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 || + read_subdevice->async == NULL) { + mutex_unlock(&info->device->mutex); + return -EINVAL; + } + read_subdevice->async->max_bufsize = new_max_size; + mutex_unlock(&info->device->mutex); + + return count; +} + +static struct device_attribute dev_attr_max_read_buffer_kb = { + .attr = { + .name = "max_read_buffer_kb", + .mode = S_IRUGO | S_IWUSR + }, + .show = &show_max_read_buffer_kb, + .store = &store_max_read_buffer_kb +}; + +static ssize_t show_read_buffer_kb(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t retval; + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned buffer_size_kb = 0; + struct comedi_subdevice *const read_subdevice = + comedi_get_read_subdevice(info); + + mutex_lock(&info->device->mutex); + if (read_subdevice && + (read_subdevice->subdev_flags & SDF_CMD_READ) && + read_subdevice->async) { + buffer_size_kb = read_subdevice->async->prealloc_bufsz / + bytes_per_kibi; + } + retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); + mutex_unlock(&info->device->mutex); + + return retval; +} + +static ssize_t store_read_buffer_kb(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned long new_size_kb; + uint64_t new_size; + int retval; + struct comedi_subdevice *const read_subdevice = + comedi_get_read_subdevice(info); + + if (strict_strtoul(buf, 10, &new_size_kb)) + return -EINVAL; + if (new_size_kb != (uint32_t)new_size_kb) + return -EINVAL; + new_size = ((uint64_t)new_size_kb) * bytes_per_kibi; + if (new_size != (uint32_t)new_size) + return -EINVAL; + + mutex_lock(&info->device->mutex); + if (read_subdevice == NULL || + (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 || + read_subdevice->async == NULL) { + mutex_unlock(&info->device->mutex); + return -EINVAL; + } + retval = resize_async_buffer(info->device, read_subdevice, + read_subdevice->async, new_size); + mutex_unlock(&info->device->mutex); + + if (retval < 0) + return retval; + return count; +} + +static struct device_attribute dev_attr_read_buffer_kb = { + .attr = { + .name = "read_buffer_kb", + .mode = S_IRUGO | S_IWUSR | S_IWGRP + }, + .show = &show_read_buffer_kb, + .store = &store_read_buffer_kb +}; + +static ssize_t show_max_write_buffer_kb(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t retval; + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned max_buffer_size_kb = 0; + struct comedi_subdevice *const write_subdevice = + comedi_get_write_subdevice(info); + + mutex_lock(&info->device->mutex); + if (write_subdevice && + (write_subdevice->subdev_flags & SDF_CMD_WRITE) && + write_subdevice->async) { + max_buffer_size_kb = write_subdevice->async->max_bufsize / + bytes_per_kibi; + } + retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); + mutex_unlock(&info->device->mutex); + + return retval; +} + +static ssize_t store_max_write_buffer_kb(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned long new_max_size_kb; + uint64_t new_max_size; + struct comedi_subdevice *const write_subdevice = + comedi_get_write_subdevice(info); + + if (strict_strtoul(buf, 10, &new_max_size_kb)) + return -EINVAL; + if (new_max_size_kb != (uint32_t)new_max_size_kb) + return -EINVAL; + new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi; + if (new_max_size != (uint32_t)new_max_size) + return -EINVAL; + + mutex_lock(&info->device->mutex); + if (write_subdevice == NULL || + (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 || + write_subdevice->async == NULL) { + mutex_unlock(&info->device->mutex); + return -EINVAL; + } + write_subdevice->async->max_bufsize = new_max_size; + mutex_unlock(&info->device->mutex); + + return count; +} + +static struct device_attribute dev_attr_max_write_buffer_kb = { + .attr = { + .name = "max_write_buffer_kb", + .mode = S_IRUGO | S_IWUSR + }, + .show = &show_max_write_buffer_kb, + .store = &store_max_write_buffer_kb +}; + +static ssize_t show_write_buffer_kb(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t retval; + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned buffer_size_kb = 0; + struct comedi_subdevice *const write_subdevice = + comedi_get_write_subdevice(info); + + mutex_lock(&info->device->mutex); + if (write_subdevice && + (write_subdevice->subdev_flags & SDF_CMD_WRITE) && + write_subdevice->async) { + buffer_size_kb = write_subdevice->async->prealloc_bufsz / + bytes_per_kibi; + } + retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); + mutex_unlock(&info->device->mutex); + + return retval; +} + +static ssize_t store_write_buffer_kb(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct comedi_device_file_info *info = dev_get_drvdata(dev); + unsigned long new_size_kb; + uint64_t new_size; + int retval; + struct comedi_subdevice *const write_subdevice = + comedi_get_write_subdevice(info); + + if (strict_strtoul(buf, 10, &new_size_kb)) + return -EINVAL; + if (new_size_kb != (uint32_t)new_size_kb) + return -EINVAL; + new_size = ((uint64_t)new_size_kb) * bytes_per_kibi; + if (new_size != (uint32_t)new_size) + return -EINVAL; + + mutex_lock(&info->device->mutex); + if (write_subdevice == NULL || + (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 || + write_subdevice->async == NULL) { + mutex_unlock(&info->device->mutex); + return -EINVAL; + } + retval = resize_async_buffer(info->device, write_subdevice, + write_subdevice->async, new_size); + mutex_unlock(&info->device->mutex); + + if (retval < 0) + return retval; + return count; +} + +static struct device_attribute dev_attr_write_buffer_kb = { + .attr = { + .name = "write_buffer_kb", + .mode = S_IRUGO | S_IWUSR | S_IWGRP + }, + .show = &show_write_buffer_kb, + .store = &store_write_buffer_kb +}; diff --git a/drivers/staging/comedi/comedi_ksyms.c b/drivers/staging/comedi/comedi_ksyms.c index 6e6fb979ef54..a732e342dcd2 100644 --- a/drivers/staging/comedi/comedi_ksyms.c +++ b/drivers/staging/comedi/comedi_ksyms.c @@ -46,13 +46,6 @@ EXPORT_SYMBOL(range_bipolar2_5); EXPORT_SYMBOL(range_unipolar10); EXPORT_SYMBOL(range_unipolar5); EXPORT_SYMBOL(range_unknown); -#ifdef CONFIG_COMEDI_RT -EXPORT_SYMBOL(comedi_free_irq); -EXPORT_SYMBOL(comedi_request_irq); -EXPORT_SYMBOL(comedi_switch_to_rt); -EXPORT_SYMBOL(comedi_switch_to_non_rt); -EXPORT_SYMBOL(rt_pend_call); -#endif #ifdef CONFIG_COMEDI_DEBUG EXPORT_SYMBOL(comedi_debug); #endif diff --git a/drivers/staging/comedi/comedi_rt.h b/drivers/staging/comedi/comedi_rt.h deleted file mode 100644 index 169ca963312a..000000000000 --- a/drivers/staging/comedi/comedi_rt.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - module/comedi_rt.h - header file for real-time structures, variables, and constants - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef _COMEDI_RT_H -#define _COMEDI_RT_H - -#ifndef _COMEDIDEV_H -#error comedi_rt.h should only be included by comedidev.h -#endif - -#include <linux/kdev_t.h> -#include <linux/slab.h> -#include <linux/errno.h> -#include <linux/spinlock.h> -#include <linux/delay.h> - -#ifdef CONFIG_COMEDI_RT - -#ifdef CONFIG_COMEDI_RTAI -#include <rtai.h> -#include <rtai_sched.h> -#include <rtai_version.h> -#endif -#ifdef CONFIG_COMEDI_RTL -#include <rtl_core.h> -#include <rtl_time.h> -/* #ifdef RTLINUX_VERSION_CODE */ -#include <rtl_sync.h> -/* #endif */ -#define rt_printk rtl_printf -#endif -#ifdef CONFIG_COMEDI_FUSION -#define rt_printk(format, args...) printk(format , ## args) -#endif /* CONFIG_COMEDI_FUSION */ -#ifdef CONFIG_PRIORITY_IRQ -#define rt_printk printk -#endif - -int comedi_request_irq(unsigned int irq, irqreturn_t(*handler) (int, - void *PT_REGS_ARG), unsigned long flags, const char *device, - struct comedi_device *dev_id); -void comedi_free_irq(unsigned int irq, struct comedi_device *dev_id); -void comedi_rt_init(void); -void comedi_rt_cleanup(void); -int comedi_switch_to_rt(struct comedi_device *dev); -void comedi_switch_to_non_rt(struct comedi_device *dev); -void comedi_rt_pend_wakeup(wait_queue_head_t *q); -extern int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1, - void *arg2); - -#else - -#define comedi_request_irq(a, b, c, d, e) request_irq(a, b, c, d, e) -#define comedi_free_irq(a, b) free_irq(a, b) -#define comedi_rt_init() do {} while (0) -#define comedi_rt_cleanup() do {} while (0) -#define comedi_switch_to_rt(a) (-1) -#define comedi_switch_to_non_rt(a) do {} while (0) -#define comedi_rt_pend_wakeup(a) do {} while (0) - -#define rt_printk(format, args...) printk(format, ##args) - -#endif - -/* Define a spin_lock_irqsave function that will work with rt or without. - * Use inline functions instead of just macros to enforce some type checking. - */ -#define comedi_spin_lock_irqsave(lock_ptr, flags) \ - (flags = __comedi_spin_lock_irqsave(lock_ptr)) - -static inline unsigned long __comedi_spin_lock_irqsave(spinlock_t *lock_ptr) -{ - unsigned long flags; - -#if defined(CONFIG_COMEDI_RTAI) - flags = rt_spin_lock_irqsave(lock_ptr); - -#elif defined(CONFIG_COMEDI_RTL) - rtl_spin_lock_irqsave(lock_ptr, flags); - -#elif defined(CONFIG_COMEDI_RTL_V1) - rtl_spin_lock_irqsave(lock_ptr, flags); - -#elif defined(CONFIG_COMEDI_FUSION) - rthal_spin_lock_irqsave(lock_ptr, flags); -#else - spin_lock_irqsave(lock_ptr, flags); - -#endif - - return flags; -} - -static inline void comedi_spin_unlock_irqrestore(spinlock_t *lock_ptr, - unsigned long flags) -{ - -#if defined(CONFIG_COMEDI_RTAI) - rt_spin_unlock_irqrestore(flags, lock_ptr); - -#elif defined(CONFIG_COMEDI_RTL) - rtl_spin_unlock_irqrestore(lock_ptr, flags); - -#elif defined(CONFIG_COMEDI_RTL_V1) - rtl_spin_unlock_irqrestore(lock_ptr, flags); -#elif defined(CONFIG_COMEDI_FUSION) - rthal_spin_unlock_irqrestore(lock_ptr, flags); -#else - spin_unlock_irqrestore(lock_ptr, flags); - -#endif - -} - -/* define a RT safe udelay */ -static inline void comedi_udelay(unsigned int usec) -{ -#if defined(CONFIG_COMEDI_RTAI) - static const int nanosec_per_usec = 1000; - rt_busy_sleep(usec * nanosec_per_usec); -#elif defined(CONFIG_COMEDI_RTL) - static const int nanosec_per_usec = 1000; - rtl_delay(usec * nanosec_per_usec); -#else - udelay(usec); -#endif -} - -#endif diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ea319360ae68..89af44a788df 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -28,6 +28,7 @@ #include <linux/module.h> #include <linux/kdev_t.h> #include <linux/slab.h> +#include <linux/delay.h> #include <linux/errno.h> #include <linux/spinlock.h> #include <linux/mutex.h> @@ -35,10 +36,10 @@ #include <linux/mm.h> #include <linux/init.h> #include <linux/vmalloc.h> -#include "interrupt.h" #include <linux/dma-mapping.h> #include <linux/uaccess.h> #include <linux/io.h> +#include <linux/timer.h> #include "comedi.h" @@ -264,7 +265,6 @@ struct comedi_device { const char *board_name; const void *board_ptr; int attached; - int rt; spinlock_t spinlock; struct mutex mutex; int in_request_module; @@ -524,6 +524,17 @@ struct usb_device; /* forward declaration */ int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name); void comedi_usb_auto_unconfig(struct usb_device *usbdev); -#include "comedi_rt.h" +#ifdef CONFIG_COMEDI_PCI_DRIVERS + #define CONFIG_COMEDI_PCI +#endif +#ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE + #define CONFIG_COMEDI_PCI +#endif +#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS + #define CONFIG_COMEDI_PCMCIA +#endif +#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE + #define CONFIG_COMEDI_PCMCIA +#endif #endif /* _COMEDIDEV_H */ diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 6e13e450dc73..42a02571ff1b 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -198,7 +198,7 @@ int comedi_driver_unregister(struct comedi_driver *driver) struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i); struct comedi_device *dev; - if(dev_file_info == NULL) continue; + if (dev_file_info == NULL) continue; dev = dev_file_info->device; mutex_lock(&dev->mutex); @@ -554,7 +554,7 @@ unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes block_size = num_bytes - count; if (block_size < 0) { - rt_printk("%s: %s: bug! block_size is negative\n", + printk("%s: %s: bug! block_size is negative\n", __FILE__, __func__); break; } @@ -633,8 +633,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) { if ((int)(async->buf_write_count + nbytes - async->buf_write_alloc_count) > 0) { - rt_printk - ("comedi: attempted to write-free more bytes than have been write-allocated.\n"); + printk("comedi: attempted to write-free more bytes than have been write-allocated.\n"); nbytes = async->buf_write_alloc_count - async->buf_write_count; } async->buf_write_count += nbytes; @@ -667,8 +666,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) smp_mb(); if ((int)(async->buf_read_count + nbytes - async->buf_read_alloc_count) > 0) { - rt_printk - ("comedi: attempted to read-free more bytes than have been read-allocated.\n"); + printk("comedi: attempted to read-free more bytes than have been read-allocated.\n"); nbytes = async->buf_read_alloc_count - async->buf_read_count; } async->buf_read_count += nbytes; @@ -801,7 +799,7 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c } minor = comedi_alloc_board_minor(hardware_device); - if(minor < 0) return minor; + if (minor < 0) return minor; private_data = kmalloc(sizeof(unsigned), GFP_KERNEL); if (private_data == NULL) { @@ -824,7 +822,7 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c mutex_unlock(&dev_file_info->device->mutex); cleanup: - if(retval < 0) + if (retval < 0) { kfree(private_data); comedi_free_board_minor(minor); @@ -835,7 +833,7 @@ cleanup: void comedi_auto_unconfig(struct device *hardware_device) { unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device); - if(minor == NULL) return; + if (minor == NULL) return; BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS); @@ -853,7 +851,8 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name) /* pci slot */ options[1] = PCI_SLOT(pcidev->devfn); - return comedi_auto_config(&pcidev->dev, board_name, options, sizeof(options) / sizeof(options[0])); + return comedi_auto_config(&pcidev->dev, board_name, + options, ARRAY_SIZE(options)); } void comedi_pci_auto_unconfig(struct pci_dev *pcidev) diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h index 08a11a5a16e6..ad467ac290a3 100644 --- a/drivers/staging/comedi/drivers/8253.h +++ b/drivers/staging/comedi/drivers/8253.h @@ -24,11 +24,7 @@ #ifndef _8253_H #define _8253_H -#ifndef CMDTEST -#include "../comedi.h" -#else #include "../comedi.h" -#endif #define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div @@ -205,7 +201,7 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, } *nanosec = div1 * div2 * i8253_osc_base; - *d1 = div1 & 0xffff; // masking is done since counter maps zero to 0x10000 + *d1 = div1 & 0xffff; /* masking is done since counter maps zero to 0x10000 */ *d2 = div2 & 0xffff; return; } @@ -247,12 +243,12 @@ static inline int i8254_load(unsigned long base_address, unsigned int regshift, return -1; byte = counter_number << 6; - byte |= 0x30; // load low then high byte - byte |= (mode << 1); // set counter mode + byte |= 0x30; /* load low then high byte */ + byte |= (mode << 1); /* set counter mode */ outb(byte, base_address + (i8254_control_reg << regshift)); - byte = count & 0xff; // lsb of counter value + byte = count & 0xff; /* lsb of counter value */ outb(byte, base_address + (counter_number << regshift)); - byte = (count >> 8) & 0xff; // msb of counter value + byte = (count >> 8) & 0xff; /* msb of counter value */ outb(byte, base_address + (counter_number << regshift)); return 0; @@ -273,12 +269,12 @@ static inline int i8254_mm_load(void *base_address, unsigned int regshift, return -1; byte = counter_number << 6; - byte |= 0x30; // load low then high byte - byte |= (mode << 1); // set counter mode + byte |= 0x30; /* load low then high byte */ + byte |= (mode << 1); /* set counter mode */ writeb(byte, base_address + (i8254_control_reg << regshift)); - byte = count & 0xff; // lsb of counter value + byte = count & 0xff; /* lsb of counter value */ writeb(byte, base_address + (counter_number << regshift)); - byte = (count >> 8) & 0xff; // msb of counter value + byte = (count >> 8) & 0xff; /* msb of counter value */ writeb(byte, base_address + (counter_number << regshift)); return 0; @@ -294,13 +290,13 @@ static inline int i8254_read(unsigned long base_address, unsigned int regshift, if (counter_number > 2) return -1; - // latch counter + /* latch counter */ byte = counter_number << 6; outb(byte, base_address + (i8254_control_reg << regshift)); - // read lsb + /* read lsb */ ret = inb(base_address + (counter_number << regshift)); - // read msb + /* read msb */ ret += inb(base_address + (counter_number << regshift)) << 8; return ret; @@ -315,13 +311,13 @@ static inline int i8254_mm_read(void *base_address, unsigned int regshift, if (counter_number > 2) return -1; - // latch counter + /* latch counter */ byte = counter_number << 6; writeb(byte, base_address + (i8254_control_reg << regshift)); - // read lsb + /* read lsb */ ret = readb(base_address + (counter_number << regshift)); - // read msb + /* read msb */ ret += readb(base_address + (counter_number << regshift)) << 8; return ret; @@ -336,9 +332,9 @@ static inline void i8254_write(unsigned long base_address, if (counter_number > 2) return; - byte = count & 0xff; // lsb of counter value + byte = count & 0xff; /* lsb of counter value */ outb(byte, base_address + (counter_number << regshift)); - byte = (count >> 8) & 0xff; // msb of counter value + byte = (count >> 8) & 0xff; /* msb of counter value */ outb(byte, base_address + (counter_number << regshift)); } @@ -350,9 +346,9 @@ static inline void i8254_mm_write(void *base_address, if (counter_number > 2) return; - byte = count & 0xff; // lsb of counter value + byte = count & 0xff; /* lsb of counter value */ writeb(byte, base_address + (counter_number << regshift)); - byte = (count >> 8) & 0xff; // msb of counter value + byte = (count >> 8) & 0xff; /* msb of counter value */ writeb(byte, base_address + (counter_number << regshift)); } @@ -374,8 +370,8 @@ static inline int i8254_set_mode(unsigned long base_address, return -1; byte = counter_number << 6; - byte |= 0x30; // load low then high byte - byte |= mode; // set counter mode and BCD|binary + byte |= 0x30; /* load low then high byte */ + byte |= mode; /* set counter mode and BCD|binary */ outb(byte, base_address + (i8254_control_reg << regshift)); return 0; @@ -392,8 +388,8 @@ static inline int i8254_mm_set_mode(void *base_address, return -1; byte = counter_number << 6; - byte |= 0x30; // load low then high byte - byte |= mode; // set counter mode and BCD|binary + byte |= 0x30; /* load low then high byte */ + byte |= mode; /* set counter mode and BCD|binary */ writeb(byte, base_address + (i8254_control_reg << regshift)); return 0; diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 0369c7c84ac5..bdc3957bceb8 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -108,10 +108,10 @@ struct subdev_8255_struct { static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it); static int dev_8255_detach(struct comedi_device *dev); static struct comedi_driver driver_8255 = { - driver_name:"8255", - module:THIS_MODULE, - attach:dev_8255_attach, - detach:dev_8255_detach, + .driver_name = "8255", + .module = THIS_MODULE, + .attach = dev_8255_attach, + .detach = dev_8255_detach, }; COMEDI_INITCLEANUP(driver_8255); @@ -144,7 +144,7 @@ static int subdev_8255_cb(int dir, int port, int data, unsigned long arg) } static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -169,7 +169,7 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice * } static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; unsigned int bits; @@ -223,7 +223,7 @@ static void do_config(struct comedi_device *dev, struct comedi_subdevice * s) } static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -361,8 +361,10 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s, void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s) { if (s->private) { - if (subdevpriv->have_irq) { - } + /* this test does nothing, so comment it out + * if (subdevpriv->have_irq) { + * } + */ kfree(s->private); } @@ -394,7 +396,8 @@ static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * return -EINVAL; } - if ((ret = alloc_subdevices(dev, i)) < 0) + ret = alloc_subdevices(dev, i); + if (ret < 0) return ret; for (i = 0; i < dev->n_subdevices; i++) { diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 979311b99275..5457c6b2d22e 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -28,16 +28,16 @@ #if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE) -int subdev_8255_init(struct comedi_device * dev, struct comedi_subdevice * s, +int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), unsigned long arg); -int subdev_8255_init_irq(struct comedi_device * dev, struct comedi_subdevice * s, +int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), unsigned long arg); -void subdev_8255_cleanup(struct comedi_device * dev, struct comedi_subdevice * s); -void subdev_8255_interrupt(struct comedi_device * dev, struct comedi_subdevice * s); +void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s); +void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice *s); #else -static inline int subdev_8255_init(struct comedi_device * dev, struct comedi_subdevice * s, +static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, void *x, unsigned long y) { printk("8255 support not configured -- disabling subdevice\n"); @@ -47,8 +47,8 @@ static inline int subdev_8255_init(struct comedi_device * dev, struct comedi_sub return 0; } -static inline void subdev_8255_cleanup(struct comedi_device * dev, - struct comedi_subdevice * s) +static inline void subdev_8255_cleanup(struct comedi_device *dev, + struct comedi_subdevice *s) { } diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 12d6e4312f3a..df2854d543cc 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_COMEDI) += comedi_fc.o obj-$(CONFIG_COMEDI) += comedi_bond.o obj-$(CONFIG_COMEDI) += comedi_test.o obj-$(CONFIG_COMEDI) += comedi_parport.o +obj-$(CONFIG_COMEDI) += pcm_common.o # Comedi PCI drivers obj-$(CONFIG_COMEDI_PCI_DRIVERS) += 8255.o @@ -125,6 +126,8 @@ obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += ni_mio_cs.o obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += quatech_daqp_cs.o # Comedi USB drivers +obj-$(CONFIG_COMEDI_USB_DRIVERS) += dt9812.o obj-$(CONFIG_COMEDI_USB_DRIVERS) += usbdux.o obj-$(CONFIG_COMEDI_USB_DRIVERS) += usbduxfast.o -obj-$(CONFIG_COMEDI_USB_DRIVERS) += dt9812.o +obj-$(CONFIG_COMEDI_USB_DRIVERS) += vmk80xx.o + diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c index b21320f0959f..5b986aa7398b 100644 --- a/drivers/staging/comedi/drivers/acl7225b.c +++ b/drivers/staging/comedi/drivers/acl7225b.c @@ -26,8 +26,8 @@ static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * static int acl7225b_detach(struct comedi_device *dev); struct boardtype { - const char *name; // driver name - int io_range; // len of I/O space + const char *name; /* driver name */ + int io_range; /* len of I/O space */ }; static const struct boardtype boardtypes[] = { @@ -39,19 +39,19 @@ static const struct boardtype boardtypes[] = { #define this_board ((const struct boardtype *)dev->board_ptr) static struct comedi_driver driver_acl7225b = { - driver_name:"acl7225b", - module:THIS_MODULE, - attach:acl7225b_attach, - detach:acl7225b_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct boardtype), + .driver_name = "acl7225b", + .module = THIS_MODULE, + .attach = acl7225b_attach, + .detach = acl7225b_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct boardtype), }; COMEDI_INITCLEANUP(driver_acl7225b); static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -72,7 +72,7 @@ static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * } static int acl7225b_di_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c index c96aee09e1b6..60213d292a5f 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c @@ -23,16 +23,16 @@ /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitTimer | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TimerNbr, | -| BYTE_ b_TimerMode, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TimerNbr, | +| unsigned char_ b_TimerMode, | | ULONG_ ul_ReloadValue, | -| BYTE_ b_InputClockSelection, | -| BYTE_ b_InputClockLevel, | -| BYTE_ b_OutputLevel, | -| BYTE_ b_HardwareGateLevel) -INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, +| unsigned char_ b_InputClockSelection, | +| unsigned char_ b_InputClockLevel, | +| unsigned char_ b_OutputLevel, | +| unsigned char_ b_HardwareGateLevel) +int i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ @@ -148,13 +148,13 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, | +--------------------------------+------------------------------------+ | | | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Module number to | +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_TimerNbr : Timer number to | +| unsigned char_ b_TimerNbr : Timer number to | | configure (0 to 2) | -| BYTE_ b_TimerMode : Timer mode selection | +| unsigned char_ b_TimerMode : Timer mode selection | | (0 to 5) | | 0: Interrupt on terminal| | count | @@ -173,21 +173,21 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, | or division factor | | See timer mode | | description table. | -| BYTE_ b_InputClockSelection : Selection from input | +| unsigned char_ b_InputClockSelection : Selection from input | | timer clock. | | See input clock | | selection table. | -| BYTE_ b_InputClockLevel : Selection from input | +| unsigned char_ b_InputClockLevel : Selection from input | | clock level. | | 0 : Low active | | (Input inverted) | | 1 : High active | -| BYTE_ b_OutputLevel, : Selection from output | +| unsigned char_ b_OutputLevel, : Selection from output | | clock level. | | 0 : Low active | | 1 : High active | | (Output inverted) | -| BYTE_ b_HardwareGateLevel : Selection from | +| unsigned char_ b_HardwareGateLevel : Selection from | | hardware gate level. | | 0 : Low active | | (Input inverted) | @@ -195,14 +195,14 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, | If you will not used | | the hardware gate set | | this value to 0. -|b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec); - b_TimerMode = (BYTE) data[0]; - ul_ReloadValue = (ULONG) data[1]; - b_InputClockSelection =(BYTE) data[2]; - b_InputClockLevel =(BYTE) data[3]; - b_OutputLevel =(BYTE) data[4]; - b_HardwareGateLevel =(BYTE) data[5]; +|b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); + b_TimerMode = (unsigned char) data[0]; + ul_ReloadValue = (unsigned int) data[1]; + b_InputClockSelection =(unsigned char) data[2]; + b_InputClockLevel =(unsigned char) data[3]; + b_OutputLevel =(unsigned char) data[4]; + b_HardwareGateLevel =(unsigned char) data[5]; +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -219,33 +219,33 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr; - BYTE b_TimerNbr; - BYTE b_TimerMode; - ULONG ul_ReloadValue; - BYTE b_InputClockSelection; - BYTE b_InputClockLevel; - BYTE b_OutputLevel; - BYTE b_HardwareGateLevel; + int i_ReturnValue = 0; + unsigned char b_ModulNbr; + unsigned char b_TimerNbr; + unsigned char b_TimerMode; + unsigned int ul_ReloadValue; + unsigned char b_InputClockSelection; + unsigned char b_InputClockLevel; + unsigned char b_OutputLevel; + unsigned char b_HardwareGateLevel; - //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz - DWORD dw_Test = 0; - //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz + /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ + unsigned int dw_Test = 0; + /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec); - b_TimerMode = (BYTE) data[0]; - ul_ReloadValue = (ULONG) data[1]; - b_InputClockSelection = (BYTE) data[2]; - b_InputClockLevel = (BYTE) data[3]; - b_OutputLevel = (BYTE) data[4]; - b_HardwareGateLevel = (BYTE) data[5]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); + b_TimerMode = (unsigned char) data[0]; + ul_ReloadValue = (unsigned int) data[1]; + b_InputClockSelection = (unsigned char) data[2]; + b_InputClockLevel = (unsigned char) data[3]; + b_OutputLevel = (unsigned char) data[4]; + b_HardwareGateLevel = (unsigned char) data[5]; /* Test the module number */ if (b_ModulNbr < 4) { @@ -256,7 +256,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub if (b_TimerNbr <= 2) { /* Test the timer mode */ if (b_TimerMode <= 5) { - //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz + /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ /* Test te imput clock selection */ /* if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) || @@ -271,11 +271,11 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub ((b_InputClockSelection == APCI1710_PCI_BUS_CLOCK) || (b_InputClockSelection == APCI1710_FRONT_CONNECTOR_INPUT) || (b_InputClockSelection == APCI1710_10MHZ)))) { - //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz + /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ if (((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) >= 0x3131)) || (b_InputClockSelection != APCI1710_10MHZ)) { - //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz + /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ /* Test the input clock level selection */ if ((b_InputClockLevel == 0) || @@ -284,7 +284,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) { /* Test the hardware gate level selection */ if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) { - //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz + /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ /* Test if version > 1.1 and clock selection = 10MHz */ if ((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) > 0x3131)) { /* Test if 40MHz quartz on board */ @@ -297,7 +297,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub /* Test if detection OK */ if (dw_Test == 1) { - //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz + /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ /* Initialisation OK */ devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init = 1; @@ -314,12 +314,12 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_HardwareGateLevel = b_HardwareGateLevel; /* Set the configuration word and disable the timer */ - //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz + /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ /* devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. - dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel << 0) & 0x1) | + dw_ConfigurationWord = (unsigned int) (((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x10)); @@ -329,40 +329,40 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub b_InputClockSelection = 2; } - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = (DWORD)(((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30)); - //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz + devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = (unsigned int)(((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30)); + /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); /* Initialise the 82X54 Timer */ - outl((DWORD) b_TimerMode, devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); + outl((unsigned int) b_TimerMode, devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); /* Write the reload value */ outl(ul_ReloadValue, devpriv->s_BoardInfos.ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz - } // if (dw_Test == 1) + /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ + } /* if (dw_Test == 1) */ else { /* Input timer clock selection is wrong */ i_ReturnValue = -6; - } // if (dw_Test == 1) - //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz - } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) + } /* if (dw_Test == 1) */ + /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ + } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */ else { /* Selection from hardware gate level is wrong */ DPRINTK("Selection from hardware gate level is wrong\n"); i_ReturnValue = -9; - } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) - } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) + } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */ + } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */ else { /* Selection from output clock level is wrong */ DPRINTK("Selection from output clock level is wrong\n"); i_ReturnValue = -8; - } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) - } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) + } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */ + } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */ else { /* Selection from input clock level is wrong */ DPRINTK("Selection from input clock level is wrong\n"); i_ReturnValue = -7; - } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) + } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */ } else { /* Input timer clock selection is wrong */ DPRINTK("Input timer clock selection is wrong\n"); @@ -373,18 +373,18 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub DPRINTK("Input timer clock selection is wrong\n"); i_ReturnValue = -6; } - } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) + } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */ else { /* Timer mode selection is wrong */ DPRINTK("Timer mode selection is wrong\n"); i_ReturnValue = -5; - } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */ + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ else { /* Timer selection wrong */ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ DPRINTK("The module is not a TIMER module\n"); @@ -396,17 +396,17 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableTimer | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TimerNbr, | -| BYTE_ b_InterruptEnable) -INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct comedi_subdevice *s, +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TimerNbr, | +| unsigned char_ b_InterruptEnable) +int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Enable OR Disable the Timer (b_TimerNbr) from selected module | @@ -416,22 +416,22 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct come | generate a interrupt after the timer value reach | | the zero. See function "i_APCI1710_SetBoardIntRoutineX"| +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | -| BYTE_ b_TimerNbr : Timer number to enable | +| unsigned char_ b_TimerNbr : Timer number to enable | | (0 to 2) | -| BYTE_ b_InterruptEnable : Enable or disable the | +| unsigned char_ b_InterruptEnable : Enable or disable the | | timer interrupt. | | APCI1710_ENABLE : | | Enable the timer interrupt | | APCI1710_DISABLE : | | Disable the timer interrupt| i_ReturnValue=insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec); - b_ActionType = (BYTE) data[0]; // enable disable + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); + b_ActionType = (unsigned char) data[0]; /* enable disable */ +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -448,21 +448,21 @@ i_ReturnValue=insn->n; +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, - struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_DummyRead; - BYTE b_ModulNbr; - BYTE b_TimerNbr; - BYTE b_ActionType; - BYTE b_InterruptEnable; + int i_ReturnValue = 0; + unsigned int dw_DummyRead; + unsigned char b_ModulNbr; + unsigned char b_TimerNbr; + unsigned char b_ActionType; + unsigned char b_InterruptEnable; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec); - b_ActionType = (BYTE) data[0]; // enable disable + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); + b_ActionType = (unsigned char) data[0]; /* enable disable */ /* Test the module number */ if (b_ModulNbr < 4) { @@ -475,7 +475,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, switch (b_ActionType) { case APCI1710_ENABLE: - b_InterruptEnable = (BYTE) data[1]; + b_InterruptEnable = (unsigned char) data[1]; /* Test the interrupt selection */ if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) { @@ -487,9 +487,9 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord | 0x8; outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ - } // if (b_InterruptEnable == APCI1710_ENABLE) + } /* if (b_InterruptEnable == APCI1710_ENABLE) */ else { /* Disable the interrupt */ devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord & 0xF7; @@ -498,7 +498,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, /* Save the interrupt flag */ devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr)); - } // if (b_InterruptEnable == APCI1710_ENABLE) + } /* if (b_InterruptEnable == APCI1710_ENABLE) */ /* Test if error occur */ if (i_ReturnValue >= 0) { @@ -530,7 +530,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, /* Disable the timer */ outl(0, devpriv->s_BoardInfos.ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); break; - } // Switch end + } /* Switch end */ } else { /* Timer not initialised see function */ DPRINTK ("Timer not initialised see function\n"); @@ -540,7 +540,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, /* Timer selection wrong */ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ DPRINTK("The module is not a TIMER module\n"); @@ -552,24 +552,24 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadAllTimerValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | | PULONG_ pul_TimerValueArray) -INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_subdevice *s, +int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Return the all timer values from selected timer | | module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_TimerValueArray : Timer value array. | @@ -590,16 +590,16 @@ INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_sub +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr, b_ReadType; - PULONG pul_TimerValueArray; + int i_ReturnValue = 0; + unsigned char b_ModulNbr, b_ReadType; + unsigned int *pul_TimerValueArray; b_ModulNbr = CR_AREF(insn->chanspec); b_ReadType = CR_CHAN(insn->chanspec); - pul_TimerValueArray = (PULONG) data; + pul_TimerValueArray = (unsigned int *) data; i_ReturnValue = insn->n; switch (b_ReadType) { @@ -662,8 +662,8 @@ INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_su i_ReturnValue = -2; } - } // End of Switch - return (i_ReturnValue); + } /* End of Switch */ + return i_ReturnValue; } /* @@ -681,11 +681,11 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_BitsType; - INT i_ReturnValue = 0; + unsigned char b_BitsType; + int i_ReturnValue = 0; b_BitsType = data[0]; printk("\n82X54"); @@ -693,30 +693,30 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice switch (b_BitsType) { case APCI1710_TIMER_READVALUE: i_ReturnValue = i_APCI1710_ReadTimerValue(dev, - (BYTE)CR_AREF(insn->chanspec), - (BYTE)CR_CHAN(insn->chanspec), - (PULONG) & data[0]); + (unsigned char)CR_AREF(insn->chanspec), + (unsigned char)CR_CHAN(insn->chanspec), + (unsigned int *) &data[0]); break; case APCI1710_TIMER_GETOUTPUTLEVEL: i_ReturnValue = i_APCI1710_GetTimerOutputLevel(dev, - (BYTE)CR_AREF(insn->chanspec), - (BYTE)CR_CHAN(insn->chanspec), - (PBYTE) &data[0]); + (unsigned char)CR_AREF(insn->chanspec), + (unsigned char)CR_CHAN(insn->chanspec), + (unsigned char *) &data[0]); break; case APCI1710_TIMER_GETPROGRESSSTATUS: i_ReturnValue = i_APCI1710_GetTimerProgressStatus(dev, - (BYTE)CR_AREF(insn->chanspec), - (BYTE)CR_CHAN(insn->chanspec), - (PBYTE)&data[0]); + (unsigned char)CR_AREF(insn->chanspec), + (unsigned char)CR_CHAN(insn->chanspec), + (unsigned char *)&data[0]); break; case APCI1710_TIMER_WRITEVALUE: i_ReturnValue = i_APCI1710_WriteTimerValue(dev, - (BYTE)CR_AREF(insn->chanspec), - (BYTE)CR_CHAN(insn->chanspec), - (ULONG)data[1]); + (unsigned char)CR_AREF(insn->chanspec), + (unsigned char)CR_CHAN(insn->chanspec), + (unsigned int)data[1]); break; @@ -727,25 +727,25 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadTimerValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TimerNbr, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TimerNbr, | | PULONG_ pul_TimerValue) | +----------------------------------------------------------------------------+ | Task : Return the timer value from selected digital timer | | (b_TimerNbr) from selected timer module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | -| BYTE_ b_TimerNbr : Timer number to read | +| unsigned char_ b_TimerNbr : Timer number to read | | (0 to 2) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_TimerValue : Timer value | @@ -760,11 +760,11 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ReadTimerValue(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PULONG pul_TimerValue) +int i_APCI1710_ReadTimerValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned int *pul_TimerValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /* Test the module number */ if (b_ModulNbr < 4) { @@ -800,7 +800,7 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev, /* Timer selection wrong */ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ DPRINTK("The module is not a TIMER module\n"); @@ -812,29 +812,29 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetTimerOutputLevel | - | (BYTE_ b_BoardHandle, | - | BYTE_ b_ModulNbr, | - | BYTE_ b_TimerNbr, | - | PBYTE_ pb_OutputLevel) | + | (unsigned char_ b_BoardHandle, | + | unsigned char_ b_ModulNbr, | + | unsigned char_ b_TimerNbr, | + | unsigned char *_ pb_OutputLevel) | +----------------------------------------------------------------------------+ | Task : Return the output signal level (pb_OutputLevel) from | | selected digital timer (b_TimerNbr) from selected timer| | module (b_ModulNbr). | +----------------------------------------------------------------------------+ - | Input Parameters : BYTE_ b_BoardHandle : Handle of board | + | Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | - | BYTE_ b_ModulNbr : Selected module number | + | unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | - | BYTE_ b_TimerNbr : Timer number to test | + | unsigned char_ b_TimerNbr : Timer number to test | | (0 to 2) | +----------------------------------------------------------------------------+ - | Output Parameters : PBYTE_ pb_OutputLevel : Output signal level | + | Output Parameters : unsigned char *_ pb_OutputLevel : Output signal level | | 0 : The output is low | | 1 : The output is high | +----------------------------------------------------------------------------+ @@ -848,12 +848,12 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PBYTE pb_OutputLevel) +int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned char *pb_OutputLevel) { - INT i_ReturnValue = 0; - DWORD dw_TimerStatus; + int i_ReturnValue = 0; + unsigned int dw_TimerStatus; /* Test the module number */ if (b_ModulNbr < 4) { @@ -869,7 +869,7 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev, /* Read the timer status */ dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - *pb_OutputLevel = (BYTE) (((dw_TimerStatus >> 7) & 1) ^ devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel); + *pb_OutputLevel = (unsigned char) (((dw_TimerStatus >> 7) & 1) ^ devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel); } else { /* Timer not initialised see function */ DPRINTK("Timer not initialised see function\n"); @@ -879,7 +879,7 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev, /* Timer selection wrong */ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ DPRINTK("The module is not a TIMER module\n"); @@ -891,29 +891,29 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetTimerProgressStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TimerNbr, | -| PBYTE_ pb_TimerStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TimerNbr, | +| unsigned char *_ pb_TimerStatus) | +----------------------------------------------------------------------------+ | Task : Return the progress status (pb_TimerStatus) from | | selected digital timer (b_TimerNbr) from selected timer| | module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | -| BYTE_ b_TimerNbr : Timer number to test | +| unsigned char_ b_TimerNbr : Timer number to test | | (0 to 2) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_TimerStatus : Output signal level | +| Output Parameters : unsigned char *_ pb_TimerStatus : Output signal level | | 0 : Timer not in progress | | 1 : Timer in progress | +----------------------------------------------------------------------------+ @@ -927,12 +927,12 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PBYTE pb_TimerStatus) +int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned char *pb_TimerStatus) { - INT i_ReturnValue = 0; - DWORD dw_TimerStatus; + int i_ReturnValue = 0; + unsigned int dw_TimerStatus; /* Test the module number */ if (b_ModulNbr < 4) { @@ -949,7 +949,7 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, /* Read the timer status */ dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - *pb_TimerStatus = (BYTE) ((dw_TimerStatus) >> 8) & 1; + *pb_TimerStatus = (unsigned char) ((dw_TimerStatus) >> 8) & 1; printk("ProgressStatus : %d", *pb_TimerStatus); } else { /* Timer not initialised see function */ @@ -958,7 +958,7 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, } else { /* Timer selection wrong */ i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ @@ -976,9 +976,9 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_WriteTimerValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TimerNbr, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TimerNbr, | | ULONG_ ul_WriteValue) | +----------------------------------------------------------------------------+ | Task : Write the value (ul_WriteValue) into the selected timer| @@ -986,11 +986,11 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, | The action in depend of the time mode selection. | | See timer mode description table. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | | APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | -| BYTE_ b_TimerNbr : Timer number to write | +| unsigned char_ b_TimerNbr : Timer number to write | | (0 to 2) | | ULONG_ ul_WriteValue : Value to write | +----------------------------------------------------------------------------+ @@ -1006,11 +1006,11 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_WriteTimerValue(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - ULONG ul_WriteValue) +int i_APCI1710_WriteTimerValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned int ul_WriteValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /* Test the module number */ if (b_ModulNbr < 4) { @@ -1031,7 +1031,7 @@ INT i_APCI1710_WriteTimerValue(struct comedi_device * dev, /* Timer selection wrong */ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; - } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) + } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ } else { /* The module is not a TIMER module */ DPRINTK("The module is not a TIMER module\n"); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h index 4797c0b77a43..9698ae13509d 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h @@ -34,40 +34,40 @@ /* * 82X54 TIMER INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev, +int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * 82X54 READ FUNCTION */ -INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * 82X54 READ & WRITE FUNCTION */ -INT i_APCI1710_ReadTimerValue(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PULONG pul_TimerValue); +int i_APCI1710_ReadTimerValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned int *pul_TimerValue); -INT i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PBYTE pb_OutputLevel); +int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned char *pb_OutputLevel); -INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - PBYTE pb_TimerStatus); +int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned char *pb_TimerStatus); /* * 82X54 WRITE FUNCTION */ -INT i_APCI1710_WriteTimerValue(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_TimerNbr, - ULONG ul_WriteValue); +int i_APCI1710_WriteTimerValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_TimerNbr, + unsigned int ul_WriteValue); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c index 1a54d3b2c694..ccb109a851f2 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -62,11 +62,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitChrono | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_ChronoMode, | -| BYTE_ b_PCIInputClock, | -| BYTE_ b_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_ChronoMode, | +| unsigned char_ b_PCIInputClock, | +| unsigned char_ b_TimingUnit, | | ULONG_ ul_TimingInterval, | | PULONG_ pul_RealTimingInterval) @@ -88,12 +88,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | The mode 4 to 7 is appropriate for measuring the timing| | between two event. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure | | (0 to 3) | -| BYTE_ b_ChronoMode data[0] : Chronometer action mode | +| unsigned char_ b_ChronoMode data[0] : Chronometer action mode | | (0 to 7). | -| BYTE_ b_PCIInputClock data[1] : Selection from PCI bus clock| +| unsigned char_ b_PCIInputClock data[1] : Selection from PCI bus clock| | - APCI1710_30MHZ : | | The PC have a PCI bus | | clock from 30 MHz | @@ -104,7 +104,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | The APCI-1710 have a | | integrated 40Mhz | | quartz. | -| BYTE_ b_TimingUnit data[2] : Base timing unity (0 to 4) | +| unsigned char_ b_TimingUnit data[2] : Base timing unity (0 to 4) | | 0 : ns | | 1 : µs | | 2 : ms | @@ -131,23 +131,23 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - ULONG ul_TimerValue = 0; - ULONG ul_TimingInterval = 0; - ULONG ul_RealTimingInterval = 0; + int i_ReturnValue = 0; + unsigned int ul_TimerValue = 0; + unsigned int ul_TimingInterval = 0; + unsigned int ul_RealTimingInterval = 0; double d_RealTimingInterval = 0; - DWORD dw_ModeArray[8] = + unsigned int dw_ModeArray[8] = { 0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06 }; - BYTE b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit; + unsigned char b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit; b_ModulNbr = CR_AREF(insn->chanspec); - b_ChronoMode = (BYTE) data[0]; - b_PCIInputClock = (BYTE) data[1]; - b_TimingUnit = (BYTE) data[2]; - ul_TimingInterval = (ULONG) data[3]; + b_ChronoMode = (unsigned char) data[0]; + b_PCIInputClock = (unsigned char) data[1]; + b_TimingUnit = (unsigned char) data[2]; + ul_TimingInterval = (unsigned int) data[3]; i_ReturnValue = insn->n; /**************************/ @@ -214,7 +214,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (0.001 * b_PCIInputClock)); @@ -237,7 +237,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (0.001 * (double)b_PCIInputClock)); @@ -272,7 +272,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -294,7 +294,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (1.0 * b_PCIInputClock)); @@ -317,7 +317,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (1.0 * (double)b_PCIInputClock)); @@ -354,7 +354,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -400,7 +400,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (1000.0 * (double)b_PCIInputClock)); @@ -435,7 +435,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -457,7 +457,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (1000000.0 @@ -482,7 +482,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (1000000.0 @@ -520,7 +520,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -542,7 +542,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_TimerValue = - (ULONG) + (unsigned int) ( (ul_TimingInterval * @@ -570,7 +570,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (1000000.0 @@ -608,7 +608,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -736,7 +736,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su DPRINTK("Base timing selection is wrong\n"); i_ReturnValue = -7; } - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ else { /***********************************/ /* Timing unity selection is wrong */ @@ -744,8 +744,8 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su DPRINTK("Timing unity selection is wrong\n"); i_ReturnValue = -6; - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ else { /*****************************************/ /* The selected PCI input clock is wrong */ @@ -753,8 +753,8 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su DPRINTK("The selected PCI input clock is wrong\n"); i_ReturnValue = -5; - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) - } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7) + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ + } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */ else { /***************************************/ /* Chronometer mode selection is wrong */ @@ -762,7 +762,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su DPRINTK("Chronometer mode selection is wrong\n"); i_ReturnValue = -4; - } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7) + } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */ } else { /******************************************/ /* The module is not a Chronometer module */ @@ -780,17 +780,17 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su i_ReturnValue = -2; } data[0] = ul_RealTimingInterval; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableChrono | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_CycleMode, | -| BYTE_ b_InterruptEnable) -INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_CycleMode, | +| unsigned char_ b_InterruptEnable) +int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Enable the chronometer from selected module | @@ -810,12 +810,12 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | | witch the " i_APCI1710_EnableChrono" function, if no | | stop signal occur this start signal is ignored. +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) | data[0] ENABle/Disable chrono -| BYTE_ b_CycleMode : Selected the chronometer | +| unsigned char_ b_CycleMode : Selected the chronometer | | data[1] acquisition mode | -| BYTE_ b_InterruptEnable : Enable or disable the | +| unsigned char_ b_InterruptEnable : Enable or disable the | | data[2] chronometer interrupt. | | APCI1710_ENABLE: | | Enable the chronometer | @@ -840,15 +840,15 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action; + int i_ReturnValue = 0; + unsigned char b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action; b_ModulNbr = CR_AREF(insn->chanspec); - b_Action = (BYTE) data[0]; - b_CycleMode = (BYTE) data[1]; - b_InterruptEnable = (BYTE) data[2]; + b_Action = (unsigned char) data[0]; + b_CycleMode = (unsigned char) data[1]; + b_InterruptEnable = (unsigned char) data[2]; i_ReturnValue = insn->n; /**************************/ @@ -951,7 +951,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, ui_Address + 32 + (64 * b_ModulNbr)); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ } /***********************************/ @@ -980,7 +980,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, 36 + (64 * b_ModulNbr)); - } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) + } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ else { /********************************/ /* Interrupt parameter is wrong */ @@ -988,8 +988,8 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, DPRINTK("Interrupt parameter is wrong\n"); i_ReturnValue = -6; - } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) - } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) + } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ + } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ else { /***********************************************/ /* Chronometer acquisition mode cycle is wrong */ @@ -997,7 +997,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, DPRINTK("Chronometer acquisition mode cycle is wrong\n"); i_ReturnValue = -5; - } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) + } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ break; case APCI1710_DISABLE: @@ -1046,7 +1046,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, default: DPRINTK("Inputs wrong! Enable or Disable chrono\n"); i_ReturnValue = -8; - } // switch ENABLE/DISABLE + } /* switch ENABLE/DISABLE */ } else { /*******************************/ /* Chronometer not initialised */ @@ -1072,7 +1072,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1090,36 +1090,36 @@ struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_ReadType; - INT i_ReturnValue = insn->n; + unsigned char b_ReadType; + int i_ReturnValue = insn->n; b_ReadType = CR_CHAN(insn->chanspec); switch (b_ReadType) { case APCI1710_CHRONO_PROGRESS_STATUS: i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_CHRONO_READVALUE: i_ReturnValue = i_APCI1710_ReadChronoValue(dev, - (BYTE) CR_AREF(insn->chanspec), - (UINT) insn->unused[0], - (PBYTE) & data[0], (PULONG) & data[1]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned int) insn->unused[0], + (unsigned char *) &data[0], (unsigned int *) &data[1]); break; case APCI1710_CHRONO_CONVERTVALUE: i_ReturnValue = i_APCI1710_ConvertChronoValue(dev, - (BYTE) CR_AREF(insn->chanspec), - (ULONG) insn->unused[0], - (PULONG) & data[0], - (PBYTE) & data[1], - (PBYTE) & data[2], - (PUINT) & data[3], - (PUINT) & data[4], (PUINT) & data[5]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned int) insn->unused[0], + (unsigned int *) &data[0], + (unsigned char *) &data[1], + (unsigned char *) &data[2], + (unsigned int *) &data[3], + (unsigned int *) &data[4], (unsigned int *) &data[5]); break; case APCI1710_CHRONO_READINTERRUPT: @@ -1152,22 +1152,22 @@ INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevic if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetChronoProgressStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_ChronoStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_ChronoStatus) | +----------------------------------------------------------------------------+ | Task : Return the chronometer status (pb_ChronoStatus) from | | selected chronometer module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer | | status. | @@ -1194,11 +1194,11 @@ INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_ChronoStatus) +int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus) { - INT i_ReturnValue = 0; - DWORD dw_Status; + int i_ReturnValue = 0; + unsigned int dw_Status; /**************************/ /* Test the module number */ @@ -1233,7 +1233,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, /******************/ *pb_ChronoStatus = 3; - } // if ((dw_Status & 8) == 8) + } /* if ((dw_Status & 8) == 8) */ else { /*******************************/ /* Test if measurement stopped */ @@ -1245,7 +1245,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, /***********************/ *pb_ChronoStatus = 2; - } // if ((dw_Status & 2) == 2) + } /* if ((dw_Status & 2) == 2) */ else { /*******************************/ /* Test if measurement started */ @@ -1257,16 +1257,16 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, /************************/ *pb_ChronoStatus = 1; - } // if ((dw_Status & 1) == 1) + } /* if ((dw_Status & 1) == 1) */ else { /***************************/ /* Measurement not started */ /***************************/ *pb_ChronoStatus = 0; - } // if ((dw_Status & 1) == 1) - } // if ((dw_Status & 2) == 2) - } // if ((dw_Status & 8) == 8) + } /* if ((dw_Status & 1) == 1) */ + } /* if ((dw_Status & 2) == 2) */ + } /* if ((dw_Status & 8) == 8) */ } else { /*******************************/ /* Chronometer not initialised */ @@ -1289,16 +1289,16 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadChronoValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| UINT_ ui_TimeOut, | -| PBYTE_ pb_ChronoStatus, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned int_ ui_TimeOut, | +| unsigned char *_ pb_ChronoStatus, | | PULONG_ pul_ChronoValue) | +----------------------------------------------------------------------------+ | Task : Return the chronometer status (pb_ChronoStatus) and the| @@ -1323,8 +1323,8 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, | "i_APCI1710_InitChrono" function and the time unity is | | the b_TimingUnit from "i_APCI1710_InitChrono" function| +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer | | status. | @@ -1341,7 +1341,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, | timing witch the | | function | | "i_APCI1710_InitChrono" | -| PULONG pul_ChronoValue : Chronometer timing value. | +| unsigned int * pul_ChronoValue : Chronometer timing value. | +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -1355,13 +1355,13 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, - BYTE b_ModulNbr, - UINT ui_TimeOut, PBYTE pb_ChronoStatus, PULONG pul_ChronoValue) +int i_APCI1710_ReadChronoValue(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, unsigned int *pul_ChronoValue) { - INT i_ReturnValue = 0; - DWORD dw_Status; - DWORD dw_TimeOut = 0; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned int dw_TimeOut = 0; /**************************/ /* Test the module number */ @@ -1430,7 +1430,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, } break; - } // if ((dw_Status & 8) == 8) + } /* if ((dw_Status & 8) == 8) */ else { /*******************************/ /* Test if measurement stopped */ @@ -1464,7 +1464,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr)); } break; - } // if ((dw_Status & 2) == 2) + } /* if ((dw_Status & 2) == 2) */ else { /*******************************/ /* Test if measurement started */ @@ -1478,7 +1478,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, *pb_ChronoStatus = 1; - } // if ((dw_Status & 1) == 1) + } /* if ((dw_Status & 1) == 1) */ else { /***************************/ /* Measurement not started */ @@ -1487,9 +1487,9 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, *pb_ChronoStatus = 0; - } // if ((dw_Status & 1) == 1) - } // if ((dw_Status & 2) == 2) - } // if ((dw_Status & 8) == 8) + } /* if ((dw_Status & 1) == 1) */ + } /* if ((dw_Status & 2) == 2) */ + } /* if ((dw_Status & 8) == 8) */ if (dw_TimeOut == ui_TimeOut) { /*****************/ @@ -1507,7 +1507,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, mdelay(1000); } - } // for (;;) + } /* for (;;) */ /*****************************/ /* Test if stop signal occur */ @@ -1575,39 +1575,39 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ConvertChronoValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | | ULONG_ ul_ChronoValue, | | PULONG_ pul_Hour, | -| PBYTE_ pb_Minute, | -| PBYTE_ pb_Second, | -| PUINT_ pui_MilliSecond, | -| PUINT_ pui_MicroSecond, | -| PUINT_ pui_NanoSecond) | +| unsigned char *_ pb_Minute, | +| unsigned char *_ pb_Second, | +| unsigned int *_ pui_MilliSecond, | +| unsigned int *_ pui_MicroSecond, | +| unsigned int *_ pui_NanoSecond) | +----------------------------------------------------------------------------+ | Task : Convert the chronometer measured timing | | (ul_ChronoValue) in to h, mn, s, ms, µs, ns. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3)| +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| | ULONG_ ul_ChronoValue : Measured chronometer timing | | value. | | See"i_APCI1710_ReadChronoValue"| +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_Hour : Chronometer timing hour | -| PBYTE_ pb_Minute : Chronometer timing minute | -| PBYTE_ pb_Second : Chronometer timing second | -| PUINT_ pui_MilliSecond : Chronometer timing mini | +| unsigned char *_ pb_Minute : Chronometer timing minute | +| unsigned char *_ pb_Second : Chronometer timing second | +| unsigned int *_ pui_MilliSecond : Chronometer timing mini | | second | -| PUINT_ pui_MicroSecond : Chronometer timing micro | +| unsigned int *_ pui_MicroSecond : Chronometer timing micro | | second | -| PUINT_ pui_NanoSecond : Chronometer timing nano | +| unsigned int *_ pui_NanoSecond : Chronometer timing nano | | second | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -1619,15 +1619,15 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, - BYTE b_ModulNbr, - ULONG ul_ChronoValue, - PULONG pul_Hour, - PBYTE pb_Minute, - PBYTE pb_Second, - PUINT pui_MilliSecond, PUINT pui_MicroSecond, PUINT pui_NanoSecond) +int i_APCI1710_ConvertChronoValue(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned int ul_ChronoValue, + unsigned int *pul_Hour, + unsigned char *pb_Minute, + unsigned char *pb_Second, + unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, unsigned int *pui_NanoSecond) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; double d_Hour; double d_Minute; double d_Second; @@ -1681,7 +1681,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, /**********************/ d_Hour = d_Hour / (double)60.0; - *pul_Hour = (ULONG) d_Hour; + *pul_Hour = (unsigned int) d_Hour; /************************/ /* Calculate the minute */ @@ -1689,7 +1689,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, d_Minute = d_Hour - *pul_Hour; d_Minute = d_Minute * 60; - *pb_Minute = (BYTE) d_Minute; + *pb_Minute = (unsigned char) d_Minute; /************************/ /* Calculate the second */ @@ -1697,7 +1697,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, d_Second = d_Minute - *pb_Minute; d_Second = d_Second * 60; - *pb_Second = (BYTE) d_Second; + *pb_Second = (unsigned char) d_Second; /*****************************/ /* Calculate the mini second */ @@ -1705,7 +1705,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, d_MilliSecond = d_Second - *pb_Second; d_MilliSecond = d_MilliSecond * 1000; - *pui_MilliSecond = (UINT) d_MilliSecond; + *pui_MilliSecond = (unsigned int) d_MilliSecond; /******************************/ /* Calculate the micro second */ @@ -1715,7 +1715,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, d_MilliSecond - *pui_MilliSecond; d_MicroSecond = d_MicroSecond * 1000; - *pui_MicroSecond = (UINT) d_MicroSecond; + *pui_MicroSecond = (unsigned int) d_MicroSecond; /******************************/ /* Calculate the micro second */ @@ -1725,7 +1725,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, d_MicroSecond - *pui_MicroSecond; d_NanoSecond = d_NanoSecond * 1000; - *pui_NanoSecond = (UINT) d_NanoSecond; + *pui_NanoSecond = (unsigned int) d_NanoSecond; break; } @@ -1752,21 +1752,21 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s, +| Function Name : int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Sets the output witch has been passed with the | | parameter b_Channel. Setting an output means setting an| | output high. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3)| -| BYTE_ b_OutputChannel : Selection from digital output | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| +| unsigned char_ b_OutputChannel : Selection from digital output | | CR_CHAN() channel (0 to 2) | | 0 : Channel H | | 1 : Channel A | @@ -1787,19 +1787,19 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetChronoChlOff | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_OutputChannel) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_OutputChannel) | +----------------------------------------------------------------------------+ | Task : Resets the output witch has been passed with the | | parameter b_Channel. Resetting an output means setting | | an output low. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 data[0] : Chl ON, Chl OFF , Chl Read , Port Read -| BYTE_ b_ModulNbr CR_AREF : Selected module number (0 to 3)| -| BYTE_ b_OutputChannel CR_CHAN : Selection from digital output | +| unsigned char_ b_ModulNbr CR_AREF : Selected module number (0 to 3)| +| unsigned char_ b_OutputChannel CR_CHAN : Selection from digital output | | channel (0 to 2) | | 0 : Channel H | | 1 : Channel A | @@ -1820,24 +1820,24 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadChronoChlValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_InputChannel, | -| PBYTE_ pb_ChannelStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_InputChannel, | +| unsigned char *_ pb_ChannelStatus) | +----------------------------------------------------------------------------+ | Task : Return the status from selected digital input | | (b_InputChannel) from selected chronometer | | module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3)| -| BYTE_ b_InputChannel : Selection from digital input | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| +| unsigned char_ b_InputChannel : Selection from digital input | | channel (0 to 2) | | CR_CHAN() 0 : Channel E | | 1 : Channel F | | 2 : Channel G | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_ChannelStatus : Digital input channel status.| +| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel status.| | data[0] 0 : Channel is not active | | 1 : Channel is active | +----------------------------------------------------------------------------+ @@ -1854,17 +1854,17 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadChronoPortValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_PortValue) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_PortValue) | +----------------------------------------------------------------------------+ | Task : Return the status from digital inputs port from | | selected (b_ModulNbr) chronometer module. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3)| +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_PortValue : Digital inputs port status. +| Output Parameters : unsigned char *_ pb_PortValue : Digital inputs port status. | data[0] +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -1876,18 +1876,18 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType; - DWORD dw_Status; - PBYTE pb_ChannelStatus; - PBYTE pb_PortValue; + int i_ReturnValue = 0; + unsigned char b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType; + unsigned int dw_Status; + unsigned char *pb_ChannelStatus; + unsigned char *pb_PortValue; b_ModulNbr = CR_AREF(insn->chanspec); i_ReturnValue = insn->n; - b_IOType = (BYTE) data[0]; + b_IOType = (unsigned char) data[0]; /**************************/ /* Test the module number */ @@ -1915,14 +1915,14 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, case APCI1710_CHRONO_SET_CHANNELOFF: b_OutputChannel = - (BYTE) CR_CHAN(insn->chanspec); + (unsigned char) CR_CHAN(insn->chanspec); if (b_OutputChannel <= 2) { outl(0, devpriv->s_BoardInfos. ui_Address + 20 + (b_OutputChannel * 4) + (64 * b_ModulNbr)); - } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) + } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ else { /****************************************/ /* The selected digital output is wrong */ @@ -1931,21 +1931,21 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, DPRINTK("The selected digital output is wrong\n"); i_ReturnValue = -4; - } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) + } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ break; case APCI1710_CHRONO_SET_CHANNELON: b_OutputChannel = - (BYTE) CR_CHAN(insn->chanspec); + (unsigned char) CR_CHAN(insn->chanspec); if (b_OutputChannel <= 2) { outl(1, devpriv->s_BoardInfos. ui_Address + 20 + (b_OutputChannel * 4) + (64 * b_ModulNbr)); - } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) + } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ else { /****************************************/ /* The selected digital output is wrong */ @@ -1954,7 +1954,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, DPRINTK("The selected digital output is wrong\n"); i_ReturnValue = -4; - } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) + } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ break; @@ -1962,9 +1962,9 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, /**********************************/ /* Test the digital input channel */ /**********************************/ - pb_ChannelStatus = (PBYTE) & data[0]; + pb_ChannelStatus = (unsigned char *) &data[0]; b_InputChannel = - (BYTE) CR_CHAN(insn->chanspec); + (unsigned char) CR_CHAN(insn->chanspec); if (b_InputChannel <= 2) { @@ -1975,10 +1975,10 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, (64 * b_ModulNbr)); *pb_ChannelStatus = - (BYTE) (((dw_Status >> + (unsigned char) (((dw_Status >> b_InputChannel) & 1) ^ 1); - } // if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) + } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */ else { /***************************************/ /* The selected digital input is wrong */ @@ -1986,13 +1986,13 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, DPRINTK("The selected digital input is wrong\n"); i_ReturnValue = -4; - } // if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) + } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */ break; case APCI1710_CHRONO_READ_PORT: - pb_PortValue = (PBYTE) & data[0]; + pb_PortValue = (unsigned char *) &data[0]; dw_Status = inl(devpriv->s_BoardInfos. @@ -2000,7 +2000,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, (64 * b_ModulNbr)); *pb_PortValue = - (BYTE) ((dw_Status & 0x7) ^ 7); + (unsigned char) ((dw_Status & 0x7) ^ 7); break; } } else { @@ -2028,5 +2028,5 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h index 26b50cefee5a..29bad1d144a1 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h @@ -35,10 +35,10 @@ /* * CHRONOMETER INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, +int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -46,29 +46,29 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, /* * CHRONOMETER READ FUNCTION */ -INT i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_ChronoStatus); +int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus); -INT i_APCI1710_ReadChronoValue(struct comedi_device *dev, - BYTE b_ModulNbr, - UINT ui_TimeOut, PBYTE pb_ChronoStatus, - PULONG pul_ChronoValue); +int i_APCI1710_ReadChronoValue(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, + unsigned int *pul_ChronoValue); -INT i_APCI1710_ConvertChronoValue(struct comedi_device *dev, - BYTE b_ModulNbr, - ULONG ul_ChronoValue, - PULONG pul_Hour, - PBYTE pb_Minute, - PBYTE pb_Second, - PUINT pui_MilliSecond, PUINT pui_MicroSecond, - PUINT pui_NanoSecond); +int i_APCI1710_ConvertChronoValue(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned int ul_ChronoValue, + unsigned int *pul_Hour, + unsigned char *pb_Minute, + unsigned char *pb_Second, + unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, + unsigned int *pui_NanoSecond); /* * CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION */ -INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev, +int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c index 8be27aedaaf5..f3e47e5791db 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -61,7 +61,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, | +| Function Name : int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, | | struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| +----------------------------------------------------------------------------+ | Task : Configure the digital I/O operating mode from selected | @@ -70,14 +70,14 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | I/O. | +----------------------------------------------------------------------------+ | Input Parameters : | -| BYTE_ b_ModulNbr data[0]: Module number to | +| unsigned char_ b_ModulNbr data[0]: Module number to | | configure (0 to 3) | -| BYTE_ b_ChannelAMode data[1] : Channel A mode selection | +| unsigned char_ b_ChannelAMode data[1] : Channel A mode selection | | 0 : Channel used for digital | | input | | 1 : Channel used for digital | | output | -| BYTE_ b_ChannelBMode data[2] : Channel B mode selection | +| unsigned char_ b_ChannelBMode data[2] : Channel B mode selection | | 0 : Channel used for digital | | input | | 1 : Channel used for digital | @@ -99,19 +99,19 @@ Activates and deactivates the digital output memory. +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_ModulNbr, b_ChannelAMode, b_ChannelBMode; - BYTE b_MemoryOnOff, b_ConfigType; - INT i_ReturnValue = 0; - DWORD dw_WriteConfig = 0; - - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_ConfigType = (BYTE) data[0]; // Memory or Init - b_ChannelAMode = (BYTE) data[1]; - b_ChannelBMode = (BYTE) data[2]; - b_MemoryOnOff = (BYTE) data[1]; // if memory operation + unsigned char b_ModulNbr, b_ChannelAMode, b_ChannelBMode; + unsigned char b_MemoryOnOff, b_ConfigType; + int i_ReturnValue = 0; + unsigned int dw_WriteConfig = 0; + + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_ConfigType = (unsigned char) data[0]; /* Memory or Init */ + b_ChannelAMode = (unsigned char) data[1]; + b_ChannelBMode = (unsigned char) data[2]; + b_MemoryOnOff = (unsigned char) data[1]; /* if memory operation */ i_ReturnValue = insn->n; /**************************/ @@ -126,7 +126,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub switch (b_ConfigType) { case APCI1710_DIGIO_MEMORYONOFF: - if (b_MemoryOnOff) // If Memory ON + if (b_MemoryOnOff) /* If Memory ON */ { /****************************/ /* Set the output memory on */ @@ -140,7 +140,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub /***************************/ devpriv->s_ModuleInfo[b_ModulNbr]. s_DigitalIOInfo.dw_OutputMemory = 0; - } else // If memory off + } else /* If memory off */ { /*****************************/ /* Set the output memory off */ @@ -197,7 +197,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub /*****************************************/ dw_WriteConfig = - (DWORD) (b_ChannelAMode | + (unsigned int) (b_ChannelAMode | (b_ChannelBMode * 2)); /***************************/ @@ -233,7 +233,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub DPRINTK("The module is not a digital I/O module\n"); i_ReturnValue = -3; } - } // end of Switch + } /* end of Switch */ printk("Return Value %d\n", i_ReturnValue); return i_ReturnValue; } @@ -257,9 +257,9 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub | -| BYTE_ b_ModulNbr CR_AREF(chanspec) : Selected module number | +| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number | | (0 to 3) | -| BYTE_ b_InputChannel CR_CHAN(chanspec) : Selection from digital | +| unsigned char_ b_InputChannel CR_CHAN(chanspec) : Selection from digital | | input ( 0 to 6) | | 0 : Channel C | | 1 : Channel D | @@ -288,22 +288,22 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -//_INT_ i_APCI1710_ReadDigitalIOChlValue (BYTE_ b_BoardHandle, -// BYTE_ b_ModulNbr, -// BYTE_ b_InputChannel, -// -// PBYTE_ pb_ChannelStatus) -INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +/* _INT_ i_APCI1710_ReadDigitalIOChlValue (unsigned char_ b_BoardHandle, */ +/* +* unsigned char_ b_ModulNbr, unsigned char_ b_InputChannel, +* unsigned char *_ pb_ChannelStatus) +*/ +int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg; - BYTE b_ModulNbr, b_InputChannel; - PBYTE pb_ChannelStatus; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_InputChannel = (BYTE) CR_CHAN(insn->chanspec); + int i_ReturnValue = 0; + unsigned int dw_StatusReg; + unsigned char b_ModulNbr, b_InputChannel; + unsigned char *pb_ChannelStatus; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec); data[0] = 0; - pb_ChannelStatus = (PBYTE) & data[0]; + pb_ChannelStatus = (unsigned char *) &data[0]; i_ReturnValue = insn->n; /**************************/ @@ -356,7 +356,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, i_ReturnValue = -6; } - } // if (b_InputChannel == 5) + } /* if (b_InputChannel == 5) */ else { /***************************/ /* Test the channel B mode */ @@ -375,8 +375,8 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, i_ReturnValue = -7; } - } // if (b_InputChannel == 5) - } // if (b_InputChannel > 4) + } /* if (b_InputChannel == 5) */ + } /* if (b_InputChannel > 4) */ /***********************/ /* Test if error occur */ @@ -387,11 +387,10 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, /* Read all digital input */ /**************************/ - //INPDW (ps_APCI1710Variable-> - // s_Board [b_BoardHandle]. - // s_BoardInfos. - // ui_Address + (64 * b_ModulNbr), - // &dw_StatusReg); +/* +* INPDW (ps_APCI1710Variable-> s_Board [b_BoardHandle]. +* s_BoardInfos. ui_Address + (64 * b_ModulNbr), &dw_StatusReg); +*/ dw_StatusReg = inl(devpriv-> @@ -400,11 +399,11 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, (64 * b_ModulNbr)); *pb_ChannelStatus = - (BYTE) ((dw_StatusReg ^ + (unsigned char) ((dw_StatusReg ^ 0x1C) >> b_InputChannel) & 1; - } // if (i_ReturnValue == 0) + } /* if (i_ReturnValue == 0) */ } else { /*******************************/ /* Digital I/O not initialised */ @@ -434,7 +433,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -445,7 +444,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device +| Function Name : int i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device |*dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ @@ -453,9 +452,9 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, | parameter b_Channel. Setting an output means setting | | an ouput high. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr (aref ) : Selected module number (0 to 3)| -| BYTE_ b_OutputChannel (CR_CHAN) : Selection from digital output | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr (aref ) : Selected module number (0 to 3)| +| unsigned char_ b_OutputChannel (CR_CHAN) : Selection from digital output | | channel (0 to 2) | | 0 : Channel H | | 1 : Channel A | @@ -478,15 +477,16 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -//_INT_ i_APCI1710_SetDigitalIOChlOn (BYTE_ b_BoardHandle, -// BYTE_ b_ModulNbr, -// BYTE_ b_OutputChannel) -INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +/* +* _INT_ i_APCI1710_SetDigitalIOChlOn (unsigned char_ b_BoardHandle, +* unsigned char_ b_ModulNbr, unsigned char_ b_OutputChannel) +*/ +int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_WriteValue = 0; - BYTE b_ModulNbr, b_OutputChannel; + int i_ReturnValue = 0; + unsigned int dw_WriteValue = 0; + unsigned char b_ModulNbr, b_OutputChannel; i_ReturnValue = insn->n; b_ModulNbr = CR_AREF(insn->chanspec); b_OutputChannel = CR_CHAN(insn->chanspec); @@ -602,7 +602,7 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, 1 << b_OutputChannel; } - } // set channel off + } /* set channel off */ else { if (devpriv-> s_ModuleInfo @@ -627,23 +627,24 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, dw_OutputMemory = dw_WriteValue; } else { - /*****************************/ + /*****************************/ /* Digital Output Memory OFF */ - /*****************************/ - // +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn" + /*****************************/ + /* +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn" */ i_ReturnValue = -8; } } - /*******************/ + /*******************/ /* Write the value */ - /*******************/ + /*******************/ - //OUTPDW (ps_APCI1710Variable-> - // s_Board [b_BoardHandle]. - // s_BoardInfos. - // ui_Address + (64 * b_ModulNbr), - // dw_WriteValue); + /* OUTPDW (ps_APCI1710Variable-> + * s_Board [b_BoardHandle]. + * s_BoardInfos. ui_Address + (64 * b_ModulNbr), + * dw_WriteValue); + */ +*/ outl(dw_WriteValue, devpriv->s_BoardInfos. ui_Address + (64 * b_ModulNbr)); @@ -670,7 +671,7 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -690,19 +691,19 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, | from selected digital I/O module (b_ModulNbr) +----------------------------------------------------------------------------+ | Input Parameters : - BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr CR_AREF(aref) : Selected module number (0 to 3)| -| BYTE_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 ) + unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr CR_AREF(aref) : Selected module number (0 to 3)| +| unsigned char_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 ) | data[0] read or write port - data[1] if write then indicate ON or OFF +| data[1] if write then indicate ON or OFF - if read : data[1] will return port status. +| if read : data[1] will return port status. +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ | Return Value : - INPUT : +| INPUT : 0: No error | | -1: The handle parameter of the board is wrong | @@ -725,75 +726,78 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -//_INT_ i_APCI1710_SetDigitalIOPortOn (BYTE_ b_BoardHandle, -// BYTE_ b_ModulNbr, -// BYTE_ b_PortValue) -INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +/* + * _INT_ i_APCI1710_SetDigitalIOPortOn (unsigned char_ + * b_BoardHandle, unsigned char_ b_ModulNbr, unsigned char_ + * b_PortValue) +*/ +int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_WriteValue = 0; - DWORD dw_StatusReg; - BYTE b_ModulNbr, b_PortValue; - BYTE b_PortOperation, b_PortOnOFF; - - PBYTE pb_PortValue; - - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_PortOperation = (BYTE) data[0]; // Input or output - b_PortOnOFF = (BYTE) data[1]; // if output then On or Off - b_PortValue = (BYTE) data[2]; // if out put then Value + int i_ReturnValue = 0; + unsigned int dw_WriteValue = 0; + unsigned int dw_StatusReg; + unsigned char b_ModulNbr, b_PortValue; + unsigned char b_PortOperation, b_PortOnOFF; + + unsigned char *pb_PortValue; + + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_PortOperation = (unsigned char) data[0]; /* Input or output */ + b_PortOnOFF = (unsigned char) data[1]; /* if output then On or Off */ + b_PortValue = (unsigned char) data[2]; /* if out put then Value */ i_ReturnValue = insn->n; - pb_PortValue = (PBYTE) & data[0]; -// if input then read value + pb_PortValue = (unsigned char *) &data[0]; +/* if input then read value */ switch (b_PortOperation) { case APCI1710_INPUT: - /**************************/ + /**************************/ /* Test the module number */ - /**************************/ + /**************************/ if (b_ModulNbr < 4) { - /*******************************/ + /*******************************/ /* Test if digital I/O counter */ - /*******************************/ + /*******************************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - /**********************************************/ + /**********************************************/ /* Test if the digital I/O module initialised */ - /**********************************************/ + /**********************************************/ if (devpriv->s_ModuleInfo[b_ModulNbr]. s_DigitalIOInfo.b_DigitalInit == 1) { - /**************************/ + /**************************/ /* Read all digital input */ - /**************************/ + /**************************/ - //INPDW (ps_APCI1710Variable-> - // s_Board [b_BoardHandle]. - // s_BoardInfos. - // ui_Address + (64 * b_ModulNbr), - // &dw_StatusReg); + /* INPDW (ps_APCI1710Variable-> + * s_Board [b_BoardHandle]. + * s_BoardInfos. + * ui_Address + (64 * b_ModulNbr), + * &dw_StatusReg); + */ dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + (64 * b_ModulNbr)); *pb_PortValue = - (BYTE) (dw_StatusReg ^ 0x1C); + (unsigned char) (dw_StatusReg ^ 0x1C); } else { - /*******************************/ + /*******************************/ /* Digital I/O not initialised */ - /*******************************/ + /*******************************/ i_ReturnValue = -4; } } else { - /******************************************/ + /******************************************/ /* The module is not a digital I/O module */ - /******************************************/ + /******************************************/ i_ReturnValue = -3; } @@ -853,11 +857,11 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, i_ReturnValue = -6; } - } // if ((b_PortValue & 2) == 2) + } /* if ((b_PortValue & 2) == 2) */ - /**************************/ + /**************************/ /* Test if channel B used */ - /**************************/ + /**************************/ if ((b_PortValue & 4) == 4) { if (devpriv-> @@ -866,33 +870,33 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, s_DigitalIOInfo. b_ChannelBMode != 1) { - /*******************************************/ + /*******************************************/ /* The digital channel B is used for input */ - /*******************************************/ + /*******************************************/ i_ReturnValue = -7; } - } // if ((b_PortValue & 4) == 4) + } /* if ((b_PortValue & 4) == 4) */ - /***********************/ + /***********************/ /* Test if error occur */ - /***********************/ + /***********************/ if (i_ReturnValue >= 0) { - //if(data[1]) - //{ + /* if(data[1]) { */ + switch (b_PortOnOFF) { - /*********************************/ + /*********************************/ /* Test if set Port ON */ - /*********************************/ + /*********************************/ case APCI1710_ON: - /*********************************/ + /*********************************/ /* Test if output memory enabled */ - /*********************************/ + /*********************************/ if (devpriv-> s_ModuleInfo @@ -924,7 +928,7 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, } break; - // If Set PORT OFF + /* If Set PORT OFF */ case APCI1710_OFF: /*********************************/ @@ -957,25 +961,26 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, = dw_WriteValue; } else { - /*****************************/ + /*****************************/ /* Digital Output Memory OFF */ - /*****************************/ + /*****************************/ i_ReturnValue = -8; } - } // switch + } /* switch */ - /*******************/ + /*******************/ /* Write the value */ - /*******************/ + /*******************/ + + /* OUTPDW (ps_APCI1710Variable-> + * s_Board [b_BoardHandle]. + * s_BoardInfos. + * ui_Address + (64 * b_ModulNbr), + * dw_WriteValue); */ - // OUTPDW (ps_APCI1710Variable-> - // s_Board [b_BoardHandle]. - // s_BoardInfos. - // ui_Address + (64 * b_ModulNbr), - // dw_WriteValue); outl(dw_WriteValue, devpriv-> s_BoardInfos. @@ -983,16 +988,16 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, (64 * b_ModulNbr)); } } else { - /**********************/ + /**********************/ /* Output value wrong */ - /**********************/ + /**********************/ i_ReturnValue = -4; } } else { - /*******************************/ + /*******************************/ /* Digital I/O not initialised */ - /*******************************/ + /*******************************/ i_ReturnValue = -5; } @@ -1015,6 +1020,6 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev, default: i_ReturnValue = -9; DPRINTK("NO INPUT/OUTPUT specified\n"); - } //switch INPUT / OUTPUT - return (i_ReturnValue); + } /* switch INPUT / OUTPUT */ + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h index 5ef157a55ca1..af1b9cdecfb3 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h @@ -27,20 +27,20 @@ /* * DIGITAL I/O INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * INPUT OUTPUT FUNCTIONS */ -INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev, +int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, +int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev, +int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c index 1062f2fdec30..6c092efee7bd 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -61,7 +61,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ -| INT i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,struct comedi_subdevice *s, +| int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ @@ -75,58 +75,58 @@ struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_ConfigType; - INT i_ReturnValue = 0; + unsigned int ui_ConfigType; + int i_ReturnValue = 0; ui_ConfigType = CR_CHAN(insn->chanspec); printk("\nINC_CPT"); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ switch (ui_ConfigType) { case APCI1710_INCCPT_INITCOUNTER: i_ReturnValue = i_APCI1710_InitCounter(dev, CR_AREF(insn->chanspec), - (BYTE) data[0], - (BYTE) data[1], - (BYTE) data[2], (BYTE) data[3], (BYTE) data[4]); + (unsigned char) data[0], + (unsigned char) data[1], + (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]); break; case APCI1710_INCCPT_COUNTERAUTOTEST: i_ReturnValue = i_APCI1710_CounterAutoTest(dev, - (PBYTE) & data[0]); + (unsigned char *) &data[0]); break; case APCI1710_INCCPT_INITINDEX: i_ReturnValue = i_APCI1710_InitIndex(dev, CR_AREF(insn->chanspec), - (BYTE) data[0], - (BYTE) data[1], (BYTE) data[2], (BYTE) data[3]); + (unsigned char) data[0], + (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]); break; case APCI1710_INCCPT_INITREFERENCE: i_ReturnValue = i_APCI1710_InitReference(dev, - CR_AREF(insn->chanspec), (BYTE) data[0]); + CR_AREF(insn->chanspec), (unsigned char) data[0]); break; case APCI1710_INCCPT_INITEXTERNALSTROBE: i_ReturnValue = i_APCI1710_InitExternalStrobe(dev, CR_AREF(insn->chanspec), - (BYTE) data[0], (BYTE) data[1]); + (unsigned char) data[0], (unsigned char) data[1]); break; case APCI1710_INCCPT_INITCOMPARELOGIC: i_ReturnValue = i_APCI1710_InitCompareLogic(dev, - CR_AREF(insn->chanspec), (UINT) data[0]); + CR_AREF(insn->chanspec), (unsigned int) data[0]); break; case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT: i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev, CR_AREF(insn->chanspec), - (BYTE) data[0], - (BYTE) data[1], (ULONG) data[2], (PULONG) & data[0]); + (unsigned char) data[0], + (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]); break; default: @@ -136,19 +136,19 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitCounter | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_CounterRange, | -| BYTE_ b_FirstCounterModus, | -| BYTE_ b_FirstCounterOption, | -| BYTE_ b_SecondCounterModus, | -| BYTE_ b_SecondCounterOption) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_CounterRange, | +| unsigned char_ b_FirstCounterModus, | +| unsigned char_ b_FirstCounterOption, | +| unsigned char_ b_SecondCounterModus, | +| unsigned char_ b_SecondCounterOption) | +----------------------------------------------------------------------------+ | Task : Configure the counter operating mode from selected | | module (b_ModulNbr). You must calling this function be | @@ -273,17 +273,17 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev | +----------------------+--------------------+----------------------------+ | | | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_CounterRange : Selection form counter | +| unsigned char_ b_CounterRange : Selection form counter | | range. | -| BYTE_ b_FirstCounterModus : First counter operating | +| unsigned char_ b_FirstCounterModus : First counter operating | | mode. | -| BYTE_ b_FirstCounterOption : First counter option. | -| BYTE_ b_SecondCounterModus : Second counter operating | +| unsigned char_ b_FirstCounterOption : First counter option. | +| unsigned char_ b_SecondCounterModus : Second counter operating | | mode. | -| BYTE_ b_SecondCounterOption : Second counter option. | +| unsigned char_ b_SecondCounterOption : Second counter option. | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -299,14 +299,14 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitCounter(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_CounterRange, - BYTE b_FirstCounterModus, - BYTE b_FirstCounterOption, - BYTE b_SecondCounterModus, BYTE b_SecondCounterOption) +int i_APCI1710_InitCounter(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_CounterRange, + unsigned char b_FirstCounterModus, + unsigned char b_FirstCounterOption, + unsigned char b_SecondCounterModus, unsigned char b_SecondCounterOption) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /*******************************/ /* Test if incremental counter */ @@ -502,14 +502,14 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_CounterAutoTest | -| (BYTE_ b_BoardHandle, | -| PBYTE_ pb_TestStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char *_ pb_TestStatus) | +----------------------------------------------------------------------------+ | Task : A test mode is intended for testing the component and | | the connected periphery. All the 8-bit counter chains | @@ -535,9 +535,9 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev, | | 1000 | Error detected of counter 3 | | | +-----------------+-----------------------------+ | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_TestStatus : Auto test conclusion. See table| +| Output Parameters : unsigned char *_ pb_TestStatus : Auto test conclusion. See table| +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -545,11 +545,11 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus) +int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char *pb_TestStatus) { - BYTE b_ModulCpt = 0; - INT i_ReturnValue = 0; - DWORD dw_LathchValue; + unsigned char b_ModulCpt = 0; + int i_ReturnValue = 0; + unsigned int dw_LathchValue; *pb_TestStatus = 0; @@ -627,17 +627,17 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitIndex (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_ReferenceAction, | -| BYTE_ b_IndexOperation, | -| BYTE_ b_AutoMode, | -| BYTE_ b_InterruptEnable) | +| Function Name : _INT_ i_APCI1710_InitIndex (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_ReferenceAction, | +| unsigned char_ b_IndexOperation, | +| unsigned char_ b_AutoMode, | +| unsigned char_ b_InterruptEnable) | +----------------------------------------------------------------------------+ | Task : Initialise the index corresponding to the selected | | module (b_ModulNbr). If a INDEX flag occur, you have | @@ -665,10 +665,10 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus) | | | value is cleared (32-Bit) | | | +------------------------+------------------------------------+ | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_ReferenceAction : Determine if the reference | +| unsigned char_ b_ReferenceAction : Determine if the reference | | must set or no for the | | acceptance from index | | APCI1710_ENABLE : | @@ -677,15 +677,15 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus) | APCI1710_DISABLE : | | Reference have not | | importance | -| BYTE_ b_IndexOperation : Index operating mode. | +| unsigned char_ b_IndexOperation : Index operating mode. | | See table. | -| BYTE_ b_AutoMode : Enable or disable the | +| unsigned char_ b_AutoMode : Enable or disable the | | automatic index reset. | | APCI1710_ENABLE : | | Enable the automatic mode | | APCI1710_DISABLE : | | Disable the automatic mode | -| BYTE_ b_InterruptEnable : Enable or disable the | +| unsigned char_ b_InterruptEnable : Enable or disable the | | interrupt. | | APCI1710_ENABLE : | | Enable the interrupt | @@ -708,12 +708,12 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitIndex(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_ReferenceAction, - BYTE b_IndexOperation, BYTE b_AutoMode, BYTE b_InterruptEnable) +int i_APCI1710_InitIndex(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_ReferenceAction, + unsigned char b_IndexOperation, unsigned char b_AutoMode, unsigned char b_InterruptEnable) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -902,7 +902,7 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev, b_ModeRegister4 | APCI1710_ENABLE_LATCH_AND_CLEAR; - } // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) + } /* if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */ else { /*****************************************/ /* Clear the latch and clear flag (DQ27) */ @@ -975,7 +975,7 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev, & (~APCI1710_INDEX_LATCH_COUNTER); } - } // // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) + } /* // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */ if (b_AutoMode == APCI1710_DISABLE) @@ -1113,15 +1113,15 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitReference | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_ReferenceLevel) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_ReferenceLevel) | +----------------------------------------------------------------------------+ | Task : Initialise the reference corresponding to the selected | | module (b_ModulNbr). | @@ -1136,10 +1136,10 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev, | | APCI1710_HIGH | Reference occur if "1" | | | +--------------------+-------------------------+ | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_ReferenceLevel : Reference level. | +| unsigned char_ b_ReferenceLevel : Reference level. | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -1152,10 +1152,10 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitReference(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_ReferenceLevel) +int i_APCI1710_InitReference(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_ReferenceLevel) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -1239,27 +1239,27 @@ INT i_APCI1710_InitReference(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitExternalStrobe | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_ExternalStrobe, | -| BYTE_ b_ExternalStrobeLevel) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_ExternalStrobe, | +| unsigned char_ b_ExternalStrobeLevel) | +----------------------------------------------------------------------------+ | Task : Initialises the external strobe level corresponding to | | the selected module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_ExternalStrobe : External strobe selection | +| unsigned char_ b_ExternalStrobe : External strobe selection | | 0 : External strobe A | | 1 : External strobe B | -| BYTE_ b_ExternalStrobeLevel : External strobe level | +| unsigned char_ b_ExternalStrobeLevel : External strobe level | | APCI1710_LOW : | | External latch occurs if "0" | | APCI1710_HIGH : | @@ -1277,10 +1277,10 @@ INT i_APCI1710_InitReference(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_ExternalStrobe, BYTE b_ExternalStrobeLevel) +int i_APCI1710_InitExternalStrobe(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_ExternalStrobe, unsigned char b_ExternalStrobeLevel) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -1335,7 +1335,7 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev, DPRINTK("External strobe level parameter is wrong\n"); i_ReturnValue = -5; } - } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) + } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */ else { /**************************************/ /* External strobe selection is wrong */ @@ -1343,7 +1343,7 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev, DPRINTK("External strobe selection is wrong\n"); i_ReturnValue = -4; - } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) + } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */ } else { /****************************************/ /* Counter not initialised see function */ @@ -1362,24 +1362,24 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitCompareLogic | - | (BYTE_ b_BoardHandle, | - | BYTE_ b_ModulNbr, | - | UINT_ ui_CompareValue) | + | (unsigned char_ b_BoardHandle, | + | unsigned char_ b_ModulNbr, | + | unsigned int_ ui_CompareValue) | +----------------------------------------------------------------------------+ | Task : Set the 32-Bit compare value. At that moment that the | | incremental counter arrive to the compare value | | (ui_CompareValue) a interrupt is generated. | +----------------------------------------------------------------------------+ - | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | - | BYTE_ b_ModulNbr : Module number to configure | + | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | + | unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | - | UINT_ ui_CompareValue : 32-Bit compare value | + | unsigned int_ ui_CompareValue : 32-Bit compare value | +----------------------------------------------------------------------------+ | Output Parameters : - +----------------------------------------------------------------------------+ @@ -1391,10 +1391,10 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitCompareLogic(struct comedi_device * dev, - BYTE b_ModulNbr, UINT ui_CompareValue) +int i_APCI1710_InitCompareLogic(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int ui_CompareValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -1434,16 +1434,16 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitFrequencyMeasurement | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PCIInputClock, | -| BYTE_ b_TimingUnity, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PCIInputClock, | +| unsigned char_ b_TimingUnity, | | ULONG_ ul_TimingInterval, | | PULONG_ pul_RealTimingInterval) | +----------------------------------------------------------------------------+ @@ -1456,10 +1456,10 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev, | you call up any other function which gives access to | | the frequency measurement. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Number of the module to be | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | -| BYTE_ b_PCIInputClock : Selection of the PCI bus | +| unsigned char_ b_PCIInputClock : Selection of the PCI bus | | clock | | - APCI1710_30MHZ : | | The PC has a PCI bus clock | @@ -1467,7 +1467,7 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev, | - APCI1710_33MHZ : | | The PC has a PCI bus clock | | of 33 MHz | -| BYTE_ b_TimingUnity : Base time unit (0 to 2) | +| unsigned char_ b_TimingUnity : Base time unit (0 to 2) | | 0 : ns | | 1 : æs | | 2 : ms | @@ -1487,16 +1487,16 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_PCIInputClock, - BYTE b_TimingUnity, - ULONG ul_TimingInterval, PULONG pul_RealTimingInterval) +int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PCIInputClock, + unsigned char b_TimingUnity, + unsigned int ul_TimingInterval, unsigned int *pul_RealTimingInterval) { - INT i_ReturnValue = 0; - ULONG ul_TimerValue = 0; + int i_ReturnValue = 0; + unsigned int ul_TimerValue = 0; double d_RealTimingInterval; - DWORD dw_Status = 0; + unsigned int dw_Status = 0; /**************************/ /* Test the module number */ @@ -1637,7 +1637,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, i_ReturnValue = -7; } - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ /***************************/ /* Test if not error occur */ @@ -1676,7 +1676,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, b_ModeRegister4 | APCI1710_ENABLE_40MHZ_FREQUENCY; - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ else { /**********************************/ /* Disable the 40MHz quarz (DQ30) */ @@ -1700,7 +1700,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, & APCI1710_DISABLE_40MHZ_FREQUENCY; - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ /********************************/ /* Calculate the division fator */ @@ -1720,7 +1720,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (0.00025 * b_PCIInputClock)); @@ -1743,7 +1743,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, *pul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (0.00025 * (double)b_PCIInputClock)); @@ -1790,7 +1790,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (0.25 * b_PCIInputClock)); @@ -1813,7 +1813,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, *pul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (0.25 * (double)b_PCIInputClock)); @@ -1886,7 +1886,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, *pul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (250.0 * (double)b_PCIInputClock)); @@ -1949,7 +1949,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, i_ReturnValue = -3; } - } // if (i_ReturnValue == 0) + } /* if (i_ReturnValue == 0) */ } else { /**********************************/ /* Base timing selection is wrong */ @@ -1992,12 +1992,12 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /*########################################################################### */ - //INSN BITS + /* INSN BITS */ /*########################################################################### */ /* @@ -2015,18 +2015,18 @@ struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_BitsType; - INT i_ReturnValue = 0; + unsigned int ui_BitsType; + int i_ReturnValue = 0; ui_BitsType = CR_CHAN(insn->chanspec); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ switch (ui_BitsType) { case APCI1710_INCCPT_CLEARCOUNTERVALUE: i_ReturnValue = i_APCI1710_ClearCounterValue(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_CLEARALLCOUNTERVALUE: @@ -2035,28 +2035,28 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic case APCI1710_INCCPT_SETINPUTFILTER: i_ReturnValue = i_APCI1710_SetInputFilter(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) data[0], (BYTE) data[1]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) data[0], (unsigned char) data[1]); break; case APCI1710_INCCPT_LATCHCOUNTER: i_ReturnValue = i_APCI1710_LatchCounter(dev, - (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); break; case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE: i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev, - (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); break; case APCI1710_INCCPT_SETDIGITALCHLON: i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_SETDIGITALCHLOFF: i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; default: @@ -2065,20 +2065,20 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ClearCounterValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Clear the counter value from selected module | | (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -2091,9 +2091,9 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -2131,17 +2131,17 @@ INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ClearAllCounterValue | -| (BYTE_ b_BoardHandle) | +| (unsigned char_ b_BoardHandle) | +----------------------------------------------------------------------------+ | Task : Clear all counter value. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -2151,10 +2151,10 @@ INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev) +int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev) { - BYTE b_ModulCpt = 0; - INT i_ReturnValue = 0; + unsigned char b_ModulCpt = 0; + int i_ReturnValue = 0; /********************************/ /* Test if counter module found */ @@ -2198,24 +2198,24 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetInputFilter | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_Module, | -| BYTE_ b_PCIInputClock, | -| BYTE_ b_Filter) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_Module, | +| unsigned char_ b_PCIInputClock, | +| unsigned char_ b_Filter) | +----------------------------------------------------------------------------+ | Task : Disable or enable the software filter from selected | | module (b_ModulNbr). b_Filter determine the filter time| +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Number of the module to be | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | -| BYTE_ b_PCIInputClock : Selection of the PCI bus | +| unsigned char_ b_PCIInputClock : Selection of the PCI bus | | clock | | - APCI1710_30MHZ : | | The PC has a PCI bus clock | @@ -2226,7 +2226,7 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev) | - APCI1710_40MHZ : | | The APCI1710 has a 40MHz | | quartz | -| BYTE_ b_Filter : Filter selection | +| unsigned char_ b_Filter : Filter selection | | | | 30 MHz | | ------ | @@ -2297,11 +2297,11 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_SetInputFilter(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_PCIInputClock, BYTE b_Filter) +int i_APCI1710_SetInputFilter(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_PCIInputClock, unsigned char b_Filter) { - INT i_ReturnValue = 0; - DWORD dw_Status = 0; + int i_ReturnValue = 0; + unsigned int dw_Status = 0; /**************************/ /* Test the module number */ @@ -2365,7 +2365,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, i_ReturnValue = -6; } - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ /***************************/ /* Test if error not occur */ @@ -2401,7 +2401,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, | APCI1710_ENABLE_40MHZ_FILTER; - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ else { /**********************************/ /* Disable the 40MHz quarz (DQ31) */ @@ -2425,7 +2425,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, & APCI1710_DISABLE_40MHZ_FILTER; - } // if (b_PCIInputClock == APCI1710_40MHZ) + } /* if (b_PCIInputClock == APCI1710_40MHZ) */ /************************/ /* Set the filter value */ @@ -2486,8 +2486,8 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, ui_Address + 20 + (64 * b_ModulNbr)); - } // if (i_ReturnValue == 0) - } // if (b_Filter < 16) + } /* if (i_ReturnValue == 0) */ + } /* if (b_Filter < 16) */ else { /**************************************/ /* The selected filter value is wrong */ @@ -2495,8 +2495,8 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, DPRINTK("The selected filter value is wrong\n"); i_ReturnValue = -5; - } // if (b_Filter < 16) - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) + } /* if (b_Filter < 16) */ + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */ else { /*****************************************/ /* The selected PCI input clock is wrong */ @@ -2504,7 +2504,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, DPRINTK("The selected PCI input clock is wrong\n"); i_ReturnValue = 4; - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */ } else { /**************************************/ /* The module is not a counter module */ @@ -2530,23 +2530,23 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_LatchCounter (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_LatchReg) | +| Function Name : _INT_ i_APCI1710_LatchCounter (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_LatchReg) | +----------------------------------------------------------------------------+ | Task : Latch the courant value from selected module | | (b_ModulNbr) in to the selected latch register | | (b_LatchReg). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_LatchReg : Selected latch register | +| unsigned char_ b_LatchReg : Selected latch register | | 0 : for the first latch register | | 1 : for the second latch register | +----------------------------------------------------------------------------+ @@ -2561,10 +2561,10 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_LatchCounter(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_LatchReg) +int i_APCI1710_LatchCounter(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -2616,25 +2616,25 @@ INT i_APCI1710_LatchCounter(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetIndexAndReferenceSource | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SourceSelection) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SourceSelection) | +----------------------------------------------------------------------------+ | Task : Determine the hardware source for the index and the | | reference logic. Per default the index logic is | | connected to the difference input C and the reference | | logic is connected to the 24V input E | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_SourceSelection : APCI1710_SOURCE_0 : | +| unsigned char_ b_SourceSelection : APCI1710_SOURCE_0 : | | The index logic is connected | | to the difference input C and| | the reference logic is | @@ -2658,10 +2658,10 @@ INT i_APCI1710_LatchCounter(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_SourceSelection) +int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_SourceSelection) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -2735,7 +2735,7 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev, b_ModeRegister4 & APCI1710_DEFAULT_INDEX_RFERENCE; } - } // if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) + } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */ else { /*********************************/ /* The source selection is wrong */ @@ -2743,7 +2743,7 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev, DPRINTK("The source selection is wrong\n"); i_ReturnValue = -4; - } // if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) + } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */ } else { /**************************************/ /* The module is not a counter module */ @@ -2769,20 +2769,20 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetDigitalChlOn | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Sets the digital output H Setting an output means | | setting an ouput high. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Number of the module to be | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -2795,9 +2795,9 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -2849,20 +2849,20 @@ INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetDigitalChlOff | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Resets the digital output H. Resetting an output means | | setting an ouput low. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Number of the module to be | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -2875,9 +2875,9 @@ INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_SetDigitalChlOff(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -2929,12 +2929,12 @@ INT i_APCI1710_SetDigitalChlOff(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /*########################################################################### */ - // INSN WRITE + /* INSN WRITE */ /*########################################################################### */ /* @@ -2951,65 +2951,65 @@ struct comedi_insn *insn,unsigned int *data) | | Return Value : +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_WriteType; - INT i_ReturnValue = 0; + unsigned int ui_WriteType; + int i_ReturnValue = 0; ui_WriteType = CR_CHAN(insn->chanspec); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ switch (ui_WriteType) { case APCI1710_INCCPT_ENABLELATCHINTERRUPT: i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_DISABLELATCHINTERRUPT: i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE: i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) data[0], (UINT) data[1]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) data[0], (unsigned int) data[1]); break; case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE: i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev, - (BYTE) CR_AREF(insn->chanspec), (ULONG) data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]); break; case APCI1710_INCCPT_ENABLEINDEX: - i_APCI1710_EnableIndex(dev, (BYTE) CR_AREF(insn->chanspec)); + i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_DISABLEINDEX: i_ReturnValue = i_APCI1710_DisableIndex(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_ENABLECOMPARELOGIC: i_ReturnValue = i_APCI1710_EnableCompareLogic(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_DISABLECOMPARELOGIC: i_ReturnValue = i_APCI1710_DisableCompareLogic(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT: i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev, - (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); break; case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT: i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev, - (BYTE) CR_AREF(insn->chanspec)); + (unsigned char) CR_AREF(insn->chanspec)); break; default: @@ -3018,21 +3018,21 @@ INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevi if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableLatchInterrupt | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Enable the latch interrupt from selected module | | (b_ModulNbr). Each software or hardware latch occur a | | interrupt. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -3047,9 +3047,9 @@ INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevi +----------------------------------------------------------------------------+ */ -INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3105,20 +3105,20 @@ INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_DisableLatchInterrupt | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Disable the latch interrupt from selected module | | (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -3133,9 +3133,9 @@ INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3198,27 +3198,27 @@ INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Write16BitCounterValue | -| (BYTE_ b_BoardHandle | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SelectedCounter, | -| UINT_ ui_WriteValue) | +| (unsigned char_ b_BoardHandle | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SelectedCounter, | +| unsigned int_ ui_WriteValue) | +----------------------------------------------------------------------------+ | Task : Write a 16-Bit value (ui_WriteValue) in to the selected| | 16-Bit counter (b_SelectedCounter) from selected module| | (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_SelectedCounter : Selected 16-Bit counter | +| unsigned char_ b_SelectedCounter : Selected 16-Bit counter | | (0 or 1) | -| UINT_ ui_WriteValue : 16-Bit write value | +| unsigned int_ ui_WriteValue : 16-Bit write value | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -3231,10 +3231,10 @@ INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr +----------------------------------------------------------------------------+ */ -INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_SelectedCounter, UINT ui_WriteValue) +int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int ui_WriteValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3257,7 +3257,7 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev, /* Write the value */ /*******************/ - outl((ULONG) ((ULONG) (ui_WriteValue) << (16 * + outl((unsigned int) ((unsigned int) (ui_WriteValue) << (16 * b_SelectedCounter)), devpriv->s_BoardInfos.ui_Address + 8 + (b_SelectedCounter * 4) + @@ -3288,21 +3288,21 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Write32BitCounterValue | -| (BYTE_ b_BoardHandle | -| BYTE_ b_ModulNbr, | +| (unsigned char_ b_BoardHandle | +| unsigned char_ b_ModulNbr, | | ULONG_ ul_WriteValue) | +----------------------------------------------------------------------------+ | Task : Write a 32-Bit value (ui_WriteValue) in to the selected| | module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | | ULONG_ ul_WriteValue : 32-Bit write value | +----------------------------------------------------------------------------+ @@ -3316,10 +3316,10 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev, - BYTE b_ModulNbr, ULONG ul_WriteValue) +int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int ul_WriteValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3357,18 +3357,18 @@ INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableIndex (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| Function Name : _INT_ i_APCI1710_EnableIndex (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Enable the INDEX actions | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -3383,10 +3383,10 @@ INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; - ULONG ul_InterruptLatchReg; + int i_ReturnValue = 0; + unsigned int ul_InterruptLatchReg; /**************************/ /* Test the module number */ @@ -3455,18 +3455,18 @@ INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisableIndex (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| Function Name : _INT_ i_APCI1710_DisableIndex (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Disable the INDEX actions | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -3481,9 +3481,9 @@ INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3549,21 +3549,21 @@ INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableCompareLogic | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Enable the 32-Bit compare logic. At that moment that | | the incremental counter arrive to the compare value a | | interrupt is generated. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - @@ -3580,9 +3580,9 @@ INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3653,19 +3653,19 @@ INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_DisableCompareLogic | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Disable the 32-Bit compare logic. +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - @@ -3680,9 +3680,9 @@ INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3753,22 +3753,22 @@ INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableFrequencyMeasurement | - | (BYTE_ b_BoardHandle, | - | BYTE_ b_ModulNbr, | - | BYTE_ b_InterruptEnable) | + | (unsigned char_ b_BoardHandle, | + | unsigned char_ b_ModulNbr, | + | unsigned char_ b_InterruptEnable) | +----------------------------------------------------------------------------+ | Task : Enables the frequency measurement function | +----------------------------------------------------------------------------+ - | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | - | BYTE_ b_ModulNbr : Number of the module to be | + | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | + | unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | - | BYTE_ b_InterruptEnable: Enable or disable the | + | unsigned char_ b_InterruptEnable: Enable or disable the | | interrupt. | | APCI1710_ENABLE: | | Enable the interrupt | @@ -3789,10 +3789,10 @@ INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_InterruptEnable) +int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_InterruptEnable) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3909,19 +3909,19 @@ INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_DisableFrequencyMeasurement | - | (BYTE_ b_BoardHandle, | - | BYTE_ b_ModulNbr) | + | (unsigned char_ b_BoardHandle, | + | unsigned char_ b_ModulNbr) | +----------------------------------------------------------------------------+ | Task : Disables the frequency measurement function | +----------------------------------------------------------------------------+ - | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | - | BYTE_ b_ModulNbr : Number of the module to be | + | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | + | unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -3936,9 +3936,9 @@ INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_ModulNbr) +int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, unsigned char b_ModulNbr) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -3976,9 +3976,9 @@ INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_Mo s_ByteModeRegister. b_ModeRegister3 & APCI1710_DISABLE_FREQUENCY - // Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared + /* Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */ & APCI1710_DISABLE_FREQUENCY_INT; - // End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared + /* End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */ /***************************/ /* Write the configuration */ @@ -4026,12 +4026,12 @@ INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_Mo i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /*########################################################################### */ - // INSN READ + /* INSN READ */ /*########################################################################### */ @@ -4049,82 +4049,82 @@ struct comedi_insn *insn,unsigned int *data) | | Return Value : +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_ReadType; - INT i_ReturnValue = 0; + unsigned int ui_ReadType; + int i_ReturnValue = 0; ui_ReadType = CR_CHAN(insn->chanspec); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ switch (ui_ReadType) { case APCI1710_INCCPT_READLATCHREGISTERSTATUS: i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) CR_RANGE(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_READLATCHREGISTERVALUE: i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) CR_RANGE(insn->chanspec), (PULONG) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]); printk("Latch Register Value %d\n", data[0]); break; case APCI1710_INCCPT_READ16BITCOUNTERVALUE: i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) CR_RANGE(insn->chanspec), (PUINT) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]); break; case APCI1710_INCCPT_READ32BITCOUNTERVALUE: i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev, - (BYTE) CR_AREF(insn->chanspec), (PULONG) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]); break; case APCI1710_INCCPT_GETINDEXSTATUS: i_ReturnValue = i_APCI1710_GetIndexStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_GETREFERENCESTATUS: i_ReturnValue = i_APCI1710_GetReferenceStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_GETUASSTATUS: i_ReturnValue = i_APCI1710_GetUASStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_GETCBSTATUS: i_ReturnValue = i_APCI1710_GetCBStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_GET16BITCBSTATUS: i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev, - (BYTE) CR_AREF(insn->chanspec), - (PBYTE) & data[0], (PBYTE) & data[1]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char *) &data[0], (unsigned char *) &data[1]); break; case APCI1710_INCCPT_GETUDSTATUS: i_ReturnValue = i_APCI1710_GetUDStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS: i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev, - (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); break; case APCI1710_INCCPT_READFREQUENCYMEASUREMENT: i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev, - (BYTE) CR_AREF(insn->chanspec), - (PBYTE) & data[0], - (PBYTE) & data[1], (PULONG) & data[2]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char *) &data[0], + (unsigned char *) &data[1], (unsigned int *) &data[2]); break; case APCI1710_INCCPT_READINTERRUPT: @@ -4155,29 +4155,29 @@ INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevic if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadLatchRegisterStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_LatchReg, | -| PBYTE_ pb_LatchStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_LatchReg, | +| unsigned char *_ pb_LatchStatus) | +----------------------------------------------------------------------------+ | Task : Read the latch register status from selected module | | (b_ModulNbr) and selected latch register (b_LatchReg). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_LatchReg : Selected latch register | +| unsigned char_ b_LatchReg : Selected latch register | | 0 : for the first latch register | | 1 : for the second latch register | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_LatchStatus : Latch register status. | +| Output Parameters : unsigned char *_ pb_LatchStatus : Latch register status. | | 0 : No latch occur | | 1 : A software latch occur | | 2 : A hardware latch occur | @@ -4193,11 +4193,11 @@ INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_LatchReg, PBYTE pb_LatchStatus) +int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned char *pb_LatchStatus) { - INT i_ReturnValue = 0; - DWORD dw_LatchReg; + int i_ReturnValue = 0; + unsigned int dw_LatchReg; /**************************/ /* Test the module number */ @@ -4220,7 +4220,7 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev, ui_Address + (64 * b_ModulNbr)); *pb_LatchStatus = - (BYTE) ((dw_LatchReg >> (b_LatchReg * + (unsigned char) ((dw_LatchReg >> (b_LatchReg * 4)) & 0x3); } else { /**************************************************/ @@ -4248,24 +4248,24 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadLatchRegisterValue | -| (BYTE_ b_BoardHandle,| -| BYTE_ b_ModulNbr, | -| BYTE_ b_LatchReg, | +| (unsigned char_ b_BoardHandle,| +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_LatchReg, | | PULONG_ pul_LatchValue) | +----------------------------------------------------------------------------+ | Task : Read the latch register value from selected module | | (b_ModulNbr) and selected latch register (b_LatchReg). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_LatchReg : Selected latch register | +| unsigned char_ b_LatchReg : Selected latch register | | 0 : for the first latch register | | 1 : for the second latch register | +----------------------------------------------------------------------------+ @@ -4280,10 +4280,10 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_LatchReg, PULONG pul_LatchValue) +int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned int *pul_LatchValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -4332,28 +4332,28 @@ INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Read16BitCounterValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SelectedCounter, | -| PUINT_ pui_CounterValue) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SelectedCounter, | +| unsigned int *_ pui_CounterValue) | +----------------------------------------------------------------------------+ | Task : Latch the selected 16-Bit counter (b_SelectedCounter) | | from selected module (b_ModulNbr) in to the first | | latch register and return the latched value. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| BYTE_ b_SelectedCounter : Selected 16-Bit counter | +| unsigned char_ b_SelectedCounter : Selected 16-Bit counter | | (0 or 1) | +----------------------------------------------------------------------------+ -| Output Parameters : PUINT_ pui_CounterValue : 16-Bit counter value | +| Output Parameters : unsigned int *_ pui_CounterValue : 16-Bit counter value | +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -4364,11 +4364,11 @@ INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev, - BYTE b_ModulNbr, BYTE b_SelectedCounter, PUINT pui_CounterValue) +int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int *pui_CounterValue) { - INT i_ReturnValue = 0; - DWORD dw_LathchValue = 0; + int i_ReturnValue = 0; + unsigned int dw_LathchValue = 0; /**************************/ /* Test the module number */ @@ -4402,7 +4402,7 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev, ui_Address + 4 + (64 * b_ModulNbr)); *pui_CounterValue = - (UINT) ((dw_LathchValue >> (16 * + (unsigned int) ((dw_LathchValue >> (16 * b_SelectedCounter)) & 0xFFFFU); } else { @@ -4431,22 +4431,22 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Read32BitCounterValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | | PULONG_ pul_CounterValue) | +----------------------------------------------------------------------------+ | Task : Latch the 32-Bit counter from selected module | | (b_ModulNbr) in to the first latch register and return | | the latched value. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_CounterValue : 32-Bit counter value | @@ -4459,10 +4459,10 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev, - BYTE b_ModulNbr, PULONG pul_CounterValue) +int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int *pul_CounterValue) { - INT i_ReturnValue = 0; + int i_ReturnValue = 0; /**************************/ /* Test the module number */ @@ -4507,22 +4507,22 @@ INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetIndexStatus (BYTE_ b_BoardHandle,| -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_IndexStatus)| +| Function Name : _INT_ i_APCI1710_GetIndexStatus (unsigned char_ b_BoardHandle,| +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_IndexStatus)| +----------------------------------------------------------------------------+ | Task : Return the index status | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_IndexStatus : 0 : No INDEX occur | +| Output Parameters : unsigned char *_ pb_IndexStatus : 0 : No INDEX occur | | 1 : A INDEX occur | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -4535,11 +4535,11 @@ INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetIndexStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_IndexStatus) +int i_APCI1710_GetIndexStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_IndexStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4563,7 +4563,7 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev, dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + 12 + (64 * b_ModulNbr)); - *pb_IndexStatus = (BYTE) (dw_StatusReg & 1); + *pb_IndexStatus = (unsigned char) (dw_StatusReg & 1); } else { /*************************************************************/ /* Index not initialised see function "i_APCI1710_InitIndex" */ @@ -4590,23 +4590,23 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetReferenceStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_ReferenceStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_ReferenceStatus) | +----------------------------------------------------------------------------+ | Task : Return the reference status | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_ReferenceStatus : 0 : No REFERENCE occur | +| Output Parameters : unsigned char *_ pb_ReferenceStatus : 0 : No REFERENCE occur | | 1 : A REFERENCE occur | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -4619,11 +4619,11 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_ReferenceStatus) +int i_APCI1710_GetReferenceStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4649,7 +4649,7 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev, ui_Address + 24 + (64 * b_ModulNbr)); *pb_ReferenceStatus = - (BYTE) (~dw_StatusReg & 1); + (unsigned char) (~dw_StatusReg & 1); } else { /*********************************************************************/ /* Reference not initialised see function "i_APCI1710_InitReference" */ @@ -4676,23 +4676,23 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetUASStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_UASStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_UASStatus) | +----------------------------------------------------------------------------+ | Task : Return the error signal (UAS) status | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_UASStatus : 0 : UAS is low "0" | +| Output Parameters : unsigned char *_ pb_UASStatus : 0 : UAS is low "0" | | 1 : UAS is high "1" | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -4703,11 +4703,11 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetUASStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_UASStatus) +int i_APCI1710_GetUASStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UASStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4724,7 +4724,7 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev, dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + 24 + (64 * b_ModulNbr)); - *pb_UASStatus = (BYTE) ((dw_StatusReg >> 1) & 1); + *pb_UASStatus = (unsigned char) ((dw_StatusReg >> 1) & 1); } else { /****************************************/ /* Counter not initialised see function */ @@ -4744,23 +4744,23 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev, } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetCBStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_CBStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_CBStatus) | +----------------------------------------------------------------------------+ | Task : Return the counter overflow status | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_CBStatus : 0 : Counter no overflow | +| Output Parameters : unsigned char *_ pb_CBStatus : 0 : Counter no overflow | | 1 : Counter overflow | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -4771,11 +4771,11 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetCBStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_CBStatus) +int i_APCI1710_GetCBStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_CBStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4792,7 +4792,7 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev, dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + 16 + (64 * b_ModulNbr)); - *pb_CBStatus = (BYTE) (dw_StatusReg & 1); + *pb_CBStatus = (unsigned char) (dw_StatusReg & 1); } else { /****************************************/ @@ -4812,31 +4812,31 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Get16BitCBStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_CBStatusCounter0, | -| PBYTE_ pb_CBStatusCounter1) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_CBStatusCounter0, | +| unsigned char *_ pb_CBStatusCounter1) | +----------------------------------------------------------------------------+ | Task : Returns the counter overflow (counter initialised to | | 2*16-bit) status from selected incremental counter | | module | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_CBStatusCounter0 : 0 : No overflow occur for | +| Output Parameters : unsigned char *_ pb_CBStatusCounter0 : 0 : No overflow occur for | | the first 16-bit | | counter | | 1 : Overflow occur for the| | first 16-bit counter | -| PBYTE_ pb_CBStatusCounter1 : 0 : No overflow occur for | +| unsigned char *_ pb_CBStatusCounter1 : 0 : No overflow occur for | | the second 16-bit | | counter | | 1 : Overflow occur for the| @@ -4853,11 +4853,11 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_CBStatusCounter0, PBYTE pb_CBStatusCounter1) +int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0, unsigned char *pb_CBStatusCounter1) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4894,20 +4894,20 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, (64 * b_ModulNbr)); *pb_CBStatusCounter1 = - (BYTE) ((dw_StatusReg >> 0) & + (unsigned char) ((dw_StatusReg >> 0) & 1); *pb_CBStatusCounter0 = - (BYTE) ((dw_StatusReg >> 1) & + (unsigned char) ((dw_StatusReg >> 1) & 1); - } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) + } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */ else { /****************************/ /* Firmware revision error */ /****************************/ i_ReturnValue = -5; - } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) - } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) + } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */ + } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */ else { /********************************************/ /* Counter not initialised to 2*16-bit mode */ @@ -4916,8 +4916,8 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, DPRINTK("Counter not initialised\n"); i_ReturnValue = -4; - } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) - } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) + } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */ + } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */ else { /****************************************/ /* Counter not initialised see function */ @@ -4926,8 +4926,8 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, DPRINTK("Counter not initialised\n"); i_ReturnValue = -3; - } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) - } // if (b_ModulNbr < 4) + } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */ + } /* if (b_ModulNbr < 4) */ else { /*************************************************/ /* The selected module number parameter is wrong */ @@ -4935,25 +4935,25 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, DPRINTK("The selected module number parameter is wrong\n"); i_ReturnValue = -2; - } // if (b_ModulNbr < 4) + } /* if (b_ModulNbr < 4) */ - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetUDStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_UDStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_UDStatus) | +----------------------------------------------------------------------------+ | Task : Return the counter progress status | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_UDStatus : 0 : Counter progress in the | +| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the | | selected mode down | | 1 : Counter progress in the | | selected mode up | @@ -4966,11 +4966,11 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetUDStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_UDStatus) +int i_APCI1710_GetUDStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UDStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -4987,7 +4987,7 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev, dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + 24 + (64 * b_ModulNbr)); - *pb_UDStatus = (BYTE) ((dw_StatusReg >> 2) & 1); + *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 2) & 1); } else { /****************************************/ @@ -5007,24 +5007,24 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetInterruptUDLatchedStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| PBYTE_ pb_UDStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char *_ pb_UDStatus) | +----------------------------------------------------------------------------+ | Task : Return the counter progress latched status after a | | index interrupt occur. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_UDStatus : 0 : Counter progress in the | +| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the | | selected mode down | | 1 : Counter progress in the | | selected mode up | @@ -5040,11 +5040,11 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev, - BYTE b_ModulNbr, PBYTE pb_UDStatus) +int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UDStatus) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; /**************************/ /* Test the module number */ @@ -5074,7 +5074,7 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev, dw_StatusReg = inl(devpriv->s_BoardInfos. ui_Address + 12 + (64 * b_ModulNbr)); - *pb_UDStatus = (BYTE) ((dw_StatusReg >> 1) & 1); + *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 1) & 1); } else { /****************************/ /* No index interrupt occur */ @@ -5100,26 +5100,26 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadFrequencyMeasurement | - | (BYTE_ b_BoardHandle, | - | BYTE_ b_ModulNbr, | - | PBYTE_ pb_Status, | + | (unsigned char_ b_BoardHandle, | + | unsigned char_ b_ModulNbr, | + | unsigned char *_ pb_Status, | | PULONG_ pul_ReadValue) | +----------------------------------------------------------------------------+ | Task : Returns the status (pb_Status) and the number of | | increments in the set time. | | See function " i_APCI1710_InitFrequencyMeasurement " | +----------------------------------------------------------------------------+ - | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | - | BYTE_ b_ModulNbr : Number of the module to be | + | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | + | unsigned char_ b_ModulNbr : Number of the module to be | | configured (0 to 3) | +----------------------------------------------------------------------------+ - | Output Parameters : PBYTE_ pb_Status : Returns the frequency | + | Output Parameters : unsigned char *_ pb_Status : Returns the frequency | | measurement status | | 0 : Counting cycle not | | started. | @@ -5127,7 +5127,7 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev, | 2 : Counting cycle stopped. | | The measurement cycle is | | completed. | - | PBYTE_ pb_UDStatus : 0 : Counter progress in the | + | unsigned char *_ pb_UDStatus : 0 : Counter progress in the | | selected mode down | | 1 : Counter progress in the | | selected mode up | @@ -5145,13 +5145,13 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, - BYTE b_ModulNbr, - PBYTE pb_Status, PBYTE pb_UDStatus, PULONG pul_ReadValue) +int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char *pb_Status, unsigned char *pb_UDStatus, unsigned int *pul_ReadValue) { - INT i_ReturnValue = 0; - UINT ui_16BitValue; - DWORD dw_StatusReg; + int i_ReturnValue = 0; + unsigned int ui_16BitValue; + unsigned int dw_StatusReg; /**************************/ /* Test the module number */ @@ -5198,7 +5198,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, if (dw_StatusReg & 1) { *pb_Status = 2; *pb_UDStatus = - (BYTE) ((dw_StatusReg >> + (unsigned char) ((dw_StatusReg >> 1) & 3); /******************/ @@ -5224,7 +5224,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, if ((*pul_ReadValue & 0xFFFFU) != 0) { ui_16BitValue = - (UINT) + (unsigned int) * pul_ReadValue & @@ -5247,7 +5247,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, if ((*pul_ReadValue & 0xFFFF0000UL) != 0) { ui_16BitValue = - (UINT) + (unsigned int) ( (*pul_ReadValue >> @@ -5281,7 +5281,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, if ((*pul_ReadValue & 0xFFFF0000UL) != 0) { ui_16BitValue = - (UINT) + (unsigned int) ( (*pul_ReadValue >> @@ -5307,7 +5307,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, if ((*pul_ReadValue & 0xFFFFU) != 0) { ui_16BitValue = - (UINT) + (unsigned int) * pul_ReadValue & @@ -5359,5 +5359,5 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h index 5153cf686658..7b481107fe1d 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h @@ -132,140 +132,140 @@ #define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409 /************ Main Functions *************/ -INT i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int * data); -INT i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, +int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, struct comedi_insn *insn, unsigned int * data); -INT i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, +int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, struct comedi_insn *insn, unsigned int * data); -INT i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, +int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, struct comedi_insn *insn, unsigned int * data); /*********** Supplementary Functions********/ /* INSN CONFIG */ -INT i_APCI1710_InitCounter(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_CounterRange, - BYTE b_FirstCounterModus, - BYTE b_FirstCounterOption, - BYTE b_SecondCounterModus, - BYTE b_SecondCounterOption); - -INT i_APCI1710_CounterAutoTest(struct comedi_device *dev, PBYTE pb_TestStatus); - -INT i_APCI1710_InitIndex(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_ReferenceAction, - BYTE b_IndexOperation, BYTE b_AutoMode, - BYTE b_InterruptEnable); - -INT i_APCI1710_InitReference(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_ReferenceLevel); - -INT i_APCI1710_InitExternalStrobe(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_ExternalStrobe, - BYTE b_ExternalStrobeLevel); - -INT i_APCI1710_InitCompareLogic(struct comedi_device *dev, - BYTE b_ModulNbr, UINT ui_CompareValue); - -INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_PCIInputClock, - BYTE b_TimingUnity, - ULONG ul_TimingInterval, - PULONG pul_RealTimingInterval); +int i_APCI1710_InitCounter(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_CounterRange, + unsigned char b_FirstCounterModus, + unsigned char b_FirstCounterOption, + unsigned char b_SecondCounterModus, + unsigned char b_SecondCounterOption); + +int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char * pb_TestStatus); + +int i_APCI1710_InitIndex(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_ReferenceAction, + unsigned char b_IndexOperation, unsigned char b_AutoMode, + unsigned char b_InterruptEnable); + +int i_APCI1710_InitReference(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_ReferenceLevel); + +int i_APCI1710_InitExternalStrobe(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_ExternalStrobe, + unsigned char b_ExternalStrobeLevel); + +int i_APCI1710_InitCompareLogic(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int ui_CompareValue); + +int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PCIInputClock, + unsigned char b_TimingUnity, + unsigned int ul_TimingInterval, + unsigned int *pul_RealTimingInterval); /* INSN BITS */ -INT i_APCI1710_ClearCounterValue(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_ClearAllCounterValue(struct comedi_device *dev); +int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev); -INT i_APCI1710_SetInputFilter(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_PCIInputClock, - BYTE b_Filter); +int i_APCI1710_SetInputFilter(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_PCIInputClock, + unsigned char b_Filter); -INT i_APCI1710_LatchCounter(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_LatchReg); +int i_APCI1710_LatchCounter(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg); -INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_SourceSelection); +int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_SourceSelection); -INT i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr); /* INSN WRITE */ -INT i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_SelectedCounter, - UINT ui_WriteValue); +int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_SelectedCounter, + unsigned int ui_WriteValue); -INT i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, - BYTE b_ModulNbr, ULONG ul_WriteValue); +int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int ul_WriteValue); -INT i_APCI1710_EnableIndex(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_DisableIndex(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_EnableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_DisableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr); +int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr); -INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_InterruptEnable); +int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_InterruptEnable); -INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, - BYTE b_ModulNbr); +int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr); /* INSN READ */ -INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_LatchReg, - PBYTE pb_LatchStatus); +int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg, + unsigned char *pb_LatchStatus); -INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_LatchReg, - PULONG pul_LatchValue); +int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_LatchReg, + unsigned int *pul_LatchValue); -INT i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, - BYTE b_ModulNbr, BYTE b_SelectedCounter, - PUINT pui_CounterValue); +int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char b_SelectedCounter, + unsigned int *pui_CounterValue); -INT i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, - BYTE b_ModulNbr, PULONG pul_CounterValue); +int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned int *pul_CounterValue); -INT i_APCI1710_GetIndexStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_IndexStatus); +int i_APCI1710_GetIndexStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_IndexStatus); -INT i_APCI1710_GetReferenceStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_ReferenceStatus); +int i_APCI1710_GetReferenceStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus); -INT i_APCI1710_GetUASStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_UASStatus); +int i_APCI1710_GetUASStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UASStatus); -INT i_APCI1710_GetCBStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_CBStatus); +int i_APCI1710_GetCBStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_CBStatus); -INT i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_CBStatusCounter0, - PBYTE pb_CBStatusCounter1); +int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0, + unsigned char *pb_CBStatusCounter1); -INT i_APCI1710_GetUDStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_UDStatus); +int i_APCI1710_GetUDStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UDStatus); -INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, - BYTE b_ModulNbr, PBYTE pb_UDStatus); +int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, + unsigned char b_ModulNbr, unsigned char *pb_UDStatus); -INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, - BYTE b_ModulNbr, - PBYTE pb_Status, PBYTE pb_UDStatus, - PULONG pul_ReadValue); +int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char *pb_Status, unsigned char *pb_UDStatus, + unsigned int *pul_ReadValue); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c index 3ac6a264ef54..0fc2285c9ef8 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -60,11 +60,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitPulseEncoder | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PulseEncoderNbr, | -| BYTE_ b_InputLevelSelection, | -| BYTE_ b_TriggerOutputAction, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PulseEncoderNbr, | +| unsigned char_ b_InputLevelSelection, | +| unsigned char_ b_TriggerOutputAction, | | ULONG_ ul_StartValue) | +----------------------------------------------------------------------------+ | Task : Configure the pulse encoder operating mode selected via| @@ -74,12 +74,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | You must calling this function be for you call any | | other function witch access of pulse encoders. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_PulseEncoderNbr : Pulse encoder selection | +| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | | (0 to 3) | -| BYTE_ b_InputLevelSelection : Input level selection | +| unsigned char_ b_InputLevelSelection : Input level selection | | (0 or 1) | | 0 : Set pulse encoder| | count the the low| @@ -87,7 +87,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | 1 : Set pulse encoder| | count the the | | high level pulse.| -| BYTE_ b_TriggerOutputAction : Digital TRIGGER output | +| unsigned char_ b_TriggerOutputAction : Digital TRIGGER output | | action | | 0 : No action | | 1 : Set the trigger | @@ -104,11 +104,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | encoder | | ULONG_ ul_StartValue : Pulse encoder start value| | (1 to 4294967295) - b_ModulNbr =(BYTE) CR_AREF(insn->chanspec); - b_PulseEncoderNbr =(BYTE) data[0]; - b_InputLevelSelection =(BYTE) data[1]; - b_TriggerOutputAction =(BYTE) data[2]; - ul_StartValue =(ULONG) data[3]; + b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); + b_PulseEncoderNbr =(unsigned char) data[0]; + b_InputLevelSelection =(unsigned char) data[1]; + b_TriggerOutputAction =(unsigned char) data[2]; + ul_StartValue =(unsigned int) data[3]; | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -123,23 +123,23 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_IntRegister; + int i_ReturnValue = 0; + unsigned int dw_IntRegister; - BYTE b_ModulNbr; - BYTE b_PulseEncoderNbr; - BYTE b_InputLevelSelection; - BYTE b_TriggerOutputAction; - ULONG ul_StartValue; + unsigned char b_ModulNbr; + unsigned char b_PulseEncoderNbr; + unsigned char b_InputLevelSelection; + unsigned char b_TriggerOutputAction; + unsigned int ul_StartValue; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_PulseEncoderNbr = (BYTE) data[0]; - b_InputLevelSelection = (BYTE) data[1]; - b_TriggerOutputAction = (BYTE) data[2]; - ul_StartValue = (ULONG) data[3]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_PulseEncoderNbr = (unsigned char) data[0]; + b_InputLevelSelection = (unsigned char) data[1]; + b_TriggerOutputAction = (unsigned char) data[2]; + ul_StartValue = (unsigned int) data[3]; i_ReturnValue = insn->n; @@ -346,17 +346,17 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnablePulseEncoder | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PulseEncoderNbr, | -| BYTE_ b_CycleSelection, | -| BYTE_ b_InterruptHandling) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PulseEncoderNbr, | +| unsigned char_ b_CycleSelection, | +| unsigned char_ b_InterruptHandling) | +----------------------------------------------------------------------------+ | Task : Enableor disable the selected pulse encoder (b_PulseEncoderNbr) | | from selected module (b_ModulNbr). Each input pulse | @@ -365,12 +365,12 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, | interrupt is generated when the pulse encoder has run | | down. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_PulseEncoderNbr : Pulse encoder selection | +| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | | (0 to 3) | -| BYTE_ b_CycleSelection : APCI1710_CONTINUOUS: | +| unsigned char_ b_CycleSelection : APCI1710_CONTINUOUS: | | Each time the | | counting value is set| | on "0", the pulse | @@ -381,7 +381,7 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, | If the counter is set| | on "0", the pulse | | encoder is stopped. | -| BYTE_ b_InterruptHandling : Interrupts can be | +| unsigned char_ b_InterruptHandling : Interrupts can be | | generated, when the pulse| | encoder has run down. | | With this parameter the | @@ -393,11 +393,11 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, | APCI1710_DISABLE: | | Interrupts are disabled - b_ModulNbr =(BYTE) CR_AREF(insn->chanspec); - b_Action =(BYTE) data[0]; - b_PulseEncoderNbr =(BYTE) data[1]; - b_CycleSelection =(BYTE) data[2]; - b_InterruptHandling =(BYTE) data[3];| + b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); + b_Action =(unsigned char) data[0]; + b_PulseEncoderNbr =(unsigned char) data[1]; + b_CycleSelection =(unsigned char) data[2]; + b_InterruptHandling =(unsigned char) data[3];| +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -414,22 +414,22 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr; - BYTE b_PulseEncoderNbr; - BYTE b_CycleSelection; - BYTE b_InterruptHandling; - BYTE b_Action; + int i_ReturnValue = 0; + unsigned char b_ModulNbr; + unsigned char b_PulseEncoderNbr; + unsigned char b_CycleSelection; + unsigned char b_InterruptHandling; + unsigned char b_Action; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_Action = (BYTE) data[0]; - b_PulseEncoderNbr = (BYTE) data[1]; - b_CycleSelection = (BYTE) data[2]; - b_InterruptHandling = (BYTE) data[3]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_Action = (unsigned char) data[0]; + b_PulseEncoderNbr = (unsigned char) data[1]; + b_CycleSelection = (unsigned char) data[2]; + b_InterruptHandling = (unsigned char) data[3]; /***********************************/ /* Test the selected module number */ @@ -515,7 +515,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev, | (1UL << b_PulseEncoderNbr); - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ } @@ -629,7 +629,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev, (64 * b_ModulNbr)); break; - } // switch End + } /* switch End */ } else { /*********************************/ @@ -656,39 +656,39 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadPulseEncoderStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PulseEncoderNbr, | -| PBYTE_ pb_Status) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PulseEncoderNbr, | +| unsigned char *_ pb_Status) | +----------------------------------------------------------------------------+ | Task APCI1710_PULSEENCODER_READ : Reads the pulse encoder status and valuefrom selected pulse | | encoder (b_PulseEncoderNbr) from selected module | | (b_ModulNbr). | +----------------------------------------------------------------------------+ - BYTE b_Type; data[0] + unsigned char b_Type; data[0] APCI1710_PULSEENCODER_WRITE Writes a 32-bit value (ul_WriteValue) into the selected| | pulse encoder (b_PulseEncoderNbr) from selected module | | (b_ModulNbr). This operation set the new start pulse | | encoder value. APCI1710_PULSEENCODER_READ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| CRAREF() BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| CRAREF() unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| data[1] BYTE_ b_PulseEncoderNbr : Pulse encoder selection | +| data[1] unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | | (0 to 3) APCI1710_PULSEENCODER_WRITE data[2] ULONG_ ul_WriteValue : 32-bit value to be | | written | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_Status : Pulse encoder status. | +| Output Parameters : unsigned char *_ pb_Status : Pulse encoder status. | | 0 : No overflow occur| | 1 : Overflow occur PULONG_ pul_ReadValue : Pulse encoder value | | @@ -702,30 +702,30 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -/*_INT_ i_APCI1710_ReadPulseEncoderStatus (BYTE_ b_BoardHandle, - BYTE_ b_ModulNbr, - BYTE_ b_PulseEncoderNbr, +/*_INT_ i_APCI1710_ReadPulseEncoderStatus (unsigned char_ b_BoardHandle, + unsigned char_ b_ModulNbr, + unsigned char_ b_PulseEncoderNbr, - PBYTE_ pb_Status) + unsigned char *_ pb_Status) */ -INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusRegister; - BYTE b_ModulNbr; - BYTE b_PulseEncoderNbr; - PBYTE pb_Status; - BYTE b_Type; - PULONG pul_ReadValue; - ULONG ul_WriteValue; + int i_ReturnValue = 0; + unsigned int dw_StatusRegister; + unsigned char b_ModulNbr; + unsigned char b_PulseEncoderNbr; + unsigned char *pb_Status; + unsigned char b_Type; + unsigned int *pul_ReadValue; + unsigned int ul_WriteValue; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_Type = (BYTE) data[0]; - b_PulseEncoderNbr = (BYTE) data[1]; - pb_Status = (PBYTE) & data[0]; - pul_ReadValue = (PULONG) & data[1]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_Type = (unsigned char) data[0]; + b_PulseEncoderNbr = (unsigned char) data[1]; + pb_Status = (unsigned char *) &data[0]; + pul_ReadValue = (unsigned int *) &data[1]; /***********************************/ /* Test the selected module number */ @@ -766,7 +766,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev, dw_StatusRegister; *pb_Status = - (BYTE) (devpriv-> + (unsigned char) (devpriv-> s_ModuleInfo[b_ModulNbr]. s_PulseEncoderModuleInfo. dw_StatusRegister >> (1 + @@ -794,7 +794,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev, break; case APCI1710_PULSEENCODER_WRITE: - ul_WriteValue = (ULONG) data[2]; + ul_WriteValue = (unsigned int) data[2]; /*******************/ /* Write the value */ /*******************/ @@ -805,7 +805,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev, (4 * b_PulseEncoderNbr) + (64 * b_ModulNbr)); - } //end of switch + } /* end of switch */ } else { /*********************************/ /* Pulse encoder not initialised */ @@ -831,11 +831,11 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } -INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->s_InterruptParameters. diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h index 28252873e862..61a21cc94063 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h @@ -21,11 +21,11 @@ #define APCI1710_PULSEENCODER_READ 0 #define APCI1710_PULSEENCODER_WRITE 1 -INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev, +int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, +int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -33,7 +33,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, /* * READ PULSE ENCODER FUNCTIONS */ -INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, +int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -41,7 +41,7 @@ INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, /* * WRITE PULSE ENCODER FUNCTIONS */ -INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev, +int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c index 5ddd092a656a..138a84f572c8 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -70,38 +70,38 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_ConfigType; - INT i_ReturnValue = 0; + unsigned char b_ConfigType; + int i_ReturnValue = 0; b_ConfigType = CR_CHAN(insn->chanspec); switch (b_ConfigType) { case APCI1710_PWM_INIT: - i_ReturnValue = i_APCI1710_InitPWM(dev, (BYTE) CR_AREF(insn->chanspec), // b_ModulNbr - (BYTE) data[0], //b_PWM - (BYTE) data[1], // b_ClockSelection - (BYTE) data[2], // b_TimingUnit - (ULONG) data[3], //ul_LowTiming - (ULONG) data[4], //ul_HighTiming - (PULONG) & data[0], //pul_RealLowTiming - (PULONG) & data[1] //pul_RealHighTiming + i_ReturnValue = i_APCI1710_InitPWM(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */ + (unsigned char) data[0], /* b_PWM */ + (unsigned char) data[1], /* b_ClockSelection */ + (unsigned char) data[2], /* b_TimingUnit */ + (unsigned int) data[3], /* ul_LowTiming */ + (unsigned int) data[4], /* ul_HighTiming */ + (unsigned int *) &data[0], /* pul_RealLowTiming */ + (unsigned int *) &data[1] /* pul_RealHighTiming */ ); break; case APCI1710_PWM_GETINITDATA: - i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (BYTE) CR_AREF(insn->chanspec), // b_ModulNbr - (BYTE) data[0], //b_PWM - (PBYTE) & data[0], //pb_TimingUnit - (PULONG) & data[1], //pul_LowTiming - (PULONG) & data[2], //pul_HighTiming - (PBYTE) & data[3], // pb_StartLevel - (PBYTE) & data[4], // pb_StopMode - (PBYTE) & data[5], // pb_StopLevel - (PBYTE) & data[6], // pb_ExternGate - (PBYTE) & data[7], // pb_InterruptEnable - (PBYTE) & data[8] // pb_Enable + i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */ + (unsigned char) data[0], /* b_PWM */ + (unsigned char *) &data[0], /* pb_TimingUnit */ + (unsigned int *) &data[1], /* pul_LowTiming */ + (unsigned int *) &data[2], /* pul_HighTiming */ + (unsigned char *) &data[3], /* pb_StartLevel */ + (unsigned char *) &data[4], /* pb_StopMode */ + (unsigned char *) &data[5], /* pb_StopLevel */ + (unsigned char *) &data[6], /* pb_ExternGate */ + (unsigned char *) &data[7], /* pb_InterruptEnable */ + (unsigned char *) &data[8] /* pb_Enable */ ); break; @@ -111,17 +111,17 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitPWM | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM, | -| BYTE_ b_ClockSelection, | -| BYTE_ b_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM, | +| unsigned char_ b_ClockSelection, | +| unsigned char_ b_TimingUnit, | | ULONG_ ul_LowTiming, | | ULONG_ ul_HighTiming, | | PULONG_ pul_RealLowTiming, | @@ -135,11 +135,11 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice | You must calling this function be for you call any | | other function witch access of the PWM. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure| +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure| | (0 to 3) | -| BYTE_ b_PWM : Selected PWM (0 or 1). | -| BYTE_ b_ClockSelection : Selection from PCI bus | +| unsigned char_ b_PWM : Selected PWM (0 or 1). | +| unsigned char_ b_ClockSelection : Selection from PCI bus | | clock | | - APCI1710_30MHZ : | | The PC have a 30 MHz | @@ -151,7 +151,7 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice | The APCI-1710 have a | | integrated 40Mhz | | quartz. | -| BYTE_ b_TimingUnit : Base timing Unit (0 to 4) | +| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) | | 0 : ns | | 1 : æs | | 2 : ms | @@ -179,19 +179,19 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InitPWM(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_PWM, - BYTE b_ClockSelection, - BYTE b_TimingUnit, - ULONG ul_LowTiming, - ULONG ul_HighTiming, - PULONG pul_RealLowTiming, PULONG pul_RealHighTiming) +int i_APCI1710_InitPWM(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char b_ClockSelection, + unsigned char b_TimingUnit, + unsigned int ul_LowTiming, + unsigned int ul_HighTiming, + unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming) { - INT i_ReturnValue = 0; - ULONG ul_LowTimerValue = 0; - ULONG ul_HighTimerValue = 0; - DWORD dw_Command; + int i_ReturnValue = 0; + unsigned int ul_LowTimerValue = 0; + unsigned int ul_HighTimerValue = 0; + unsigned int dw_Command; double d_RealLowTiming = 0; double d_RealHighTiming = 0; @@ -200,33 +200,33 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /******************/ + /******************/ /* Test the clock */ - /******************/ + /******************/ if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) { - /************************/ + /************************/ /* Test the timing unit */ - /************************/ + /************************/ if (b_TimingUnit <= 4) { - /*********************************/ + /*********************************/ /* Test the low timing selection */ - /*********************************/ + /*********************************/ if (((b_ClockSelection == APCI1710_30MHZ) @@ -361,45 +361,45 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, && (ul_LowTiming <= 7UL))) { - /**********************************/ + /**********************************/ /* Test the High timing selection */ - /**********************************/ + /**********************************/ if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) { - /**************************/ + /**************************/ /* Test the board version */ - /**************************/ + /**************************/ if (((b_ClockSelection == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_ClockSelection != APCI1710_40MHZ)) { - /************************************/ + /************************************/ /* Calculate the low division fator */ - /************************************/ + /************************************/ fpu_begin (); switch (b_TimingUnit) { - /******/ + /******/ /* ns */ - /******/ + /******/ case 0: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (0.00025 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -409,13 +409,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (0.00025 * (double)b_ClockSelection)); @@ -451,7 +451,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -461,26 +461,26 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* æs */ - /******/ + /******/ case 1: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (0.25 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -490,13 +490,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (0.25 * (double)b_ClockSelection)); @@ -534,7 +534,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -544,15 +544,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* ms */ - /******/ + /******/ case 2: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = @@ -562,9 +562,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, * b_ClockSelection); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -574,13 +574,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250.0 * (double)b_ClockSelection)); @@ -616,7 +616,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -626,27 +626,27 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /*****/ + /*****/ /* s */ - /*****/ + /*****/ case 3: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (250000.0 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -656,13 +656,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250000.0 @@ -701,7 +701,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -711,19 +711,19 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* mn */ - /******/ + /******/ case 4: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) ( (ul_LowTiming * @@ -733,9 +733,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -745,13 +745,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250000.0 @@ -795,7 +795,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -806,31 +806,31 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; } - /*************************************/ + /*************************************/ /* Calculate the high division fator */ - /*************************************/ + /*************************************/ switch (b_TimingUnit) { - /******/ + /******/ /* ns */ - /******/ + /******/ case 0: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (0.00025 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -840,13 +840,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (0.00025 * (double)b_ClockSelection)); @@ -882,7 +882,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -892,26 +892,26 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* æs */ - /******/ + /******/ case 1: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (0.25 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -921,13 +921,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (0.25 * (double)b_ClockSelection)); @@ -965,7 +965,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -975,15 +975,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* ms */ - /******/ + /******/ case 2: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = @@ -993,9 +993,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, * b_ClockSelection); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -1005,13 +1005,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250.0 * (double)b_ClockSelection)); @@ -1047,7 +1047,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -1057,28 +1057,28 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /*****/ + /*****/ /* s */ - /*****/ + /*****/ case 3: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (250000.0 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -1088,13 +1088,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250000.0 @@ -1133,7 +1133,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -1143,19 +1143,19 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, break; - /******/ + /******/ /* mn */ - /******/ + /******/ case 4: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) ( (ul_HighTiming * @@ -1165,9 +1165,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -1177,13 +1177,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ *pul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250000.0 @@ -1227,7 +1227,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -1239,9 +1239,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, } fpu_end(); - /****************************/ + /****************************/ /* Save the clock selection */ - /****************************/ + /****************************/ devpriv-> s_ModuleInfo @@ -1251,9 +1251,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, = b_ClockSelection; - /************************/ + /************************/ /* Save the timing unit */ - /************************/ + /************************/ devpriv-> s_ModuleInfo @@ -1265,9 +1265,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, = b_TimingUnit; - /****************************/ + /****************************/ /* Save the low base timing */ - /****************************/ + /****************************/ devpriv-> s_ModuleInfo @@ -1289,9 +1289,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, = *pul_RealLowTiming; - /****************************/ + /****************************/ /* Save the high base timing */ - /****************************/ + /****************************/ devpriv-> s_ModuleInfo @@ -1313,21 +1313,21 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, = *pul_RealHighTiming; - /************************/ + /************************/ /* Write the low timing */ - /************************/ + /************************/ outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr)); - /*************************/ + /*************************/ /* Write the high timing */ - /*************************/ + /*************************/ outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr)); - /***************************/ + /***************************/ /* Set the clock selection */ - /***************************/ + /***************************/ dw_Command = @@ -1354,15 +1354,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, 0x80; } - /***************************/ + /***************************/ /* Set the clock selection */ - /***************************/ + /***************************/ outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); - /*************/ + /*************/ /* PWM init. */ - /*************/ + /*************/ devpriv-> s_ModuleInfo [b_ModulNbr]. @@ -1373,98 +1373,98 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, = 1; } else { - /***************************************************/ + /***************************************************/ /* You can not used the 40MHz clock selection with */ /* this board */ - /***************************************************/ + /***************************************************/ DPRINTK("You can not used the 40MHz clock selection with this board\n"); i_ReturnValue = -9; } } else { - /***************************************/ + /***************************************/ /* High base timing selection is wrong */ - /***************************************/ + /***************************************/ DPRINTK("High base timing selection is wrong\n"); i_ReturnValue = -8; } } else { - /**************************************/ + /**************************************/ /* Low base timing selection is wrong */ - /**************************************/ + /**************************************/ DPRINTK("Low base timing selection is wrong\n"); i_ReturnValue = -7; } - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ else { - /**********************************/ + /**********************************/ /* Timing unit selection is wrong */ - /**********************************/ + /**********************************/ DPRINTK("Timing unit selection is wrong\n"); i_ReturnValue = -6; - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) - } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ + } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */ else { - /*******************************/ + /*******************************/ /* The selected clock is wrong */ - /*******************************/ + /*******************************/ DPRINTK("The selected clock is wrong\n"); i_ReturnValue = -5; - } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetPWMInitialisation | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM, | -| PBYTE_ pb_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM, | +| unsigned char *_ pb_TimingUnit, | | PULONG_ pul_LowTiming, | | PULONG_ pul_HighTiming, | -| PBYTE_ pb_StartLevel, | -| PBYTE_ pb_StopMode, | -| PBYTE_ pb_StopLevel, | -| PBYTE_ pb_ExternGate, | -| PBYTE_ pb_InterruptEnable, | -| PBYTE_ pb_Enable) | +| unsigned char *_ pb_StartLevel, | +| unsigned char *_ pb_StopMode, | +| unsigned char *_ pb_StopLevel, | +| unsigned char *_ pb_ExternGate, | +| unsigned char *_ pb_InterruptEnable, | +| unsigned char *_ pb_Enable) | +----------------------------------------------------------------------------+ | Task : Return the PWM (b_PWM) initialisation from selected | | module (b_ModulNbr). You must calling the | | "i_APCI1710_InitPWM" function be for you call this | | function. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_PWM : Selected PWM (0 or 1) | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_PWM : Selected PWM (0 or 1) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_TimingUnit : Base timing Unit (0 to 4) | +| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing Unit (0 to 4) | | 0 : ns | | 1 : æs | | 2 : ms | @@ -1472,13 +1472,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, | 4 : mn | | PULONG_ pul_LowTiming : Low base timing value. | | PULONG_ pul_HighTiming : High base timing value. | -| PBYTE_ pb_StartLevel : Start period level | +| unsigned char *_ pb_StartLevel : Start period level | | selection | | 0 : The period start | | with a low level | | 1 : The period start | | with a high level| -| PBYTE_ pb_StopMode : Stop mode selection | +| unsigned char *_ pb_StopMode : Stop mode selection | | 0 : The PWM is stopped | | directly after the | | "i_APCI1710_DisablePWM"| @@ -1489,7 +1489,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, | function the PWM is | | stopped at the end | | from last period cycle| -| PBYTE_ pb_StopLevel : Stop PWM level selection | +| unsigned char *_ pb_StopLevel : Stop PWM level selection | | 0 : The output signal | | keep the level after| | the | @@ -1504,13 +1504,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, | the | | "i_APCI1710_DisablePWM"| | function | -| PBYTE_ pb_ExternGate : Extern gate action | +| unsigned char *_ pb_ExternGate : Extern gate action | | selection | | 0 : Extern gate signal | | not used. | | 1 : Extern gate signal | | used. | -| PBYTE_ pb_InterruptEnable : Enable or disable the PWM | +| unsigned char *_ pb_InterruptEnable : Enable or disable the PWM | | interrupt. | | - APCI1710_ENABLE : | | Enable the PWM interrupt| @@ -1519,7 +1519,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, | - APCI1710_DISABLE : | | Disable the PWM | | interrupt | -| PBYTE_ pb_Enable : Indicate if the PWM is | +| unsigned char *_ pb_Enable : Indicate if the PWM is | | enabled or no | | 0 : PWM not enabled | | 1 : PWM enabled | @@ -1534,138 +1534,138 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_GetPWMInitialisation(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_PWM, - PBYTE pb_TimingUnit, - PULONG pul_LowTiming, - PULONG pul_HighTiming, - PBYTE pb_StartLevel, - PBYTE pb_StopMode, - PBYTE pb_StopLevel, - PBYTE pb_ExternGate, PBYTE pb_InterruptEnable, PBYTE pb_Enable) +int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char *pb_TimingUnit, + unsigned int *pul_LowTiming, + unsigned int *pul_HighTiming, + unsigned char *pb_StartLevel, + unsigned char *pb_StopMode, + unsigned char *pb_StopLevel, + unsigned char *pb_ExternGate, unsigned char *pb_InterruptEnable, unsigned char *pb_Enable) { - INT i_ReturnValue = 0; - DWORD dw_Status; - DWORD dw_Command; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned int dw_Command; /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /***************************/ + /***************************/ /* Test if PWM initialised */ - /***************************/ + /***************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { - /***********************/ + /***********************/ /* Read the low timing */ - /***********************/ + /***********************/ *pul_LowTiming = inl(devpriv->s_BoardInfos. ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr)); - /************************/ + /************************/ /* Read the high timing */ - /************************/ + /************************/ *pul_HighTiming = inl(devpriv->s_BoardInfos. ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr)); - /********************/ + /********************/ /* Read the command */ - /********************/ + /********************/ dw_Command = inl(devpriv->s_BoardInfos. ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); *pb_StartLevel = - (BYTE) ((dw_Command >> 5) & 1); + (unsigned char) ((dw_Command >> 5) & 1); *pb_StopMode = - (BYTE) ((dw_Command >> 0) & 1); + (unsigned char) ((dw_Command >> 0) & 1); *pb_StopLevel = - (BYTE) ((dw_Command >> 1) & 1); + (unsigned char) ((dw_Command >> 1) & 1); *pb_ExternGate = - (BYTE) ((dw_Command >> 4) & 1); + (unsigned char) ((dw_Command >> 4) & 1); *pb_InterruptEnable = - (BYTE) ((dw_Command >> 3) & 1); + (unsigned char) ((dw_Command >> 3) & 1); if (*pb_StopLevel) { *pb_StopLevel = *pb_StopLevel + - (BYTE) ((dw_Command >> + (unsigned char) ((dw_Command >> 2) & 1); } - /********************/ + /********************/ /* Read the command */ - /********************/ + /********************/ dw_Command = inl(devpriv->s_BoardInfos. ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); *pb_Enable = - (BYTE) ((dw_Command >> 0) & 1); + (unsigned char) ((dw_Command >> 0) & 1); *pb_TimingUnit = devpriv-> s_ModuleInfo[b_ModulNbr]. s_PWMModuleInfo. s_PWMInfo[b_PWM].b_TimingUnit; - } // if (dw_Status & 0x10) + } /* if (dw_Status & 0x10) */ else { - /***********************/ + /***********************/ /* PWM not initialised */ - /***********************/ + /***********************/ DPRINTK("PWM not initialised\n"); i_ReturnValue = -5; - } // if (dw_Status & 0x10) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (dw_Status & 0x10) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1683,33 +1683,33 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_WriteType; - INT i_ReturnValue = 0; + unsigned char b_WriteType; + int i_ReturnValue = 0; b_WriteType = CR_CHAN(insn->chanspec); switch (b_WriteType) { case APCI1710_PWM_ENABLE: i_ReturnValue = i_APCI1710_EnablePWM(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) data[0], - (BYTE) data[1], - (BYTE) data[2], - (BYTE) data[3], (BYTE) data[4], (BYTE) data[5]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) data[0], + (unsigned char) data[1], + (unsigned char) data[2], + (unsigned char) data[3], (unsigned char) data[4], (unsigned char) data[5]); break; case APCI1710_PWM_DISABLE: i_ReturnValue = i_APCI1710_DisablePWM(dev, - (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]); + (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); break; case APCI1710_PWM_NEWTIMING: i_ReturnValue = i_APCI1710_SetNewPWMTiming(dev, - (BYTE) CR_AREF(insn->chanspec), - (BYTE) data[0], - (BYTE) data[1], (ULONG) data[2], (ULONG) data[3]); + (unsigned char) CR_AREF(insn->chanspec), + (unsigned char) data[0], + (unsigned char) data[1], (unsigned int) data[2], (unsigned int) data[3]); break; default: @@ -1718,20 +1718,20 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice if (i_ReturnValue >= 0) i_ReturnValue = insn->n; - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnablePWM | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM, | -| BYTE_ b_StartLevel, | -| BYTE_ b_StopMode, | -| BYTE_ b_StopLevel, | -| BYTE_ b_ExternGate, | -| BYTE_ b_InterruptEnable) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM, | +| unsigned char_ b_StartLevel, | +| unsigned char_ b_StopMode, | +| unsigned char_ b_StopLevel, | +| unsigned char_ b_ExternGate, | +| unsigned char_ b_InterruptEnable) | +----------------------------------------------------------------------------+ | Task : Enable the selected PWM (b_PWM) from selected module | | (b_ModulNbr). You must calling the "i_APCI1710_InitPWM"| @@ -1741,16 +1741,16 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice | See function "i_APCI1710_SetBoardIntRoutineX" and the | | Interrupt mask description chapter. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number | | (0 to 3) | -| BYTE_ b_PWM : Selected PWM (0 or 1) | -| BYTE_ b_StartLevel : Start period level selection | +| unsigned char_ b_PWM : Selected PWM (0 or 1) | +| unsigned char_ b_StartLevel : Start period level selection | | 0 : The period start with a | | low level | | 1 : The period start with a | | high level | -| BYTE_ b_StopMode : Stop mode selection | +| unsigned char_ b_StopMode : Stop mode selection | | 0 : The PWM is stopped | | directly after the | | "i_APCI1710_DisablePWM" | @@ -1761,7 +1761,7 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice | function the PWM is | | stopped at the end from| | last period cycle. | -| BYTE_ b_StopLevel : Stop PWM level selection | +| unsigned char_ b_StopLevel : Stop PWM level selection | | 0 : The output signal keep | | the level after the | | "i_APCI1710_DisablePWM" | @@ -1774,11 +1774,11 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice | to high after the | | "i_APCI1710_DisablePWM" | | function | -| BYTE_ b_ExternGate : Extern gate action selection | +| unsigned char_ b_ExternGate : Extern gate action selection | | 0 : Extern gate signal not | | used. | | 1 : Extern gate signal used.| -| BYTE_ b_InterruptEnable : Enable or disable the PWM | +| unsigned char_ b_InterruptEnable : Enable or disable the PWM | | interrupt. | | - APCI1710_ENABLE : | | Enable the PWM interrupt | @@ -1806,77 +1806,77 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI1710_EnablePWM(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_PWM, - BYTE b_StartLevel, - BYTE b_StopMode, - BYTE b_StopLevel, BYTE b_ExternGate, BYTE b_InterruptEnable) +int i_APCI1710_EnablePWM(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char b_StartLevel, + unsigned char b_StopMode, + unsigned char b_StopLevel, unsigned char b_ExternGate, unsigned char b_InterruptEnable) { - INT i_ReturnValue = 0; - DWORD dw_Status; - DWORD dw_Command; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned int dw_Command; - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /***************************/ + /***************************/ /* Test if PWM initialised */ - /***************************/ + /***************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { - /**********************************/ + /**********************************/ /* Test the start level selection */ - /**********************************/ + /**********************************/ if (b_StartLevel <= 1) { - /**********************/ + /**********************/ /* Test the stop mode */ - /**********************/ + /**********************/ if (b_StopMode <= 1) { - /***********************/ + /***********************/ /* Test the stop level */ - /***********************/ + /***********************/ if (b_StopLevel <= 2) { - /*****************************/ + /*****************************/ /* Test the extern gate mode */ - /*****************************/ + /*****************************/ if (b_ExternGate <= 1) { - /*****************************/ + /*****************************/ /* Test the interrupt action */ - /*****************************/ + /*****************************/ if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) { - /******************************************/ + /******************************************/ /* Test if interrupt function initialised */ - /******************************************/ + /******************************************/ - /********************/ + /********************/ /* Read the command */ - /********************/ + /********************/ dw_Command = @@ -1895,9 +1895,9 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev, & 0x80; - /********************/ + /********************/ /* Make the command */ - /********************/ + /********************/ dw_Command = @@ -1943,100 +1943,100 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev, = b_InterruptEnable; - /*******************/ + /*******************/ /* Set the command */ - /*******************/ + /*******************/ outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); - /******************/ + /******************/ /* Enable the PWM */ - /******************/ + /******************/ outl(1, devpriv->s_BoardInfos.ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); - } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) + } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */ else { - /********************************/ + /********************************/ /* Interrupt parameter is wrong */ - /********************************/ + /********************************/ DPRINTK("Interrupt parameter is wrong\n"); i_ReturnValue = -10; - } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) - } // if (b_ExternGate >= 0 && b_ExternGate <= 1) + } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */ + } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ else { - /*****************************************/ + /*****************************************/ /* Extern gate signal selection is wrong */ - /*****************************************/ + /*****************************************/ DPRINTK("Extern gate signal selection is wrong\n"); i_ReturnValue = -9; - } // if (b_ExternGate >= 0 && b_ExternGate <= 1) - } // if (b_StopLevel >= 0 && b_StopLevel <= 2) + } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ + } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */ else { - /*************************************/ + /*************************************/ /* PWM stop level selection is wrong */ - /*************************************/ + /*************************************/ DPRINTK("PWM stop level selection is wrong\n"); i_ReturnValue = -8; - } // if (b_StopLevel >= 0 && b_StopLevel <= 2) - } // if (b_StopMode >= 0 && b_StopMode <= 1) + } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */ + } /* if (b_StopMode >= 0 && b_StopMode <= 1) */ else { - /************************************/ + /************************************/ /* PWM stop mode selection is wrong */ - /************************************/ + /************************************/ DPRINTK("PWM stop mode selection is wrong\n"); i_ReturnValue = -7; - } // if (b_StopMode >= 0 && b_StopMode <= 1) - } // if (b_StartLevel >= 0 && b_StartLevel <= 1) + } /* if (b_StopMode >= 0 && b_StopMode <= 1) */ + } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */ else { - /**************************************/ + /**************************************/ /* PWM start level selection is wrong */ - /**************************************/ + /**************************************/ DPRINTK("PWM start level selection is wrong\n"); i_ReturnValue = -6; - } // if (b_StartLevel >= 0 && b_StartLevel <= 1) - } // if (dw_Status & 0x10) + } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */ + } /* if (dw_Status & 0x10) */ else { - /***********************/ + /***********************/ /* PWM not initialised */ - /***********************/ + /***********************/ DPRINTK("PWM not initialised\n"); i_ReturnValue = -5; - } // if (dw_Status & 0x10) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (dw_Status & 0x10) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisablePWM (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM) | +| Function Name : _INT_ i_APCI1710_DisablePWM (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM) | +----------------------------------------------------------------------------+ | Task : Disable the selected PWM (b_PWM) from selected module | | (b_ModulNbr). The output signal level depend of the | @@ -2045,8 +2045,8 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev, | parameters from this function. | +----------------------------------------------------------------------------+ | Input Parameters :BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_PWM : Selected PWM (0 or 1) | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_PWM : Selected PWM (0 or 1) | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -2062,99 +2062,99 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PWM) +int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM) { - INT i_ReturnValue = 0; - DWORD dw_Status; + int i_ReturnValue = 0; + unsigned int dw_Status; /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /***************************/ + /***************************/ /* Test if PWM initialised */ - /***************************/ + /***************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { - /***********************/ + /***********************/ /* Test if PWM enabled */ - /***********************/ + /***********************/ if (dw_Status & 0x1) { - /*******************/ + /*******************/ /* Disable the PWM */ - /*******************/ + /*******************/ outl(0, devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); - } // if (dw_Status & 0x1) + } /* if (dw_Status & 0x1) */ else { - /*******************/ + /*******************/ /* PWM not enabled */ - /*******************/ + /*******************/ DPRINTK("PWM not enabled\n"); i_ReturnValue = -6; - } // if (dw_Status & 0x1) - } // if (dw_Status & 0x10) + } /* if (dw_Status & 0x1) */ + } /* if (dw_Status & 0x10) */ else { - /***********************/ + /***********************/ /* PWM not initialised */ - /***********************/ + /***********************/ DPRINTK(" PWM not initialised\n"); i_ReturnValue = -5; - } // if (dw_Status & 0x10) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (dw_Status & 0x10) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetNewPWMTiming | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM, | -| BYTE_ b_ClockSelection, | -| BYTE_ b_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM, | +| unsigned char_ b_ClockSelection, | +| unsigned char_ b_TimingUnit, | | ULONG_ ul_LowTiming, | | ULONG_ ul_HighTiming) | +----------------------------------------------------------------------------+ @@ -2162,11 +2162,11 @@ INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PW | ul_TimingUnit determine the low/high timing base for | | the period. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Module number to configure| +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Module number to configure| | (0 to 3) | -| BYTE_ b_PWM : Selected PWM (0 or 1). | -| BYTE_ b_TimingUnit : Base timing Unit (0 to 4) | +| unsigned char_ b_PWM : Selected PWM (0 or 1). | +| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) | | 0 : ns | | 1 : æs | | 2 : ms | @@ -2189,18 +2189,18 @@ INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PW +----------------------------------------------------------------------------+ */ -INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, - BYTE b_ModulNbr, - BYTE b_PWM, BYTE b_TimingUnit, ULONG ul_LowTiming, ULONG ul_HighTiming) +int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, unsigned char b_TimingUnit, unsigned int ul_LowTiming, unsigned int ul_HighTiming) { - BYTE b_ClockSelection; - INT i_ReturnValue = 0; - ULONG ul_LowTimerValue = 0; - ULONG ul_HighTimerValue = 0; - ULONG ul_RealLowTiming = 0; - ULONG ul_RealHighTiming = 0; - DWORD dw_Status; - DWORD dw_Command; + unsigned char b_ClockSelection; + int i_ReturnValue = 0; + unsigned int ul_LowTimerValue = 0; + unsigned int ul_HighTimerValue = 0; + unsigned int ul_RealLowTiming = 0; + unsigned int ul_RealHighTiming = 0; + unsigned int dw_Status; + unsigned int dw_Command; double d_RealLowTiming = 0; double d_RealHighTiming = 0; @@ -2209,21 +2209,21 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /***************************/ + /***************************/ /* Test if PWM initialised */ - /***************************/ + /***************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + @@ -2235,14 +2235,14 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, s_PWMModuleInfo. b_ClockSelection; - /************************/ + /************************/ /* Test the timing unit */ - /************************/ + /************************/ if (b_TimingUnit <= 4) { - /*********************************/ + /*********************************/ /* Test the low timing selection */ - /*********************************/ + /*********************************/ if (((b_ClockSelection == APCI1710_30MHZ) @@ -2377,37 +2377,37 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, && (ul_LowTiming <= 7UL))) { - /**********************************/ + /**********************************/ /* Test the High timing selection */ - /**********************************/ + /**********************************/ if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) { - /************************************/ + /************************************/ /* Calculate the low division fator */ - /************************************/ + /************************************/ fpu_begin(); switch (b_TimingUnit) { - /******/ + /******/ /* ns */ - /******/ + /******/ case 0: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (0.00025 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -2417,13 +2417,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (0.00025 * (double)b_ClockSelection)); @@ -2459,7 +2459,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -2469,26 +2469,26 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* æs */ - /******/ + /******/ case 1: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (0.25 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -2498,13 +2498,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (0.25 * (double)b_ClockSelection)); @@ -2542,7 +2542,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -2552,15 +2552,15 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* ms */ - /******/ + /******/ case 2: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = @@ -2570,9 +2570,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, * b_ClockSelection); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -2582,13 +2582,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250.0 * (double)b_ClockSelection)); @@ -2624,7 +2624,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -2634,28 +2634,28 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /*****/ + /*****/ /* s */ - /*****/ + /*****/ case 3: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) (ul_LowTiming * (250000.0 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -2665,13 +2665,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250000.0 @@ -2710,7 +2710,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -2720,19 +2720,19 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* mn */ - /******/ + /******/ case 4: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_LowTimerValue = - (ULONG) + (unsigned int) ( (ul_LowTiming * @@ -2742,9 +2742,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { ul_LowTimerValue @@ -2754,13 +2754,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealLowTiming = - (ULONG) + (unsigned int) (ul_LowTimerValue / (250000.0 @@ -2804,7 +2804,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_LowTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_LowTimerValue) @@ -2815,31 +2815,31 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; } - /*************************************/ + /*************************************/ /* Calculate the high division fator */ - /*************************************/ + /*************************************/ switch (b_TimingUnit) { - /******/ + /******/ /* ns */ - /******/ + /******/ case 0: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (0.00025 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -2849,13 +2849,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (0.00025 * (double)b_ClockSelection)); @@ -2891,7 +2891,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -2901,26 +2901,26 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* æs */ - /******/ + /******/ case 1: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (0.25 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -2930,13 +2930,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (0.25 * (double)b_ClockSelection)); @@ -2974,7 +2974,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -2984,15 +2984,15 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* ms */ - /******/ + /******/ case 2: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = @@ -3002,9 +3002,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, * b_ClockSelection); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -3014,13 +3014,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250.0 * (double)b_ClockSelection)); @@ -3056,7 +3056,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -3066,28 +3066,28 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /*****/ + /*****/ /* s */ - /*****/ + /*****/ case 3: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) (ul_HighTiming * (250000.0 * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -3097,13 +3097,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250000.0 @@ -3142,7 +3142,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -3152,19 +3152,19 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, break; - /******/ + /******/ /* mn */ - /******/ + /******/ case 4: - /******************/ + /******************/ /* Timer 0 factor */ - /******************/ + /******************/ ul_HighTimerValue = - (ULONG) + (unsigned int) ( (ul_HighTiming * @@ -3174,9 +3174,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, * b_ClockSelection)); - /*******************/ + /*******************/ /* Round the value */ - /*******************/ + /*******************/ if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { ul_HighTimerValue @@ -3186,13 +3186,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 1; } - /*****************************/ + /*****************************/ /* Calculate the real timing */ - /*****************************/ + /*****************************/ ul_RealHighTiming = - (ULONG) + (unsigned int) (ul_HighTimerValue / (250000.0 @@ -3236,7 +3236,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, if (b_ClockSelection != APCI1710_40MHZ) { ul_HighTimerValue = - (ULONG) + (unsigned int) ( (double) (ul_HighTimerValue) @@ -3249,9 +3249,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, fpu_end(); - /************************/ + /************************/ /* Save the timing unit */ - /************************/ + /************************/ devpriv-> s_ModuleInfo @@ -3263,9 +3263,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, = b_TimingUnit; - /****************************/ + /****************************/ /* Save the low base timing */ - /****************************/ + /****************************/ devpriv-> s_ModuleInfo @@ -3287,9 +3287,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, = ul_RealLowTiming; - /****************************/ + /****************************/ /* Save the high base timing */ - /****************************/ + /****************************/ devpriv-> s_ModuleInfo @@ -3311,21 +3311,21 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, = ul_RealHighTiming; - /************************/ + /************************/ /* Write the low timing */ - /************************/ + /************************/ outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr)); - /*************************/ + /*************************/ /* Write the high timing */ - /*************************/ + /*************************/ outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr)); - /***************************/ + /***************************/ /* Set the clock selection */ - /***************************/ + /***************************/ dw_Command = inl @@ -3347,9 +3347,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, 0x80; } - /***************************/ + /***************************/ /* Set the clock selection */ - /***************************/ + /***************************/ outl(dw_Command, devpriv-> @@ -3358,96 +3358,96 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); } else { - /***************************************/ + /***************************************/ /* High base timing selection is wrong */ - /***************************************/ + /***************************************/ DPRINTK("High base timing selection is wrong\n"); i_ReturnValue = -8; } } else { - /**************************************/ + /**************************************/ /* Low base timing selection is wrong */ - /**************************************/ + /**************************************/ DPRINTK("Low base timing selection is wrong\n"); i_ReturnValue = -7; } - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ else { - /**********************************/ + /**********************************/ /* Timing unit selection is wrong */ - /**********************************/ + /**********************************/ DPRINTK("Timing unit selection is wrong\n"); i_ReturnValue = -6; - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) - } // if (dw_Status & 0x10) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ + } /* if (dw_Status & 0x10) */ else { - /***********************/ + /***********************/ /* PWM not initialised */ - /***********************/ + /***********************/ DPRINTK("PWM not initialised\n"); i_ReturnValue = -5; - } // if (dw_Status & 0x10) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (dw_Status & 0x10) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetPWMStatus | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PWM, | -| PBYTE_ pb_PWMOutputStatus, | -| PBYTE_ pb_ExternGateStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PWM, | +| unsigned char *_ pb_PWMOutputStatus, | +| unsigned char *_ pb_ExternGateStatus) | +----------------------------------------------------------------------------+ | Task : Return the status from selected PWM (b_PWM) from | | selected module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_PWM : Selected PWM (0 or 1) | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) - b_ModulNbr =(BYTE) CR_AREF(insn->chanspec); - b_PWM =(BYTE) data[0]; +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_PWM : Selected PWM (0 or 1) | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) + b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); + b_PWM =(unsigned char) data[0]; | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_PWMOutputStatus : Return the PWM output | +| Output Parameters : unsigned char *_ pb_PWMOutputStatus : Return the PWM output | | level status. | | 0 : The PWM output level| | is low. | | 1 : The PWM output level| | is high. | -| PBYTE_ pb_ExternGateStatus : Return the extern gate | +| unsigned char *_ pb_ExternGateStatus : Return the extern gate | | level status. | | 0 : The extern gate is | | low. | | 1 : The extern gate is | | high. - pb_PWMOutputStatus =(PBYTE) data[0]; - pb_ExternGateStatus =(PBYTE) data[1]; | + pb_PWMOutputStatus =(unsigned char *) data[0]; + pb_ExternGateStatus =(unsigned char *) data[1]; | +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -3460,109 +3460,109 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadGetPWMStatus(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_Status; + int i_ReturnValue = 0; + unsigned int dw_Status; - BYTE b_ModulNbr; - BYTE b_PWM; - PBYTE pb_PWMOutputStatus; - PBYTE pb_ExternGateStatus; + unsigned char b_ModulNbr; + unsigned char b_PWM; + unsigned char *pb_PWMOutputStatus; + unsigned char *pb_ExternGateStatus; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_PWM = (BYTE) CR_CHAN(insn->chanspec); - pb_PWMOutputStatus = (PBYTE) & data[0]; - pb_ExternGateStatus = (PBYTE) & data[1]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_PWM = (unsigned char) CR_CHAN(insn->chanspec); + pb_PWMOutputStatus = (unsigned char *) &data[0]; + pb_ExternGateStatus = (unsigned char *) &data[1]; /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { - /***************/ + /***************/ /* Test if PWM */ - /***************/ + /***************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ + /**************************/ /* Test the PWM selection */ - /**************************/ + /**************************/ if (b_PWM <= 1) { - /***************************/ + /***************************/ /* Test if PWM initialised */ - /***************************/ + /***************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { - /***********************/ + /***********************/ /* Test if PWM enabled */ - /***********************/ + /***********************/ if (dw_Status & 0x1) { *pb_PWMOutputStatus = - (BYTE) ((dw_Status >> 7) + (unsigned char) ((dw_Status >> 7) & 1); *pb_ExternGateStatus = - (BYTE) ((dw_Status >> 6) + (unsigned char) ((dw_Status >> 6) & 1); - } // if (dw_Status & 0x1) + } /* if (dw_Status & 0x1) */ else { - /*******************/ + /*******************/ /* PWM not enabled */ - /*******************/ + /*******************/ DPRINTK("PWM not enabled \n"); i_ReturnValue = -6; - } // if (dw_Status & 0x1) - } // if (dw_Status & 0x10) + } /* if (dw_Status & 0x1) */ + } /* if (dw_Status & 0x10) */ else { - /***********************/ + /***********************/ /* PWM not initialised */ - /***********************/ + /***********************/ DPRINTK("PWM not initialised\n"); i_ReturnValue = -5; - } // if (dw_Status & 0x10) - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (dw_Status & 0x10) */ + } /* if (b_PWM >= 0 && b_PWM <= 1) */ else { - /******************************/ + /******************************/ /* Tor PWM selection is wrong */ - /******************************/ + /******************************/ DPRINTK("Tor PWM selection is wrong\n"); i_ReturnValue = -4; - } // if (b_PWM >= 0 && b_PWM <= 1) + } /* if (b_PWM >= 0 && b_PWM <= 1) */ } else { - /**********************************/ + /**********************************/ /* The module is not a PWM module */ - /**********************************/ + /**********************************/ DPRINTK("The module is not a PWM module\n"); i_ReturnValue = -3; } } else { - /***********************/ + /***********************/ /* Module number error */ - /***********************/ + /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } -INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->s_InterruptParameters. s_FIFOInterruptParameters[devpriv-> @@ -3574,9 +3574,9 @@ INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device * dev, s_FIFOInterruptParameters[devpriv-> s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - /**************************/ + /**************************/ /* Increment the read FIFO */ - /***************************/ + /***************************/ devpriv-> s_InterruptParameters. diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h index c1b7f4ca47c3..bf1b4c39a1cd 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h @@ -26,51 +26,51 @@ #define APCI1710_PWM_ENABLE 1 #define APCI1710_PWM_NEWTIMING 2 -INT i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InitPWM(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_PWM, - BYTE b_ClockSelection, - BYTE b_TimingUnit, - ULONG ul_LowTiming, - ULONG ul_HighTiming, - PULONG pul_RealLowTiming, PULONG pul_RealHighTiming); +int i_APCI1710_InitPWM(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char b_ClockSelection, + unsigned char b_TimingUnit, + unsigned int ul_LowTiming, + unsigned int ul_HighTiming, + unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming); -INT i_APCI1710_GetPWMInitialisation(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_PWM, - PBYTE pb_TimingUnit, - PULONG pul_LowTiming, - PULONG pul_HighTiming, - PBYTE pb_StartLevel, - PBYTE pb_StopMode, - PBYTE pb_StopLevel, - PBYTE pb_ExternGate, - PBYTE pb_InterruptEnable, PBYTE pb_Enable); +int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char *pb_TimingUnit, + unsigned int *pul_LowTiming, + unsigned int *pul_HighTiming, + unsigned char *pb_StartLevel, + unsigned char *pb_StopMode, + unsigned char *pb_StopLevel, + unsigned char *pb_ExternGate, + unsigned char *pb_InterruptEnable, unsigned char *pb_Enable); -INT i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_EnablePWM(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_PWM, - BYTE b_StartLevel, - BYTE b_StopMode, - BYTE b_StopLevel, BYTE b_ExternGate, - BYTE b_InterruptEnable); +int i_APCI1710_EnablePWM(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, + unsigned char b_StartLevel, + unsigned char b_StopMode, + unsigned char b_StopLevel, unsigned char b_ExternGate, + unsigned char b_InterruptEnable); -INT i_APCI1710_SetNewPWMTiming(struct comedi_device *dev, - BYTE b_ModulNbr, - BYTE b_PWM, BYTE b_TimingUnit, - ULONG ul_LowTiming, ULONG ul_HighTiming); +int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev, + unsigned char b_ModulNbr, + unsigned char b_PWM, unsigned char b_TimingUnit, + unsigned int ul_LowTiming, unsigned int ul_HighTiming); -INT i_APCI1710_DisablePWM(struct comedi_device *dev, BYTE b_ModulNbr, BYTE b_PWM); +int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM); -INT i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev, +int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c index bb6e1622e379..a445dab50eac 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -65,31 +65,31 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitSSI | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SSIProfile, | -| BYTE_ b_PositionTurnLength, | -| BYTE_ b_TurnCptLength, | -| BYTE_ b_PCIInputClock, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SSIProfile, | +| unsigned char_ b_PositionTurnLength, | +| unsigned char_ b_TurnCptLength, | +| unsigned char_ b_PCIInputClock, | | ULONG_ ul_SSIOutputClock, | -| BYTE_ b_SSICountingMode) | +| unsigned char_ b_SSICountingMode) | +----------------------------------------------------------------------------+ | Task : Configure the SSI operating mode from selected module | | (b_ModulNbr). You must calling this function be for you| | call any other function witch access of SSI. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_SSIProfile : Selection from SSI | +| unsigned char_ b_SSIProfile : Selection from SSI | | profile length (2 to 32).| -| BYTE_ b_PositionTurnLength : Selection from SSI | +| unsigned char_ b_PositionTurnLength : Selection from SSI | | position data length | | (1 to 31). | -| BYTE_ b_TurnCptLength : Selection from SSI turn | +| unsigned char_ b_TurnCptLength : Selection from SSI turn | | counter data length | | (1 to 31). | -| BYTE b_PCIInputClock : Selection from PCI bus | +| unsigned char b_PCIInputClock : Selection from PCI bus | | clock | | - APCI1710_30MHZ : | | The PC have a PCI bus | @@ -103,7 +103,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | for 30 MHz selection. | | From 252 to 5 000 000 Hz| | for 33 MHz selection. | -| BYTE b_SSICountingMode : SSI counting mode | +| unsigned char b_SSICountingMode : SSI counting mode | | selection | | - APCI1710_BINARY_MODE : | | Binary counting mode. | @@ -111,12 +111,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | Gray counting mode. b_ModulNbr = CR_AREF(insn->chanspec); - b_SSIProfile = (BYTE) data[0]; - b_PositionTurnLength= (BYTE) data[1]; - b_TurnCptLength = (BYTE) data[2]; - b_PCIInputClock = (BYTE) data[3]; - ul_SSIOutputClock = (ULONG) data[4]; - b_SSICountingMode = (BYTE) data[5]; | + b_SSIProfile = (unsigned char) data[0]; + b_PositionTurnLength= (unsigned char) data[1]; + b_TurnCptLength = (unsigned char) data[2]; + b_PCIInputClock = (unsigned char) data[3]; + ul_SSIOutputClock = (unsigned int) data[4]; + b_SSICountingMode = (unsigned char) data[5]; | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -133,22 +133,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - UINT ui_TimerValue; - BYTE b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength, + int i_ReturnValue = 0; + unsigned int ui_TimerValue; + unsigned char b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength, b_PCIInputClock, b_SSICountingMode; - ULONG ul_SSIOutputClock; + unsigned int ul_SSIOutputClock; b_ModulNbr = CR_AREF(insn->chanspec); - b_SSIProfile = (BYTE) data[0]; - b_PositionTurnLength = (BYTE) data[1]; - b_TurnCptLength = (BYTE) data[2]; - b_PCIInputClock = (BYTE) data[3]; - ul_SSIOutputClock = (ULONG) data[4]; - b_SSICountingMode = (BYTE) data[5]; + b_SSIProfile = (unsigned char) data[0]; + b_PositionTurnLength = (unsigned char) data[1]; + b_TurnCptLength = (unsigned char) data[2]; + b_PCIInputClock = (unsigned char) data[3]; + ul_SSIOutputClock = (unsigned int) data[4]; + b_SSICountingMode = (unsigned char) data[5]; i_ReturnValue = insn->n; /**************************/ @@ -167,7 +167,7 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde /* Test the SSI profile length */ /*******************************/ - // CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2 + /* CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2 */ if (b_SSIProfile >= 2 && b_SSIProfile < 33) { /*************************************/ /* Test the SSI position data length */ @@ -250,9 +250,9 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde ui_TimerValue = - (UINT) + (unsigned int) ( - ((ULONG) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock); + ((unsigned int) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock); /************************/ /* Initialise the timer */ @@ -351,18 +351,18 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_Read1SSIValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SelectedSSI, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SelectedSSI, | | PULONG_ pul_Position, | | PULONG_ pul_TurnCpt) - INT i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s, + int i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : @@ -373,22 +373,22 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde or Read all SSI counter (b_SelectedSSI) from | | selected module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | -| BYTE_ b_SelectedSSI : Selection from SSI | +| unsigned char_ b_SelectedSSI : Selection from SSI | | counter (0 to 2) - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_SelectedSSI = (BYTE) CR_CHAN(insn->chanspec); (in case of single ssi) - b_ReadType = (BYTE) CR_RANGE(insn->chanspec); + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); (in case of single ssi) + b_ReadType = (unsigned char) CR_RANGE(insn->chanspec); | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_Position : SSI position in the turn | | PULONG_ pul_TurnCpt : Number of turns -pul_Position = (PULONG) &data[0]; - pul_TurnCpt = (PULONG) &data[1]; | +pul_Position = (unsigned int *) &data[0]; + pul_TurnCpt = (unsigned int *) &data[1]; | +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -400,37 +400,37 @@ pul_Position = (PULONG) &data[0]; +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_Cpt; - BYTE b_Length; - BYTE b_Schift; - BYTE b_SSICpt; - DWORD dw_And; - DWORD dw_And1; - DWORD dw_And2; - DWORD dw_StatusReg; - DWORD dw_CounterValue; - BYTE b_ModulNbr; - BYTE b_SelectedSSI; - BYTE b_ReadType; - PULONG pul_Position; - PULONG pul_TurnCpt; - PULONG pul_Position1; - PULONG pul_TurnCpt1; + int i_ReturnValue = 0; + unsigned char b_Cpt; + unsigned char b_Length; + unsigned char b_Schift; + unsigned char b_SSICpt; + unsigned int dw_And; + unsigned int dw_And1; + unsigned int dw_And2; + unsigned int dw_StatusReg; + unsigned int dw_CounterValue; + unsigned char b_ModulNbr; + unsigned char b_SelectedSSI; + unsigned char b_ReadType; + unsigned int *pul_Position; + unsigned int *pul_TurnCpt; + unsigned int *pul_Position1; + unsigned int *pul_TurnCpt1; i_ReturnValue = insn->n; - pul_Position1 = (PULONG) & data[0]; -// For Read1 - pul_TurnCpt1 = (PULONG) & data[1]; -// For Read all - pul_Position = (PULONG) & data[0]; //0-2 - pul_TurnCpt = (PULONG) & data[3]; //3-5 - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_SelectedSSI = (BYTE) CR_CHAN(insn->chanspec); - b_ReadType = (BYTE) CR_RANGE(insn->chanspec); + pul_Position1 = (unsigned int *) &data[0]; +/* For Read1 */ + pul_TurnCpt1 = (unsigned int *) &data[1]; +/* For Read all */ + pul_Position = (unsigned int *) &data[0]; /* 0-2 */ + pul_TurnCpt = (unsigned int *) &data[3]; /* 3-5 */ + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); + b_ReadType = (unsigned char) CR_RANGE(insn->chanspec); /**************************/ /* Test the module number */ @@ -477,9 +477,8 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev s_BoardInfos. ui_Address + (64 * b_ModulNbr)); - } - while ((dw_StatusReg & 0x1) != - 0); + } while ((dw_StatusReg & 0x1) + != 0); /******************************/ /* Read the SSI counter value */ @@ -608,8 +607,7 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev s_BoardInfos. ui_Address + (64 * b_ModulNbr)); - } - while ((dw_StatusReg & 0x1) != 0); + } while ((dw_StatusReg & 0x1) != 0); for (b_SSICpt = 0; b_SSICpt < 3; b_SSICpt++) { @@ -667,7 +665,7 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev default: printk("Read Type Inputs Wrong\n"); - } // switch ending + } /* switch ending */ } else { /***********************/ @@ -695,16 +693,16 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadSSI1DigitalInput | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_InputChannel, | -| PBYTE_ pb_ChannelStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_InputChannel, | +| unsigned char *_ pb_ChannelStatus) | +----------------------------------------------------------------------------+ | Task : (0) Set the digital output from selected SSI moule | @@ -716,13 +714,13 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev (3)Read the status from all SSI digital inputs from | | selected SSI module (b_ModulNbr) | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr CR_AREF : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr CR_AREF : Module number to | | configure (0 to 3) | -| BYTE_ b_InputChannel CR_CHAN : Selection from digital | +| unsigned char_ b_InputChannel CR_CHAN : Selection from digital | | data[0] which IOTYPE input ( 0 to 2) | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_ChannelStatus : Digital input channel | +| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel | | data[0] status | | 0 : Channle is not active| | 1 : Channle is active | @@ -735,19 +733,19 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg; - BYTE b_ModulNbr; - BYTE b_InputChannel; - PBYTE pb_ChannelStatus; - PBYTE pb_InputStatus; - BYTE b_IOType; + int i_ReturnValue = 0; + unsigned int dw_StatusReg; + unsigned char b_ModulNbr; + unsigned char b_InputChannel; + unsigned char *pb_ChannelStatus; + unsigned char *pb_InputStatus; + unsigned char b_IOType; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_IOType = (BYTE) data[0]; + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_IOType = (unsigned char) data[0]; /**************************/ /* Test the module number */ @@ -785,8 +783,8 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su /* Test the digital imnput channel number */ /******************************************/ - b_InputChannel = (BYTE) CR_CHAN(insn->chanspec); - pb_ChannelStatus = (PBYTE) & data[0]; + b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec); + pb_ChannelStatus = (unsigned char *) &data[0]; if (b_InputChannel <= 2) { /**************************/ @@ -797,7 +795,7 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su inl(devpriv->s_BoardInfos. ui_Address + (64 * b_ModulNbr)); *pb_ChannelStatus = - (BYTE) (((~dw_StatusReg) >> (4 + + (unsigned char) (((~dw_StatusReg) >> (4 + b_InputChannel)) & 1); } else { @@ -814,19 +812,19 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su /**************************/ /* Read all digital input */ /**************************/ - pb_InputStatus = (PBYTE) & data[0]; + pb_InputStatus = (unsigned char *) &data[0]; dw_StatusReg = inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr)); *pb_InputStatus = - (BYTE) (((~dw_StatusReg) >> 4) & 7); + (unsigned char) (((~dw_StatusReg) >> 4) & 7); break; default: printk("IO type wrong\n"); - } //switch end + } /* switch end */ } else { /**********************************/ /* The module is not a SSI module */ @@ -844,5 +842,5 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h index 88daad1a3912..eb7f101d2d61 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h @@ -33,11 +33,11 @@ /* * SSI INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c index 90316e10a3bd..43198aafb2dc 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -63,11 +63,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitTorCounter | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TorCounter, | -| BYTE_ b_PCIInputClock, | -| BYTE_ b_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TorCounter, | +| unsigned char_ b_PCIInputClock, | +| unsigned char_ b_TimingUnit, | | ULONG_ ul_TimingInterval, | | PULONG_ pul_RealTimingInterval) | +----------------------------------------------------------------------------+ @@ -82,11 +82,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ | Input Parameters : | | - CR_AREF BYTE_ b_ModulNbr : Module number to configure | + CR_AREF unsigned char_ b_ModulNbr : Module number to configure | | (0 to 3) | -| data[0] BYTE_ b_TorCounter : Tor counter selection | +| data[0] unsigned char_ b_TorCounter : Tor counter selection | | (0 or 1). | -| data[1] BYTE_ b_PCIInputClock : Selection from PCI bus clock| +| data[1] unsigned char_ b_PCIInputClock : Selection from PCI bus clock| | - APCI1710_30MHZ : | | The PC have a PCI bus | | clock from 30 MHz | @@ -104,7 +104,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | than it is not possibl to | | used the gate input for | | enabled the acquisition | -| data[2] BYTE_ b_TimingUnit : Base timing unit (0 to 4) | +| data[2] unsigned char_ b_TimingUnit : Base timing unit (0 to 4) | | 0 : ns | | 1 : µs | | 2 : ms | @@ -130,27 +130,27 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - ULONG ul_TimerValue = 0; - DWORD dw_Command; + int i_ReturnValue = 0; + unsigned int ul_TimerValue = 0; + unsigned int dw_Command; double d_RealTimingInterval = 0; - BYTE b_ModulNbr; - BYTE b_TorCounter; - BYTE b_PCIInputClock; - BYTE b_TimingUnit; - ULONG ul_TimingInterval; - ULONG ul_RealTimingInterval = 0; + unsigned char b_ModulNbr; + unsigned char b_TorCounter; + unsigned char b_PCIInputClock; + unsigned char b_TimingUnit; + unsigned int ul_TimingInterval; + unsigned int ul_RealTimingInterval = 0; i_ReturnValue = insn->n; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_TorCounter = (BYTE) data[0]; - b_PCIInputClock = (BYTE) data[1]; - b_TimingUnit = (BYTE) data[2]; - ul_TimingInterval = (ULONG) data[3]; + b_TorCounter = (unsigned char) data[0]; + b_PCIInputClock = (unsigned char) data[1]; + b_TimingUnit = (unsigned char) data[2]; + ul_TimingInterval = (unsigned int) data[3]; printk("INPUT clock %d\n", b_PCIInputClock); /**************************/ @@ -225,7 +225,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (0.00025 * b_PCIInputClock)); @@ -248,7 +248,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (0.00025 * (double)b_PCIInputClock)); @@ -284,7 +284,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -306,7 +306,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (0.25 * b_PCIInputClock)); @@ -329,7 +329,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (0.25 * (double)b_PCIInputClock)); @@ -367,7 +367,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -413,7 +413,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (250.0 * (double)b_PCIInputClock)); @@ -449,7 +449,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -471,7 +471,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) (ul_TimingInterval * (250000.0 @@ -496,7 +496,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (250000.0 @@ -535,7 +535,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -557,7 +557,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_TimerValue = - (ULONG) + (unsigned int) ( (ul_TimingInterval * @@ -585,7 +585,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_RealTimingInterval = - (ULONG) + (unsigned int) (ul_TimerValue / (250000.0 @@ -629,7 +629,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, if (b_PCIInputClock != APCI1710_40MHZ) { ul_TimerValue = - (ULONG) + (unsigned int) ( (double) (ul_TimerValue) @@ -641,7 +641,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, } fpu_end(); - } // if (b_PCIInputClock != APCI1710_GATE_INPUT) + } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */ else { /*************************************************************/ /* 2 Clock used for the overflow and the reload from counter */ @@ -652,7 +652,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, ul_TimingInterval - 2; - } // if (b_PCIInputClock != APCI1710_GATE_INPUT) + } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */ /****************************/ /* Save the PCI input clock */ @@ -814,7 +814,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, DPRINTK("Base timing selection is wrong\n"); i_ReturnValue = -7; } - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ else { /**********************************/ /* Timing unit selection is wrong */ @@ -822,8 +822,8 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, DPRINTK("Timing unit selection is wrong\n"); i_ReturnValue = -6; - } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) + } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ else { /*****************************************/ /* The selected PCI input clock is wrong */ @@ -831,8 +831,8 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, DPRINTK("The selected PCI input clock is wrong\n"); i_ReturnValue = -5; - } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) - } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) + } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ + } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */ else { /**********************************/ /* Tor Counter selection is wrong */ @@ -840,7 +840,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, DPRINTK("Tor Counter selection is wrong\n"); i_ReturnValue = -4; - } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) + } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */ } else { /******************************************/ /* The module is not a tor counter module */ @@ -857,20 +857,20 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, DPRINTK("Module number error\n"); i_ReturnValue = -2; } - data[0] = (UINT) ul_RealTimingInterval; - return (i_ReturnValue); + data[0] = (unsigned int) ul_RealTimingInterval; + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_EnableTorCounter | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TorCounter, | -| BYTE_ b_InputMode, | -| BYTE_ b_ExternGate, | -| BYTE_ b_CycleMode, | -| BYTE_ b_InterruptEnable) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TorCounter, | +| unsigned char_ b_InputMode, | +| unsigned char_ b_ExternGate, | +| unsigned char_ b_CycleMode, | +| unsigned char_ b_InterruptEnable) | +----------------------------------------------------------------------------+ | Task : Enable the tor counter (b_TorCounter) from selected | | module (b_ModulNbr). You must calling the | @@ -883,13 +883,13 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, | The b_CycleMode parameter determine if you will | | measured a single or more cycle. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_TorCounter : Tor counter selection (0 or 1). | -| BYTE_ b_InputMode : Input signal level selection | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). | +| unsigned char_ b_InputMode : Input signal level selection | | 0 : Tor count each low level | | 1 : Tor count each high level| -| BYTE_ b_ExternGate : Extern gate action selection | +| unsigned char_ b_ExternGate : Extern gate action selection | | 0 : Extern gate signal not | | used | | 1 : Extern gate signal used. | @@ -928,9 +928,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, | The gate input is used for the | | signal B | | | -| BYTE_ b_CycleMode : Selected the tor counter | +| unsigned char_ b_CycleMode : Selected the tor counter | | acquisition mode | -| BYTE_ b_InterruptEnable : Enable or disable the | +| unsigned char_ b_InterruptEnable : Enable or disable the | | tor counter interrupt. | | APCI1710_ENABLE: | | Enable the tor counter | @@ -959,9 +959,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_DisableTorCounter | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TorCounter) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TorCounter) | +----------------------------------------------------------------------------+ | Task : Disable the tor counter (b_TorCounter) from selected | | module (b_ModulNbr). If you disable the tor counter | @@ -969,9 +969,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, | counter witch the " i_APCI1710_EnableTorCounter" | | function, the status register is cleared | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_TorCounter : Tor counter selection (0 or 1). | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -987,29 +987,29 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_Status; - DWORD dw_DummyRead; - DWORD dw_ConfigReg; - BYTE b_ModulNbr, b_Action; - BYTE b_TorCounter; - BYTE b_InputMode; - BYTE b_ExternGate; - BYTE b_CycleMode; - BYTE b_InterruptEnable; - - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_Action = (BYTE) data[0]; // enable or disable - b_TorCounter = (BYTE) data[1]; - b_InputMode = (BYTE) data[2]; - b_ExternGate = (BYTE) data[3]; - b_CycleMode = (BYTE) data[4]; - b_InterruptEnable = (BYTE) data[5]; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned int dw_DummyRead; + unsigned int dw_ConfigReg; + unsigned char b_ModulNbr, b_Action; + unsigned char b_TorCounter; + unsigned char b_InputMode; + unsigned char b_ExternGate; + unsigned char b_CycleMode; + unsigned char b_InterruptEnable; + + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_Action = (unsigned char) data[0]; /* enable or disable */ + b_TorCounter = (unsigned char) data[1]; + b_InputMode = (unsigned char) data[2]; + b_ExternGate = (unsigned char) data[3]; + b_CycleMode = (unsigned char) data[4]; + b_InterruptEnable = (unsigned char) data[5]; i_ReturnValue = insn->n;; - devpriv->tsk_Current = current; // Save the current process task structure + devpriv->tsk_Current = current; /* Save the current process task structure */ /**************************/ /* Test the module number */ /**************************/ @@ -1027,7 +1027,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, /**********************************/ if (b_TorCounter <= 1) { - switch (b_Action) // Enable or Disable + switch (b_Action) /* Enable or Disable */ { case APCI1710_ENABLE: /***********************************/ @@ -1149,7 +1149,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, | 0x780; - } // if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) + } /* if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) */ /***********************/ /* Test if double mode */ @@ -1166,12 +1166,12 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, | 0x180; - } // if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) + } /* if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) */ b_InputMode = 0; - } // if (b_InputMode > 1) + } /* if (b_InputMode > 1) */ /*******************/ /* Set the command */ @@ -1237,7 +1237,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, outl(1, devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) + } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ else { /********************************/ /* Interrupt parameter is wrong */ @@ -1247,8 +1247,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, i_ReturnValue = -9; - } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) - } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) + } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ + } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ else { /***********************************************/ /* Tor counter acquisition mode cycle is wrong */ @@ -1258,8 +1258,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, i_ReturnValue = -8; - } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) - } // if (b_ExternGate >= 0 && b_ExternGate <= 1) + } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ + } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ else { /***********************************/ /* Extern gate input mode is wrong */ @@ -1268,8 +1268,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, DPRINTK("Extern gate input mode is wrong\n"); i_ReturnValue = -7; - } // if (b_ExternGate >= 0 && b_ExternGate <= 1) - } // if (b_InputMode >= 0 && b_InputMode <= 1) + } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ + } /* if (b_InputMode >= 0 && b_InputMode <= 1) */ else { /***************************************/ /* Tor input signal selection is wrong */ @@ -1329,7 +1329,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, s_BoardInfos. ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - } // if (dw_Status & 0x1) + } /* if (dw_Status & 0x1) */ else { /***************************/ /* Tor counter not enabled */ @@ -1337,8 +1337,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, DPRINTK("Tor counter not enabled \n"); i_ReturnValue = -6; - } // if (dw_Status & 0x1) - } // if (dw_Status & 0x10) + } /* if (dw_Status & 0x1) */ + } /* if (dw_Status & 0x10) */ else { /*******************************/ /* Tor counter not initialised */ @@ -1346,10 +1346,10 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, DPRINTK("Tor counter not initialised\n"); i_ReturnValue = -5; - } // // if (dw_Status & 0x10) + } /* // if (dw_Status & 0x10) */ - } // switch - } // if (b_TorCounter <= 1) + } /* switch */ + } /* if (b_TorCounter <= 1) */ else { /**********************************/ /* Tor counter selection is wrong */ @@ -1357,7 +1357,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, DPRINTK("Tor counter selection is wrong\n"); i_ReturnValue = -4; - } // if (b_TorCounter <= 1) + } /* if (b_TorCounter <= 1) */ } else { /******************************************/ /* The module is not a tor counter module */ @@ -1375,22 +1375,22 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_GetTorCounterInitialisation | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TorCounter, | -| PBYTE_ pb_TimingUnit, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TorCounter, | +| unsigned char *_ pb_TimingUnit, | | PULONG_ pul_TimingInterval, | -| PBYTE_ pb_InputMode, | -| PBYTE_ pb_ExternGate, | -| PBYTE_ pb_CycleMode, | -| PBYTE_ pb_Enable, | -| PBYTE_ pb_InterruptEnable)| +| unsigned char *_ pb_InputMode, | +| unsigned char *_ pb_ExternGate, | +| unsigned char *_ pb_CycleMode, | +| unsigned char *_ pb_Enable, | +| unsigned char *_ pb_InterruptEnable)| +----------------------------------------------------------------------------+ | Task : Enable the tor counter (b_TorCounter) from selected | | module (b_ModulNbr). You must calling the | @@ -1403,37 +1403,37 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, | The b_CycleMode parameter determine if you will | | measured a single or more cycle. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_TorCounter : Tor counter selection (0 or 1) +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_TorCounter : Tor counter selection (0 or 1) b_ModulNbr = CR_AREF(insn->chanspec); b_TorCounter = CR_CHAN(insn->chanspec); . | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_TimingUnit : Base timing unit (0 to 4) | +| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing unit (0 to 4) | | 0 : ns | | 1 : µs | | 2 : ms | | 3 : s | | 4 : mn | | PULONG_ pul_TimingInterval : Base timing value. | -| PBYTE_ pb_InputMode : Input signal level | +| unsigned char *_ pb_InputMode : Input signal level | | selection | | 0 : Tor count each low level | | 1 : Tor count each high level| -| PBYTE_ pb_ExternGate : Extern gate action | +| unsigned char *_ pb_ExternGate : Extern gate action | | selection | | 0 : Extern gate signal not | | used | | 1 : Extern gate signal used| -| PBYTE_ pb_CycleMode : Tor counter acquisition | +| unsigned char *_ pb_CycleMode : Tor counter acquisition | | mode | -| PBYTE_ pb_Enable : Indicate if the tor counter| +| unsigned char *_ pb_Enable : Indicate if the tor counter| | is enabled or no | | 0 : Tor counter disabled | | 1 : Tor counter enabled | -| PBYTE_ pb_InterruptEnable : Enable or disable the | +| unsigned char *_ pb_InterruptEnable : Enable or disable the | | tor counter interrupt. | | APCI1710_ENABLE: | | Enable the tor counter | @@ -1441,13 +1441,13 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, | APCI1710_DISABLE: | | Disable the tor counter | | interrupt - pb_TimingUnit = (PBYTE) &data[0]; - pul_TimingInterval = (PULONG) &data[1]; - pb_InputMode = (PBYTE) &data[2]; - pb_ExternGate = (PBYTE) &data[3]; - pb_CycleMode = (PBYTE) &data[4]; - pb_Enable = (PBYTE) &data[5]; - pb_InterruptEnable = (PBYTE) &data[6]; + pb_TimingUnit = (unsigned char *) &data[0]; + pul_TimingInterval = (unsigned int *) &data[1]; + pb_InputMode = (unsigned char *) &data[2]; + pb_ExternGate = (unsigned char *) &data[3]; + pb_CycleMode = (unsigned char *) &data[4]; + pb_Enable = (unsigned char *) &data[5]; + pb_InterruptEnable = (unsigned char *) &data[6]; | +----------------------------------------------------------------------------+ | Return Value : 0: No error | @@ -1460,32 +1460,32 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_Status; - BYTE b_ModulNbr; - BYTE b_TorCounter; - PBYTE pb_TimingUnit; - PULONG pul_TimingInterval; - PBYTE pb_InputMode; - PBYTE pb_ExternGate; - PBYTE pb_CycleMode; - PBYTE pb_Enable; - PBYTE pb_InterruptEnable; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned char b_ModulNbr; + unsigned char b_TorCounter; + unsigned char *pb_TimingUnit; + unsigned int *pul_TimingInterval; + unsigned char *pb_InputMode; + unsigned char *pb_ExternGate; + unsigned char *pb_CycleMode; + unsigned char *pb_Enable; + unsigned char *pb_InterruptEnable; i_ReturnValue = insn->n; b_ModulNbr = CR_AREF(insn->chanspec); b_TorCounter = CR_CHAN(insn->chanspec); - pb_TimingUnit = (PBYTE) & data[0]; - pul_TimingInterval = (PULONG) & data[1]; - pb_InputMode = (PBYTE) & data[2]; - pb_ExternGate = (PBYTE) & data[3]; - pb_CycleMode = (PBYTE) & data[4]; - pb_Enable = (PBYTE) & data[5]; - pb_InterruptEnable = (PBYTE) & data[6]; + pb_TimingUnit = (unsigned char *) &data[0]; + pul_TimingInterval = (unsigned int *) &data[1]; + pb_InputMode = (unsigned char *) &data[2]; + pb_ExternGate = (unsigned char *) &data[3]; + pb_CycleMode = (unsigned char *) &data[4]; + pb_Enable = (unsigned char *) &data[5]; + pb_InterruptEnable = (unsigned char *) &data[6]; /**************************/ /* Test the module number */ @@ -1526,9 +1526,9 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, (64 * b_ModulNbr)); *pb_CycleMode = - (BYTE) ((dw_Status >> 4) & 1); + (unsigned char) ((dw_Status >> 4) & 1); *pb_InterruptEnable = - (BYTE) ((dw_Status >> 5) & 1); + (unsigned char) ((dw_Status >> 5) & 1); /******************************************************/ /* Test if extern gate used for clock or for signal B */ @@ -1569,25 +1569,25 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, *pb_InputMode = APCI1710_TOR_QUADRUPLE_MODE; } - } // if (dw_Status & 0x400) + } /* if (dw_Status & 0x400) */ else { *pb_InputMode = 1; - } // // if (dw_Status & 0x400) + } /* // if (dw_Status & 0x400) */ /************************/ /* Extern gate not used */ /************************/ *pb_ExternGate = 0; - } // if (dw_Status & 0x600) + } /* if (dw_Status & 0x600) */ else { *pb_InputMode = - (BYTE) ((dw_Status >> 6) + (unsigned char) ((dw_Status >> 6) & 1); *pb_ExternGate = - (BYTE) ((dw_Status >> 7) + (unsigned char) ((dw_Status >> 7) & 1); - } // if (dw_Status & 0x600) + } /* if (dw_Status & 0x600) */ *pb_TimingUnit = devpriv-> @@ -1611,7 +1611,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, i_ReturnValue = -5; } - } // if (b_TorCounter <= 1) + } /* if (b_TorCounter <= 1) */ else { /**********************************/ /* Tor counter selection is wrong */ @@ -1619,7 +1619,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, DPRINTK("Tor counter selection is wrong \n"); i_ReturnValue = -4; - } // if (b_TorCounter <= 1) + } /* if (b_TorCounter <= 1) */ } else { /******************************************/ /* The module is not a tor counter module */ @@ -1637,17 +1637,17 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadTorCounterValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_TorCounter, | -| UINT_ ui_TimeOut, | -| PBYTE_ pb_TorCounterStatus, | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_TorCounter, | +| unsigned int_ ui_TimeOut, | +| unsigned char *_ pb_TorCounterStatus, | | PULONG_ pul_TorCounterValue) | +----------------------------------------------------------------------------+ | Task case APCI1710_TOR_GETPROGRESSSTATUS: Return the tor counter @@ -1660,15 +1660,15 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, | (pul_TorCounterValue) after a conting cycle stop | | from selected tor counter module (b_ModulNbr). | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3) | -| BYTE_ b_TorCounter : Tor counter selection (0 or 1). +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | +| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). b_ModulNbr = CR_AREF(insn->chanspec); - b_ReadType = (BYTE) data[0]; - b_TorCounter = (BYTE) data[1]; - ui_TimeOut = (UINT) data[2]; | + b_ReadType = (unsigned char) data[0]; + b_TorCounter = (unsigned char) data[1]; + ui_TimeOut = (unsigned int) data[2]; | +----------------------------------------------------------------------------+ -| Output Parameters : PBYTE_ pb_TorCounterStatus : Return the tor counter | +| Output Parameters : unsigned char *_ pb_TorCounterStatus : Return the tor counter | | status. | | 0 : Conting cycle not started| | Software gate not set. | @@ -1683,9 +1683,9 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, | function | | "i_APCI1710_InitTorCounter"| | 4 : Timeeout occur | -| PULONG pul_TorCounterValue : Tor counter value. - pb_TorCounterStatus=(PBYTE) &data[0]; - pul_TorCounterValue=(PULONG) &data[1]; | +| unsigned int * pul_TorCounterValue : Tor counter value. + pb_TorCounterStatus=(unsigned char *) &data[0]; + pul_TorCounterValue=(unsigned int *) &data[1]; | +----------------------------------------------------------------------------+ | Return Value : 0: No error | | -1: The handle parameter of the board is wrong | @@ -1700,27 +1700,27 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_Status; - DWORD dw_TimeOut = 0; + int i_ReturnValue = 0; + unsigned int dw_Status; + unsigned int dw_TimeOut = 0; - BYTE b_ModulNbr; - BYTE b_TorCounter; - BYTE b_ReadType; - UINT ui_TimeOut; - PBYTE pb_TorCounterStatus; - PULONG pul_TorCounterValue; + unsigned char b_ModulNbr; + unsigned char b_TorCounter; + unsigned char b_ReadType; + unsigned int ui_TimeOut; + unsigned char *pb_TorCounterStatus; + unsigned int *pul_TorCounterValue; i_ReturnValue = insn->n; b_ModulNbr = CR_AREF(insn->chanspec); - b_ReadType = (BYTE) data[0]; - b_TorCounter = (BYTE) data[1]; - ui_TimeOut = (UINT) data[2]; - pb_TorCounterStatus = (PBYTE) & data[0]; - pul_TorCounterValue = (PULONG) & data[1]; + b_ReadType = (unsigned char) data[0]; + b_TorCounter = (unsigned char) data[1]; + ui_TimeOut = (unsigned int) data[2]; + pb_TorCounterStatus = (unsigned char *) &data[0]; + pul_TorCounterValue = (unsigned int *) &data[1]; /**************************/ /* Test the module number */ @@ -1896,7 +1896,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device + (16 * b_TorCounter) + (64 * b_ModulNbr)); break; - } // if ((dw_Status & 4) == 4) + } /* if ((dw_Status & 4) == 4) */ else { /*******************************/ /* Test if measurement stopped */ @@ -1927,7 +1927,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device (16 * b_TorCounter) + (64 * b_ModulNbr)); break; - } // if ((dw_Status & 2) == 2) + } /* if ((dw_Status & 2) == 2) */ else { /*******************************/ /* Test if measurement started */ @@ -1941,7 +1941,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *pb_TorCounterStatus = 1; - } // if ((dw_Status & 1) == 1) + } /* if ((dw_Status & 1) == 1) */ else { /***************************/ /* Measurement not started */ @@ -1950,9 +1950,9 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *pb_TorCounterStatus = 0; - } // if ((dw_Status & 1) == 1) - } // if ((dw_Status & 2) == 2) - } // if ((dw_Status & 8) == 8) + } /* if ((dw_Status & 1) == 1) */ + } /* if ((dw_Status & 2) == 2) */ + } /* if ((dw_Status & 8) == 8) */ if (dw_TimeOut == ui_TimeOut) { /*****************/ @@ -1973,7 +1973,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device mdelay(1000); } - } // for (;;) + } /* for (;;) */ /*************************/ /* Test if timeout occur */ @@ -2001,8 +2001,8 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device default: printk("Inputs wrong\n"); - } // switch end - } // if (dw_Status & 0x1) + } /* switch end */ + } /* if (dw_Status & 0x1) */ else { /***************************/ /* Tor counter not enabled */ @@ -2010,7 +2010,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device DPRINTK("Tor counter not enabled\n"); i_ReturnValue = -6; - } // if (dw_Status & 0x1) + } /* if (dw_Status & 0x1) */ } else { /*******************************/ /* Tor counter not initialised */ @@ -2019,7 +2019,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device DPRINTK("Tor counter not initialised\n"); i_ReturnValue = -5; } - } // if (b_TorCounter <= 1) + } /* if (b_TorCounter <= 1) */ else { /**********************************/ /* Tor counter selection is wrong */ @@ -2027,7 +2027,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device DPRINTK("Tor counter selection is wrong\n"); i_ReturnValue = -4; - } // if (b_TorCounter <= 1) + } /* if (b_TorCounter <= 1) */ } else { /******************************************/ /* The module is not a tor counter module */ @@ -2045,5 +2045,5 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h index c245d16207b8..03a93cb26d7a 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h @@ -35,23 +35,23 @@ /* * TOR_COUNTER INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev, +int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev, +int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev, +int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * TOR_COUNTER READ FUNCTION */ -INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev, +int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c index 68b1d26bae13..d3d78d37de5c 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -63,12 +63,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_InitTTLIODirection | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_PortAMode, | -| BYTE_ b_PortBMode, | -| BYTE_ b_PortCMode, | -| BYTE_ b_PortDMode) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_PortAMode, | +| unsigned char_ b_PortBMode, | +| unsigned char_ b_PortCMode, | +| unsigned char_ b_PortDMode) | +----------------------------------------------------------------------------+ | Task APCI1710_TTL_INIT (using defaults) : Configure the TTL I/O operating mode from selected | | module (b_ModulNbr). You must calling this function be| @@ -76,15 +76,15 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc APCI1710_TTL_INITDIRECTION(user inputs for direction) +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_InitType = (BYTE) data[0]; - b_PortAMode = (BYTE) data[1]; - b_PortBMode = (BYTE) data[2]; - b_PortCMode = (BYTE) data[3]; - b_PortDMode = (BYTE) data[4];| + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_InitType = (unsigned char) data[0]; + b_PortAMode = (unsigned char) data[1]; + b_PortBMode = (unsigned char) data[2]; + b_PortCMode = (unsigned char) data[3]; + b_PortDMode = (unsigned char) data[4];| +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -100,19 +100,19 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - BYTE b_ModulNbr; - BYTE b_InitType; - BYTE b_PortAMode; - BYTE b_PortBMode; - BYTE b_PortCMode; - BYTE b_PortDMode; - - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); - b_InitType = (BYTE) data[0]; + int i_ReturnValue = 0; + unsigned char b_ModulNbr; + unsigned char b_InitType; + unsigned char b_PortAMode; + unsigned char b_PortBMode; + unsigned char b_PortCMode; + unsigned char b_PortDMode; + + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); + b_InitType = (unsigned char) data[0]; i_ReturnValue = insn->n; /**************************/ @@ -172,10 +172,10 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub case APCI1710_TTL_INITDIRECTION: - b_PortAMode = (BYTE) data[1]; - b_PortBMode = (BYTE) data[2]; - b_PortCMode = (BYTE) data[3]; - b_PortDMode = (BYTE) data[4]; + b_PortAMode = (unsigned char) data[1]; + b_PortBMode = (unsigned char) data[2]; + b_PortCMode = (unsigned char) data[3]; + b_PortDMode = (unsigned char) data[4]; /********************/ /* Test the version */ @@ -322,7 +322,7 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub DPRINTK("\n"); default: printk("Bad Config Type\n"); - } // switch end + } /* switch end */ } else { /**********************************/ /* The module is not a TTL module */ @@ -340,7 +340,7 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -352,11 +352,11 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_ReadTTLIOChannelValue | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_SelectedPort, | -| BYTE_ b_InputChannel, | -| PBYTE_ pb_ChannelStatus) | +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_SelectedPort, | +| unsigned char_ b_InputChannel, | +| unsigned char *_ pb_ChannelStatus) | +----------------------------------------------------------------------------+ | Task : Read the status from selected TTL digital input | | (b_InputChannel) @@ -366,32 +366,32 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 7) | -| BYTE_ b_SelectedPort, : Selection from TTL I/O | +| unsigned char_ b_SelectedPort, : Selection from TTL I/O | | port (0 to 2) | | 0 : Port A selection | | 1 : Port B selection | | 2 : Port C selection | | 3 : Port D selection | -| BYTE_ b_InputChannel : Selection from digital | +| unsigned char_ b_InputChannel : Selection from digital | | input ( 0 to 2) APCI1710_TTL_READCHANNEL b_ModulNbr = CR_AREF(insn->chanspec); b_SelectedPort= CR_RANGE(insn->chanspec); b_InputChannel= CR_CHAN(insn->chanspec); - b_ReadType = (BYTE) data[0]; + b_ReadType = (unsigned char) data[0]; APCI1710_TTL_READPORT| b_ModulNbr = CR_AREF(insn->chanspec); b_SelectedPort= CR_RANGE(insn->chanspec); - b_ReadType = (BYTE) data[0]; + b_ReadType = (unsigned char) data[0]; +----------------------------------------------------------------------------+ | Output Parameters : data[0] - PBYTE_ pb_ChannelStatus : Digital input channel | + unsigned char *_ pb_ChannelStatus : Digital input channel | | status | | 0 : Channle is not active| | 1 : Channle is active | @@ -406,20 +406,20 @@ APCI1710_TTL_READCHANNEL +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg; - BYTE b_ModulNbr; - BYTE b_SelectedPort; - BYTE b_InputChannel; - BYTE b_ReadType; - PBYTE pb_ChannelStatus; - PBYTE pb_PortValue; + int i_ReturnValue = 0; + unsigned int dw_StatusReg; + unsigned char b_ModulNbr; + unsigned char b_SelectedPort; + unsigned char b_InputChannel; + unsigned char b_ReadType; + unsigned char *pb_ChannelStatus; + unsigned char *pb_PortValue; i_ReturnValue = insn->n; - b_ReadType = (BYTE) data[0]; + b_ReadType = (unsigned char) data[0]; b_ModulNbr = CR_AREF(insn->chanspec); b_SelectedPort = CR_RANGE(insn->chanspec); b_InputChannel = CR_CHAN(insn->chanspec); @@ -439,7 +439,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde switch (b_ReadType) { case APCI1710_TTL_READCHANNEL: - pb_ChannelStatus = (PBYTE) & data[0]; + pb_ChannelStatus = (unsigned char *) &data[0]; /********************************/ /* Test the TTL I/O port number */ /********************************/ @@ -493,7 +493,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde *pb_ChannelStatus = - (BYTE) ( + (unsigned char) ( (dw_StatusReg >> (8 * b_SelectedPort)) >> b_InputChannel) & 1; @@ -533,7 +533,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde break; case APCI1710_TTL_READPORT: - pb_PortValue = (PBYTE) & data[0]; + pb_PortValue = (unsigned char *) &data[0]; /********************************/ /* Test the TTL I/O port number */ /********************************/ @@ -578,7 +578,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde (64 * b_ModulNbr)); *pb_PortValue = - (BYTE) ( + (unsigned char) ( (dw_StatusReg >> (8 * b_SelectedPort)) & 0xFF); } else { @@ -610,7 +610,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde default: printk("Bad ReadType\n"); - } //End Switch + } /* End Switch */ } else { /**********************************/ /* The module is not a TTL module */ @@ -628,20 +628,20 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device +| Function Name : int i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Read the status from all digital input ports | | (port A, port B and port C) from selected TTL | | module (b_ModulNbr) | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710| -| BYTE_ b_ModulNbr : Module number to | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| +| unsigned char_ b_ModulNbr : Module number to | | configure (0 to 3) | +----------------------------------------------------------------------------+ | Output Parameters : PULONG_ pul_PortValue : Digital TTL inputs port | @@ -655,17 +655,17 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg; - BYTE b_ModulNbr; - PULONG pul_PortValue; + int i_ReturnValue = 0; + unsigned int dw_StatusReg; + unsigned char b_ModulNbr; + unsigned int *pul_PortValue; - b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); + b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); i_ReturnValue = insn->n; - pul_PortValue = (PULONG) & data[0]; + pul_PortValue = (unsigned int *) &data[0]; /**************************/ /* Test the module number */ @@ -777,7 +777,7 @@ INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -789,19 +789,19 @@ INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ | Function Name : _INT_ i_APCI1710_SetTTLIOChlOn | -| (BYTE_ b_BoardHandle, | -| BYTE_ b_ModulNbr, | -| BYTE_ b_OutputChannel) -INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi_subdevice *s, +| (unsigned char_ b_BoardHandle, | +| unsigned char_ b_ModulNbr, | +| unsigned char_ b_OutputChannel) +int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Sets or resets the output witch has been passed with the | | parameter b_Channel. Setting an output means setting | | an ouput high. | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| BYTE_ b_ModulNbr : Selected module number (0 to 3)| -| BYTE_ b_OutputChannel : Selection from digital output | +| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | +| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| +| unsigned char_ b_OutputChannel : Selection from digital output | | channel (0 or 1) | | 0 : PD0 | | 1 : PD1 | @@ -811,7 +811,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi b_ModulNbr = CR_AREF(insn->chanspec); b_OutputChannel= CR_CHAN(insn->chanspec); - ui_State = data[0]; // ON or OFF + ui_State = data[0]; /* ON or OFF */ +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -825,19 +825,19 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi +----------------------------------------------------------------------------+ */ -INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = 0; - DWORD dw_StatusReg = 0; - BYTE b_ModulNbr; - BYTE b_OutputChannel; - UINT ui_State; + int i_ReturnValue = 0; + unsigned int dw_StatusReg = 0; + unsigned char b_ModulNbr; + unsigned char b_OutputChannel; + unsigned int ui_State; i_ReturnValue = insn->n; b_ModulNbr = CR_AREF(insn->chanspec); b_OutputChannel = CR_CHAN(insn->chanspec); - ui_State = data[0]; // ON or OFF + ui_State = data[0]; /* ON or OFF */ /**************************/ /* Test the module number */ @@ -953,7 +953,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev, ui_Address + (64 * b_ModulNbr)); - if (ui_State) // ON + if (ui_State) /* ON */ { dw_StatusReg = @@ -969,7 +969,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev, (b_OutputChannel % 8)); - } else // Off + } else /* Off */ { dw_StatusReg = @@ -1034,5 +1034,5 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev, i_ReturnValue = -2; } - return (i_ReturnValue); + return i_ReturnValue; } diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h index 00915ddf9218..c4f11347f243 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h @@ -24,21 +24,21 @@ /* * TTL INISIALISATION FUNCTION */ -INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * TTL INPUT FUNCTION */ -INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev, +int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * TTL OUTPUT FUNCTIONS */ -INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev, +int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c index b0907ec14667..6e9e7ed4dba9 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -49,37 +49,37 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc #include "addi_amcc_S5920.h" /*+----------------------------------------------------------------------------+*/ -/*| Function Name : INT i_AddiHeaderRW_ReadEeprom |*/ -/*| (INT i_NbOfWordsToRead, |*/ -/*| DWORD dw_PCIBoardEepromAddress, |*/ -/*| WORD w_EepromStartAddress, |*/ -/*| PWORD pw_DataRead) |*/ +/*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/ +/*| (int i_NbOfWordsToRead, |*/ +/*| unsigned int dw_PCIBoardEepromAddress, |*/ +/*| unsigned short w_EepromStartAddress, |*/ +/*| unsigned short * pw_DataRead) |*/ /*+----------------------------------------------------------------------------+*/ /*| Task : Read word from the 5920 eeprom. |*/ /*+----------------------------------------------------------------------------+*/ -/*| Input Parameters : INT i_NbOfWordsToRead : Nbr. of word to read |*/ -/*| DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/ -/*| WORD w_EepromStartAddress : Eeprom strat address |*/ +/*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/ +/*| unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/ +/*| unsigned short w_EepromStartAddress : Eeprom strat address |*/ /*+----------------------------------------------------------------------------+*/ -/*| Output Parameters : PWORD pw_DataRead : Read data |*/ +/*| Output Parameters : unsigned short * pw_DataRead : Read data |*/ /*+----------------------------------------------------------------------------+*/ /*| Return Value : - |*/ /*+----------------------------------------------------------------------------+*/ -INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, - DWORD dw_PCIBoardEepromAddress, - WORD w_EepromStartAddress, PWORD pw_DataRead) +int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, + unsigned int dw_PCIBoardEepromAddress, + unsigned short w_EepromStartAddress, unsigned short *pw_DataRead) { - DWORD dw_eeprom_busy = 0; - INT i_Counter = 0; - INT i_WordCounter; - INT i; - BYTE pb_ReadByte[1]; - BYTE b_ReadLowByte = 0; - BYTE b_ReadHighByte = 0; - BYTE b_SelectedAddressLow = 0; - BYTE b_SelectedAddressHigh = 0; - WORD w_ReadWord = 0; + unsigned int dw_eeprom_busy = 0; + int i_Counter = 0; + int i_WordCounter; + int i; + unsigned char pb_ReadByte[1]; + unsigned char b_ReadLowByte = 0; + unsigned char b_ReadHighByte = 0; + unsigned char b_SelectedAddressLow = 0; + unsigned char b_SelectedAddressHigh = 0; + unsigned short w_ReadWord = 0; for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead; i_WordCounter++) { @@ -88,106 +88,99 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); for (i_Counter = 0; i_Counter < 2; i_Counter++) { - b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; //Read the low 8 bit part - b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; //Read the high 8 bit part + b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */ + b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */ - //Select the load low address mode + /* Select the load low address mode */ outb(NVCMD_LOAD_LOW, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Load the low address + /* Load the low address */ outb(b_SelectedAddressLow, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the load high address mode + /* Select the load high address mode */ outb(NVCMD_LOAD_HIGH, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Load the high address + /* Load the high address */ outb(b_SelectedAddressHigh, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the READ mode + /* Select the READ mode */ outb(NVCMD_BEGIN_READ, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Read data into the EEPROM + /* Read data into the EEPROM */ *pb_ReadByte = inb(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the upper address part + /* Select the upper address part */ if (i_Counter == 0) { b_ReadLowByte = pb_ReadByte[0]; } else { b_ReadHighByte = pb_ReadByte[0]; } - //Sleep - for (i = 0; i < 10000; i++) ; + /* Sleep */ + msleep(1); } w_ReadWord = @@ -196,8 +189,8 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, pw_DataRead[i_WordCounter] = w_ReadWord; - w_EepromStartAddress += 2; // to read the next word + w_EepromStartAddress += 2; /* to read the next word */ - } // for (...) i_NbOfWordsToRead - return (0); + } /* for (...) i_NbOfWordsToRead */ + return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h index 9ae56bc3adad..622a4ac2b799 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h @@ -22,6 +22,6 @@ #define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ #define NVCMD_BEGIN_WRITE (0x6 << 5) /* EEPROM begin write command */ -INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, - DWORD dw_PCIBoardEepromAddress, - WORD w_EepromStartAddress, PWORD pw_DataRead); +int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, + unsigned int dw_PCIBoardEepromAddress, + unsigned short w_EepromStartAddress, unsigned short *pw_DataRead); diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h index b50774cdcf77..d288289143ea 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h @@ -85,7 +85,7 @@ #define AMCC_OP_REG_MRTC 0x30 #define AMCC_OP_REG_MBEF 0x34 #define AMCC_OP_REG_INTCSR 0x38 -/* INT source */ +/* int source */ #define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* FIFO ctrl */ #define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3) @@ -343,7 +343,7 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id, *card = amcc; return 0; /* ok, card is found */ } else { - rt_printk(" - \nCard on requested position is used b:s %d:%d!\n", + printk(" - \nCard on requested position is used b:s %d:%d!\n", pci_bus, pci_slot); return 2; /* card exist but is used */ } @@ -447,7 +447,7 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, /* use autodetection */ card = ptr_find_free_pci_card_by_device(vendor_id, device_id); if (card == NULL) { - rt_printk(" - Unused card not found in system!\n"); + printk(" - Unused card not found in system!\n"); return NULL; } } else { @@ -455,18 +455,18 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, pci_bus, pci_slot, &card)) { case 1: - rt_printk(" - Card not found on requested position b:s %d:%d!\n", + printk(" - Card not found on requested position b:s %d:%d!\n", pci_bus, pci_slot); return NULL; case 2: - rt_printk(" - Card on requested position is used b:s %d:%d!\n", + printk(" - Card on requested position is used b:s %d:%d!\n", pci_bus, pci_slot); return NULL; } } if (pci_card_alloc(card, i_Master) != 0) { - rt_printk(" - Can't allocate card!\n"); + printk(" - Can't allocate card!\n"); return NULL; } diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 618c69b6838d..a56535fbcd3e 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -68,25 +68,25 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc #include "addi_common.h" #include "addi_amcc_s5933.h" -//Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <info@addi-data.com>"); -//Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module"); -//Update-0.7.57->0.7.68MODULE_LICENSE("GPL"); +/* Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <info@addi-data.com>"); */ +/* Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module"); */ +/* Update-0.7.57->0.7.68MODULE_LICENSE("GPL"); */ -#define devpriv ((addi_private *)dev->private) -#define this_board ((boardtype *)dev->board_ptr) +#define devpriv ((struct addi_private *)dev->private) +#define this_board ((struct addi_board *)dev->board_ptr) #if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300) -//BYTE b_SaveFPUReg [94]; +/* BYTE b_SaveFPUReg [94]; */ void fpu_begin(void) { - //asm ("fstenv b_SaveFPUReg"); + /* asm ("fstenv b_SaveFPUReg"); */ kernel_fpu_begin(); } void fpu_end(void) { - // asm ("frstor b_SaveFPUReg"); + /* asm ("frstor b_SaveFPUReg"); */ kernel_fpu_end(); } #endif @@ -219,7 +219,7 @@ static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = { MODULE_DEVICE_TABLE(pci, addi_apci_tbl); -static const boardtype boardtypes[] = { +static const struct addi_board boardtypes[] = { #ifdef CONFIG_APCI_3120 {"apci3120", APCI3120_BOARD_VENDOR_ID, @@ -901,7 +901,7 @@ static const boardtype boardtypes[] = { NULL}, #endif #ifdef CONFIG_APCI_3300 - //Begin JK 20.10.2004: APCI-3300 integration + /* Begin JK .20.10.2004 = APCI-3300 integration */ {"apci3300", APCI3200_BOARD_VENDOR_ID, 0x3007, @@ -2525,16 +2525,16 @@ static const boardtype boardtypes[] = { #endif }; -#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype)) +#define n_boardtypes (sizeof(boardtypes)/sizeof(struct addi_board)) struct comedi_driver driver_addi = { - driver_name:"addi_common", - module:THIS_MODULE, - attach:i_ADDI_Attach, - detach:i_ADDI_Detach, - num_names:n_boardtypes, - board_name:&boardtypes[0].pc_DriverName, - offset:sizeof(boardtype), + .driver_name = "addi_common", + .module = THIS_MODULE, + .attach = i_ADDI_Attach, + .detach = i_ADDI_Detach, + .num_names = n_boardtypes, + .board_name = &boardtypes[0].pc_DriverName, + .offset = sizeof(struct addi_board), }; COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl); @@ -2559,11 +2559,11 @@ COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl); +----------------------------------------------------------------------------+ */ -static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, pages, i, n_subdevices; - DWORD dw_Dummy; + unsigned int dw_Dummy; resource_size_t io_addr[5]; unsigned int irq; resource_size_t iobase_a, iobase_main, iobase_addon, iobase_reserved; @@ -2575,26 +2575,28 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i sprintf(c_Identifier, "Addi-Data GmbH Comedi %s", this_board->pc_DriverName); - if ((ret = alloc_private(dev, sizeof(addi_private))) < 0) { - return -ENOMEM; - } + ret = alloc_private(dev, sizeof(struct addi_private)); + if (ret < 0) + return -ENOMEM; if (!pci_list_builded) { - v_pci_card_list_init(this_board->i_VendorId, 1); //1 for displaying the list.. + v_pci_card_list_init(this_board->i_VendorId, 1); /* 1 for displaying the list.. */ pci_list_builded = 1; } - //rt_printk("comedi%d: addi_common: board=%s",dev->minor,this_board->pc_DriverName); + /* printk("comedi%d: addi_common: board=%s",dev->minor,this_board->pc_DriverName); */ if ((this_board->i_Dma) && (it->options[2] == 0)) { i_Dma = 1; } - if ((card = ptr_select_and_alloc_pci_card(this_board->i_VendorId, - this_board->i_DeviceId, - it->options[0], - it->options[1], i_Dma)) == NULL) { + card = ptr_select_and_alloc_pci_card(this_board->i_VendorId, + this_board->i_DeviceId, + it->options[0], + it->options[1], i_Dma); + + if (card == NULL) return -EIO; - } + devpriv->allocated = 1; if ((i_pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0], @@ -2617,63 +2619,63 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i /************************************/ if (this_board->i_IorangeBase1 != 0) { - dev->iobase = (unsigned long)iobase_main; // DAQ base address... + dev->iobase = (unsigned long)iobase_main; /* DAQ base address... */ } else { - dev->iobase = (unsigned long)iobase_a; // DAQ base address... + dev->iobase = (unsigned long)iobase_a; /* DAQ base address... */ } dev->board_name = this_board->pc_DriverName; devpriv->amcc = card; - devpriv->iobase = (INT) dev->iobase; - devpriv->i_IobaseAmcc = (INT) iobase_a; //AMCC base address... - devpriv->i_IobaseAddon = (INT) iobase_addon; //ADD ON base address.... - devpriv->i_IobaseReserved = (INT) iobase_reserved; + devpriv->iobase = (int) dev->iobase; + devpriv->i_IobaseAmcc = (int) iobase_a; /* AMCC base address... */ + devpriv->i_IobaseAddon = (int) iobase_addon; /* ADD ON base address.... */ + devpriv->i_IobaseReserved = (int) iobase_reserved; devpriv->ps_BoardInfo = this_board; } else { dev->board_name = this_board->pc_DriverName; dev->iobase = (unsigned long)io_addr[2]; devpriv->amcc = card; - devpriv->iobase = (INT) io_addr[2]; + devpriv->iobase = (int) io_addr[2]; devpriv->ps_BoardInfo = this_board; - devpriv->i_IobaseReserved = (INT) io_addr[3]; + devpriv->i_IobaseReserved = (int) io_addr[3]; printk("\nioremap begin"); devpriv->dw_AiBase = - (ULONG_PTR) ioremap(io_addr[3], + (unsigned long) ioremap(io_addr[3], this_board->i_IorangeBase3); printk("\nioremap end"); } - //## + /* ## */ if (irq > 0) { - if (comedi_request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED, + if (request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED, c_Identifier, dev) < 0) { printk(", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk("\nirq=%u", irq); + printk("\nirq=%u", irq); } } else { - rt_printk(", IRQ disabled"); + printk(", IRQ disabled"); } printk("\nOption %d %d %d\n", it->options[0], it->options[1], it->options[2]); dev->irq = irq; - // Read eepeom and fill boardtype Structure + /* Read eepeom and fill addi_board Structure */ if (this_board->i_PCIEeprom) { printk("\nPCI Eeprom used"); if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { - // Set 3 wait stait + /* Set 3 wait stait */ if (!(strcmp(this_board->pc_DriverName, "apci035"))) { outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); } else { outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); } - // Enable the interrupt for the controler + /* Enable the interrupt for the controler */ dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); printk("\nEnable the interrupt for the controler"); @@ -2694,16 +2696,15 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i if (this_board->i_Dma) { printk("\nDMA used"); if (devpriv->us_UseDma == ADDI_ENABLE) { - // alloc DMA buffers + /* alloc DMA buffers */ devpriv->b_DmaDoubleBuffer = 0; for (i = 0; i < 2; i++) { for (pages = 4; pages >= 0; pages--) { - if ((devpriv->ul_DmaBufferVirtual[i] = - (void *) - __get_free_pages - (GFP_KERNEL, pages))) { + devpriv->ul_DmaBufferVirtual[i] = + (void *) __get_free_pages(GFP_KERNEL, pages); + + if (devpriv->ul_DmaBufferVirtual[i]) break; - } } if (devpriv->ul_DmaBufferVirtual[i]) { devpriv->ui_DmaBufferPages[i] = pages; @@ -2718,7 +2719,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i } } if (!devpriv->ul_DmaBufferVirtual[0]) { - rt_printk + printk (", Can't allocate DMA buffer, DMA disabled!"); devpriv->us_UseDma = ADDI_DISABLE; } @@ -2729,7 +2730,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i } if ((devpriv->us_UseDma == ADDI_ENABLE)) { - rt_printk("\nDMA ENABLED\n"); + printk("\nDMA ENABLED\n"); } else { printk("\nDMA DISABLED\n"); } @@ -2739,23 +2740,24 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i #ifdef CONFIG_APCI_1710 i_ADDI_AttachPCI1710(dev); - // save base address + /* save base address */ devpriv->s_BoardInfos.ui_Address = io_addr[2]; #endif } else { - //Update-0.7.57->0.7.68dev->n_subdevices = 7; + /* Update-0.7.57->0.7.68dev->n_subdevices = 7; */ n_subdevices = 7; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) return ret; - // Allocate and Initialise AI Subdevice Structures + /* Allocate and Initialise AI Subdevice Structures */ s = dev->subdevices + 0; if ((this_board->i_NbrAiChannel) || (this_board->i_NbrAiChannelDiff)) { dev->read_subdev = s; s->type = COMEDI_SUBD_AI; s->subdev_flags = - SDF_READABLE | SDF_RT | SDF_COMMON | SDF_GROUND + SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; if (this_board->i_NbrAiChannel) { s->n_chan = this_board->i_NbrAiChannel; @@ -2786,13 +2788,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i s->type = COMEDI_SUBD_UNUSED; } - // Allocate and Initialise AO Subdevice Structures + /* Allocate and Initialise AO Subdevice Structures */ s = dev->subdevices + 1; if (this_board->i_NbrAoChannel) { s->type = COMEDI_SUBD_AO; - s->subdev_flags = - SDF_WRITEABLE | SDF_GROUND | SDF_COMMON | - SDF_RT; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->i_NbrAoChannel; s->maxdata = this_board->i_AoMaxdata; s->len_chanlist = this_board->i_NbrAoChannel; @@ -2804,12 +2804,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i } else { s->type = COMEDI_SUBD_UNUSED; } - // Allocate and Initialise DI Subdevice Structures + /* Allocate and Initialise DI Subdevice Structures */ s = dev->subdevices + 2; if (this_board->i_NbrDiChannel) { s->type = COMEDI_SUBD_DI; - s->subdev_flags = - SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->i_NbrDiChannel; s->maxdata = 1; s->len_chanlist = this_board->i_NbrDiChannel; @@ -2824,20 +2823,19 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i } else { s->type = COMEDI_SUBD_UNUSED; } - // Allocate and Initialise DO Subdevice Structures + /* Allocate and Initialise DO Subdevice Structures */ s = dev->subdevices + 3; if (this_board->i_NbrDoChannel) { s->type = COMEDI_SUBD_DO; s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_RT | - SDF_GROUND | SDF_COMMON; + SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->i_NbrDoChannel; s->maxdata = this_board->i_DoMaxdata; s->len_chanlist = this_board->i_NbrDoChannel; s->range_table = &range_digital; s->io_bits = 0xf; /* all bits output */ - s->insn_config = this_board->i_hwdrv_InsnConfigDigitalOutput; //for digital output memory.. + s->insn_config = this_board->i_hwdrv_InsnConfigDigitalOutput; /* for digital output memory.. */ s->insn_write = this_board->i_hwdrv_InsnWriteDigitalOutput; s->insn_bits = @@ -2848,13 +2846,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i s->type = COMEDI_SUBD_UNUSED; } - // Allocate and Initialise Timer Subdevice Structures + /* Allocate and Initialise Timer Subdevice Structures */ s = dev->subdevices + 4; if (this_board->i_Timer) { s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = - SDF_WRITEABLE | SDF_RT | SDF_GROUND | - SDF_COMMON; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 1; s->maxdata = 0; s->len_chanlist = 1; @@ -2868,13 +2864,12 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i s->type = COMEDI_SUBD_UNUSED; } - // Allocate and Initialise TTL + /* Allocate and Initialise TTL */ s = dev->subdevices + 5; if (this_board->i_NbrTTLChannel) { s->type = COMEDI_SUBD_TTLIO; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | - SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->i_NbrTTLChannel; s->maxdata = 1; s->io_bits = 0; /* all bits input */ @@ -2926,7 +2921,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i +----------------------------------------------------------------------------+ */ -static int i_ADDI_Detach(struct comedi_device * dev) +static int i_ADDI_Detach(struct comedi_device *dev) { if (dev->private) { @@ -2935,7 +2930,7 @@ static int i_ADDI_Detach(struct comedi_device * dev) } if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if ((devpriv->ps_BoardInfo->pc_EepromChip == NULL) @@ -2965,7 +2960,7 @@ static int i_ADDI_Detach(struct comedi_device * dev) } if (pci_list_builded) { - //v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC); + /* v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC); */ v_pci_card_list_cleanup(this_board->i_VendorId); pci_list_builded = 0; } @@ -2992,18 +2987,18 @@ static int i_ADDI_Detach(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -static int i_ADDI_Reset(struct comedi_device * dev) +static int i_ADDI_Reset(struct comedi_device *dev) { this_board->i_hwdrv_Reset(dev); return 0; } -// Interrupt function +/* Interrupt function */ /* +----------------------------------------------------------------------------+ | Function name : | -|static void v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG) | +|static void v_ADDI_Interrupt(int irq, void *d) | | | +----------------------------------------------------------------------------+ | Task : Registerd interrupt routine | @@ -3018,14 +3013,14 @@ static int i_ADDI_Reset(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t v_ADDI_Interrupt(int irq, void *d) { struct comedi_device *dev = d; this_board->v_hwdrv_Interrupt(irq, d); return IRQ_RETVAL(1); } -// EEPROM Read Function +/* EEPROM Read Function */ /* +----------------------------------------------------------------------------+ | Function name : | @@ -3046,17 +3041,17 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG) +----------------------------------------------------------------------------+ */ -static int i_ADDIDATA_InsnReadEeprom(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - WORD w_Data; - WORD w_Address; - w_Address = CR_CHAN(insn->chanspec); // address to be read as 0,1,2,3...255 + unsigned short w_Data; + unsigned short w_Address; + w_Address = CR_CHAN(insn->chanspec); /* address to be read as 0,1,2,3...255 */ w_Data = w_EepromReadWord(devpriv->i_IobaseAmcc, this_board->pc_EepromChip, 0x100 + (2 * w_Address)); data[0] = w_Data; - //multiplied by 2 bcozinput will be like 0,1,2...255 + /* multiplied by 2 bcozinput will be like 0,1,2...255 */ return insn->n; } diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 19df5c1444a4..edd657b902aa 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -36,26 +36,12 @@ #define ERROR -1 #define SUCCESS 1 -/* variable type definition */ -typedef unsigned char BYTE, *PBYTE; -typedef short SHORT, *PSHORT; -typedef unsigned short USHORT, *PUSHORT; -typedef unsigned short WORD, *PWORD; -typedef int INT, *PINT;; -typedef unsigned int UINT, *PUINT; -typedef int LONG, *PLONG; /* 32-bit */ -typedef unsigned int ULONG, *PULONG; /* 32-bit */ -typedef unsigned int DWORD, *PDWORD; /* 32-bit */ -typedef unsigned long ULONG_PTR; - -typedef const struct comedi_lrange *PCRANGE; - -#define LOBYTE(W) (BYTE)((W) & 0xFF) -#define HIBYTE(W) (BYTE)(((W) >> 8) & 0xFF) -#define MAKEWORD(H, L) (USHORT)((L) | ((H) << 8)) -#define LOWORD(W) (USHORT)((W) & 0xFFFF) -#define HIWORD(W) (USHORT)(((W) >> 16) & 0xFFFF) -#define MAKEDWORD(H, L) (UINT)((L) | ((H) << 16)) +#define LOBYTE(W) (unsigned char)((W) & 0xFF) +#define HIBYTE(W) (unsigned char)(((W) >> 8) & 0xFF) +#define MAKEWORD(H, L) (unsigned short)((L) | ((H) << 8)) +#define LOWORD(W) (unsigned short)((W) & 0xFFFF) +#define HIWORD(W) (unsigned short)(((W) >> 16) & 0xFFFF) +#define MAKEDWORD(H, L) (unsigned int)((L) | ((H) << 16)) #define ADDI_ENABLE 1 #define ADDI_DISABLE 0 @@ -75,37 +61,37 @@ typedef const struct comedi_lrange *PCRANGE; /* Structures */ /* structure for the boardtype */ -typedef struct { - const char *pc_DriverName; // driver name - INT i_VendorId; //PCI vendor a device ID of card - INT i_DeviceId; - INT i_IorangeBase0; - INT i_IorangeBase1; - INT i_IorangeBase2; // base 2 range - INT i_IorangeBase3; // base 3 range - INT i_PCIEeprom; // eeprom present or not - char *pc_EepromChip; // type of chip - INT i_NbrAiChannel; // num of A/D chans - INT i_NbrAiChannelDiff; // num of A/D chans in diff mode - INT i_AiChannelList; // len of chanlist - INT i_NbrAoChannel; // num of D/A chans - INT i_AiMaxdata; // resolution of A/D - INT i_AoMaxdata; // resolution of D/A - PCRANGE pr_AiRangelist; // rangelist for A/D - PCRANGE pr_AoRangelist; // rangelist for D/A - - INT i_NbrDiChannel; // Number of DI channels - INT i_NbrDoChannel; // Number of DO channels - INT i_DoMaxdata; // data to set all chanels high - - INT i_NbrTTLChannel; // Number of TTL channels - PCRANGE pr_TTLRangelist; // rangelist for TTL - - INT i_Dma; // dma present or not - INT i_Timer; // timer subdevice present or not - BYTE b_AvailableConvertUnit; - UINT ui_MinAcquisitiontimeNs; // Minimum Acquisition in Nano secs - UINT ui_MinDelaytimeNs; // Minimum Delay in Nano secs +struct addi_board { + const char *pc_DriverName; /* driver name */ + int i_VendorId; /* PCI vendor a device ID of card */ + int i_DeviceId; + int i_IorangeBase0; + int i_IorangeBase1; + int i_IorangeBase2; /* base 2 range */ + int i_IorangeBase3; /* base 3 range */ + int i_PCIEeprom; /* eeprom present or not */ + char *pc_EepromChip; /* type of chip */ + int i_NbrAiChannel; /* num of A/D chans */ + int i_NbrAiChannelDiff; /* num of A/D chans in diff mode */ + int i_AiChannelList; /* len of chanlist */ + int i_NbrAoChannel; /* num of D/A chans */ + int i_AiMaxdata; /* resolution of A/D */ + int i_AoMaxdata; /* resolution of D/A */ + const struct comedi_lrange *pr_AiRangelist; /* rangelist for A/D */ + const struct comedi_lrange *pr_AoRangelist; /* rangelist for D/A */ + + int i_NbrDiChannel; /* Number of DI channels */ + int i_NbrDoChannel; /* Number of DO channels */ + int i_DoMaxdata; /* data to set all chanels high */ + + int i_NbrTTLChannel; /* Number of TTL channels */ + const struct comedi_lrange *pr_TTLRangelist; /* rangelist for TTL */ + + int i_Dma; /* dma present or not */ + int i_Timer; /* timer subdevice present or not */ + unsigned char b_AvailableConvertUnit; + unsigned int ui_MinAcquisitiontimeNs; /* Minimum Acquisition in Nano secs */ + unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */ /* interrupt and reset */ void (*v_hwdrv_Interrupt)(int irq, void *d); @@ -213,21 +199,21 @@ typedef struct { int (*i_hwdr_WriteTTLIOChlOnOff)(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -} boardtype; +}; -//MODULE INFO STRUCTURE +/* MODULE INFO STRUCTURE */ -typedef union { +union str_ModuleInfo { /* Incremental counter infos */ struct { union { struct { - BYTE b_ModeRegister1; - BYTE b_ModeRegister2; - BYTE b_ModeRegister3; - BYTE b_ModeRegister4; + unsigned char b_ModeRegister1; + unsigned char b_ModeRegister2; + unsigned char b_ModeRegister3; + unsigned char b_ModeRegister4; } s_ByteModeRegister; - DWORD dw_ModeRegister1_2_3_4; + unsigned int dw_ModeRegister1_2_3_4; } s_ModeRegister; struct { @@ -244,25 +230,25 @@ typedef union { /* SSI infos */ struct { - BYTE b_SSIProfile; - BYTE b_PositionTurnLength; - BYTE b_TurnCptLength; - BYTE b_SSIInit; + unsigned char b_SSIProfile; + unsigned char b_PositionTurnLength; + unsigned char b_TurnCptLength; + unsigned char b_SSIInit; } s_SSICounterInfo; /* TTL I/O infos */ struct { - BYTE b_TTLInit; - BYTE b_PortConfiguration[4]; + unsigned char b_TTLInit; + unsigned char b_PortConfiguration[4]; } s_TTLIOInfo; /* Digital I/O infos */ struct { - BYTE b_DigitalInit; - BYTE b_ChannelAMode; - BYTE b_ChannelBMode; - BYTE b_OutputMemoryEnabled; - DWORD dw_OutputMemory; + unsigned char b_DigitalInit; + unsigned char b_ChannelAMode; + unsigned char b_ChannelBMode; + unsigned char b_OutputMemoryEnabled; + unsigned int dw_OutputMemory; } s_DigitalIOInfo; /*********************/ @@ -271,14 +257,14 @@ typedef union { struct { struct { - BYTE b_82X54Init; - BYTE b_InputClockSelection; - BYTE b_InputClockLevel; - BYTE b_OutputLevel; - BYTE b_HardwareGateLevel; - DWORD dw_ConfigurationWord; + unsigned char b_82X54Init; + unsigned char b_InputClockSelection; + unsigned char b_InputClockLevel; + unsigned char b_OutputLevel; + unsigned char b_HardwareGateLevel; + unsigned int dw_ConfigurationWord; } s_82X54TimerInfo[3]; - BYTE b_InterruptMask; + unsigned char b_InterruptMask; } s_82X54ModuleInfo; /*********************/ @@ -286,13 +272,13 @@ typedef union { /*********************/ struct { - BYTE b_ChronoInit; - BYTE b_InterruptMask; - BYTE b_PCIInputClock; - BYTE b_TimingUnit; - BYTE b_CycleMode; + unsigned char b_ChronoInit; + unsigned char b_InterruptMask; + unsigned char b_PCIInputClock; + unsigned char b_TimingUnit; + unsigned char b_CycleMode; double d_TimingInterval; - DWORD dw_ConfigReg; + unsigned int dw_ConfigReg; } s_ChronoModuleInfo; /***********************/ @@ -301,154 +287,154 @@ typedef union { struct { struct { - BYTE b_PulseEncoderInit; + unsigned char b_PulseEncoderInit; } s_PulseEncoderInfo[4]; - DWORD dw_SetRegister; - DWORD dw_ControlRegister; - DWORD dw_StatusRegister; + unsigned int dw_SetRegister; + unsigned int dw_ControlRegister; + unsigned int dw_StatusRegister; } s_PulseEncoderModuleInfo; /* Tor conter infos */ struct { struct { - BYTE b_TorCounterInit; - BYTE b_TimingUnit; - BYTE b_InterruptEnable; + unsigned char b_TorCounterInit; + unsigned char b_TimingUnit; + unsigned char b_InterruptEnable; double d_TimingInterval; - ULONG ul_RealTimingInterval; + unsigned int ul_RealTimingInterval; } s_TorCounterInfo[2]; - BYTE b_PCIInputClock; + unsigned char b_PCIInputClock; } s_TorCounterModuleInfo; /* PWM infos */ struct { struct { - BYTE b_PWMInit; - BYTE b_TimingUnit; - BYTE b_InterruptEnable; + unsigned char b_PWMInit; + unsigned char b_TimingUnit; + unsigned char b_InterruptEnable; double d_LowTiming; double d_HighTiming; - ULONG ul_RealLowTiming; - ULONG ul_RealHighTiming; + unsigned int ul_RealLowTiming; + unsigned int ul_RealHighTiming; } s_PWMInfo[2]; - BYTE b_ClockSelection; + unsigned char b_ClockSelection; } s_PWMModuleInfo; /* ETM infos */ struct { struct { - BYTE b_ETMEnable; - BYTE b_ETMInterrupt; + unsigned char b_ETMEnable; + unsigned char b_ETMInterrupt; } s_ETMInfo[2]; - BYTE b_ETMInit; - BYTE b_TimingUnit; - BYTE b_ClockSelection; + unsigned char b_ETMInit; + unsigned char b_TimingUnit; + unsigned char b_ClockSelection; double d_TimingInterval; - ULONG ul_Timing; + unsigned int ul_Timing; } s_ETMModuleInfo; /* CDA infos */ struct { - BYTE b_CDAEnable; - BYTE b_CDAInterrupt; - BYTE b_CDAInit; - BYTE b_FctSelection; - BYTE b_CDAReadFIFOOverflow; + unsigned char b_CDAEnable; + unsigned char b_CDAInterrupt; + unsigned char b_CDAInit; + unsigned char b_FctSelection; + unsigned char b_CDAReadFIFOOverflow; } s_CDAModuleInfo; -} str_ModuleInfo; +}; /* Private structure for the addi_apci3120 driver */ -typedef struct { - - INT iobase; - INT i_IobaseAmcc; // base+size for AMCC chip - INT i_IobaseAddon; //addon base address - INT i_IobaseReserved; - ULONG_PTR dw_AiBase; - struct pcilst_struct *amcc; // ptr too AMCC data - BYTE allocated; // we have blocked card - BYTE b_ValidDriver; // driver is ok - BYTE b_AiContinuous; // we do unlimited AI - BYTE b_AiInitialisation; - UINT ui_AiActualScan; //how many scans we finished - UINT ui_AiBufferPtr; // data buffer ptr in samples - UINT ui_AiNbrofChannels; // how many channels is measured - UINT ui_AiScanLength; // Length of actual scanlist - UINT ui_AiActualScanPosition; // position in actual scan - PUINT pui_AiChannelList; // actual chanlist - UINT ui_AiChannelList[32]; // actual chanlist - BYTE b_AiChannelConfiguration[32]; // actual chanlist - UINT ui_AiReadData[32]; - DWORD dw_AiInitialised; - UINT ui_AiTimer0; //Timer Constant for Timer0 - UINT ui_AiTimer1; //Timer constant for Timer1 - UINT ui_AiFlags; - UINT ui_AiDataLength; - short *AiData; // Pointer to sample data - UINT ui_AiNbrofScans; // number of scans to do - USHORT us_UseDma; // To use Dma or not - BYTE b_DmaDoubleBuffer; // we can use double buffering - UINT ui_DmaActualBuffer; // which buffer is used now - //*UPDATE-0.7.57->0.7.68 - //ULONG ul_DmaBufferVirtual[2];// pointers to begin of DMA buffer - short *ul_DmaBufferVirtual[2]; // pointers to begin of DMA buffer - ULONG ul_DmaBufferHw[2]; // hw address of DMA buff - UINT ui_DmaBufferSize[2]; // size of dma buffer in bytes - UINT ui_DmaBufferUsesize[2]; // which size we may now used for transfer - UINT ui_DmaBufferSamples[2]; // size in samples - UINT ui_DmaBufferPages[2]; // number of pages in buffer - BYTE b_DigitalOutputRegister; // Digital Output Register - BYTE b_OutputMemoryStatus; - BYTE b_AnalogInputChannelNbr; // Analog input channel Nbr - BYTE b_AnalogOutputChannelNbr; // Analog input Output Nbr - BYTE b_TimerSelectMode; // Contain data written at iobase + 0C - BYTE b_ModeSelectRegister; // Contain data written at iobase + 0E - USHORT us_OutputRegister; // Contain data written at iobase + 0 - BYTE b_InterruptState; - BYTE b_TimerInit; // Specify if InitTimerWatchdog was load - BYTE b_TimerStarted; // Specify if timer 2 is running or not - BYTE b_Timer2Mode; // Specify the timer 2 mode - BYTE b_Timer2Interrupt; //Timer2 interrupt enable or disable - BYTE b_AiCyclicAcquisition; // indicate cyclic acquisition - BYTE b_InterruptMode; // eoc eos or dma - BYTE b_EocEosInterrupt; // Enable disable eoc eos interrupt - UINT ui_EocEosConversionTime; - BYTE b_EocEosConversionTimeBase; - BYTE b_SingelDiff; - BYTE b_ExttrigEnable; /* To enable or disable external trigger */ +struct addi_private { + + int iobase; + int i_IobaseAmcc; /* base+size for AMCC chip */ + int i_IobaseAddon; /* addon base address */ + int i_IobaseReserved; + unsigned long dw_AiBase; + struct pcilst_struct *amcc; /* ptr too AMCC data */ + unsigned char allocated; /* we have blocked card */ + unsigned char b_ValidDriver; /* driver is ok */ + unsigned char b_AiContinuous; /* we do unlimited AI */ + unsigned char b_AiInitialisation; + unsigned int ui_AiActualScan; /* how many scans we finished */ + unsigned int ui_AiBufferPtr; /* data buffer ptr in samples */ + unsigned int ui_AiNbrofChannels; /* how many channels is measured */ + unsigned int ui_AiScanLength; /* Length of actual scanlist */ + unsigned int ui_AiActualScanPosition; /* position in actual scan */ + unsigned int *pui_AiChannelList; /* actual chanlist */ + unsigned int ui_AiChannelList[32]; /* actual chanlist */ + unsigned char b_AiChannelConfiguration[32]; /* actual chanlist */ + unsigned int ui_AiReadData[32]; + unsigned int dw_AiInitialised; + unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */ + unsigned int ui_AiTimer1; /* Timer constant for Timer1 */ + unsigned int ui_AiFlags; + unsigned int ui_AiDataLength; + short *AiData; /* Pointer to sample data */ + unsigned int ui_AiNbrofScans; /* number of scans to do */ + unsigned short us_UseDma; /* To use Dma or not */ + unsigned char b_DmaDoubleBuffer; /* we can use double buffering */ + unsigned int ui_DmaActualBuffer; /* which buffer is used now */ + /* UPDATE-0.7.57->0.7.68 */ + /* unsigned int ul_DmaBufferVirtual[2]; pointers to begin of DMA buffer */ + short *ul_DmaBufferVirtual[2]; /* pointers to begin of DMA buffer */ + unsigned int ul_DmaBufferHw[2]; /* hw address of DMA buff */ + unsigned int ui_DmaBufferSize[2]; /* size of dma buffer in bytes */ + unsigned int ui_DmaBufferUsesize[2]; /* which size we may now used for transfer */ + unsigned int ui_DmaBufferSamples[2]; /* size in samples */ + unsigned int ui_DmaBufferPages[2]; /* number of pages in buffer */ + unsigned char b_DigitalOutputRegister; /* Digital Output Register */ + unsigned char b_OutputMemoryStatus; + unsigned char b_AnalogInputChannelNbr; /* Analog input channel Nbr */ + unsigned char b_AnalogOutputChannelNbr; /* Analog input Output Nbr */ + unsigned char b_TimerSelectMode; /* Contain data written at iobase + 0C */ + unsigned char b_ModeSelectRegister; /* Contain data written at iobase + 0E */ + unsigned short us_OutputRegister; /* Contain data written at iobase + 0 */ + unsigned char b_InterruptState; + unsigned char b_TimerInit; /* Specify if InitTimerWatchdog was load */ + unsigned char b_TimerStarted; /* Specify if timer 2 is running or not */ + unsigned char b_Timer2Mode; /* Specify the timer 2 mode */ + unsigned char b_Timer2Interrupt; /* Timer2 interrupt enable or disable */ + unsigned char b_AiCyclicAcquisition; /* indicate cyclic acquisition */ + unsigned char b_InterruptMode; /* eoc eos or dma */ + unsigned char b_EocEosInterrupt; /* Enable disable eoc eos interrupt */ + unsigned int ui_EocEosConversionTime; + unsigned char b_EocEosConversionTimeBase; + unsigned char b_SingelDiff; + unsigned char b_ExttrigEnable; /* To enable or disable external trigger */ /* Pointer to the current process */ struct task_struct *tsk_Current; - boardtype *ps_BoardInfo; + struct addi_board *ps_BoardInfo; /* Hardware board infos for 1710 */ struct { - UINT ui_Address; /* Board address */ - UINT ui_FlashAddress; - BYTE b_InterruptNbr; /* Board interrupt number */ - BYTE b_SlotNumber; /* PCI slot number */ - BYTE b_BoardVersion; - DWORD dw_MolduleConfiguration[4]; /* Module config */ + unsigned int ui_Address; /* Board address */ + unsigned int ui_FlashAddress; + unsigned char b_InterruptNbr; /* Board interrupt number */ + unsigned char b_SlotNumber; /* PCI slot number */ + unsigned char b_BoardVersion; + unsigned int dw_MolduleConfiguration[4]; /* Module config */ } s_BoardInfos; /* Interrupt infos */ struct { - ULONG ul_InterruptOccur; /* 0 : No interrupt occur */ + unsigned int ul_InterruptOccur; /* 0 : No interrupt occur */ /* > 0 : Interrupt occur */ - UINT ui_Read; /* Read FIFO */ - UINT ui_Write; /* Write FIFO */ + unsigned int ui_Read; /* Read FIFO */ + unsigned int ui_Write; /* Write FIFO */ struct { - BYTE b_OldModuleMask; - ULONG ul_OldInterruptMask; /* Interrupt mask */ - ULONG ul_OldCounterLatchValue; /* Interrupt counter value */ + unsigned char b_OldModuleMask; + unsigned int ul_OldInterruptMask; /* Interrupt mask */ + unsigned int ul_OldCounterLatchValue; /* Interrupt counter value */ } s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT]; } s_InterruptParameters; - str_ModuleInfo s_ModuleInfo[4]; - ULONG ul_TTLPortConfiguration[10]; + union str_ModuleInfo s_ModuleInfo[4]; + unsigned int ul_TTLPortConfiguration[10]; -} addi_private; +}; static unsigned short pci_list_builded; /* set to 1 when list of card is known */ @@ -457,6 +443,6 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it) static int i_ADDI_Detach(struct comedi_device *dev); static int i_ADDI_Reset(struct comedi_device *dev); -static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG); +static irqreturn_t v_ADDI_Interrupt(int irq, void *d); static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c index a8a1bb2e8fa5..69b427390e53 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -45,19 +45,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------+-----------+------------------------------------------------+ */ -#define NVCMD_BEGIN_READ (0x7 << 5 ) // nvRam begin read command -#define NVCMD_LOAD_LOW (0x4 << 5 ) // nvRam load low command -#define NVCMD_LOAD_HIGH (0x5 << 5 ) // nvRam load high command -#define EE76_CMD_LEN 13 // bits in instructions -#define EE_READ 0x0180 // 01 1000 0000 read instruction - -#define WORD unsigned short -#define PWORD unsigned short * -#define PDWORD unsigned int * - -#ifndef DWORD -#define DWORD unsigned int -#endif +#define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ +#define NVCMD_LOAD_LOW (0x4 << 5) /* nvRam load low command */ +#define NVCMD_LOAD_HIGH (0x5 << 5) /* nvRam load high command */ +#define EE76_CMD_LEN 13 /* bits in instructions */ +#define EE_READ 0x0180 /* 01 1000 0000 read instruction */ #define EEPROM_DIGITALINPUT 0 #define EEPROM_DIGITALOUTPUT 1 @@ -68,107 +60,114 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc #define EEPROM_TIMER_WATCHDOG_COUNTER 10 struct str_Functionality { - BYTE b_Type; - WORD w_Address; + unsigned char b_Type; + unsigned short w_Address; }; -typedef struct { - WORD w_HeaderSize; - BYTE b_Nfunctions; +struct str_MainHeader { + unsigned short w_HeaderSize; + unsigned char b_Nfunctions; struct str_Functionality s_Functions[7]; -} str_MainHeader; +}; -typedef struct { - WORD w_Nchannel; - BYTE b_Interruptible; - WORD w_NinterruptLogic; -} str_DigitalInputHeader; +struct str_DigitalInputHeader { + unsigned short w_Nchannel; + unsigned char b_Interruptible; + unsigned short w_NinterruptLogic; +}; -typedef struct { - WORD w_Nchannel; -} str_DigitalOutputHeader; +struct str_DigitalOutputHeader { -// used for timer as well as watchdog + unsigned short w_Nchannel; +}; -typedef struct { - WORD w_HeaderSize; - BYTE b_Resolution; - BYTE b_Mode; // in case of Watchdog it is functionality - WORD w_MinTiming; - BYTE b_TimeBase; -} str_TimerDetails; -typedef struct { - WORD w_Ntimer; - str_TimerDetails s_TimerDetails[4]; // supports 4 timers -} str_TimerMainHeader; +/* used for timer as well as watchdog */ + +struct str_TimerDetails { + + unsigned short w_HeaderSize; + unsigned char b_Resolution; + unsigned char b_Mode; /* in case of Watchdog it is functionality */ + unsigned short w_MinTiming; + unsigned char b_TimeBase; +}; + +struct str_TimerMainHeader { + + + unsigned short w_Ntimer; + struct str_TimerDetails s_TimerDetails[4]; /* supports 4 timers */ +}; + typedef struct { - WORD w_Nchannel; - BYTE b_Resolution; + unsigned short w_Nchannel; + unsigned char b_Resolution; } str_AnalogOutputHeader; -typedef struct { - WORD w_Nchannel; - WORD w_MinConvertTiming; - WORD w_MinDelayTiming; - BYTE b_HasDma; - BYTE b_Resolution; -} str_AnalogInputHeader; +struct str_AnalogInputHeader { + unsigned short w_Nchannel; + unsigned short w_MinConvertTiming; + unsigned short w_MinDelayTiming; + unsigned char b_HasDma; + unsigned char b_Resolution; +}; + /*****************************************/ /* Read Header Functions */ /*****************************************/ -INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, +int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, struct comedi_device *dev); -INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_DigitalInputHeader * s_Header); +int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_DigitalInputHeader *s_Header); -INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_DigitalOutputHeader * s_Header); +int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_DigitalOutputHeader *s_Header); -INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_TimerMainHeader * s_Header); +int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_TimerMainHeader *s_Header); -INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_AnalogOutputHeader * s_Header); +int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + str_AnalogOutputHeader *s_Header); -INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_AnalogInputHeader * s_Header); +int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_AnalogInputHeader *s_Header); /******************************************/ /* Eeprom Specific Functions */ /******************************************/ -WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, - WORD w_EepromStartAddress); -void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress); -void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue); -void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress); -void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand, - BYTE b_DataLengthInBits); -void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value); +unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, + unsigned short w_EepromStartAddress); +void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress); +void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue); +void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress); +void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand, + unsigned char b_DataLengthInBits); +void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short *pw_Value); /* +----------------------------------------------------------------------------+ -| Function Name : WORD w_EepromReadWord | -| (WORD w_PCIBoardEepromAddress, | +| Function Name : unsigned short w_EepromReadWord | +| (unsigned short w_PCIBoardEepromAddress, | | char * pc_PCIChipInformation, | -| WORD w_EepromStartAddress) | +| unsigned short w_EepromStartAddress) | +----------------------------------------------------------------------------+ | Task : Read from eepromn a word | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | -| WORD w_EepromStartAddress : Selected eeprom address | +| unsigned short w_EepromStartAddress : Selected eeprom address | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -176,23 +175,23 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value); +----------------------------------------------------------------------------+ */ -WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, - WORD w_EepromStartAddress) +unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, + unsigned short w_EepromStartAddress) { - BYTE b_Counter = 0; + unsigned char b_Counter = 0; - BYTE b_ReadByte = 0; + unsigned char b_ReadByte = 0; - BYTE b_ReadLowByte = 0; + unsigned char b_ReadLowByte = 0; - BYTE b_ReadHighByte = 0; + unsigned char b_ReadHighByte = 0; - BYTE b_SelectedAddressLow = 0; + unsigned char b_SelectedAddressLow = 0; - BYTE b_SelectedAddressHigh = 0; + unsigned char b_SelectedAddressHigh = 0; - WORD w_ReadWord = 0; + unsigned short w_ReadWord = 0; /**************************/ @@ -207,9 +206,9 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, for (b_Counter = 0; b_Counter < 2; b_Counter++) { - b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; //Read the low 8 bit part + b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; /* Read the low 8 bit part */ - b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; //Read the high 8 bit part + b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; /* Read the high 8 bit part */ /************************************/ @@ -320,20 +319,20 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, b_ReadLowByte = b_ReadByte; - } // if(b_Counter==0) + } /* if(b_Counter==0) */ else { b_ReadHighByte = b_ReadByte; - } // if(b_Counter==0) + } /* if(b_Counter==0) */ - } // for (b_Counter=0; b_Counter<2; b_Counter++) + } /* for (b_Counter=0; b_Counter<2; b_Counter++) */ - w_ReadWord = (b_ReadLowByte | (((WORD) b_ReadHighByte) * 256)); + w_ReadWord = (b_ReadLowByte | (((unsigned short) b_ReadHighByte) * 256)); - } // end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933"))) + } /* end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933"))) */ if (!strcmp(pc_PCIChipInformation, "93C76")) { @@ -349,7 +348,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, } - return (w_ReadWord); + return w_ReadWord; } @@ -359,7 +358,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, | Function Name : void v_EepromWaitBusy | -| (WORD w_PCIBoardEepromAddress) | +| (unsigned short w_PCIBoardEepromAddress) | +----------------------------------------------------------------------------+ @@ -367,7 +366,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom base address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom base address | +----------------------------------------------------------------------------+ @@ -381,10 +380,10 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation, */ -void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress) +void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress) { - BYTE b_EepromBusy = 0; + unsigned char b_EepromBusy = 0; do { @@ -403,17 +402,16 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress) /* the operator register is AMCC_OP_REG_MCSR+3 */ - /* WORD read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */ + /* unsigned short read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */ - /* DWORD read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */ + /* unsigned int read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */ /************************************************************************/ b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F); b_EepromBusy = b_EepromBusy & 0x80; - } - while (b_EepromBusy == 0x80); + } while (b_EepromBusy == 0x80); } @@ -421,9 +419,9 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress) +---------------------------------------------------------------------------------+ -| Function Name : void v_EepromClock76(DWORD dw_Address, | +| Function Name : void v_EepromClock76(unsigned int dw_Address, | -| DWORD dw_RegisterValue) | +| unsigned int dw_RegisterValue) | +---------------------------------------------------------------------------------+ @@ -431,9 +429,9 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress) +---------------------------------------------------------------------------------+ -| Input Parameters : DWORD dw_Address : PCI eeprom base address | +| Input Parameters : unsigned int dw_Address : PCI eeprom base address | -| DWORD dw_RegisterValue : PCI eeprom register value to write.| +| unsigned int dw_RegisterValue : PCI eeprom register value to write.| +---------------------------------------------------------------------------------+ @@ -447,7 +445,7 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress) */ -void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue) +void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue) { /************************/ @@ -488,11 +486,11 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue) +---------------------------------------------------------------------------------+ -| Function Name : void v_EepromSendCommand76(DWORD dw_Address, | +| Function Name : void v_EepromSendCommand76(unsigned int dw_Address, | -| DWORD dw_EepromCommand, | +| unsigned int dw_EepromCommand, | -| BYTE b_DataLengthInBits) | +| unsigned char b_DataLengthInBits) | +---------------------------------------------------------------------------------+ @@ -500,11 +498,11 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue) +---------------------------------------------------------------------------------+ -| Input Parameters : DWORD dw_Address : PCI eeprom base address | +| Input Parameters : unsigned int dw_Address : PCI eeprom base address | -| DWORD dw_EepromCommand : PCI eeprom command to write. | +| unsigned int dw_EepromCommand : PCI eeprom command to write. | -| BYTE b_DataLengthInBits : PCI eeprom command data length. | +| unsigned char b_DataLengthInBits : PCI eeprom command data length. | +---------------------------------------------------------------------------------+ @@ -518,13 +516,13 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue) */ -void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand, - BYTE b_DataLengthInBits) +void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand, + unsigned char b_DataLengthInBits) { char c_BitPos = 0; - DWORD dw_RegisterValue = 0; + unsigned int dw_RegisterValue = 0; /*****************************/ @@ -623,11 +621,11 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand, +---------------------------------------------------------------------------------+ -| Function Name : void v_EepromCs76Read(DWORD dw_Address, | +| Function Name : void v_EepromCs76Read(unsigned int dw_Address, | -| WORD w_offset, | +| unsigned short w_offset, | -| PWORD pw_Value) | +| unsigned short * pw_Value) | +---------------------------------------------------------------------------------+ @@ -635,11 +633,11 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand, +---------------------------------------------------------------------------------+ -| Input Parameters : DWORD dw_Address : PCI eeprom base address | +| Input Parameters : unsigned int dw_Address : PCI eeprom base address | -| WORD w_offset : Offset of the adress to read | +| unsigned short w_offset : Offset of the adress to read | -| PWORD pw_Value : PCI eeprom 16 bit read value. | +| unsigned short * pw_Value : PCI eeprom 16 bit read value. | +---------------------------------------------------------------------------------+ @@ -653,14 +651,14 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand, */ -void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value) +void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short *pw_Value) { char c_BitPos = 0; - DWORD dw_RegisterValue = 0; + unsigned int dw_RegisterValue = 0; - DWORD dw_RegisterValueRead = 0; + unsigned int dw_RegisterValueRead = 0; /*************************************************/ @@ -786,12 +784,12 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value) /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, | +| Function Name : int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, | | char * pc_PCIChipInformation,struct comedi_device *dev) | +----------------------------------------------------------------------------+ | Task : Read from eeprom Main Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | @@ -804,43 +802,43 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value) +----------------------------------------------------------------------------+ */ -INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, +int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, struct comedi_device *dev) { - WORD w_Temp, i, w_Count = 0; - UINT ui_Temp; - str_MainHeader s_MainHeader; - str_DigitalInputHeader s_DigitalInputHeader; - str_DigitalOutputHeader s_DigitalOutputHeader; - //str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; + unsigned short w_Temp, i, w_Count = 0; + unsigned int ui_Temp; + struct str_MainHeader s_MainHeader; + struct str_DigitalInputHeader s_DigitalInputHeader; + struct str_DigitalOutputHeader s_DigitalOutputHeader; + /* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */ str_AnalogOutputHeader s_AnalogOutputHeader; - str_AnalogInputHeader s_AnalogInputHeader; + struct str_AnalogInputHeader s_AnalogInputHeader; - // Read size + /* Read size */ s_MainHeader.w_HeaderSize = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + 8); - // Read nbr of functionality + /* Read nbr of functionality */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + 10); - s_MainHeader.b_Nfunctions = (BYTE) w_Temp & 0x00FF; + s_MainHeader.b_Nfunctions = (unsigned char) w_Temp & 0x00FF; - // Read functionality details + /* Read functionality details */ for (i = 0; i < s_MainHeader.b_Nfunctions; i++) { - // Read Type + /* Read Type */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + 12 + w_Count); - s_MainHeader.s_Functions[i].b_Type = (BYTE) w_Temp & 0x3F; + s_MainHeader.s_Functions[i].b_Type = (unsigned char) w_Temp & 0x3F; w_Count = w_Count + 2; - //Read Address + /* Read Address */ s_MainHeader.s_Functions[i].w_Address = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + 12 + w_Count); w_Count = w_Count + 2; } - // Display main header info + /* Display main header info */ for (i = 0; i < s_MainHeader.b_Nfunctions; i++) { switch (s_MainHeader.s_Functions[i].b_Type) { @@ -878,10 +876,10 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, s_AnalogInputHeader.w_Nchannel; this_board->i_Dma = s_AnalogInputHeader.b_HasDma; this_board->ui_MinAcquisitiontimeNs = - (UINT) s_AnalogInputHeader.w_MinConvertTiming * + (unsigned int) s_AnalogInputHeader.w_MinConvertTiming * 1000; this_board->ui_MinDelaytimeNs = - (UINT) s_AnalogInputHeader.w_MinDelayTiming * + (unsigned int) s_AnalogInputHeader.w_MinDelayTiming * 1000; ui_Temp = 0xffff; this_board->i_AiMaxdata = @@ -903,15 +901,15 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, break; case EEPROM_TIMER: - this_board->i_Timer = 1; //Timer subdevice present + this_board->i_Timer = 1; /* Timer subdevice present */ break; case EEPROM_WATCHDOG: - this_board->i_Timer = 1; //Timer subdevice present + this_board->i_Timer = 1; /* Timer subdevice present */ break; case EEPROM_TIMER_WATCHDOG_COUNTER: - this_board->i_Timer = 1; //Timer subdevice present + this_board->i_Timer = 1; /* Timer subdevice present */ } } @@ -920,18 +918,18 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadDigitalInputHeader(WORD | +| Function Name : int i_EepromReadDigitalInputHeader(unsigned short | | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, | -| WORD w_Address,str_DigitalInputHeader *s_Header) | +| unsigned short w_Address,struct str_DigitalInputHeader *s_Header) | | | +----------------------------------------------------------------------------+ | Task : Read Digital Input Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | -| str_DigitalInputHeader *s_Header: Digita Input Header | +| struct str_DigitalInputHeader *s_Header: Digita Input Header | | Pointer | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -939,23 +937,23 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, | Return Value : 0 | +----------------------------------------------------------------------------+ */ -INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_DigitalInputHeader * s_Header) +int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_DigitalInputHeader *s_Header) { - WORD w_Temp; + unsigned short w_Temp; - // read nbr of channels + /* read nbr of channels */ s_Header->w_Nchannel = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 6); - // interruptible or not + /* interruptible or not */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 8); - s_Header->b_Interruptible = (BYTE) (w_Temp >> 7) & 0x01; + s_Header->b_Interruptible = (unsigned char) (w_Temp >> 7) & 0x01; -// How many interruptible logic +/* How many interruptible logic */ s_Header->w_NinterruptLogic = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 10); @@ -965,18 +963,18 @@ INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadDigitalOutputHeader(WORD | +| Function Name : int i_EepromReadDigitalOutputHeader(unsigned short | | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, | -| WORD w_Address,str_DigitalOutputHeader *s_Header) | +| unsigned short w_Address,struct str_DigitalOutputHeader *s_Header) | | | +----------------------------------------------------------------------------+ | Task : Read Digital Output Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | -| str_DigitalOutputHeader *s_Header: Digital Output Header| +| struct str_DigitalOutputHeader *s_Header: Digital Output Header| | Pointer | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -984,11 +982,11 @@ INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress, | Return Value : 0 | +----------------------------------------------------------------------------+ */ -INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_DigitalOutputHeader * s_Header) +int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_DigitalOutputHeader *s_Header) { -// Read Nbr channels +/* Read Nbr channels */ s_Header->w_Nchannel = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 6); @@ -997,17 +995,17 @@ INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, | +| Function Name : int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, | | char *pc_PCIChipInformation,WORD w_Address, | -| str_TimerMainHeader *s_Header) | +| struct str_TimerMainHeader *s_Header) | +----------------------------------------------------------------------------+ | Task : Read Timer or Watchdog Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | -| str_TimerMainHeader *s_Header: Timer Header | +| struct str_TimerMainHeader *s_Header: Timer Header | | Pointer | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -1015,18 +1013,18 @@ INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress, | Return Value : 0 | +----------------------------------------------------------------------------+ */ -INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_TimerMainHeader * s_Header) +int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_TimerMainHeader *s_Header) { - WORD i, w_Size = 0, w_Temp; + unsigned short i, w_Size = 0, w_Temp; -//Read No of Timer +/* Read No of Timer */ s_Header->w_Ntimer = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 6); -//Read header size +/* Read header size */ for (i = 0; i < s_Header->w_Ntimer; i++) { s_Header->s_TimerDetails[i].w_HeaderSize = @@ -1037,23 +1035,23 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 8 + w_Size + 2); - //Read Resolution + /* Read Resolution */ s_Header->s_TimerDetails[i].b_Resolution = - (BYTE) (w_Temp >> 10) & 0x3F; + (unsigned char) (w_Temp >> 10) & 0x3F; - //Read Mode + /* Read Mode */ s_Header->s_TimerDetails[i].b_Mode = - (BYTE) (w_Temp >> 4) & 0x3F; + (unsigned char) (w_Temp >> 4) & 0x3F; w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 8 + w_Size + 4); - //Read MinTiming + /* Read MinTiming */ s_Header->s_TimerDetails[i].w_MinTiming = (w_Temp >> 6) & 0x3FF; - //Read Timebase - s_Header->s_TimerDetails[i].b_TimeBase = (BYTE) (w_Temp) & 0x3F; + /* Read Timebase */ + s_Header->s_TimerDetails[i].b_TimeBase = (unsigned char) (w_Temp) & 0x3F; w_Size += s_Header->s_TimerDetails[i].w_HeaderSize; } @@ -1062,13 +1060,13 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadAnlogOutputHeader(WORD | +| Function Name : int i_EepromReadAnlogOutputHeader(unsigned short | | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, | -| WORD w_Address,str_AnalogOutputHeader *s_Header) | +| unsigned short w_Address,str_AnalogOutputHeader *s_Header) | +----------------------------------------------------------------------------+ | Task : Read Nalog Output Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | @@ -1081,35 +1079,35 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, +----------------------------------------------------------------------------+ */ -INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_AnalogOutputHeader * s_Header) +int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + str_AnalogOutputHeader *s_Header) { - WORD w_Temp; - // No of channels for 1st hard component + unsigned short w_Temp; + /* No of channels for 1st hard component */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 10); s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF; - // Resolution for 1st hard component + /* Resolution for 1st hard component */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 16); - s_Header->b_Resolution = (BYTE) (w_Temp >> 8) & 0xFF; + s_Header->b_Resolution = (unsigned char) (w_Temp >> 8) & 0xFF; return 0; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_EepromReadAnlogInputHeader(WORD | +| Function Name : int i_EepromReadAnlogInputHeader(unsigned short | | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, | -| WORD w_Address,str_AnalogInputHeader *s_Header) | +| unsigned short w_Address,struct str_AnalogInputHeader *s_Header) | +----------------------------------------------------------------------------+ | Task : Read Nalog Output Header | +----------------------------------------------------------------------------+ -| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address | +| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address | | | | char *pc_PCIChipInformation : PCI Chip Type. | | | -| str_AnalogInputHeader *s_Header:Anlog Input Header | +| struct str_AnalogInputHeader *s_Header:Anlog Input Header | | Pointer | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -1118,12 +1116,12 @@ INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress, +----------------------------------------------------------------------------+ */ -// Reads only for ONE hardware component -INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress, - char *pc_PCIChipInformation, WORD w_Address, - str_AnalogInputHeader * s_Header) +/* Reads only for ONE hardware component */ +int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress, + char *pc_PCIChipInformation, unsigned short w_Address, + struct str_AnalogInputHeader *s_Header) { - WORD w_Temp, w_Offset; + unsigned short w_Temp, w_Offset; w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 10); s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF; @@ -1135,24 +1133,24 @@ INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress, 0x100 + w_Address + 30); w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 20); - s_Header->b_HasDma = (w_Temp >> 13) & 0x01; // whether dma present or not + s_Header->b_HasDma = (w_Temp >> 13) & 0x01; /* whether dma present or not */ - w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); // reading Y + w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); /* reading Y */ w_Temp = w_Temp & 0x00FF; - if (w_Temp) //Y>0 + if (w_Temp) /* Y>0 */ { - w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); // offset of first analog input single header - w_Offset = w_Offset + 2; // resolution - } else //Y=0 + w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); /* offset of first analog input single header */ + w_Offset = w_Offset + 2; /* resolution */ + } else /* Y=0 */ { w_Offset = 74; - w_Offset = w_Offset + 2; // resolution + w_Offset = w_Offset + 2; /* resolution */ } -// read Resolution +/* read Resolution */ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + w_Offset); - s_Header->b_Resolution = w_Temp & 0x001F; // last 5 bits + s_Header->b_Resolution = w_Temp & 0x001F; /* last 5 bits */ return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h index 617dc087dcbf..b76f877f250a 100644 --- a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h +++ b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h @@ -31,15 +31,15 @@ *************************/ -#define FIFO_ADVANCE_ON_BYTE_2 0x20000000 // written on base0 +#define FIFO_ADVANCE_ON_BYTE_2 0x20000000 /* written on base0 */ -#define AMWEN_ENABLE 0x02 // added for step 6 dma written on base2 +#define AMWEN_ENABLE 0x02 /* added for step 6 dma written on base2 */ #define A2P_FIFO_WRITE_ENABLE 0x01 -#define AGCSTS_TC_ENABLE 0x10000000 // Added for transfer count enable bit +#define AGCSTS_TC_ENABLE 0x10000000 /* Added for transfer count enable bit */ -// ADDON RELATED ADDITIONS -// Constant +/* ADDON RELATED ADDITIONS */ +/* Constant */ #define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW 0x00 #define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH 0x1200 #define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L @@ -52,7 +52,7 @@ #define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0 #define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 - // ADD_ON ::: this needed since apci supports 16 bit interface to add on + /* ADD_ON ::: this needed since apci supports 16 bit interface to add on */ #define APCI3120_ADD_ON_AGCSTS_LOW 0x3C #define APCI3120_ADD_ON_AGCSTS_HIGH APCI3120_ADD_ON_AGCSTS_LOW + 2 #define APCI3120_ADD_ON_MWAR_LOW 0x24 @@ -60,7 +60,7 @@ #define APCI3120_ADD_ON_MWTC_LOW 0x058 #define APCI3120_ADD_ON_MWTC_HIGH APCI3120_ADD_ON_MWTC_LOW + 2 -// AMCC +/* AMCC */ #define APCI3120_AMCC_OP_MCSR 0x3C #define APCI3120_AMCC_OP_REG_INTCSR 0x38 @@ -85,7 +85,7 @@ #define AMCC_OP_REG_MRTC 0x30 #define AMCC_OP_REG_MBEF 0x34 #define AMCC_OP_REG_INTCSR 0x38 -#define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* INT source */ +#define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* int source */ #define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3) /* FIFO ctrl */ #define AMCC_OP_REG_MCSR 0x3c #define AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2) /* Data in byte 2 */ @@ -212,7 +212,7 @@ struct pcilst_struct { unsigned int irq; }; -struct pcilst_struct *amcc_devices; // ptr to root list of all amcc devices +struct pcilst_struct *amcc_devices; /* ptr to root list of all amcc devices */ /****************************************************************************/ @@ -267,7 +267,7 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display) amcc->vendor = pcidev->vendor; amcc->device = pcidev->device; #if 0 - amcc->master = pcidev->master; // how get this information under 2.4 kernels? + amcc->master = pcidev->master; /* how get this information under 2.4 kernels? */ #endif amcc->pci_bus = pcidev->bus->number; amcc->pci_slot = PCI_SLOT(pcidev->devfn); @@ -333,17 +333,17 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id, && (amcc->pci_slot == pci_slot)) { if (!(amcc->used)) { *card = amcc; - return 0; // ok, card is found + return 0; /* ok, card is found */ } else { - rt_printk + printk (" - \nCard on requested position is used b:s %d:%d!\n", pci_bus, pci_slot); - return 2; // card exist but is used + return 2; /* card exist but is used */ } } } - return 1; // no card found + return 1; /* no card found */ } /****************************************************************************/ @@ -422,11 +422,10 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, { struct pcilst_struct *card; - if ((pci_bus < 1) & (pci_slot < 1)) { // use autodetection - if ((card = ptr_find_free_pci_card_by_device(vendor_id, - device_id)) == - NULL) { - rt_printk(" - Unused card not found in system!\n"); + if ((pci_bus < 1) & (pci_slot < 1)) { /* use autodetection */ + card = ptr_find_free_pci_card_by_device(vendor_id, device_id); + if (card == NULL) { + printk(" - Unused card not found in system!\n"); return NULL; } } else { @@ -434,12 +433,12 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, pci_bus, pci_slot, &card)) { case 1: - rt_printk + printk (" - Card not found on requested position b:s %d:%d!\n", pci_bus, pci_slot); return NULL; case 2: - rt_printk + printk (" - Card on requested position is used b:s %d:%d!\n", pci_bus, pci_slot); return NULL; @@ -447,7 +446,7 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, } if (i_pci_card_alloc(card) != 0) { - rt_printk(" - Can't allocate card!\n"); + printk(" - Can't allocate card!\n"); return NULL; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c index 3f8929c09070..47517a938ec5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c @@ -1,15 +1,15 @@ -/** +//** @verbatim Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -56,21 +56,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc #include "APCI1710_Pwm.c" #include "APCI1710_INCCPT.c" -void i_ADDI_AttachPCI1710(struct comedi_device * dev) +void i_ADDI_AttachPCI1710(struct comedi_device *dev) { struct comedi_subdevice *s; int ret = 0; int n_subdevices = 9; - //Update-0.7.57->0.7.68dev->n_subdevices = 9; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) + /* Update-0.7.57->0.7.68dev->n_subdevices = 9; */ + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) return; - // Allocate and Initialise Timer Subdevice Structures + /* Allocate and Initialise Timer Subdevice Structures */ s = dev->subdevices + 0; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 3; s->maxdata = 0; s->len_chanlist = 3; @@ -80,12 +81,12 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_config = i_APCI1710_InsnConfigInitTimer; s->insn_bits = i_APCI1710_InsnBitsTimer; - // Allocate and Initialise DIO Subdevice Structures + /* Allocate and Initialise DIO Subdevice Structures */ s = dev->subdevices + 1; s->type = COMEDI_SUBD_DIO; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 7; s->maxdata = 1; s->len_chanlist = 7; @@ -95,11 +96,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_bits = i_APCI1710_InsnBitsDigitalIOPortOnOff; s->insn_write = i_APCI1710_InsnWriteDigitalIOChlOnOff; - // Allocate and Initialise Chrono Subdevice Structures + /* Allocate and Initialise Chrono Subdevice Structures */ s = dev->subdevices + 2; s->type = COMEDI_SUBD_CHRONO; - s->subdev_flags = SDF_WRITEABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 4; s->maxdata = 0; s->len_chanlist = 4; @@ -109,55 +110,55 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_config = i_APCI1710_InsnConfigInitChrono; s->insn_bits = i_APCI1710_InsnBitsChronoDigitalIO; - // Allocate and Initialise PWM Subdevice Structures + /* Allocate and Initialise PWM Subdevice Structures */ s = dev->subdevices + 3; s->type = COMEDI_SUBD_PWM; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 3; s->maxdata = 1; s->len_chanlist = 3; s->range_table = &range_digital; - s->io_bits = 0; //all bits input + s->io_bits = 0; /* all bits input */ s->insn_config = i_APCI1710_InsnConfigPWM; s->insn_read = i_APCI1710_InsnReadGetPWMStatus; s->insn_write = i_APCI1710_InsnWritePWM; s->insn_bits = i_APCI1710_InsnBitsReadPWMInterrupt; - // Allocate and Initialise TTLIO Subdevice Structures + /* Allocate and Initialise TTLIO Subdevice Structures */ s = dev->subdevices + 4; s->type = COMEDI_SUBD_TTLIO; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; - s->range_table = &range_apci1710_ttl; // to pass arguments in range + s->range_table = &range_apci1710_ttl; /* to pass arguments in range */ s->insn_config = i_APCI1710_InsnConfigInitTTLIO; s->insn_bits = i_APCI1710_InsnBitsReadTTLIO; s->insn_write = i_APCI1710_InsnWriteSetTTLIOChlOnOff; s->insn_read = i_APCI1710_InsnReadTTLIOAllPortValue; - // Allocate and Initialise TOR Subdevice Structures + /* Allocate and Initialise TOR Subdevice Structures */ s = dev->subdevices + 5; s->type = COMEDI_SUBD_TOR; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; s->range_table = &range_digital; - s->io_bits = 0; //all bits input + s->io_bits = 0; /* all bits input */ s->insn_config = i_APCI1710_InsnConfigInitTorCounter; s->insn_read = i_APCI1710_InsnReadGetTorCounterInitialisation; s->insn_write = i_APCI1710_InsnWriteEnableDisableTorCounter; s->insn_bits = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue; - // Allocate and Initialise SSI Subdevice Structures + /* Allocate and Initialise SSI Subdevice Structures */ s = dev->subdevices + 6; s->type = COMEDI_SUBD_SSI; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 4; s->maxdata = 1; s->len_chanlist = 4; @@ -166,11 +167,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_read = i_APCI1710_InsnReadSSIValue; s->insn_bits = i_APCI1710_InsnBitsSSIDigitalIO; - // Allocate and Initialise PULSEENCODER Subdevice Structures + /* Allocate and Initialise PULSEENCODER Subdevice Structures */ s = dev->subdevices + 7; s->type = COMEDI_SUBD_PULSEENCODER; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 4; s->maxdata = 1; s->len_chanlist = 4; @@ -180,11 +181,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_bits = i_APCI1710_InsnBitsReadWritePulseEncoder; s->insn_read = i_APCI1710_InsnReadInterruptPulseEncoder; - // Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures + /* Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures */ s = dev->subdevices + 8; s->type = COMEDI_SUBD_INCREMENTALCOUNTER; s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON; + SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 500; s->maxdata = 1; s->len_chanlist = 500; @@ -195,14 +196,14 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev) s->insn_bits = i_APCI1710_InsnBitsINCCPT; } -int i_APCI1710_Reset(struct comedi_device * dev); +int i_APCI1710_Reset(struct comedi_device *dev); void v_APCI1710_Interrupt(int irq, void *d); -//for 1710 +/* for 1710 */ -int i_APCI1710_Reset(struct comedi_device * dev) +int i_APCI1710_Reset(struct comedi_device *dev) { int ret; - DWORD dw_Dummy; + unsigned int dw_Dummy; /*********************************/ /* Read all module configuration */ @@ -219,12 +220,12 @@ int i_APCI1710_Reset(struct comedi_device * dev) ret = inl(devpriv->s_BoardInfos.ui_Address + 252); devpriv->s_BoardInfos.dw_MolduleConfiguration[3] = ret; - // outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60); + /* outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60); */ outl(0x83838383, devpriv->s_BoardInfos.ui_Address + 0x60); devpriv->s_BoardInfos.b_BoardVersion = 1; - // Enable the interrupt for the controler + /* Enable the interrupt for the controler */ dw_Dummy = inl(devpriv->s_BoardInfos.ui_Address + 0x38); outl(dw_Dummy | 0x2000, devpriv->s_BoardInfos.ui_Address + 0x38); @@ -234,11 +235,11 @@ int i_APCI1710_Reset(struct comedi_device * dev) /* +----------------------------------------------------------------------------+ | Function's Name : __void__ v_APCI1710_InterruptFunction | -| (BYTE b_Interrupt, __CPPARGS) | +| (unsigned char b_Interrupt, __CPPARGS) | +----------------------------------------------------------------------------+ | Task : APCI-1710 interrupt function | +----------------------------------------------------------------------------+ -| Input Parameters : BYTE b_Interrupt : Interrupt number | +| Input Parameters : unsigned char b_Interrupt : Interrupt number | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -250,18 +251,18 @@ int i_APCI1710_Reset(struct comedi_device * dev) void v_APCI1710_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - BYTE b_ModuleCpt = 0; - BYTE b_InterruptFlag = 0; - BYTE b_PWMCpt = 0; - BYTE b_TorCounterCpt = 0; - BYTE b_PulseIncoderCpt = 0; - UINT ui_16BitValue; - ULONG ul_InterruptLatchReg = 0; - ULONG ul_LatchRegisterValue = 0; - ULONG ul_82X54InterruptStatus; - ULONG ul_StatusRegister; - - str_ModuleInfo *ps_ModuleInfo; + unsigned char b_ModuleCpt = 0; + unsigned char b_InterruptFlag = 0; + unsigned char b_PWMCpt = 0; + unsigned char b_TorCounterCpt = 0; + unsigned char b_PulseIncoderCpt = 0; + unsigned int ui_16BitValue; + unsigned int ul_InterruptLatchReg = 0; + unsigned int ul_LatchRegisterValue = 0; + unsigned int ul_82X54InterruptStatus; + unsigned int ul_StatusRegister; + + union str_ModuleInfo *ps_ModuleInfo; printk("APCI1710 Interrupt\n"); for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt++, ps_ModuleInfo++) { @@ -279,7 +280,7 @@ void v_APCI1710_Interrupt(int irq, void *d) dw_MolduleConfiguration[b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - //printk("TIMER Interrupt Occurred\n"); + /* printk("TIMER Interrupt Occurred\n"); */ ul_82X54InterruptStatus = inl(devpriv->s_BoardInfos. ui_Address + 12 + (64 * b_ModuleCpt)); @@ -332,11 +333,11 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if ((ul_82X54InterruptStatus & 0x7) != 0) - } // 82X54 timer + } /* if ((ul_82X54InterruptStatus & 0x7) != 0) */ + } /* 82X54 timer */ /***************************/ /* Test if increm. counter */ @@ -412,7 +413,7 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); @@ -473,7 +474,7 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); @@ -562,7 +563,7 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); @@ -628,7 +629,7 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); @@ -675,7 +676,7 @@ void v_APCI1710_Interrupt(int irq, void *d) if ((ul_LatchRegisterValue & 0xFFFFU) != 0) { ui_16BitValue = - (UINT) + (unsigned int) ul_LatchRegisterValue & 0xFFFFU; ul_LatchRegisterValue = @@ -693,7 +694,7 @@ void v_APCI1710_Interrupt(int irq, void *d) 0xFFFF0000UL) != 0) { ui_16BitValue = - (UINT) ( + (unsigned int) ( (ul_LatchRegisterValue >> 16) & 0xFFFFU); @@ -721,7 +722,7 @@ void v_APCI1710_Interrupt(int irq, void *d) if ((ul_LatchRegisterValue & 0xFFFF0000UL) != 0) { ui_16BitValue = - (UINT) ( + (unsigned int) ( (ul_LatchRegisterValue >> 16) & 0xFFFFU); @@ -741,7 +742,7 @@ void v_APCI1710_Interrupt(int irq, void *d) if ((ul_LatchRegisterValue & 0xFFFFU) != 0) { ui_16BitValue = - (UINT) + (unsigned int) ul_LatchRegisterValue & 0xFFFFU; ul_LatchRegisterValue = @@ -795,11 +796,11 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); } - } // Incremental counter + } /* Incremental counter */ /***************/ /* Test if CDA */ @@ -870,14 +871,14 @@ void v_APCI1710_Interrupt(int irq, void *d) /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if (ul_StatusRegister & 1) + } /* if (ul_StatusRegister & 1) */ } - } // CDA + } /* CDA */ /***********************/ /* Test if PWM counter */ @@ -950,15 +951,15 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if (ul_StatusRegister & 0x1) - } // if (APCI1710_ENABLE) - } // for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++) - } // PWM counter + } /* if (ul_StatusRegister & 0x1) */ + } /* if (APCI1710_ENABLE) */ + } /* for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++) */ + } /* PWM counter */ /***********************/ /* Test if tor counter */ @@ -1054,14 +1055,14 @@ void v_APCI1710_Interrupt(int irq, void *d) /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if (ul_StatusRegister & 0x1) - } // if (APCI1710_ENABLE) - } // for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++) - } // Tor counter + } /* if (ul_StatusRegister & 0x1) */ + } /* if (APCI1710_ENABLE) */ + } /* for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++) */ + } /* Tor counter */ /***********************/ /* Test if chronometer */ @@ -1071,7 +1072,7 @@ void v_APCI1710_Interrupt(int irq, void *d) dw_MolduleConfiguration[b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - //printk("APCI1710 Chrono Interrupt\n"); + /* printk("APCI1710 Chrono Interrupt\n"); */ /*****************************/ /* Read the interrupt status */ /*****************************/ @@ -1163,13 +1164,13 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); } } - } // Chronometer + } /* Chronometer */ /*************************/ /* Test if pulse encoder */ @@ -1249,7 +1250,7 @@ void v_APCI1710_Interrupt(int irq, void *d) /**********************/ /* Call user function */ /**********************/ - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); @@ -1257,7 +1258,7 @@ void v_APCI1710_Interrupt(int irq, void *d) } } } - } //pulse encoder + } /* pulse encoder */ } return; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h index 998cbba8afeb..22b3e569ecd5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h @@ -44,7 +44,7 @@ #define APCI1710_SYNCHRONOUS_MODE 1 #define APCI1710_ASYNCHRONOUS_MODE 0 -//MODULE INFO STRUCTURE +/* MODULE INFO STRUCTURE */ static const struct comedi_lrange range_apci1710_ttl = { 4, { BIP_RANGE(10), diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index e4527926c2df..016721efdbfb 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -52,9 +52,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ #include "hwdrv_apci035.h" -INT i_WatchdogNbr = 0; -INT i_Temp = 0; -INT i_Flag = 1; +int i_WatchdogNbr = 0; +int i_Temp = 0; +int i_Flag = 1; /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI035_ConfigTimerWatchdog | @@ -64,42 +64,42 @@ INT i_Flag = 1; | Task : Configures The Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Configure As Timer | | 1 Configure As Watchdog | - data[1] : Watchdog number +| data[1] : Watchdog number | data[2] : Time base Unit | | data[3] : Reload Value | - data[4] : External Trigger | - 1:Enable - 0:Disable - data[5] :External Trigger Level - 00 Trigger Disabled - 01 Trigger Enabled (Low level) - 10 Trigger Enabled (High Level) - 11 Trigger Enabled (High/Low level) - data[6] : External Gate | - 1:Enable - 0:Disable - data[7] : External Gate level - 00 Gate Disabled - 01 Gate Enabled (Low level) - 10 Gate Enabled (High Level) - data[8] :Warning Relay - 1: ENABLE - 0: DISABLE - data[9] :Warning Delay available - data[10] :Warning Relay Time unit - data[11] :Warning Relay Time Reload value - data[12] :Reset Relay - 1 : ENABLE - 0 : DISABLE - data[13] :Interrupt - 1 : ENABLE - 0 : DISABLE - +| data[4] : External Trigger | +| 1:Enable +| 0:Disable +| data[5] :External Trigger Level +| 00 Trigger Disabled +| 01 Trigger Enabled (Low level) +| 10 Trigger Enabled (High Level) +| 11 Trigger Enabled (High/Low level) +| data[6] : External Gate | +| 1:Enable +| 0:Disable +| data[7] : External Gate level +| 00 Gate Disabled +| 01 Gate Enabled (Low level) +| 10 Gate Enabled (High Level) +| data[8] :Warning Relay +| 1: ENABLE +| 0: DISABLE +| data[9] :Warning Delay available +| data[10] :Warning Relay Time unit +| data[11] :Warning Relay Time Reload value +| data[12] :Reset Relay +| 1 : ENABLE +| 0 : DISABLE +| data[13] :Interrupt +| 1 : ENABLE +| 0 : DISABLE +| | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -109,12 +109,12 @@ INT i_Flag = 1; | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Status = 0; - UINT ui_Command = 0; - UINT ui_Mode = 0; + unsigned int ui_Status = 0; + unsigned int ui_Command = 0; + unsigned int ui_Mode = 0; i_Temp = 0; devpriv->tsk_Current = current; devpriv->b_TimerSelectMode = data[0]; @@ -124,9 +124,9 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd } else { ui_Mode = 0; } -//ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); +/* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */ ui_Command = 0; -//ui_Command = ui_Command & 0xFFFFF9FEUL; +/* ui_Command = ui_Command & 0xFFFFF9FEUL; */ outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -153,7 +153,7 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL; - } //if (data[0] == ADDIDATA_TIMER) + } /* if (data[0] == ADDIDATA_TIMER) */ else { if (data[0] == ADDIDATA_WATCHDOG) { @@ -260,7 +260,7 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd | Task : Start / Stop The Selected Timer , or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 - Stop Selected Timer/Watchdog | @@ -278,11 +278,11 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - UINT ui_Command = 0; - INT i_Count = 0; + unsigned int ui_Command = 0; + int i_Count = 0; if (data[0] == 1) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -292,7 +292,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - } // if (data[0]==1) + } /* if (data[0]==1) */ if (data[0] == 2) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -304,16 +304,18 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); } - if (data[0] == 0) //Stop The Watchdog + if (data[0] == 0) /* Stop The Watchdog */ { - //Stop The Watchdog + /* Stop The Watchdog */ ui_Command = 0; - //ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); - //ui_Command = ui_Command & 0xFFFFF9FEUL; +/* +* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); +* ui_Command = ui_Command & 0xFFFFF9FEUL; +*/ outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - } // if (data[1]==0) - if (data[0] == 3) //stop all Watchdogs + } /* if (data[1]==0) */ + if (data[0] == 3) /* stop all Watchdogs */ { ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { @@ -329,7 +331,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, } } - if (data[0] == 4) //start all Watchdogs + if (data[0] == 4) /* start all Watchdogs */ { ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { @@ -344,7 +346,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, 0); } } - if (data[0] == 5) //trigger all Watchdogs + if (data[0] == 5) /* trigger all Watchdogs */ { ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { @@ -373,17 +375,17 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, | Task : Read The Selected Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | | +----------------------------------------------------------------------------+ | Output Parameters : data[0] : software trigger status - data[1] : hardware trigger status -| data[2] : Software clear status - data[3] : Overflow status - data[4] : Timer actual value - +| data[1] : hardware trigger status +| data[2] : Software clear status +| data[3] : Overflow status +| data[4] : Timer actual value +| +----------------------------------------------------------------------------+ | Return Value : TRUE : No error occur | @@ -391,42 +393,46 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_ReadTimerWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Status = 0; // Status register + unsigned int ui_Status = 0; /* Status register */ i_WatchdogNbr = insn->unused[0]; - /******************/ + + /******************/ /* Get the status */ - /******************/ + /******************/ + ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); - /***********************************/ + + /***********************************/ /* Get the software trigger status */ - /***********************************/ + /***********************************/ + data[0] = ((ui_Status >> 1) & 1); - /***********************************/ + /***********************************/ /* Get the hardware trigger status */ - /***********************************/ + /***********************************/ data[1] = ((ui_Status >> 2) & 1); - /*********************************/ + /*********************************/ /* Get the software clear status */ - /*********************************/ + /*********************************/ data[2] = ((ui_Status >> 3) & 1); - /***************************/ + /***************************/ /* Get the overflow status */ - /***************************/ + /***************************/ data[3] = ((ui_Status >> 0) & 1); if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); - } // if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) + } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ return insn->n; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI035_ConfigAnalogInput | +| Function Name : int i_APCI035_ConfigAnalogInput | | (struct comedi_device *dev,struct comedi_subdevice *s, | | struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ @@ -447,8 +453,8 @@ INT i_APCI035_ReadTimerWatchdog(struct comedi_device * dev, struct comedi_subdev | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { devpriv->tsk_Current = current; outl(0x200 | 0, devpriv->iobase + 128 + 0x4); @@ -472,8 +478,8 @@ INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdev | Task : Read value of the selected channel | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : Digital Value Of Input | @@ -484,10 +490,10 @@ INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdev | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_CommandRegister = 0; + unsigned int ui_CommandRegister = 0; /******************/ /* Set the start */ /******************/ @@ -519,14 +525,14 @@ INT i_APCI035_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevic | | +----------------------------------------------------------------------------+ */ -INT i_APCI035_Reset(struct comedi_device * dev) +int i_APCI035_Reset(struct comedi_device *dev) { - INT i_Count = 0; + int i_Count = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { i_WatchdogNbr = i_Count; - outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); //stop all timers + outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); /* stop all timers */ } - outl(0x0, devpriv->iobase + 128 + 12); //Disable the warning delay + outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */ return 0; } @@ -551,11 +557,11 @@ INT i_APCI035_Reset(struct comedi_device * dev) static void v_APCI035_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - UINT ui_StatusRegister1 = 0; - UINT ui_StatusRegister2 = 0; - UINT ui_ReadCommand = 0; - UINT ui_ChannelNumber = 0; - UINT ui_DigitalTemperature = 0; + unsigned int ui_StatusRegister1 = 0; + unsigned int ui_StatusRegister2 = 0; + unsigned int ui_ReadCommand = 0; + unsigned int ui_ChannelNumber = 0; + unsigned int ui_DigitalTemperature = 0; if (i_Temp == 1) { i_WatchdogNbr = i_Flag; i_Flag = i_Flag + 1; @@ -571,7 +577,7 @@ static void v_APCI035_Interrupt(int irq, void *d) ui_StatusRegister2 = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20); - if ((((ui_StatusRegister1) & 0x8) == 0x8)) //Test if warning relay interrupt + if ((((ui_StatusRegister1) & 0x8) == 0x8)) /* Test if warning relay interrupt */ { /**********************************/ /* Disable the temperature warning */ @@ -587,14 +593,14 @@ static void v_APCI035_Interrupt(int irq, void *d) /* Read the digital temperature value */ /**************************************/ ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample - } //if (((ui_StatusRegister1 & 0x8) == 0x8)) + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */ else { if ((ui_StatusRegister2 & 0x1) == 0x1) { - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } - } //else if (((ui_StatusRegister1 & 0x8) == 0x8)) + } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */ return; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h index 80d7c0d39aab..e0023c8cb628 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h @@ -19,18 +19,18 @@ #define APCI035_BOARD_VENDOR_ID 0x15B8 #define APCI035_ADDRESS_RANGE 255 -INT i_TW_Number; +int i_TW_Number; struct { - INT i_Gain; - INT i_Polarity; - INT i_OffsetRange; - INT i_Coupling; - INT i_SingleDiff; - INT i_AutoCalibration; - UINT ui_ReloadValue; - UINT ui_TimeUnitReloadVal; - INT i_Interrupt; - INT i_ModuleSelection; + int i_Gain; + int i_Polarity; + int i_OffsetRange; + int i_Coupling; + int i_SingleDiff; + int i_AutoCalibration; + unsigned int ui_ReloadValue; + unsigned int ui_TimeUnitReloadVal; + int i_Interrupt; + int i_ModuleSelection; } Config_Parameters_Main; /* ANALOG INPUT RANGE */ @@ -101,23 +101,23 @@ struct comedi_lrange range_apci035_ai = { 8, { /* TIMER */ /* timer value is passed as u seconds */ -INT i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, +int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* Temperature Related Defines (Analog Input Subdevice) */ -INT i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* Interrupt */ static void v_APCI035_Interrupt(int irq, void *d); /* Reset functions */ -INT i_APCI035_Reset(struct comedi_device *dev); +int i_APCI035_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c index 32796ceb946e..e9021cd4d341 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -53,8 +53,8 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc */ #include "hwdrv_apci1032.h" #include <linux/delay.h> -//Global variables -UINT ui_InterruptStatus = 0; +/* Global variables */ +unsigned int ui_InterruptStatus = 0; /* +----------------------------------------------------------------------------+ @@ -84,13 +84,13 @@ UINT ui_InterruptStatus = 0; +----------------------------------------------------------------------------+ */ -INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue; + unsigned int ui_TmpValue; - ULONG ul_Command1 = 0; - ULONG ul_Command2 = 0; + unsigned int ul_Command1 = 0; + unsigned int ul_Command2 = 0; devpriv->tsk_Current = current; /*******************************/ @@ -107,11 +107,11 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd outl(0x4, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); ui_TmpValue = inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); - } //if (data[1] == ADDIDATA_OR) + } /* if (data[1] == ADDIDATA_OR) */ else { outl(0x6, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); - } //else if(data[1] == ADDIDATA_OR) - } // if( data[0] == ADDIDATA_ENABLE) + } /* else if(data[1] == ADDIDATA_OR) */ + } /* if( data[0] == ADDIDATA_ENABLE) */ else { ul_Command1 = ul_Command1 & 0xFFFF0000; ul_Command2 = ul_Command2 & 0xFFFF0000; @@ -120,7 +120,7 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd outl(ul_Command2, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2); outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); - } //else if ( data[0] == ADDIDATA_ENABLE) + } /* else if ( data[0] == ADDIDATA_ENABLE) */ return insn->n; } @@ -134,7 +134,7 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd | Task : Return the status of the digital input | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_Channel : Channel number to read | +| unsigned int ui_Channel : Channel number to read | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -144,22 +144,24 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue = 0; - UINT ui_Channel; + unsigned int ui_TmpValue = 0; + unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); if (ui_Channel >= 0 && ui_Channel <= 31) { - ui_TmpValue = (UINT) inl(devpriv->iobase + APCI1032_DIGITAL_IP); - // since only 1 channel reqd to bring it to last bit it is rotated - // 8 +(chan - 1) times then ANDed with 1 for last bit. + ui_TmpValue = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP); +/* +* since only 1 channel reqd to bring it to last bit it is rotated 8 +* +(chan - 1) times then ANDed with 1 for last bit. +*/ *data = (ui_TmpValue >> ui_Channel) & 0x1; - } //if(ui_Channel >= 0 && ui_Channel <=31) + } /* if(ui_Channel >= 0 && ui_Channel <=31) */ else { - //comedi_error(dev," \n chan spec wrong\n"); - return -EINVAL; // "sorry channel spec wrong " - } //else if(ui_Channel >= 0 && ui_Channel <=31) + /* comedi_error(dev," \n chan spec wrong\n"); */ + return -EINVAL; /* "sorry channel spec wrong " */ + } /* else if(ui_Channel >= 0 && ui_Channel <=31) */ return insn->n; } @@ -172,8 +174,8 @@ INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde | Task : Return the status of the Requested digital inputs | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To be Read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To be Read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -183,16 +185,16 @@ INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_PortValue = data[0]; - UINT ui_Mask = 0; - UINT ui_NoOfChannels; + unsigned int ui_PortValue = data[0]; + unsigned int ui_Mask = 0; + unsigned int ui_NoOfChannels; ui_NoOfChannels = CR_CHAN(insn->chanspec); if (data[1] == 0) { - *data = (UINT) inl(devpriv->iobase + APCI1032_DIGITAL_IP); + *data = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP); switch (ui_NoOfChannels) { case 2: ui_Mask = 3; @@ -213,16 +215,16 @@ INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su case 31: break; default: - //comedi_error(dev," \nchan spec wrong\n"); - return -EINVAL; // "sorry channel spec wrong " + /* comedi_error(dev," \nchan spec wrong\n"); */ + return -EINVAL; /* "sorry channel spec wrong " */ break; - } //switch(ui_NoOfChannels) - } //if(data[1]==0) + } /* switch(ui_NoOfChannels) */ + } /* if(data[1]==0) */ else { if (data[1] == 1) { *data = ui_InterruptStatus; - } //if(data[1]==1) - } //else if(data[1]==0) + } /* if(data[1]==1) */ + } /* else if(data[1]==0) */ return insn->n; } @@ -247,16 +249,16 @@ static void v_APCI1032_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - UINT ui_Temp; - //disable the interrupt + unsigned int ui_Temp; + /* disable the interrupt */ ui_Temp = inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); outl(ui_Temp & APCI1032_DIGITAL_IP_INTERRUPT_DISABLE, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); ui_InterruptStatus = inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); ui_InterruptStatus = ui_InterruptStatus & 0X0000FFFF; - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample - outl(ui_Temp, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); //enable the interrupt + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + outl(ui_Temp, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* enable the interrupt */ return; } @@ -275,11 +277,11 @@ static void v_APCI1032_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -INT i_APCI1032_Reset(struct comedi_device * dev) +int i_APCI1032_Reset(struct comedi_device *dev) { - outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); //disable the interrupts - inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); //Reset the interrupt status register - outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); //Disable the and/or interrupt + outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* disable the interrupts */ + inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); /* Reset the interrupt status register */ + outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); /* Disable the and/or interrupt */ outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2); return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h index 659ef85088cd..e29a72a568f3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h @@ -19,45 +19,46 @@ #define APCI1032_BOARD_VENDOR_ID 0x15B8 #define APCI1032_ADDRESS_RANGE 20 -//DIGITAL INPUT DEFINE +/* DIGITAL INPUT DEFINE */ #define APCI1032_DIGITAL_IP 0 #define APCI1032_DIGITAL_IP_INTERRUPT_MODE1 4 #define APCI1032_DIGITAL_IP_INTERRUPT_MODE2 8 #define APCI1032_DIGITAL_IP_IRQ 16 -//Digital Input IRQ Function Selection +/* Digital Input IRQ Function Selection */ #define ADDIDATA_OR 0 #define ADDIDATA_AND 1 -//Digital Input Interrupt Status +/* Digital Input Interrupt Status */ #define APCI1032_DIGITAL_IP_INTERRUPT_STATUS 12 -//Digital Input Interrupt Enable Disable. +/* Digital Input Interrupt Enable Disable. */ #define APCI1032_DIGITAL_IP_INTERRUPT_ENABLE 0x4 #define APCI1032_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB -//ADDIDATA Enable Disable +/* ADDIDATA Enable Disable */ #define ADDIDATA_ENABLE 1 #define ADDIDATA_DISABLE 0 -// Hardware Layer functions for Apci1032 +/* Hardware Layer functions for Apci1032 */ -//DI -// for di read +/* +* DI for di read +*/ -INT i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// Interrupt functions..... +/* Interrupt functions..... */ static void v_APCI1032_Interrupt(int irq, void *d); -//Reset -INT i_APCI1032_Reset(struct comedi_device *dev); +/* Reset */ +int i_APCI1032_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c index 2d6adcff41e3..236b8a31c824 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -77,7 +77,7 @@ int i_TimerCounter1Enabled = 0, i_TimerCounter2Enabled = | data[0] :Number of the input port on | | which the event will take place | | (1 or 2) - data[1] : The event logic for port 1 has | +| data[1] : The event logic for port 1 has | | three possibilities | | :0 APCI1500_AND :This logic | | links | @@ -137,8 +137,8 @@ int i_TimerCounter1Enabled = 0, i_TimerCounter2Enabled = +----------------------------------------------------------------------------+ */ -INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ConfigDigitalInputEvent(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i_PatternPolarity = 0, i_PatternTransition = 0, i_PatternMask = 0; int i_MaxChannel = 0, i_Count = 0, i_EventMask = 0; @@ -157,16 +157,16 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, if (data[0] == 1) { i_MaxChannel = 8; - } // if (data[0] == 1) + } /* if (data[0] == 1) */ else { if (data[0] == 2) { i_MaxChannel = 6; - } // if(data[0]==2) + } /* if(data[0]==2) */ else { printk("\nThe specified port event does not exist\n"); return -EINVAL; - } //else if(data[0]==2) - } //else if (data[0] == 1) + } /* else if(data[0]==2) */ + } /* else if (data[0] == 1) */ switch (data[1]) { case 0: data[1] = APCI1500_AND; @@ -180,7 +180,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, default: printk("\nThe specified interrupt logic does not exist\n"); return -EINVAL; - } //switch(data[1]); + } /* switch(data[1]); */ i_Logic = data[1]; for (i_Count = i_MaxChannel, i = 0; i_Count > 0; i_Count--, i++) { @@ -224,8 +224,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, default: printk("\nThe option indicated in the event mask does not exist\n"); return -EINVAL; - } // switch(i_EventMask) - } //for (i_Count = i_MaxChannel; i_Count >0;i_Count --) + } /* switch(i_EventMask) */ + } /* for (i_Count = i_MaxChannel; i_Count >0;i_Count --) */ if (data[0] == 1) { /****************************/ @@ -247,7 +247,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, /********************************************/ printk("\nTransition error on an OR PRIORITY logic\n"); return -EINVAL; - } // if (data[1]== APCI1500_OR_PRIORITY && i_PatternTransition != 0) + } /* if (data[1]== APCI1500_OR_PRIORITY && i_PatternTransition != 0) */ /*************************************/ /* Tests if more than one transition */ @@ -261,7 +261,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, ((i_PatternTransition >> i_Count) & 0x1); - } //for (i_Count = 0; i_Count < 8; i_Count++) + } /* for (i_Count = 0; i_Count < 8; i_Count++) */ if (i_PatternTransitionCount > 1) { /****************************************/ @@ -269,8 +269,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, /****************************************/ printk("\n Transition error on an AND logic\n"); return -EINVAL; - } // if (i_PatternTransitionCount > 1) - } // if (data[1]== APCI1500_AND) + } /* if (i_PatternTransitionCount > 1) */ + } /* if (data[1]== APCI1500_AND) */ /*****************************************************************/ /* Selects the APCI1500_RW_MASTER_CONFIGURATION_CONTROL register */ @@ -359,12 +359,12 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } // if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) + } /* if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) */ else { printk("\nThe choice for interrupt logic does not exist\n"); return -EINVAL; - } // else }// if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) - } // if (data[0]== 1) + } /* else }// if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) */ + } /* if (data[0]== 1) */ /************************************/ /* Test if event setting for port 2 */ @@ -487,12 +487,12 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, outb(0xF4, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } // if (data[1] == APCI1500_OR) + } /* if (data[1] == APCI1500_OR) */ else { printk("\nThe choice for interrupt logic does not exist\n"); return -EINVAL; - } //elseif (data[1] == APCI1500_OR) - } //if(data[0]==2) + } /* elseif (data[1] == APCI1500_OR) */ + } /* if(data[0]==2) */ return insn->n; } @@ -506,11 +506,11 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, | Task : Allows or disallows a port event | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_Channel : Channel number to read | +| unsigned int ui_Channel : Channel number to read | | unsigned int *data : Data Pointer to read status | - data[0] :0 Start input event - 1 Stop input event - data[1] :No of port (1 or 2) +| data[0] :0 Start input event +| 1 Stop input event +| data[1] :No of port (1 or 2) +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -519,8 +519,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_StartStopInputEvent(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i_Event1InterruptStatus = 0, i_Event2InterruptStatus = 0, i_RegValue; @@ -589,12 +589,12 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } // if(i_Event1Status==1) + } /* if(i_Event1Status==1) */ else { printk("\nEvent 1 not initialised\n"); return -EINVAL; - } //else if(i_Event1Status==1) - } //if (data[1]==1) + } /* else if(i_Event1Status==1) */ + } /* if (data[1]==1) */ if (data[1] == 2) { if (i_Event2Status == 1) { @@ -640,17 +640,17 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); i_Event2InterruptStatus = 1; - } // if(i_Event2Status==1) + } /* if(i_Event2Status==1) */ else { printk("\nEvent 2 not initialised\n"); return -EINVAL; - } //else if(i_Event2Status==1) - } // if(data[1]==2) - } // if (data[1] == 1 || data[0] == 2) + } /* else if(i_Event2Status==1) */ + } /* if(data[1]==2) */ + } /* if (data[1] == 1 || data[0] == 2) */ else { printk("\nThe port parameter is in error\n"); return -EINVAL; - } //else if (data[1] == 1 || data[0] == 2) + } /* else if (data[1] == 1 || data[0] == 2) */ break; @@ -701,12 +701,12 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); i_Event1InterruptStatus = 0; - } // if(i_Event1Status==1) + } /* if(i_Event1Status==1) */ else { printk("\nEvent 1 not initialised\n"); return -EINVAL; - } //else if(i_Event1Status==1) - } //if (data[1]==1) + } /* else if(i_Event1Status==1) */ + } /* if (data[1]==1) */ if (data[1] == 2) { /*****************************/ /* Test if event initialised */ @@ -744,23 +744,23 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); i_Event2InterruptStatus = 0; - } // if(i_Event2Status==1) + } /* if(i_Event2Status==1) */ else { printk("\nEvent 2 not initialised\n"); return -EINVAL; - } //else if(i_Event2Status==1) - } //if(data[1]==2) + } /* else if(i_Event2Status==1) */ + } /* if(data[1]==2) */ - } // if (data[1] == 1 || data[1] == 2) + } /* if (data[1] == 1 || data[1] == 2) */ else { printk("\nThe port parameter is in error\n"); return -EINVAL; - } //else if (data[1] == 1 || data[1] == 2) + } /* else if (data[1] == 1 || data[1] == 2) */ break; default: printk("\nThe option of START/STOP logic does not exist\n"); return -EINVAL; - } //switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -774,7 +774,7 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub | Task : Return the status of the digital input | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_Channel : Channel number to read | +| unsigned int ui_Channel : Channel number to read | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -784,8 +784,8 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub | | +----------------------------------------------------------------------------+ */ -INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_Initialisation(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i_DummyRead = 0; /******************/ @@ -943,11 +943,11 @@ INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevic | Task : Return the status of the Requested digital inputs | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To be Read | -| UINT *data : Data Pointer - data[0] : 0 Read a single channel - 1 read a port value - data[1] : port value +| unsigned int ui_NoOfChannels : No Of Channels To be Read | +| unsigned int *data : Data Pointer +| data[0] : 0 Read a single channel +| 1 read a port value +| data[1] : port value +----------------------------------------------------------------------------+ | Output Parameters : -- data[0] :The read status value +----------------------------------------------------------------------------+ @@ -957,31 +957,31 @@ INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_PortValue = data[1]; - UINT ui_Mask = 0; - UINT ui_Channel; - UINT ui_TmpValue = 0; + unsigned int ui_PortValue = data[1]; + unsigned int ui_Mask = 0; + unsigned int ui_Channel; + unsigned int ui_TmpValue = 0; ui_Channel = CR_CHAN(insn->chanspec); switch (data[0]) { case 0: if (ui_Channel >= 0 && ui_Channel <= 15) { ui_TmpValue = - (UINT) inw(devpriv->i_IobaseAddon + + (unsigned int) inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP); *data = (ui_TmpValue >> ui_Channel) & 0x1; - } //if(ui_Channel >= 0 && ui_Channel <=15) + } /* if(ui_Channel >= 0 && ui_Channel <=15) */ else { printk("\nThe channel specification are in error\n"); - return -EINVAL; // "sorry channel spec wrong " - } //else if(ui_Channel >= 0 && ui_Channel <=15) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* else if(ui_Channel >= 0 && ui_Channel <=15) */ break; case 1: - *data = (UINT) inw(devpriv->i_IobaseAddon + + *data = (unsigned int) inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP); switch (ui_Channel) { case 2: @@ -1001,35 +1001,35 @@ INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su default: printk("\nSpecified channel cannot be read \n"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } //switch(ui_Channel) + } /* switch(ui_Channel) */ break; default: printk("\nThe specified functionality does not exist\n"); return -EINVAL; - } //switch(data[0]) + } /* switch(data[0]) */ return insn->n; } /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_ConfigDigitalOutputErrorInterrupt - (struct comedi_device *dev,struct comedi_subdevice *s struct comedi_insn - *insn,unsigned int *data) | +| (struct comedi_device *dev,struct comedi_subdevice *s struct comedi_insn +| *insn,unsigned int *data) | | | +----------------------------------------------------------------------------+ | Task : Configures the digital output memory and the digital - output error interrupt | +| output error interrupt | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | unsigned int *data : Data Pointer contains | | configuration parameters as below | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | data[0] :1:Memory on | | 0:Memory off | - data[1] :1 Enable the voltage error interrupt +| data[1] :1 Enable the voltage error interrupt | :0 Disable the voltage error interrupt | | | +----------------------------------------------------------------------------+ @@ -1040,8 +1040,8 @@ INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | | +----------------------------------------------------------------------------+ */ -int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { devpriv->b_OutputMemoryStatus = data[0]; return insn->n; @@ -1056,8 +1056,8 @@ int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev, | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To Write | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To Write | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -1067,24 +1067,24 @@ int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - static UINT ui_Temp = 0; - UINT ui_Temp1; + static unsigned int ui_Temp = 0; + unsigned int ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if (!devpriv->b_OutputMemoryStatus) { ui_Temp = 0; - } //if(!devpriv->b_OutputMemoryStatus ) + } /* if(!devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outw(data[0], devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -1113,19 +1113,19 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -1140,7 +1140,7 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd outw(data[0], devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -1190,48 +1190,48 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ ui_Temp = data[0]; - return (insn->n);; + return insn->n; } /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_ConfigCounterTimerWatchdog(comedi_device - *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| +| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| | | +----------------------------------------------------------------------------+ | Task : Configures The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status data[0] : 2 APCI1500_1_8_KHZ | 1 APCI1500_3_6_KHZ | | 0 APCI1500_115_KHZ - data[1] : 0 Counter1/Timer1 - 1 Counter2/Timer2 - 2 Counter3/Watchdog - data[2] : 0 Counter - 1 Timer/Watchdog - data[3] : This parameter has | +| data[1] : 0 Counter1/Timer1 +| 1 Counter2/Timer2 +| 2 Counter3/Watchdog +| data[2] : 0 Counter +| 1 Timer/Watchdog +| data[3] : This parameter has | | two meanings. | | - If the counter/timer | | is used as a counter | @@ -1243,15 +1243,15 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | the divider factor | | for the output is | | given. - data[4] : 0 APCI1500_CONTINUOUS - 1 APCI1500_SINGLE - data[5] : 0 Software Trigger - 1 Hardware Trigger - - data[6] :0 Software gate - 1 Hardware gate - data[7] :0 Interrupt Disable - 1 Interrupt Enable +| data[4] : 0 APCI1500_CONTINUOUS +| 1 APCI1500_SINGLE +| data[5] : 0 Software Trigger +| 1 Hardware Trigger +| +| data[6] :0 Software gate +| 1 Hardware gate +| data[7] :0 Interrupt Disable +| 1 Interrupt Enable +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -1261,27 +1261,27 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i_TimerCounterMode, i_MasterConfiguration; devpriv->tsk_Current = current; -//Selection of the input clock +/* Selection of the input clock */ if (data[0] == 0 || data[0] == 1 || data[0] == 2) { outw(data[0], devpriv->i_IobaseAddon + APCI1500_CLK_SELECT); - } // if(data[0]==0||data[0]==1||data[0]==2) + } /* if(data[0]==0||data[0]==1||data[0]==2) */ else { if (data[0] != 3) { printk("\nThe option for input clock selection does not exist\n"); return -EINVAL; - } // if(data[0]!=3) - } //elseif(data[0]==0||data[0]==1||data[0]==2) - //Select the counter/timer + } /* if(data[0]!=3) */ + } /* elseif(data[0]==0||data[0]==1||data[0]==2) */ + /* Select the counter/timer */ switch (data[1]) { case COUNTER1: - //selecting counter or timer + /* selecting counter or timer */ switch (data[2]) { case 0: data[2] = APCI1500_COUNTER; @@ -1292,9 +1292,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice is not a timer nor a counter\n"); return -EINVAL; - } // switch(data[2]) + } /* switch(data[2]) */ - //Selecting single or continuous mode + /* Selecting single or continuous mode */ switch (data[4]) { case 0: data[4] = APCI1500_CONTINUOUS; @@ -1305,7 +1305,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis option for single/continuous mode does not exist\n"); return -EINVAL; - } // switch(data[4]) + } /* switch(data[4]) */ i_TimerCounterMode = data[2] | data[4] | 7; /*************************/ @@ -1428,21 +1428,21 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, outb(0x2, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) + } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ else { printk("\nError in selection of interrupt enable or disable\n"); return -EINVAL; - } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) - } // if ((data[3]>= 0) && (data[3] <= 65535)) + } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ + } /* if ((data[3]>= 0) && (data[3] <= 65535)) */ else { printk("\nError in selection of reload value\n"); return -EINVAL; - } //else if ((data[3]>= 0) && (data[3] <= 65535)) + } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */ i_TimerCounterWatchdogInterrupt = data[7]; i_TimerCounter1Init = 1; break; - case COUNTER2: //selecting counter or timer + case COUNTER2: /* selecting counter or timer */ switch (data[2]) { case 0: data[2] = APCI1500_COUNTER; @@ -1453,9 +1453,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice is not a timer nor a counter\n"); return -EINVAL; - } // switch(data[2]) + } /* switch(data[2]) */ - //Selecting single or continuous mode + /* Selecting single or continuous mode */ switch (data[4]) { case 0: data[4] = APCI1500_CONTINUOUS; @@ -1466,9 +1466,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis option for single/continuous mode does not exist\n"); return -EINVAL; - } // switch(data[4]) + } /* switch(data[4]) */ - //Selecting software or hardware trigger + /* Selecting software or hardware trigger */ switch (data[5]) { case 0: data[5] = APCI1500_SOFTWARE_TRIGGER; @@ -1479,9 +1479,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice for software or hardware trigger does not exist\n"); return -EINVAL; - } // switch(data[5]) + } /* switch(data[5]) */ - //Selecting software or hardware gate + /* Selecting software or hardware gate */ switch (data[6]) { case 0: data[6] = APCI1500_SOFTWARE_GATE; @@ -1492,7 +1492,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice for software or hardware gate does not exist\n"); return -EINVAL; - } // switch(data[6]) + } /* switch(data[6]) */ i_TimerCounterMode = data[2] | data[4] | data[5] | data[6] | 7; @@ -1616,21 +1616,21 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, outb(0x2, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) + } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ else { printk("\nError in selection of interrupt enable or disable\n"); return -EINVAL; - } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) - } // if ((data[3]>= 0) && (data[3] <= 65535)) + } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ + } /* if ((data[3]>= 0) && (data[3] <= 65535)) */ else { printk("\nError in selection of reload value\n"); return -EINVAL; - } //else if ((data[3]>= 0) && (data[3] <= 65535)) + } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */ i_TimerCounterWatchdogInterrupt = data[7]; i_TimerCounter2Init = 1; break; - case COUNTER3: //selecting counter or watchdog + case COUNTER3: /* selecting counter or watchdog */ switch (data[2]) { case 0: data[2] = APCI1500_COUNTER; @@ -1641,9 +1641,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice is not a watchdog nor a counter\n"); return -EINVAL; - } // switch(data[2]) + } /* switch(data[2]) */ - //Selecting single or continuous mode + /* Selecting single or continuous mode */ switch (data[4]) { case 0: data[4] = APCI1500_CONTINUOUS; @@ -1654,9 +1654,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis option for single/continuous mode does not exist\n"); return -EINVAL; - } // switch(data[4]) + } /* switch(data[4]) */ - //Selecting software or hardware gate + /* Selecting software or hardware gate */ switch (data[6]) { case 0: data[6] = APCI1500_SOFTWARE_GATE; @@ -1667,7 +1667,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, default: printk("\nThis choice for software or hardware gate does not exist\n"); return -EINVAL; - } // switch(data[6]) + } /* switch(data[6]) */ /*****************************/ /* Test if used for watchdog */ @@ -1680,10 +1680,10 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, /* - Pulses output */ /*****************************/ i_TimerCounterMode = data[2] | data[4] | 0x54; - } //if (data[2] == APCI1500_WATCHDOG) + } /* if (data[2] == APCI1500_WATCHDOG) */ else { i_TimerCounterMode = data[2] | data[4] | data[6] | 7; - } //elseif (data[2] == APCI1500_WATCHDOG) + } /* elseif (data[2] == APCI1500_WATCHDOG) */ /*************************/ /* Test the reload value */ /*************************/ @@ -1809,25 +1809,25 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //elseif(data[2]==APCI1500_COUNTER) + } /* elseif(data[2]==APCI1500_COUNTER) */ - } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) + } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ else { printk("\nError in selection of interrupt enable or disable\n"); return -EINVAL; - } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) - } // if ((data[3]>= 0) && (data[3] <= 65535)) + } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */ + } /* if ((data[3]>= 0) && (data[3] <= 65535)) */ else { printk("\nError in selection of reload value\n"); return -EINVAL; - } //else if ((data[3]>= 0) && (data[3] <= 65535)) + } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */ i_TimerCounterWatchdogInterrupt = data[7]; i_WatchdogCounter3Init = 1; break; default: printk("\nThe specified counter\timer option does not exist\n"); - } //switch(data[1]) + } /* switch(data[1]) */ i_CounterLogic = data[2]; return insn->n; } @@ -1836,22 +1836,22 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_StartStopTriggerTimerCounterWatchdog | | (struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data); | +| struct comedi_insn *insn,unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Start / Stop or trigger the timer counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | - data[0] : 0 Counter1/Timer1 - 1 Counter2/Timer2 - 2 Counter3/Watchdog - data[1] : 0 start - 1 stop - 2 Trigger - data[2] : 0 Counter - 1 Timer/Watchdog +| data[0] : 0 Counter1/Timer1 +| 1 Counter2/Timer2 +| 2 Counter3/Watchdog +| data[1] : 0 start +| 1 stop +| 2 Trigger +| data[2] : 0 Counter +| 1 Timer/Watchdog +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -1860,8 +1860,8 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i_CommandAndStatusValue; @@ -1871,11 +1871,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, case START: if (i_TimerCounter1Init == 1) { if (i_TimerCounterWatchdogInterrupt == 1) { - i_CommandAndStatusValue = 0xC4; //Enable the interrupt - } // if(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */ + } /* if(i_TimerCounterWatchdogInterrupt==1) */ else { - i_CommandAndStatusValue = 0xE4; //disable the interrupt - } //elseif(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xE4; /* disable the interrupt */ + } /* elseif(i_TimerCounterWatchdogInterrupt==1) */ /**************************/ /* Starts timer/counter 1 */ /**************************/ @@ -1889,7 +1889,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(i_CommandAndStatusValue, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter1Init==1) + } /* if( i_TimerCounter1Init==1) */ else { printk("\nCounter/Timer1 not configured\n"); return -EINVAL; @@ -1922,14 +1922,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0x6; - } //if( i_TimerCounter1Enabled==1) + } /* if( i_TimerCounter1Enabled==1) */ else { /***************/ /* Set Trigger */ /***************/ i_CommandAndStatusValue = 0x2; - } //elseif(i_TimerCounter1Enabled==1) + } /* elseif(i_TimerCounter1Enabled==1) */ /********************************************/ /* Selects the commands and status register */ @@ -1940,7 +1940,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(i_CommandAndStatusValue, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter1Init==1) + } /* if( i_TimerCounter1Init==1) */ else { printk("\nCounter/Timer1 not configured\n"); return -EINVAL; @@ -1950,7 +1950,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, default: printk("\nThe specified option for start/stop/trigger does not exist\n"); return -EINVAL; - } //switch(data[1]) + } /* switch(data[1]) */ break; case COUNTER2: @@ -1958,11 +1958,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, case START: if (i_TimerCounter2Init == 1) { if (i_TimerCounterWatchdogInterrupt == 1) { - i_CommandAndStatusValue = 0xC4; //Enable the interrupt - } // if(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */ + } /* if(i_TimerCounterWatchdogInterrupt==1) */ else { - i_CommandAndStatusValue = 0xE4; //disable the interrupt - } //elseif(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xE4; /* disable the interrupt */ + } /* elseif(i_TimerCounterWatchdogInterrupt==1) */ /**************************/ /* Starts timer/counter 2 */ /**************************/ @@ -1976,7 +1976,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(i_CommandAndStatusValue, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter2Init==1) + } /* if( i_TimerCounter2Init==1) */ else { printk("\nCounter/Timer2 not configured\n"); return -EINVAL; @@ -2008,14 +2008,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0x6; - } //if( i_TimerCounter2Enabled==1) + } /* if( i_TimerCounter2Enabled==1) */ else { /***************/ /* Set Trigger */ /***************/ i_CommandAndStatusValue = 0x2; - } //elseif(i_TimerCounter2Enabled==1) + } /* elseif(i_TimerCounter2Enabled==1) */ /********************************************/ /* Selects the commands and status register */ @@ -2026,7 +2026,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(i_CommandAndStatusValue, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter2Init==1) + } /* if( i_TimerCounter2Init==1) */ else { printk("\nCounter/Timer2 not configured\n"); return -EINVAL; @@ -2035,7 +2035,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, default: printk("\nThe specified option for start/stop/trigger does not exist\n"); return -EINVAL; - } //switch(data[1]) + } /* switch(data[1]) */ break; case COUNTER3: switch (data[1]) { @@ -2043,11 +2043,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, if (i_WatchdogCounter3Init == 1) { if (i_TimerCounterWatchdogInterrupt == 1) { - i_CommandAndStatusValue = 0xC4; //Enable the interrupt - } // if(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */ + } /* if(i_TimerCounterWatchdogInterrupt==1) */ else { - i_CommandAndStatusValue = 0xE4; //disable the interrupt - } //elseif(i_TimerCounterWatchdogInterrupt==1) + i_CommandAndStatusValue = 0xE4; /* disable the interrupt */ + } /* elseif(i_TimerCounterWatchdogInterrupt==1) */ /**************************/ /* Starts Watchdog/counter 3 */ /**************************/ @@ -2062,7 +2062,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } // if( i_WatchdogCounter3init==1) + } /* if( i_WatchdogCounter3init==1) */ else { printk("\nWatchdog/Counter3 not configured\n"); return -EINVAL; @@ -2089,7 +2089,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, case TRIGGER: switch (data[2]) { - case 0: //triggering counter 3 + case 0: /* triggering counter 3 */ if (i_WatchdogCounter3Init == 1) { if (i_WatchdogCounter3Enabled == 1) { /************************/ @@ -2097,14 +2097,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0x6; - } //if( i_WatchdogCounter3Enabled==1) + } /* if( i_WatchdogCounter3Enabled==1) */ else { /***************/ /* Set Trigger */ /***************/ i_CommandAndStatusValue = 0x2; - } //elseif(i_WatchdogCounter3Enabled==1) + } /* elseif(i_WatchdogCounter3Enabled==1) */ /********************************************/ /* Selects the commands and status register */ @@ -2115,14 +2115,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(i_CommandAndStatusValue, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_WatchdogCounter3Init==1) + } /* if( i_WatchdogCounter3Init==1) */ else { printk("\nCounter3 not configured\n"); return -EINVAL; } break; case 1: - //triggering Watchdog 3 + /* triggering Watchdog 3 */ if (i_WatchdogCounter3Init == 1) { /********************************************/ @@ -2134,7 +2134,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, outb(0x6, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_WatchdogCounter3Init==1) + } /* if( i_WatchdogCounter3Init==1) */ else { printk("\nWatchdog 3 not configured\n"); return -EINVAL; @@ -2143,17 +2143,17 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, default: printk("\nWrong choice of watchdog/counter3\n"); return -EINVAL; - } //switch(data[2]) + } /* switch(data[2]) */ break; default: printk("\nThe specified option for start/stop/trigger does not exist\n"); return -EINVAL; - } //switch(data[1]) + } /* switch(data[1]) */ break; default: printk("\nThe specified choice for counter/watchdog/timer does not exist\n"); return -EINVAL; - } //switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -2161,18 +2161,18 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_ReadCounterTimerWatchdog | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | +| unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Read The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | - data[0] : 0 Counter1/Timer1 - 1 Counter2/Timer2 - 2 Counter3/Watchdog - +| data[0] : 0 Counter1/Timer1 +| 1 Counter2/Timer2 +| 2 Counter3/Watchdog +| +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -2182,13 +2182,13 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i_CommandAndStatusValue; switch (data[0]) { case COUNTER1: - //Read counter/timer1 + /* Read counter/timer1 */ if (i_TimerCounter1Init == 1) { if (i_TimerCounter1Enabled == 1) { /************************/ @@ -2196,14 +2196,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0xC; - } //if( i_TimerCounter1Init==1) + } /* if( i_TimerCounter1Init==1) */ else { /***************/ /* Set RCC */ /***************/ i_CommandAndStatusValue = 0x8; - } //elseif(i_TimerCounter1Init==1) + } /* elseif(i_TimerCounter1Init==1) */ /********************************************/ /* Selects the commands and status register */ @@ -2232,14 +2232,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, data[0] = data[0] | inb(devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter1Init==1) + } /* if( i_TimerCounter1Init==1) */ else { printk("\nTimer/Counter1 not configured\n"); return -EINVAL; - } //elseif( i_TimerCounter1Init==1) + } /* elseif( i_TimerCounter1Init==1) */ break; case COUNTER2: - //Read counter/timer2 + /* Read counter/timer2 */ if (i_TimerCounter2Init == 1) { if (i_TimerCounter2Enabled == 1) { /************************/ @@ -2247,14 +2247,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0xC; - } //if( i_TimerCounter2Init==1) + } /* if( i_TimerCounter2Init==1) */ else { /***************/ /* Set RCC */ /***************/ i_CommandAndStatusValue = 0x8; - } //elseif(i_TimerCounter2Init==1) + } /* elseif(i_TimerCounter2Init==1) */ /********************************************/ /* Selects the commands and status register */ @@ -2283,14 +2283,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, data[0] = data[0] | inb(devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_TimerCounter2Init==1) + } /* if( i_TimerCounter2Init==1) */ else { printk("\nTimer/Counter2 not configured\n"); return -EINVAL; - } //elseif( i_TimerCounter2Init==1) + } /* elseif( i_TimerCounter2Init==1) */ break; case COUNTER3: - //Read counter/watchdog2 + /* Read counter/watchdog2 */ if (i_WatchdogCounter3Init == 1) { if (i_WatchdogCounter3Enabled == 1) { /************************/ @@ -2298,14 +2298,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, /************************/ i_CommandAndStatusValue = 0xC; - } //if( i_TimerCounter2Init==1) + } /* if( i_TimerCounter2Init==1) */ else { /***************/ /* Set RCC */ /***************/ i_CommandAndStatusValue = 0x8; - } //elseif(i_WatchdogCounter3Init==1) + } /* elseif(i_WatchdogCounter3Init==1) */ /********************************************/ /* Selects the commands and status register */ @@ -2334,16 +2334,16 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, data[0] = data[0] | inb(devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } //if( i_WatchdogCounter3Init==1) + } /* if( i_WatchdogCounter3Init==1) */ else { printk("\nWatchdogCounter3 not configured\n"); return -EINVAL; - } //elseif( i_WatchdogCounter3Init==1) + } /* elseif( i_WatchdogCounter3Init==1) */ break; default: printk("\nThe choice of timer/counter/watchdog does not exist\n"); return -EINVAL; - } //switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -2352,13 +2352,13 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_ReadInterruptMask | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | +| unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Read the interrupt mask | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | @@ -2370,8 +2370,8 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ReadInterruptMask(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = i_InterruptMask; data[1] = i_InputChannel; @@ -2383,15 +2383,15 @@ int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ | Function Name : int i_APCI1500_ConfigureInterrupt | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | +| unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Configures the interrupt registers | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer | - +| +----------------------------------------------------------------------------+ | Output Parameters : -- @@ -2401,26 +2401,26 @@ int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -int i_APCI1500_ConfigureInterrupt(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1500_ConfigureInterrupt(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Status; + unsigned int ui_Status; int i_RegValue; int i_Constant; devpriv->tsk_Current = current; outl(0x0, devpriv->i_IobaseAmcc + 0x38); if (data[0] == 1) { i_Constant = 0xC0; - } //if(data[0]==1) + } /* if(data[0]==1) */ else { if (data[0] == 0) { i_Constant = 0x00; - } //if{data[0]==0) + } /* if{data[0]==0) */ else { printk("\nThe parameter passed to driver is in error for enabling the voltage interrupt\n"); return -EINVAL; - } //else if(data[0]==0) - } //elseif(data[0]==1) + } /* else if(data[0]==0) */ + } /* elseif(data[0]==1) */ /*****************************************************/ /* Selects the mode specification register of port B */ @@ -2580,7 +2580,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - UINT ui_InterruptStatus = 0; + unsigned int ui_InterruptStatus = 0; int i_RegValue = 0; i_InterruptMask = 0; @@ -2599,11 +2599,11 @@ static void v_APCI1500_Interrupt(int irq, void *d) /*************************************************/ /* Selects the master interrupt control register */ /*************************************************/ - //outb(APCI1500_RW_MASTER_INTERRUPT_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); + /* outb(APCI1500_RW_MASTER_INTERRUPT_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); */ /**********************************************/ /* Disables the main interrupt on the board */ /**********************************************/ - //outb(0x00,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); + /* outb(0x00,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); */ /*****************************************************/ /* Selects the command and status register of port A */ @@ -2647,11 +2647,11 @@ static void v_APCI1500_Interrupt(int irq, void *d) i_InputChannel = 1 + (i_RegValue >> 1); - } // if(i_Logic==APCI1500_OR_PRIORITY) + } /* if(i_Logic==APCI1500_OR_PRIORITY) */ else { i_InputChannel = 0; - } //elseif(i_Logic==APCI1500_OR_PRIORITY) - } // if ((i_RegValue & 0x60) == 0x60) + } /* elseif(i_Logic==APCI1500_OR_PRIORITY) */ + } /* if ((i_RegValue & 0x60) == 0x60) */ /*****************************************************/ /* Selects the command and status register of port B */ @@ -2679,7 +2679,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) /* Reads port B */ /****************/ i_RegValue = - inb((UINT) devpriv->iobase + + inb((unsigned int) devpriv->iobase + APCI1500_Z8536_PORT_B); i_RegValue = i_RegValue & 0xC0; @@ -2688,7 +2688,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) /**************************************/ if (i_RegValue) { - //Disable the interrupt + /* Disable the interrupt */ /*****************************************************/ /* Selects the command and status register of port B */ /*****************************************************/ @@ -2697,17 +2697,17 @@ static void v_APCI1500_Interrupt(int irq, void *d) if (i_RegValue & 0x80) { i_InterruptMask = i_InterruptMask | 0x40; - } //if (i_RegValue & 0x80) + } /* if (i_RegValue & 0x80) */ if (i_RegValue & 0x40) { i_InterruptMask = i_InterruptMask | 0x80; - } //if (i_RegValue & 0x40) - } // if (i_RegValue) + } /* if (i_RegValue & 0x40) */ + } /* if (i_RegValue) */ else { i_InterruptMask = i_InterruptMask | 2; - } // if (i_RegValue) - } //if ((i_RegValue & 0x60) == 0x60) + } /* if (i_RegValue) */ + } /* if ((i_RegValue & 0x60) == 0x60) */ /*****************************************************/ /* Selects the command and status register of timer 1 */ @@ -2731,7 +2731,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); i_InterruptMask = i_InterruptMask | 4; - } // if ((i_RegValue & 0x60) == 0x60) + } /* if ((i_RegValue & 0x60) == 0x60) */ /*****************************************************/ /* Selects the command and status register of timer 2 */ /*****************************************************/ @@ -2754,7 +2754,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); i_InterruptMask = i_InterruptMask | 8; - } // if ((i_RegValue & 0x60) == 0x60) + } /* if ((i_RegValue & 0x60) == 0x60) */ /*****************************************************/ /* Selects the command and status register of timer 3 */ @@ -2779,13 +2779,13 @@ static void v_APCI1500_Interrupt(int irq, void *d) APCI1500_Z8536_CONTROL_REGISTER); if (i_CounterLogic == APCI1500_COUNTER) { i_InterruptMask = i_InterruptMask | 0x10; - } //if(i_CounterLogic==APCI1500_COUNTER) + } /* if(i_CounterLogic==APCI1500_COUNTER) */ else { i_InterruptMask = i_InterruptMask | 0x20; } - } // if ((i_RegValue & 0x60) == 0x60) + } /* if ((i_RegValue & 0x60) == 0x60) */ - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ /***********************/ /* Enable all Interrupts */ /***********************/ @@ -2799,11 +2799,11 @@ static void v_APCI1500_Interrupt(int irq, void *d) /* Authorizes the main interrupt on the board */ /**********************************************/ outb(0xD0, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - } // if ((ui_InterruptStatus & 0x800000) == 0x800000) + } /* if ((ui_InterruptStatus & 0x800000) == 0x800000) */ else { printk("\nInterrupt from unknown source\n"); - } //else if ((ui_InterruptStatus & 0x800000) == 0x800000) + } /* else if ((ui_InterruptStatus & 0x800000) == 0x800000) */ return; } @@ -2822,7 +2822,7 @@ static void v_APCI1500_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -INT i_APCI1500_Reset(struct comedi_device * dev) +int i_APCI1500_Reset(struct comedi_device *dev) { int i_DummyRead = 0; i_TimerCounter1Init = 0; @@ -2982,7 +2982,7 @@ INT i_APCI1500_Reset(struct comedi_device * dev) devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); /* Deletes all interrupts */ outb(0, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER); - //reset all the digital outputs + /* reset all the digital outputs */ outw(0x0, devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP); /*******************************/ /* Disable the board interrupt */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h index 5d960b40a6a8..057903366a80 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h @@ -17,11 +17,11 @@ /********* Definitions for APCI-1500 card *****/ -// Card Specific information +/* Card Specific information */ #define APCI1500_BOARD_VENDOR_ID 0x10e8 #define APCI1500_ADDRESS_RANGE 4 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI1500_DIGITAL_OP 2 #define APCI1500_DIGITAL_IP 0 diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c index 5ae9a93844e7..38416356628d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -63,7 +63,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -73,22 +73,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | | +----------------------------------------------------------------------------+ */ -INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue = 0; - UINT ui_Channel; + unsigned int ui_TmpValue = 0; + unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); if (ui_Channel >= 0 && ui_Channel <= 7) { - ui_TmpValue = (UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP); - // since only 1 channel reqd to bring it to last bit it is rotated - // 8 +(chan - 1) times then ANDed with 1 for last bit. + ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP); + /* since only 1 channel reqd to bring it to last bit it is rotated */ + /* 8 +(chan - 1) times then ANDed with 1 for last bit. */ *data = (ui_TmpValue >> ui_Channel) & 0x1; - } //if(ui_Channel >= 0 && ui_Channel <=7) + } /* if(ui_Channel >= 0 && ui_Channel <=7) */ else { - //comedi_error(dev," \n chan spec wrong\n"); - return -EINVAL; // "sorry channel spec wrong " - } //else if(ui_Channel >= 0 && ui_Channel <=7) + /* comedi_error(dev," \n chan spec wrong\n"); */ + return -EINVAL; /* "sorry channel spec wrong " */ + } /* else if(ui_Channel >= 0 && ui_Channel <=7) */ return insn->n; } @@ -103,7 +103,7 @@ INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -114,17 +114,17 @@ INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_PortValue = data[0]; - UINT ui_Mask = 0; - UINT ui_NoOfChannels; + unsigned int ui_PortValue = data[0]; + unsigned int ui_Mask = 0; + unsigned int ui_NoOfChannels; ui_NoOfChannels = CR_CHAN(insn->chanspec); - *data = (UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP); + *data = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP); switch (ui_NoOfChannels) { case 2: ui_Mask = 3; @@ -139,9 +139,9 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su default: printk("\nWrong parameters\n"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ return insn->n; } @@ -149,7 +149,7 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI1516_ConfigDigitalOutput (struct comedi_device *dev, - struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) | +| struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) | | | +----------------------------------------------------------------------------+ | Task : Configures The Digital Output Subdevice. | @@ -158,7 +158,7 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | unsigned int *data : Data Pointer contains | | configuration parameters as below | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | data[0] :1:Memory on | | 0:Memory off | | | @@ -171,8 +171,8 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | | +----------------------------------------------------------------------------+ */ -int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { devpriv->b_OutputMemoryStatus = data[0]; return insn->n; @@ -182,13 +182,13 @@ int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ | Function Name : int i_APCI1516_WriteDigitalOutput | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data) | +| unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -199,21 +199,21 @@ int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp, ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ printk("EL311003 : @=%x\n", devpriv->iobase + APCI1516_DIGITAL_OP); if (devpriv->b_OutputMemoryStatus) { ui_Temp = inw(devpriv->iobase + APCI1516_DIGITAL_OP); - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; @@ -222,7 +222,7 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd printk("EL311003 : d=%d @=%x\n", data[0], devpriv->iobase + APCI1516_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -245,21 +245,21 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + APCI1516_DIGITAL_OP); printk("EL311003 : d=%d @=%x\n", data[0], devpriv->iobase + APCI1516_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -275,7 +275,7 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd printk("EL311003 : d=%d @=%x\n", data[0], devpriv->iobase + APCI1516_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -312,9 +312,9 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + @@ -324,17 +324,17 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0], devpriv->iobase + APCI1516_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ return (insn->n);; } @@ -342,13 +342,13 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ | Function Name : int i_APCI1516_ReadDigitalOutput | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data) | +| unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -359,17 +359,17 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ ui_Temp = data[0]; *data = inw(devpriv->iobase + APCI1516_DIGITAL_OP_RW); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } //if(ui_Temp==0) + } /* if(ui_Temp==0) */ else { if (ui_Temp == 1) { switch (ui_NoOfChannel) { @@ -387,28 +387,28 @@ INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) - } //if(ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if(ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } //elseif(ui_Temp==1) - } //elseif(ui_Temp==0) + } /* elseif(ui_Temp==1) */ + } /* elseif(ui_Temp==0) */ return insn->n; } /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | +| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | | | +----------------------------------------------------------------------------+ | Task : Configures The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -419,15 +419,15 @@ INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0] == 0) { - //Disable the watchdog + /* Disable the watchdog */ outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); - //Loading the Reload value + /* Loading the Reload value */ outw(data[1], devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE); @@ -435,11 +435,11 @@ int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic outw(data[1], devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE + 2); - } //if(data[0]==0) + } /* if(data[0]==0) */ else { printk("\nThe input parameters are wrong\n"); return -EINVAL; - } //elseif(data[0]==0) + } /* elseif(data[0]==0) */ return insn->n; } @@ -465,19 +465,19 @@ int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { - case 0: //stop the watchdog - outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); //disable the watchdog + case 0: /* stop the watchdog */ + outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ break; - case 1: //start the watchdog + case 1: /* start the watchdog */ outw(0x0001, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); break; - case 2: //Software trigger + case 2: /* Software trigger */ outw(0x0201, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); @@ -485,7 +485,7 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ default: printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } // switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -510,8 +510,8 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI1516_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = inw(devpriv->i_IobaseAddon + APCI1516_WATCHDOG_STATUS) & 0x1; return insn->n; @@ -532,9 +532,9 @@ int i_APCI1516_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI1516_Reset(struct comedi_device * dev) +int i_APCI1516_Reset(struct comedi_device *dev) { - outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); //RESETS THE DIGITAL OUTPUTS + outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */ outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE); outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE + 2); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h index 398baa04a163..21c09ed01b1d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h @@ -17,17 +17,17 @@ /********* Definitions for APCI-1516 card *****/ -// Card Specific information +/* Card Specific information */ #define APCI1516_BOARD_VENDOR_ID 0x15B8 #define APCI1516_ADDRESS_RANGE 8 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI1516_DIGITAL_OP 4 #define APCI1516_DIGITAL_OP_RW 4 #define APCI1516_DIGITAL_IP 0 -// TIMER COUNTER WATCHDOG DEFINES +/* TIMER COUNTER WATCHDOG DEFINES */ #define ADDIDATA_WATCHDOG 2 #define APCI1516_DIGITAL_OP_WATCHDOG 0 @@ -35,24 +35,25 @@ #define APCI1516_WATCHDOG_RELOAD_VALUE 4 #define APCI1516_WATCHDOG_STATUS 16 -// Hardware Layer functions for Apci1516 +/* Hardware Layer functions for Apci1516 */ -//Digital Input -INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +/* Digital Input */ +int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//Digital Output +/* Digital Output */ int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER -// timer value is passed as u seconds +/* +* TIMER timer value is passed as u seconds +*/ int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, @@ -60,5 +61,5 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//reset -INT i_APCI1516_Reset(struct comedi_device *dev); +/* reset */ +int i_APCI1516_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index a6b504c3d391..3a47c3034229 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -55,9 +55,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc #include <linux/delay.h> #include "hwdrv_apci1564.h" -//Global variables -UINT ui_InterruptStatus_1564 = 0; -UINT ui_InterruptData, ui_Type; +/* Global variables */ +unsigned int ui_InterruptStatus_1564 = 0; +unsigned int ui_InterruptData, ui_Type; /* +----------------------------------------------------------------------------+ @@ -86,8 +86,8 @@ UINT ui_InterruptData, ui_Type; | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { devpriv->tsk_Current = current; /*******************************/ @@ -106,13 +106,13 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd outl(0x4, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } // if (data[1] == ADDIDATA_OR) + } /* if (data[1] == ADDIDATA_OR) */ else { outl(0x6, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } // else if (data[1] == ADDIDATA_OR) - } // if (data[0] == ADDIDATA_ENABLE) + } /* else if (data[1] == ADDIDATA_OR) */ + } /* if (data[0] == ADDIDATA_ENABLE) */ else { outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + @@ -123,7 +123,7 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } // else if (data[0] == ADDIDATA_ENABLE) + } /* else if (data[0] == ADDIDATA_ENABLE) */ return insn->n; } @@ -137,7 +137,7 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd | Task : Return the status of the digital input | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_Channel : Channel number to read | +| unsigned int ui_Channel : Channel number to read | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -147,24 +147,26 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue = 0; - UINT ui_Channel; + unsigned int ui_TmpValue = 0; + unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); if (ui_Channel >= 0 && ui_Channel <= 31) { ui_TmpValue = - (UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP); - // since only 1 channel reqd to bring it to last bit it is rotated - // 8 +(chan - 1) times then ANDed with 1 for last bit. + (unsigned int) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP); +/* +* since only 1 channel reqd to bring it to last bit it is rotated 8 +* +(chan - 1) times then ANDed with 1 for last bit. +*/ *data = (ui_TmpValue >> ui_Channel) & 0x1; - } // if (ui_Channel >= 0 && ui_Channel <=31) + } /* if (ui_Channel >= 0 && ui_Channel <=31) */ else { comedi_error(dev, "Not a valid channel number !!! \n"); - return -EINVAL; // "sorry channel spec wrong " - } //else if (ui_Channel >= 0 && ui_Channel <=31) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* else if (ui_Channel >= 0 && ui_Channel <=31) */ return insn->n; } @@ -177,8 +179,8 @@ INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde | Task : Return the status of the Requested digital inputs | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To be Read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To be Read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -187,16 +189,16 @@ INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_PortValue = data[0]; - UINT ui_Mask = 0; - UINT ui_NoOfChannels; + unsigned int ui_PortValue = data[0]; + unsigned int ui_Mask = 0; + unsigned int ui_NoOfChannels; ui_NoOfChannels = CR_CHAN(insn->chanspec); if (data[1] == 0) { - *data = (UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP); + *data = (unsigned int) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP); switch (ui_NoOfChannels) { case 2: ui_Mask = 3; @@ -218,15 +220,15 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su break; default: comedi_error(dev, "Not a valid Channel number !!!\n"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } // switch (ui_NoOfChannels) - } // if (data[1]==0) + } /* switch (ui_NoOfChannels) */ + } /* if (data[1]==0) */ else { if (data[1] == 1) { *data = ui_InterruptStatus_1564; - } // if (data[1]==1) - } // else if (data[1]==0) + } /* if (data[1]==1) */ + } /* else if (data[1]==0) */ return insn->n; } @@ -239,7 +241,7 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | Task : Configures The Digital Output Subdevice. | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[1] : 1 Enable VCC Interrupt | @@ -255,34 +257,34 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command = 0; + unsigned int ul_Command = 0; if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } // if ((data[0]!=0) && (data[0]!=1)) + } /* if ((data[0]!=0) && (data[0]!=1)) */ if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } // if (data[0]) + } /* if (data[0]) */ else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } // else if (data[0]) + } /* else if (data[0]) */ if (data[1] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x1; - } // if (data[1] == ADDIDATA_ENABLE) + } /* if (data[1] == ADDIDATA_ENABLE) */ else { ul_Command = ul_Command & 0xFFFFFFFE; - } // else if (data[1] == ADDIDATA_ENABLE) + } /* else if (data[1] == ADDIDATA_ENABLE) */ if (data[2] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x2; - } // if (data[2] == ADDIDATA_ENABLE) + } /* if (data[2] == ADDIDATA_ENABLE) */ else { ul_Command = ul_Command & 0xFFFFFFFD; - } // else if (data[2] == ADDIDATA_ENABLE) + } /* else if (data[2] == ADDIDATA_ENABLE) */ outl(ul_Command, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT); @@ -302,8 +304,8 @@ INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To Write | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To Write | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -312,28 +314,28 @@ INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp, ui_Temp1; - UINT ui_NoOfChannel; + unsigned int ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); if (devpriv->b_OutputMemoryStatus) { ui_Temp = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW); - } // if (devpriv->b_OutputMemoryStatus ) + } /* if (devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } // else if (devpriv->b_OutputMemoryStatus ) + } /* else if (devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outl(data[0], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW); - } // if (data[1]==0) + } /* if (data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -362,18 +364,18 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd break; default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } // switch (ui_NoOfChannels) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch (ui_NoOfChannels) */ outl(data[0], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW); - } // if (data[1]==1) + } /* if (data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } // else if (data[1]==1) - } // else if (data[1]==0) - } //if(data[3]==0) + } /* else if (data[1]==1) */ + } /* else if (data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -389,7 +391,7 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW); - } // if (data[1]==0) + } /* if (data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -447,23 +449,23 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } //switch(ui_NoOfChannels) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch(ui_NoOfChannels) */ outl(data[0], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW); - } // if (data[1]==1) + } /* if (data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } // else if (data[1]==1) - } // else if (data[1]==0) - } // if (data[3]==1); + } /* else if (data[1]==1) */ + } /* else if (data[1]==0) */ + } /* if (data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } // else if (data[3]==1) - } // else if (data[3]==0) + } /* else if (data[3]==1) */ + } /* else if (data[3]==0) */ return insn->n; } @@ -476,8 +478,8 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -486,11 +488,11 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; @@ -498,7 +500,7 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde APCI1564_DIGITAL_OP_RW); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } // if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { switch (ui_NoOfChannel) { @@ -523,14 +525,14 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } // switch(ui_NoOfChannels) - } // if (ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } // else if (ui_Temp==1) - } // else if (ui_Temp==0) + } /* else if (ui_Temp==1) */ + } /* else if (ui_Temp==0) */ return insn->n; } @@ -543,7 +545,7 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde | Task : Configures The Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Configure As Timer | @@ -564,34 +566,34 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0; + unsigned int ul_Command1 = 0; devpriv->tsk_Current = current; if (data[0] == ADDIDATA_WATCHDOG) { devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG; - //Disable the watchdog + /* Disable the watchdog */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); - //Loading the Reload value + /* Loading the Reload value */ outl(data[3], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_RELOAD_VALUE); - } // if (data[0]==ADDIDATA_WATCHDOG) + } /* if (data[0]==ADDIDATA_WATCHDOG) */ else if (data[0] == ADDIDATA_TIMER) { - //First Stop The Timer + /* First Stop The Timer */ ul_Command1 = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //Stop The Timer + outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* Stop The Timer */ devpriv->b_TimerSelectMode = ADDIDATA_TIMER; if (data[1] == 1) { - outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES + outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); @@ -614,18 +616,18 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, outl(0x0, devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_IRQ); - } // if (data[1]==1) + } /* if (data[1]==1) */ else { - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //disable Timer interrupt - } // else if (data[1]==1) + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* disable Timer interrupt */ + } /* else if (data[1]==1) */ - // Loading Timebase + /* Loading Timebase */ outl(data[2], devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_TIMEBASE); - //Loading the Reload value + /* Loading the Reload value */ outl(data[3], devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_RELOAD_VALUE); @@ -635,18 +637,18 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, APCI1564_TCW_PROG); ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; - outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //mode 2 - } // else if (data[0]==ADDIDATA_TIMER) + outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* mode 2 */ + } /* else if (data[0]==ADDIDATA_TIMER) */ else if (data[0] == ADDIDATA_COUNTER) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; devpriv->b_ModeSelectRegister = data[5]; - //First Stop The Counter + /* First Stop The Counter */ ul_Command1 = inl(devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); //Stop The Timer + outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); /* Stop The Timer */ /************************/ /* Set the reload value */ @@ -666,12 +668,12 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, /******************************/ ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | - (ULONG) ((ULONG) data[4] << 16UL); + (unsigned int) ((unsigned int) data[4] << 16UL); outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); - // Enable or Disable Interrupt + /* Enable or Disable Interrupt */ ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + @@ -684,10 +686,10 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); - } // else if (data[0]==ADDIDATA_COUNTER) + } /* else if (data[0]==ADDIDATA_COUNTER) */ else { printk(" Invalid subdevice."); - } // else if (data[0]==ADDIDATA_WATCHDOG) + } /* else if (data[0]==ADDIDATA_WATCHDOG) */ return insn->n; } @@ -701,7 +703,7 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, | Task : Start / Stop The Selected Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Timer | @@ -718,22 +720,22 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0; + unsigned int ul_Command1 = 0; if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { switch (data[1]) { - case 0: //stop the watchdog - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); //disable the watchdog + case 0: /* stop the watchdog */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); /* disable the watchdog */ break; - case 1: //start the watchdog + case 1: /* start the watchdog */ outl(0x0001, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); break; - case 2: //Software trigger + case 2: /* Software trigger */ outl(0x0201, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + @@ -742,8 +744,8 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, default: printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } // switch (data[1]) - } // if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) + } /* switch (data[1]) */ + } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { if (data[1] == 1) { ul_Command1 = @@ -751,13 +753,13 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, APCI1564_TCW_PROG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - //Enable the Timer + /* Enable the Timer */ outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); - } // if (data[1]==1) + } /* if (data[1]==1) */ else if (data[1] == 0) { - //Stop The Timer + /* Stop The Timer */ ul_Command1 = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + @@ -766,29 +768,29 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); - } // else if(data[1]==0) - } // if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) + } /* else if(data[1]==0) */ + } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { ul_Command1 = inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister - 1) * 0x20) + APCI1564_TCW_PROG); if (data[1] == 1) { - //Start the Counter subdevice + /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - } // if (data[1] == 1) + } /* if (data[1] == 1) */ else if (data[1] == 0) { - // Stops the Counter subdevice + /* Stops the Counter subdevice */ ul_Command1 = 0; - } // else if (data[1] == 0) + } /* else if (data[1] == 0) */ else if (data[1] == 2) { - // Clears the Counter subdevice + /* Clears the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; - } // else if (data[1] == 3) + } /* else if (data[1] == 3) */ outl(ul_Command1, devpriv->iobase + ((devpriv->b_ModeSelectRegister - 1) * 0x20) + APCI1564_TCW_PROG); - } // if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) + } /* if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) */ return insn->n; } @@ -801,7 +803,7 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, | Task : Read The Selected Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | @@ -813,13 +815,13 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0; + unsigned int ul_Command1 = 0; if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { - // Stores the status of the Watchdog + /* Stores the status of the Watchdog */ data[0] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + @@ -827,18 +829,18 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev, data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG); - } // if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) + } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { - // Stores the status of the Timer + /* Stores the status of the Timer */ data[0] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_TRIG_STATUS) & 0x1; - // Stores the Actual value of the Timer + /* Stores the Actual value of the Timer */ data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER); - } // else if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) + } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { - // Read the Counter Actual Value. + /* Read the Counter Actual Value. */ data[0] = inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister - 1) * 0x20) + @@ -850,28 +852,28 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev, /***********************************/ /* Get the software trigger status */ /***********************************/ - data[1] = (BYTE) ((ul_Command1 >> 1) & 1); + data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); /***********************************/ /* Get the hardware trigger status */ /***********************************/ - data[2] = (BYTE) ((ul_Command1 >> 2) & 1); + data[2] = (unsigned char) ((ul_Command1 >> 2) & 1); /*********************************/ /* Get the software clear status */ /*********************************/ - data[3] = (BYTE) ((ul_Command1 >> 3) & 1); + data[3] = (unsigned char) ((ul_Command1 >> 3) & 1); /***************************/ /* Get the overflow status */ /***************************/ - data[4] = (BYTE) ((ul_Command1 >> 0) & 1); - } // else if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) + data[4] = (unsigned char) ((ul_Command1 >> 0) & 1); + } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) */ else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG) && (devpriv->b_TimerSelectMode != ADDIDATA_COUNTER)) { printk("\n Invalid Subdevice !!!\n"); - } // else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER)) + } /* else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER)) */ return insn->n; } @@ -892,8 +894,8 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI1564_ReadInterruptStatus(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI1564_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { *data = ui_Type; return insn->n; @@ -919,10 +921,10 @@ int i_APCI1564_ReadInterruptStatus(struct comedi_device * dev, struct comedi_sub static void v_APCI1564_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - UINT ui_DO, ui_DI; - UINT ui_Timer; - UINT ui_C1, ui_C2, ui_C3, ui_C4; - ULONG ul_Command2 = 0; + unsigned int ui_DO, ui_DI; + unsigned int ui_Timer; + unsigned int ui_C1, ui_C2, ui_C3, ui_C4; + unsigned int ul_Command2 = 0; ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ) & 0x01; ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + @@ -941,7 +943,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0 && ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) { printk("\nInterrupt from unknown source\n"); - } // if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0) + } /* if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0) */ if (ui_DI == 1) { ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + @@ -953,116 +955,137 @@ static void v_APCI1564_Interrupt(int irq, void *d) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_STATUS); ui_InterruptStatus_1564 = ui_InterruptStatus_1564 & 0X000FFFF0; - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample - outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); //enable the interrupt + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); /* enable the interrupt */ return; } if (ui_DO == 1) { - // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. + /* Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. */ ui_Type = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT_STATUS) & 0x3; - //Disable the Interrupt + /* Disable the Interrupt */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT); - //Sends signal to user space + /* Sends signal to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if (ui_DO) + } /* if (ui_DO) */ - if ((ui_Timer == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_TIMER)) { - // Disable Timer Interrupt - ul_Command2 = - inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + - APCI1564_TCW_PROG); - outl(0x0, - devpriv->i_IobaseAmcc + APCI1564_TIMER + - APCI1564_TCW_PROG); + if (ui_Timer == 1) { + devpriv->b_TimerSelectMode = ADDIDATA_TIMER; + if (devpriv->b_TimerSelectMode) { - //Send a signal to from kernel to user space - send_sig(SIGIO, devpriv->tsk_Current, 0); + /* Disable Timer Interrupt */ + ul_Command2 = + inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + + APCI1564_TCW_PROG); + outl(0x0, + devpriv->i_IobaseAmcc + APCI1564_TIMER + + APCI1564_TCW_PROG); - // Enable Timer Interrupt + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); - outl(ul_Command2, - devpriv->i_IobaseAmcc + APCI1564_TIMER + - APCI1564_TCW_PROG); - } // if ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER)) + /* Enable Timer Interrupt */ - if ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) { - // Disable Counter Interrupt - ul_Command2 = - inl(devpriv->iobase + APCI1564_COUNTER1 + - APCI1564_TCW_PROG); - outl(0x0, - devpriv->iobase + APCI1564_COUNTER1 + - APCI1564_TCW_PROG); + outl(ul_Command2, + devpriv->i_IobaseAmcc + APCI1564_TIMER + + APCI1564_TCW_PROG); + } + }/* if (ui_Timer == 1) */ - //Send a signal to from kernel to user space - send_sig(SIGIO, devpriv->tsk_Current, 0); - // Enable Counter Interrupt - outl(ul_Command2, - devpriv->iobase + APCI1564_COUNTER1 + - APCI1564_TCW_PROG); - } // if ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) + if (ui_C1 == 1) { + devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; + if (devpriv->b_TimerSelectMode) { - if ((ui_C2 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) { - // Disable Counter Interrupt - ul_Command2 = - inl(devpriv->iobase + APCI1564_COUNTER2 + - APCI1564_TCW_PROG); - outl(0x0, - devpriv->iobase + APCI1564_COUNTER2 + - APCI1564_TCW_PROG); + /* Disable Counter Interrupt */ + ul_Command2 = + inl(devpriv->iobase + APCI1564_COUNTER1 + + APCI1564_TCW_PROG); + outl(0x0, + devpriv->iobase + APCI1564_COUNTER1 + + APCI1564_TCW_PROG); - //Send a signal to from kernel to user space - send_sig(SIGIO, devpriv->tsk_Current, 0); + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); - // Enable Counter Interrupt - outl(ul_Command2, - devpriv->iobase + APCI1564_COUNTER2 + - APCI1564_TCW_PROG); - } // if ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER)) + /* Enable Counter Interrupt */ + outl(ul_Command2, + devpriv->iobase + APCI1564_COUNTER1 + + APCI1564_TCW_PROG); + } + } /* if (ui_C1 == 1) */ - if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) { - // Disable Counter Interrupt - ul_Command2 = - inl(devpriv->iobase + APCI1564_COUNTER3 + - APCI1564_TCW_PROG); - outl(0x0, - devpriv->iobase + APCI1564_COUNTER3 + - APCI1564_TCW_PROG); + if (ui_C2 == 1) { + devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; + if (devpriv->b_TimerSelectMode) { - //Send a signal to from kernel to user space - send_sig(SIGIO, devpriv->tsk_Current, 0); + /* Disable Counter Interrupt */ + ul_Command2 = + inl(devpriv->iobase + APCI1564_COUNTER2 + + APCI1564_TCW_PROG); + outl(0x0, + devpriv->iobase + APCI1564_COUNTER2 + + APCI1564_TCW_PROG); - // Enable Counter Interrupt - outl(ul_Command2, - devpriv->iobase + APCI1564_COUNTER3 + - APCI1564_TCW_PROG); - } // if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER)) + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); - if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) { - // Disable Counter Interrupt - ul_Command2 = - inl(devpriv->iobase + APCI1564_COUNTER4 + - APCI1564_TCW_PROG); - outl(0x0, - devpriv->iobase + APCI1564_COUNTER4 + - APCI1564_TCW_PROG); + /* Enable Counter Interrupt */ + outl(ul_Command2, + devpriv->iobase + APCI1564_COUNTER2 + + APCI1564_TCW_PROG); + } + } /* if ((ui_C2 == 1) */ - //Send a signal to from kernel to user space - send_sig(SIGIO, devpriv->tsk_Current, 0); + if (ui_C3 == 1) { + devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; + if (devpriv->b_TimerSelectMode) { - // Enable Counter Interrupt - outl(ul_Command2, - devpriv->iobase + APCI1564_COUNTER4 + - APCI1564_TCW_PROG); - } // if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER)) + /* Disable Counter Interrupt */ + ul_Command2 = + inl(devpriv->iobase + APCI1564_COUNTER3 + + APCI1564_TCW_PROG); + outl(0x0, + devpriv->iobase + APCI1564_COUNTER3 + + APCI1564_TCW_PROG); + + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); + + /* Enable Counter Interrupt */ + outl(ul_Command2, + devpriv->iobase + APCI1564_COUNTER3 + + APCI1564_TCW_PROG); + } + } /* if ((ui_C3 == 1) */ + + if (ui_C4 == 1) { + devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; + if (devpriv->b_TimerSelectMode) { + + /* Disable Counter Interrupt */ + ul_Command2 = + inl(devpriv->iobase + APCI1564_COUNTER4 + + APCI1564_TCW_PROG); + outl(0x0, + devpriv->iobase + APCI1564_COUNTER4 + + APCI1564_TCW_PROG); + + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); + + /* Enable Counter Interrupt */ + outl(ul_Command2, + devpriv->iobase + APCI1564_COUNTER4 + + APCI1564_TCW_PROG); + } + } /* if (ui_C4 == 1) */ return; } @@ -1081,16 +1104,16 @@ static void v_APCI1564_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -INT i_APCI1564_Reset(struct comedi_device * dev) +int i_APCI1564_Reset(struct comedi_device *dev) { - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_IRQ); //disable the interrupts - inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_STATUS); //Reset the interrupt status register - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE1); //Disable the and/or interrupt + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_IRQ); /* disable the interrupts */ + inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_STATUS); /* Reset the interrupt status register */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE1); /* Disable the and/or interrupt */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE2); devpriv->b_DigitalOutputRegister = 0; ui_Type = 0; - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP); //Resets the output channels - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_INTERRUPT); //Disables the interrupt. + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP); /* Resets the output channels */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_INTERRUPT); /* Disables the interrupt. */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_RELOAD_VALUE); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h index f0c461ca5396..0780c440c44a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h @@ -20,45 +20,45 @@ #define APCI1564_BOARD_VENDOR_ID 0x15B8 #define APCI1564_ADDRESS_RANGE 128 -//DIGITAL INPUT-OUTPUT DEFINE -// Input defines +/* DIGITAL INPUT-OUTPUT DEFINE */ +/* Input defines */ #define APCI1564_DIGITAL_IP 0x04 #define APCI1564_DIGITAL_IP_INTERRUPT_MODE1 4 #define APCI1564_DIGITAL_IP_INTERRUPT_MODE2 8 #define APCI1564_DIGITAL_IP_IRQ 16 -// Output defines +/* Output defines */ #define APCI1564_DIGITAL_OP 0x18 #define APCI1564_DIGITAL_OP_RW 0 #define APCI1564_DIGITAL_OP_INTERRUPT 4 #define APCI1564_DIGITAL_OP_IRQ 12 -//Digital Input IRQ Function Selection +/* Digital Input IRQ Function Selection */ #define ADDIDATA_OR 0 #define ADDIDATA_AND 1 -//Digital Input Interrupt Status +/* Digital Input Interrupt Status */ #define APCI1564_DIGITAL_IP_INTERRUPT_STATUS 12 -//Digital Output Interrupt Status +/* Digital Output Interrupt Status */ #define APCI1564_DIGITAL_OP_INTERRUPT_STATUS 8 -//Digital Input Interrupt Enable Disable. +/* Digital Input Interrupt Enable Disable. */ #define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE 0x4 #define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB -//Digital Output Interrupt Enable Disable. +/* Digital Output Interrupt Enable Disable. */ #define APCI1564_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1 #define APCI1564_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE #define APCI1564_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2 #define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD -//ADDIDATA Enable Disable +/* ADDIDATA Enable Disable */ #define ADDIDATA_ENABLE 1 #define ADDIDATA_DISABLE 0 -// TIMER COUNTER WATCHDOG DEFINES +/* TIMER COUNTER WATCHDOG DEFINES */ #define ADDIDATA_TIMER 0 #define ADDIDATA_COUNTER 1 @@ -78,30 +78,32 @@ #define APCI1564_TCW_WARN_TIMEVAL 24 #define APCI1564_TCW_WARN_TIMEBASE 28 -// Hardware Layer functions for Apci1564 +/* Hardware Layer functions for Apci1564 */ -//DI -// for di read -INT i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +/* +* DI for di read +*/ +int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//DO +/* DO */ int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI1564_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER -// timer value is passed as u seconds -INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, +/* +* TIMER timer value is passed as u seconds +*/ +int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, @@ -112,8 +114,8 @@ int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// INTERRUPT +/* intERRUPT */ static void v_APCI1564_Interrupt(int irq, void *d); -// RESET -INT i_APCI1564_Reset(struct comedi_device *dev); +/* RESET */ +int i_APCI1564_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c index 906d635da6b2..988e3fc2b857 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -57,7 +57,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI16XX_InsnConfigInitTTLIO | +| Function Name : int i_APCI16XX_InsnConfigInitTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -69,11 +69,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | for you call any other function witch access of TTL. | | APCI16XX_TTL_INITDIRECTION(user inputs for direction) | +----------------------------------------------------------------------------+ -| Input Parameters : b_InitType = (BYTE) data[0]; | -| b_Port0Mode = (BYTE) data[1]; | -| b_Port1Mode = (BYTE) data[2]; | -| b_Port2Mode = (BYTE) data[3]; | -| b_Port3Mode = (BYTE) data[4]; | +| Input Parameters : b_InitType = (unsigned char) data[0]; | +| b_Port0Mode = (unsigned char) data[1]; | +| b_Port1Mode = (unsigned char) data[2]; | +| b_Port2Mode = (unsigned char) data[3]; | +| b_Port3Mode = (unsigned char) data[4]; | | ........ | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -90,14 +90,14 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Command = 0; - BYTE b_Cpt = 0; - BYTE b_NumberOfPort = - (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); + int i_ReturnValue = insn->n; + unsigned char b_Command = 0; + unsigned char b_Cpt = 0; + unsigned char b_NumberOfPort = + (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); /************************/ /* Test the buffer size */ @@ -108,7 +108,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, /* Get the command */ /* **************** */ - b_Command = (BYTE) data[0]; + b_Command = (unsigned char) data[0]; /********************/ /* Test the command */ @@ -122,7 +122,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, /***************************************/ if ((b_Command == APCI16XX_TTL_INITDIRECTION) - && ((BYTE) (insn->n - 1) != b_NumberOfPort)) { + && ((unsigned char) (insn->n - 1) != b_NumberOfPort)) { /*******************/ /* Data size error */ /*******************/ @@ -132,7 +132,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, } if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY) - && ((BYTE) (insn->n) != 2)) { + && ((unsigned char) (insn->n) != 2)) { /*******************/ /* Data size error */ /*******************/ @@ -182,8 +182,8 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, /************************/ printk("\nPort %d direction selection error", - (INT) b_Cpt); - i_ReturnValue = -(INT) b_Cpt; + (int) b_Cpt); + i_ReturnValue = -(int) b_Cpt; } /**************************/ @@ -239,7 +239,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, } } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -250,7 +250,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI16XX_InsnBitsReadTTLIO | +| Function Name : int i_APCI16XX_InsnBitsReadTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -266,11 +266,11 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, | APCI16XX_TTL_READCHANNEL | | b_SelectedPort= CR_RANGE(insn->chanspec); | | b_InputChannel= CR_CHAN(insn->chanspec); | -| b_ReadType = (BYTE) data[0]; | +| b_ReadType = (unsigned char) data[0]; | | | | APCI16XX_TTL_READPORT | | b_SelectedPort= CR_RANGE(insn->chanspec); | -| b_ReadType = (BYTE) data[0]; | +| b_ReadType = (unsigned char) data[0]; | +----------------------------------------------------------------------------+ | Output Parameters : data[0] 0 : Channle is not active | | 1 : Channle is active | @@ -283,17 +283,17 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Command = 0; - BYTE b_NumberOfPort = - (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); - BYTE b_SelectedPort = CR_RANGE(insn->chanspec); - BYTE b_InputChannel = CR_CHAN(insn->chanspec); - BYTE *pb_Status; - DWORD dw_Status; + int i_ReturnValue = insn->n; + unsigned char b_Command = 0; + unsigned char b_NumberOfPort = + (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); + unsigned char b_SelectedPort = CR_RANGE(insn->chanspec); + unsigned char b_InputChannel = CR_CHAN(insn->chanspec); + unsigned char *pb_Status; + unsigned int dw_Status; /************************/ /* Test the buffer size */ @@ -304,7 +304,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, /* Get the command */ /* **************** */ - b_Command = (BYTE) data[0]; + b_Command = (unsigned char) data[0]; /********************/ /* Test the command */ @@ -380,7 +380,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, /**************************/ if (i_ReturnValue >= 0) { - pb_Status = (PBYTE) & data[0]; + pb_Status = (unsigned char *) &data[0]; /*******************************/ /* Get the digital inpu status */ @@ -394,7 +394,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, /* Save the port value */ /***********************/ - *pb_Status = (BYTE) dw_Status; + *pb_Status = (unsigned char) dw_Status; /***************************************/ /* Test if read channel status command */ @@ -405,12 +405,12 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, } } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI16XX_InsnReadTTLIOAllPortValue | +| Function Name : int i_APCI16XX_InsnReadTTLIOAllPortValue | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -430,13 +430,13 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - BYTE b_Command = (BYTE) CR_AREF(insn->chanspec); - INT i_ReturnValue = insn->n; - BYTE b_Cpt = 0; - BYTE b_NumberOfPort = 0; + unsigned char b_Command = (unsigned char) CR_AREF(insn->chanspec); + int i_ReturnValue = insn->n; + unsigned char b_Cpt = 0; + unsigned char b_NumberOfPort = 0; unsigned int *pls_ReadData = data; /********************/ @@ -450,7 +450,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, /**********************************/ b_NumberOfPort = - (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32); + (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32); if ((b_NumberOfPort * 32) < devpriv->ps_BoardInfo->i_NbrTTLChannel) { b_NumberOfPort = b_NumberOfPort + 1; @@ -524,7 +524,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, i_ReturnValue = -100; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -535,7 +535,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI16XX_InsnBitsWriteTTLIO | +| Function Name : int i_APCI16XX_InsnBitsWriteTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -551,11 +551,11 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, | APCI16XX_TTL_WRITECHANNEL_ON | APCI16XX_TTL_WRITECHANNEL_OFF | | b_SelectedPort = CR_RANGE(insn->chanspec); | | b_OutputChannel= CR_CHAN(insn->chanspec); | -| b_Command = (BYTE) data[0]; | +| b_Command = (unsigned char) data[0]; | | | | APCI16XX_TTL_WRITEPORT_ON | APCI16XX_TTL_WRITEPORT_OFF | | b_SelectedPort = CR_RANGE(insn->chanspec); | -| b_Command = (BYTE) data[0]; | +| b_Command = (unsigned char) data[0]; | +----------------------------------------------------------------------------+ | Output Parameters : data[0] : TTL output port 0 to 3 data | | data[1] : TTL output port 4 to 7 data | @@ -570,16 +570,16 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Command = 0; - BYTE b_NumberOfPort = - (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); - BYTE b_SelectedPort = CR_RANGE(insn->chanspec); - BYTE b_OutputChannel = CR_CHAN(insn->chanspec); - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_Command = 0; + unsigned char b_NumberOfPort = + (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8); + unsigned char b_SelectedPort = CR_RANGE(insn->chanspec); + unsigned char b_OutputChannel = CR_CHAN(insn->chanspec); + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ @@ -590,7 +590,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev, /* Get the command */ /* **************** */ - b_Command = (BYTE) data[0]; + b_Command = (unsigned char) data[0]; /********************/ /* Test the command */ @@ -758,7 +758,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev, devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4)); } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -774,7 +774,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI16XX_Reset(struct comedi_device * dev) +int i_APCI16XX_Reset(struct comedi_device *dev) { return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c index 31f55da39ea8..457917f292b7 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -62,7 +62,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | Task : Configures The Digital Output Subdevice. | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 1 Digital Memory On | @@ -75,20 +75,20 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | | +----------------------------------------------------------------------------+ */ -int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } // if ((data[0]!=0) && (data[0]!=1)) + } /* if ((data[0]!=0) && (data[0]!=1)) */ if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } // if (data[0] + } /* if (data[0] */ else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } // else if (data[0] + } /* else if (data[0] */ return insn->n; } @@ -101,8 +101,8 @@ int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To Write | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To Write | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -111,34 +111,34 @@ int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | | +----------------------------------------------------------------------------+ */ -int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_NoOfChannel; - UINT ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel; + unsigned int ui_Temp, ui_Temp1; ui_NoOfChannel = CR_CHAN(insn->chanspec); if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) { comedi_error(dev, "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); return -EINVAL; - } // if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) + } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */ if (devpriv->b_OutputMemoryStatus) { ui_Temp = inw(devpriv->iobase + APCI2016_DIGITAL_OP); - } // if (devpriv->b_OutputMemoryStatus ) + } /* if (devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } // else if (devpriv->b_OutputMemoryStatus ) + } /* else if (devpriv->b_OutputMemoryStatus ) */ if ((data[1] != 0) && (data[1] != 1)) { comedi_error(dev, "Invalid Data[1] value !!!, Data[1] should be 0 or 1\n"); return -EINVAL; - } // if ((data[1]!=0) && (data[1]!=1)) + } /* if ((data[1]!=0) && (data[1]!=1)) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP); - } // if (data[1]==0) + } /* if (data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -162,16 +162,16 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd break; default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } //switch(ui_NoOfChannels) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP); - } // if (data[1]==1) + } /* if (data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } // else if (data[1]==1) - } // else if (data[1]==0) - } // if (data[3]==0) + } /* else if (data[1]==1) */ + } /* else if (data[1]==0) */ + } /* if (data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -183,7 +183,7 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0] = data[0] & ui_Temp; outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP); - } // if (data[1]==0) + } /* if (data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -228,22 +228,22 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } //switch(ui_NoOfChannels) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ return insn->n; } @@ -256,8 +256,8 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -266,27 +266,27 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) { comedi_error(dev, "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); return -EINVAL; - } // if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) + } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */ if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Invalid Data[0] value !!!, Data[0] should be 0 or 1\n"); return -EINVAL; - } // if ((data[0]!=0) && (data[0]!=1)) + } /* if ((data[0]!=0) && (data[0]!=1)) */ ui_Temp = data[0]; *data = inw(devpriv->iobase + APCI2016_DIGITAL_OP_RW); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } // if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { switch (ui_NoOfChannel) { @@ -307,13 +307,13 @@ int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } //switch(ui_NoOfChannel) - } // if (ui_Temp==1) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch(ui_NoOfChannel) */ + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } // else if (ui_Temp==1) - } // if (ui_Temp==0) + } /* else if (ui_Temp==1) */ + } /* if (ui_Temp==0) */ return insn->n; } @@ -337,16 +337,16 @@ int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -int i_APCI2016_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0] == 0) { - //Disable the watchdog + /* Disable the watchdog */ outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); - //Loading the Reload value + /* Loading the Reload value */ outw(data[1], devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE); @@ -380,20 +380,20 @@ int i_APCI2016_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic | | +----------------------------------------------------------------------------+ */ -int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { - case 0: //stop the watchdog - outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); //disable the watchdog + case 0: /* stop the watchdog */ + outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ break; - case 1: //start the watchdog + case 1: /* start the watchdog */ outw(0x0001, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); break; - case 2: //Software trigger + case 2: /* Software trigger */ outw(0x0201, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); @@ -401,7 +401,7 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ default: printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } // switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -427,8 +427,8 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI2016_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { udelay(5); data[0] = inw(devpriv->i_IobaseAddon + APCI2016_WATCHDOG_STATUS) & 0x1; @@ -450,9 +450,9 @@ int i_APCI2016_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI2016_Reset(struct comedi_device * dev) +int i_APCI2016_Reset(struct comedi_device *dev) { - outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); // Resets the digital output channels + outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); /* Resets the digital output channels */ outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE); outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE + 2); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h index 9261aacd25f1..639944c44469 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h @@ -19,17 +19,17 @@ #define APCI2016_BOARD_VENDOR_ID 0x15B8 #define APCI2016_ADDRESS_RANGE 8 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI2016_DIGITAL_OP 0x04 #define APCI2016_DIGITAL_OP_RW 4 -//ADDIDATA Enable Disable +/* ADDIDATA Enable Disable */ #define ADDIDATA_ENABLE 1 #define ADDIDATA_DISABLE 0 -// TIMER COUNTER WATCHDOG DEFINES +/* TIMER COUNTER WATCHDOG DEFINES */ #define ADDIDATA_WATCHDOG 2 #define APCI2016_DIGITAL_OP_WATCHDOG 0 @@ -37,9 +37,9 @@ #define APCI2016_WATCHDOG_RELOAD_VALUE 4 #define APCI2016_WATCHDOG_STATUS 16 -// Hardware Layer functions for Apci2016 +/* Hardware Layer functions for Apci2016 */ -//DO +/* DO */ int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -49,8 +49,10 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subde int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER -// timer value is passed as u seconds +/* +* TIMER +* timer value is passed as u seconds +*/ int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -61,10 +63,10 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// Interrupt functions..... +/* Interrupt functions..... */ -// void v_APCI2016_Interrupt(int irq, void *d) ; +/* void v_APCI2016_Interrupt(int irq, void *d); */ - //void v_APCI2016_Interrupt(int irq, void *d); -// RESET -INT i_APCI2016_Reset(struct comedi_device *dev); +/* void v_APCI2016_Interrupt(int irq, void *d); */ +/* RESET */ +int i_APCI2016_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c index 1347bc388f3e..ec817082d170 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -53,7 +53,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc */ #include "hwdrv_apci2032.h" -UINT ui_InterruptData, ui_Type; +unsigned int ui_InterruptData, ui_Type; /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI2032_ConfigDigitalOutput | @@ -63,7 +63,7 @@ UINT ui_InterruptData, ui_Type; | Task : Configures The Digital Output Subdevice. | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[1] : 1 Enable VCC Interrupt | @@ -79,36 +79,36 @@ UINT ui_InterruptData, ui_Type; | | +----------------------------------------------------------------------------+ */ -int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command = 0; + unsigned int ul_Command = 0; devpriv->tsk_Current = current; if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } //if ( (data[0]!=0) && (data[0]!=1) ) + } /* if ( (data[0]!=0) && (data[0]!=1) ) */ if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } // if (data[0]) + } /* if (data[0]) */ else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } //else if (data[0]) + } /* else if (data[0]) */ if (data[1] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x1; - } //if (data[1] == ADDIDATA_ENABLE) + } /* if (data[1] == ADDIDATA_ENABLE) */ else { ul_Command = ul_Command & 0xFFFFFFFE; - } //elseif (data[1] == ADDIDATA_ENABLE) + } /* elseif (data[1] == ADDIDATA_ENABLE) */ if (data[2] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x2; - } //if (data[2] == ADDIDATA_ENABLE) + } /* if (data[2] == ADDIDATA_ENABLE) */ else { ul_Command = ul_Command & 0xFFFFFFFD; - } //elseif (data[2] == ADDIDATA_ENABLE) + } /* elseif (data[2] == ADDIDATA_ENABLE) */ outl(ul_Command, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); ui_InterruptData = inl(devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); return insn->n; @@ -123,8 +123,8 @@ int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To Write | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To Write | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -134,23 +134,23 @@ int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp, ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if (devpriv->b_OutputMemoryStatus) { ui_Temp = inl(devpriv->iobase + APCI2032_DIGITAL_OP); - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -184,18 +184,18 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -209,7 +209,7 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0] = data[0] & ui_Temp; outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -272,25 +272,25 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) - return (insn->n);; + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ + return insn->n; } /* @@ -302,8 +302,8 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -313,17 +313,17 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; *data = inl(devpriv->iobase + APCI2032_DIGITAL_OP_RW); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } //if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { switch (ui_NoOfChannel) { @@ -349,28 +349,28 @@ INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) - } //if (ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } //elseif (ui_Temp==1) + } /* elseif (ui_Temp==1) */ } return insn->n; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI2032_ConfigWatchdog(comedi_device - *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| +| Function Name : int i_APCI2032_ConfigWatchdog(comedi_device +| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| | | +----------------------------------------------------------------------------+ | Task : Configures The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -380,15 +380,15 @@ INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI2032_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0] == 0) { - //Disable the watchdog + /* Disable the watchdog */ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); - //Loading the Reload value + /* Loading the Reload value */ outl(data[1], devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); @@ -421,19 +421,19 @@ INT i_APCI2032_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { - case 0: //stop the watchdog - outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); //disable the watchdog + case 0: /* stop the watchdog */ + outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */ break; - case 1: //start the watchdog + case 1: /* start the watchdog */ outl(0x0001, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); break; - case 2: //Software trigger + case 2: /* Software trigger */ outl(0x0201, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); @@ -449,13 +449,13 @@ int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ | Function Name : int i_APCI2032_ReadWatchdog | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | +| unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Read The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -466,8 +466,8 @@ int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI2032_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = @@ -498,13 +498,13 @@ void v_APCI2032_Interrupt(int irq, void *d) struct comedi_device *dev = d; unsigned int ui_DO; - ui_DO = inl(devpriv->iobase + APCI2032_DIGITAL_OP_IRQ) & 0x1; //Check if VCC OR CC interrupt has occured. + ui_DO = inl(devpriv->iobase + APCI2032_DIGITAL_OP_IRQ) & 0x1; /* Check if VCC OR CC interrupt has occured. */ if (ui_DO == 0) { printk("\nInterrupt from unKnown source\n"); - } // if(ui_DO==0) + } /* if(ui_DO==0) */ if (ui_DO) { - // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. + /* Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. */ ui_Type = inl(devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT_STATUS) & 0x3; @@ -512,16 +512,16 @@ void v_APCI2032_Interrupt(int irq, void *d) devpriv->iobase + APCI2032_DIGITAL_OP + APCI2032_DIGITAL_OP_INTERRUPT); if (ui_Type == 1) { - //Sends signal to user space + /* Sends signal to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } // if (ui_Type==1) + } /* if (ui_Type==1) */ else { if (ui_Type == 2) { - // Sends signal to user space + /* Sends signal to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - } //if (ui_Type==2) - } //else if (ui_Type==1) - } //if(ui_DO) + } /* if (ui_Type==2) */ + } /* else if (ui_Type==1) */ + } /* if(ui_DO) */ return; @@ -544,8 +544,8 @@ void v_APCI2032_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -int i_APCI2032_ReadInterruptStatus(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { *data = ui_Type; return insn->n; @@ -567,13 +567,13 @@ int i_APCI2032_ReadInterruptStatus(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -int i_APCI2032_Reset(struct comedi_device * dev) +int i_APCI2032_Reset(struct comedi_device *dev) { devpriv->b_DigitalOutputRegister = 0; ui_Type = 0; - outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP); //Resets the output channels - outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); //Disables the interrupt. - outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); //disable the watchdog - outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); //reload=0 + outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP); /* Resets the output channels */ + outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); /* Disables the interrupt. */ + outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */ + outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); /* reload=0 */ return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h index 55002e0288b5..c971d143c249 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h @@ -17,32 +17,32 @@ /********* Definitions for APCI-2032 card *****/ -// Card Specific information +/* Card Specific information */ #define APCI2032_BOARD_VENDOR_ID 0x15B8 #define APCI2032_ADDRESS_RANGE 63 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI2032_DIGITAL_OP 0 #define APCI2032_DIGITAL_OP_RW 0 #define APCI2032_DIGITAL_OP_INTERRUPT 4 #define APCI2032_DIGITAL_OP_IRQ 12 -//Digital Output Interrupt Status +/* Digital Output Interrupt Status */ #define APCI2032_DIGITAL_OP_INTERRUPT_STATUS 8 -//Digital Output Interrupt Enable Disable. +/* Digital Output Interrupt Enable Disable. */ #define APCI2032_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1 #define APCI2032_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE #define APCI2032_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2 #define APCI2032_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD -//ADDIDATA Enable Disable +/* ADDIDATA Enable Disable */ #define ADDIDATA_ENABLE 1 #define ADDIDATA_DISABLE 0 -// TIMER COUNTER WATCHDOG DEFINES +/* TIMER COUNTER WATCHDOG DEFINES */ #define ADDIDATA_WATCHDOG 2 #define APCI2032_DIGITAL_OP_WATCHDOG 16 @@ -52,30 +52,32 @@ #define APCI2032_TCW_TRIG_STATUS 16 #define APCI2032_TCW_IRQ 20 -// Hardware Layer functions for Apci2032 +/* Hardware Layer functions for Apci2032 */ -//DO +/* DO */ int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER -// timer value is passed as u seconds -INT i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, +/* TIMER + * timer value is passed as u seconds +*/ + +int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// Interrupt functions..... +/* Interrupt functions..... */ void v_APCI2032_Interrupt(int irq, void *d); -//Reset functions +/* Reset functions */ int i_APCI2032_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c index 947e18ef3ab3..a853c62a4fd9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -63,7 +63,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -73,20 +73,20 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | | +----------------------------------------------------------------------------+ */ -INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue = 0; - UINT ui_Channel; + unsigned int ui_TmpValue = 0; + unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); if (ui_Channel >= 0 && ui_Channel <= 7) { - ui_TmpValue = (UINT) inw(devpriv->iobase + APCI2200_DIGITAL_IP); + ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI2200_DIGITAL_IP); *data = (ui_TmpValue >> ui_Channel) & 0x1; - } //if(ui_Channel >= 0 && ui_Channel <=7) + } /* if(ui_Channel >= 0 && ui_Channel <=7) */ else { printk("\nThe specified channel does not exist\n"); - return -EINVAL; // "sorry channel spec wrong " - } //else if(ui_Channel >= 0 && ui_Channel <=7) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* else if(ui_Channel >= 0 && ui_Channel <=7) */ return insn->n; } @@ -101,7 +101,7 @@ INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -112,17 +112,17 @@ INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_PortValue = data[0]; - UINT ui_Mask = 0; - UINT ui_NoOfChannels; + unsigned int ui_PortValue = data[0]; + unsigned int ui_Mask = 0; + unsigned int ui_NoOfChannels; ui_NoOfChannels = CR_CHAN(insn->chanspec); - *data = (UINT) inw(devpriv->iobase + APCI2200_DIGITAL_IP); + *data = (unsigned int) inw(devpriv->iobase + APCI2200_DIGITAL_IP); switch (ui_NoOfChannels) { case 2: ui_Mask = 3; @@ -137,9 +137,9 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su default: printk("\nWrong parameters\n"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ return insn->n; } @@ -147,7 +147,7 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_ConfigDigitalOutput (struct comedi_device *dev, - struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) | +| struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) | | | +----------------------------------------------------------------------------+ | Task : Configures The Digital Output Subdevice. | @@ -156,7 +156,7 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | unsigned int *data : Data Pointer contains | | configuration parameters as below | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | data[0] :1:Memory on | | 0:Memory off | | | @@ -169,8 +169,8 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su | | +----------------------------------------------------------------------------+ */ -int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { devpriv->b_OutputMemoryStatus = data[0]; return insn->n; @@ -180,13 +180,13 @@ int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_WriteDigitalOutput | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data) | +| unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Writes port value To the selected port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -197,23 +197,23 @@ int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp, ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if (devpriv->b_OutputMemoryStatus) { ui_Temp = inw(devpriv->iobase + APCI2200_DIGITAL_OP); - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outw(data[0], devpriv->iobase + APCI2200_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -240,18 +240,18 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd break; default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + APCI2200_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -263,7 +263,7 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0] = data[0] & ui_Temp; outw(data[0], devpriv->iobase + APCI2200_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -312,38 +312,38 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outw(data[0], devpriv->iobase + APCI2200_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) - return (insn->n);; + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ + return insn->n; } /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_ReadDigitalOutput | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data) | +| unsigned int *data) | +----------------------------------------------------------------------------+ | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -354,17 +354,17 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ ui_Temp = data[0]; *data = inw(devpriv->iobase + APCI2200_DIGITAL_OP); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } //if(ui_Temp==0) + } /* if(ui_Temp==0) */ else { if (ui_Temp == 1) { switch (ui_NoOfChannel) { @@ -386,28 +386,28 @@ INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) - } //if(ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if(ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } //elseif(ui_Temp==1) - } //elseif(ui_Temp==0) + } /* elseif(ui_Temp==1) */ + } /* elseif(ui_Temp==0) */ return insn->n; } /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | +| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | | | +----------------------------------------------------------------------------+ | Task : Configures The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -418,15 +418,15 @@ INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde +----------------------------------------------------------------------------+ */ -int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0] == 0) { - //Disable the watchdog + /* Disable the watchdog */ outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); - //Loading the Reload value + /* Loading the Reload value */ outw(data[1], devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_RELOAD_VALUE); @@ -434,11 +434,11 @@ int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic outw(data[1], devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_RELOAD_VALUE + 2); - } //if(data[0]==0) + } /* if(data[0]==0) */ else { printk("\nThe input parameters are wrong\n"); return -EINVAL; - } //elseif(data[0]==0) + } /* elseif(data[0]==0) */ return insn->n; } @@ -464,19 +464,19 @@ int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic +----------------------------------------------------------------------------+ */ -int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { - case 0: //stop the watchdog - outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); //disable the watchdog + case 0: /* stop the watchdog */ + outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ break; - case 1: //start the watchdog + case 1: /* start the watchdog */ outw(0x0001, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); break; - case 2: //Software trigger + case 2: /* Software trigger */ outw(0x0201, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); @@ -484,7 +484,7 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ default: printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } // switch(data[0]) + } /* switch(data[0]) */ return insn->n; } @@ -492,13 +492,13 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_ReadWatchdog | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | +| unsigned int *data); | +----------------------------------------------------------------------------+ | Task : Read The Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | +| struct comedi_insn *insn :pointer to insn structure | | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | @@ -509,8 +509,8 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI2200_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI2200_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = inw(devpriv->iobase + APCI2200_WATCHDOG + @@ -533,9 +533,9 @@ int i_APCI2200_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice +----------------------------------------------------------------------------+ */ -INT i_APCI2200_Reset(struct comedi_device * dev) +int i_APCI2200_Reset(struct comedi_device *dev) { - outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP); //RESETS THE DIGITAL OUTPUTS + outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */ outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h index 0a115b4c44c9..63e5f1fcecc7 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h @@ -17,39 +17,39 @@ /********* Definitions for APCI-2200 card *****/ -// Card Specific information +/* Card Specific information */ #define APCI2200_BOARD_VENDOR_ID 0x15b8 #define APCI2200_ADDRESS_RANGE 64 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI2200_DIGITAL_OP 4 #define APCI2200_DIGITAL_IP 0 -// TIMER COUNTER WATCHDOG DEFINES +/* TIMER COUNTER WATCHDOG DEFINES */ #define APCI2200_WATCHDOG 0x08 #define APCI2200_WATCHDOG_ENABLEDISABLE 12 #define APCI2200_WATCHDOG_RELOAD_VALUE 4 #define APCI2200_WATCHDOG_STATUS 16 -// Hardware Layer functions for Apci2200 +/* Hardware Layer functions for Apci2200 */ -//Digital Input -INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +/* Digital Input */ +int i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//Digital Output +/* Digital Output */ int i_APCI2200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER +/* TIMER */ int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, @@ -57,5 +57,5 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s int i_APCI2200_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//reset -INT i_APCI2200_Reset(struct comedi_device *dev); +/* reset */ +int i_APCI2200_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 68eb8dfd5139..169cee41b871 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -45,9 +45,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc */ #include "hwdrv_apci3120.h" -static UINT ui_Temp = 0; +static unsigned int ui_Temp = 0; -// FUNCTION DEFINITIONS +/* FUNCTION DEFINITIONS */ /* +----------------------------------------------------------------------------+ @@ -74,20 +74,20 @@ static UINT ui_Temp = 0; +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT i; + unsigned int i; if ((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE)) return -1; - // Check for Conversion time to be added ?? + /* Check for Conversion time to be added ?? */ devpriv->ui_EocEosConversionTime = data[2]; if (data[0] == APCI3120_EOS_MODE) { - //Test the number of the channel + /* Test the number of the channel */ for (i = 0; i < data[3]; i++) { if (CR_CHAN(data[4 + i]) >= this_board->i_NbrAiChannel) { @@ -102,14 +102,14 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_s devpriv->b_EocEosInterrupt = APCI3120_ENABLE; } else devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - // Copy channel list and Range List to devpriv + /* Copy channel list and Range List to devpriv */ devpriv->ui_AiNbrofChannels = data[3]; for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { devpriv->ui_AiChannelList[i] = data[4 + i]; } - } else // EOC + } else /* EOC */ { devpriv->b_InterruptMode = APCI3120_EOC_MODE; if (data[1]) { @@ -145,28 +145,28 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_s +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - USHORT us_ConvertTiming, us_TmpValue, i; - BYTE b_Tmp; + unsigned short us_ConvertTiming, us_TmpValue, i; + unsigned char b_Tmp; - // fix convertion time to 10 us + /* fix convertion time to 10 us */ if (!devpriv->ui_EocEosConversionTime) { printk("No timer0 Value using 10 us\n"); us_ConvertTiming = 10; } else - us_ConvertTiming = (USHORT) (devpriv->ui_EocEosConversionTime / 1000); // nano to useconds + us_ConvertTiming = (unsigned short) (devpriv->ui_EocEosConversionTime / 1000); /* nano to useconds */ - // this_board->i_hwdrv_InsnReadAnalogInput(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); + /* this_board->i_hwdrv_InsnReadAnalogInput(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); */ - // Clear software registers + /* Clear software registers */ devpriv->b_TimerSelectMode = 0; devpriv->b_ModeSelectRegister = 0; devpriv->us_OutputRegister = 0; -// devpriv->b_DigitalOutputRegister=0; +/* devpriv->b_DigitalOutputRegister=0; */ - if (insn->unused[0] == 222) // second insn read + if (insn->unused[0] == 222) /* second insn read */ { for (i = 0; i < insn->n; i++) { @@ -174,14 +174,16 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub } } else { - devpriv->tsk_Current = current; // Save the current process task structure - //Testing if board have the new Quartz and calculate the time value - //to set in the timer + devpriv->tsk_Current = current; /* Save the current process task structure */ +/* + * Testing if board have the new Quartz and calculate the time value + * to set in the timer + */ us_TmpValue = - (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS); + (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); - //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 + /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ if ((us_TmpValue & 0x00B0) == 0x00B0 || !strcmp(this_board->pc_DriverName, "apci3001")) { us_ConvertTiming = (us_ConvertTiming * 2) - 2; @@ -190,25 +192,26 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub ((us_ConvertTiming * 12926) / 10000) - 1; } - us_TmpValue = (USHORT) devpriv->b_InterruptMode; + us_TmpValue = (unsigned short) devpriv->b_InterruptMode; switch (us_TmpValue) { case APCI3120_EOC_MODE: - // Testing the interrupt flag and set the EOC bit - // Clears the FIFO +/* + * Testing the interrupt flag and set the EOC bit Clears the FIFO + */ inw(devpriv->iobase + APCI3120_RESET_FIFO); - // Initialize the sequence array + /* Initialize the sequence array */ - //if (!i_APCI3120_SetupChannelList(dev,s,1,chanlist,0)) return -EINVAL; + /* if (!i_APCI3120_SetupChannelList(dev,s,1,chanlist,0)) return -EINVAL; */ if (!i_APCI3120_SetupChannelList(dev, s, 1, &insn->chanspec, 0)) return -EINVAL; - //Initialize Timer 0 mode 4 + /* Initialize Timer 0 mode 4 */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0xFC) | @@ -216,14 +219,14 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub outb(devpriv->b_TimerSelectMode, devpriv->iobase + APCI3120_TIMER_CRT1); - // Reset the scan bit and Disables the EOS, DMA, EOC interrupt + /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_SCAN; if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - //Disables the EOS,DMA and enables the EOC interrupt + /* Disables the EOS,DMA and enables the EOC interrupt */ devpriv->b_ModeSelectRegister = (devpriv-> b_ModeSelectRegister & @@ -241,7 +244,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub outb(devpriv->b_ModeSelectRegister, devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - // Sets gate 0 + /* Sets gate 0 */ devpriv->us_OutputRegister = (devpriv-> us_OutputRegister & APCI3120_CLEAR_PA_PR) | @@ -249,30 +252,30 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS); - // Select Timer 0 + /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); - //Set the convertion time + /* Set the convertion time */ outw(us_ConvertTiming, devpriv->iobase + APCI3120_TIMER_VALUE); us_TmpValue = - (USHORT) inw(dev->iobase + APCI3120_RD_STATUS); + (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) { do { - // Waiting for the end of conversion + /* Waiting for the end of conversion */ us_TmpValue = inw(devpriv->iobase + APCI3120_RD_STATUS); } while ((us_TmpValue & APCI3120_EOC) == APCI3120_EOC); - //Read the result in FIFO and put it in insn data pointer + /* Read the result in FIFO and put it in insn data pointer */ us_TmpValue = inw(devpriv->iobase + 0); *data = us_TmpValue; @@ -284,9 +287,9 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub case APCI3120_EOS_MODE: inw(devpriv->iobase); - // Clears the FIFO + /* Clears the FIFO */ inw(devpriv->iobase + APCI3120_RESET_FIFO); - // clear PA PR and disable timer 0 + /* clear PA PR and disable timer 0 */ devpriv->us_OutputRegister = (devpriv-> @@ -301,7 +304,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub devpriv->ui_AiChannelList, 0)) return -EINVAL; - //Initialize Timer 0 mode 2 + /* Initialize Timer 0 mode 2 */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0xFC) | @@ -309,26 +312,26 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub outb(devpriv->b_TimerSelectMode, devpriv->iobase + APCI3120_TIMER_CRT1); - //Select Timer 0 + /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); - //Set the convertion time + /* Set the convertion time */ outw(us_ConvertTiming, devpriv->iobase + APCI3120_TIMER_VALUE); - //Set the scan bit + /* Set the scan bit */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | APCI3120_ENABLE_SCAN; outb(devpriv->b_ModeSelectRegister, devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - //If Interrupt function is loaded + /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - //Disables the EOC,DMA and enables the EOS interrupt + /* Disables the EOC,DMA and enables the EOS interrupt */ devpriv->b_ModeSelectRegister = (devpriv-> b_ModeSelectRegister & @@ -347,7 +350,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub inw(devpriv->iobase + APCI3120_RD_STATUS); - //Sets gate 0 + /* Sets gate 0 */ devpriv->us_OutputRegister = devpriv-> @@ -355,28 +358,27 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS); - //Start conversion + /* Start conversion */ outw(0, devpriv->iobase + APCI3120_START_CONVERSION); - //Waiting of end of convertion if interrupt is not installed + /* Waiting of end of convertion if interrupt is not installed */ if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) { - //Waiting the end of convertion + /* Waiting the end of convertion */ do { us_TmpValue = inw(devpriv->iobase + APCI3120_RD_STATUS); - } - while ((us_TmpValue & APCI3120_EOS) != - APCI3120_EOS); + } while ((us_TmpValue & APCI3120_EOS) != + APCI3120_EOS); for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { - //Read the result in FIFO and write them in shared memory + /* Read the result in FIFO and write them in shared memory */ us_TmpValue = inw(devpriv->iobase); - data[i] = (UINT) us_TmpValue; + data[i] = (unsigned int) us_TmpValue; } - devpriv->b_InterruptMode = APCI3120_EOC_MODE; // Restore defaults. + devpriv->b_InterruptMode = APCI3120_EOC_MODE; /* Restore defaults. */ } break; @@ -384,7 +386,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub printk("inputs wrong\n"); } - devpriv->ui_EocEosConversionTime = 0; // re initializing the variable; + devpriv->ui_EocEosConversionTime = 0; /* re initializing the variable; */ } return insn->n; @@ -409,38 +411,41 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub +----------------------------------------------------------------------------+ */ -int i_APCI3120_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_subdevice * s) +int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s) { - // Disable A2P Fifo write and AMWEN signal + /* Disable A2P Fifo write and AMWEN signal */ outw(0, devpriv->i_IobaseAddon + 4); - //Disable Bus Master ADD ON + /* Disable Bus Master ADD ON */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); outw(0, devpriv->i_IobaseAddon + 2); outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); outw(0, devpriv->i_IobaseAddon + 2); - //Disable BUS Master PCI + /* Disable BUS Master PCI */ outl(0, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); - //outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR)&(~AINT_WRITE_COMPL), devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); // stop amcc irqs - //outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR)&(~EN_A2P_TRANSFERS), devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR); // stop DMA + /* outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR)&(~AINT_WRITE_COMPL), + * devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); stop amcc irqs */ + + /* outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR)&(~EN_A2P_TRANSFERS), + * devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR); stop DMA */ - //Disable ext trigger + /* Disable ext trigger */ i_APCI3120_ExttrigDisable(dev); devpriv->us_OutputRegister = 0; - //stop counters + /* stop counters */ outw(devpriv-> us_OutputRegister & APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1, dev->iobase + APCI3120_WR_ADDRESS); outw(APCI3120_DISABLE_ALL_TIMER, dev->iobase + APCI3120_WR_ADDRESS); - //DISABLE_ALL_INTERRUPT + /* DISABLE_ALL_INTERRUPT */ outb(APCI3120_DISABLE_ALL_INTERRUPT, dev->iobase + APCI3120_WRITE_MODE_SELECT); - //Flush FIFO + /* Flush FIFO */ inb(dev->iobase + APCI3120_RESET_FIFO); inw(dev->iobase + APCI3120_RD_STATUS); devpriv->ui_AiActualScan = 0; @@ -476,13 +481,13 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s +----------------------------------------------------------------------------+ */ -int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; - int tmp; // divisor1,divisor2; + int tmp; /* divisor1,divisor2; */ - // step 1: make sure trigger sources are trivially valid + /* step 1: make sure trigger sources are trivially valid */ tmp = cmd->start_src; cmd->start_src &= TRIG_NOW | TRIG_EXT; @@ -512,7 +517,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ if (err) return 1; - //step 2: make sure trigger sources are unique and mutually compatible + /* step 2: make sure trigger sources are unique and mutually compatible */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) { err++; @@ -536,14 +541,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ if (err) return 2; - // step 3: make sure arguments are trivially compatible + /* step 3: make sure arguments are trivially compatible */ if (cmd->start_arg != 0) { cmd->start_arg = 0; err++; } - if (cmd->scan_begin_src == TRIG_TIMER) // Test Delay timing + if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ { if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) { cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs; @@ -551,7 +556,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ } } - if (cmd->convert_src == TRIG_TIMER) // Test Acquisition timing + if (cmd->convert_src == TRIG_TIMER) /* Test Acquisition timing */ { if (cmd->scan_begin_src == TRIG_TIMER) { if ((cmd->convert_arg) @@ -585,7 +590,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ cmd->stop_arg = 1; err++; } - } else { // TRIG_NONE + } else { /* TRIG_NONE */ if (cmd->stop_arg != 0) { cmd->stop_arg = 0; err++; @@ -595,7 +600,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ if (err) return 3; - // step 4: fix up any arguments + /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { @@ -633,19 +638,19 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s) +int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; - //loading private structure with cmd structure inputs + /* loading private structure with cmd structure inputs */ devpriv->ui_AiFlags = cmd->flags; devpriv->ui_AiNbrofChannels = cmd->chanlist_len; devpriv->ui_AiScanLength = cmd->scan_end_arg; devpriv->pui_AiChannelList = cmd->chanlist; - //UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; + /* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */ devpriv->AiData = s->async->prealloc_buf; - //UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; + /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */ devpriv->ui_AiDataLength = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) { @@ -654,11 +659,11 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd devpriv->ui_AiNbrofScans = 0; } - devpriv->ui_AiTimer0 = 0; // variables changed to timer0,timer1 + devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */ devpriv->ui_AiTimer1 = 0; if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1)) - devpriv->b_AiContinuous = 1; // user want neverending analog acquisition - // stopped using cancel + devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ + /* stopped using cancel */ if (cmd->start_src == TRIG_EXT) devpriv->b_ExttrigEnable = APCI3120_ENABLE; @@ -666,22 +671,22 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd devpriv->b_ExttrigEnable = APCI3120_DISABLE; if (cmd->scan_begin_src == TRIG_FOLLOW) { - // mode 1 or 3 + /* mode 1 or 3 */ if (cmd->convert_src == TRIG_TIMER) { - // mode 1 + /* mode 1 */ - devpriv->ui_AiTimer0 = cmd->convert_arg; // timer constant in nano seconds - //return this_board->i_hwdrv_CommandAnalogInput(1,dev,s); + devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */ + /* return this_board->i_hwdrv_CommandAnalogInput(1,dev,s); */ return i_APCI3120_CyclicAnalogInput(1, dev, s); } } if ((cmd->scan_begin_src == TRIG_TIMER) && (cmd->convert_src == TRIG_TIMER)) { - // mode 2 + /* mode 2 */ devpriv->ui_AiTimer1 = cmd->scan_begin_arg; - devpriv->ui_AiTimer0 = cmd->convert_arg; // variable changed timer2 to timer0 - //return this_board->i_hwdrv_CommandAnalogInput(2,dev,s); + devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */ + /* return this_board->i_hwdrv_CommandAnalogInput(2,dev,s); */ return i_APCI3120_CyclicAnalogInput(2, dev, s); } return -1; @@ -707,73 +712,74 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, - struct comedi_subdevice * s) +int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev, + struct comedi_subdevice *s) { - BYTE b_Tmp; - UINT ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 = + unsigned char b_Tmp; + unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 = 0, dmalen1 = 0, ui_TimerValue2 = 0, ui_TimerValue0, ui_ConvertTiming; - USHORT us_TmpValue; + unsigned short us_TmpValue; - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE; - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE; */ + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /*******************/ /* Resets the FIFO */ /*******************/ inb(dev->iobase + APCI3120_RESET_FIFO); - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //inw(dev->iobase+APCI3120_RD_STATUS); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* inw(dev->iobase+APCI3120_RD_STATUS); */ + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /***************************/ /* Acquisition initialized */ /***************************/ - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ devpriv->b_AiCyclicAcquisition = APCI3120_ENABLE; - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - // clear software registers + /* clear software registers */ devpriv->b_TimerSelectMode = 0; devpriv->us_OutputRegister = 0; devpriv->b_ModeSelectRegister = 0; - //devpriv->b_DigitalOutputRegister=0; + /* devpriv->b_DigitalOutputRegister=0; */ - //COMMENT JK 07.05.04: Followings calls are in i_APCI3120_StartAnalogInputAcquisition + /* COMMENT JK 07.05.04: Followings calls are in i_APCI3120_StartAnalogInputAcquisition */ - /****************************/ - /* Clear Timer Write TC INT */ - /****************************/ + /****************************/ + /* Clear Timer Write TC int */ + /****************************/ outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_REG_INTCSR); - /************************************/ + /************************************/ /* Clears the timer status register */ - /************************************/ - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER); - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /************************************/ + + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER); */ + /* inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); */ + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - /**************************/ + /**************************/ /* Disables All Timer */ /* Sets PR and PA to 0 */ - /**************************/ + /**************************/ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_CLEAR_PA_PR; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - /*******************/ + /*******************/ /* Resets the FIFO */ - /*******************/ - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver + /*******************/ + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ inb(devpriv->iobase + APCI3120_RESET_FIFO); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ devpriv->ui_AiActualScan = 0; devpriv->ui_AiActualScanPosition = 0; @@ -781,7 +787,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, devpriv->ui_AiBufferPtr = 0; devpriv->ui_DmaActualBuffer = 0; - // value for timer2 minus -2 has to be done .....dunno y?? + /* value for timer2 minus -2 has to be done .....dunno y?? */ ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2; ui_ConvertTiming = devpriv->ui_AiTimer0; @@ -795,31 +801,31 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, devpriv->pui_AiChannelList, 0)) return -EINVAL; - us_TmpValue = (USHORT) inw(dev->iobase + APCI3120_RD_STATUS); + us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); /*** EL241003 : add this section in comment because floats must not be used - if((us_TmpValue & 0x00B0)==0x00B0) + if((us_TmpValue & 0x00B0)==0x00B0) { - f_ConvertValue=(((float)ui_ConvertTiming * 0.002) - 2); - ui_TimerValue0=(UINT)f_ConvertValue; + f_ConvertValue=(((float)ui_ConvertTiming * 0.002) - 2); + ui_TimerValue0=(unsigned int)f_ConvertValue; if (mode==2) { f_DelayValue = (((float)ui_DelayTiming * 0.00002) - 2); - ui_TimerValue1 = (UINT) f_DelayValue; + ui_TimerValue1 = (unsigned int) f_DelayValue; } } - else + else { f_ConvertValue=(((float)ui_ConvertTiming * 0.0012926) - 1); - ui_TimerValue0=(UINT)f_ConvertValue; + ui_TimerValue0=(unsigned int)f_ConvertValue; if (mode == 2) { f_DelayValue = (((float)ui_DelayTiming * 0.000012926) - 1); - ui_TimerValue1 = (UINT) f_DelayValue; + ui_TimerValue1 = (unsigned int) f_DelayValue; } } ***********************************************************************************************/ /*** EL241003 Begin : add this section to replace floats calculation by integer calculations **/ - //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 + /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ if ((us_TmpValue & 0x00B0) == 0x00B0 || !strcmp(this_board->pc_DriverName, "apci3001")) { ui_TimerValue0 = ui_ConvertTiming * 2 - 2000; @@ -844,79 +850,82 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, /*** EL241003 End ******************************************************************************/ if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { - i_APCI3120_ExttrigEnable(dev); // activate EXT trigger + i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */ } switch (mode) { case 1: - // init timer0 in mode 2 + /* init timer0 in mode 2 */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2; outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - //Select Timer 0 + /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - //Set the convertion time - outw(((USHORT) ui_TimerValue0), + /* Set the convertion time */ + outw(((unsigned short) ui_TimerValue0), dev->iobase + APCI3120_TIMER_VALUE); break; case 2: - // init timer1 in mode 2 + /* init timer1 in mode 2 */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0xF3) | APCI3120_TIMER_1_MODE_2; outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - //Select Timer 1 + /* Select Timer 1 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_1_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - //Set the convertion time - outw(((USHORT) ui_TimerValue1), + /* Set the convertion time */ + outw(((unsigned short) ui_TimerValue1), dev->iobase + APCI3120_TIMER_VALUE); - // init timer0 in mode 2 + /* init timer0 in mode 2 */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2; outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - //Select Timer 0 + /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - //Set the convertion time - outw(((USHORT) ui_TimerValue0), + /* Set the convertion time */ + outw(((unsigned short) ui_TimerValue0), dev->iobase + APCI3120_TIMER_VALUE); break; } - // ##########common for all modes################# + /* ##########common for all modes################# */ /***********************/ /* Clears the SCAN bit */ /***********************/ - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN; + + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN; */ + devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & APCI3120_DISABLE_SCAN; - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - // If DMA is disabled + /* If DMA is disabled */ if (devpriv->us_UseDma == APCI3120_DISABLE) { - // disable EOC and enable EOS + /* disable EOC and enable EOS */ devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->b_EocEosInterrupt = APCI3120_ENABLE; @@ -928,15 +937,17 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (!devpriv->b_AiContinuous) { - // configure Timer2 For counting EOS - //Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) +/* + * configure Timer2 For counting EOS Reset gate 2 of Timer 2 to + * disable it (Set Bit D14 to 0) + */ devpriv->us_OutputRegister = devpriv-> us_OutputRegister & APCI3120_DISABLE_TIMER2; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - // DISABLE TIMER INTERRUPT + /* DISABLE TIMER intERRUPT */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & @@ -944,7 +955,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - //(1) Init timer 2 in mode 0 and write timer value + /* (1) Init timer 2 in mode 0 and write timer value */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0x0F) | @@ -952,7 +963,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - //Writing LOW WORD + /* Writing LOW unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; @@ -960,7 +971,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, outw(LOWORD(ui_TimerValue2), dev->iobase + APCI3120_TIMER_VALUE); - //Writing HIGH WORD + /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; @@ -968,20 +979,20 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, outw(HIWORD(ui_TimerValue2), dev->iobase + APCI3120_TIMER_VALUE); - //(2) Reset FC_TIMER BIT Clearing timer status register + /* (2) Reset FC_TIMER BIT Clearing timer status register */ inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - // enable timer counter and disable watch dog + /* enable timer counter and disable watch dog */ devpriv->b_ModeSelectRegister = (devpriv-> b_ModeSelectRegister | APCI3120_ENABLE_TIMER_COUNTER) & APCI3120_DISABLE_WATCHDOG; - // select EOS clock input for timer 2 + /* select EOS clock input for timer 2 */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | APCI3120_TIMER2_SELECT_EOS; - // Enable timer2 interrupt + /* Enable timer2 interrupt */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | @@ -992,15 +1003,16 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, devpriv->b_Timer2Interrupt = APCI3120_ENABLE; } } else { - // If DMA Enabled - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //inw(dev->iobase+0);// reset EOC bit - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* If DMA Enabled */ + + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* inw(dev->iobase+0); reset EOC bit */ + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ devpriv->b_InterruptMode = APCI3120_DMA_MODE; - /************************************/ + /************************************/ /* Disables the EOC, EOS interrupt */ - /************************************/ + /************************************/ devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; @@ -1012,18 +1024,18 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, if (!devpriv->b_AiContinuous) { - if (dmalen0 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2)) { // must we fill full first buffer? + if (dmalen0 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2)) { /* must we fill full first buffer? */ dmalen0 = devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2; - } else if (dmalen1 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0)) // and must we fill full second buffer when first is once filled? + } else if (dmalen1 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0)) /* and must we fill full second buffer when first is once filled? */ dmalen1 = devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0; } if (devpriv->ui_AiFlags & TRIG_WAKE_EOS) { - // don't we want wake up every scan? + /* don't we want wake up every scan? */ if (dmalen0 > (devpriv->ui_AiScanLength * 2)) { dmalen0 = devpriv->ui_AiScanLength * 2; if (devpriv->ui_AiScanLength & 1) @@ -1036,7 +1048,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, if (dmalen1 < 4) dmalen1 = 4; } - } else { // isn't output buff smaller that our DMA buff? + } else { /* isn't output buff smaller that our DMA buff? */ if (dmalen0 > (devpriv->ui_AiDataLength)) { dmalen0 = devpriv->ui_AiDataLength; } @@ -1047,14 +1059,16 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, devpriv->ui_DmaBufferUsesize[0] = dmalen0; devpriv->ui_DmaBufferUsesize[1] = dmalen1; - //Initialize DMA + /* Initialize DMA */ - // Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS register - //1 +/* + * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS + * register 1 + */ ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); - // changed since 16 bit interface for add on + /* changed since 16 bit interface for add on */ /*********************/ /* ENABLE BUS MASTER */ /*********************/ @@ -1066,104 +1080,121 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); - // TO VERIFIED - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver +/* + * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux + * driver + */ outw(0x1000, devpriv->i_IobaseAddon + 2); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - //2 No change - // A2P FIFO MANAGEMENT - // A2P fifo reset & transfer control enable - /***********************/ + /* 2 No change */ /* A2P FIFO MANAGEMENT */ - /***********************/ + /* A2P fifo reset & transfer control enable */ + + /***********************/ + /* A2P FIFO MANAGEMENT */ + /***********************/ outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_MCSR); - //3 - //beginning address of dma buf - //The 32 bit address of dma buffer is converted into two 16 bit addresses - // Can done by using _attach and put into into an array - // array used may be for differnet pages +/* + * 3 + * beginning address of dma buf The 32 bit address of dma buffer + * is converted into two 16 bit addresses Can done by using _attach + * and put into into an array array used may be for differnet pages + */ - // DMA Start Adress Low + /* DMA Start Adress Low */ outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF), devpriv->i_IobaseAddon + 2); - /*************************/ + /*************************/ /* DMA Start Adress High */ - /*************************/ + /*************************/ outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); outw((devpriv->ul_DmaBufferHw[0] / 65536), devpriv->i_IobaseAddon + 2); - //4 - // amount of bytes to be transfered set transfer count - // used ADDON MWTC register - //commented testing outl(devpriv->ui_DmaBufferUsesize[0], devpriv->i_IobaseAddon+AMCC_OP_REG_AMWTC); - - /**************************/ +/* + * 4 + * amount of bytes to be transfered set transfer count used ADDON + * MWTC register commented testing + * outl(devpriv->ui_DmaBufferUsesize[0], + * devpriv->i_IobaseAddon+AMCC_OP_REG_AMWTC); + */ + + /**************************/ /* Nbr of acquisition LOW */ - /**************************/ + /**************************/ outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); outw((devpriv->ui_DmaBufferUsesize[0] & 0xFFFF), devpriv->i_IobaseAddon + 2); - /***************************/ + /***************************/ /* Nbr of acquisition HIGH */ - /***************************/ + /***************************/ outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); outw((devpriv->ui_DmaBufferUsesize[0] / 65536), devpriv->i_IobaseAddon + 2); - //5 - // To configure A2P FIFO - // testing outl( FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); +/* + * 5 + * To configure A2P FIFO testing outl( + * FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); + */ /******************/ /* A2P FIFO RESET */ /******************/ - // TO VERIFY - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver +/* + * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux + * driver + */ outl(0x04000000UL, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + +/* + * 6 + * ENABLE A2P FIFO WRITE AND ENABLE AMWEN AMWEN_ENABLE | + * A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 + */ - //6 - //ENABLE A2P FIFO WRITE AND ENABLE AMWEN - // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver - //outw(3,devpriv->i_IobaseAddon + 4); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* outw(3,devpriv->i_IobaseAddon + 4); */ + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - //7 - //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) +/* + * 7 + * initialise end of dma interrupt AINT_WRITE_COMPL = + * ENABLE_WRITE_TC_INT(ADDI) + */ /***************************************************/ - /* A2P FIFO CONFIGURATE, END OF DMA INTERRUPT INIT */ + /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */ /***************************************************/ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ /******************************************/ /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ /******************************************/ outw(3, devpriv->i_IobaseAddon + 4); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /******************/ /* A2P FIFO RESET */ /******************/ - //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ outl(0x04000000UL, devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_MCSR); - //END JK 07.05.04: Comparison between WIN32 and Linux driver + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ } if ((devpriv->us_UseDma == APCI3120_DISABLE) && !devpriv->b_AiContinuous) { - // set gate 2 to start conversion + /* set gate 2 to start conversion */ devpriv->us_OutputRegister = devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER2; outw(devpriv->us_OutputRegister, @@ -1172,14 +1203,14 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, switch (mode) { case 1: - // set gate 0 to start conversion + /* set gate 0 to start conversion */ devpriv->us_OutputRegister = devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER0; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); break; case 2: - // set gate 0 and gate 1 + /* set gate 0 and gate 1 */ devpriv->us_OutputRegister = devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER1; devpriv->us_OutputRegister = @@ -1196,7 +1227,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| INTERNAL FUNCTIONS | +| intERNAL FUNCTIONS | +----------------------------------------------------------------------------+ */ @@ -1218,7 +1249,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3120_Reset(struct comedi_device * dev) +int i_APCI3120_Reset(struct comedi_device *dev) { unsigned int i; unsigned short us_TmpValue; @@ -1226,47 +1257,49 @@ int i_APCI3120_Reset(struct comedi_device * dev) devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; - devpriv->ui_EocEosConversionTime = 0; // set eoc eos conv time to 0 + devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */ devpriv->b_OutputMemoryStatus = 0; - // variables used in timer subdevice + /* variables used in timer subdevice */ devpriv->b_Timer2Mode = 0; devpriv->b_Timer2Interrupt = 0; - devpriv->b_ExttrigEnable = 0; // Disable ext trigger + devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */ /* Disable all interrupts, watchdog for the anolog output */ devpriv->b_ModeSelectRegister = 0; outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - // Disables all counters, ext trigger and clears PA, PR + /* Disables all counters, ext trigger and clears PA, PR */ devpriv->us_OutputRegister = 0; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - //Code to set the all anolog o/p channel to 0v - //8191 is decimal value for zero(0 v)volt in bipolar mode(default) - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 1 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 2 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 3 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 4 - - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 5 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 6 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 7 - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 8 - - // Reset digital output to L0W - -//ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); +/* + * Code to set the all anolog o/p channel to 0v 8191 is decimal + * value for zero(0 v)volt in bipolar mode(default) + */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 1 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 2 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 3 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 4 */ + + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 5 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 6 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 7 */ + outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 8 */ + + /* Reset digital output to L0W */ + +/* ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */ udelay(10); - inw(dev->iobase + 0); //make a dummy read - inb(dev->iobase + APCI3120_RESET_FIFO); // flush FIFO - inw(dev->iobase + APCI3120_RD_STATUS); // flush A/D status register + inw(dev->iobase + 0); /* make a dummy read */ + inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ + inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ - //code to reset the RAM sequence + /* code to reset the RAM sequence */ for (i = 0; i < 16; i++) { - us_TmpValue = i << 8; //select the location + us_TmpValue = i << 8; /* select the location */ outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS); } return 0; @@ -1296,10 +1329,10 @@ int i_APCI3120_Reset(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdevice * s, +int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, char check) { - unsigned int i; //, differencial=0, bipolar=0; + unsigned int i; /* , differencial=0, bipolar=0; */ unsigned int gain; unsigned short us_TmpValue; @@ -1309,29 +1342,29 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev comedi_error(dev, "range/channel list is empty!"); return 0; } - // All is ok, so we can setup channel/range list + /* All is ok, so we can setup channel/range list */ if (check) return 1; - //Code to set the PA and PR...Here it set PA to 0.. + /* Code to set the PA and PR...Here it set PA to 0.. */ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR; devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); for (i = 0; i < n_chan; i++) { - // store range list to card - us_TmpValue = CR_CHAN(chanlist[i]); // get channel number; + /* store range list to card */ + us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */ if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) { - us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); // set bipolar + us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */ } else { - us_TmpValue |= APCI3120_UNIPOLAR; // enable unipolar...... + us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */ } - gain = CR_RANGE(chanlist[i]); // get gain number - us_TmpValue |= ((gain & 0x03) << 4); //<<4 for G0 and G1 bit in RAM - us_TmpValue |= i << 8; //To select the RAM LOCATION.... + gain = CR_RANGE(chanlist[i]); /* get gain number */ + us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */ + us_TmpValue |= i << 8; /* To select the RAM LOCATION.... */ outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS); printk("\n Gain = %i", @@ -1339,7 +1372,7 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev printk("\n Channel = %i", CR_CHAN(chanlist[i])); printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR); } - return 1; // we can serve this with scan logic + return 1; /* we can serve this with scan logic */ } /* @@ -1360,7 +1393,7 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev +----------------------------------------------------------------------------+ */ -int i_APCI3120_ExttrigEnable(struct comedi_device * dev) +int i_APCI3120_ExttrigEnable(struct comedi_device *dev) { devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER; @@ -1385,7 +1418,7 @@ int i_APCI3120_ExttrigEnable(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -int i_APCI3120_ExttrigDisable(struct comedi_device * dev) +int i_APCI3120_ExttrigDisable(struct comedi_device *dev) { devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); @@ -1394,7 +1427,7 @@ int i_APCI3120_ExttrigDisable(struct comedi_device * dev) /* +----------------------------------------------------------------------------+ -| INTERRUPT FUNCTIONS | +| intERRUPT FUNCTIONS | +----------------------------------------------------------------------------+ */ @@ -1422,33 +1455,33 @@ int i_APCI3120_ExttrigDisable(struct comedi_device * dev) void v_APCI3120_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - USHORT int_daq; + unsigned short int_daq; unsigned int int_amcc, ui_Check, i; - USHORT us_TmpValue; - BYTE b_DummyRead; + unsigned short us_TmpValue; + unsigned char b_DummyRead; struct comedi_subdevice *s = dev->subdevices + 0; ui_Check = 1; - int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; // get IRQ reasons - int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); // get AMCC INT register + int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; /* get IRQ reasons */ + int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* get AMCC int register */ if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) { comedi_error(dev, "IRQ from unknow source"); return; } - outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); // shutdown IRQ reasons in AMCC + outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */ int_daq = (int_daq >> 12) & 0xF; if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { - //Disable ext trigger + /* Disable ext trigger */ i_APCI3120_ExttrigDisable(dev); devpriv->b_ExttrigEnable = APCI3120_DISABLE; } - //clear the timer 2 interrupt + /* clear the timer 2 interrupt */ inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER); if (int_amcc & MASTER_ABORT_INT) @@ -1456,19 +1489,19 @@ void v_APCI3120_Interrupt(int irq, void *d) if (int_amcc & TARGET_ABORT_INT) comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!"); - // Ckeck if EOC interrupt + /* Ckeck if EOC interrupt */ if (((int_daq & 0x8) == 0) && (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) { if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - // Read the AI Value + /* Read the AI Value */ devpriv->ui_AiReadData[0] = - (UINT) inw(devpriv->iobase + 0); + (unsigned int) inw(devpriv->iobase + 0); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } else { - //Disable EOC Interrupt + /* Disable EOC Interrupt */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT; @@ -1478,10 +1511,10 @@ void v_APCI3120_Interrupt(int irq, void *d) } } - // Check If EOS interrupt + /* Check If EOS interrupt */ if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) { - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) // enable this in without DMA ??? + if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) /* enable this in without DMA ??? */ { if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) { @@ -1501,12 +1534,12 @@ void v_APCI3120_Interrupt(int irq, void *d) i++) { us_TmpValue = inw(devpriv->iobase + 0); devpriv->ui_AiReadData[i] = - (UINT) us_TmpValue; + (unsigned int) us_TmpValue; } devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } @@ -1516,12 +1549,12 @@ void v_APCI3120_Interrupt(int irq, void *d) b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT; outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; //Default settings + devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ devpriv->b_InterruptMode = APCI3120_EOC_MODE; } } - //Timer2 interrupt + /* Timer2 interrupt */ if (int_daq & 0x1) { switch (devpriv->b_Timer2Mode) { @@ -1534,18 +1567,18 @@ void v_APCI3120_Interrupt(int irq, void *d) outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - // stop timer 2 + /* stop timer 2 */ devpriv->us_OutputRegister = devpriv-> us_OutputRegister & APCI3120_DISABLE_ALL_TIMER; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - //stop timer 0 and timer 1 + /* stop timer 0 and timer 1 */ i_APCI3120_StopCyclicAcquisition(dev, s); devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; - //UPDATE-0.7.57->0.7.68comedi_done(dev,s); + /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */ s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); @@ -1553,19 +1586,19 @@ void v_APCI3120_Interrupt(int irq, void *d) case APCI3120_TIMER: - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); break; case APCI3120_WATCHDOG: - //Send a signal to from kernel to user space + /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); break; default: - // disable Timer Interrupt + /* disable Timer Interrupt */ devpriv->b_ModeSelectRegister = devpriv-> @@ -1585,7 +1618,7 @@ void v_APCI3120_Interrupt(int irq, void *d) if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) { /****************************/ - /* Clear Timer Write TC INT */ + /* Clear Timer Write TC int */ /****************************/ outl(APCI3120_CLEAR_WRITE_TC_INT, @@ -1596,7 +1629,7 @@ void v_APCI3120_Interrupt(int irq, void *d) /* Clears the timer status register */ /************************************/ inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - v_APCI3120_InterruptDma(irq, d); // do some data transfer + v_APCI3120_InterruptDma(irq, d); /* do some data transfer */ } else { /* Stops the Timer */ outw(devpriv-> @@ -1630,32 +1663,8 @@ void v_APCI3120_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -/* - * int i_APCI3120_InterruptHandleEos(struct comedi_device *dev) -{ - int n_chan,i; - short *data; - struct comedi_subdevice *s=dev->subdevices+0; - struct comedi_async *async = s->async; - data=async->data+async->buf_int_ptr; - n_chan=devpriv->ui_AiNbrofChannels; - - for(i=0;i<n_chan;i++) - { - data[i]=inw(dev->iobase+0); - } - async->buf_int_count+=n_chan*sizeof(short); - async->buf_int_ptr+=n_chan*sizeof(short); - comedi_eos(dev,s); - if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over - { -*//* buffer rollover */ -/* s->async->buf_int_ptr=0; - comedi_eobuf(dev,s); - } - return 0; -}*/ -int i_APCI3120_InterruptHandleEos(struct comedi_device * dev) + +int i_APCI3120_InterruptHandleEos(struct comedi_device *dev) { int n_chan, i; struct comedi_subdevice *s = dev->subdevices + 0; @@ -1704,7 +1713,7 @@ void v_APCI3120_InterruptDma(int irq, void *d) unsigned int next_dma_buf, samplesinbuf; unsigned long low_word, high_word, var; - UINT ui_Tmp; + unsigned int ui_Tmp; samplesinbuf = devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] - inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC); @@ -1720,20 +1729,20 @@ void v_APCI3120_InterruptDma(int irq, void *d) return; } - samplesinbuf = samplesinbuf >> 1; // number of received samples + samplesinbuf = samplesinbuf >> 1; /* number of received samples */ if (devpriv->b_DmaDoubleBuffer) { - // switch DMA buffers if is used double buffering + /* switch DMA buffers if is used double buffering */ next_dma_buf = 1 - devpriv->ui_DmaActualBuffer; ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS); - // changed since 16 bit interface for add on + /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->i_IobaseAddon + 2); outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); // 0x1000 is out putted in windows driver + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */ var = devpriv->ul_DmaBufferHw[next_dma_buf]; low_word = var & 0xffff; @@ -1761,54 +1770,18 @@ void v_APCI3120_InterruptDma(int irq, void *d) outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); outw(high_word, devpriv->i_IobaseAddon + 2); - // To configure A2P FIFO - // ENABLE A2P FIFO WRITE AND ENABLE AMWEN - // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 +/* + * To configure A2P FIFO + * ENABLE A2P FIFO WRITE AND ENABLE AMWEN + * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 + */ outw(3, devpriv->i_IobaseAddon + 4); - //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) + /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); } -/*UPDATE-0.7.57->0.7.68 - ptr=(short *)devpriv->ul_DmaBufferVirtual[devpriv->ui_DmaActualBuffer]; - - - // if there is not enough space left in the buffer to copy all data contained in the DMABufferVirtual - if(s->async->buf_int_ptr+samplesinbuf*sizeof(short)>=devpriv->ui_AiDataLength) - { - m=(devpriv->ui_AiDataLength-s->async->buf_int_ptr)/sizeof(short); - v_APCI3120_InterruptDmaMoveBlock16bit(dev,s,(void *)ptr,((void *)(devpriv->AiData))+s->async->buf_int_ptr,m); - s->async->buf_int_count+=m*sizeof(short); - ptr+=m*sizeof(short); - samplesinbuf-=m; - s->async->buf_int_ptr=0; - comedi_eobuf(dev,s); - } - - if (samplesinbuf) - { - v_APCI3120_InterruptDmaMoveBlock16bit(dev,s,(void *)ptr,((void *)(devpriv->AiData))+s->async->buf_int_ptr,samplesinbuf); - - s->async->buf_int_count+=samplesinbuf*sizeof(short); - s->async->buf_int_ptr+=samplesinbuf*sizeof(short); - if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS)) - { - comedi_bufcheck(dev,s); - } - } - if (!devpriv->b_AiContinuous) - if ( devpriv->ui_AiActualScan>=devpriv->ui_AiNbrofScans ) - { - // all data sampled - i_APCI3120_StopCyclicAcquisition(dev,s); - devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE; - //DPRINTK("\n Single DMA completed..\n"); - comedi_done(dev,s); - return; - } -*/ if (samplesinbuf) { v_APCI3120_InterruptDmaMoveBlock16bit(dev, s, devpriv->ul_DmaBufferVirtual[devpriv-> @@ -1821,7 +1794,7 @@ void v_APCI3120_InterruptDma(int irq, void *d) } if (!devpriv->b_AiContinuous) if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) { - // all data sampled + /* all data sampled */ i_APCI3120_StopCyclicAcquisition(dev, s); devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; s->async->events |= COMEDI_CB_EOA; @@ -1829,22 +1802,26 @@ void v_APCI3120_InterruptDma(int irq, void *d) return; } - if (devpriv->b_DmaDoubleBuffer) { // switch dma buffers + if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */ devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; } else { - // restart DMA if is not used double buffering - //ADDED REINITIALISE THE DMA +/* + * restart DMA if is not used double buffering + * ADDED REINITIALISE THE DMA + */ ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS); - // changed since 16 bit interface for add on + /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->i_IobaseAddon + 2); outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); // - // A2P FIFO MANAGEMENT - // A2P fifo reset & transfer control enable + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* */ +/* + * A2P FIFO MANAGEMENT + * A2P fifo reset & transfer control enable + */ outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); @@ -1858,7 +1835,7 @@ void v_APCI3120_InterruptDma(int irq, void *d) outw(high_word, devpriv->i_IobaseAddon + 2); var = devpriv->ui_DmaBufferUsesize[0]; - low_word = var & 0xffff; //changed + low_word = var & 0xffff; /* changed */ var = devpriv->ui_DmaBufferUsesize[0]; high_word = var / 65536; outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); @@ -1866,11 +1843,13 @@ void v_APCI3120_InterruptDma(int irq, void *d) outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); outw(high_word, devpriv->i_IobaseAddon + 2); - // To configure A2P FIFO - //ENABLE A2P FIFO WRITE AND ENABLE AMWEN - // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 +/* + * To configure A2P FIFO + * ENABLE A2P FIFO WRITE AND ENABLE AMWEN + * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 + */ outw(3, devpriv->i_IobaseAddon + 4); - //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) + /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); @@ -1897,37 +1876,8 @@ void v_APCI3120_InterruptDma(int irq, void *d) +----------------------------------------------------------------------------+ */ -/*void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n) -{ - int i,j,m; - - j=s->async->cur_chan; - m=devpriv->ui_AiActualScanPosition; - for(i=0;i<n;i++) - { - *data=*dma; - data++; dma++; - j++; - if(j>=devpriv->ui_AiNbrofChannels) - { - m+=j; - j=0; - if(m>=devpriv->ui_AiScanLength) - { - m=0; - devpriv->ui_AiActualScan++; - if (devpriv->ui_AiFlags & TRIG_WAKE_EOS) -;//UPDATE-0.7.57->0.7.68 comedi_eos(dev,s); - } - } - } - devpriv->ui_AiActualScanPosition=m; - s->async->cur_chan=j; - -} -*/ -void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device * dev, - struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples) +void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, + struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) { devpriv->ui_AiActualScan += (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength; @@ -1968,71 +1918,77 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Timervalue2; - USHORT us_TmpValue; - BYTE b_Tmp; + unsigned int ui_Timervalue2; + unsigned short us_TmpValue; + unsigned char b_Tmp; if (!data[1]) comedi_error(dev, "config:No timer constant !"); - devpriv->b_Timer2Interrupt = (BYTE) data[2]; // save info whether to enable or disable interrupt + devpriv->b_Timer2Interrupt = (unsigned char) data[2]; /* save info whether to enable or disable interrupt */ - ui_Timervalue2 = data[1] / 1000; // convert nano seconds to u seconds + ui_Timervalue2 = data[1] / 1000; /* convert nano seconds to u seconds */ - //this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(BYTE)data[0]); - us_TmpValue = (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS); + /* this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(unsigned char)data[0]); */ + us_TmpValue = (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); - //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 - // and calculate the time value to set in the timer +/* + * EL250804: Testing if board APCI3120 have the new Quartz or if it + * is an APCI3001 and calculate the time value to set in the timer + */ if ((us_TmpValue & 0x00B0) == 0x00B0 || !strcmp(this_board->pc_DriverName, "apci3001")) { - //Calculate the time value to set in the timer + /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 50; } else { - //Calculate the time value to set in the timer + /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 70; } - //Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) + /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER2; outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS); - // Disable TIMER Interrupt + /* Disable TIMER Interrupt */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT & 0xEF; - // Disable Eoc and Eos Interrupts + /* Disable Eoc and Eos Interrupts */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; outb(devpriv->b_ModeSelectRegister, devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - if (data[0] == APCI3120_TIMER) //initialize timer + if (data[0] == APCI3120_TIMER) /* initialize timer */ { + /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | + * APCI3120_ENABLE_TIMER_INT; */ - //devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister| APCI3120_ENABLE_TIMER_INT ; - //outb(devpriv->b_ModeSelectRegister,devpriv->iobase+APCI3120_WRITE_MODE_SELECT); + /* outb(devpriv->b_ModeSelectRegister,devpriv->iobase+APCI3120_WRITE_MODE_SELECT); */ - //Set the Timer 2 in mode 2(Timer) + /* Set the Timer 2 in mode 2(Timer) */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_2; outb(devpriv->b_TimerSelectMode, devpriv->iobase + APCI3120_TIMER_CRT1); - //Configure the timer 2 for writing the LOW WORD of timer is Delay value - //You must make a b_tmp variable with DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 - //you can set the digital output and configure the timer 2,and if you don't make this, digital output - //are erase (Set to 0) - - //Writing LOW WORD +/* + * Configure the timer 2 for writing the LOW unsigned short of timer + * is Delay value You must make a b_tmp variable with + * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 + * you can set the digital output and configure the timer 2,and if + * you don't make this, digital output are erase (Set to 0) + */ + + /* Writing LOW unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; @@ -2040,20 +1996,20 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi outw(LOWORD(ui_Timervalue2), devpriv->iobase + APCI3120_TIMER_VALUE); - //Writing HIGH WORD + /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); outw(HIWORD(ui_Timervalue2), devpriv->iobase + APCI3120_TIMER_VALUE); - // timer2 in Timer mode enabled + /* timer2 in Timer mode enabled */ devpriv->b_Timer2Mode = APCI3120_TIMER; - } else // Initialize Watch dog + } else /* Initialize Watch dog */ { - //Set the Timer 2 in mode 5(Watchdog) + /* Set the Timer 2 in mode 5(Watchdog) */ devpriv->b_TimerSelectMode = (devpriv-> @@ -2061,12 +2017,15 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi outb(devpriv->b_TimerSelectMode, devpriv->iobase + APCI3120_TIMER_CRT1); - //Configure the timer 2 for writing the LOW WORD of timer is Delay value - //You must make a b_tmp variable with DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 - //you can set the digital output and configure the timer 2,and if you don't make this, digital output - //are erase (Set to 0) - - //Writing LOW WORD +/* + * Configure the timer 2 for writing the LOW unsigned short of timer + * is Delay value You must make a b_tmp variable with + * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 + * you can set the digital output and configure the timer 2,and if + * you don't make this, digital output are erase (Set to 0) + */ + + /* Writing LOW unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; @@ -2074,7 +2033,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi outw(LOWORD(ui_Timervalue2), devpriv->iobase + APCI3120_TIMER_VALUE); - //Writing HIGH WORD + /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; @@ -2082,7 +2041,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi outw(HIWORD(ui_Timervalue2), devpriv->iobase + APCI3120_TIMER_VALUE); - //watchdog enabled + /* watchdog enabled */ devpriv->b_Timer2Mode = APCI3120_WATCHDOG; } @@ -2119,13 +2078,13 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Timervalue2 = 0; - USHORT us_TmpValue; - BYTE b_Tmp; + unsigned int ui_Timervalue2 = 0; + unsigned short us_TmpValue; + unsigned char b_Tmp; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { @@ -2133,7 +2092,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic return -EINVAL; } - if (data[0] == 2) // write new value + if (data[0] == 2) /* write new value */ { if (devpriv->b_Timer2Mode != APCI3120_TIMER) { comedi_error(dev, @@ -2147,35 +2106,35 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic ui_Timervalue2 = 0; } - //this_board->i_hwdrv_InsnWriteTimer(dev,data[0],ui_Timervalue2); + /* this_board->i_hwdrv_InsnWriteTimer(dev,data[0],ui_Timervalue2); */ switch (data[0]) { case APCI3120_START: - // Reset FC_TIMER BIT + /* Reset FC_TIMER BIT */ inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); - if (devpriv->b_Timer2Mode == APCI3120_TIMER) //start timer + if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ { - //Enable Timer + /* Enable Timer */ devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & 0x0B; - } else //start watch dog + } else /* start watch dog */ { - //Enable WatchDog + /* Enable WatchDog */ devpriv->b_ModeSelectRegister = (devpriv-> b_ModeSelectRegister & 0x0B) | APCI3120_ENABLE_WATCHDOG; } - //enable disable interrupt + /* enable disable interrupt */ if ((devpriv->b_Timer2Interrupt) == APCI3120_ENABLE) { devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | APCI3120_ENABLE_TIMER_INT; - // save the task structure to pass info to user + /* save the task structure to pass info to user */ devpriv->tsk_Current = current; } else { @@ -2187,9 +2146,9 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic outb(devpriv->b_ModeSelectRegister, devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - if (devpriv->b_Timer2Mode == APCI3120_TIMER) //start timer + if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ { - //For Timer mode is Gate2 must be activated **timer started + /* For Timer mode is Gate2 must be activated **timer started */ devpriv->us_OutputRegister = devpriv-> us_OutputRegister | APCI3120_ENABLE_TIMER2; @@ -2201,62 +2160,64 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic case APCI3120_STOP: if (devpriv->b_Timer2Mode == APCI3120_TIMER) { - //Disable timer + /* Disable timer */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_TIMER_COUNTER; } else { - //Disable WatchDog + /* Disable WatchDog */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_WATCHDOG; } - // Disable timer interrupt + /* Disable timer interrupt */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT; - // Write above states to register + /* Write above states to register */ outb(devpriv->b_ModeSelectRegister, devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - // Reset Gate 2 + /* Reset Gate 2 */ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER_INT; outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS); - // Reset FC_TIMER BIT + /* Reset FC_TIMER BIT */ inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); - // Disable timer - //devpriv->b_Timer2Mode=APCI3120_DISABLE; + /* Disable timer */ + /* devpriv->b_Timer2Mode=APCI3120_DISABLE; */ break; - case 2: //write new value to Timer + case 2: /* write new value to Timer */ if (devpriv->b_Timer2Mode != APCI3120_TIMER) { comedi_error(dev, "write :timer2 not configured in TIMER MODE"); return -EINVAL; } - // ui_Timervalue2=data[1]; // passed as argument + /* ui_Timervalue2=data[1]; // passed as argument */ us_TmpValue = - (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS); + (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); - //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 - // and calculate the time value to set in the timer +/* + * EL250804: Testing if board APCI3120 have the new Quartz or if it + * is an APCI3001 and calculate the time value to set in the timer + */ if ((us_TmpValue & 0x00B0) == 0x00B0 || !strcmp(this_board->pc_DriverName, "apci3001")) { - //Calculate the time value to set in the timer + /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 50; } else { - //Calculate the time value to set in the timer + /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 70; } - //Writing LOW WORD + /* Writing LOW unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; @@ -2265,7 +2226,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic outw(LOWORD(ui_Timervalue2), devpriv->iobase + APCI3120_TIMER_VALUE); - //Writing HIGH WORD + /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; @@ -2276,7 +2237,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic break; default: - return -EINVAL; // Not a valid input + return -EINVAL; /* Not a valid input */ } return insn->n; @@ -2305,21 +2266,21 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic | | +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - BYTE b_Tmp; - USHORT us_TmpValue, us_TmpValue_2, us_StatusValue; + unsigned char b_Tmp; + unsigned short us_TmpValue, us_TmpValue_2, us_StatusValue; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { comedi_error(dev, "\nread:timer2 not configured "); } - //this_board->i_hwdrv_InsnReadTimer(dev,data); + /* this_board->i_hwdrv_InsnReadTimer(dev,data); */ if (devpriv->b_Timer2Mode == APCI3120_TIMER) { - //Read the LOW WORD of Timer 2 register + /* Read the LOW unsigned short of Timer 2 register */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; @@ -2327,7 +2288,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice us_TmpValue = inw(devpriv->iobase + APCI3120_TIMER_VALUE); - //Read the HIGH WORD of Timer 2 register + /* Read the HIGH unsigned short of Timer 2 register */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; @@ -2335,20 +2296,20 @@ int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice us_TmpValue_2 = inw(devpriv->iobase + APCI3120_TIMER_VALUE); - // combining both words - data[0] = (UINT) ((us_TmpValue) | ((us_TmpValue_2) << 16)); + /* combining both words */ + data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16)); - } else // Read watch dog status + } else /* Read watch dog status */ { us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS); us_StatusValue = ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1; if (us_StatusValue == 1) { - // RESET FC_TIMER BIT + /* RESET FC_TIMER BIT */ inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); } - data[0] = us_StatusValue; // when data[0] = 1 then the watch dog has rundown + data[0] = us_StatusValue; /* when data[0] = 1 then the watch dog has rundown */ } return insn->n; } @@ -2384,21 +2345,23 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - UINT ui_Chan, ui_TmpValue; + unsigned int ui_Chan, ui_TmpValue; - ui_Chan = CR_CHAN(insn->chanspec); // channel specified + ui_Chan = CR_CHAN(insn->chanspec); /* channel specified */ - //this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); + /* this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); */ if (ui_Chan >= 0 && ui_Chan <= 3) { - ui_TmpValue = (UINT) inw(devpriv->iobase + APCI3120_RD_STATUS); + ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS); - // since only 1 channel reqd to bring it to last bit it is rotated - // 8 +(chan - 1) times then ANDed with 1 for last bit. +/* + * since only 1 channel reqd to bring it to last bit it is rotated 8 + * +(chan - 1) times then ANDed with 1 for last bit. + */ *data = (ui_TmpValue >> (ui_Chan + 8)) & 1; - //return 0; + /* return 0; */ } else { - // comedi_error(dev," chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + /* comedi_error(dev," chan spec wrong"); */ + return -EINVAL; /* "sorry channel spec wrong " */ } return insn->n; @@ -2423,18 +2386,18 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, | | +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnBitsDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_TmpValue; - ui_TmpValue = (UINT) inw(devpriv->iobase + APCI3120_RD_STATUS); + unsigned int ui_TmpValue; + ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS); /***** state of 4 channels in the 11, 10, 9, 8 bits of status reg rotated right 8 times to bring them to last four bits ANDed with oxf for value. *****/ *data = (ui_TmpValue >> 8) & 0xf; - //this_board->i_hwdrv_InsnBitsDigitalInput(dev,data); + /* this_board->i_hwdrv_InsnBitsDigitalInput(dev,data); */ return insn->n; } @@ -2462,8 +2425,8 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device * dev, struct comedi_su +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if ((data[0] != 0) && (data[0] != 1)) { @@ -2481,7 +2444,7 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev, if (!devpriv->b_OutputMemoryStatus) { ui_Temp = 0; - } //if(!devpriv->b_OutputMemoryStatus ) + } /* if(!devpriv->b_OutputMemoryStatus ) */ return insn->n; } @@ -2499,16 +2462,16 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev, | struct comedi_subdevice *s | | struct comedi_insn *insn | | unsigned int *data | - data[0] Value to be written - data[1] :1 Set digital o/p ON - data[1] 2 Set digital o/p OFF with memory ON +| data[0] Value to be written +| data[1] :1 Set digital o/p ON +| data[1] 2 Set digital o/p OFF with memory ON +----------------------------------------------------------------------------+ | Return Value : | | | +----------------------------------------------------------------------------+ */ -int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device * dev, +int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -2530,7 +2493,7 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device * dev, default: printk("\nThe parameter passed is in error \n"); return -EINVAL; - } // switch(data[1]) + } /* switch(data[1]) */ outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT); devpriv->b_DigitalOutputRegister = data[0] & 0xF0; @@ -2567,9 +2530,9 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, unsigned int *data) { - UINT ui_Temp1; + unsigned int ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, @@ -2586,7 +2549,7 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, switch (data[1]) { case 1: data[0] = (data[0] << ui_NoOfChannel); -//ES05 data[0]=(data[0]<<4)|ui_Temp; +/* ES05 data[0]=(data[0]<<4)|ui_Temp; */ data[0] = (data[0] << 4) | devpriv->b_DigitalOutputRegister; break; @@ -2595,24 +2558,24 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, ui_Temp1 = 1; ui_Temp1 = ui_Temp1 << ui_NoOfChannel; ui_Temp1 = ui_Temp1 << 4; -//ES05 ui_Temp=ui_Temp|ui_Temp1; +/* ES05 ui_Temp=ui_Temp|ui_Temp1; */ devpriv->b_DigitalOutputRegister = devpriv->b_DigitalOutputRegister | ui_Temp1; data[0] = (data[0] << ui_NoOfChannel) ^ 0xf; data[0] = data[0] << 4; -//ES05 data[0]=data[0]& ui_Temp; +/* ES05 data[0]=data[0]& ui_Temp; */ data[0] = data[0] & devpriv->b_DigitalOutputRegister; break; default: printk("\nThe parameter passed is in error \n"); return -EINVAL; - } // switch(data[1]) + } /* switch(data[1]) */ outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT); -//ES05 ui_Temp=data[0] & 0xf0; +/* ES05 ui_Temp=data[0] & 0xf0; */ devpriv->b_DigitalOutputRegister = data[0] & 0xf0; - return (insn->n); + return insn->n; } @@ -2646,14 +2609,14 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - UINT ui_Range, ui_Channel; - USHORT us_TmpValue; + unsigned int ui_Range, ui_Channel; + unsigned short us_TmpValue; ui_Range = CR_RANGE(insn->chanspec); ui_Channel = CR_CHAN(insn->chanspec); - //this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); - if (ui_Range) // if 1 then unipolar + /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */ + if (ui_Range) /* if 1 then unipolar */ { if (data[0] != 0) @@ -2665,7 +2628,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 << 13) | 8192); - } else // if 0 then bipolar + } else /* if 0 then bipolar */ { data[0] = ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) | @@ -2673,24 +2636,30 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, } - //out put n values at the given channel. - // rt_printk("\nwaiting for DA_READY BIT"); - do //Waiting of DA_READY BIT +/* + * out put n values at the given channel. printk("\nwaiting for + * DA_READY BIT"); + */ + do /* Waiting of DA_READY BIT */ { us_TmpValue = - ((USHORT) inw(devpriv->iobase + + ((unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS)) & 0x0001; } while (us_TmpValue != 0x0001); if (ui_Channel <= 3) - // for channel 0-3 out at the register 1 (wrDac1-8) - // data[i] typecasted to ushort since word write is to be done - outw((USHORT) data[0], +/* + * for channel 0-3 out at the register 1 (wrDac1-8) data[i] + * typecasted to ushort since word write is to be done + */ + outw((unsigned short) data[0], devpriv->iobase + APCI3120_ANALOG_OUTPUT_1); else - // for channel 4-7 out at the register 2 (wrDac5-8) - //data[i] typecasted to ushort since word write is to be done - outw((USHORT) data[0], +/* + * for channel 4-7 out at the register 2 (wrDac5-8) data[i] + * typecasted to ushort since word write is to be done + */ + outw((unsigned short) data[0], devpriv->iobase + APCI3120_ANALOG_OUTPUT_2); return insn->n; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h index 59d5d87a845b..fedfc9c58a88 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h @@ -1,5 +1,5 @@ -// hwdrv_apci3120.h +/* hwdrv_apci3120.h */ /* * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. @@ -18,9 +18,9 @@ * any later version. */ -// comedi related defines +/* comedi related defines */ -//ANALOG INPUT RANGE +/* ANALOG INPUT RANGE */ static const struct comedi_lrange range_apci3120_ai = { 8, { BIP_RANGE(10), BIP_RANGE(5), @@ -33,14 +33,14 @@ static const struct comedi_lrange range_apci3120_ai = { 8, { } }; -// ANALOG OUTPUT RANGE +/* ANALOG OUTPUT RANGE */ static const struct comedi_lrange range_apci3120_ao = { 2, { BIP_RANGE(10), UNI_RANGE(10) } }; -#define APCI3120_BIPOLAR_RANGES 4 // used for test on mixture of BIP/UNI ranges +#define APCI3120_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */ #define APCI3120_BOARD_VENDOR_ID 0x10E8 #define APCI3120_ADDRESS_RANGE 16 @@ -55,17 +55,17 @@ static const struct comedi_lrange range_apci3120_ao = { 2, { #define APCI3120_EOS_MODE 2 #define APCI3120_DMA_MODE 3 -//DIGITAL INPUT-OUTPUT DEFINE +/* DIGITAL INPUT-OUTPUT DEFINE */ #define APCI3120_DIGITAL_OUTPUT 0x0D #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -// digital output insn_write ON /OFF selection +/* digital output insn_write ON /OFF selection */ #define APCI3120_SET4DIGITALOUTPUTON 1 #define APCI3120_SET4DIGITALOUTPUTOFF 0 -// analog output SELECT BIT +/* analog output SELECT BIT */ #define APCI3120_ANALOG_OP_CHANNEL_1 0x0000 #define APCI3120_ANALOG_OP_CHANNEL_2 0x4000 #define APCI3120_ANALOG_OP_CHANNEL_3 0x8000 @@ -75,32 +75,32 @@ static const struct comedi_lrange range_apci3120_ao = { 2, { #define APCI3120_ANALOG_OP_CHANNEL_7 0x8000 #define APCI3120_ANALOG_OP_CHANNEL_8 0xC000 -// Enable external trigger bit in nWrAddress +/* Enable external trigger bit in nWrAddress */ #define APCI3120_ENABLE_EXT_TRIGGER 0x8000 -//ANALOG OUTPUT AND INPUT DEFINE -#define APCI3120_UNIPOLAR 0x80 //$$ RAM sequence polarity BIT -#define APCI3120_BIPOLAR 0x00 //$$ RAM sequence polarity BIT -#define APCI3120_ANALOG_OUTPUT_1 0x08 // (ADDRESS ) -#define APCI3120_ANALOG_OUTPUT_2 0x0A // (ADDRESS ) -#define APCI3120_1_GAIN 0x00 //$$ RAM sequence Gain Bits for gain 1 -#define APCI3120_2_GAIN 0x10 //$$ RAM sequence Gain Bits for gain 2 -#define APCI3120_5_GAIN 0x20 //$$ RAM sequence Gain Bits for gain 5 -#define APCI3120_10_GAIN 0x30 //$$ RAM sequence Gain Bits for gain 10 -#define APCI3120_SEQ_RAM_ADDRESS 0x06 //$$ EARLIER NAMED APCI3120_FIFO_ADDRESS -#define APCI3120_RESET_FIFO 0x0C //(ADDRESS) -#define APCI3120_TIMER_0_MODE_2 0x01 //$$ Bits for timer mode +/* ANALOG OUTPUT AND INPUT DEFINE */ +#define APCI3120_UNIPOLAR 0x80 /* $$ RAM sequence polarity BIT */ +#define APCI3120_BIPOLAR 0x00 /* $$ RAM sequence polarity BIT */ +#define APCI3120_ANALOG_OUTPUT_1 0x08 /* (ADDRESS ) */ +#define APCI3120_ANALOG_OUTPUT_2 0x0A /* (ADDRESS ) */ +#define APCI3120_1_GAIN 0x00 /* $$ RAM sequence Gain Bits for gain 1 */ +#define APCI3120_2_GAIN 0x10 /* $$ RAM sequence Gain Bits for gain 2 */ +#define APCI3120_5_GAIN 0x20 /* $$ RAM sequence Gain Bits for gain 5 */ +#define APCI3120_10_GAIN 0x30 /* $$ RAM sequence Gain Bits for gain 10 */ +#define APCI3120_SEQ_RAM_ADDRESS 0x06 /* $$ EARLIER NAMED APCI3120_FIFO_ADDRESS */ +#define APCI3120_RESET_FIFO 0x0C /* (ADDRESS) */ +#define APCI3120_TIMER_0_MODE_2 0x01 /* $$ Bits for timer mode */ #define APCI3120_TIMER_0_MODE_4 0x2 #define APCI3120_SELECT_TIMER_0_WORD 0x00 -#define APCI3120_ENABLE_TIMER0 0x1000 //$$Gatebit 0 in nWrAddress +#define APCI3120_ENABLE_TIMER0 0x1000 /* $$Gatebit 0 in nWrAddress */ #define APCI3120_CLEAR_PR 0xF0FF #define APCI3120_CLEAR_PA 0xFFF0 #define APCI3120_CLEAR_PA_PR (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA) -// nWrMode_Select -#define APCI3120_ENABLE_SCAN 0x8 //$$ bit in nWrMode_Select +/* nWrMode_Select */ +#define APCI3120_ENABLE_SCAN 0x8 /* $$ bit in nWrMode_Select */ #define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN) -#define APCI3120_ENABLE_EOS_INT 0x2 //$$ bit in nWrMode_Select +#define APCI3120_ENABLE_EOS_INT 0x2 /* $$ bit in nWrMode_Select */ #define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) #define APCI3120_ENABLE_EOC_INT 0x1 @@ -108,50 +108,50 @@ static const struct comedi_lrange range_apci3120_ao = { 2, { #define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) #define APCI3120_DISABLE_ALL_INTERRUPT (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) -//status register bits +/* status register bits */ #define APCI3120_EOC 0x8000 #define APCI3120_EOS 0x2000 -// software trigger dummy register -#define APCI3120_START_CONVERSION 0x02 //(ADDRESS) +/* software trigger dummy register */ +#define APCI3120_START_CONVERSION 0x02 /* (ADDRESS) */ -//TIMER DEFINE +/* TIMER DEFINE */ #define APCI3120_QUARTZ_A 70 #define APCI3120_QUARTZ_B 50 #define APCI3120_TIMER 1 #define APCI3120_WATCHDOG 2 #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_ENABLE_TIMER2 0x4000 //$$ gatebit 2 in nWrAddress +#define APCI3120_ENABLE_TIMER2 0x4000 /* $$ gatebit 2 in nWrAddress */ #define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) -#define APCI3120_ENABLE_TIMER_INT 0x04 //$$ ENAIRQ_FC_Bit in nWrModeSelect +#define APCI3120_ENABLE_TIMER_INT 0x04 /* $$ ENAIRQ_FC_Bit in nWrModeSelect */ #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) -#define APCI3120_WRITE_MODE_SELECT 0x0E // (ADDRESS) +#define APCI3120_WRITE_MODE_SELECT 0x0E /* (ADDRESS) */ #define APCI3120_SELECT_TIMER_0_WORD 0x00 #define APCI3120_SELECT_TIMER_1_WORD 0x01 #define APCI3120_TIMER_1_MODE_2 0x4 -//$$ BIT FOR MODE IN nCsTimerCtr1 +/* $$ BIT FOR MODE IN nCsTimerCtr1 */ #define APCI3120_TIMER_2_MODE_0 0x0 #define APCI3120_TIMER_2_MODE_2 0x10 #define APCI3120_TIMER_2_MODE_5 0x30 -//$$ BIT FOR MODE IN nCsTimerCtr0 +/* $$ BIT FOR MODE IN nCsTimerCtr0 */ #define APCI3120_SELECT_TIMER_2_LOW_WORD 0x02 #define APCI3120_SELECT_TIMER_2_HIGH_WORD 0x03 -#define APCI3120_TIMER_CRT0 0x0D //(ADDRESS for cCsTimerCtr0) -#define APCI3120_TIMER_CRT1 0x0C //(ADDRESS for cCsTimerCtr1) +#define APCI3120_TIMER_CRT0 0x0D /* (ADDRESS for cCsTimerCtr0) */ +#define APCI3120_TIMER_CRT1 0x0C /* (ADDRESS for cCsTimerCtr1) */ -#define APCI3120_TIMER_VALUE 0x04 //ADDRESS for nCsTimerWert -#define APCI3120_TIMER_STATUS_REGISTER 0x0D //ADDRESS for delete timer 2 interrupt -#define APCI3120_RD_STATUS 0x02 //ADDRESS -#define APCI3120_WR_ADDRESS 0x00 //ADDRESS -#define APCI3120_ENABLE_WATCHDOG 0x20 //$$BIT in nWrMode_Select +#define APCI3120_TIMER_VALUE 0x04 /* ADDRESS for nCsTimerWert */ +#define APCI3120_TIMER_STATUS_REGISTER 0x0D /* ADDRESS for delete timer 2 interrupt */ +#define APCI3120_RD_STATUS 0x02 /* ADDRESS */ +#define APCI3120_WR_ADDRESS 0x00 /* ADDRESS */ +#define APCI3120_ENABLE_WATCHDOG 0x20 /* $$BIT in nWrMode_Select */ #define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) -#define APCI3120_ENABLE_TIMER_COUNTER 0x10 //$$BIT in nWrMode_Select +#define APCI3120_ENABLE_TIMER_COUNTER 0x10 /* $$BIT in nWrMode_Select */ #define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER) -#define APCI3120_FC_TIMER 0x1000 //bit in status register +#define APCI3120_FC_TIMER 0x1000 /* bit in status register */ #define APCI3120_ENABLE_TIMER0 0x1000 #define APCI3120_ENABLE_TIMER1 0x2000 #define APCI3120_ENABLE_TIMER2 0x4000 @@ -159,25 +159,27 @@ static const struct comedi_lrange range_apci3120_ao = { 2, { #define APCI3120_DISABLE_TIMER1 (~APCI3120_ENABLE_TIMER1) #define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) -#define APCI3120_TIMER2_SELECT_EOS 0xC0 // ADDED on 20-6 -#define APCI3120_COUNTER 3 // on 20-6 -#define APCI3120_DISABLE_ALL_TIMER ( APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2 ) // on 20-6 +#define APCI3120_TIMER2_SELECT_EOS 0xC0 /* ADDED on 20-6 */ +#define APCI3120_COUNTER 3 /* on 20-6 */ +#define APCI3120_DISABLE_ALL_TIMER (APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2) /* on 20-6 */ #define MAX_ANALOGINPUT_CHANNELS 32 -typedef struct { - BYTE b_Type; /* EOC or EOS */ - BYTE b_InterruptFlag; /* Interrupt use or not */ - UINT ui_ConvertTiming; /* Selection of the convertion time */ - BYTE b_NbrOfChannel; /* Number of channel to read */ - UINT ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; /* Number of the channel to be read */ - UINT ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */ +struct str_AnalogReadInformation { -} str_AnalogReadInformation; + unsigned char b_Type; /* EOC or EOS */ + unsigned char b_InterruptFlag; /* Interrupt use or not */ + unsigned int ui_ConvertTiming; /* Selection of the convertion time */ + unsigned char b_NbrOfChannel; /* Number of channel to read */ + unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; /* Number of the channel to be read */ + unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */ + +}; -// Function Declaration For APCI-3120 -// Internal functions +/* Function Declaration For APCI-3120 */ + +/* Internal functions */ int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, char check); int i_APCI3120_ExttrigEnable(struct comedi_device *dev); @@ -186,9 +188,9 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su int i_APCI3120_Reset(struct comedi_device *dev); int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev, struct comedi_subdevice *s); -// Interrupt functions +/* Interrupt functions */ void v_APCI3120_Interrupt(int irq, void *d); -//UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); +/* UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); */ void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, struct comedi_subdevice *s, short *dma_buffer, @@ -196,7 +198,7 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, int i_APCI3120_InterruptHandleEos(struct comedi_device *dev); void v_APCI3120_InterruptDma(int irq, void *d); -// TIMER +/* TIMER */ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -205,16 +207,19 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//DI -// for di read +/* +* DI for di read +*/ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//DO -//int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev, BYTE data); +/* DO */ +/* int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev, + * unsigned char data); + */ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -223,12 +228,15 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_su int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//AO -//int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range,UINT ui_Channel,UINT data ); +/* AO */ +/* int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range, + * UINT ui_Channel,UINT data ); + */ + int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//AI HArdware layer +/* AI HArdware layer */ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); @@ -237,5 +245,5 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); -//int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); +/* int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); */ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 1ff66bee548d..9b53255bd45b 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -57,73 +57,73 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ #include "hwdrv_apci3200.h" -//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ #include "addi_amcc_S5920.h" -//#define PRINT_INFO +/* #define PRINT_INFO */ -//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ -//BEGIN JK 06.07.04: Management of sevrals boards +/* BEGIN JK 06.07.04: Management of sevrals boards */ /* - INT i_CJCAvailable=1; - INT i_CJCPolarity=0; - INT i_CJCGain=2;//changed from 0 to 2 - INT i_InterruptFlag=0; - INT i_ADDIDATAPolarity; - INT i_ADDIDATAGain; - INT i_AutoCalibration=0; //: auto calibration - INT i_ADDIDATAConversionTime; - INT i_ADDIDATAConversionTimeUnit; - INT i_ADDIDATAType; - INT i_ChannelNo; - INT i_ChannelCount=0; - INT i_ScanType; - INT i_FirstChannel; - INT i_LastChannel; - INT i_Sum=0; - INT i_Offset; - UINT ui_Channel_num=0; + int i_CJCAvailable=1; + int i_CJCPolarity=0; + int i_CJCGain=2;/* changed from 0 to 2 */ + int i_InterruptFlag=0; + int i_ADDIDATAPolarity; + int i_ADDIDATAGain; + int i_AutoCalibration=0; /* : auto calibration */ + int i_ADDIDATAConversionTime; + int i_ADDIDATAConversionTimeUnit; + int i_ADDIDATAType; + int i_ChannelNo; + int i_ChannelCount=0; + int i_ScanType; + int i_FirstChannel; + int i_LastChannel; + int i_Sum=0; + int i_Offset; + unsigned int ui_Channel_num=0; static int i_Count=0; - INT i_Initialised=0; - UINT ui_InterruptChannelValue[96]; //Buffer + int i_Initialised=0; + unsigned int ui_InterruptChannelValue[96]; /* Buffer */ */ -str_BoardInfos s_BoardInfos[100]; // 100 will be the max number of boards to be used -//END JK 06.07.04: Management of sevrals boards +struct str_BoardInfos s_BoardInfos[100]; /* 100 will be the max number of boards to be used */ +/* END JK 06.07.04: Management of sevrals boards */ -//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ /*+----------------------------------------------------------------------------+*/ -/*| Function Name : INT i_AddiHeaderRW_ReadEeprom |*/ -/*| (INT i_NbOfWordsToRead, |*/ -/*| DWORD dw_PCIBoardEepromAddress, |*/ -/*| WORD w_EepromStartAddress, |*/ -/*| PWORD pw_DataRead) |*/ +/*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/ +/*| (int i_NbOfWordsToRead, |*/ +/*| unsigned int dw_PCIBoardEepromAddress, |*/ +/*| unsigned short w_EepromStartAddress, |*/ +/*| unsigned short * pw_DataRead) |*/ /*+----------------------------------------------------------------------------+*/ /*| Task : Read word from the 5920 eeprom. |*/ /*+----------------------------------------------------------------------------+*/ -/*| Input Parameters : INT i_NbOfWordsToRead : Nbr. of word to read |*/ -/*| DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/ -/*| WORD w_EepromStartAddress : Eeprom strat address |*/ +/*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/ +/*| unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/ +/*| unsigned short w_EepromStartAddress : Eeprom strat address |*/ /*+----------------------------------------------------------------------------+*/ -/*| Output Parameters : PWORD pw_DataRead : Read data |*/ +/*| Output Parameters : unsigned short * pw_DataRead : Read data |*/ /*+----------------------------------------------------------------------------+*/ /*| Return Value : - |*/ /*+----------------------------------------------------------------------------+*/ -INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, - DWORD dw_PCIBoardEepromAddress, - WORD w_EepromStartAddress, PWORD pw_DataRead) +int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, + unsigned int dw_PCIBoardEepromAddress, + unsigned short w_EepromStartAddress, unsigned short *pw_DataRead) { - DWORD dw_eeprom_busy = 0; - INT i_Counter = 0; - INT i_WordCounter; - INT i; - BYTE pb_ReadByte[1]; - BYTE b_ReadLowByte = 0; - BYTE b_ReadHighByte = 0; - BYTE b_SelectedAddressLow = 0; - BYTE b_SelectedAddressHigh = 0; - WORD w_ReadWord = 0; + unsigned int dw_eeprom_busy = 0; + int i_Counter = 0; + int i_WordCounter; + int i; + unsigned char pb_ReadByte[1]; + unsigned char b_ReadLowByte = 0; + unsigned char b_ReadHighByte = 0; + unsigned char b_SelectedAddressLow = 0; + unsigned char b_SelectedAddressHigh = 0; + unsigned short w_ReadWord = 0; for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead; i_WordCounter++) { @@ -132,106 +132,99 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); for (i_Counter = 0; i_Counter < 2; i_Counter++) { - b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; //Read the low 8 bit part - b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; //Read the high 8 bit part + b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */ + b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */ - //Select the load low address mode + /* Select the load low address mode */ outb(NVCMD_LOAD_LOW, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Load the low address + /* Load the low address */ outb(b_SelectedAddressLow, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the load high address mode + /* Select the load high address mode */ outb(NVCMD_LOAD_HIGH, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Load the high address + /* Load the high address */ outb(b_SelectedAddressHigh, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the READ mode + /* Select the READ mode */ outb(NVCMD_BEGIN_READ, dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 3); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Read data into the EEPROM + /* Read data into the EEPROM */ *pb_ReadByte = inb(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + 2); - //Wait on busy + /* Wait on busy */ do { dw_eeprom_busy = inl(dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR); dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } - while (dw_eeprom_busy == EEPROM_BUSY); + } while (dw_eeprom_busy == EEPROM_BUSY); - //Select the upper address part - if (i_Counter == 0) { + /* Select the upper address part */ + if (i_Counter == 0) b_ReadLowByte = pb_ReadByte[0]; - } else { + else b_ReadHighByte = pb_ReadByte[0]; - } - //Sleep - for (i = 0; i < 10000; i++) ; + + /* Sleep */ + msleep(1); } w_ReadWord = @@ -240,10 +233,10 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, pw_DataRead[i_WordCounter] = w_ReadWord; - w_EepromStartAddress += 2; // to read the next word + w_EepromStartAddress += 2; /* to read the next word */ - } // for (...) i_NbOfWordsToRead - return (0); + } /* for (...) i_NbOfWordsToRead */ + return 0; } /*+----------------------------------------------------------------------------+*/ @@ -258,31 +251,31 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead, /*| Return Value : - |*/ /*+----------------------------------------------------------------------------+*/ -void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, - str_BoardInfos * BoardInformations) +void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress, + struct str_BoardInfos *BoardInformations) { - WORD w_AnalogInputMainHeaderAddress; - WORD w_AnalogInputComponentAddress; - WORD w_NumberOfModuls = 0; - WORD w_CurrentSources[2]; - WORD w_ModulCounter = 0; - WORD w_FirstHeaderSize = 0; - WORD w_NumberOfInputs = 0; - WORD w_CJCFlag = 0; - WORD w_NumberOfGainValue = 0; - WORD w_SingleHeaderAddress = 0; - WORD w_SingleHeaderSize = 0; - WORD w_Input = 0; - WORD w_GainFactorAddress = 0; - WORD w_GainFactorValue[2]; - WORD w_GainIndex = 0; - WORD w_GainValue = 0; + unsigned short w_AnalogInputMainHeaderAddress; + unsigned short w_AnalogInputComponentAddress; + unsigned short w_NumberOfModuls = 0; + unsigned short w_CurrentSources[2]; + unsigned short w_ModulCounter = 0; + unsigned short w_FirstHeaderSize = 0; + unsigned short w_NumberOfInputs = 0; + unsigned short w_CJCFlag = 0; + unsigned short w_NumberOfGainValue = 0; + unsigned short w_SingleHeaderAddress = 0; + unsigned short w_SingleHeaderSize = 0; + unsigned short w_Input = 0; + unsigned short w_GainFactorAddress = 0; + unsigned short w_GainFactorValue[2]; + unsigned short w_GainIndex = 0; + unsigned short w_GainValue = 0; /*****************************************/ /** Get the Analog input header address **/ /*****************************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, 0x116, //w_EepromStartAddress: Analog input header address + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, 0x116, /* w_EepromStartAddress: Analog input header address */ &w_AnalogInputMainHeaderAddress); /*******************************************/ @@ -293,8 +286,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /******************************/ /** Get the number of moduls **/ /******************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02, //w_EepromStartAddress: Number of conponment + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02, /* w_EepromStartAddress: Number of conponment */ &w_NumberOfModuls); for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls; @@ -309,8 +302,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /****************************/ /** Read first header size **/ /****************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress, // Address of the first header + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress, /* Address of the first header */ &w_FirstHeaderSize); w_FirstHeaderSize = w_FirstHeaderSize >> 4; @@ -318,8 +311,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /***************************/ /** Read number of inputs **/ /***************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, // Number of inputs for the first modul + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, /* Number of inputs for the first modul */ &w_NumberOfInputs); w_NumberOfInputs = w_NumberOfInputs >> 4; @@ -327,17 +320,17 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /***********************/ /** Read the CJC flag **/ /***********************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, // CJC flag + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, /* CJC flag */ &w_CJCFlag); - w_CJCFlag = (w_CJCFlag >> 3) & 0x1; // Get only the CJC flag + w_CJCFlag = (w_CJCFlag >> 3) & 0x1; /* Get only the CJC flag */ /*******************************/ /** Read number of gain value **/ /*******************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, // Number of gain value + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, /* Number of gain value */ &w_NumberOfGainValue); w_NumberOfGainValue = w_NumberOfGainValue & 0xFF; @@ -354,8 +347,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /********************************************/ /** Read current sources value for input 1 **/ /********************************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_SingleHeaderAddress, //w_EepromStartAddress: Single header address + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_SingleHeaderAddress, /* w_EepromStartAddress: Single header address */ &w_SingleHeaderSize); w_SingleHeaderSize = w_SingleHeaderSize >> 4; @@ -370,8 +363,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /************************************/ /** Read gain value for the module **/ /************************************/ - i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), // Gain value + i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), /* Gain value */ &w_GainValue); BoardInformations->s_Module[w_ModulCounter]. @@ -386,8 +379,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /*************************************/ /** Read gain factor for the module **/ /*************************************/ - i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), // Gain factor + i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ + dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), /* Gain factor */ w_GainFactorValue); BoardInformations->s_Module[w_ModulCounter]. @@ -409,7 +402,7 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /********************************************/ /** Read current sources value for input 1 **/ /********************************************/ - i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead + i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ dw_PCIBoardEepromAddress, (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C, w_CurrentSources); @@ -432,7 +425,7 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, /***************************************/ /** Read the CJC current source value **/ /***************************************/ - i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead + i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ dw_PCIBoardEepromAddress, (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C, w_CurrentSources); @@ -453,9 +446,9 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress, } } -INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, - unsigned int ui_Channel_num, unsigned int * CJCCurrentSource, - unsigned int * ChannelCurrentSource, unsigned int * ChannelGainFactor) +int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev, + unsigned int ui_Channel_num, unsigned int *CJCCurrentSource, + unsigned int *ChannelCurrentSource, unsigned int *ChannelGainFactor) { int i_DiffChannel = 0; int i_Module = 0; @@ -464,9 +457,9 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, printk("\n Channel = %u", ui_Channel_num); #endif - //Test if single or differential mode + /* Test if single or differential mode */ if (s_BoardInfos[dev->minor].i_ConnectionType == 1) { - //if diff + /* if diff */ if ((ui_Channel_num >= 0) && (ui_Channel_num <= 1)) i_DiffChannel = ui_Channel_num, i_Module = 0; @@ -478,7 +471,7 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, i_DiffChannel = ui_Channel_num - 6, i_Module = 3; } else { - // if single + /* if single */ if ((ui_Channel_num == 0) || (ui_Channel_num == 1)) i_DiffChannel = 0, i_Module = 0; else if ((ui_Channel_num == 2) || (ui_Channel_num == 3)) @@ -497,7 +490,7 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, i_DiffChannel = 1, i_Module = 3; } - //Test if thermocouple or RTD mode + /* Test if thermocouple or RTD mode */ *CJCCurrentSource = s_BoardInfos[dev->minor].s_Module[i_Module].ul_CurrentSourceCJC; #ifdef PRINT_INFO @@ -510,22 +503,22 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, #ifdef PRINT_INFO printk("\n ChannelCurrentSource = %lu", *ChannelCurrentSource); #endif - // } - // } + /* } */ + /* } */ - //Channle gain factor + /* Channle gain factor */ *ChannelGainFactor = s_BoardInfos[dev->minor].s_Module[i_Module]. ul_GainFactor[s_BoardInfos[dev->minor].i_ADDIDATAGain]; #ifdef PRINT_INFO printk("\n ChannelGainFactor = %lu", *ChannelGainFactor); #endif - //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - return (0); + return 0; } -//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ /* +----------------------------------------------------------------------------+ @@ -536,9 +529,9 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT ui_NoOfChannels : No Of Channels To read for Port + | unsigned int ui_NoOfChannels : No Of Channels To read for Port Channel Numberfor single channel - | UINT data[0] : 0: Read single channel + | unsigned int data[0] : 0: Read single channel 1: Read port value data[1] Port number +----------------------------------------------------------------------------+ @@ -550,24 +543,24 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp = 0; - UINT ui_NoOfChannel = 0; + unsigned int ui_Temp = 0; + unsigned int ui_NoOfChannel = 0; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; *data = inl(devpriv->i_IobaseReserved); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } //if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { if (data[1] < 0 || data[1] > 1) { printk("\nThe port number is in error\n"); return -EINVAL; - } //if(data[1] < 0 || data[1] >1) + } /* if(data[1] < 0 || data[1] >1) */ switch (ui_NoOfChannel) { case 2: @@ -578,13 +571,13 @@ INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev break; default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ - } //switch(ui_NoOfChannels) - } //if (ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } //elseif (ui_Temp==1) + } /* elseif (ui_Temp==1) */ } return insn->n; } @@ -608,21 +601,21 @@ INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } //if ( (data[0]!=0) && (data[0]!=1) ) + } /* if ( (data[0]!=0) && (data[0]!=1) ) */ if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } // if (data[0]) + } /* if (data[0]) */ else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } //else if (data[0]) + } /* else if (data[0]) */ return insn->n; } @@ -653,23 +646,23 @@ int i_APCI3200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | | +----------------------------------------------------------------------------+ */ -INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp = 0, ui_Temp1 = 0; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp = 0, ui_Temp1 = 0; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if (devpriv->b_OutputMemoryStatus) { ui_Temp = inl(devpriv->i_IobaseAddon); - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outl(data[0], devpriv->i_IobaseAddon); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -682,15 +675,15 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd case 3: data[0] = (data[0] | ui_Temp); break; - } //switch(ui_NoOfChannels) + } /* switch(ui_NoOfChannels) */ outl(data[0], devpriv->i_IobaseAddon); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -701,7 +694,7 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0] = (data[0] << ui_NoOfChannel) ^ 0xf; data[0] = data[0] & ui_Temp; outl(data[0], devpriv->i_IobaseAddon); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { switch (ui_NoOfChannel) { @@ -725,21 +718,21 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " - } //switch(ui_NoOfChannels) + return -EINVAL; /* "sorry channel spec wrong " */ + } /* switch(ui_NoOfChannels) */ outl(data[0], devpriv->i_IobaseAddon); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ return insn->n; } @@ -752,8 +745,8 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT ui_NoOfChannels : No Of Channels To read | - | UINT *data : Data Pointer to read status | + | unsigned int ui_NoOfChannels : No Of Channels To read | + | unsigned int *data : Data Pointer to read status | data[0] :0 read single channel 1 read port value data[1] port no @@ -766,23 +759,23 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; *data = inl(devpriv->i_IobaseAddon); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } // if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { if (data[1] < 0 || data[1] > 1) { printk("\nThe port selection is in error\n"); return -EINVAL; - } //if(data[1] <0 ||data[1] >1) + } /* if(data[1] <0 ||data[1] >1) */ switch (ui_NoOfChannel) { case 2: *data = (*data >> (2 * data[1])) & 3; @@ -793,20 +786,20 @@ INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde default: comedi_error(dev, " chan spec wrong"); - return -EINVAL; // "sorry channel spec wrong " + return -EINVAL; /* "sorry channel spec wrong " */ break; - } // switch(ui_NoOfChannels) - } // if (ui_Temp==1) + } /* switch(ui_NoOfChannels) */ + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } // else if (ui_Temp==1) - } // else if (ui_Temp==0) + } /* else if (ui_Temp==1) */ + } /* else if (ui_Temp==0) */ return insn->n; } /* +----------------------------------------------------------------------------+ - | Function Name : INT i_APCI3200_ConfigAnalogInput | + | Function Name : int i_APCI3200_ConfigAnalogInput | | (struct comedi_device *dev,struct comedi_subdevice *s, | | struct comedi_insn *insn,unsigned int *data) | +----------------------------------------------------------------------------+ @@ -874,30 +867,30 @@ INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ul_Config = 0, ul_Temp = 0; - UINT ui_ChannelNo = 0; - UINT ui_Dummy = 0; - INT i_err = 0; + unsigned int ul_Config = 0, ul_Temp = 0; + unsigned int ui_ChannelNo = 0; + unsigned int ui_Dummy = 0; + int i_err = 0; - //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ #ifdef PRINT_INFO - INT i = 0, i2 = 0; + int i = 0, i2 = 0; #endif - //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - //BEGIN JK 06.07.04: Management of sevrals boards - // Initialize the structure + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* Initialize the structure */ if (s_BoardInfos[dev->minor].b_StructInitialized != 1) { s_BoardInfos[dev->minor].i_CJCAvailable = 1; s_BoardInfos[dev->minor].i_CJCPolarity = 0; - s_BoardInfos[dev->minor].i_CJCGain = 2; //changed from 0 to 2 + s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */ s_BoardInfos[dev->minor].i_InterruptFlag = 0; - s_BoardInfos[dev->minor].i_AutoCalibration = 0; //: auto calibration + s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */ s_BoardInfos[dev->minor].i_ChannelCount = 0; s_BoardInfos[dev->minor].i_Sum = 0; s_BoardInfos[dev->minor].ui_Channel_num = 0; @@ -905,11 +898,11 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde s_BoardInfos[dev->minor].i_Initialised = 0; s_BoardInfos[dev->minor].b_StructInitialized = 1; - //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ s_BoardInfos[dev->minor].i_ConnectionType = 0; - //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ memset(s_BoardInfos[dev->minor].s_Module, 0, sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE])); @@ -938,72 +931,72 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde } } #endif - //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ } if (data[0] != 0 && data[0] != 1 && data[0] != 2) { printk("\nThe selection of acquisition type is in error\n"); i_err++; - } //if(data[0]!=0 && data[0]!=1 && data[0]!=2) + } /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */ if (data[0] == 1) { if (data[14] != 0 && data[14] != 1 && data[14] != 2 && data[14] != 4) { printk("\n Error in selection of RTD connection type\n"); i_err++; - } //if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) - } //if(data[0]==1 ) + } /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */ + } /* if(data[0]==1 ) */ if (data[1] < 0 || data[1] > 7) { printk("\nThe selection of gain is in error\n"); i_err++; - } // if(data[1]<0 || data[1]>7) + } /* if(data[1]<0 || data[1]>7) */ if (data[2] != 0 && data[2] != 1) { printk("\nThe selection of polarity is in error\n"); i_err++; - } //if(data[2]!=0 && data[2]!=1) + } /* if(data[2]!=0 && data[2]!=1) */ if (data[3] != 0) { printk("\nThe selection of offset range is in error\n"); i_err++; - } // if(data[3]!=0) + } /* if(data[3]!=0) */ if (data[4] != 0 && data[4] != 1) { printk("\nThe selection of coupling is in error\n"); i_err++; - } //if(data[4]!=0 && data[4]!=1) + } /* if(data[4]!=0 && data[4]!=1) */ if (data[5] != 0 && data[5] != 1) { printk("\nThe selection of single/differential mode is in error\n"); i_err++; - } //if(data[5]!=0 && data[5]!=1) + } /* if(data[5]!=0 && data[5]!=1) */ if (data[8] != 0 && data[8] != 1 && data[2] != 2) { printk("\nError in selection of functionality\n"); - } //if(data[8]!=0 && data[8]!=1 && data[2]!=2) + } /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */ if (data[12] == 0 || data[12] == 1) { if (data[6] != 20 && data[6] != 40 && data[6] != 80 && data[6] != 160) { printk("\nThe selection of conversion time reload value is in error\n"); i_err++; - } // if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) + } /* if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */ if (data[7] != 2) { printk("\nThe selection of conversion time unit is in error\n"); i_err++; - } // if(data[7]!=2) + } /* if(data[7]!=2) */ } if (data[9] != 0 && data[9] != 1) { printk("\nThe selection of interrupt enable is in error\n"); i_err++; - } //if(data[9]!=0 && data[9]!=1) + } /* if(data[9]!=0 && data[9]!=1) */ if (data[11] < 0 || data[11] > 4) { printk("\nThe selection of module is in error\n"); i_err++; - } //if(data[11] <0 || data[11]>1) + } /* if(data[11] <0 || data[11]>1) */ if (data[12] < 0 || data[12] > 3) { printk("\nThe selection of singlechannel/scan selection is in error\n"); i_err++; - } //if(data[12] < 0 || data[12]> 3) + } /* if(data[12] < 0 || data[12]> 3) */ if (data[13] < 0 || data[13] > 16) { printk("\nThe selection of number of channels is in error\n"); i_err++; - } // if(data[13] <0 ||data[13] >15) + } /* if(data[13] <0 ||data[13] >15) */ - //BEGIN JK 06.07.04: Management of sevrals boards + /* BEGIN JK 06.07.04: Management of sevrals boards */ /* i_ChannelCount=data[13]; i_ScanType=data[12]; @@ -1014,7 +1007,7 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde i_ADDIDATAType=data[0]; */ - // Save acquisition configuration for the actual board + /* Save acquisition configuration for the actual board */ s_BoardInfos[dev->minor].i_ChannelCount = data[13]; s_BoardInfos[dev->minor].i_ScanType = data[12]; s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2]; @@ -1022,307 +1015,307 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6]; s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7]; s_BoardInfos[dev->minor].i_ADDIDATAType = data[0]; - //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ s_BoardInfos[dev->minor].i_ConnectionType = data[5]; - //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //END JK 06.07.04: Management of sevrals boards + /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* END JK 06.07.04: Management of sevrals boards */ - //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); // 7 is the maximal number of channels - //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /* 7 is the maximal number of channels */ + /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - //BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards - //while(i_InterruptFlag==1) + /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */ + /* while(i_InterruptFlag==1) */ while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { #ifndef MSXBOX udelay(1); #else - // In the case where the driver is compiled for the MSX-Box - // we used a printk to have a little delay because udelay - // seems to be broken under the MSX-Box. - // This solution hat to be studied. + /* In the case where the driver is compiled for the MSX-Box */ + /* we used a printk to have a little delay because udelay */ + /* seems to be broken under the MSX-Box. */ + /* This solution hat to be studied. */ printk(""); #endif } - //END JK 02.07.04 : This while can't be do, it block the process when using severals boards + /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */ - ui_ChannelNo = CR_CHAN(insn->chanspec); // get the channel - //BEGIN JK 06.07.04: Management of sevrals boards - //i_ChannelNo=ui_ChannelNo; - //ui_Channel_num =ui_ChannelNo; + ui_ChannelNo = CR_CHAN(insn->chanspec); /* get the channel */ + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_ChannelNo=ui_ChannelNo; */ + /* ui_Channel_num =ui_ChannelNo; */ s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo; s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ if (data[5] == 0) { if (ui_ChannelNo < 0 || ui_ChannelNo > 15) { printk("\nThe Selection of the channel is in error\n"); i_err++; - } // if(ui_ChannelNo<0 || ui_ChannelNo>15) - } //if(data[5]==0) + } /* if(ui_ChannelNo<0 || ui_ChannelNo>15) */ + } /* if(data[5]==0) */ else { if (data[14] == 2) { if (ui_ChannelNo < 0 || ui_ChannelNo > 3) { printk("\nThe Selection of the channel is in error\n"); i_err++; - } // if(ui_ChannelNo<0 || ui_ChannelNo>3) - } //if(data[14]==2) + } /* if(ui_ChannelNo<0 || ui_ChannelNo>3) */ + } /* if(data[14]==2) */ else { if (ui_ChannelNo < 0 || ui_ChannelNo > 7) { printk("\nThe Selection of the channel is in error\n"); i_err++; - } // if(ui_ChannelNo<0 || ui_ChannelNo>7) - } //elseif(data[14]==2) - } //elseif(data[5]==0) + } /* if(ui_ChannelNo<0 || ui_ChannelNo>7) */ + } /* elseif(data[14]==2) */ + } /* elseif(data[5]==0) */ if (data[12] == 0 || data[12] == 1) { switch (data[5]) { case 0: if (ui_ChannelNo >= 0 && ui_ChannelNo <= 3) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=0; */ s_BoardInfos[dev->minor].i_Offset = 0; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo >=0 && ui_ChannelNo <=3) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo >=0 && ui_ChannelNo <=3) */ if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=64; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=64; */ s_BoardInfos[dev->minor].i_Offset = 64; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo >=4 && ui_ChannelNo <=7) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */ if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=128; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=128; */ s_BoardInfos[dev->minor].i_Offset = 128; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo >=8 && ui_ChannelNo <=11) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */ if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=192; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=192; */ s_BoardInfos[dev->minor].i_Offset = 192; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo >=12 && ui_ChannelNo <=15) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */ break; case 1: if (data[14] == 2) { if (ui_ChannelNo == 0) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=0; */ s_BoardInfos[dev->minor].i_Offset = 0; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo ==0 ) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo ==0 ) */ if (ui_ChannelNo == 1) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=0; */ s_BoardInfos[dev->minor].i_Offset = 64; - //END JK 06.07.04: Management of sevrals boards - } // if(ui_ChannelNo ==1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo ==1) */ if (ui_ChannelNo == 2) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=128; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=128; */ s_BoardInfos[dev->minor].i_Offset = 128; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo ==2 ) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo ==2 ) */ if (ui_ChannelNo == 3) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=192; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=192; */ s_BoardInfos[dev->minor].i_Offset = 192; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo ==3) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo ==3) */ - //BEGIN JK 06.07.04: Management of sevrals boards - //i_ChannelNo=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_ChannelNo=0; */ s_BoardInfos[dev->minor].i_ChannelNo = 0; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ ui_ChannelNo = 0; break; - } //if(data[14]==2) + } /* if(data[14]==2) */ if (ui_ChannelNo >= 0 && ui_ChannelNo <= 1) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=0; */ s_BoardInfos[dev->minor].i_Offset = 0; - //END JK 06.07.04: Management of sevrals boards - } //if(ui_ChannelNo >=0 && ui_ChannelNo <=1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(ui_ChannelNo >=0 && ui_ChannelNo <=1) */ if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_ChannelNo=i_ChannelNo-2; - //i_Offset=64; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_ChannelNo=i_ChannelNo-2; */ + /* i_Offset=64; */ s_BoardInfos[dev->minor].i_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo - 2; s_BoardInfos[dev->minor].i_Offset = 64; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ ui_ChannelNo = ui_ChannelNo - 2; - } //if(ui_ChannelNo >=2 && ui_ChannelNo <=3) + } /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */ if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_ChannelNo=i_ChannelNo-4; - //i_Offset=128; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_ChannelNo=i_ChannelNo-4; */ + /* i_Offset=128; */ s_BoardInfos[dev->minor].i_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo - 4; s_BoardInfos[dev->minor].i_Offset = 128; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ ui_ChannelNo = ui_ChannelNo - 4; - } //if(ui_ChannelNo >=4 && ui_ChannelNo <=5) + } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */ if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_ChannelNo=i_ChannelNo-6; - //i_Offset=192; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_ChannelNo=i_ChannelNo-6; */ + /* i_Offset=192; */ s_BoardInfos[dev->minor].i_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo - 6; s_BoardInfos[dev->minor].i_Offset = 192; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ ui_ChannelNo = ui_ChannelNo - 6; - } //if(ui_ChannelNo >=6 && ui_ChannelNo <=7) + } /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */ break; default: printk("\n This selection of polarity does not exist\n"); i_err++; - } //switch(data[2]) - } //if(data[12]==0 || data[12]==1) + } /* switch(data[2]) */ + } /* if(data[12]==0 || data[12]==1) */ else { switch (data[11]) { case 1: - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=0; */ s_BoardInfos[dev->minor].i_Offset = 0; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ break; case 2: - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=64; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=64; */ s_BoardInfos[dev->minor].i_Offset = 64; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ break; case 3: - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=128; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=128; */ s_BoardInfos[dev->minor].i_Offset = 128; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ break; case 4: - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Offset=192; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Offset=192; */ s_BoardInfos[dev->minor].i_Offset = 192; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ break; default: printk("\nError in module selection\n"); i_err++; - } // switch(data[11]) - } // elseif(data[12]==0 || data[12]==1) + } /* switch(data[11]) */ + } /* elseif(data[12]==0 || data[12]==1) */ if (i_err) { i_APCI3200_Reset(dev); return -EINVAL; } - //if(i_ScanType!=1) + /* if(i_ScanType!=1) */ if (s_BoardInfos[dev->minor].i_ScanType != 1) { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Count=0; - //i_Sum=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Count=0; */ + /* i_Sum=0; */ s_BoardInfos[dev->minor].i_Count = 0; s_BoardInfos[dev->minor].i_Sum = 0; - //END JK 06.07.04: Management of sevrals boards - } //if(i_ScanType!=1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(i_ScanType!=1) */ ul_Config = data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) | (data[4] << 9); - //BEGIN JK 06.07.04: Management of sevrals boards - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ /*********************************/ /* Write the channel to configure */ /*********************************/ - //BEGIN JK 06.07.04: Management of sevrals boards - //outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */ outl(0 | ui_ChannelNo, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //BEGIN JK 06.07.04: Management of sevrals boards - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ /**************************/ /* Reset the configuration */ /**************************/ - //BEGIN JK 06.07.04: Management of sevrals boards - //outl(0 , devpriv->iobase+i_Offset + 0x0); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* outl(0 , devpriv->iobase+i_Offset + 0x0); */ outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //BEGIN JK 06.07.04: Management of sevrals boards - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ /***************************/ /* Write the configuration */ /***************************/ - //BEGIN JK 06.07.04: Management of sevrals boards - //outl(ul_Config , devpriv->iobase+i_Offset + 0x0); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */ outl(ul_Config, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ /***************************/ /*Reset the calibration bit */ /***************************/ - //BEGIN JK 06.07.04: Management of sevrals boards - //ul_Temp = inl(devpriv->iobase+i_Offset + 12); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */ ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //BEGIN JK 06.07.04: Management of sevrals boards - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //BEGIN JK 06.07.04: Management of sevrals boards - //outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */ outl((ul_Temp & 0xFFF9FFFF), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ if (data[9] == 1) { devpriv->tsk_Current = current; - //BEGIN JK 06.07.04: Management of sevrals boards - //i_InterruptFlag=1; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_InterruptFlag=1; */ s_BoardInfos[dev->minor].i_InterruptFlag = 1; - //END JK 06.07.04: Management of sevrals boards - } // if(data[9]==1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(data[9]==1) */ else { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_InterruptFlag=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_InterruptFlag=0; */ s_BoardInfos[dev->minor].i_InterruptFlag = 0; - //END JK 06.07.04: Management of sevrals boards - } //else if(data[9]==1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* else if(data[9]==1) */ - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Initialised=1; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Initialised=1; */ s_BoardInfos[dev->minor].i_Initialised = 1; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //BEGIN JK 06.07.04: Management of sevrals boards - //if(i_ScanType==1) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if(i_ScanType==1) */ if (s_BoardInfos[dev->minor].i_ScanType == 1) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { - //BEGIN JK 06.07.04: Management of sevrals boards - //i_Sum=i_Sum+1; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* i_Sum=i_Sum+1; */ s_BoardInfos[dev->minor].i_Sum = s_BoardInfos[dev->minor].i_Sum + 1; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ insn->unused[0] = 0; i_APCI3200_ReadAnalogInput(dev, s, insn, &ui_Dummy); @@ -1340,8 +1333,8 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde | Task : Read value of the selected channel | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT ui_NoOfChannels : No Of Channels To read | - | UINT *data : Data Pointer to read status | + | unsigned int ui_NoOfChannels : No Of Channels To read | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : Digital Value Of Input | @@ -1361,21 +1354,21 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_DummyValue = 0; + unsigned int ui_DummyValue = 0; int i_ConvertCJCCalibration; int i = 0; - //BEGIN JK 06.07.04: Management of sevrals boards - //if(i_Initialised==0) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if(i_Initialised==0) */ if (s_BoardInfos[dev->minor].i_Initialised == 0) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { i_APCI3200_Reset(dev); return -EINVAL; - } //if(i_Initialised==0); + } /* if(i_Initialised==0); */ #ifdef PRINT_INFO printk("\n insn->unused[0] = %i", insn->unused[0]); @@ -1386,14 +1379,14 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi i_APCI3200_Read1AnalogInputChannel(dev, s, insn, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos[dev->minor]. i_Count + 0] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - //Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ i_APCI3200_GetChannelCalibrationValue(dev, s_BoardInfos[dev->minor].ui_Channel_num, &s_BoardInfos[dev->minor]. @@ -1414,62 +1407,62 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 8]); #endif - //End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - //BEGIN JK 06.07.04: Management of sevrals boards - //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */ if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2) && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE) && (s_BoardInfos[dev->minor].i_CJCAvailable == 1)) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { i_APCI3200_ReadCJCValue(dev, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos[dev-> minor].i_Count + 3] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards - } //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */ else { - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count + 3]=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count + 3]=0; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos[dev-> minor].i_Count + 3] = 0; - //END JK 06.07.04: Management of sevrals boards - } //elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) + /* END JK 06.07.04: Management of sevrals boards */ + } /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */ - //BEGIN JK 06.07.04: Management of sevrals boards - //if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */ if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { i_APCI3200_ReadCalibrationOffsetValue(dev, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos[dev-> minor].i_Count + 1] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ i_APCI3200_ReadCalibrationGainValue(dev, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos[dev-> minor].i_Count + 2] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards - } //if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */ - //BEGIN JK 06.07.04: Management of sevrals boards - //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */ if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2) && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE) && (s_BoardInfos[dev->minor].i_CJCAvailable == 1)) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { /**********************************************************/ /*Test if the Calibration channel must be read for the CJC */ @@ -1477,52 +1470,52 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi /**********************************/ /*Test if the polarity is the same */ /**********************************/ - //BEGIN JK 06.07.04: Management of sevrals boards - //if(i_CJCPolarity!=i_ADDIDATAPolarity) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ if (s_BoardInfos[dev->minor].i_CJCPolarity != s_BoardInfos[dev->minor].i_ADDIDATAPolarity) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { i_ConvertCJCCalibration = 1; - } //if(i_CJCPolarity!=i_ADDIDATAPolarity) + } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ else { - //BEGIN JK 06.07.04: Management of sevrals boards - //if(i_CJCGain==i_ADDIDATAGain) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if(i_CJCGain==i_ADDIDATAGain) */ if (s_BoardInfos[dev->minor].i_CJCGain == s_BoardInfos[dev->minor].i_ADDIDATAGain) - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ { i_ConvertCJCCalibration = 0; - } //if(i_CJCGain==i_ADDIDATAGain) + } /* if(i_CJCGain==i_ADDIDATAGain) */ else { i_ConvertCJCCalibration = 1; - } //elseif(i_CJCGain==i_ADDIDATAGain) - } //elseif(i_CJCPolarity!=i_ADDIDATAPolarity) + } /* elseif(i_CJCGain==i_ADDIDATAGain) */ + } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */ if (i_ConvertCJCCalibration == 1) { i_APCI3200_ReadCJCCalOffset(dev, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 4] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue); - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 5] = ui_DummyValue; - //END JK 06.07.04: Management of sevrals boards - } //if(i_ConvertCJCCalibration==1) + /* END JK 06.07.04: Management of sevrals boards */ + } /* if(i_ConvertCJCCalibration==1) */ else { - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_InterruptChannelValue[i_Count+4]=0; - //ui_InterruptChannelValue[i_Count+5]=0; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_InterruptChannelValue[i_Count+4]=0; */ + /* ui_InterruptChannelValue[i_Count+5]=0; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos @@ -1530,36 +1523,36 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi s_BoardInfos[dev->minor]. ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 5] = 0; - //END JK 06.07.04: Management of sevrals boards - } //elseif(i_ConvertCJCCalibration==1) - } //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) + /* END JK 06.07.04: Management of sevrals boards */ + } /* elseif(i_ConvertCJCCalibration==1) */ + } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */ - //BEGIN JK 06.07.04: Management of sevrals boards - //if(i_ScanType!=1) + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* if(i_ScanType!=1) */ if (s_BoardInfos[dev->minor].i_ScanType != 1) { - //i_Count=0; + /* i_Count=0; */ s_BoardInfos[dev->minor].i_Count = 0; - } //if(i_ScanType!=1) + } /* if(i_ScanType!=1) */ else { - //i_Count=i_Count +6; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; + /* i_Count=i_Count +6; */ + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */ s_BoardInfos[dev->minor].i_Count = s_BoardInfos[dev->minor].i_Count + 9; - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - } //else if(i_ScanType!=1) + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + } /* else if(i_ScanType!=1) */ - //if((i_ScanType==1) &&(i_InterruptFlag==1)) + /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */ if ((s_BoardInfos[dev->minor].i_ScanType == 1) && (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) { - //i_Count=i_Count-6; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; + /* i_Count=i_Count-6; */ + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */ s_BoardInfos[dev->minor].i_Count = s_BoardInfos[dev->minor].i_Count - 9; - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ } - //if(i_ScanType==0) + /* if(i_ScanType==0) */ if (s_BoardInfos[dev->minor].i_ScanType == 0) { /* data[0]= ui_InterruptChannelValue[0]; @@ -1591,41 +1584,41 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi s_BoardInfos[dev->minor]. ui_InterruptChannelValue[5]; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - //printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + /* printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); */ i_APCI3200_GetChannelCalibrationValue(dev, s_BoardInfos[dev->minor].ui_Channel_num, &data[6], &data[7], &data[8]); - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ } break; case 1: for (i = 0; i < insn->n; i++) { - //data[i]=ui_InterruptChannelValue[i]; + /* data[i]=ui_InterruptChannelValue[i]; */ data[i] = s_BoardInfos[dev->minor]. ui_InterruptChannelValue[i]; } - //i_Count=0; - //i_Sum=0; - //if(i_ScanType==1) + /* i_Count=0; */ + /* i_Sum=0; */ + /* if(i_ScanType==1) */ s_BoardInfos[dev->minor].i_Count = 0; s_BoardInfos[dev->minor].i_Sum = 0; if (s_BoardInfos[dev->minor].i_ScanType == 1) { - //i_Initialised=0; - //i_InterruptFlag=0; + /* i_Initialised=0; */ + /* i_InterruptFlag=0; */ s_BoardInfos[dev->minor].i_Initialised = 0; s_BoardInfos[dev->minor].i_InterruptFlag = 0; - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ } break; default: printk("\nThe parameters passed are in error\n"); i_APCI3200_Reset(dev); return -EINVAL; - } //switch(insn->unused[0]) + } /* switch(insn->unused[0]) */ return insn->n; } @@ -1639,8 +1632,8 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi | Task : Read value of the selected channel | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT ui_NoOfChannel : Channel No to read | - | UINT *data : Data Pointer to read status | + | unsigned int ui_NoOfChannel : Channel No to read | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : Digital Value read | @@ -1651,49 +1644,49 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi | | +----------------------------------------------------------------------------+ */ -INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - UINT ui_EOC = 0; - UINT ui_ChannelNo = 0; - UINT ui_CommandRegister = 0; + unsigned int ui_EOC = 0; + unsigned int ui_ChannelNo = 0; + unsigned int ui_CommandRegister = 0; - //BEGIN JK 06.07.04: Management of sevrals boards - //ui_ChannelNo=i_ChannelNo; + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* ui_ChannelNo=i_ChannelNo; */ ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo; - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; /*********************************/ /* Write the channel to configure */ /*********************************/ - //Begin JK 20.10.2004: Bad channel value is used when using differential mode - //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); - //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); + /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */ + /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ + /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ outl(0 | s_BoardInfos[dev->minor].i_ChannelNo, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4); - //End JK 20.10.2004: Bad channel value is used when using differential mode + /* End JK 20.10.2004: Bad channel value is used when using differential mode */ /*******************************/ /* Set the convert timing unit */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); @@ -1707,36 +1700,36 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev, /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /************************/ /* Enable the interrupt */ /************************/ ui_CommandRegister = ui_CommandRegister | 0x00100000; - } //if (i_InterruptFlag == ADDIDATA_ENABLE) + } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ /******************************/ /* Write the command register */ /******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); /*****************************/ /*Test if interrupt is enable */ /*****************************/ - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { /*************************/ /*Read the EOC Status bit */ /*************************/ - //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; @@ -1746,13 +1739,13 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev, /* Read the digital value of the input */ /***************************************/ - //data[0] = inl (devpriv->iobase+i_Offset + 28); + /* data[0] = inl (devpriv->iobase+i_Offset + 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - //END JK 06.07.04: Management of sevrals boards + /* END JK 06.07.04: Management of sevrals boards */ - } // if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -1765,7 +1758,7 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev, | Task : Read calibration offset value of the selected channel| +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT *data : Data Pointer to read status | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : Calibration offset Value | @@ -1776,54 +1769,54 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev, | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * data) +int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data) { - UINT ui_Temp = 0, ui_EOC = 0; - UINT ui_CommandRegister = 0; + unsigned int ui_Temp = 0, ui_EOC = 0; + unsigned int ui_CommandRegister = 0; - //BEGIN JK 06.07.04: Management of sevrals boards - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* BEGIN JK 06.07.04: Management of sevrals boards */ + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; /*********************************/ /* Write the channel to configure */ /*********************************/ - //Begin JK 20.10.2004: This seems not necessary ! - //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); - //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); - //End JK 20.10.2004: This seems not necessary ! + /* Begin JK 20.10.2004: This seems not necessary ! */ + /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ + /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ + /* End JK 20.10.2004: This seems not necessary ! */ /*******************************/ /* Set the convert timing unit */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /*****************************/ /*Read the calibration offset */ /*****************************/ - //ui_Temp = inl(devpriv->iobase+i_Offset + 12); + /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */ ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); /*********************************/ /*Configure the Offset Conversion */ /*********************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); + /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */ outl((ui_Temp | 0x00020000), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); /*******************************/ @@ -1836,7 +1829,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /**********************/ @@ -1845,7 +1838,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat ui_CommandRegister = ui_CommandRegister | 0x00100000; - } //if (i_InterruptFlag == ADDIDATA_ENABLE) + } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ /**********************/ /*Start the conversion */ @@ -1855,10 +1848,10 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat /***************************/ /*Write the command regiter */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); @@ -1866,7 +1859,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat /*Test if interrupt is enable */ /*****************************/ - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { @@ -1874,7 +1867,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat /*Read the EOC flag */ /*******************/ - //ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; @@ -1884,11 +1877,11 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat /*Read the digital value of the calibration Offset */ /**************************************************/ - //data[0] = inl(devpriv->iobase+i_Offset+ 28); + /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - } //if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -1901,7 +1894,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat | Task : Read calibration gain value of the selected channel | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT *data : Data Pointer to read status | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : Calibration gain Value Of Input | @@ -1912,21 +1905,21 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) +int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data) { - UINT ui_EOC = 0; - INT ui_CommandRegister = 0; + unsigned int ui_EOC = 0; + int ui_CommandRegister = 0; - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; /*********************************/ /* Write the channel to configure */ /*********************************/ - //Begin JK 20.10.2004: This seems not necessary ! - //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); - //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); - //End JK 20.10.2004: This seems not necessary ! + /* Begin JK 20.10.2004: This seems not necessary ! */ + /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ + /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ + /* End JK 20.10.2004: This seems not necessary ! */ /***************************/ /*Read the calibration gain */ @@ -1934,28 +1927,28 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /*******************************/ /* Set the convert timing unit */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /*******************************/ /*Configure the Gain Conversion */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(0x00040000 , devpriv->iobase+i_Offset + 12); + /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */ outl(0x00040000, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); @@ -1969,7 +1962,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /**********************/ @@ -1978,7 +1971,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) ui_CommandRegister = ui_CommandRegister | 0x00100000; - } //if (i_InterruptFlag == ADDIDATA_ENABLE) + } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ /**********************/ /*Start the conversion */ @@ -1988,10 +1981,10 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /***************************/ /*Write the command regiter */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); @@ -1999,7 +1992,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /*Test if interrupt is enable */ /*****************************/ - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { @@ -2008,7 +2001,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /*Read the EOC flag */ /*******************/ - //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; @@ -2018,12 +2011,12 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) /*Read the digital value of the calibration Gain */ /************************************************/ - //data[0] = inl(devpriv->iobase+i_Offset + 28); + /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - } //if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -2036,7 +2029,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) | Task : Read CJC value of the selected channel | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT *data : Data Pointer to read status | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : CJC Value | @@ -2048,41 +2041,41 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data) +----------------------------------------------------------------------------+ */ -int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) +int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data) { - UINT ui_EOC = 0; - INT ui_CommandRegister = 0; + unsigned int ui_EOC = 0; + int ui_CommandRegister = 0; /******************************/ /*Set the converting time unit */ /******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /******************************/ /*Configure the CJC Conversion */ /******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl( 0x00000400 , devpriv->iobase+i_Offset + 4); + /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */ outl(0x00000400, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); /*******************************/ @@ -2092,7 +2085,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) /*********************************/ /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /**********************/ /*Enable the interrupt */ @@ -2109,10 +2102,10 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) /***************************/ /*Write the command regiter */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); @@ -2120,7 +2113,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) /*Test if interrupt is enable */ /*****************************/ - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { @@ -2128,7 +2121,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) /*Read the EOC flag */ /*******************/ - //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; @@ -2138,12 +2131,12 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) /*Read the digital value of the CJC */ /***********************************/ - //data[0] = inl(devpriv->iobase+i_Offset + 28); + /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - } //if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -2156,7 +2149,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) | Task : Read CJC calibration offset value of the selected channel +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT *data : Data Pointer to read status | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : CJC calibration offset Value @@ -2167,47 +2160,47 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data) | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) +int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data) { - UINT ui_EOC = 0; - INT ui_CommandRegister = 0; + unsigned int ui_EOC = 0; + int ui_CommandRegister = 0; /*******************************************/ /*Read calibration offset value for the CJC */ /*******************************************/ /*******************************/ /* Set the convert timing unit */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /******************************/ /*Configure the CJC Conversion */ /******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(0x00000400 , devpriv->iobase+i_Offset + 4); + /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */ outl(0x00000400, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); /*********************************/ /*Configure the Offset Conversion */ /*********************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(0x00020000, devpriv->iobase+i_Offset + 12); + /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */ outl(0x00020000, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); /*******************************/ @@ -2218,7 +2211,7 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /**********************/ /*Enable the interrupt */ @@ -2234,19 +2227,19 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) /***************************/ /*Write the command regiter */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { /*******************/ /*Read the EOC flag */ /*******************/ - //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; } while (ui_EOC != 1); @@ -2254,11 +2247,11 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) /**************************************************/ /*Read the digital value of the calibration Offset */ /**************************************************/ - //data[0] = inl(devpriv->iobase+i_Offset + 28); + /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - } //if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -2271,8 +2264,8 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) | Task : Read CJC calibration gain value +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | - | UINT ui_NoOfChannels : No Of Channels To read | - | UINT *data : Data Pointer to read status | + | unsigned int ui_NoOfChannels : No Of Channels To read | + | unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | | data[0] : CJC calibration gain value @@ -2283,44 +2276,44 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data) | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data) +int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, unsigned int *data) { - UINT ui_EOC = 0; - INT ui_CommandRegister = 0; + unsigned int ui_EOC = 0; + int ui_CommandRegister = 0; /*******************************/ /* Set the convert timing unit */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); + /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /**************************/ /* Set the convert timing */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); + /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /******************************/ /*Configure the CJC Conversion */ /******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(0x00000400,devpriv->iobase+i_Offset + 4); + /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */ outl(0x00000400, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); /*******************************/ /*Configure the Gain Conversion */ /*******************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(0x00040000,devpriv->iobase+i_Offset + 12); + /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */ outl(0x00040000, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); @@ -2331,7 +2324,7 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data) /*********************************/ /*Test if the interrupt is enable */ /*********************************/ - //if (i_InterruptFlag == ADDIDATA_ENABLE) + /* if (i_InterruptFlag == ADDIDATA_ENABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) { /**********************/ /*Enable the interrupt */ @@ -2345,30 +2338,30 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data) /***************************/ /*Write the command regiter */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); + /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */ outl(ui_CommandRegister, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - //if (i_InterruptFlag == ADDIDATA_DISABLE) + /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) { do { /*******************/ /*Read the EOC flag */ /*******************/ - //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; + /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ ui_EOC = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 20) & 1; } while (ui_EOC != 1); /************************************************/ /*Read the digital value of the calibration Gain */ /************************************************/ - //data[0] = inl (devpriv->iobase+i_Offset + 28); + /* data[0] = inl (devpriv->iobase+i_Offset + 28); */ data[0] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - } //if (i_InterruptFlag == ADDIDATA_DISABLE) + } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */ return 0; } @@ -2404,33 +2397,33 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data) +----------------------------------------------------------------------------+ */ -INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - UINT ui_Configuration = 0; - INT i_Temp; //,i_TimeUnit; - //if(i_Initialised==0) + unsigned int ui_Configuration = 0; + int i_Temp; /* ,i_TimeUnit; */ + /* if(i_Initialised==0) */ if (s_BoardInfos[dev->minor].i_Initialised == 0) { i_APCI3200_Reset(dev); return -EINVAL; - } //if(i_Initialised==0); + } /* if(i_Initialised==0); */ if (data[0] != 0 && data[0] != 1) { printk("\nError in selection of functionality\n"); i_APCI3200_Reset(dev); return -EINVAL; - } //if(data[0]!=0 && data[0]!=1) + } /* if(data[0]!=0 && data[0]!=1) */ - if (data[0] == 1) //Perform Short Circuit TEST + if (data[0] == 1) /* Perform Short Circuit TEST */ { /**************************/ /*Set the short-cicuit bit */ /**************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. i_Offset + 12) >> 19) & 1) != 1) ; - //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); + /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ outl((0x00001000 | s_BoardInfos[dev->minor].i_ChannelNo), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); @@ -2439,19 +2432,19 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, /*************************/ /* i_TimeUnit= i_ADDIDATAConversionTimeUnit; i_ADDIDATAConversionTimeUnit= 1; */ - //i_Temp= i_InterruptFlag ; + /* i_Temp= i_InterruptFlag ; */ i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag; - //i_InterruptFlag = ADDIDATA_DISABLE; + /* i_InterruptFlag = ADDIDATA_DISABLE; */ s_BoardInfos[dev->minor].i_InterruptFlag = ADDIDATA_DISABLE; i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data); - //if(i_AutoCalibration == FALSE) + /* if(i_AutoCalibration == FALSE) */ if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) { - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. i_Offset + 12) >> 19) & 1) != 1) ; - //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); + /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ outl((0x00001000 | s_BoardInfos[dev->minor]. i_ChannelNo), devpriv->iobase + @@ -2462,15 +2455,15 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, i_APCI3200_ReadCalibrationGainValue(dev, data); } } else { - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. i_Offset + 12) >> 19) & 1) != 1) ; - //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); + /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ outl((0x00000800 | s_BoardInfos[dev->minor].i_ChannelNo), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - //ui_Configuration = inl(devpriv->iobase+i_Offset + 0); + /* ui_Configuration = inl(devpriv->iobase+i_Offset + 0); */ ui_Configuration = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0); @@ -2479,18 +2472,18 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, /*************************/ /* i_TimeUnit= i_ADDIDATAConversionTimeUnit; i_ADDIDATAConversionTimeUnit= 1; */ - //i_Temp= i_InterruptFlag ; + /* i_Temp= i_InterruptFlag ; */ i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag; - //i_InterruptFlag = ADDIDATA_DISABLE; + /* i_InterruptFlag = ADDIDATA_DISABLE; */ s_BoardInfos[dev->minor].i_InterruptFlag = ADDIDATA_DISABLE; i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data); - //if(i_AutoCalibration == FALSE) + /* if(i_AutoCalibration == FALSE) */ if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) { - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. i_Offset + 12) >> 19) & 1) != 1) ; - //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); + /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ outl((0x00000800 | s_BoardInfos[dev->minor]. i_ChannelNo), devpriv->iobase + @@ -2501,9 +2494,9 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, i_APCI3200_ReadCalibrationGainValue(dev, data); } } - //i_InterruptFlag=i_Temp ; + /* i_InterruptFlag=i_Temp ; */ s_BoardInfos[dev->minor].i_InterruptFlag = i_Temp; - //printk("\ni_InterruptFlag=%d\n",i_InterruptFlag); + /* printk("\ni_InterruptFlag=%d\n",i_InterruptFlag); */ return insn->n; } @@ -2529,8 +2522,8 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { i_APCI3200_Reset(dev); return insn->n; @@ -2560,23 +2553,23 @@ INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; - int tmp; // divisor1,divisor2; - UINT ui_ConvertTime = 0; - UINT ui_ConvertTimeBase = 0; - UINT ui_DelayTime = 0; - UINT ui_DelayTimeBase = 0; - INT i_Triggermode = 0; - INT i_TriggerEdge = 0; - INT i_NbrOfChannel = 0; - INT i_Cpt = 0; + int tmp; /* divisor1,divisor2; */ + unsigned int ui_ConvertTime = 0; + unsigned int ui_ConvertTimeBase = 0; + unsigned int ui_DelayTime = 0; + unsigned int ui_DelayTimeBase = 0; + int i_Triggermode = 0; + int i_TriggerEdge = 0; + int i_NbrOfChannel = 0; + int i_Cpt = 0; double d_ConversionTimeForAllChannels = 0.0; double d_SCANTimeNewUnit = 0.0; - // step 1: make sure trigger sources are trivially valid + /* step 1: make sure trigger sources are trivially valid */ tmp = cmd->start_src; cmd->start_src &= TRIG_NOW | TRIG_EXT; @@ -2598,10 +2591,10 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ cmd->stop_src &= TRIG_COUNT | TRIG_NONE; if (!cmd->stop_src || tmp != cmd->stop_src) err++; - //if(i_InterruptFlag==0) + /* if(i_InterruptFlag==0) */ if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { err++; - // printk("\nThe interrupt should be enabled\n"); + /* printk("\nThe interrupt should be enabled\n"); */ } if (err) { i_APCI3200_Reset(dev); @@ -2643,9 +2636,9 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ i_APCI3200_Reset(dev); return 2; } - //i_FirstChannel=cmd->chanlist[0]; + /* i_FirstChannel=cmd->chanlist[0]; */ s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0]; - //i_LastChannel=cmd->chanlist[1]; + /* i_LastChannel=cmd->chanlist[1]; */ s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1]; if (cmd->convert_src == TRIG_TIMER) { @@ -2656,11 +2649,11 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ { printk("\nThe selection of conversion time reload value is in error\n"); err++; - } // if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) + } /* if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) */ if (ui_ConvertTimeBase != 2) { printk("\nThe selection of conversion time unit is in error\n"); err++; - } //if(ui_ConvertTimeBase!=2) + } /* if(ui_ConvertTimeBase!=2) */ } else { ui_ConvertTime = 0; ui_ConvertTimeBase = 0; @@ -2668,7 +2661,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ if (cmd->scan_begin_src == TRIG_FOLLOW) { ui_DelayTime = 0; ui_DelayTimeBase = 0; - } //if(cmd->scan_begin_src==TRIG_FOLLOW) + } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */ else { ui_DelayTime = cmd->scan_begin_arg & 0xFFFF; ui_DelayTimeBase = cmd->scan_begin_arg >> 16; @@ -2686,7 +2679,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ } fpu_begin(); d_SCANTimeNewUnit = (double)ui_DelayTime; - //i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4; + /* i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4; */ i_NbrOfChannel = s_BoardInfos[dev->minor].i_LastChannel - s_BoardInfos[dev->minor].i_FirstChannel + 4; @@ -2736,7 +2729,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ err++; } fpu_end(); - } //else if(cmd->scan_begin_src==TRIG_FOLLOW) + } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */ if (err) { i_APCI3200_Reset(dev); @@ -2764,13 +2757,13 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_ +----------------------------------------------------------------------------+ */ -int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_subdevice * s) +int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s) { - UINT ui_Configuration = 0; - //i_InterruptFlag=0; - //i_Initialised=0; - //i_Count=0; - //i_Sum=0; + unsigned int ui_Configuration = 0; + /* i_InterruptFlag=0; */ + /* i_Initialised=0; */ + /* i_Count=0; */ + /* i_Sum=0; */ s_BoardInfos[dev->minor].i_InterruptFlag = 0; s_BoardInfos[dev->minor].i_Initialised = 0; s_BoardInfos[dev->minor].i_Count = 0; @@ -2779,16 +2772,16 @@ int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s /*******************/ /*Read the register */ /*******************/ - //ui_Configuration = inl(devpriv->iobase+i_Offset + 8); + /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */ ui_Configuration = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); /*****************************/ /*Reset the START and IRQ bit */ /*****************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8); + /* outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8); */ outl((ui_Configuration & 0xFFE7FFFF), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); return 0; @@ -2814,52 +2807,52 @@ int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s +----------------------------------------------------------------------------+ */ -int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s) +int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; - UINT ui_Configuration = 0; - //INT i_CurrentSource = 0; - UINT ui_Trigger = 0; - UINT ui_TriggerEdge = 0; - UINT ui_Triggermode = 0; - UINT ui_ScanMode = 0; - UINT ui_ConvertTime = 0; - UINT ui_ConvertTimeBase = 0; - UINT ui_DelayTime = 0; - UINT ui_DelayTimeBase = 0; - UINT ui_DelayMode = 0; - //i_FirstChannel=cmd->chanlist[0]; - //i_LastChannel=cmd->chanlist[1]; + unsigned int ui_Configuration = 0; + /* INT i_CurrentSource = 0; */ + unsigned int ui_Trigger = 0; + unsigned int ui_TriggerEdge = 0; + unsigned int ui_Triggermode = 0; + unsigned int ui_ScanMode = 0; + unsigned int ui_ConvertTime = 0; + unsigned int ui_ConvertTimeBase = 0; + unsigned int ui_DelayTime = 0; + unsigned int ui_DelayTimeBase = 0; + unsigned int ui_DelayMode = 0; + /* i_FirstChannel=cmd->chanlist[0]; */ + /* i_LastChannel=cmd->chanlist[1]; */ s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0]; s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1]; if (cmd->start_src == TRIG_EXT) { ui_Trigger = 1; ui_TriggerEdge = cmd->start_arg & 0xFFFF; ui_Triggermode = cmd->start_arg >> 16; - } //if(cmd->start_src==TRIG_EXT) + } /* if(cmd->start_src==TRIG_EXT) */ else { ui_Trigger = 0; - } //elseif(cmd->start_src==TRIG_EXT) + } /* elseif(cmd->start_src==TRIG_EXT) */ if (cmd->stop_src == TRIG_COUNT) { ui_ScanMode = 0; - } // if (cmd->stop_src==TRIG_COUNT) + } /* if (cmd->stop_src==TRIG_COUNT) */ else { ui_ScanMode = 2; - } //else if (cmd->stop_src==TRIG_COUNT) + } /* else if (cmd->stop_src==TRIG_COUNT) */ if (cmd->scan_begin_src == TRIG_FOLLOW) { ui_DelayTime = 0; ui_DelayTimeBase = 0; ui_DelayMode = 0; - } //if(cmd->scan_begin_src==TRIG_FOLLOW) + } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */ else { ui_DelayTime = cmd->scan_begin_arg & 0xFFFF; ui_DelayTimeBase = cmd->scan_begin_arg >> 16; ui_DelayMode = 1; - } //else if(cmd->scan_begin_src==TRIG_FOLLOW) - // printk("\nui_DelayTime=%u\n",ui_DelayTime); - // printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase); + } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */ + /* printk("\nui_DelayTime=%u\n",ui_DelayTime); */ + /* printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase); */ if (cmd->convert_src == TRIG_TIMER) { ui_ConvertTime = cmd->convert_arg & 0xFFFF; ui_ConvertTimeBase = cmd->convert_arg >> 16; @@ -2868,34 +2861,34 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd ui_ConvertTimeBase = 0; } - // if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2))) - // { + /* if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2))) */ + /* { */ /**************************************************/ /*Read the old configuration of the current source */ /**************************************************/ - //ui_Configuration = inl(devpriv->iobase+i_Offset + 12); + /* ui_Configuration = inl(devpriv->iobase+i_Offset + 12); */ ui_Configuration = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); /***********************************************/ /*Write the configuration of the current source */ /***********************************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12); + /* outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12); */ outl((ui_Configuration & 0xFFC00000), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - // } + /* } */ ui_Configuration = 0; - // printk("\nfirstchannel=%u\n",i_FirstChannel); - // printk("\nlastchannel=%u\n",i_LastChannel); - // printk("\nui_Trigger=%u\n",ui_Trigger); - // printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge); - // printk("\nui_Triggermode=%u\n",ui_Triggermode); - // printk("\nui_DelayMode=%u\n",ui_DelayMode); - // printk("\nui_ScanMode=%u\n",ui_ScanMode); - - //ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | + /* printk("\nfirstchannel=%u\n",i_FirstChannel); */ + /* printk("\nlastchannel=%u\n",i_LastChannel); */ + /* printk("\nui_Trigger=%u\n",ui_Trigger); */ + /* printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge); */ + /* printk("\nui_Triggermode=%u\n",ui_Triggermode); */ + /* printk("\nui_DelayMode=%u\n",ui_DelayMode); */ + /* printk("\nui_ScanMode=%u\n",ui_ScanMode); */ + + /* ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | */ ui_Configuration = s_BoardInfos[dev->minor].i_FirstChannel | (s_BoardInfos[dev-> minor]. @@ -2906,80 +2899,80 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd /*************************/ /*Write the Configuration */ /*************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8); + /* outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8); */ outl(ui_Configuration, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x8); /***********************/ /*Write the Delay Value */ /***********************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_DelayTime,devpriv->iobase+i_Offset + 40); + /* outl(ui_DelayTime,devpriv->iobase+i_Offset + 40); */ outl(ui_DelayTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 40); /***************************/ /*Write the Delay time base */ /***************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44); + /* outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44); */ outl(ui_DelayTimeBase, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 44); /*********************************/ /*Write the conversion time value */ /*********************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32); + /* outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32); */ outl(ui_ConvertTime, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); /********************************/ /*Write the conversion time base */ /********************************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36); + /* outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36); */ outl(ui_ConvertTimeBase, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); /*******************/ /*Read the register */ /*******************/ - //ui_Configuration = inl(devpriv->iobase+i_Offset + 4); + /* ui_Configuration = inl(devpriv->iobase+i_Offset + 4); */ ui_Configuration = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); /******************/ /*Set the SCAN bit */ /******************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); + /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */ outl(((ui_Configuration & 0x1E0FF) | 0x00002000), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); /*******************/ /*Read the register */ /*******************/ ui_Configuration = 0; - //ui_Configuration = inl(devpriv->iobase+i_Offset + 8); + /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */ ui_Configuration = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); /*******************/ /*Set the START bit */ /*******************/ - //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); + /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12) >> 19) & 1) != 1) ; - //outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); + /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */ outl((ui_Configuration | 0x00080000), devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); return 0; @@ -3001,14 +2994,14 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd +----------------------------------------------------------------------------+ */ -int i_APCI3200_Reset(struct comedi_device * dev) +int i_APCI3200_Reset(struct comedi_device *dev) { - INT i_Temp; - DWORD dw_Dummy; - //i_InterruptFlag=0; - //i_Initialised==0; - //i_Count=0; - //i_Sum=0; + int i_Temp; + unsigned int dw_Dummy; + /* i_InterruptFlag=0; */ + /* i_Initialised==0; */ + /* i_Count=0; */ + /* i_Sum=0; */ s_BoardInfos[dev->minor].i_InterruptFlag = 0; s_BoardInfos[dev->minor].i_Initialised = 0; @@ -3018,17 +3011,17 @@ int i_APCI3200_Reset(struct comedi_device * dev) outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - // Enable the interrupt for the controler + /* Enable the interrupt for the controler */ dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - outl(0, devpriv->i_IobaseAddon); //Resets the output + outl(0, devpriv->i_IobaseAddon); /* Resets the output */ /***************/ /*Empty the buffer */ /**************/ for (i_Temp = 0; i_Temp <= 95; i_Temp++) { - //ui_InterruptChannelValue[i_Temp]=0; + /* ui_InterruptChannelValue[i_Temp]=0; */ s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0; - } //for(i_Temp=0;i_Temp<=95;i_Temp++) + } /* for(i_Temp=0;i_Temp<=95;i_Temp++) */ /*****************************/ /*Reset the START and IRQ bit */ /*****************************/ @@ -3036,7 +3029,7 @@ int i_APCI3200_Reset(struct comedi_device * dev) while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ; outl(0, devpriv->iobase + i_Temp + 8); i_Temp = i_Temp + 64; - } //for(i_Temp=0;i_Temp<=192;i_Temp+64) + } /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */ return 0; } @@ -3060,26 +3053,26 @@ int i_APCI3200_Reset(struct comedi_device * dev) void v_APCI3200_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - UINT ui_StatusRegister = 0; - UINT ui_ChannelNumber = 0; - INT i_CalibrationFlag = 0; - INT i_CJCFlag = 0; - UINT ui_DummyValue = 0; - UINT ui_DigitalTemperature = 0; - UINT ui_DigitalInput = 0; + unsigned int ui_StatusRegister = 0; + unsigned int ui_ChannelNumber = 0; + int i_CalibrationFlag = 0; + int i_CJCFlag = 0; + unsigned int ui_DummyValue = 0; + unsigned int ui_DigitalTemperature = 0; + unsigned int ui_DigitalInput = 0; int i_ConvertCJCCalibration; - //BEGIN JK TEST + /* BEGIN JK TEST */ int i_ReturnValue = 0; - //END JK TEST + /* END JK TEST */ - //printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType); + /* printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType); */ - //switch(i_ScanType) + /* switch(i_ScanType) */ switch (s_BoardInfos[dev->minor].i_ScanType) { case 0: case 1: - //switch(i_ADDIDATAType) + /* switch(i_ADDIDATAType) */ switch (s_BoardInfos[dev->minor].i_ADDIDATAType) { case 0: case 1: @@ -3087,12 +3080,12 @@ void v_APCI3200_Interrupt(int irq, void *d) /************************************/ /*Read the interrupt status register */ /************************************/ - //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); + /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ ui_StatusRegister = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16); if ((ui_StatusRegister & 0x2) == 0x2) { - //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); + /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */ i_CalibrationFlag = ((inl(devpriv->iobase + s_BoardInfos[dev-> @@ -3103,12 +3096,12 @@ void v_APCI3200_Interrupt(int irq, void *d) /*************************/ /*Read the channel number */ /*************************/ - //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); + /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ /*************************************/ /*Read the digital analog input value */ /*************************************/ - //ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28); + /* ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28); */ ui_DigitalInput = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); @@ -3117,13 +3110,13 @@ void v_APCI3200_Interrupt(int irq, void *d) /* Test if the value read is the channel value */ /***********************************************/ if (i_CalibrationFlag == 0) { - //ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput; + /* ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. i_Count + 0] = ui_DigitalInput; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ /* printk("\n 1 - i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos %i", ui_ChannelNumber); i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num, @@ -3131,14 +3124,14 @@ void v_APCI3200_Interrupt(int irq, void *d) &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7], &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 8]); */ - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ /******************************************************/ /*Start the conversion of the calibration offset value */ /******************************************************/ i_APCI3200_ReadCalibrationOffsetValue (dev, &ui_DummyValue); - } //if (i_CalibrationFlag == 0) + } /* if (i_CalibrationFlag == 0) */ /**********************************************************/ /* Test if the value read is the calibration offset value */ /**********************************************************/ @@ -3149,7 +3142,7 @@ void v_APCI3200_Interrupt(int irq, void *d) /* Save the value */ /******************/ - //ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput; + /* ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3160,7 +3153,7 @@ void v_APCI3200_Interrupt(int irq, void *d) /******************************************************/ i_APCI3200_ReadCalibrationGainValue(dev, &ui_DummyValue); - } //if (i_CalibrationFlag == 1) + } /* if (i_CalibrationFlag == 1) */ /******************************************************/ /*Test if the value read is the calibration gain value */ /******************************************************/ @@ -3170,48 +3163,48 @@ void v_APCI3200_Interrupt(int irq, void *d) /****************/ /*Save the value */ /****************/ - //ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput; + /* ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. i_Count + 2] = ui_DigitalInput; - //if(i_ScanType==1) + /* if(i_ScanType==1) */ if (s_BoardInfos[dev->minor]. i_ScanType == 1) { - //i_InterruptFlag=0; + /* i_InterruptFlag=0; */ s_BoardInfos[dev->minor]. i_InterruptFlag = 0; - //i_Count=i_Count + 6; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; + /* i_Count=i_Count + 6; */ + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */ s_BoardInfos[dev->minor]. i_Count = s_BoardInfos[dev-> minor].i_Count + 9; - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - } //if(i_ScanType==1) + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + } /* if(i_ScanType==1) */ else { - //i_Count=0; + /* i_Count=0; */ s_BoardInfos[dev->minor]. i_Count = 0; - } //elseif(i_ScanType==1) - //if(i_ScanType!=1) + } /* elseif(i_ScanType==1) */ + /* if(i_ScanType!=1) */ if (s_BoardInfos[dev->minor]. i_ScanType != 1) { - i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample - } //if(i_ScanType!=1) + i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + } /* if(i_ScanType!=1) */ else { - //if(i_ChannelCount==i_Sum) + /* if(i_ChannelCount==i_Sum) */ if (s_BoardInfos[dev->minor]. i_ChannelCount == s_BoardInfos[dev-> minor].i_Sum) { - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } - } //if(i_ScanType!=1) - } //if (i_CalibrationFlag == 2) - } // if ((ui_StatusRegister & 0x2) == 0x2) + } /* if(i_ScanType!=1) */ + } /* if (i_CalibrationFlag == 2) */ + } /* if ((ui_StatusRegister & 0x2) == 0x2) */ break; @@ -3220,7 +3213,7 @@ void v_APCI3200_Interrupt(int irq, void *d) /*Read the interrupt status register */ /************************************/ - //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); + /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ ui_StatusRegister = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16); @@ -3230,7 +3223,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((ui_StatusRegister & 0x2) == 0x2) { - //i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10); + /* i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10); */ i_CJCFlag = ((inl(devpriv->iobase + s_BoardInfos[dev-> @@ -3238,7 +3231,7 @@ void v_APCI3200_Interrupt(int irq, void *d) i_Offset + 4) & 0x00000400) >> 10); - //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); + /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */ i_CalibrationFlag = ((inl(devpriv->iobase + s_BoardInfos[dev-> @@ -3251,19 +3244,19 @@ void v_APCI3200_Interrupt(int irq, void *d) /*Read the channel number */ /*************************/ - //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); + /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ ui_ChannelNumber = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 24); - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNumber; - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ /************************************/ /*Read the digital temperature value */ /************************************/ - //ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28); + /* ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28); */ ui_DigitalTemperature = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); @@ -3274,7 +3267,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) { - //ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3287,7 +3280,7 @@ void v_APCI3200_Interrupt(int irq, void *d) i_APCI3200_ReadCJCValue(dev, &ui_DummyValue); - } //if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) + } /* if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) */ /*****************************************/ /*Test if the value read is the CJC value */ @@ -3295,7 +3288,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) { - //ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3307,7 +3300,7 @@ void v_APCI3200_Interrupt(int irq, void *d) /******************************************************/ i_APCI3200_ReadCalibrationOffsetValue (dev, &ui_DummyValue); - } // if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) + } /* if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) */ /********************************************************/ /*Test if the value read is the calibration offset value */ @@ -3315,7 +3308,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) { - //ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3328,7 +3321,7 @@ void v_APCI3200_Interrupt(int irq, void *d) i_APCI3200_ReadCalibrationGainValue(dev, &ui_DummyValue); - } //if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) + } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) */ /******************************************************/ /*Test if the value read is the calibration gain value */ @@ -3336,7 +3329,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) { - //ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3349,15 +3342,15 @@ void v_APCI3200_Interrupt(int irq, void *d) /*Test if the polarity is the same */ /**********************************/ - //if(i_CJCPolarity!=i_ADDIDATAPolarity) + /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ if (s_BoardInfos[dev->minor]. i_CJCPolarity != s_BoardInfos[dev->minor]. i_ADDIDATAPolarity) { i_ConvertCJCCalibration = 1; - } //if(i_CJCPolarity!=i_ADDIDATAPolarity) + } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ else { - //if(i_CJCGain==i_ADDIDATAGain) + /* if(i_CJCGain==i_ADDIDATAGain) */ if (s_BoardInfos[dev->minor]. i_CJCGain == s_BoardInfos[dev-> @@ -3365,12 +3358,12 @@ void v_APCI3200_Interrupt(int irq, void *d) i_ADDIDATAGain) { i_ConvertCJCCalibration = 0; - } //if(i_CJCGain==i_ADDIDATAGain) + } /* if(i_CJCGain==i_ADDIDATAGain) */ else { i_ConvertCJCCalibration = 1; - } //elseif(i_CJCGain==i_ADDIDATAGain) - } //elseif(i_CJCPolarity!=i_ADDIDATAPolarity) + } /* elseif(i_CJCGain==i_ADDIDATAGain) */ + } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */ if (i_ConvertCJCCalibration == 1) { /****************************************************************/ /*Start the conversion of the calibration gain value for the CJC */ @@ -3378,10 +3371,10 @@ void v_APCI3200_Interrupt(int irq, void *d) i_APCI3200_ReadCJCCalOffset(dev, &ui_DummyValue); - } //if(i_ConvertCJCCalibration==1) + } /* if(i_ConvertCJCCalibration==1) */ else { - //ui_InterruptChannelValue[i_Count + 4]=0; - //ui_InterruptChannelValue[i_Count + 5]=0; + /* ui_InterruptChannelValue[i_Count + 4]=0; */ + /* ui_InterruptChannelValue[i_Count + 5]=0; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev-> @@ -3392,8 +3385,8 @@ void v_APCI3200_Interrupt(int irq, void *d) [s_BoardInfos[dev-> minor].i_Count + 5] = 0; - } //elseif(i_ConvertCJCCalibration==1) - } //else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) + } /* elseif(i_ConvertCJCCalibration==1) */ + } /* else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) */ /********************************************************************/ /*Test if the value read is the calibration offset value for the CJC */ @@ -3401,7 +3394,7 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) { - //ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. @@ -3414,7 +3407,7 @@ void v_APCI3200_Interrupt(int irq, void *d) i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue); - } //if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) + } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) */ /******************************************************************/ /*Test if the value read is the calibration gain value for the CJC */ @@ -3422,61 +3415,61 @@ void v_APCI3200_Interrupt(int irq, void *d) if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) { - //ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature; + /* ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature; */ s_BoardInfos[dev->minor]. ui_InterruptChannelValue [s_BoardInfos[dev->minor]. i_Count + 5] = ui_DigitalTemperature; - //if(i_ScanType==1) + /* if(i_ScanType==1) */ if (s_BoardInfos[dev->minor]. i_ScanType == 1) { - //i_InterruptFlag=0; + /* i_InterruptFlag=0; */ s_BoardInfos[dev->minor]. i_InterruptFlag = 0; - //i_Count=i_Count + 6; - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; + /* i_Count=i_Count + 6; */ + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */ s_BoardInfos[dev->minor]. i_Count = s_BoardInfos[dev-> minor].i_Count + 9; - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - } //if(i_ScanType==1) + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + } /* if(i_ScanType==1) */ else { - //i_Count=0; + /* i_Count=0; */ s_BoardInfos[dev->minor]. i_Count = 0; - } //elseif(i_ScanType==1) + } /* elseif(i_ScanType==1) */ - //if(i_ScanType!=1) + /* if(i_ScanType!=1) */ if (s_BoardInfos[dev->minor]. i_ScanType != 1) { - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample - } //if(i_ScanType!=1) + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + } /* if(i_ScanType!=1) */ else { - //if(i_ChannelCount==i_Sum) + /* if(i_ChannelCount==i_Sum) */ if (s_BoardInfos[dev->minor]. i_ChannelCount == s_BoardInfos[dev-> minor].i_Sum) { - send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } //if(i_ChannelCount==i_Sum) - } //else if(i_ScanType!=1) - } //if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) + } /* if(i_ChannelCount==i_Sum) */ + } /* else if(i_ScanType!=1) */ + } /* if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) */ - } //else if ((ui_StatusRegister & 0x2) == 0x2) + } /* else if ((ui_StatusRegister & 0x2) == 0x2) */ break; - } //switch(i_ADDIDATAType) + } /* switch(i_ADDIDATAType) */ break; case 2: case 3: i_APCI3200_InterruptHandleEos(dev); break; - } //switch(i_ScanType) + } /* switch(i_ScanType) */ return; } @@ -3499,22 +3492,22 @@ void v_APCI3200_Interrupt(int irq, void *d) | | +----------------------------------------------------------------------------+ */ -int i_APCI3200_InterruptHandleEos(struct comedi_device * dev) +int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) { - UINT ui_StatusRegister = 0; + unsigned int ui_StatusRegister = 0; struct comedi_subdevice *s = dev->subdevices + 0; - //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //comedi_async *async = s->async; - //UINT *data; - //data=async->data+async->buf_int_ptr;//new samples added from here onwards + /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* comedi_async *async = s->async; */ + /* UINT *data; */ + /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */ int n = 0, i = 0; - //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ /************************************/ /*Read the interrupt status register */ /************************************/ - //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); + /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ ui_StatusRegister = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16); @@ -3526,33 +3519,33 @@ int i_APCI3200_InterruptHandleEos(struct comedi_device * dev) /*************************/ /*Read the channel number */ /*************************/ - //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); - //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //This value is not used - //ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); + /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ + /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* This value is not used */ + /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */ s->async->events = 0; - //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ /*************************************/ /*Read the digital Analog Input value */ /*************************************/ - //data[i_Count] = inl(devpriv->iobase+i_Offset + 28); - //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); + /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */ + /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */ s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev-> minor].i_Count] = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 28); - //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - //if((i_Count == (i_LastChannel-i_FirstChannel+3))) + /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */ if ((s_BoardInfos[dev->minor].i_Count == (s_BoardInfos[dev->minor].i_LastChannel - s_BoardInfos[dev->minor]. i_FirstChannel + 3))) { - //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ s_BoardInfos[dev->minor].i_Count++; for (i = s_BoardInfos[dev->minor].i_FirstChannel; @@ -3582,61 +3575,61 @@ int i_APCI3200_InterruptHandleEos(struct comedi_device * dev) * 3) + 2]); } - //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values + /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - //i_Count=-1; + /* i_Count=-1; */ s_BoardInfos[dev->minor].i_Count = -1; - //async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT); - //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT); - //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT); - //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - //async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT); - //comedi_eos(dev,s); + /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */ + /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */ + /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */ + /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */ + /* comedi_eos(dev,s); */ - // Set the event type (Comedi Buffer End Of Scan) + /* Set the event type (Comedi Buffer End Of Scan) */ s->async->events |= COMEDI_CB_EOS; - // Test if enougth memory is available and allocate it for 7 values - //n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); + /* Test if enougth memory is available and allocate it for 7 values */ + /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */ n = comedi_buf_write_alloc(s->async, (7 + 12) * sizeof(unsigned int)); - // If not enougth memory available, event is set to Comedi Buffer Errror + /* If not enougth memory available, event is set to Comedi Buffer Errror */ if (n > ((7 + 12) * sizeof(unsigned int))) { printk("\ncomedi_buf_write_alloc n = %i", n); s->async->events |= COMEDI_CB_ERROR; } - // Write all 7 scan values in the comedi buffer + /* Write all 7 scan values in the comedi buffer */ comedi_buf_memcpy_to(s->async, 0, (unsigned int *) s_BoardInfos[dev->minor]. ui_ScanValueArray, (7 + 12) * sizeof(unsigned int)); - // Update comedi buffer pinters indexes + /* Update comedi buffer pinters indexes */ comedi_buf_write_free(s->async, (7 + 12) * sizeof(unsigned int)); - // Send events + /* Send events */ comedi_event(dev, s); - //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - - //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - // - //if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over - // { - // /* buffer rollover */ - // s->async->buf_int_ptr=0; - // comedi_eobuf(dev,s); - // } - //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 + /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + + /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + /* */ + /* if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over */ + /* { */ + /* /* buffer rollover */ */ + /* s->async->buf_int_ptr=0; */ + /* comedi_eobuf(dev,s); */ + /* } */ + /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ } - //i_Count++; + /* i_Count++; */ s_BoardInfos[dev->minor].i_Count++; } - //i_InterruptFlag=0; + /* i_InterruptFlag=0; */ s_BoardInfos[dev->minor].i_InterruptFlag = 0; return 0; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h index a6f57f55e79c..f3e7ebf8c1f3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h @@ -15,26 +15,26 @@ * any later version. */ -// Card Specific information +/* Card Specific information */ #define APCI3200_BOARD_VENDOR_ID 0x15B8 -//#define APCI3200_ADDRESS_RANGE 264 +/* #define APCI3200_ADDRESS_RANGE 264 */ int MODULE_NO; struct { - INT i_Gain; - INT i_Polarity; - INT i_OffsetRange; - INT i_Coupling; - INT i_SingleDiff; - INT i_AutoCalibration; - UINT ui_ReloadValue; - UINT ui_TimeUnitReloadVal; - INT i_Interrupt; - INT i_ModuleSelection; + int i_Gain; + int i_Polarity; + int i_OffsetRange; + int i_Coupling; + int i_SingleDiff; + int i_AutoCalibration; + unsigned int ui_ReloadValue; + unsigned int ui_TimeUnitReloadVal; + int i_Interrupt; + int i_ModuleSelection; } Config_Parameters_Module1, Config_Parameters_Module2, Config_Parameters_Module3, Config_Parameters_Module4; -//ANALOG INPUT RANGE +/* ANALOG INPUT RANGE */ static const struct comedi_lrange range_apci3200_ai = { 8, { BIP_RANGE(10), BIP_RANGE(5), @@ -55,7 +55,7 @@ static const struct comedi_lrange range_apci3300_ai = { 4, { } }; -//Analog Input related Defines +/* Analog Input related Defines */ #define APCI3200_AI_OFFSET_GAIN 0 #define APCI3200_AI_SC_TEST 4 #define APCI3200_AI_IRQ 8 @@ -89,98 +89,102 @@ static const struct comedi_lrange range_apci3300_ai = { 4, { #define ADDIDATA_UNIPOLAR 1 #define ADDIDATA_BIPOLAR 2 -//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ #define MAX_MODULE 4 -//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values +/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ -typedef struct { - ULONG ul_NumberOfValue; - ULONG *pul_ResistanceValue; - ULONG *pul_TemperatureValue; -} str_ADDIDATA_RTDStruct, *pstr_ADDIDATA_RTDStruct; +struct str_ADDIDATA_RTDStruct { + unsigned int ul_NumberOfValue; + unsigned int *pul_ResistanceValue; + unsigned int *pul_TemperatureValue; +}; + +/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ +struct str_Module { -//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values -typedef struct { - // Begin JK 05/08/2003 change for Linux + /* Begin JK 05/08/2003 change for Linux */ unsigned long ul_CurrentSourceCJC; unsigned long ul_CurrentSource[5]; - // End JK 05/08/2003 change for Linux + /* End JK 05/08/2003 change for Linux */ - // Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 - unsigned long ul_GainFactor[8]; // Gain Factor + /* Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */ + unsigned long ul_GainFactor[8]; /* Gain Factor */ unsigned int w_GainValue[10]; - // End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 -} str_Module; -//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - -//BEGIN JK 06.07.04: Management of sevrals boards -typedef struct { - INT i_CJCAvailable; - INT i_CJCPolarity; - INT i_CJCGain; - INT i_InterruptFlag; - INT i_ADDIDATAPolarity; - INT i_ADDIDATAGain; - INT i_AutoCalibration; - INT i_ADDIDATAConversionTime; - INT i_ADDIDATAConversionTimeUnit; - INT i_ADDIDATAType; - INT i_ChannelNo; - INT i_ChannelCount; - INT i_ScanType; - INT i_FirstChannel; - INT i_LastChannel; - INT i_Sum; - INT i_Offset; - UINT ui_Channel_num; - INT i_Count; - INT i_Initialised; - //UINT ui_InterruptChannelValue[96]; //Buffer - UINT ui_InterruptChannelValue[144]; //Buffer - BYTE b_StructInitialized; - //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - unsigned int ui_ScanValueArray[7 + 12]; // 7 is the maximal number of channels - //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 - - //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values - INT i_ConnectionType; - INT i_NbrOfModule; - str_Module s_Module[MAX_MODULE]; - //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values -} str_BoardInfos; -//END JK 06.07.04: Management of sevrals boards - -// Hardware Layer functions for Apci3200 - -//AI - -INT i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, + /* End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */ +}; + +/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + +/* BEGIN JK 06.07.04: Management of sevrals boards */ +struct str_BoardInfos { + + int i_CJCAvailable; + int i_CJCPolarity; + int i_CJCGain; + int i_InterruptFlag; + int i_ADDIDATAPolarity; + int i_ADDIDATAGain; + int i_AutoCalibration; + int i_ADDIDATAConversionTime; + int i_ADDIDATAConversionTimeUnit; + int i_ADDIDATAType; + int i_ChannelNo; + int i_ChannelCount; + int i_ScanType; + int i_FirstChannel; + int i_LastChannel; + int i_Sum; + int i_Offset; + unsigned int ui_Channel_num; + int i_Count; + int i_Initialised; + /* UINT ui_InterruptChannelValue[96]; //Buffer */ + unsigned int ui_InterruptChannelValue[144]; /* Buffer */ + unsigned char b_StructInitialized; + /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + unsigned int ui_ScanValueArray[7 + 12]; /* 7 is the maximal number of channels */ + /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ + + /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ + int i_ConnectionType; + int i_NbrOfModule; + struct str_Module s_Module[MAX_MODULE]; + /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ +}; + +/* END JK 06.07.04: Management of sevrals boards */ + +/* Hardware Layer functions for Apci3200 */ + +/* AI */ + +int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev, +int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev, +int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); -INT i_APCI3200_InterruptHandleEos(struct comedi_device *dev); -INT i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); +int i_APCI3200_InterruptHandleEos(struct comedi_device *dev); +int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); -INT i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); -INT i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); +int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//Interrupt +/* Interrupt */ void v_APCI3200_Interrupt(int irq, void *d); int i_APCI3200_InterruptHandleEos(struct comedi_device *dev); -//Reset functions -INT i_APCI3200_Reset(struct comedi_device *dev); +/* Reset functions */ +int i_APCI3200_Reset(struct comedi_device *dev); int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data); int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data); -int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, UINT *data); -int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, UINT *data); +int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data); +int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data); int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c index 20391a91da03..ef21f03fc961 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -62,8 +62,8 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -73,26 +73,26 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; *data = inl(devpriv->iobase + APCI3501_DIGITAL_IP); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } //if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { *data = *data & 0x3; - } //if (ui_Temp==1) + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } //elseif (ui_Temp==1) - } //elseif (ui_Temp==0) + } /* elseif (ui_Temp==1) */ + } /* elseif (ui_Temp==0) */ return insn->n; } @@ -105,7 +105,7 @@ INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev | Task : Configures The Digital Output Subdevice. | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[1] : 1 Enable VCC Interrupt | @@ -121,21 +121,21 @@ INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev | | +----------------------------------------------------------------------------+ */ -int i_APCI3501_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if ((data[0] != 0) && (data[0] != 1)) { comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } //if ( (data[0]!=0) && (data[0]!=1) ) + } /* if ( (data[0]!=0) && (data[0]!=1) ) */ if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } // if (data[0]) + } /* if (data[0]) */ else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } //else if (data[0]) + } /* else if (data[0]) */ return insn->n; } @@ -161,33 +161,33 @@ int i_APCI3501_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub | | +----------------------------------------------------------------------------+ */ -INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp, ui_Temp1; - UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel + unsigned int ui_Temp, ui_Temp1; + unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ if (devpriv->b_OutputMemoryStatus) { ui_Temp = inl(devpriv->iobase + APCI3501_DIGITAL_OP); - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ else { ui_Temp = 0; - } //if(devpriv->b_OutputMemoryStatus ) + } /* if(devpriv->b_OutputMemoryStatus ) */ if (data[3] == 0) { if (data[1] == 0) { data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; outl(data[0], devpriv->iobase + APCI3501_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { data[0] = (data[0] << (2 * data[2])) | ui_Temp; outl(data[0], devpriv->iobase + APCI3501_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==0) + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==0) */ else { if (data[3] == 1) { if (data[1] == 0) { @@ -201,7 +201,7 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd data[0] = data[0] & ui_Temp; outl(data[0], devpriv->iobase + APCI3501_DIGITAL_OP); - } //if(data[1]==0) + } /* if(data[1]==0) */ else { if (data[1] == 1) { data[0] = ~data[0] & 0x3; @@ -215,17 +215,17 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd outl(data[0], devpriv->iobase + APCI3501_DIGITAL_OP); - } // if(data[1]==1) + } /* if(data[1]==1) */ else { printk("\nSpecified channel not supported\n"); - } //else if(data[1]==1) - } //elseif(data[1]==0) - } //if(data[3]==1); + } /* else if(data[1]==1) */ + } /* elseif(data[1]==0) */ + } /* if(data[3]==1); */ else { printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } //if else data[3]==1) - } //if else data[3]==0) + } /* if else data[3]==1) */ + } /* if else data[3]==0) */ return insn->n; } @@ -238,8 +238,8 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | Task : Read value of the selected channel or port | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT ui_NoOfChannels : No Of Channels To read | -| UINT *data : Data Pointer to read status | +| unsigned int ui_NoOfChannels : No Of Channels To read | +| unsigned int *data : Data Pointer to read status | +----------------------------------------------------------------------------+ | Output Parameters : -- | +----------------------------------------------------------------------------+ @@ -248,27 +248,27 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI3501_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - UINT ui_Temp; - UINT ui_NoOfChannel; + unsigned int ui_Temp; + unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); ui_Temp = data[0]; *data = inl(devpriv->iobase + APCI3501_DIGITAL_OP); if (ui_Temp == 0) { *data = (*data >> ui_NoOfChannel) & 0x1; - } // if (ui_Temp==0) + } /* if (ui_Temp==0) */ else { if (ui_Temp == 1) { *data = *data & 0x3; - } // if (ui_Temp==1) + } /* if (ui_Temp==1) */ else { printk("\nSpecified channel not supported \n"); - } // else if (ui_Temp==1) - } // else if (ui_Temp==0) + } /* else if (ui_Temp==1) */ + } /* else if (ui_Temp==0) */ return insn->n; } @@ -298,8 +298,8 @@ INT i_APCI3501_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI3501_ConfigAnalogOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { outl(data[0], devpriv->iobase + APCI3501_ANALOG_OUTPUT + @@ -336,10 +336,10 @@ INT i_APCI3501_ConfigAnalogOutput(struct comedi_device * dev, struct comedi_subd | | +----------------------------------------------------------------------------+ */ -INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0;; + unsigned int ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0;; ul_Channel_no = CR_CHAN(insn->chanspec); @@ -349,18 +349,18 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde printk("\nIn WriteAnalogOutput :: Not Valid Data\n"); } - } // end if(devpriv->b_InterruptMode==MODE1) + } /* end if(devpriv->b_InterruptMode==MODE1) */ else { ul_Polarity = 0; if ((*data < 0) || (*data > 8192)) { printk("\nIn WriteAnalogOutput :: Not Valid Data\n"); } - } // end else + } /* end else */ if ((ul_Channel_no < 0) || (ul_Channel_no > 7)) { printk("\nIn WriteAnalogOutput :: Not Valid Channel\n"); - } // end if((ul_Channel_no<0)||(ul_Channel_no>7)) + } /* end if((ul_Channel_no<0)||(ul_Channel_no>7)) */ ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT); @@ -370,11 +370,11 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde } if (ul_DAC_Ready) { -// Output the Value on the output channels. +/* Output the Value on the output channels. */ ul_Command1 = - (ULONG) ((ULONG) (ul_Channel_no & 0xFF) | - (ULONG) ((*data << 0x8) & 0x7FFFFF00L) | - (ULONG) (ul_Polarity)); + (unsigned int) ((unsigned int) (ul_Channel_no & 0xFF) | + (unsigned int) ((*data << 0x8) & 0x7FFFFF00L) | + (unsigned int) (ul_Polarity)); outl(ul_Command1, devpriv->iobase + APCI3501_ANALOG_OUTPUT + APCI3501_AO_PROG); @@ -392,7 +392,7 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde | Task : Configures The Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Configure As Timer | @@ -410,78 +410,78 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde | | +----------------------------------------------------------------------------+ */ -INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0; + unsigned int ul_Command1 = 0; devpriv->tsk_Current = current; if (data[0] == ADDIDATA_WATCHDOG) { devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG; - //Disable the watchdog - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Wa + /* Disable the watchdog */ + outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Wa */ if (data[1] == 1) { - //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES + /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ outl(0x02, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); } else { - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Timer interrupt + outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */ } - //Loading the Timebase value + /* Loading the Timebase value */ outl(data[2], devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_TIMEBASE); - //Loading the Reload value + /* Loading the Reload value */ outl(data[3], devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_RELOAD_VALUE); - //Set the mode - ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL; //e2->e0 + /* Set the mode */ + ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL; /* e2->e0 */ outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - } //end if(data[0]==ADDIDATA_WATCHDOG) + } /* end if(data[0]==ADDIDATA_WATCHDOG) */ else if (data[0] == ADDIDATA_TIMER) { - //First Stop The Timer + /* First Stop The Timer */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //Stop The Timer + outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* Stop The Timer */ devpriv->b_TimerSelectMode = ADDIDATA_TIMER; if (data[1] == 1) { - //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES + /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ outl(0x02, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); } else { - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Timer interrupt + outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */ } - // Loading Timebase + /* Loading Timebase */ outl(data[2], devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_TIMEBASE); - //Loading the Reload value + /* Loading the Reload value */ outl(data[3], devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_RELOAD_VALUE); - // printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG)); + /* printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG)); */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; - outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //mode 2 + outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* mode 2 */ - } //end if(data[0]==ADDIDATA_TIMER) + } /* end if(data[0]==ADDIDATA_TIMER) */ return insn->n; } @@ -495,7 +495,7 @@ INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev, | Task : Start / Stop The Selected Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Timer | @@ -511,10 +511,10 @@ INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - ULONG ul_Command1 = 0; + unsigned int ul_Command1 = 0; int i_Temp; if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { @@ -523,15 +523,15 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - //Enable the Watchdog + /* Enable the Watchdog */ outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); } - else if (data[1] == 0) //Stop The Watchdog + else if (data[1] == 0) /* Stop The Watchdog */ { - //Stop The Watchdog + /* Stop The Watchdog */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); @@ -547,8 +547,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - } //if(data[1]==2) - } // end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) + } /* if(data[1]==2) */ + } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { if (data[1] == 1) { @@ -557,12 +557,12 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - //Enable the Timer + /* Enable the Timer */ outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); } else if (data[1] == 0) { - //Stop The Timer + /* Stop The Timer */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); @@ -573,7 +573,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, } else if (data[1] == 2) { - //Trigger the Timer + /* Trigger the Timer */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); @@ -583,7 +583,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, APCI3501_TCW_PROG); } - } // end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) + } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ i_Temp = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_TRIG_STATUS) & 0x1; return insn->n; @@ -598,7 +598,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, | Task : Read The Selected Timer , Counter or Watchdog | +----------------------------------------------------------------------------+ | Input Parameters : struct comedi_device *dev : Driver handle | -| UINT *data : Data Pointer contains | +| unsigned int *data : Data Pointer contains | | configuration parameters as below | | | | data[0] : 0 Timer | @@ -613,8 +613,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { @@ -622,14 +622,14 @@ int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev, inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_TRIG_STATUS) & 0x1; data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG); - } // end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) + } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { data[0] = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_TRIG_STATUS) & 0x1; data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG); - } // end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) + } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)) { @@ -654,10 +654,10 @@ int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3501_Reset(struct comedi_device * dev) +int i_APCI3501_Reset(struct comedi_device *dev) { int i_Count = 0, i_temp = 0; - ULONG ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0; + unsigned int ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0; outl(0x0, devpriv->iobase + APCI3501_DIGITAL_OP); outl(1, devpriv->iobase + APCI3501_ANALOG_OUTPUT + APCI3501_AO_VOLT_MODE); @@ -674,11 +674,11 @@ int i_APCI3501_Reset(struct comedi_device * dev) } if (ul_DAC_Ready) { - // Output the Value on the output channels. + /* Output the Value on the output channels. */ ul_Command1 = - (ULONG) ((ULONG) (i_Count & 0xFF) | - (ULONG) ((i_temp << 0x8) & 0x7FFFFF00L) | - (ULONG) (ul_Polarity)); + (unsigned int) ((unsigned int) (i_Count & 0xFF) | + (unsigned int) ((i_temp << 0x8) & 0x7FFFFF00L) | + (unsigned int) (ul_Polarity)); outl(ul_Command1, devpriv->iobase + APCI3501_ANALOG_OUTPUT + APCI3501_AO_PROG); @@ -711,7 +711,7 @@ void v_APCI3501_Interrupt(int irq, void *d) struct comedi_device *dev = d; unsigned int ui_Timer_AOWatchdog; unsigned long ul_Command1; - // Disable Interrupt + /* Disable Interrupt */ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); @@ -728,8 +728,9 @@ void v_APCI3501_Interrupt(int irq, void *d) return; } - // Enable Interrupt - //Send a signal to from kernel to user space +/* +* Enable Interrupt Send a signal to from kernel to user space +*/ send_sig(SIGIO, devpriv->tsk_Current, 0); ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h index 51e7b66544ac..c456d75674b8 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h @@ -15,7 +15,7 @@ * any later version. */ -// Card Specific information +/* Card Specific information */ #define APCI3501_BOARD_VENDOR_ID 0x15B8 #define APCI3501_ADDRESS_RANGE 255 @@ -23,7 +23,7 @@ #define APCI3501_DIGITAL_OP 0x40 #define APCI3501_ANALOG_OUTPUT 0x00 -//Analog Output related Defines +/* Analog Output related Defines */ #define APCI3501_AO_VOLT_MODE 0 #define APCI3501_AO_PROG 4 #define APCI3501_AO_TRIG_SCS 8 @@ -31,14 +31,14 @@ #define BIPOLAR 1 #define MODE0 0 #define MODE1 1 -// ANALOG OUTPUT RANGE +/* ANALOG OUTPUT RANGE */ struct comedi_lrange range_apci3501_ao = { 2, { BIP_RANGE(10), UNI_RANGE(10) } }; -//Watchdog Related Defines +/* Watchdog Related Defines */ #define APCI3501_WATCHDOG 0x20 #define APCI3501_TCW_SYNC_ENABLEDISABLE 0 @@ -52,32 +52,36 @@ struct comedi_lrange range_apci3501_ao = { 2, { #define ADDIDATA_TIMER 0 #define ADDIDATA_WATCHDOG 2 -// Hardware Layer functions for Apci3501 +/* Hardware Layer functions for Apci3501 */ -//AO -INT i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, +/* AO */ +int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//DI -// for di read -//INT i_APCI3501_ReadDigitalInput(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); +/* +* DI for di read INT i_APCI3501_ReadDigitalInput(struct +* comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn +* *insn,unsigned int *data); +*/ -INT i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//DO +/* DO */ int i_APCI3501_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -INT i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, +int i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -// TIMER -// timer value is passed as u seconds -INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, +/* TIMER + * timer value is passed as u seconds + */ + +int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, @@ -87,8 +91,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -//Interrupt +/* Interrupt */ void v_APCI3501_Interrupt(int irq, void *d); -//Reset functions +/* Reset functions */ int i_APCI3501_Reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c index b7268e4da64e..338727879827 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c @@ -3,13 +3,13 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data-com - info@addi-data.com + ADDI-DATA GmbH + Dieselstrasse 3 + D-77833 Ottersweier + Tel: +19(0)7223/9493-0 + Fax: +49(0)7223/9493-92 + http://www.addi-data-com + info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -54,7 +54,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_TestConversionStarted | +| Function Name : int i_APCI3XXX_TestConversionStarted | | (struct comedi_device *dev) | +----------------------------------------------------------------------------+ | Task Test if any conversion started | @@ -68,18 +68,18 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev) +int i_APCI3XXX_TestConversionStarted(struct comedi_device *dev) { - if ((readl((void *)(devpriv->dw_AiBase + 8)) & 0x80000UL) == 0x80000UL) { - return (1); - } else { - return (0); - } + if ((readl((void *)(devpriv->dw_AiBase + 8)) & 0x80000UL) == 0x80000UL) + return 1; + else + return 0; + } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_AnalogInputConfigOperatingMode | +| Function Name : int i_APCI3XXX_AnalogInputConfigOperatingMode | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -87,9 +87,9 @@ int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev) +----------------------------------------------------------------------------+ | Task Converting mode and convert time selection | +----------------------------------------------------------------------------+ -| Input Parameters : b_SingleDiff = (BYTE) data[1]; | -| b_TimeBase = (BYTE) data[2]; (0: ns, 1:micros 2:ms)| -| dw_ReloadValue = (DWORD) data[3]; | +| Input Parameters : b_SingleDiff = (unsigned char) data[1]; | +| b_TimeBase = (unsigned char) data[2]; (0: ns, 1:micros 2:ms)| +| dw_ReloadValue = (unsigned int) data[3]; | | ........ | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -105,14 +105,14 @@ int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev) +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_TimeBase = 0; - BYTE b_SingleDiff = 0; - DWORD dw_ReloadValue = 0; - DWORD dw_TestReloadValue = 0; + int i_ReturnValue = insn->n; + unsigned char b_TimeBase = 0; + unsigned char b_SingleDiff = 0; + unsigned int dw_ReloadValue = 0; + unsigned int dw_TestReloadValue = 0; /************************/ /* Test the buffer size */ @@ -123,19 +123,19 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, /* Get the Singel/Diff flag */ /****************************/ - b_SingleDiff = (BYTE) data[1]; + b_SingleDiff = (unsigned char) data[1]; /****************************/ /* Get the time base unitiy */ /****************************/ - b_TimeBase = (BYTE) data[2]; + b_TimeBase = (unsigned char) data[2]; /*************************************/ /* Get the convert time reload value */ /*************************************/ - dw_ReloadValue = (DWORD) data[3]; + dw_ReloadValue = (unsigned int) data[3]; /**********************/ /* Test the time base */ @@ -186,7 +186,7 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, devpriv-> ui_EocEosConversionTime = - (UINT) + (unsigned int) dw_ReloadValue; devpriv-> b_EocEosConversionTimeBase @@ -204,7 +204,7 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, /* Set the convert timing unit */ /*******************************/ - writel((DWORD) + writel((unsigned int) b_TimeBase, (void *) (devpriv-> @@ -268,12 +268,12 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnConfigAnalogInput | +| Function Name : int i_APCI3XXX_InsnConfigAnalogInput | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -281,9 +281,9 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, +----------------------------------------------------------------------------+ | Task Converting mode and convert time selection | +----------------------------------------------------------------------------+ -| Input Parameters : b_ConvertMode = (BYTE) data[0]; | -| b_TimeBase = (BYTE) data[1]; (0: ns, 1:micros 2:ms)| -| dw_ReloadValue = (DWORD) data[2]; | +| Input Parameters : b_ConvertMode = (unsigned char) data[0]; | +| b_TimeBase = (unsigned char) data[1]; (0: ns, 1:micros 2:ms)| +| dw_ReloadValue = (unsigned int) data[2]; | | ........ | +----------------------------------------------------------------------------+ | Output Parameters : - | @@ -295,17 +295,17 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; + int i_ReturnValue = insn->n; /************************/ /* Test the buffer size */ /************************/ if (insn->n >= 1) { - switch ((BYTE) data[0]) { + switch ((unsigned char) data[0]) { case APCI3XXX_CONFIGURATION: i_ReturnValue = i_APCI3XXX_AnalogInputConfigOperatingMode(dev, @@ -326,12 +326,12 @@ int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnReadAnalogInput | +| Function Name : int i_APCI3XXX_InsnReadAnalogInput | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -355,16 +355,16 @@ int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Configuration = (BYTE) CR_RANGE(insn->chanspec); - BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec); - DWORD dw_Temp = 0; - DWORD dw_Configuration = 0; - DWORD dw_AcquisitionCpt = 0; - BYTE b_Interrupt = 0; + int i_ReturnValue = insn->n; + unsigned char b_Configuration = (unsigned char) CR_RANGE(insn->chanspec); + unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec); + unsigned int dw_Temp = 0; + unsigned int dw_Configuration = 0; + unsigned int dw_AcquisitionCpt = 0; + unsigned char b_Interrupt = 0; /*************************************/ /* Test if operating mode configured */ @@ -449,8 +449,8 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, dw_Configuration = (b_Configuration & 3) | - ((DWORD) (b_Configuration >> 2) - << 6) | ((DWORD) devpriv-> + ((unsigned int) (b_Configuration >> 2) + << 6) | ((unsigned int) devpriv-> b_SingelDiff << 7); /***************************/ @@ -468,7 +468,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, writel(dw_Temp | 0x100UL, (void *)(devpriv->dw_AiBase + 4)); - writel((DWORD) b_Channel, + writel((unsigned int) b_Channel, (void *)(devpriv->dw_AiBase + 0)); @@ -535,8 +535,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, dw_Temp = dw_Temp & 1; - } - while (dw_Temp != 1); + } while (dw_Temp != 1); /*************************/ /* Read the analog value */ @@ -585,7 +584,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, printk("Operating mode not configured\n"); i_ReturnValue = -1; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -607,15 +606,15 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev, void v_APCI3XXX_Interrupt(int irq, void *d) { struct comedi_device *dev = d; - BYTE b_CopyCpt = 0; - DWORD dw_Status = 0; + unsigned char b_CopyCpt = 0; + unsigned int dw_Status = 0; /***************************/ /* Test if interrupt occur */ /***************************/ - if (((dw_Status = readl((void *)(devpriv->dw_AiBase + 16))) & 0x2UL) == - 0x2UL) { + dw_Status = readl((void *)(devpriv->dw_AiBase + 16)); + if ( (dw_Status & 0x2UL) == 0x2UL) { /***********************/ /* Reset the interrupt */ /***********************/ @@ -635,7 +634,7 @@ void v_APCI3XXX_Interrupt(int irq, void *d) b_CopyCpt < devpriv->ui_AiNbrofChannels; b_CopyCpt++) { devpriv->ui_AiReadData[b_CopyCpt] = - (UINT) readl((void *)(devpriv-> + (unsigned int) readl((void *)(devpriv-> dw_AiBase + 28)); } @@ -662,7 +661,7 @@ void v_APCI3XXX_Interrupt(int irq, void *d) /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnWriteAnalogOutput | +| Function Name : int i_APCI3XXX_InsnWriteAnalogOutput | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -684,13 +683,13 @@ void v_APCI3XXX_Interrupt(int irq, void *d) +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - BYTE b_Range = (BYTE) CR_RANGE(insn->chanspec); - BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec); - DWORD dw_Status = 0; - INT i_ReturnValue = insn->n; + unsigned char b_Range = (unsigned char) CR_RANGE(insn->chanspec); + unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec); + unsigned int dw_Status = 0; + int i_ReturnValue = insn->n; /************************/ /* Test the buffer size */ @@ -729,8 +728,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, dw_Status = readl((void *)(devpriv-> dw_AiBase + 96)); - } - while ((dw_Status & 0x100) != 0x100); + } while ((dw_Status & 0x100) != 0x100); } else { /***************************/ /* Channel not initialised */ @@ -757,7 +755,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -768,7 +766,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnConfigInitTTLIO | +| Function Name : int i_APCI3XXX_InsnConfigInitTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -778,8 +776,8 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, | for you call any other function witch access of TTL. | | APCI3XXX_TTL_INIT_DIRECTION_PORT2(user inputs for direction)| +----------------------------------------------------------------------------+ -| Input Parameters : b_InitType = (BYTE) data[0]; | -| b_Port2Mode = (BYTE) data[1]; | +| Input Parameters : b_InitType = (unsigned char) data[0]; | +| b_Port2Mode = (unsigned char) data[1]; | +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ @@ -791,11 +789,11 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Command = 0; + int i_ReturnValue = insn->n; + unsigned char b_Command = 0; /************************/ /* Test the buffer size */ @@ -806,7 +804,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev, /* Get the command */ /* **************** */ - b_Command = (BYTE) data[0]; + b_Command = (unsigned char) data[0]; /********************/ /* Test the command */ @@ -888,7 +886,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev, } } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -899,7 +897,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnBitsTTLIO | +| Function Name : int i_APCI3XXX_InsnBitsTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -919,14 +917,14 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_ChannelCpt = 0; - DWORD dw_ChannelMask = 0; - DWORD dw_BitMask = 0; - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_ChannelCpt = 0; + unsigned int dw_ChannelMask = 0; + unsigned int dw_BitMask = 0; + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ @@ -1051,12 +1049,12 @@ int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnReadTTLIO | +| Function Name : int i_APCI3XXX_InsnReadTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -1074,11 +1072,11 @@ int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnReadTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec); - INT i_ReturnValue = insn->n; + unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec); + int i_ReturnValue = insn->n; unsigned int *pls_ReadData = data; /************************/ @@ -1157,7 +1155,7 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1168,7 +1166,7 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev, /* +----------------------------------------------------------------------------+ -| Function Name : INT i_APCI3XXX_InsnWriteTTLIO | +| Function Name : int i_APCI3XXX_InsnWriteTTLIO | | (struct comedi_device *dev, | | struct comedi_subdevice *s, | | struct comedi_insn *insn, | @@ -1187,20 +1185,20 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec); - BYTE b_State = 0; - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec); + unsigned char b_State = 0; + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ /************************/ if (insn->n >= 1) { - b_State = (BYTE) data[0]; + b_State = (unsigned char) data[0]; /***********************/ /* Test if read port 0 */ @@ -1269,7 +1267,7 @@ int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1298,12 +1296,12 @@ int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec); - DWORD dw_Temp = 0; + int i_ReturnValue = insn->n; + unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec); + unsigned int dw_Temp = 0; /***************************/ /* Test the channel number */ @@ -1334,7 +1332,7 @@ int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev, i_ReturnValue = -3; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1356,11 +1354,11 @@ int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev, | -101 : Data size error | +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - DWORD dw_Temp = 0; + int i_ReturnValue = insn->n; + unsigned int dw_Temp = 0; /************************/ /* Test the buffer size */ @@ -1378,7 +1376,7 @@ int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1409,14 +1407,14 @@ int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev, | -101 : Data size error | +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_ChannelCpt = 0; - DWORD dw_ChannelMask = 0; - DWORD dw_BitMask = 0; - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_ChannelCpt = 0; + unsigned int dw_ChannelMask = 0; + unsigned int dw_BitMask = 0; + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ @@ -1481,7 +1479,7 @@ int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1505,13 +1503,13 @@ int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Channel = CR_CHAN(insn->chanspec); - BYTE b_State = 0; - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_Channel = CR_CHAN(insn->chanspec); + unsigned char b_State = 0; + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ @@ -1527,7 +1525,7 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev, /* Get the command */ /*******************/ - b_State = (BYTE) data[0]; + b_State = (unsigned char) data[0]; /********************************/ /* Read the digital output port */ @@ -1557,7 +1555,7 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1580,12 +1578,12 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - INT i_ReturnValue = insn->n; - BYTE b_Channel = CR_CHAN(insn->chanspec); - DWORD dw_Status = 0; + int i_ReturnValue = insn->n; + unsigned char b_Channel = CR_CHAN(insn->chanspec); + unsigned int dw_Status = 0; /************************/ /* Test the buffer size */ @@ -1622,7 +1620,7 @@ int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev, i_ReturnValue = -101; } - return (i_ReturnValue); + return i_ReturnValue; } /* @@ -1638,7 +1636,7 @@ int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev, +----------------------------------------------------------------------------+ */ -int i_APCI3XXX_Reset(struct comedi_device * dev) +int i_APCI3XXX_Reset(struct comedi_device *dev) { unsigned char b_Cpt = 0; diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index bac018202fe8..da454e854c4c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -1,5 +1,5 @@ #define CONFIG_APCI_035 1 -#define ADDIDATA_WATCHDOG 2 // Or shold it be something else +#define ADDIDATA_WATCHDOG 2 /* Or shold it be something else */ #include "addi-data/addi_common.c" diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index f710f551820d..b4807fc7eb01 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -61,35 +61,35 @@ struct pci6208_board { const char *name; unsigned short dev_id; /* `lspci` will show you this */ int ao_chans; - //int ao_bits; + /* int ao_bits; */ }; static const struct pci6208_board pci6208_boards[] = { /*{ - name : "pci6208v", - dev_id : 0x6208, //not sure - ao_chans: 8 - //, ao_bits : 16 + .name = "pci6208v", + .dev_id = 0x6208, // not sure + .ao_chans = 8 + // , .ao_bits = 16 }, { - name : "pci6216v", - dev_id : 0x6208, //not sure - ao_chans: 16 - //, ao_bits : 16 + .name = "pci6216v", + .dev_id = 0x6208, // not sure + .ao_chans = 16 + // , .ao_bits = 16 }, */ { - name: "pci6208a", - dev_id: 0x6208, - ao_chans:8 - //, ao_bits : 16 + .name = "pci6208a", + .dev_id = 0x6208, + .ao_chans = 8 + /* , .ao_bits = 16 */ } }; /* This is used by modprobe to translate PCI IDs to drivers. Should * only be used for PCI and ISA-PnP devices */ static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = { - //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ + /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ {PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {0} }; @@ -107,35 +107,32 @@ struct pci6208_private { #define devpriv ((struct pci6208_private *)dev->private) -static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci6208_detach(struct comedi_device * dev); - -#define pci6208_board_nbr \ - (sizeof(pci6208_boards) / sizeof(struct pci6208_board)) +static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci6208_detach(struct comedi_device *dev); static struct comedi_driver driver_pci6208 = { - driver_name:PCI6208_DRIVER_NAME, - module:THIS_MODULE, - attach:pci6208_attach, - detach:pci6208_detach, + .driver_name = PCI6208_DRIVER_NAME, + .module = THIS_MODULE, + .attach = pci6208_attach, + .detach = pci6208_detach, }; COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table); -static int pci6208_find_device(struct comedi_device * dev, int bus, int slot); +static int pci6208_find_device(struct comedi_device *dev, int bus, int slot); static int pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, int dev_minor); /*read/write functions*/ -static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, -// struct comedi_insn *insn,unsigned int *data); -//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, -// struct comedi_insn *insn,unsigned int *data); +static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* struct comedi_insn *insn,unsigned int *data); */ +/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* struct comedi_insn *insn,unsigned int *data); */ /* * Attach is called by the Comedi core to configure the driver @@ -143,7 +140,7 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * in the driver structure, dev->board_ptr contains that * address. */ -static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int retval; @@ -176,22 +173,22 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * s = dev->subdevices + 0; /* analog output subdevice */ s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; //anything else to add here?? + s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */ s->n_chan = thisboard->ao_chans; - s->maxdata = 0xffff; //16-bit DAC - s->range_table = &range_bipolar10; //this needs to be checked. + s->maxdata = 0xffff; /* 16-bit DAC */ + s->range_table = &range_bipolar10; /* this needs to be checked. */ s->insn_write = pci6208_ao_winsn; s->insn_read = pci6208_ao_rinsn; - //s=dev->subdevices+1; + /* s=dev->subdevices+1; */ /* digital i/o subdevice */ - //s->type=COMEDI_SUBD_DIO; - //s->subdev_flags=SDF_READABLE|SDF_WRITABLE; - //s->n_chan=16; - //s->maxdata=1; - //s->range_table=&range_digital; - //s->insn_bits = pci6208_dio_insn_bits; - //s->insn_config = pci6208_dio_insn_config; + /* s->type=COMEDI_SUBD_DIO; */ + /* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */ + /* s->n_chan=16; */ + /* s->maxdata=1; */ + /* s->range_table=&range_digital; */ + /* s->insn_bits = pci6208_dio_insn_bits; */ + /* s->insn_config = pci6208_dio_insn_config; */ printk("attached\n"); @@ -206,7 +203,7 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pci6208_detach(struct comedi_device * dev) +static int pci6208_detach(struct comedi_device *dev) { printk("comedi%d: pci6208: remove\n", dev->minor); @@ -220,8 +217,8 @@ static int pci6208_detach(struct comedi_device * dev) return 0; } -static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i = 0, Data_Read; unsigned short chan = CR_CHAN(insn->chanspec); @@ -245,8 +242,8 @@ static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -262,51 +259,51 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, -// struct comedi_insn *insn,unsigned int *data) -//{ -// if(insn->n!=2)return -EINVAL; +/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* struct comedi_insn *insn,unsigned int *data) */ +/* { */ +/* if(insn->n!=2)return -EINVAL; */ /* The insn data is a mask in data[0] and the new data * in data[1], each channel cooresponding to a bit. */ -// if(data[0]){ -// s->state &= ~data[0]; -// s->state |= data[0]&data[1]; +/* if(data[0]){ */ +/* s->state &= ~data[0]; */ +/* s->state |= data[0]&data[1]; */ /* Write out the new digital output lines */ - //outw(s->state,dev->iobase + SKEL_DIO); -// } + /* outw(s->state,dev->iobase + SKEL_DIO); */ +/* } */ /* on return, data[1] contains the value of the digital * input and output lines. */ - //data[1]=inw(dev->iobase + SKEL_DIO); + /* data[1]=inw(dev->iobase + SKEL_DIO); */ /* or we could just return the software copy of the output values if * it was a purely digital output subdevice */ - //data[1]=s->state; + /* data[1]=s->state; */ -// return 2; -//} +/* return 2; */ +/* } */ -//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, -// struct comedi_insn *insn,unsigned int *data) -//{ -// int chan=CR_CHAN(insn->chanspec); +/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* struct comedi_insn *insn,unsigned int *data) */ +/* { */ +/* int chan=CR_CHAN(insn->chanspec); */ /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ -// if(data[0]==COMEDI_OUTPUT){ -// s->io_bits |= 1<<chan; -// }else{ -// s->io_bits &= ~(1<<chan); -// } - //outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); +/* if(data[0]==COMEDI_OUTPUT){ */ +/* s->io_bits |= 1<<chan; */ +/* }else{ */ +/* s->io_bits &= ~(1<<chan); */ +/* } */ + /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */ -// return 1; -//} +/* return 1; */ +/* } */ -static int pci6208_find_device(struct comedi_device * dev, int bus, int slot) +static int pci6208_find_device(struct comedi_device *dev, int bus, int slot) { struct pci_dev *pci_dev; int i; @@ -315,11 +312,11 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot) pci_dev != NULL; pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) { - for (i = 0; i < pci6208_board_nbr; i++) { + for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) { if (pci6208_boards[i].dev_id == pci_dev->device) { - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if ((bus != 0) || (slot != 0)) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pci_dev->bus->number != bus || PCI_SLOT(pci_dev->devfn) @@ -346,10 +343,10 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot) PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn), pci_dev->irq); - // TODO: Warn about non-tested boards. - //switch(board->device_id) - //{ - //}; + /* TODO: Warn about non-tested boards. */ + /* switch(board->device_id) */ + /* { */ + /* }; */ devpriv->pci_dev = pci_dev; @@ -362,19 +359,19 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, { unsigned long io_base, io_range, lcr_io_base, lcr_io_range; - // Enable PCI device and request regions + /* Enable PCI device and request regions */ if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) { printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor); return -EIO; } - // Read local configuration register base address [PCI_BASE_ADDRESS #1]. + /* Read local configuration register base address [PCI_BASE_ADDRESS #1]. */ lcr_io_base = pci_resource_start(pci_dev, 1); lcr_io_range = pci_resource_len(pci_dev, 1); printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n", dev_minor, lcr_io_base, lcr_io_range); - // Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. + /* Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */ io_base = pci_resource_start(pci_dev, 2); io_range = pci_resource_end(pci_dev, 2) - io_base + 1; @@ -382,10 +379,10 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, dev_minor, io_base, io_range); *io_base_ptr = io_base; - //devpriv->io_range = io_range; - //devpriv->is_valid=0; - //devpriv->lcr_io_base=lcr_io_base; - //devpriv->lcr_io_range=lcr_io_range; + /* devpriv->io_range = io_range; */ + /* devpriv->is_valid=0; */ + /* devpriv->lcr_io_base=lcr_io_base; */ + /* devpriv->lcr_io_range=lcr_io_range; */ return 0; } diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c index bd0f9ab226ef..d2f23a88608d 100644 --- a/drivers/staging/comedi/drivers/adl_pci7296.c +++ b/drivers/staging/comedi/drivers/adl_pci7296.c @@ -39,7 +39,7 @@ Configuration Options: #include "comedi_pci.h" #include "8255.h" -// #include "8253.h" +/* #include "8253.h" */ #define PORT1A 0 #define PORT2A 4 @@ -64,16 +64,16 @@ struct adl_pci7296_private { #define devpriv ((struct adl_pci7296_private *)dev->private) -static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int adl_pci7296_detach(struct comedi_device * dev); +static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci7296_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci7296 = { - driver_name:"adl_pci7296", - module:THIS_MODULE, - attach:adl_pci7296_attach, - detach:adl_pci7296_detach, + .driver_name = "adl_pci7296", + .module = THIS_MODULE, + .attach = adl_pci7296_attach, + .detach = adl_pci7296_detach, }; -static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -115,7 +115,7 @@ static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfi dev->iobase = pci_resource_start(pcidev, 2); printk("comedi: base addr %4lx\n", dev->iobase); - // four 8255 digital io subdevices + /* four 8255 digital io subdevices */ s = dev->subdevices + 0; subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase)); @@ -149,7 +149,7 @@ static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfi return -EIO; } -static int adl_pci7296_detach(struct comedi_device * dev) +static int adl_pci7296_detach(struct comedi_device *dev) { printk("comedi%d: pci7432: remove\n", dev->minor); @@ -159,7 +159,7 @@ static int adl_pci7296_detach(struct comedi_device * dev) } pci_dev_put(devpriv->pci_dev); } - // detach four 8255 digital io subdevices + /* detach four 8255 digital io subdevices */ if (dev->subdevices) { subdev_8255_cleanup(dev, dev->subdevices + 0); subdev_8255_cleanup(dev, dev->subdevices + 1); diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c index a8f1715608d1..78becbdd17a8 100644 --- a/drivers/staging/comedi/drivers/adl_pci7432.c +++ b/drivers/staging/comedi/drivers/adl_pci7432.c @@ -58,26 +58,26 @@ struct adl_pci7432_private { #define devpriv ((struct adl_pci7432_private *)dev->private) -static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int adl_pci7432_detach(struct comedi_device * dev); +static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci7432_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci7432 = { - driver_name:"adl_pci7432", - module:THIS_MODULE, - attach:adl_pci7432_attach, - detach:adl_pci7432_detach, + .driver_name = "adl_pci7432", + .module = THIS_MODULE, + .attach = adl_pci7432_attach, + .detach = adl_pci7432_detach, }; /* Digital IO */ -static int adl_pci7432_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* */ -static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -150,7 +150,7 @@ static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfi return -EIO; } -static int adl_pci7432_detach(struct comedi_device * dev) +static int adl_pci7432_detach(struct comedi_device *dev) { printk("comedi%d: pci7432: remove\n", dev->minor); @@ -164,8 +164,8 @@ static int adl_pci7432_detach(struct comedi_device * dev) return 0; } -static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { printk("comedi: pci7432_do_insn_bits called\n"); printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); @@ -184,8 +184,8 @@ static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_su return 2; } -static int adl_pci7432_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { printk("comedi: pci7432_di_insn_bits called\n"); printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index adf90be79983..2d7d68af6b1e 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -70,40 +70,40 @@ struct adl_pci8164_private { #define devpriv ((struct adl_pci8164_private *)dev->private) -static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int adl_pci8164_detach(struct comedi_device * dev); +static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci8164_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci8164 = { - driver_name:"adl_pci8164", - module:THIS_MODULE, - attach:adl_pci8164_attach, - detach:adl_pci8164_detach, + .driver_name = "adl_pci8164", + .module = THIS_MODULE, + .attach = adl_pci8164_attach, + .detach = adl_pci8164_detach, }; -static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_read_msts(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_read_ssts(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_read_buf0(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_read_buf1(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_write_otp(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_write_buf0(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_write_buf0(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_insn_write_buf1(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -149,7 +149,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi s->n_chan = 4; s->maxdata = 0xffff; s->len_chanlist = 4; - //s->range_table = &range_axis; + /* s->range_table = &range_axis; */ s->insn_read = adl_pci8164_insn_read_msts; s->insn_write = adl_pci8164_insn_write_cmd; @@ -159,7 +159,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi s->n_chan = 4; s->maxdata = 0xffff; s->len_chanlist = 4; - //s->range_table = &range_axis; + /* s->range_table = &range_axis; */ s->insn_read = adl_pci8164_insn_read_ssts; s->insn_write = adl_pci8164_insn_write_otp; @@ -169,7 +169,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi s->n_chan = 4; s->maxdata = 0xffff; s->len_chanlist = 4; - //s->range_table = &range_axis; + /* s->range_table = &range_axis; */ s->insn_read = adl_pci8164_insn_read_buf0; s->insn_write = adl_pci8164_insn_write_buf0; @@ -179,7 +179,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi s->n_chan = 4; s->maxdata = 0xffff; s->len_chanlist = 4; - //s->range_table = &range_axis; + /* s->range_table = &range_axis; */ s->insn_read = adl_pci8164_insn_read_buf1; s->insn_write = adl_pci8164_insn_write_buf1; @@ -194,7 +194,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi return -EIO; } -static int adl_pci8164_detach(struct comedi_device * dev) +static int adl_pci8164_detach(struct comedi_device *dev) { printk("comedi%d: pci8164: remove\n", dev->minor); @@ -208,8 +208,16 @@ static int adl_pci8164_detach(struct comedi_device * dev) return 0; } -static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* + all the read commands are the same except for the addition a constant + * const to the data for inw() + */ +static void adl_pci8164_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data, + char *action, + unsigned short offset) { int axis, axis_reg; char *axisname; @@ -238,127 +246,51 @@ static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_ axisname = "X"; } - data[0] = inw(dev->iobase + axis_reg + PCI8164_MSTS); - printk("comedi: pci8164 MSTS read -> %04X:%04X on axis %s\n", data[0], + data[0] = inw(dev->iobase + axis_reg + offset); + printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, data[0], data[1], axisname); +} +static int adl_pci8164_insn_read_msts(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + adl_pci8164_insn_read(dev, s, insn, data, "MSTS", PCI8164_MSTS); return 2; } -static int adl_pci8164_insn_read_ssts(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int axis, axis_reg; - char *axisname; - - axis = CR_CHAN(insn->chanspec); - - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } - - data[0] = inw(dev->iobase + axis_reg + PCI8164_SSTS); - printk("comedi: pci8164 SSTS read -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); - + adl_pci8164_insn_read(dev, s, insn, data, "SSTS", PCI8164_SSTS); return 2; } -static int adl_pci8164_insn_read_buf0(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int axis, axis_reg; - char *axisname; - - axis = CR_CHAN(insn->chanspec); - - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } - - data[0] = inw(dev->iobase + axis_reg + PCI8164_BUF0); - printk("comedi: pci8164 BUF0 read -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); - + adl_pci8164_insn_read(dev, s, insn, data, "BUF0", PCI8164_BUF0); return 2; } -static int adl_pci8164_insn_read_buf1(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int axis, axis_reg; - - char *axisname; - - axis = CR_CHAN(insn->chanspec); - - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } - - data[0] = inw(dev->iobase + axis_reg + PCI8164_BUF1); - printk("comedi: pci8164 BUF1 read -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); - + adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1); return 2; } -static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* + all the write commands are the same except for the addition a constant + * const to the data for outw() + */ +static void adl_pci8164_insn_out(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data, + char *action, + unsigned short offset) { unsigned int axis, axis_reg; @@ -388,124 +320,39 @@ static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_ axisname = "X"; } - outw(data[0], dev->iobase + axis_reg + PCI8164_CMD); - printk("comedi: pci8164 CMD write -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); - - return 2; -} - -static int adl_pci8164_insn_write_otp(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) -{ - int axis, axis_reg; - - char *axisname; + outw(data[0], dev->iobase + axis_reg + offset); - axis = CR_CHAN(insn->chanspec); + printk("comedi: pci8164 %s write -> %04X:%04X on axis %s\n", action, + data[0], data[1], axisname); - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } +} - outw(data[0], dev->iobase + axis_reg + PCI8164_OTP); - printk("comedi: pci8164 OTP write -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); +static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD); return 2; } -static int adl_pci8164_insn_write_buf0(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int axis, axis_reg; - - char *axisname; - - axis = CR_CHAN(insn->chanspec); - - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } - - outw(data[0], dev->iobase + axis_reg + PCI8164_BUF0); - printk("comedi: pci8164 BUF0 write -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); - + adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP); return 2; } -static int adl_pci8164_insn_write_buf1(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int adl_pci8164_insn_write_buf0(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int axis, axis_reg; - - char *axisname; - - axis = CR_CHAN(insn->chanspec); - - switch (axis) { - case 0: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - break; - case 1: - axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; - break; - case 2: - axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; - break; - case 3: - axis_reg = PCI8164_AXIS_U; - axisname = "U"; - break; - default: - axis_reg = PCI8164_AXIS_X; - axisname = "X"; - } - - outw(data[0], dev->iobase + axis_reg + PCI8164_BUF1); - printk("comedi: pci8164 BUF1 write -> %04X:%04X on axis %s\n", data[0], - data[1], axisname); + adl_pci8164_insn_out(dev, s, insn, data, "BUF0", PCI8164_BUF0); + return 2; +} +static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) +{ + adl_pci8164_insn_out(dev, s, insn, data, "BUF1", PCI8164_BUF1); return 2; } diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index b4a61c560c5b..0ac722e6f37a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -77,6 +77,7 @@ TODO: #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "8253.h" #include "comedi_pci.h" @@ -186,24 +187,24 @@ TODO: (inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK)&0x0F) #define pci9111_trigger_and_autoscan_set(flags) \ - outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_TRIGGER_MODE_CONTROL) + outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_TRIGGER_MODE_CONTROL) #define pci9111_interrupt_and_fifo_get() \ ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK) >> 4) &0x03) #define pci9111_interrupt_and_fifo_set(flags) \ - outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) + outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) #define pci9111_interrupt_clear() \ - outb(0,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CLEAR) + outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CLEAR) #define pci9111_software_trigger() \ - outb(0,PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER) + outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER) #define pci9111_fifo_reset() \ - outb(PCI9111_FFEN_SET_FIFO_ENABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ - outb(PCI9111_FFEN_SET_FIFO_DISABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ - outb(PCI9111_FFEN_SET_FIFO_ENABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) + outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ + outb(PCI9111_FFEN_SET_FIFO_DISABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ + outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) #define pci9111_is_fifo_full() \ ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \ @@ -218,13 +219,13 @@ TODO: PCI9111_FIFO_EMPTY_MASK)==0) #define pci9111_ai_channel_set(channel) \ - outb((channel)&PCI9111_CHANNEL_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL) + outb((channel)&PCI9111_CHANNEL_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL) #define pci9111_ai_channel_get() \ inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_READBACK)&PCI9111_CHANNEL_MASK #define pci9111_ai_range_set(range) \ - outb((range)&PCI9111_RANGE_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE) + outb((range)&PCI9111_RANGE_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE) #define pci9111_ai_range_get() \ inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)&PCI9111_RANGE_MASK @@ -238,34 +239,34 @@ TODO: ^ PCI9111_HR_AI_RESOLUTION_2_CMP_BIT #define pci9111_ao_set_data(data) \ - outw(data&PCI9111_AO_RESOLUTION_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_DA_OUTPUT) + outw(data&PCI9111_AO_RESOLUTION_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_DA_OUTPUT) #define pci9111_di_get_bits() \ inw(PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO) #define pci9111_do_set_bits(bits) \ - outw(bits,PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO) + outw(bits, PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO) #define pci9111_8254_control_set(flags) \ - outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_8254_CONTROL) + outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_8254_CONTROL) #define pci9111_8254_counter_0_set(data) \ outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0); \ - outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0) + outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0) #define pci9111_8254_counter_1_set(data) \ outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1); \ - outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1) + outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1) #define pci9111_8254_counter_2_set(data) \ outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \ - outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2) + outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2) /* Function prototypes */ -static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci9111_detach(struct comedi_device * dev); -static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci9111_detach(struct comedi_device *dev); +static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int start_chan_index); static const struct comedi_lrange pci9111_hr_ai_range = { @@ -308,27 +309,27 @@ struct pci9111_board { static const struct pci9111_board pci9111_boards[] = { { - name: "pci9111_hr", - device_id:PCI9111_HR_DEVICE_ID, - ai_channel_nbr:PCI9111_AI_CHANNEL_NBR, - ao_channel_nbr:PCI9111_AO_CHANNEL_NBR, - ai_resolution:PCI9111_HR_AI_RESOLUTION, - ai_resolution_mask:PCI9111_HR_AI_RESOLUTION_MASK, - ao_resolution:PCI9111_AO_RESOLUTION, - ao_resolution_mask:PCI9111_AO_RESOLUTION_MASK, - ai_range_list:&pci9111_hr_ai_range, - ao_range_list:&range_bipolar10, - ai_acquisition_period_min_ns:PCI9111_AI_ACQUISITION_PERIOD_MIN_NS} + .name = "pci9111_hr", + .device_id = PCI9111_HR_DEVICE_ID, + .ai_channel_nbr = PCI9111_AI_CHANNEL_NBR, + .ao_channel_nbr = PCI9111_AO_CHANNEL_NBR, + .ai_resolution = PCI9111_HR_AI_RESOLUTION, + .ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK, + .ao_resolution = PCI9111_AO_RESOLUTION, + .ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK, + .ai_range_list = &pci9111_hr_ai_range, + .ao_range_list = &range_bipolar10, + .ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS} }; #define pci9111_board_nbr \ (sizeof(pci9111_boards)/sizeof(struct pci9111_board)) static struct comedi_driver pci9111_driver = { - driver_name:PCI9111_DRIVER_NAME, - module:THIS_MODULE, - attach:pci9111_attach, - detach:pci9111_detach, + .driver_name = PCI9111_DRIVER_NAME, + .module = THIS_MODULE, + .attach = pci9111_attach, + .detach = pci9111_detach, }; COMEDI_PCI_INITCLEANUP(pci9111_driver, pci9111_pci_table); @@ -405,7 +406,7 @@ static void plx9050_interrupt_control(unsigned long io_base, /* 8254 timer */ -static void pci9111_timer_set(struct comedi_device * dev) +static void pci9111_timer_set(struct comedi_device *dev) { pci9111_8254_control_set(PCI9111_8254_COUNTER_0 | PCI9111_8254_READ_LOAD_LSB_MSB | @@ -419,7 +420,7 @@ static void pci9111_timer_set(struct comedi_device * dev) PCI9111_8254_READ_LOAD_LSB_MSB | PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER); - comedi_udelay(1); + udelay(1); pci9111_8254_counter_2_set(dev_private->timer_divisor_2); pci9111_8254_counter_1_set(dev_private->timer_divisor_1); @@ -431,7 +432,7 @@ enum pci9111_trigger_sources { external }; -static void pci9111_trigger_source_set(struct comedi_device * dev, +static void pci9111_trigger_source_set(struct comedi_device *dev, enum pci9111_trigger_sources source) { int flags; @@ -455,7 +456,7 @@ static void pci9111_trigger_source_set(struct comedi_device * dev, pci9111_trigger_and_autoscan_set(flags); } -static void pci9111_pretrigger_set(struct comedi_device * dev, bool pretrigger) +static void pci9111_pretrigger_set(struct comedi_device *dev, bool pretrigger) { int flags; @@ -467,7 +468,7 @@ static void pci9111_pretrigger_set(struct comedi_device * dev, bool pretrigger) pci9111_trigger_and_autoscan_set(flags); } -static void pci9111_autoscan_set(struct comedi_device * dev, bool autoscan) +static void pci9111_autoscan_set(struct comedi_device *dev, bool autoscan) { int flags; @@ -489,7 +490,7 @@ enum pci9111_ISC1_sources { irq_on_external_trigger }; -static void pci9111_interrupt_source_set(struct comedi_device * dev, +static void pci9111_interrupt_source_set(struct comedi_device *dev, enum pci9111_ISC0_sources irq_0_source, enum pci9111_ISC1_sources irq_1_source) { int flags; @@ -513,7 +514,7 @@ static void pci9111_interrupt_source_set(struct comedi_device * dev, #undef AI_DO_CMD_DEBUG -static int pci9111_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { /* Disable interrupts */ @@ -535,14 +536,14 @@ static int pci9111_ai_cancel(struct comedi_device * dev, struct comedi_subdevice /* Test analog input command */ -#define pci9111_check_trigger_src(src,flags) \ +#define pci9111_check_trigger_src(src, flags) \ tmp = src; \ src &= flags; \ if (!src || tmp != src) error++ static int -pci9111_ai_do_cmd_test(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_cmd * cmd) +pci9111_ai_do_cmd_test(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int tmp; int error = 0; @@ -740,7 +741,7 @@ pci9111_ai_do_cmd_test(struct comedi_device * dev, /* Analog input command */ -static int pci9111_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * subdevice) +static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice) { struct comedi_cmd *async_cmd = &subdevice->async->cmd; @@ -858,7 +859,7 @@ static int pci9111_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice return 0; } -static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int start_chan_index) { unsigned int i, num_samples = num_bytes / sizeof(short); @@ -884,7 +885,7 @@ static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice #undef INTERRUPT_DEBUG -static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) +static irqreturn_t pci9111_interrupt(int irq, void *p_device) { struct comedi_device *dev = p_device; struct comedi_subdevice *subdevice = dev->read_subdev; @@ -900,7 +901,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) async = subdevice->async; - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); /* Check if we are source of interrupt */ intcsr = inb(dev_private->lcr_io_base + @@ -918,7 +919,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) PLX9050_LINTI2_STATUS))))) { /* Not the source of the interrupt. */ /* (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return IRQ_NONE; } @@ -927,7 +928,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) /* Interrupt comes from fifo_half-full signal */ if (pci9111_is_fifo_full()) { - comedi_spin_unlock_irqrestore(&dev->spinlock, + spin_unlock_irqrestore(&dev->spinlock, irq_flags); comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow"); pci9111_interrupt_clear(); @@ -1027,7 +1028,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) pci9111_interrupt_clear(); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); comedi_event(dev, subdevice); @@ -1042,8 +1043,8 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG) #undef AI_INSN_DEBUG -static int pci9111_ai_insn_read(struct comedi_device * dev, - struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data) +static int pci9111_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) { int resolution = ((struct pci9111_board *) dev->board_ptr)->ai_resolution; @@ -1100,8 +1101,8 @@ static int pci9111_ai_insn_read(struct comedi_device * dev, /* Analog instant output */ static int -pci9111_ao_insn_write(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +pci9111_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i; @@ -1115,8 +1116,8 @@ pci9111_ao_insn_write(struct comedi_device * dev, /* Analog output readback */ -static int pci9111_ao_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int pci9111_ao_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i; @@ -1133,8 +1134,8 @@ static int pci9111_ao_insn_read(struct comedi_device * dev, /* Digital inputs */ -static int pci9111_di_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data) +static int pci9111_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -1146,8 +1147,8 @@ static int pci9111_di_insn_bits(struct comedi_device * dev, /* Digital outputs */ -static int pci9111_do_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data) +static int pci9111_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -1175,7 +1176,7 @@ static int pci9111_do_insn_bits(struct comedi_device * dev, /* Reset device */ -static int pci9111_reset(struct comedi_device * dev) +static int pci9111_reset(struct comedi_device *dev) { /* Set trigger source to software */ @@ -1200,7 +1201,7 @@ static int pci9111_reset(struct comedi_device * dev) /* - Register PCI device */ /* - Declare device driver capability */ -static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *subdevice; unsigned long io_base, io_range, lcr_io_base, lcr_io_range; @@ -1297,8 +1298,7 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * dev->irq = 0; if (pci_device->irq > 0) { - if (comedi_request_irq(pci_device->irq, - pci9111_interrupt, + if (request_irq(pci_device->irq, pci9111_interrupt, IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) { printk("comedi%d: unable to allocate irq %u\n", dev->minor, pci_device->irq); @@ -1309,7 +1309,8 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * /* TODO: Add external multiplexer setup (according to option[2]). */ - if ((error = alloc_subdevices(dev, 4)) < 0) + error = alloc_subdevices(dev, 4); + if (error < 0) return error; subdevice = dev->subdevices + 0; @@ -1365,7 +1366,7 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * /* Detach */ -static int pci9111_detach(struct comedi_device * dev) +static int pci9111_detach(struct comedi_device *dev) { /* Reset device */ @@ -1377,7 +1378,7 @@ static int pci9111_detach(struct comedi_device * dev) /* Release previously allocated irq */ if (dev->irq != 0) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev_private != 0 && dev_private->pci_device != 0) { diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 278cf30cc4a3..65f522be9124 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -66,6 +66,7 @@ Configuration options: #include "../pci_ids.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "amcc_s5933.h" #include "8253.h" @@ -79,7 +80,7 @@ Configuration options: #undef DPRINTK #ifdef PCI9118_EXTDEBUG -#define DPRINTK(fmt, args...) rt_printk(fmt, ## args) +#define DPRINTK(fmt, args...) printk(fmt, ## args) #else #define DPRINTK(fmt, args...) #endif @@ -107,7 +108,7 @@ Configuration options: #define PCI9118_INTSRC 0x38 /* R: interrupt reason register */ #define PCI9118_INTCTRL 0x38 /* W: interrupt control register */ -// bits from A/D control register (PCI9118_ADCNTRL) +/* bits from A/D control register (PCI9118_ADCNTRL) */ #define AdControl_UniP 0x80 /* 1=bipolar, 0=unipolar */ #define AdControl_Diff 0x40 /* 1=differential, 0= single end inputs */ #define AdControl_SoftG 0x20 /* 1=8254 counter works, 0=counter stops */ @@ -117,7 +118,7 @@ Configuration options: #define AdControl_Int 0x02 /* 1=enable INT, 0=disable */ #define AdControl_Dma 0x01 /* 1=enable DMA, 0=disable */ -// bits from A/D function register (PCI9118_ADFUNC) +/* bits from A/D function register (PCI9118_ADFUNC) */ #define AdFunction_PDTrg 0x80 /* 1=positive, 0=negative digital trigger (only positive is correct) */ #define AdFunction_PETrg 0x40 /* 1=positive, 0=negative external trigger (only positive is correct) */ #define AdFunction_BSSH 0x20 /* 1=with sample&hold, 0=without */ @@ -127,7 +128,7 @@ Configuration options: #define AdFunction_AM 0x02 /* 1=about trigger mode, 0=not about trigger */ #define AdFunction_Start 0x01 /* 1=trigger start, 0=trigger stop */ -// bits from A/D status register (PCI9118_ADSTAT) +/* bits from A/D status register (PCI9118_ADSTAT) */ #define AdStatus_nFull 0x100 /* 0=FIFO full (fatal), 1=not full */ #define AdStatus_nHfull 0x080 /* 0=FIFO half full, 1=FIFO not half full */ #define AdStatus_nEpty 0x040 /* 0=FIFO empty, 1=FIFO not empty */ @@ -138,8 +139,8 @@ Configuration options: #define AdStatus_ADOR 0x002 /* 1=A/D overrun (fatal) */ #define AdStatus_ADrdy 0x001 /* 1=A/D already ready, 0=not ready */ -// bits for interrupt reason and control (PCI9118_INTSRC, PCI9118_INTCTRL) -// 1=interrupt occur, enable source, 0=interrupt not occur, disable source +/* bits for interrupt reason and control (PCI9118_INTSRC, PCI9118_INTCTRL) */ +/* 1=interrupt occur, enable source, 0=interrupt not occur, disable source */ #define Int_Timer 0x08 /* timer interrupt */ #define Int_About 0x04 /* about trigger complete */ #define Int_Hfull 0x02 /* A/D FIFO hlaf full */ @@ -178,27 +179,27 @@ static const struct comedi_lrange range_pci9118hg = { 8, { #define PCI9118_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */ -static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci9118_detach(struct comedi_device * dev); +static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci9118_detach(struct comedi_device *dev); struct boardtype { - const char *name; // board name - int vendor_id; // PCI vendor a device ID of card + const char *name; /* board name */ + int vendor_id; /* PCI vendor a device ID of card */ int device_id; - int iorange_amcc; // iorange for own S5933 region - int iorange_9118; // pass thru card region size - int n_aichan; // num of A/D chans - int n_aichand; // num of A/D chans in diff mode - int mux_aichan; // num of A/D chans with external multiplexor - int n_aichanlist; // len of chanlist - int n_aochan; // num of D/A chans - int ai_maxdata; // resolution of A/D - int ao_maxdata; // resolution of D/A - const struct comedi_lrange *rangelist_ai; // rangelist for A/D - const struct comedi_lrange *rangelist_ao; // rangelist for D/A - unsigned int ai_ns_min; // max sample speed of card v ns - unsigned int ai_pacer_min; // minimal pacer value (c1*c2 or c1 in burst) - int half_fifo_size; // size of FIFO/2 + int iorange_amcc; /* iorange for own S5933 region */ + int iorange_9118; /* pass thru card region size */ + int n_aichan; /* num of A/D chans */ + int n_aichand; /* num of A/D chans in diff mode */ + int mux_aichan; /* num of A/D chans with external multiplexor */ + int n_aichanlist; /* len of chanlist */ + int n_aochan; /* num of D/A chans */ + int ai_maxdata; /* resolution of A/D */ + int ao_maxdata; /* resolution of D/A */ + const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ + unsigned int ai_ns_min; /* max sample speed of card v ns */ + unsigned int ai_pacer_min; /* minimal pacer value (c1*c2 or c1 in burst) */ + int half_fifo_size; /* size of FIFO/2 */ }; @@ -230,75 +231,75 @@ static const struct boardtype boardtypes[] = { #define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype)) static struct comedi_driver driver_pci9118 = { - driver_name:"adl_pci9118", - module:THIS_MODULE, - attach:pci9118_attach, - detach:pci9118_detach, - num_names:n_boardtypes, - board_name:&boardtypes[0].name, - offset:sizeof(struct boardtype), + .driver_name = "adl_pci9118", + .module = THIS_MODULE, + .attach = pci9118_attach, + .detach = pci9118_detach, + .num_names = n_boardtypes, + .board_name = &boardtypes[0].name, + .offset = sizeof(struct boardtype), }; COMEDI_PCI_INITCLEANUP(driver_pci9118, pci9118_pci_table); struct pci9118_private { - unsigned long iobase_a; // base+size for AMCC chip - unsigned int master; // master capable - struct pci_dev *pcidev; // ptr to actual pcidev - unsigned int usemux; // we want to use external multiplexor! + unsigned long iobase_a; /* base+size for AMCC chip */ + unsigned int master; /* master capable */ + struct pci_dev *pcidev; /* ptr to actual pcidev */ + unsigned int usemux; /* we want to use external multiplexor! */ #ifdef PCI9118_PARANOIDCHECK - unsigned short chanlist[PCI9118_CHANLEN + 1]; // list of scaned channel - unsigned char chanlistlen; // number of scanlist + unsigned short chanlist[PCI9118_CHANLEN + 1]; /* list of scaned channel */ + unsigned char chanlistlen; /* number of scanlist */ #endif - unsigned char AdControlReg; // A/D control register - unsigned char IntControlReg; // Interrupt control register - unsigned char AdFunctionReg; // A/D function register - char valid; // driver is ok - char ai_neverending; // we do unlimited AI - unsigned int i8254_osc_base; // frequence of onboard oscilator - unsigned int ai_do; // what do AI? 0=nothing, 1 to 4 mode - unsigned int ai_act_scan; // how many scans we finished - unsigned int ai_buf_ptr; // data buffer ptr in samples - unsigned int ai_n_chan; // how many channels is measured - unsigned int ai_n_scanlen; // len of actual scanlist - unsigned int ai_n_realscanlen; // what we must transfer for one outgoing scan include front/back adds - unsigned int ai_act_dmapos; // position in actual real stream - unsigned int ai_add_front; // how many channels we must add before scan to satisfy S&H? - unsigned int ai_add_back; // how many channels we must add before scan to satisfy DMA? - unsigned int *ai_chanlist; // actaul chanlist + unsigned char AdControlReg; /* A/D control register */ + unsigned char IntControlReg; /* Interrupt control register */ + unsigned char AdFunctionReg; /* A/D function register */ + char valid; /* driver is ok */ + char ai_neverending; /* we do unlimited AI */ + unsigned int i8254_osc_base; /* frequence of onboard oscilator */ + unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ + unsigned int ai_act_scan; /* how many scans we finished */ + unsigned int ai_buf_ptr; /* data buffer ptr in samples */ + unsigned int ai_n_chan; /* how many channels is measured */ + unsigned int ai_n_scanlen; /* len of actual scanlist */ + unsigned int ai_n_realscanlen; /* what we must transfer for one outgoing scan include front/back adds */ + unsigned int ai_act_dmapos; /* position in actual real stream */ + unsigned int ai_add_front; /* how many channels we must add before scan to satisfy S&H? */ + unsigned int ai_add_back; /* how many channels we must add before scan to satisfy DMA? */ + unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_timer1; unsigned int ai_timer2; unsigned int ai_flags; - char ai12_startstop; // measure can start/stop on external trigger - unsigned int ai_divisor1, ai_divisor2; // divisors for start of measure on external start + char ai12_startstop; /* measure can start/stop on external trigger */ + unsigned int ai_divisor1, ai_divisor2; /* divisors for start of measure on external start */ unsigned int ai_data_len; short *ai_data; - short ao_data[2]; // data output buffer - unsigned int ai_scans; // number of scans to do - char dma_doublebuf; // we can use double buffring - unsigned int dma_actbuf; // which buffer is used now - short *dmabuf_virt[2]; // pointers to begin of DMA buffer - unsigned long dmabuf_hw[2]; // hw address of DMA buff - unsigned int dmabuf_size[2]; // size of dma buffer in bytes - unsigned int dmabuf_use_size[2]; // which size we may now used for transfer - unsigned int dmabuf_used_size[2]; // which size was trully used + short ao_data[2]; /* data output buffer */ + unsigned int ai_scans; /* number of scans to do */ + char dma_doublebuf; /* we can use double buffring */ + unsigned int dma_actbuf; /* which buffer is used now */ + short *dmabuf_virt[2]; /* pointers to begin of DMA buffer */ + unsigned long dmabuf_hw[2]; /* hw address of DMA buff */ + unsigned int dmabuf_size[2]; /* size of dma buffer in bytes */ + unsigned int dmabuf_use_size[2]; /* which size we may now used for transfer */ + unsigned int dmabuf_used_size[2]; /* which size was trully used */ unsigned int dmabuf_panic_size[2]; - unsigned int dmabuf_samples[2]; // size in samples - int dmabuf_pages[2]; // number of pages in buffer - unsigned char cnt0_users; // bit field of 8254 CNT0 users (0-unused, 1-AO, 2-DI, 3-DO) - unsigned char exttrg_users; // bit field of external trigger users (0-AI, 1-AO, 2-DI, 3-DO) - unsigned int cnt0_divisor; // actual CNT0 divisor - void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); // ptr to actual interrupt AI function - unsigned char ai16bits; // =1 16 bit card - unsigned char usedma; // =1 use DMA transfer and not INT - unsigned char useeoshandle; // =1 change WAKE_EOS DMA transfer to fit on every second - unsigned char usessh; // =1 turn on S&H support - int softsshdelay; // >0 use software S&H, numer is requested delay in ns - unsigned char softsshsample; // polarity of S&H signal in sample state - unsigned char softsshhold; // polarity of S&H signal in hold state - unsigned int ai_maskerr; // which warning was printed - unsigned int ai_maskharderr; // on which error bits stops - unsigned int ai_inttrig_start; // TRIG_INT for start + unsigned int dmabuf_samples[2]; /* size in samples */ + int dmabuf_pages[2]; /* number of pages in buffer */ + unsigned char cnt0_users; /* bit field of 8254 CNT0 users (0-unused, 1-AO, 2-DI, 3-DO) */ + unsigned char exttrg_users; /* bit field of external trigger users (0-AI, 1-AO, 2-DI, 3-DO) */ + unsigned int cnt0_divisor; /* actual CNT0 divisor */ + void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); /* ptr to actual interrupt AI function */ + unsigned char ai16bits; /* =1 16 bit card */ + unsigned char usedma; /* =1 use DMA transfer and not INT */ + unsigned char useeoshandle; /* =1 change WAKE_EOS DMA transfer to fit on every second */ + unsigned char usessh; /* =1 turn on S&H support */ + int softsshdelay; /* >0 use software S&H, numer is requested delay in ns */ + unsigned char softsshsample; /* polarity of S&H signal in sample state */ + unsigned char softsshhold; /* polarity of S&H signal in hold state */ + unsigned int ai_maskerr; /* which warning was printed */ + unsigned int ai_maskharderr; /* on which error bits stops */ + unsigned int ai_inttrig_start; /* TRIG_INT for start */ }; #define devpriv ((struct pci9118_private *)dev->private) @@ -308,53 +309,53 @@ struct pci9118_private { ============================================================================== */ -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, int frontadd, int backadd); -static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd, int usedma, char eoshandle); -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); -static int pci9118_reset(struct comedi_device * dev); -static int pci9118_exttrg_add(struct comedi_device * dev, unsigned char source); -static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source); -static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void pci9118_calc_divisors(char mode, struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int *tim1, unsigned int *tim2, +static int pci9118_reset(struct comedi_device *dev); +static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source); +static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source); +static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void pci9118_calc_divisors(char mode, struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2, unsigned int flags, int chans, unsigned int *div1, unsigned int *div2, char usessh, unsigned int chnsshfront); /* ============================================================================== */ -static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, timeout; devpriv->AdControlReg = AdControl_Int & 0xff; devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0, 0)) return -EINVAL; - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ for (n = 0; n < insn->n; n++) { outw(0, dev->iobase + PCI9118_SOFTTRG); /* start conversion */ - comedi_udelay(2); + udelay(2); timeout = 100; while (timeout--) { if (inl(dev->iobase + PCI9118_ADSTAT) & AdStatus_ADrdy) goto conv_finish; - comedi_udelay(1); + udelay(1); } comedi_error(dev, "A/D insn timeout"); data[n] = 0; - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return -ETIME; conv_finish: @@ -369,7 +370,7 @@ static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdev } } - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return n; } @@ -377,8 +378,8 @@ static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci9118_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci9118_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chanreg, ch; @@ -400,8 +401,8 @@ static int pci9118_insn_write_ao(struct comedi_device * dev, struct comedi_subde /* ============================================================================== */ -static int pci9118_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci9118_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -415,8 +416,8 @@ static int pci9118_insn_read_ao(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci9118_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci9118_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inl(dev->iobase + PCI9118_DI) & 0xf; @@ -426,8 +427,8 @@ static int pci9118_insn_bits_di(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci9118_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci9118_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -442,7 +443,7 @@ static int pci9118_insn_bits_do(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static void interrupt_pci9118_ai_mode4_switch(struct comedi_device * dev) +static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev) { devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM; @@ -456,8 +457,8 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device * dev) outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); } -static unsigned int defragment_dma_buffer(struct comedi_device * dev, - struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples) +static unsigned int defragment_dma_buffer(struct comedi_device *dev, + struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) { unsigned int i = 0, j = 0; unsigned int start_pos = devpriv->ai_add_front, @@ -480,8 +481,8 @@ static unsigned int defragment_dma_buffer(struct comedi_device * dev, /* ============================================================================== */ -static unsigned int move_block_from_dma(struct comedi_device * dev, - struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples) +static unsigned int move_block_from_dma(struct comedi_device *dev, + struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) { unsigned int num_bytes; @@ -501,8 +502,8 @@ static unsigned int move_block_from_dma(struct comedi_device * dev, /* ============================================================================== */ -static char pci9118_decode_error_status(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned char m) +static char pci9118_decode_error_status(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned char m) { if (m & 0x100) { comedi_error(dev, "A/D FIFO Full status (Fatal Error!)"); @@ -531,7 +532,7 @@ static char pci9118_decode_error_status(struct comedi_device * dev, return 0; } -static void pci9118_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static void pci9118_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int start_chan_index) { unsigned int i, num_samples = num_bytes / sizeof(short); @@ -551,8 +552,8 @@ static void pci9118_ai_munge(struct comedi_device * dev, struct comedi_subdevice /* ============================================================================== */ -static void interrupt_pci9118_ai_onesample(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned short int_adstat, unsigned int int_amcc, +static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned short int_adstat, unsigned int int_amcc, unsigned short int_daq) { register short sampl; @@ -567,8 +568,8 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device * dev, #ifdef PCI9118_PARANOIDCHECK if (devpriv->ai16bits == 0) { - if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { // data dropout! - rt_printk + if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { /* data dropout! */ + printk ("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n", sampl & 0x000f, devpriv->chanlist[s->async->cur_chan]); @@ -598,7 +599,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device * dev, /* ============================================================================== */ -static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_subdevice * s, +static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned short int_adstat, unsigned int int_amcc, unsigned short int_daq) { @@ -621,14 +622,14 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s } if (int_adstat & devpriv->ai_maskerr) -// if (int_adstat & 0x106) +/* if (int_adstat & 0x106) */ if (pci9118_decode_error_status(dev, s, int_adstat)) return; - samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; // number of received real samples -// DPRINTK("dma_actbuf=%d\n",devpriv->dma_actbuf); + samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; /* number of received real samples */ +/* DPRINTK("dma_actbuf=%d\n",devpriv->dma_actbuf); */ - if (devpriv->dma_doublebuf) { // switch DMA buffers if is used double buffering + if (devpriv->dma_doublebuf) { /* switch DMA buffers if is used double buffering */ next_dma_buf = 1 - devpriv->dma_actbuf; outl(devpriv->dmabuf_hw[next_dma_buf], devpriv->iobase_a + AMCC_OP_REG_MWAR); @@ -641,15 +642,15 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s } if (samplesinbuf) { - m = devpriv->ai_data_len >> 1; // how many samples is to end of buffer -// DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); + m = devpriv->ai_data_len >> 1; /* how many samples is to end of buffer */ +/* DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); */ sampls = m; move_block_from_dma(dev, s, devpriv->dmabuf_virt[devpriv->dma_actbuf], samplesinbuf); - m = m - sampls; // m= how many samples was transfered + m = m - sampls; /* m= how many samples was transfered */ } -// DPRINTK("YYY\n"); +/* DPRINTK("YYY\n"); */ if (!devpriv->ai_neverending) if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ @@ -657,9 +658,9 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s s->async->events |= COMEDI_CB_EOA; } - if (devpriv->dma_doublebuf) { // switch dma buffers + if (devpriv->dma_doublebuf) { /* switch dma buffers */ devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; - } else { // restart DMA if is not used double buffering + } else { /* restart DMA if is not used double buffering */ outl(devpriv->dmabuf_hw[0], devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[0], @@ -674,36 +675,36 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s /* ============================================================================== */ -static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pci9118(int irq, void *d) { struct comedi_device *dev = d; unsigned int int_daq = 0, int_amcc, int_adstat; if (!dev->attached) - return IRQ_NONE; // not fully initialized + return IRQ_NONE; /* not fully initialized */ - int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; // get IRQ reasons from card - int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); // get INT register from AMCC chip + int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; /* get IRQ reasons from card */ + int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* get INT register from AMCC chip */ -// DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do); +/* DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do); */ if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) - return IRQ_NONE; // interrupt from other source + return IRQ_NONE; /* interrupt from other source */ - outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // shutdown IRQ reasons in AMCC + outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */ - int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; // get STATUS register + int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; /* get STATUS register */ if (devpriv->ai_do) { if (devpriv->ai12_startstop) - if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { // start stop of measure + if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { /* start stop of measure */ if (devpriv->ai12_startstop & START_AI_EXT) { devpriv->ai12_startstop &= ~START_AI_EXT; if (!(devpriv->ai12_startstop & STOP_AI_EXT)) - pci9118_exttrg_del(dev, EXTTRG_AI); // deactivate EXT trigger - start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); // start pacer + pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ + start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); /* start pacer */ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); } else { @@ -711,8 +712,8 @@ static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG) ai12_startstop & STOP_AI_EXT) { devpriv->ai12_startstop &= ~STOP_AI_EXT; - pci9118_exttrg_del(dev, EXTTRG_AI); // deactivate EXT trigger - devpriv->ai_neverending = 0; //well, on next interrupt from DMA/EOC measure will stop + pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ + devpriv->ai_neverending = 0; /* well, on next interrupt from DMA/EOC measure will stop */ } } } @@ -727,7 +728,7 @@ static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG) /* ============================================================================== */ -static int pci9118_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { if (trignum != devpriv->ai_inttrig_start) @@ -751,8 +752,8 @@ static int pci9118_ai_inttrig(struct comedi_device * dev, struct comedi_subdevic /* ============================================================================== */ -static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; @@ -949,11 +950,11 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic if (cmd->scan_begin_src == TRIG_TIMER) { tmp = cmd->scan_begin_arg; -// rt_printk("S1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); +/* printk("S1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, &divisor2, &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); -// rt_printk("S2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); +/* printk("S2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ if (cmd->scan_begin_arg < this_board->ai_ns_min) cmd->scan_begin_arg = this_board->ai_ns_min; if (tmp != cmd->scan_begin_arg) @@ -965,7 +966,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); -// rt_printk("s1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); +/* printk("s1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ if (cmd->convert_arg < this_board->ai_ns_min) cmd->convert_arg = this_board->ai_ns_min; if (tmp != cmd->convert_arg) @@ -979,7 +980,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic cmd->scan_begin_arg = this_board->ai_ns_min * (cmd->scan_end_arg + 2); -// rt_printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); +/* printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ err++; } } else { @@ -988,7 +989,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic cmd->scan_begin_arg = cmd->convert_arg * cmd->chanlist_len; -// rt_printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); +/* printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ err++; } } @@ -1001,7 +1002,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic if (cmd->chanlist) if (!check_channel_list(dev, s, cmd->chanlist_len, cmd->chanlist, 0, 0)) - return 5; // incorrect channels list + return 5; /* incorrect channels list */ return 0; } @@ -1009,7 +1010,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic /* ============================================================================== */ -static int Compute_and_setup_dma(struct comedi_device * dev) +static int Compute_and_setup_dma(struct comedi_device *dev) { unsigned int dmalen0, dmalen1, i; @@ -1018,32 +1019,32 @@ static int Compute_and_setup_dma(struct comedi_device * dev) dmalen1 = devpriv->dmabuf_size[1]; DPRINTK("1 dmalen0=%d dmalen1=%d ai_data_len=%d\n", dmalen0, dmalen1, devpriv->ai_data_len); - // isn't output buff smaller that our DMA buff? + /* isn't output buff smaller that our DMA buff? */ if (dmalen0 > (devpriv->ai_data_len)) { - dmalen0 = devpriv->ai_data_len & ~3L; // allign to 32bit down + dmalen0 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */ } if (dmalen1 > (devpriv->ai_data_len)) { - dmalen1 = devpriv->ai_data_len & ~3L; // allign to 32bit down + dmalen1 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */ } DPRINTK("2 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - // we want wake up every scan? + /* we want wake up every scan? */ if (devpriv->ai_flags & TRIG_WAKE_EOS) { if (dmalen0 < (devpriv->ai_n_realscanlen << 1)) { - // uff, too short DMA buffer, disable EOS support! + /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); - rt_printk + printk ("comedi%d: WAR: DMA0 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", dev->minor, dmalen0, devpriv->ai_n_realscanlen << 1); } else { - // short first DMA buffer to one scan + /* short first DMA buffer to one scan */ dmalen0 = devpriv->ai_n_realscanlen << 1; DPRINTK("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen0, devpriv->ai_n_realscanlen, devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen0 += 2; if (dmalen0 < 4) { - rt_printk + printk ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n", dev->minor, dmalen0); dmalen0 = 4; @@ -1052,20 +1053,20 @@ static int Compute_and_setup_dma(struct comedi_device * dev) } if (devpriv->ai_flags & TRIG_WAKE_EOS) { if (dmalen1 < (devpriv->ai_n_realscanlen << 1)) { - // uff, too short DMA buffer, disable EOS support! + /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); - rt_printk + printk ("comedi%d: WAR: DMA1 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", dev->minor, dmalen1, devpriv->ai_n_realscanlen << 1); } else { - // short second DMA buffer to one scan + /* short second DMA buffer to one scan */ dmalen1 = devpriv->ai_n_realscanlen << 1; DPRINTK("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen1, devpriv->ai_n_realscanlen, devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen1 -= 2; if (dmalen1 < 4) { - rt_printk + printk ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n", dev->minor, dmalen1); dmalen1 = 4; @@ -1074,26 +1075,26 @@ static int Compute_and_setup_dma(struct comedi_device * dev) } DPRINTK("3 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - // transfer without TRIG_WAKE_EOS + /* transfer without TRIG_WAKE_EOS */ if (!(devpriv->ai_flags & TRIG_WAKE_EOS)) { - // if it's possible then allign DMA buffers to length of scan + /* if it's possible then allign DMA buffers to length of scan */ i = dmalen0; dmalen0 = (dmalen0 / (devpriv->ai_n_realscanlen << 1)) * (devpriv->ai_n_realscanlen << 1); dmalen0 &= ~3L; if (!dmalen0) - dmalen0 = i; // uff. very long scan? + dmalen0 = i; /* uff. very long scan? */ i = dmalen1; dmalen1 = (dmalen1 / (devpriv->ai_n_realscanlen << 1)) * (devpriv->ai_n_realscanlen << 1); dmalen1 &= ~3L; if (!dmalen1) - dmalen1 = i; // uff. very long scan? - // if measure isn't neverending then test, if it whole fits into one or two DMA buffers + dmalen1 = i; /* uff. very long scan? */ + /* if measure isn't neverending then test, if it whole fits into one or two DMA buffers */ if (!devpriv->ai_neverending) { - // fits whole measure into one DMA buffer? + /* fits whole measure into one DMA buffer? */ if (dmalen0 > ((devpriv->ai_n_realscanlen << 1) * devpriv->ai_scans)) { @@ -1104,7 +1105,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev) DPRINTK("3.1 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); dmalen0 &= ~3L; - } else { // fits whole measure into two DMA buffer? + } else { /* fits whole measure into two DMA buffer? */ if (dmalen1 > ((devpriv->ai_n_realscanlen << 1) * devpriv->ai_scans - dmalen0)) @@ -1121,7 +1122,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev) DPRINTK("4 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - // these DMA buffer size we'll be used + /* these DMA buffer size we'll be used */ devpriv->dma_actbuf = 0; devpriv->dmabuf_use_size[0] = dmalen0; devpriv->dmabuf_use_size[1] = dmalen1; @@ -1143,18 +1144,18 @@ static int Compute_and_setup_dma(struct comedi_device * dev) } #endif - outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); // stop DMA + outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ outl(devpriv->dmabuf_hw[0], devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[0], devpriv->iobase_a + AMCC_OP_REG_MWTC); - // init DMA transfer + /* init DMA transfer */ outl(0x00000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); -// outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); +/* outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); */ outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) | RESET_A2P_FLAGS | A2P_HI_PRIORITY | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_MCSR); - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow bus mastering + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow bus mastering */ DPRINTK("adl_pci9118 EDBG: END: Compute_and_setup_dma()\n"); return 0; @@ -1163,7 +1164,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev) /* ============================================================================== */ -static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subdevice *s) { DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_sampl(%d,) [%d]\n", dev->minor, devpriv->ai_do); @@ -1186,17 +1187,17 @@ static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subd return -EIO; }; - devpriv->int_ai_func = interrupt_pci9118_ai_onesample; //transfer function + devpriv->int_ai_func = interrupt_pci9118_ai_onesample; /* transfer function */ if (devpriv->ai12_startstop) - pci9118_exttrg_add(dev, EXTTRG_AI); // activate EXT trigger + pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */ if ((devpriv->ai_do == 1) || (devpriv->ai_do == 2)) devpriv->IntControlReg |= Int_Timer; devpriv->AdControlReg |= AdControl_Int; - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) { outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); @@ -1216,7 +1217,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevice *s) { DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_dma(%d,) [%d,%d]\n", dev->minor, devpriv->ai_do, devpriv->usedma); @@ -1261,10 +1262,10 @@ static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdev }; if (devpriv->ai12_startstop) { - pci9118_exttrg_add(dev, EXTTRG_AI); // activate EXT trigger + pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */ } - devpriv->int_ai_func = interrupt_pci9118_ai_dma; //transfer function + devpriv->int_ai_func = interrupt_pci9118_ai_dma; /* transfer function */ outl(0x02000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); @@ -1287,7 +1288,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int addchans = 0; @@ -1307,7 +1308,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_add_back = 0; devpriv->ai_maskerr = 0x10e; - // prepare for start/stop conditions + /* prepare for start/stop conditions */ if (cmd->start_src == TRIG_EXT) devpriv->ai12_startstop |= START_AI_EXT; if (cmd->stop_src == TRIG_EXT) { @@ -1334,19 +1335,19 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_scans = 0; } - // use sample&hold signal? + /* use sample&hold signal? */ if (cmd->convert_src == TRIG_NOW) { devpriv->usessh = 1; - } // yes + } /* yes */ else { devpriv->usessh = 0; - } // no + } /* no */ DPRINTK("1 neverending=%d scans=%u usessh=%d ai_startstop=0x%2x\n", devpriv->ai_neverending, devpriv->ai_scans, devpriv->usessh, devpriv->ai12_startstop); - // use additional sample at end of every scan to satisty DMA 32 bit transfer? + /* use additional sample at end of every scan to satisty DMA 32 bit transfer? */ devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; devpriv->useeoshandle = 0; @@ -1358,27 +1359,27 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_add_back = 1; } if (cmd->convert_src == TRIG_TIMER) { - devpriv->usedma = 0; // use INT transfer if scanlist have only one channel + devpriv->usedma = 0; /* use INT transfer if scanlist have only one channel */ } } if ((cmd->flags & TRIG_WAKE_EOS) && (devpriv->ai_n_scanlen & 1) && (devpriv->ai_n_scanlen > 1)) { if (cmd->scan_begin_src == TRIG_FOLLOW) { - //vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call - devpriv->usedma = 0; // XXX maybe can be corrected to use 16 bit DMA - } else { // well, we must insert one sample to end of EOS to meet 32 bit transfer + /* vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call */ + devpriv->usedma = 0; /* XXX maybe can be corrected to use 16 bit DMA */ + } else { /* well, we must insert one sample to end of EOS to meet 32 bit transfer */ devpriv->ai_add_back = 1; } } - } else { // interrupt transfer don't need any correction + } else { /* interrupt transfer don't need any correction */ devpriv->usedma = 0; } - // we need software S&H signal? It add two samples before every scan as minimum + /* we need software S&H signal? It add two samples before every scan as minimum */ if (devpriv->usessh && devpriv->softsshdelay) { devpriv->ai_add_front = 2; - if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { // move it to front + if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { /* move it to front */ devpriv->ai_add_front++; devpriv->ai_add_back = 0; } @@ -1387,17 +1388,17 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * addchans = devpriv->softsshdelay / cmd->convert_arg; if (devpriv->softsshdelay % cmd->convert_arg) addchans++; - if (addchans > (devpriv->ai_add_front - 1)) { // uff, still short :-( + if (addchans > (devpriv->ai_add_front - 1)) { /* uff, still short :-( */ devpriv->ai_add_front = addchans + 1; if (devpriv->usedma == 1) if ((devpriv->ai_add_front + devpriv->ai_n_chan + devpriv->ai_add_back) & 1) - devpriv->ai_add_front++; // round up to 32 bit + devpriv->ai_add_front++; /* round up to 32 bit */ } - } // well, we now know what must be all added + } /* well, we now know what must be all added */ - devpriv->ai_n_realscanlen = // what we must take from card in real to have ai_n_scanlen on output? + devpriv->ai_n_realscanlen = /* what we must take from card in real to have ai_n_scanlen on output? */ (devpriv->ai_add_front + devpriv->ai_n_chan + devpriv->ai_add_back) * (devpriv->ai_n_scanlen / devpriv->ai_n_chan); @@ -1408,7 +1409,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_n_chan, devpriv->ai_add_back, devpriv->ai_n_scanlen); - // check and setup channel list + /* check and setup channel list */ if (!check_channel_list(dev, s, devpriv->ai_n_chan, devpriv->ai_chanlist, devpriv->ai_add_front, devpriv->ai_add_back)) @@ -1419,9 +1420,9 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->useeoshandle)) return -EINVAL; - // compute timers settings - // simplest way, fr=4Mhz/(tim1*tim2), channel manipulation without timers effect - if (((cmd->scan_begin_src == TRIG_FOLLOW) || (cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_INT)) && (cmd->convert_src == TRIG_TIMER)) { // both timer is used for one time + /* compute timers settings */ + /* simplest way, fr=4Mhz/(tim1*tim2), channel manipulation without timers effect */ + if (((cmd->scan_begin_src == TRIG_FOLLOW) || (cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_INT)) && (cmd->convert_src == TRIG_TIMER)) { /* both timer is used for one time */ if (cmd->scan_begin_src == TRIG_EXT) { devpriv->ai_do = 4; } else { @@ -1435,7 +1436,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_timer2 = cmd->convert_arg; } - if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { // double timed action + if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { /* double timed action */ if (!devpriv->usedma) { comedi_error(dev, "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!"); @@ -1457,15 +1458,15 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_do = 3; } - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ - devpriv->AdControlReg = 0; // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable DMA + devpriv->AdControlReg = 0; /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable DMA */ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); - devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop + devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); - comedi_udelay(1); - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO - inl(dev->iobase + PCI9118_ADSTAT); // flush A/D and INT status register + udelay(1); + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D and INT status register */ inl(dev->iobase + PCI9118_INTSRC); devpriv->ai_act_scan = 0; @@ -1473,11 +1474,10 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s->async->cur_chan = 0; devpriv->ai_buf_ptr = 0; - if (devpriv->usedma) { + if (devpriv->usedma) ret = pci9118_ai_docmd_dma(dev, s); - } else { + else ret = pci9118_ai_docmd_sampl(dev, s); - } DPRINTK("adl_pci9118 EDBG: END: pci9118_ai_cmd()\n"); return ret; @@ -1486,7 +1486,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * /* ============================================================================== */ -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, int frontadd, int backadd) { unsigned int i, differencial = 0, bipolar = 0; @@ -1497,7 +1497,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic return 0; } if ((frontadd + n_chan + backadd) > s->len_chanlist) { - rt_printk + printk ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!", dev->minor, n_chan, s->len_chanlist - frontadd - backadd); @@ -1505,11 +1505,11 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic } if (CR_AREF(chanlist[0]) == AREF_DIFF) - differencial = 1; // all input must be diff + differencial = 1; /* all input must be diff */ if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES) - bipolar = 1; // all input must be bipolar + bipolar = 1; /* all input must be bipolar */ if (n_chan > 1) - for (i = 1; i < n_chan; i++) { // check S.E/diff + for (i = 1; i < n_chan; i++) { /* check S.E/diff */ if ((CR_AREF(chanlist[i]) == AREF_DIFF) != (differencial)) { comedi_error(dev, @@ -1537,7 +1537,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic /* ============================================================================== */ -static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd, int usedma, char useeos) { @@ -1552,27 +1552,27 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic } if (CR_AREF(chanlist[0]) == AREF_DIFF) - differencial = 1; // all input must be diff + differencial = 1; /* all input must be diff */ if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES) - bipolar = 1; // all input must be bipolar + bipolar = 1; /* all input must be bipolar */ - // All is ok, so we can setup channel/range list + /* All is ok, so we can setup channel/range list */ if (!bipolar) { - devpriv->AdControlReg |= AdControl_UniP; // set unibipolar + devpriv->AdControlReg |= AdControl_UniP; /* set unibipolar */ } else { - devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); // enable bipolar + devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); /* enable bipolar */ } if (differencial) { - devpriv->AdControlReg |= AdControl_Diff; // enable diff inputs + devpriv->AdControlReg |= AdControl_Diff; /* enable diff inputs */ } else { - devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); // set single ended inputs + devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); /* set single ended inputs */ } - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // setup mode + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* setup mode */ - outl(2, dev->iobase + PCI9118_SCANMOD); // gods know why this sequence! + outl(2, dev->iobase + PCI9118_SCANMOD); /* gods know why this sequence! */ outl(0, dev->iobase + PCI9118_SCANMOD); outl(1, dev->iobase + PCI9118_SCANMOD); @@ -1582,12 +1582,12 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic devpriv->chanlist[i] = 0x55aa; #endif - if (frontadd) { // insert channels for S&H + if (frontadd) { /* insert channels for S&H */ ssh = devpriv->softsshsample; DPRINTK("FA: %04x: ", ssh); - for (i = 0; i < frontadd; i++) { // store range list to card - scanquad = CR_CHAN(chanlist[0]); // get channel number; - gain = CR_RANGE(chanlist[0]); // get gain number + for (i = 0; i < frontadd; i++) { /* store range list to card */ + scanquad = CR_CHAN(chanlist[0]); /* get channel number; */ + gain = CR_RANGE(chanlist[0]); /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); @@ -1597,23 +1597,23 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic } DPRINTK("SL: ", ssh); - for (i = 0; i < n_chan; i++) { // store range list to card - scanquad = CR_CHAN(chanlist[i]); // get channel number; + for (i = 0; i < n_chan; i++) { /* store range list to card */ + scanquad = CR_CHAN(chanlist[i]); /* get channel number; */ #ifdef PCI9118_PARANOIDCHECK devpriv->chanlist[i ^ usedma] = (scanquad & 0xf) << rot; #endif - gain = CR_RANGE(chanlist[i]); // get gain number + gain = CR_RANGE(chanlist[i]); /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); } DPRINTK("\n "); - if (backadd) { // insert channels for fit onto 32bit DMA + if (backadd) { /* insert channels for fit onto 32bit DMA */ DPRINTK("BA: %04x: ", ssh); - for (i = 0; i < backadd; i++) { // store range list to card - scanquad = CR_CHAN(chanlist[0]); // get channel number; - gain = CR_RANGE(chanlist[0]); // get gain number + for (i = 0; i < backadd; i++) { /* store range list to card */ + scanquad = CR_CHAN(chanlist[0]); /* get channel number; */ + gain = CR_RANGE(chanlist[0]); /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); @@ -1621,13 +1621,13 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic DPRINTK("\n "); } #ifdef PCI9118_PARANOIDCHECK - devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; // for 32bit oerations + devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */ if (useeos) { - for (i = 1; i < n_chan; i++) { // store range list to card + for (i = 1; i < n_chan; i++) { /* store range list to card */ devpriv->chanlist[(n_chan + i) ^ usedma] = (CR_CHAN(chanlist[i]) & 0xf) << rot; } - devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; // for 32bit oerations + devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */ useeos = 2; } else { useeos = 1; @@ -1640,19 +1640,19 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic DPRINTK("\n "); #endif #endif - outl(0, dev->iobase + PCI9118_SCANMOD); // close scan queue -// comedi_udelay(100); // important delay, or first sample will be cripled + outl(0, dev->iobase + PCI9118_SCANMOD); /* close scan queue */ +/* udelay(100); important delay, or first sample will be cripled */ DPRINTK("adl_pci9118 EDBG: END: setup_channel_list()\n"); - return 1; // we can serve this with scan logic + return 1; /* we can serve this with scan logic */ } /* ============================================================================== calculate 8254 divisors if they are used for dual timing */ -static void pci9118_calc_divisors(char mode, struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int *tim1, unsigned int *tim2, +static void pci9118_calc_divisors(char mode, struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2, unsigned int flags, int chans, unsigned int *div1, unsigned int *div2, char usessh, unsigned int chnsshfront) { @@ -1672,17 +1672,17 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev, *tim2 = this_board->ai_ns_min; DPRINTK("1 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div1 = *tim2 / devpriv->i8254_osc_base; // convert timer (burst) + *div1 = *tim2 / devpriv->i8254_osc_base; /* convert timer (burst) */ DPRINTK("2 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); if (*div1 < this_board->ai_pacer_min) *div1 = this_board->ai_pacer_min; DPRINTK("3 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div2 = *tim1 / devpriv->i8254_osc_base; // scan timer + *div2 = *tim1 / devpriv->i8254_osc_base; /* scan timer */ DPRINTK("4 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div2 = *div2 / *div1; // major timer is c1*c2 + *div2 = *div2 / *div1; /* major timer is c1*c2 */ DPRINTK("5 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); if (*div2 < chans) @@ -1690,9 +1690,9 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev, DPRINTK("6 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *tim2 = *div1 * devpriv->i8254_osc_base; // real convert timer + *tim2 = *div1 * devpriv->i8254_osc_base; /* real convert timer */ - if (usessh & (chnsshfront == 0)) // use BSSH signal + if (usessh & (chnsshfront == 0)) /* use BSSH signal */ if (*div2 < (chans + 2)) *div2 = chans + 2; @@ -1710,13 +1710,13 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev, /* ============================================================================== */ -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { outl(0x74, dev->iobase + PCI9118_CNTCTRL); outl(0xb4, dev->iobase + PCI9118_CNTCTRL); -// outl(0x30, dev->iobase + PCI9118_CNTCTRL); - comedi_udelay(1); +/* outl(0x30, dev->iobase + PCI9118_CNTCTRL); */ + udelay(1); if ((mode == 1) || (mode == 2) || (mode == 4)) { outl(divisor2 & 0xff, dev->iobase + PCI9118_CNT2); @@ -1729,29 +1729,29 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis /* ============================================================================== */ -static int pci9118_exttrg_add(struct comedi_device * dev, unsigned char source) +static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source) { if (source > 3) - return -1; // incorrect source + return -1; /* incorrect source */ devpriv->exttrg_users |= (1 << source); devpriv->IntControlReg |= Int_DTrg; outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ return 0; } /* ============================================================================== */ -static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source) +static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source) { if (source > 3) - return -1; // incorrect source + return -1; /* incorrect source */ devpriv->exttrg_users &= ~(1 << source); - if (!devpriv->exttrg_users) { // shutdown ext trg intterrupts + if (!devpriv->exttrg_users) { /* shutdown ext trg intterrupts */ devpriv->IntControlReg &= ~Int_DTrg; - if (!devpriv->IntControlReg) // all IRQ disabled - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & (~0x00001f00), devpriv->iobase_a + AMCC_OP_REG_INTCSR); // disable int in AMCC + if (!devpriv->IntControlReg) /* all IRQ disabled */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & (~0x00001f00), devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* disable int in AMCC */ outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); } return 0; @@ -1760,20 +1760,20 @@ static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source) /* ============================================================================== */ -static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { if (devpriv->usedma) - outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); // stop DMA + outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ pci9118_exttrg_del(dev, EXTTRG_AI); - start_pacer(dev, 0, 0, 0); // stop 8254 counters + start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ devpriv->AdControlReg = 0x00; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ outl(0, dev->iobase + PCI9118_BURST); outl(1, dev->iobase + PCI9118_SCANMOD); - outl(2, dev->iobase + PCI9118_SCANMOD); // reset scan queue - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO + outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ devpriv->ai_do = 0; devpriv->usedma = 0; @@ -1787,7 +1787,7 @@ static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice devpriv->dma_actbuf = 0; if (!devpriv->IntControlReg) - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ return 0; } @@ -1795,36 +1795,36 @@ static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice /* ============================================================================== */ -static int pci9118_reset(struct comedi_device * dev) +static int pci9118_reset(struct comedi_device *dev) { devpriv->IntControlReg = 0; devpriv->exttrg_users = 0; inl(dev->iobase + PCI9118_INTCTRL); - outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); // disable interrupts source + outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); /* disable interrupts source */ outl(0x30, dev->iobase + PCI9118_CNTCTRL); -// outl(0xb4, dev->iobase + PCI9118_CNTCTRL); - start_pacer(dev, 0, 0, 0); // stop 8254 counters +/* outl(0xb4, dev->iobase + PCI9118_CNTCTRL); */ + start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ devpriv->AdControlReg = 0; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ outl(0, dev->iobase + PCI9118_BURST); outl(1, dev->iobase + PCI9118_SCANMOD); - outl(2, dev->iobase + PCI9118_SCANMOD); // reset scan queue + outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ devpriv->ao_data[0] = 2047; devpriv->ao_data[1] = 2047; - outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); // reset A/D outs to 0V + outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); /* reset A/D outs to 0V */ outl(devpriv->ao_data[1], dev->iobase + PCI9118_DA2); - outl(0, dev->iobase + PCI9118_DO); // reset digi outs to L - comedi_udelay(10); + outl(0, dev->iobase + PCI9118_DO); /* reset digi outs to L */ + udelay(10); inl(dev->iobase + PCI9118_AD_DATA); - outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO - outl(0, dev->iobase + PCI9118_INTSRC); // remove INT requests - inl(dev->iobase + PCI9118_ADSTAT); // flush A/D status register - inl(dev->iobase + PCI9118_INTSRC); // flush INT requests + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(0, dev->iobase + PCI9118_INTSRC); /* remove INT requests */ + inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D status register */ + inl(dev->iobase + PCI9118_INTSRC); /* flush INT requests */ devpriv->AdControlReg = 0; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ devpriv->cnt0_users = 0; devpriv->exttrg_users = 0; @@ -1835,7 +1835,7 @@ static int pci9118_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, pages, i; @@ -1848,19 +1848,20 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * unsigned char pci_bus, pci_slot, pci_func; u16 u16w; - rt_printk("comedi%d: adl_pci9118: board=%s", dev->minor, + printk("comedi%d: adl_pci9118: board=%s", dev->minor, this_board->name); opt_bus = it->options[0]; opt_slot = it->options[1]; if (it->options[3] & 1) { - master = 0; // user don't want use bus master + master = 0; /* user don't want use bus master */ } else { master = 1; } - if ((ret = alloc_private(dev, sizeof(struct pci9118_private))) < 0) { - rt_printk(" - Allocation failed!\n"); + ret = alloc_private(dev, sizeof(struct pci9118_private)); + if (ret < 0) { + printk(" - Allocation failed!\n"); return -ENOMEM; } @@ -1889,10 +1890,10 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * if (!pcidev) { if (opt_bus || opt_slot) { - rt_printk(" - Card at b:s %d:%d %s\n", + printk(" - Card at b:s %d:%d %s\n", opt_bus, opt_slot, errstr); } else { - rt_printk(" - Card %s\n", errstr); + printk(" - Card %s\n", errstr); } return -EIO; } @@ -1908,7 +1909,7 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * iobase_a = pci_resource_start(pcidev, 0); iobase_9 = pci_resource_start(pcidev, 2); - rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot, + printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot, pci_func, iobase_9, iobase_a); dev->iobase = iobase_9; @@ -1920,30 +1921,32 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * pci9118_reset(dev); if (it->options[3] & 2) - irq = 0; // user don't want use IRQ + irq = 0; /* user don't want use IRQ */ if (irq > 0) { - if (comedi_request_irq(irq, interrupt_pci9118, IRQF_SHARED, + if (request_irq(irq, interrupt_pci9118, IRQF_SHARED, "ADLink PCI-9118", dev)) { - rt_printk(", unable to allocate IRQ %d, DISABLING IT", + printk(", unable to allocate IRQ %d, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%u", irq); + printk(", irq=%u", irq); } } else { - rt_printk(", IRQ disabled"); + printk(", IRQ disabled"); } dev->irq = irq; - if (master) { // alloc DMA buffers + if (master) { /* alloc DMA buffers */ devpriv->dma_doublebuf = 0; for (i = 0; i < 2; i++) { - for (pages = 4; pages >= 0; pages--) - if ((devpriv->dmabuf_virt[i] = (short *) - __get_free_pages(GFP_KERNEL, - pages))) + for (pages = 4; pages >= 0; pages--) { + devpriv->dmabuf_virt[i] = + (short *) __get_free_pages(GFP_KERNEL, + pages); + if (devpriv->dmabuf_virt[i]) break; + } if (devpriv->dmabuf_virt[i]) { devpriv->dmabuf_pages[i] = pages; devpriv->dmabuf_size[i] = PAGE_SIZE * pages; @@ -1955,7 +1958,7 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * } } if (!devpriv->dmabuf_virt[0]) { - rt_printk(", Can't allocate DMA buffer, DMA disabled!"); + printk(", Can't allocate DMA buffer, DMA disabled!"); master = 0; } @@ -1964,26 +1967,26 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * } - if ((devpriv->master = master)) { - rt_printk(", bus master"); - } else { - rt_printk(", no bus master"); - } + devpriv->master = master; + if (devpriv->master) + printk(", bus master"); + else + printk(", no bus master"); devpriv->usemux = 0; if (it->options[2] > 0) { devpriv->usemux = it->options[2]; if (devpriv->usemux > 256) - devpriv->usemux = 256; // max 256 channels! + devpriv->usemux = 256; /* max 256 channels! */ if (it->options[4] > 0) if (devpriv->usemux > 128) { - devpriv->usemux = 128; // max 128 channels with softare S&H! + devpriv->usemux = 128; /* max 128 channels with softare S&H! */ } - rt_printk(", ext. mux %d channels", devpriv->usemux); + printk(", ext. mux %d channels", devpriv->usemux); } devpriv->softsshdelay = it->options[4]; - if (devpriv->softsshdelay < 0) { // select sample&hold signal polarity + if (devpriv->softsshdelay < 0) { /* select sample&hold signal polarity */ devpriv->softsshdelay = -devpriv->softsshdelay; devpriv->softsshsample = 0x80; devpriv->softsshhold = 0x00; @@ -1992,12 +1995,13 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * devpriv->softsshhold = 0x80; } - rt_printk(".\n"); + printk(".\n"); pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w); - pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); // Enable parity check for parity error + pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); /* Enable parity check for parity error */ - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -2052,9 +2056,9 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * s->insn_bits = pci9118_insn_bits_do; devpriv->valid = 1; - devpriv->i8254_osc_base = 250; // 250ns=4MHz - devpriv->ai_maskharderr = 0x10a; // default measure crash condition - if (it->options[5]) // disable some requested + devpriv->i8254_osc_base = 250; /* 250ns=4MHz */ + devpriv->ai_maskharderr = 0x10a; /* default measure crash condition */ + if (it->options[5]) /* disable some requested */ devpriv->ai_maskharderr &= ~it->options[5]; switch (this_board->ai_maxdata) { @@ -2071,13 +2075,13 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * /* ============================================================================== */ -static int pci9118_detach(struct comedi_device * dev) +static int pci9118_detach(struct comedi_device *dev) { if (dev->private) { if (devpriv->valid) pci9118_reset(dev); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv->pcidev) { if (dev->iobase) { comedi_pci_disable(devpriv->pcidev); diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index 92f62854d6dc..d09d1493a8b7 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -81,7 +81,7 @@ If you do not specify any options, they will default to #include "../comedidev.h" -// address scheme (page 2.17 of the manual) +/* address scheme (page 2.17 of the manual) */ #define ADQ12B_SIZE 16 #define ADQ12B_CTREG 0x00 @@ -94,24 +94,24 @@ If you do not specify any options, they will default to #define ADQ12B_CONT2 0x0e #define ADQ12B_COWORD 0x0f -// mask of the bit at STINR to check end of conversion +/* mask of the bit at STINR to check end of conversion */ #define ADQ12B_EOC 0x20 #define TIMEOUT 20 -// available ranges through the PGA gains +/* available ranges through the PGA gains */ static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, { - BIP_RANGE( 5 ), - BIP_RANGE( 2 ), - BIP_RANGE( 1 ), - BIP_RANGE( 0.5 ) + BIP_RANGE(5), + BIP_RANGE(2), + BIP_RANGE(1), + BIP_RANGE(0.5) }}; static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, { - UNI_RANGE( 5 ), - UNI_RANGE( 2 ), - UNI_RANGE( 1 ), - UNI_RANGE( 0.5 ) + UNI_RANGE(5), + UNI_RANGE(2), + UNI_RANGE(1), + UNI_RANGE(0.5) }}; @@ -127,20 +127,20 @@ struct adq12b_board { static const struct adq12b_board adq12b_boards[] = { { - name: "adq12b", - ai_se_chans: 16, - ai_diff_chans: 8, - ai_bits: 12, - di_chans: 5, - do_chans: 8 + .name = "adq12b", + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .di_chans = 5, + .do_chans = 8 } -// potentially, more adq-based deviced will be added +/* potentially, more adq-based deviced will be added */ /*, - name: "adq12b", - ai_chans: 16, // this is just for reference, hardcoded again later - ai_bits: 12, - di_chans: 8, - do_chans: 5 + .name = "adq12b", + .ai_chans = 16, // this is just for reference, hardcoded again later + .ai_bits = 12, + .di_chans = 8, + .do_chans = 5 }*/ }; @@ -162,7 +162,7 @@ struct adq12b_private { * the board, and also about the kernel module that contains * the device code. */ -static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it); +static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int adq12b_detach(struct comedi_device *dev); static struct comedi_driver driver_adq12b={ driver_name: "adq12b", @@ -171,12 +171,12 @@ static struct comedi_driver driver_adq12b={ detach: adq12b_detach, board_name: &adq12b_boards[0].name, offset: sizeof(struct adq12b_board), - num_names: sizeof(adq12b_boards) / sizeof(struct adq12b_board), + num_names: ARRAY_SIZE(adq12b_boards), }; -static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); -static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data); -static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data); +static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * Attach is called by the Comedi core to configure the driver @@ -184,7 +184,7 @@ static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice * in the driver structure, dev->board_ptr contains that * address. */ -static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it) +static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -194,7 +194,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it) unipolar = it->options[1]; differential = it->options[2]; - printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n",dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1)?"differential":"single-ended"); + printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n", dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1) ? "differential" : "single-ended"); /* if no address was specified, try the default 0x300 */ if (iobase == 0) { @@ -219,7 +219,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it) * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. */ - if(alloc_private(dev, sizeof(struct adq12b_private)) < 0) + if (alloc_private (dev, sizeof (struct adq12b_private)) < 0) return -ENOMEM; /* fill in devpriv structure */ @@ -236,7 +236,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it) * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. */ - if(alloc_subdevices(dev, 3)<0) + if (alloc_subdevices (dev, 3)<0) return -ENOMEM; s = dev->subdevices+0; @@ -304,7 +304,7 @@ static int adq12b_detach(struct comedi_device *dev) kfree(devpriv); - printk("comedi%d: adq12b: removed\n",dev->minor); + printk("comedi%d: adq12b: removed\n", dev->minor); return 0; } @@ -314,7 +314,7 @@ static int adq12b_detach(struct comedi_device *dev) * mode. */ -static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) +static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int n, i; int range, channel; @@ -325,29 +325,29 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s, channel = CR_CHAN(insn->chanspec); if (channel != devpriv->last_channel || range != devpriv->last_range) { outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG); - comedi_udelay(50); /* wait for the mux to settle */ + udelay(50); /* wait for the mux to settle */ } /* trigger conversion */ status = inb(dev->iobase + ADQ12B_ADLOW); /* convert n samples */ - for(n=0; n < insn->n; n++){ + for (n=0; n < insn->n; n++){ /* wait for end of convertion */ i = 0; do { -// comedi_udelay(1); +/* udelay(1); */ status = inb(dev->iobase + ADQ12B_STINR); status = status & ADQ12B_EOC; } while (status == 0 && ++i < TIMEOUT); -// } while (++i < 10); +/* } while (++i < 10); */ /* read data */ hi = inb(dev->iobase + ADQ12B_ADHIG); lo = inb(dev->iobase + ADQ12B_ADLOW); - //rt_printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); + /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */ data[n] = (hi << 8) | lo; } @@ -357,7 +357,7 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s, } -static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) +static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { /* only bits 0-4 have information about digital inputs */ @@ -367,7 +367,7 @@ static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice } -static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) +static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int channel; diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 29eac743c8e0..0b56c14e2d59 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -41,6 +41,8 @@ Configuration options: device will be used. */ +#include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_pci.h" @@ -56,12 +58,12 @@ Configuration options: #undef DPRINTK #ifdef PCI171X_EXTDEBUG -#define DPRINTK(fmt, args...) rt_printk(fmt, ## args) +#define DPRINTK(fmt, args...) printk(fmt, ## args) #else #define DPRINTK(fmt, args...) #endif -// hardware types of the cards +/* hardware types of the cards */ #define TYPE_PCI171X 0 #define TYPE_PCI1713 2 #define TYPE_PCI1720 3 @@ -87,12 +89,12 @@ Configuration options: #define PCI171x_CNT2 28 /* R/W: 8254 couter 2 */ #define PCI171x_CNTCTRL 30 /* W: 8254 counter control */ -// upper bits from status register (PCI171x_STATUS) (lower is same woth control reg) +/* upper bits from status register (PCI171x_STATUS) (lower is same woth control reg) */ #define Status_FE 0x0100 /* 1=FIFO is empty */ #define Status_FH 0x0200 /* 1=FIFO is half full */ #define Status_FF 0x0400 /* 1=FIFO is full, fatal error */ #define Status_IRQ 0x0800 /* 1=IRQ occured */ -// bits from control register (PCI171x_CONTROL) +/* bits from control register (PCI171x_CONTROL) */ #define Control_CNT0 0x0040 /* 1=CNT0 have external source, 0=have internal 100kHz source */ #define Control_ONEFH 0x0020 /* 1=IRQ on FIFO is half full, 0=every sample */ #define Control_IRQEN 0x0010 /* 1=enable IRQ */ @@ -100,7 +102,7 @@ Configuration options: #define Control_EXT 0x0004 /* 1=external trigger source */ #define Control_PACER 0x0002 /* 1=enable internal 8254 trigger source */ #define Control_SW 0x0001 /* 1=enable software trigger source */ -// bits from counter control register (PCI171x_CNTCTRL) +/* bits from counter control register (PCI171x_CNTCTRL) */ #define Counter_BCD 0x0001 /* 0 = binary counter, 1 = BCD counter */ #define Counter_M0 0x0002 /* M0-M2 select modes 0-5 */ #define Counter_M1 0x0004 /* 000 = mode 0, 010 = mode 2 ... */ @@ -118,7 +120,7 @@ Configuration options: #define PCI1720_SYNCOUT 9 /* W: D/A synchronized output register */ #define PCI1720_SYNCONT 15 /* R/W: D/A synchronized control */ -// D/A synchronized control (PCI1720_SYNCONT) +/* D/A synchronized control (PCI1720_SYNCONT) */ #define Syncont_SC0 1 /* set synchronous output mode */ static const struct comedi_lrange range_pci1710_3 = { 9, { @@ -182,28 +184,28 @@ static const struct comedi_lrange range_pci171x_da = { 2, { } }; -static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci1710_detach(struct comedi_device * dev); +static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci1710_detach(struct comedi_device *dev); struct boardtype { - const char *name; // board name + const char *name; /* board name */ int device_id; - int iorange; // I/O range len - char have_irq; // 1=card support IRQ - char cardtype; // 0=1710& co. 2=1713, ... - int n_aichan; // num of A/D chans - int n_aichand; // num of A/D chans in diff mode - int n_aochan; // num of D/A chans - int n_dichan; // num of DI chans - int n_dochan; // num of DO chans - int n_counter; // num of counters - int ai_maxdata; // resolution of A/D - int ao_maxdata; // resolution of D/A - const struct comedi_lrange *rangelist_ai; // rangelist for A/D - const char *rangecode_ai; // range codes for programming - const struct comedi_lrange *rangelist_ao; // rangelist for D/A - unsigned int ai_ns_min; // max sample speed of card v ns - unsigned int fifo_half_size; // size of FIFO/2 + int iorange; /* I/O range len */ + char have_irq; /* 1=card support IRQ */ + char cardtype; /* 0=1710& co. 2=1713, ... */ + int n_aichan; /* num of A/D chans */ + int n_aichand; /* num of A/D chans in diff mode */ + int n_aochan; /* num of D/A chans */ + int n_dichan; /* num of DI chans */ + int n_dochan; /* num of DO chans */ + int n_counter; /* num of counters */ + int ai_maxdata; /* resolution of A/D */ + int ao_maxdata; /* resolution of D/A */ + const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ + const char *rangecode_ai; /* range codes for programming */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ + unsigned int ai_ns_min; /* max sample speed of card v ns */ + unsigned int fifo_half_size; /* size of FIFO/2 */ }; static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = { @@ -250,7 +252,7 @@ static const struct boardtype boardtypes[] = { 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000, &range_pci17x1, range_codes_pci17x1, NULL, 10000, 512}, - // dummy entry corresponding to driver name + /* dummy entry corresponding to driver name */ {.name = DRV_NAME}, }; @@ -267,34 +269,34 @@ static struct comedi_driver driver_pci1710 = { }; struct pci1710_private { - struct pci_dev *pcidev; // ptr to PCI device - char valid; // card is usable - char neverending_ai; // we do unlimited AI - unsigned int CntrlReg; // Control register - unsigned int i8254_osc_base; // frequence of onboard oscilator - unsigned int ai_do; // what do AI? 0=nothing, 1 to 4 mode - unsigned int ai_act_scan; // how many scans we finished - unsigned int ai_act_chan; // actual position in actual scan - unsigned int ai_buf_ptr; // data buffer ptr in samples - unsigned char ai_eos; // 1=EOS wake up + struct pci_dev *pcidev; /* ptr to PCI device */ + char valid; /* card is usable */ + char neverending_ai; /* we do unlimited AI */ + unsigned int CntrlReg; /* Control register */ + unsigned int i8254_osc_base; /* frequence of onboard oscilator */ + unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ + unsigned int ai_act_scan; /* how many scans we finished */ + unsigned int ai_act_chan; /* actual position in actual scan */ + unsigned int ai_buf_ptr; /* data buffer ptr in samples */ + unsigned char ai_eos; /* 1=EOS wake up */ unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; unsigned int ai_et_div1, ai_et_div2; - unsigned int act_chanlist[32]; // list of scaned channel - unsigned char act_chanlist_len; // len of scanlist - unsigned char act_chanlist_pos; // actual position in MUX list - unsigned char da_ranges; // copy of D/A outpit range register - unsigned int ai_scans; // len of scanlist - unsigned int ai_n_chan; // how many channels is measured - unsigned int *ai_chanlist; // actaul chanlist - unsigned int ai_flags; // flaglist - unsigned int ai_data_len; // len of data buffer - short *ai_data; // data buffer - unsigned int ai_timer1; // timers + unsigned int act_chanlist[32]; /* list of scaned channel */ + unsigned char act_chanlist_len; /* len of scanlist */ + unsigned char act_chanlist_pos; /* actual position in MUX list */ + unsigned char da_ranges; /* copy of D/A outpit range register */ + unsigned int ai_scans; /* len of scanlist */ + unsigned int ai_n_chan; /* how many channels is measured */ + unsigned int *ai_chanlist; /* actaul chanlist */ + unsigned int ai_flags; /* flaglist */ + unsigned int ai_data_len; /* len of data buffer */ + short *ai_data; /* data buffer */ + unsigned int ai_timer1; /* timers */ unsigned int ai_timer2; - short ao_data[4]; // data output buffer - unsigned int cnt0_write_wait; // after a write, wait for update of the internal state + short ao_data[4]; /* data output buffer */ + unsigned int cnt0_write_wait; /* after a write, wait for update of the internal state */ }; #define devpriv ((struct pci1710_private *)dev->private) @@ -304,16 +306,16 @@ struct pci1710_private { ============================================================================== */ -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan); -static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan, unsigned int seglen); -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); -static int pci1710_reset(struct comedi_device * dev); -static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int pci1710_reset(struct comedi_device *dev); +static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707, // used for gain list programming +static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707, /* used for gain list programming */ 0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f, 0x1010, 0x1111, 0x1212, 0x1313, 0x1414, 0x1515, 0x1616, 0x1717, 0x1818, 0x1919, 0x1a1a, 0x1b1b, 0x1c1c, 0x1d1d, 0x1e1e, 0x1f1f @@ -322,8 +324,8 @@ static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x040 /* ============================================================================== */ -static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, timeout; #ifdef PCI171x_PARANOIDCHECK @@ -332,7 +334,7 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev DPRINTK("adv_pci1710 EDBG: BGN: pci171x_insn_read_ai(...)\n"); devpriv->CntrlReg &= Control_CNT0; - devpriv->CntrlReg |= Control_SW; // set software trigger + devpriv->CntrlReg |= Control_SW; /* set software trigger */ outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); @@ -346,7 +348,7 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev outw(0, dev->iobase + PCI171x_SOFTTRG); /* start conversion */ DPRINTK("adv_pci1710 B n=%d ST=%4x\n", n, inw(dev->iobase + PCI171x_STATUS)); - //comedi_udelay(1); + /* udelay(1); */ DPRINTK("adv_pci1710 C n=%d ST=%4x\n", n, inw(dev->iobase + PCI171x_STATUS)); timeout = 100; @@ -390,8 +392,8 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci171x_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan, range, ofs; @@ -421,8 +423,8 @@ static int pci171x_insn_write_ao(struct comedi_device * dev, struct comedi_subde /* ============================================================================== */ -static int pci171x_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -436,8 +438,8 @@ static int pci171x_insn_read_ao(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci171x_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inw(dev->iobase + PCI171x_DI); @@ -447,8 +449,8 @@ static int pci171x_insn_bits_di(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci171x_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -463,8 +465,8 @@ static int pci171x_insn_bits_do(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci171x_insn_counter_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int msb, lsb, ccntrl; int i; @@ -485,8 +487,8 @@ static int pci171x_insn_counter_read(struct comedi_device * dev, struct comedi_s /* ============================================================================== */ -static int pci171x_insn_counter_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { uint msb, lsb, ccntrl, status; @@ -512,8 +514,8 @@ static int pci171x_insn_counter_write(struct comedi_device * dev, struct comedi_ /* ============================================================================== */ -static int pci171x_insn_counter_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int pci171x_insn_counter_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { #ifdef unused /* This doesn't work like a normal Comedi counter config */ @@ -548,8 +550,8 @@ static int pci171x_insn_counter_config(struct comedi_device * dev, /* ============================================================================== */ -static int pci1720_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1720_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, rangereg, chan; @@ -563,7 +565,7 @@ static int pci1720_insn_write_ao(struct comedi_device * dev, struct comedi_subde for (n = 0; n < insn->n; n++) { outw(data[n], dev->iobase + PCI1720_DA0 + (chan << 1)); - outb(0, dev->iobase + PCI1720_SYNCOUT); // update outputs + outb(0, dev->iobase + PCI1720_SYNCOUT); /* update outputs */ } devpriv->ao_data[chan] = data[n]; @@ -586,14 +588,14 @@ static void interrupt_pci1710_every_sample(void *d) DPRINTK("adv_pci1710 EDBG: BGN: interrupt_pci1710_every_sample(...)\n"); m = inw(dev->iobase + PCI171x_STATUS); if (m & Status_FE) { - rt_printk("comedi%d: A/D FIFO empty (%4x)\n", dev->minor, m); + printk("comedi%d: A/D FIFO empty (%4x)\n", dev->minor, m); pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return; } if (m & Status_FF) { - rt_printk + printk ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", dev->minor, m); pci171x_ai_cancel(dev, s); @@ -602,7 +604,7 @@ static void interrupt_pci1710_every_sample(void *d) return; } - outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request + outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ DPRINTK("FOR "); for (; !(inw(dev->iobase + PCI171x_STATUS) & Status_FE);) { @@ -612,7 +614,7 @@ static void interrupt_pci1710_every_sample(void *d) if (this_board->cardtype != TYPE_PCI1713) if ((sampl & 0xf000) != devpriv->act_chanlist[s->async->cur_chan]) { - rt_printk + printk ("comedi: A/D data dropout: received data from channel %d, expected %d!\n", (sampl & 0xf000) >> 12, (devpriv->act_chanlist[s->async-> @@ -637,11 +639,11 @@ static void interrupt_pci1710_every_sample(void *d) s->async->cur_chan = 0; } - if (s->async->cur_chan == 0) { // one scan done + if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; DPRINTK("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n", s->async->buf_int_count, s->async->buf_int_ptr, s->async->buf_user_count, s->async->buf_user_ptr); DPRINTK("adv_pci1710 EDBG: EOS2\n"); - if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { // all data sampled + if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { /* all data sampled */ pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); @@ -650,7 +652,7 @@ static void interrupt_pci1710_every_sample(void *d) } } - outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request + outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ DPRINTK("adv_pci1710 EDBG: END: interrupt_pci1710_every_sample(...)\n"); comedi_event(dev, s); @@ -659,7 +661,7 @@ static void interrupt_pci1710_every_sample(void *d) /* ============================================================================== */ -static int move_block_from_fifo(struct comedi_device * dev, struct comedi_subdevice * s, +static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s, int n, int turn) { int i, j; @@ -674,7 +676,7 @@ static int move_block_from_fifo(struct comedi_device * dev, struct comedi_subdev sampl = inw(dev->iobase + PCI171x_AD_DATA); if (this_board->cardtype != TYPE_PCI1713) if ((sampl & 0xf000) != devpriv->act_chanlist[j]) { - rt_printk + printk ("comedi%d: A/D FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n", dev->minor, (sampl & 0xf000) >> 12, (devpriv-> @@ -714,7 +716,7 @@ static void interrupt_pci1710_half_fifo(void *d) DPRINTK("adv_pci1710 EDBG: BGN: interrupt_pci1710_half_fifo(...)\n"); m = inw(dev->iobase + PCI171x_STATUS); if (!(m & Status_FH)) { - rt_printk("comedi%d: A/D FIFO not half full! (%4x)\n", + printk("comedi%d: A/D FIFO not half full! (%4x)\n", dev->minor, m); pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; @@ -722,7 +724,7 @@ static void interrupt_pci1710_half_fifo(void *d) return; } if (m & Status_FF) { - rt_printk + printk ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", dev->minor, m); pci171x_ai_cancel(dev, s); @@ -751,7 +753,7 @@ static void interrupt_pci1710_half_fifo(void *d) comedi_event(dev, s); return; } - outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request + outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ DPRINTK("adv_pci1710 EDBG: END: interrupt_pci1710_half_fifo(...)\n"); comedi_event(dev, s); @@ -760,36 +762,36 @@ static void interrupt_pci1710_half_fifo(void *d) /* ============================================================================== */ -static irqreturn_t interrupt_service_pci1710(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_service_pci1710(int irq, void *d) { struct comedi_device *dev = d; DPRINTK("adv_pci1710 EDBG: BGN: interrupt_service_pci1710(%d,...)\n", irq); - if (!dev->attached) // is device attached? - return IRQ_NONE; // no, exit + if (!dev->attached) /* is device attached? */ + return IRQ_NONE; /* no, exit */ - if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) // is this interrupt from our board? - return IRQ_NONE; // no, exit + if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) /* is this interrupt from our board? */ + return IRQ_NONE; /* no, exit */ DPRINTK("adv_pci1710 EDBG: interrupt_service_pci1710() ST: %4x\n", inw(dev->iobase + PCI171x_STATUS)); - if (devpriv->ai_et) { // Switch from initial TRIG_EXT to TRIG_xxx. + if (devpriv->ai_et) { /* Switch from initial TRIG_EXT to TRIG_xxx. */ devpriv->ai_et = 0; devpriv->CntrlReg &= Control_CNT0; - devpriv->CntrlReg |= Control_SW; // set software trigger + devpriv->CntrlReg |= Control_SW; /* set software trigger */ outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); devpriv->CntrlReg = devpriv->ai_et_CntrlReg; outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); - // start pacer + /* start pacer */ start_pacer(dev, 1, devpriv->ai_et_div1, devpriv->ai_et_div2); return IRQ_HANDLED; } - if (devpriv->ai_eos) { // We use FIFO half full INT or not? + if (devpriv->ai_eos) { /* We use FIFO half full INT or not? */ interrupt_pci1710_every_sample(d); } else { interrupt_pci1710_half_fifo(d); @@ -801,15 +803,15 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d PT_REGS_ARG) /* ============================================================================== */ -static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev, - struct comedi_subdevice * s) +static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned int divisor1, divisor2; unsigned int seglen; DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_docmd_and_mode(%d,...)\n", mode); - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ seglen = check_channel_list(dev, s, devpriv->ai_chanlist, devpriv->ai_n_chan); @@ -829,7 +831,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev, devpriv->neverending_ai = 0; devpriv->CntrlReg &= Control_CNT0; - if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan? devpriv->ai_eos=1; + if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? devpriv->ai_eos=1; */ devpriv->ai_eos = 1; } else { devpriv->CntrlReg |= Control_ONEFH; @@ -838,7 +840,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev, if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) { devpriv->neverending_ai = 1; - } //well, user want neverending + } /* well, user want neverending */ else { devpriv->neverending_ai = 0; } @@ -863,7 +865,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev, DPRINTK("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", devpriv->i8254_osc_base, divisor1, divisor2, devpriv->ai_timer1); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); if (mode != 2) { - // start pacer + /* start pacer */ start_pacer(dev, mode, divisor1, divisor2); } else { devpriv->ai_et_div1 = divisor1; @@ -884,15 +886,15 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev, /* ============================================================================== */ -static void pci171x_cmdtest_out(int e, struct comedi_cmd * cmd) +static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd) { - rt_printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, + printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, cmd->start_src, cmd->scan_begin_src, cmd->convert_src); - rt_printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e, + printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e, cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); - rt_printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, + printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, cmd->scan_end_src); - rt_printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", + printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); } #endif @@ -900,8 +902,8 @@ static void pci171x_cmdtest_out(int e, struct comedi_cmd * cmd) /* ============================================================================== */ -static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; @@ -1055,7 +1057,7 @@ static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic if (cmd->chanlist) { if (!check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len)) - return 5; // incorrect channels list + return 5; /* incorrect channels list */ } DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) ret=0\n"); @@ -1065,7 +1067,7 @@ static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic /* ============================================================================== */ -static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; @@ -1084,13 +1086,13 @@ static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * devpriv->ai_scans = 0; } - if (cmd->scan_begin_src == TRIG_FOLLOW) { // mode 1, 2, 3 - if (cmd->convert_src == TRIG_TIMER) { // mode 1 and 2 + if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */ + if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ devpriv->ai_timer1 = cmd->convert_arg; return pci171x_ai_docmd_and_mode(cmd->start_src == TRIG_EXT ? 2 : 1, dev, s); } - if (cmd->convert_src == TRIG_EXT) { // mode 3 + if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ return pci171x_ai_docmd_and_mode(3, dev, s); } } @@ -1104,7 +1106,7 @@ static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * If it's ok, then program scan/gain logic. This works for all cards. */ -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan) { unsigned int chansegment[32]; @@ -1118,12 +1120,12 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic } if (n_chan > 1) { - chansegment[0] = chanlist[0]; // first channel is everytime ok - for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { // build part of chanlist - // rt_printk("%d. %d %d\n",i,CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); + chansegment[0] = chanlist[0]; /* first channel is everytime ok */ + for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { /* build part of chanlist */ + /* printk("%d. %d %d\n",i,CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */ if (chanlist[0] == chanlist[i]) - break; // we detect loop, this must by finish - if (CR_CHAN(chanlist[i]) & 1) // odd channel cann't by differencial + break; /* we detect loop, this must by finish */ + if (CR_CHAN(chanlist[i]) & 1) /* odd channel cann't by differencial */ if (CR_AREF(chanlist[i]) == AREF_DIFF) { comedi_error(dev, "Odd channel can't be differential input!\n"); @@ -1133,20 +1135,20 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan; if (CR_AREF(chansegment[i - 1]) == AREF_DIFF) nowmustbechan = (nowmustbechan + 1) % s->n_chan; - if (nowmustbechan != CR_CHAN(chanlist[i])) { // channel list isn't continous :-( - rt_printk + if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */ + printk ("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", i, CR_CHAN(chanlist[i]), nowmustbechan, CR_CHAN(chanlist[0])); return 0; } - chansegment[i] = chanlist[i]; // well, this is next correct channel in list + chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */ } - for (i = 0, segpos = 0; i < n_chan; i++) { // check whole chanlist - //rt_printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); + for (i = 0, segpos = 0; i < n_chan; i++) { /* check whole chanlist */ + /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */ if (chanlist[i] != chansegment[i % seglen]) { - rt_printk + printk ("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", i, CR_CHAN(chansegment[i]), CR_RANGE(chansegment[i]), @@ -1154,7 +1156,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic CR_CHAN(chanlist[i % seglen]), CR_RANGE(chanlist[i % seglen]), CR_AREF(chansegment[i % seglen])); - return 0; // chan/gain list is strange + return 0; /* chan/gain list is strange */ } } } else { @@ -1163,7 +1165,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic return seglen; } -static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan, unsigned int seglen) { unsigned int i, range, chanprog; @@ -1174,7 +1176,7 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi devpriv->act_chanlist_pos = 0; DPRINTK("SegLen: %d\n", seglen); - for (i = 0; i < seglen; i++) { // store range list to card + for (i = 0; i < seglen; i++) { /* store range list to card */ chanprog = muxonechan[CR_CHAN(chanlist[i])]; outw(chanprog, dev->iobase + PCI171x_MUX); /* select channel */ range = this_board->rangecode_ai[CR_RANGE(chanlist[i])]; @@ -1200,7 +1202,7 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi /* ============================================================================== */ -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { DPRINTK("adv_pci1710 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, @@ -1220,7 +1222,7 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis /* ============================================================================== */ -static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cancel(...)\n"); @@ -1229,7 +1231,7 @@ static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice devpriv->CntrlReg &= Control_CNT0; devpriv->CntrlReg |= Control_SW; - outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); // reset any operations + outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */ start_pacer(dev, -1, 0, 0); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); @@ -1249,28 +1251,28 @@ static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice /* ============================================================================== */ -static int pci171x_reset(struct comedi_device * dev) +static int pci171x_reset(struct comedi_device *dev) { DPRINTK("adv_pci1710 EDBG: BGN: pci171x_reset(...)\n"); outw(0x30, dev->iobase + PCI171x_CNTCTRL); - devpriv->CntrlReg = Control_SW | Control_CNT0; // Software trigger, CNT0=external - outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); // reset any operations - outb(0, dev->iobase + PCI171x_CLRFIFO); // clear FIFO - outb(0, dev->iobase + PCI171x_CLRINT); // clear INT request - start_pacer(dev, -1, 0, 0); // stop 8254 + devpriv->CntrlReg = Control_SW | Control_CNT0; /* Software trigger, CNT0=external */ + outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */ + outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */ + outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */ + start_pacer(dev, -1, 0, 0); /* stop 8254 */ devpriv->da_ranges = 0; if (this_board->n_aochan) { - outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); // set DACs to 0..5V - outw(0, dev->iobase + PCI171x_DA1); // set DA outputs to 0V + outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); /* set DACs to 0..5V */ + outw(0, dev->iobase + PCI171x_DA1); /* set DA outputs to 0V */ devpriv->ao_data[0] = 0x0000; if (this_board->n_aochan > 1) { outw(0, dev->iobase + PCI171x_DA2); devpriv->ao_data[1] = 0x0000; } } - outw(0, dev->iobase + PCI171x_DO); // digital outputs to 0 - outb(0, dev->iobase + PCI171x_CLRFIFO); // clear FIFO - outb(0, dev->iobase + PCI171x_CLRINT); // clear INT request + outw(0, dev->iobase + PCI171x_DO); /* digital outputs to 0 */ + outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */ + outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */ DPRINTK("adv_pci1710 EDBG: END: pci171x_reset(...)\n"); return 0; @@ -1279,17 +1281,17 @@ static int pci171x_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci1720_reset(struct comedi_device * dev) +static int pci1720_reset(struct comedi_device *dev) { DPRINTK("adv_pci1710 EDBG: BGN: pci1720_reset(...)\n"); - outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); // set synchronous output mode + outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); /* set synchronous output mode */ devpriv->da_ranges = 0xAA; - outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); // set all ranges to +/-5V - outw(0x0800, dev->iobase + PCI1720_DA0); // set outputs to 0V + outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); /* set all ranges to +/-5V */ + outw(0x0800, dev->iobase + PCI1720_DA0); /* set outputs to 0V */ outw(0x0800, dev->iobase + PCI1720_DA1); outw(0x0800, dev->iobase + PCI1720_DA2); outw(0x0800, dev->iobase + PCI1720_DA3); - outb(0, dev->iobase + PCI1720_SYNCOUT); // update outputs + outb(0, dev->iobase + PCI1720_SYNCOUT); /* update outputs */ devpriv->ao_data[0] = 0x0800; devpriv->ao_data[1] = 0x0800; devpriv->ao_data[2] = 0x0800; @@ -1301,7 +1303,7 @@ static int pci1720_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci1710_reset(struct comedi_device * dev) +static int pci1710_reset(struct comedi_device *dev) { DPRINTK("adv_pci1710 EDBG: BGN: pci1710_reset(...)\n"); switch (this_board->cardtype) { @@ -1316,7 +1318,7 @@ static int pci1710_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices; @@ -1329,13 +1331,14 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * int i; int board_index; - rt_printk("comedi%d: adv_pci1710: ", dev->minor); + printk("comedi%d: adv_pci1710: ", dev->minor); opt_bus = it->options[0]; opt_slot = it->options[1]; - if ((ret = alloc_private(dev, sizeof(struct pci1710_private))) < 0) { - rt_printk(" - Allocation failed!\n"); + ret = alloc_private(dev, sizeof(struct pci1710_private)); + if (ret < 0) { + printk(" - Allocation failed!\n"); return -ENOMEM; } @@ -1345,20 +1348,20 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * board_index = this_board - boardtypes; while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH, PCI_ANY_ID, pcidev))) { - if(strcmp(this_board->name, DRV_NAME) == 0) + if (strcmp (this_board->name, DRV_NAME) == 0) { - for(i = 0; i < n_boardtypes; ++i) + for (i = 0; i < n_boardtypes; ++i) { - if(pcidev->device == boardtypes[i].device_id) + if (pcidev->device == boardtypes[i].device_id) { board_index = i; break; } } - if(i == n_boardtypes) continue; + if (i == n_boardtypes) continue; }else { - if(pcidev->device != boardtypes[board_index].device_id) continue; + if (pcidev->device != boardtypes[board_index].device_id) continue; } /* Found matching vendor/device. */ @@ -1376,17 +1379,17 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * errstr = "failed to enable PCI device and request regions!"; continue; } - // fixup board_ptr in case we were using the dummy entry with the driver name + /* fixup board_ptr in case we were using the dummy entry with the driver name */ dev->board_ptr = &boardtypes[board_index]; break; } if (!pcidev) { if (opt_bus || opt_slot) { - rt_printk(" - Card at b:s %d:%d %s\n", + printk(" - Card at b:s %d:%d %s\n", opt_bus, opt_slot, errstr); } else { - rt_printk(" - Card %s\n", errstr); + printk(" - Card %s\n", errstr); } return -EIO; } @@ -1397,7 +1400,7 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * irq = pcidev->irq; iobase = pci_resource_start(pcidev, 2); - rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func, + printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func, iobase); dev->iobase = iobase; @@ -1417,8 +1420,9 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * if (this_board->n_counter) n_subdevices++; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) { - rt_printk(" - Allocation failed!\n"); + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) { + printk(" - Allocation failed!\n"); return ret; } @@ -1426,18 +1430,18 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * if (this_board->have_irq) { if (irq) { - if (comedi_request_irq(irq, interrupt_service_pci1710, + if (request_irq(irq, interrupt_service_pci1710, IRQF_SHARED, "Advantech PCI-1710", dev)) { - rt_printk + printk (", unable to allocate IRQ %d, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%u", irq); + printk(", irq=%u", irq); } } else { - rt_printk(", IRQ disabled"); + printk(", IRQ disabled"); } } else { irq = 0; @@ -1467,7 +1471,7 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * s->do_cmdtest = pci171x_ai_cmdtest; s->do_cmd = pci171x_ai_cmd; } - devpriv->i8254_osc_base = 100; // 100ns=10MHz + devpriv->i8254_osc_base = 100; /* 100ns=10MHz */ subdev++; } @@ -1540,14 +1544,14 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * /* ============================================================================== */ -static int pci1710_detach(struct comedi_device * dev) +static int pci1710_detach(struct comedi_device *dev) { if (dev->private) { if (devpriv->valid) pci1710_reset(dev); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv->pcidev) { if (dev->iobase) { comedi_pci_disable(devpriv->pcidev); diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 81f7ee18c150..e1994a5290bd 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -54,7 +54,7 @@ TODO: #define ADVANTECH_VENDOR 0x13fe /* Advantech PCI vendor ID */ -// hardware types of the cards +/* hardware types of the cards */ #define TYPE_PCI1723 0 #define IORANGE_1723 0x2A @@ -92,7 +92,7 @@ TODO: #define PCI1723_SELECT_CALIBRATION 0x28 /* Select the calibration Ref_V */ -//static unsigned short pci_list_builded=0; /*=1 list of card is know */ +/* static unsigned short pci_list_builded=0; =1 list of card is know */ static const struct comedi_lrange range_pci1723 = { 1, { BIP_RANGE(10) @@ -104,27 +104,27 @@ static const struct comedi_lrange range_pci1723 = { 1, { */ struct pci1723_board { const char *name; - int vendor_id; // PCI vendor a device ID of card + int vendor_id; /* PCI vendor a device ID of card */ int device_id; int iorange; char cardtype; - int n_aochan; // num of D/A chans - int n_diochan; // num of DIO chans - int ao_maxdata; // resolution of D/A - const struct comedi_lrange *rangelist_ao; // rangelist for D/A + int n_aochan; /* num of D/A chans */ + int n_diochan; /* num of DIO chans */ + int ao_maxdata; /* resolution of D/A */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ }; static const struct pci1723_board boardtypes[] = { { - name: "pci1723", - vendor_id:ADVANTECH_VENDOR, - device_id:0x1723, - iorange: IORANGE_1723, - cardtype:TYPE_PCI1723, - n_aochan:8, - n_diochan:16, - ao_maxdata:0xffff, - rangelist_ao:&range_pci1723, + .name = "pci1723", + .vendor_id = ADVANTECH_VENDOR, + .device_id = 0x1723, + .iorange = IORANGE_1723, + .cardtype = TYPE_PCI1723, + .n_aochan = 8, + .n_diochan = 16, + .ao_maxdata = 0xffff, + .rangelist_ao = &range_pci1723, }, }; @@ -143,26 +143,26 @@ MODULE_DEVICE_TABLE(pci, pci1723_pci_table); * the board, and also about the kernel module that contains * the device code. */ -static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci1723_detach(struct comedi_device * dev); +static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci1723_detach(struct comedi_device *dev); #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board)) static struct comedi_driver driver_pci1723 = { - driver_name:"adv_pci1723", - module:THIS_MODULE, - attach:pci1723_attach, - detach:pci1723_detach, + .driver_name = "adv_pci1723", + .module = THIS_MODULE, + .attach = pci1723_attach, + .detach = pci1723_detach, }; /* this structure is for data unique to this hardware driver. */ struct pci1723_private { - int valid; //card is usable; + int valid; /* card is usable; */ struct pci_dev *pcidev; - unsigned char da_range[8]; // D/A output range for each channel + unsigned char da_range[8]; /* D/A output range for each channel */ - short ao_data[8]; // data output buffer + short ao_data[8]; /* data output buffer */ }; /*the following macro to make it easy to @@ -175,35 +175,35 @@ struct pci1723_private { /* * the pci1723 card reset; */ -static int pci1723_reset(struct comedi_device * dev) +static int pci1723_reset(struct comedi_device *dev) { int i; DPRINTK("adv_pci1723 EDBG: BGN: pci1723_reset(...)\n"); - outw(0x01, dev->iobase + PCI1723_SYN_SET); // set synchronous output mode + outw(0x01, dev->iobase + PCI1723_SYN_SET); /* set synchronous output mode */ for (i = 0; i < 8; i++) { - // set all outputs to 0V + /* set all outputs to 0V */ devpriv->ao_data[i] = 0x8000; outw(devpriv->ao_data[i], dev->iobase + PCI1723_DA(i)); - // set all ranges to +/- 10V + /* set all ranges to +/- 10V */ devpriv->da_range[i] = 0; outw(((devpriv->da_range[i] << 4) | i), PCI1723_RANGE_CALIBRATION_MODE); } - outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); // update ranges - outw(0, dev->iobase + PCI1723_SYN_STROBE); // update outputs + outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); /* update ranges */ + outw(0, dev->iobase + PCI1723_SYN_STROBE); /* update outputs */ - // set asynchronous output mode + /* set asynchronous output mode */ outw(0, dev->iobase + PCI1723_SYN_SET); DPRINTK("adv_pci1723 EDBG: END: pci1723_reset(...)\n"); return 0; } -static int pci1723_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -218,8 +218,8 @@ static int pci1723_insn_read_ao(struct comedi_device * dev, struct comedi_subdev /* analog data output; */ -static int pci1723_ao_write_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; chan = CR_CHAN(insn->chanspec); @@ -238,8 +238,8 @@ static int pci1723_ao_write_winsn(struct comedi_device * dev, struct comedi_subd /* digital i/o config/query */ -static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; unsigned int bits; @@ -265,12 +265,12 @@ static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_sub return -EINVAL; } - // update hardware DIO mode - dio_mode = 0x0000; // low byte output, high byte output + /* update hardware DIO mode */ + dio_mode = 0x0000; /* low byte output, high byte output */ if ((s->io_bits & 0x00FF) == 0) - dio_mode |= 0x0001; // low byte input + dio_mode |= 0x0001; /* low byte input */ if ((s->io_bits & 0xFF00) == 0) - dio_mode |= 0x0002; // high byte input + dio_mode |= 0x0002; /* high byte input */ outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); return 1; } @@ -278,8 +278,8 @@ static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_sub /* digital i/o bits read/write */ -static int pci1723_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -294,7 +294,7 @@ static int pci1723_dio_insn_bits(struct comedi_device * dev, struct comedi_subde * Attach is called by the Comedi core to configure the driver * for a pci1723 board. */ -static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices; @@ -304,14 +304,15 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * int opt_bus, opt_slot; const char *errstr; - rt_printk("comedi%d: adv_pci1723: board=%s", dev->minor, + printk("comedi%d: adv_pci1723: board=%s", dev->minor, this_board->name); opt_bus = it->options[0]; opt_slot = it->options[1]; - if ((ret = alloc_private(dev, sizeof(struct pci1723_private))) < 0) { - rt_printk(" - Allocation failed!\n"); + ret = alloc_private(dev, sizeof(struct pci1723_private)); + if (ret < 0) { + printk(" - Allocation failed!\n"); return -ENOMEM; } @@ -341,10 +342,10 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * if (!pcidev) { if (opt_bus || opt_slot) { - rt_printk(" - Card at b:s %d:%d %s\n", + printk(" - Card at b:s %d:%d %s\n", opt_bus, opt_slot, errstr); } else { - rt_printk(" - Card %s\n", errstr); + printk(" - Card %s\n", errstr); } return -EIO; } @@ -354,7 +355,7 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * pci_func = PCI_FUNC(pcidev->devfn); iobase = pci_resource_start(pcidev, 2); - rt_printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func, + printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func, iobase); dev->iobase = iobase; @@ -369,8 +370,9 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * if (this_board->n_diochan) n_subdevices++; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) { - rt_printk(" - Allocation failed!\n"); + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) { + printk(" - Allocation failed!\n"); return ret; } @@ -389,22 +391,22 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * s->insn_write = pci1723_ao_write_winsn; s->insn_read = pci1723_insn_read_ao; - // read DIO config + /* read DIO config */ switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) & 0x03) { - case 0x00: // low byte output, high byte output + case 0x00: /* low byte output, high byte output */ s->io_bits = 0xFFFF; break; - case 0x01: // low byte input, high byte output + case 0x01: /* low byte input, high byte output */ s->io_bits = 0xFF00; break; - case 0x02: // low byte output, high byte input + case 0x02: /* low byte output, high byte input */ s->io_bits = 0x00FF; break; - case 0x03: // low byte input, high byte input + case 0x03: /* low byte input, high byte input */ s->io_bits = 0x0000; break; } - // read DIO port state + /* read DIO port state */ s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA); subdev++; @@ -439,7 +441,7 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pci1723_detach(struct comedi_device * dev) +static int pci1723_detach(struct comedi_device *dev) { printk("comedi%d: pci1723: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 2604425c3a0f..5a8c0a3bb2f8 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -40,7 +40,7 @@ Configuration options: #undef DPRINTK #ifdef PCI_DIO_EXTDEBUG -#define DPRINTK(fmt, args...) rt_printk(fmt, ## args) +#define DPRINTK(fmt, args...) printk(fmt, ## args) #else #define DPRINTK(fmt, args...) #endif @@ -183,8 +183,8 @@ enum hw_io_access { #define OMBCMD_RETRY 0x03 /* 3 times try request before error */ -static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci_dio_detach(struct comedi_device * dev); +static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci_dio_detach(struct comedi_device *dev); struct diosubd_data { int chans; /* num of chans */ @@ -323,10 +323,10 @@ static const struct dio_boardtype boardtypes[] = { #define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype)) static struct comedi_driver driver_pci_dio = { - driver_name:"adv_pci_dio", - module:THIS_MODULE, - attach:pci_dio_attach, - detach:pci_dio_detach + .driver_name = "adv_pci_dio", + .module = THIS_MODULE, + .attach = pci_dio_attach, + .detach = pci_dio_detach }; struct pci_dio_private { @@ -357,8 +357,8 @@ static struct pci_dio_private *pci_priv = NULL; /* list of allocated cards */ /* ============================================================================== */ -static int pci_dio_insn_bits_di_b(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -374,8 +374,8 @@ static int pci_dio_insn_bits_di_b(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci_dio_insn_bits_di_w(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -390,8 +390,8 @@ static int pci_dio_insn_bits_di_w(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci_dio_insn_bits_do_b(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -411,8 +411,8 @@ static int pci_dio_insn_bits_do_b(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci_dio_insn_bits_do_w(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -432,7 +432,7 @@ static int pci_dio_insn_bits_do_w(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci1760_unchecked_mbxrequest(struct comedi_device * dev, +static int pci1760_unchecked_mbxrequest(struct comedi_device *dev, unsigned char *omb, unsigned char *imb, int repeats) { int cnt, tout, ok = 0; @@ -443,14 +443,15 @@ static int pci1760_unchecked_mbxrequest(struct comedi_device * dev, outb(omb[2], dev->iobase + OMB2); outb(omb[3], dev->iobase + OMB3); for (tout = 0; tout < 251; tout++) { - if ((imb[2] = inb(dev->iobase + IMB2)) == omb[2]) { + imb[2] = inb(dev->iobase + IMB2); + if (imb[2] == omb[2]) { imb[0] = inb(dev->iobase + IMB0); imb[1] = inb(dev->iobase + IMB1); imb[3] = inb(dev->iobase + IMB3); ok = 1; break; } - comedi_udelay(1); + udelay(1); } if (ok) return 0; @@ -460,7 +461,7 @@ static int pci1760_unchecked_mbxrequest(struct comedi_device * dev, return -ETIME; } -static int pci1760_clear_imb2(struct comedi_device * dev) +static int pci1760_clear_imb2(struct comedi_device *dev) { unsigned char omb[4] = { 0x0, 0x0, CMD_ClearIMB2, 0x0 }; unsigned char imb[4]; @@ -470,7 +471,7 @@ static int pci1760_clear_imb2(struct comedi_device * dev) return pci1760_unchecked_mbxrequest(dev, omb, imb, OMBCMD_RETRY); } -static int pci1760_mbxrequest(struct comedi_device * dev, +static int pci1760_mbxrequest(struct comedi_device *dev, unsigned char *omb, unsigned char *imb) { if (omb[2] == CMD_ClearIMB2) { @@ -490,8 +491,8 @@ static int pci1760_mbxrequest(struct comedi_device * dev, /* ============================================================================== */ -static int pci1760_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inb(dev->iobase + IMB3); @@ -501,8 +502,8 @@ static int pci1760_insn_bits_di(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret; unsigned char omb[4] = { @@ -517,7 +518,8 @@ static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdev s->state &= ~data[0]; s->state |= (data[0] & data[1]); omb[0] = s->state; - if (!(ret = pci1760_mbxrequest(dev, omb, imb))) + ret = pci1760_mbxrequest(dev, omb, imb); + if (!ret) return ret; } data[1] = s->state; @@ -528,8 +530,8 @@ static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret, n; unsigned char omb[4] = { @@ -541,7 +543,8 @@ static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subde unsigned char imb[4]; for (n = 0; n < insn->n; n++) { - if (!(ret = pci1760_mbxrequest(dev, omb, imb))) + ret = pci1760_mbxrequest(dev, omb, imb); + if (!ret) return ret; data[n] = (imb[1] << 8) + imb[0]; } @@ -552,8 +555,8 @@ static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subde /* ============================================================================== */ -static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret; unsigned char chan = CR_CHAN(insn->chanspec) & 0x07; @@ -567,20 +570,23 @@ static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subd unsigned char imb[4]; if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) { /* Set reset value if different */ - if (!(ret = pci1760_mbxrequest(dev, omb, imb))) + ret = pci1760_mbxrequest(dev, omb, imb); + if (!ret) return ret; devpriv->CntResValue[chan] = data[0] & 0xffff; } omb[0] = bitmask; /* reset counter to it reset value */ omb[2] = CMD_ResetIDICounters; - if (!(ret = pci1760_mbxrequest(dev, omb, imb))) + ret = pci1760_mbxrequest(dev, omb, imb); + if (!ret) return ret; if (!(bitmask & devpriv->IDICntEnable)) { /* start counter if it don't run */ omb[0] = bitmask; omb[2] = CMD_EnableIDICounters; - if (!(ret = pci1760_mbxrequest(dev, omb, imb))) + ret = pci1760_mbxrequest(dev, omb, imb); + if (!ret) return ret; devpriv->IDICntEnable |= bitmask; } @@ -590,7 +596,7 @@ static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subd /* ============================================================================== */ -static int pci1760_reset(struct comedi_device * dev) +static int pci1760_reset(struct comedi_device *dev) { int i; unsigned char omb[4] = { 0x00, 0x00, 0x00, 0x00 }; @@ -667,7 +673,7 @@ static int pci1760_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci_dio_reset(struct comedi_device * dev) +static int pci_dio_reset(struct comedi_device *dev) { DPRINTK("adv_pci_dio EDBG: BGN: pci171x_reset(...)\n"); @@ -750,7 +756,7 @@ static int pci_dio_reset(struct comedi_device * dev) /* ============================================================================== */ -static int pci1760_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int subdev = 0; @@ -802,8 +808,8 @@ static int pci1760_attach(struct comedi_device * dev, struct comedi_devconfig * /* ============================================================================== */ -static int pci_dio_add_di(struct comedi_device * dev, struct comedi_subdevice * s, - const struct diosubd_data * d, int subdev) +static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s, + const struct diosubd_data *d, int subdev) { s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags; @@ -829,8 +835,8 @@ static int pci_dio_add_di(struct comedi_device * dev, struct comedi_subdevice * /* ============================================================================== */ -static int pci_dio_add_do(struct comedi_device * dev, struct comedi_subdevice * s, - const struct diosubd_data * d, int subdev) +static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s, + const struct diosubd_data *d, int subdev) { s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; @@ -857,7 +863,7 @@ static int pci_dio_add_do(struct comedi_device * dev, struct comedi_subdevice * /* ============================================================================== */ -static int CheckAndAllocCard(struct comedi_device * dev, struct comedi_devconfig * it, +static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig *it, struct pci_dev *pcidev) { struct pci_dio_private *pr, *prev; @@ -883,17 +889,18 @@ static int CheckAndAllocCard(struct comedi_device * dev, struct comedi_devconfig /* ============================================================================== */ -static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices, i, j; unsigned long iobase; struct pci_dev *pcidev; - rt_printk("comedi%d: adv_pci_dio: ", dev->minor); + printk("comedi%d: adv_pci_dio: ", dev->minor); - if ((ret = alloc_private(dev, sizeof(struct pci_dio_private))) < 0) { - rt_printk(", Error: Cann't allocate private memory!\n"); + ret = alloc_private(dev, sizeof(struct pci_dio_private)); + if (ret < 0) { + printk(", Error: Cann't allocate private memory!\n"); return -ENOMEM; } @@ -925,18 +932,18 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * } if (!dev->board_ptr) { - rt_printk + printk (", Error: Requested type of the card was not found!\n"); return -EIO; } if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) { - rt_printk + printk (", Error: Can't enable PCI device and request regions!\n"); return -EIO; } iobase = pci_resource_start(pcidev, this_board->main_pci_region); - rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx", + printk(", b:s:f=%d:%d:%d, io=0x%4lx", pcidev->bus->number, PCI_SLOT(pcidev->devfn), PCI_FUNC(pcidev->devfn), iobase); @@ -959,12 +966,13 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * n_subdevices++; } - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) { - rt_printk(", Error: Cann't allocate subdevice memory!\n"); + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) { + printk(", Error: Cann't allocate subdevice memory!\n"); return ret; } - rt_printk(".\n"); + printk(".\n"); subdev = 0; @@ -1011,7 +1019,7 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * /* ============================================================================== */ -static int pci_dio_detach(struct comedi_device * dev) +static int pci_dio_detach(struct comedi_device *dev) { int i, j; struct comedi_subdevice *s; diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index b97b4d82611b..72283ae81368 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -77,7 +77,7 @@ struct aio12_8_boardtype { static const struct aio12_8_boardtype board_types[] = { { - name: "aio_aio12_8"}, + .name = "aio_aio12_8"}, }; #define thisboard ((const struct aio12_8_boardtype *) dev->board_ptr) @@ -88,29 +88,29 @@ struct aio12_8_private { #define devpriv ((struct aio12_8_private *) dev->private) -static int aio_aio12_8_ai_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; unsigned char control = ADC_MODE_NORMAL | (CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec); - //read status to clear EOC latch + /* read status to clear EOC latch */ inb(dev->iobase + AIO12_8_STATUS); for (n = 0; n < insn->n; n++) { int timeout = 5; - // Setup and start conversion + /* Setup and start conversion */ outb(control, dev->iobase + AIO12_8_ADC); - // Wait for conversion to complete + /* Wait for conversion to complete */ while (timeout && !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) { timeout--; printk("timeout %d\n", timeout); - comedi_udelay(1); + udelay(1); } if (timeout == 0) { comedi_error(dev, "ADC timeout"); @@ -122,8 +122,8 @@ static int aio_aio12_8_ai_read(struct comedi_device * dev, struct comedi_subdevi return n; } -static int aio_aio12_8_ao_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int val = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; @@ -133,19 +133,19 @@ static int aio_aio12_8_ao_read(struct comedi_device * dev, struct comedi_subdevi return insn->n; } -static int aio_aio12_8_ao_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); unsigned long port = dev->iobase + AIO12_8_DAC_0 + (2 * chan); - //enable DACs + /* enable DACs */ outb(0x01, dev->iobase + DAC_ENABLE); for (i = 0; i < insn->n; i++) { - outb(data[i] & 0xFF, port); // LSB - outb((data[i] >> 8) & 0x0F, port + 1); // MSB + outb(data[i] & 0xFF, port); /* LSB */ + outb((data[i] >> 8) & 0x0F, port + 1); /* MSB */ devpriv->ao_readback[chan] = data[i]; } return insn->n; @@ -161,7 +161,7 @@ static const struct comedi_lrange range_aio_aio12_8 = { } }; -static int aio_aio12_8_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int aio_aio12_8_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int iobase; struct comedi_subdevice *s; @@ -205,7 +205,7 @@ static int aio_aio12_8_attach(struct comedi_device * dev, struct comedi_devconfi return 0; } -static int aio_aio12_8_detach(struct comedi_device * dev) +static int aio_aio12_8_detach(struct comedi_device *dev) { subdev_8255_cleanup(dev, &dev->subdevices[2]); if (dev->iobase) @@ -214,13 +214,13 @@ static int aio_aio12_8_detach(struct comedi_device * dev) } static struct comedi_driver driver_aio_aio12_8 = { - driver_name:"aio_aio12_8", - module:THIS_MODULE, - attach:aio_aio12_8_attach, - detach:aio_aio12_8_detach, - board_name:&board_types[0].name, - num_names:1, - offset:sizeof(struct aio12_8_boardtype), + .driver_name = "aio_aio12_8", + .module = THIS_MODULE, + .attach = aio_aio12_8_attach, + .detach = aio_aio12_8_detach, + .board_name = &board_types[0].name, + .num_names = 1, + .offset = sizeof(struct aio12_8_boardtype), }; COMEDI_INITCLEANUP(driver_aio_aio12_8); diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 9160fdf0ca37..d062f8619b6e 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -52,9 +52,9 @@ struct aio_iiro_16_board { static const struct aio_iiro_16_board aio_iiro_16_boards[] = { { - name: "aio_iiro_16", - di: 16, - do_: 16}, + .name = "aio_iiro_16", + .di = 16, + .do_ = 16}, }; #define thisboard ((const struct aio_iiro_16_board *) dev->board_ptr) @@ -67,27 +67,27 @@ struct aio_iiro_16_private { #define devpriv ((struct aio_iiro_16_private *) dev->private) -static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfig * it); +static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it); -static int aio_iiro_16_detach(struct comedi_device * dev); +static int aio_iiro_16_detach(struct comedi_device *dev); static struct comedi_driver driver_aio_iiro_16 = { - driver_name:"aio_iiro_16", - module:THIS_MODULE, - attach:aio_iiro_16_attach, - detach:aio_iiro_16_detach, - board_name:&aio_iiro_16_boards[0].name, - offset:sizeof(struct aio_iiro_16_board), - num_names:sizeof(aio_iiro_16_boards) / sizeof(struct aio_iiro_16_board), + .driver_name = "aio_iiro_16", + .module = THIS_MODULE, + .attach = aio_iiro_16_attach, + .detach = aio_iiro_16_detach, + .board_name = &aio_iiro_16_boards[0].name, + .offset = sizeof(struct aio_iiro_16_board), + .num_names = ARRAY_SIZE(aio_iiro_16_boards), }; -static int aio_iiro_16_dio_insn_bits_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int iobase; struct comedi_subdevice *s; @@ -132,7 +132,7 @@ static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfi return 1; } -static int aio_iiro_16_detach(struct comedi_device * dev) +static int aio_iiro_16_detach(struct comedi_device *dev) { printk("comedi%d: aio_iiro_16: remove\n", dev->minor); @@ -142,8 +142,8 @@ static int aio_iiro_16_detach(struct comedi_device * dev) return 0; } -static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -161,8 +161,8 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev, return 2; } -static int aio_iiro_16_dio_insn_bits_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/am9513.h b/drivers/staging/comedi/drivers/am9513.h index f533cf1658cf..73367d6afffe 100644 --- a/drivers/staging/comedi/drivers/am9513.h +++ b/drivers/staging/comedi/drivers/am9513.h @@ -46,33 +46,33 @@ #ifdef Am9513_8BITBUS -#define Am9513_write_register(reg,val) \ +#define Am9513_write_register(reg, val) \ do{ \ Am9513_output_control(reg); \ Am9513_output_data(val>>8); \ Am9513_output_data(val&0xff); \ - }while(0) + }while (0) -#define Am9513_read_register(reg,val) \ +#define Am9513_read_register(reg, val) \ do{ \ Am9513_output_control(reg); \ val=Am9513_input_data()<<8; \ val|=Am9513_input_data(); \ - }while(0) + }while (0) #else /* Am9513_16BITBUS */ -#define Am9513_write_register(reg,val) \ +#define Am9513_write_register(reg, val) \ do{ \ Am9513_output_control(reg); \ Am9513_output_data(val); \ - }while(0) + }while (0) -#define Am9513_read_register(reg,val) \ +#define Am9513_read_register(reg, val) \ do{ \ Am9513_output_control(reg); \ val=Am9513_input_data(); \ - }while(0) + }while (0) #endif diff --git a/drivers/staging/comedi/drivers/amcc_s5933.h b/drivers/staging/comedi/drivers/amcc_s5933.h index aceffce7ef3f..b810d5f3d971 100644 --- a/drivers/staging/comedi/drivers/amcc_s5933.h +++ b/drivers/staging/comedi/drivers/amcc_s5933.h @@ -48,12 +48,12 @@ /****************************************************************************/ #define INTCSR_OUTBOX_BYTE(x) ((x) & 0x3) #define INTCSR_OUTBOX_SELECT(x) (((x) & 0x3) << 2) -#define INTCSR_OUTBOX_EMPTY_INT 0x10 // enable outbox empty interrupt +#define INTCSR_OUTBOX_EMPTY_INT 0x10 /* enable outbox empty interrupt */ #define INTCSR_INBOX_BYTE(x) (((x) & 0x3) << 8) #define INTCSR_INBOX_SELECT(x) (((x) & 0x3) << 10) -#define INTCSR_INBOX_FULL_INT 0x1000 // enable inbox full interrupt -#define INTCSR_INBOX_INTR_STATUS 0x20000 // read, or write clear inbox full interrupt -#define INTCSR_INTR_ASSERTED 0x800000 // read only, interrupt asserted +#define INTCSR_INBOX_FULL_INT 0x1000 /* enable inbox full interrupt */ +#define INTCSR_INBOX_INTR_STATUS 0x20000 /* read, or write clear inbox full interrupt */ +#define INTCSR_INTR_ASSERTED 0x800000 /* read only, interrupt asserted */ /****************************************************************************/ /* AMCC - PCI non-volatile ram command register (byte 3 of master control/status register) */ @@ -153,7 +153,7 @@ #define AINT_IMB_SELECT 0x0000000c #define AINT_IMB_BYTE 0x00000003 -// these are bits from various different registers, needs cleanup XXX +/* these are bits from various different registers, needs cleanup XXX */ /* Enable Bus Mastering */ #define EN_A2P_TRANSFERS 0x00000400 /* FIFO Flag Reset */ diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 8555e272a861..744680059faf 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -205,6 +205,8 @@ is packed into a short value, one bit per requested channel, in the order they appear in the channel list. */ +#include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_pci.h" @@ -288,59 +290,59 @@ struct dio200_board { static const struct dio200_board dio200_boards[] = { { - name: "pc212e", - bustype: isa_bustype, - model: pc212e_model, - layout: pc212_layout, + .name = "pc212e", + .bustype = isa_bustype, + .model = pc212e_model, + .layout = pc212_layout, }, { - name: "pc214e", - bustype: isa_bustype, - model: pc214e_model, - layout: pc214_layout, + .name = "pc214e", + .bustype = isa_bustype, + .model = pc214e_model, + .layout = pc214_layout, }, { - name: "pc215e", - bustype: isa_bustype, - model: pc215e_model, - layout: pc215_layout, + .name = "pc215e", + .bustype = isa_bustype, + .model = pc215e_model, + .layout = pc215_layout, }, #ifdef CONFIG_COMEDI_PCI { - name: "pci215", - devid: PCI_DEVICE_ID_AMPLICON_PCI215, - bustype: pci_bustype, - model: pci215_model, - layout: pc215_layout, + .name = "pci215", + .devid = PCI_DEVICE_ID_AMPLICON_PCI215, + .bustype = pci_bustype, + .model = pci215_model, + .layout = pc215_layout, }, #endif { - name: "pc218e", - bustype: isa_bustype, - model: pc218e_model, - layout: pc218_layout, + .name = "pc218e", + .bustype = isa_bustype, + .model = pc218e_model, + .layout = pc218_layout, }, { - name: "pc272e", - bustype: isa_bustype, - model: pc272e_model, - layout: pc272_layout, + .name = "pc272e", + .bustype = isa_bustype, + .model = pc272e_model, + .layout = pc272_layout, }, #ifdef CONFIG_COMEDI_PCI { - name: "pci272", - devid: PCI_DEVICE_ID_AMPLICON_PCI272, - bustype: pci_bustype, - model: pci272_model, - layout: pc272_layout, + .name = "pci272", + .devid = PCI_DEVICE_ID_AMPLICON_PCI272, + .bustype = pci_bustype, + .model = pci272_model, + .layout = pc272_layout, }, #endif #ifdef CONFIG_COMEDI_PCI { - name: DIO200_DRIVER_NAME, - devid: PCI_DEVICE_ID_INVALID, - bustype: pci_bustype, - model: anypci_model, /* wildcard */ + .name = DIO200_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ }, #endif }; @@ -365,50 +367,50 @@ struct dio200_layout_struct { static const struct dio200_layout_struct dio200_layouts[] = { [pc212_layout] = { - n_subdevs:6, - sdtype: {sd_8255, sd_8254, sd_8254, sd_8254, + .n_subdevs = 6, + .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254, sd_8254, sd_intr}, - sdinfo: {0x00, 0x08, 0x0C, 0x10, 0x14, + .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14, 0x3F}, - has_int_sce:1, - has_clk_gat_sce:1, + .has_int_sce = 1, + .has_clk_gat_sce = 1, }, [pc214_layout] = { - n_subdevs:4, - sdtype: {sd_8255, sd_8255, sd_8254, + .n_subdevs = 4, + .sdtype = {sd_8255, sd_8255, sd_8254, sd_intr}, - sdinfo: {0x00, 0x08, 0x10, 0x01}, - has_int_sce:0, - has_clk_gat_sce:0, + .sdinfo = {0x00, 0x08, 0x10, 0x01}, + .has_int_sce = 0, + .has_clk_gat_sce = 0, }, [pc215_layout] = { - n_subdevs:5, - sdtype: {sd_8255, sd_8255, sd_8254, + .n_subdevs = 5, + .sdtype = {sd_8255, sd_8255, sd_8254, sd_8254, sd_intr}, - sdinfo: {0x00, 0x08, 0x10, 0x14, 0x3F}, - has_int_sce:1, - has_clk_gat_sce:1, + .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 1, }, [pc218_layout] = { - n_subdevs:7, - sdtype: {sd_8254, sd_8254, sd_8255, sd_8254, + .n_subdevs = 7, + .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254, sd_8254, sd_intr}, - sdinfo: {0x00, 0x04, 0x08, 0x0C, 0x10, + .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x3F}, - has_int_sce:1, - has_clk_gat_sce:1, + .has_int_sce = 1, + .has_clk_gat_sce = 1, }, [pc272_layout] = { - n_subdevs:4, - sdtype: {sd_8255, sd_8255, sd_8255, + .n_subdevs = 4, + .sdtype = {sd_8255, sd_8255, sd_8255, sd_intr}, - sdinfo: {0x00, 0x08, 0x10, 0x3F}, - has_int_sce:1, - has_clk_gat_sce:0, + .sdinfo = {0x00, 0x08, 0x10, 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 0, }, }; @@ -473,16 +475,16 @@ struct dio200_subdev_intr { * the board, and also about the kernel module that contains * the device code. */ -static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dio200_detach(struct comedi_device * dev); +static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dio200_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_dio200 = { - driver_name:DIO200_DRIVER_NAME, - module:THIS_MODULE, - attach:dio200_attach, - detach:dio200_detach, - board_name:&dio200_boards[0].name, - offset:sizeof(struct dio200_board), - num_names:sizeof(dio200_boards) / sizeof(struct dio200_board), + .driver_name = DIO200_DRIVER_NAME, + .module = THIS_MODULE, + .attach = dio200_attach, + .detach = dio200_detach, + .board_name = &dio200_boards[0].name, + .offset = sizeof(struct dio200_board), + .num_names = ARRAY_SIZE(dio200_boards), }; #ifdef CONFIG_COMEDI_PCI @@ -497,7 +499,7 @@ COMEDI_INITCLEANUP(driver_amplc_dio200); */ #ifdef CONFIG_COMEDI_PCI static int -dio200_find_pci(struct comedi_device * dev, int bus, int slot, +dio200_find_pci(struct comedi_device *dev, int bus, int slot, struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -572,8 +574,8 @@ dio200_request_region(unsigned minor, unsigned long from, unsigned long extent) * 'insn_bits' function for an 'INTERRUPT' subdevice. */ static int -dio200_subdev_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +dio200_subdev_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_intr *subpriv = s->private; @@ -591,7 +593,7 @@ dio200_subdev_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice /* * Called to stop acquisition for an 'INTERRUPT' subdevice. */ -static void dio200_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static void dio200_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -605,7 +607,7 @@ static void dio200_stop_intr(struct comedi_device * dev, struct comedi_subdevice /* * Called to start acquisition for an 'INTERRUPT' subdevice. */ -static int dio200_start_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned int n; unsigned isn_bits; @@ -641,7 +643,7 @@ static int dio200_start_intr(struct comedi_device * dev, struct comedi_subdevice * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. */ static int -dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s, +dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { struct dio200_subdev_intr *subpriv; @@ -653,12 +655,12 @@ dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * subpriv = s->private; - comedi_spin_lock_irqsave(&subpriv->spinlock, flags); + spin_lock_irqsave(&subpriv->spinlock, flags); s->async->inttrig = 0; if (subpriv->active) { event = dio200_start_intr(dev, s); } - comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags); + spin_unlock_irqrestore(&subpriv->spinlock, flags); if (event) { comedi_event(dev, s); @@ -671,7 +673,7 @@ dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * * This is called from the interrupt service routine to handle a read * scan on an 'INTERRUPT' subdevice. */ -static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; unsigned triggered; @@ -682,7 +684,7 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub triggered = 0; - comedi_spin_lock_irqsave(&subpriv->spinlock, flags); + spin_lock_irqsave(&subpriv->spinlock, flags); oldevents = s->async->events; if (subpriv->has_int_sce) { /* @@ -771,7 +773,7 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub } } } - comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags); + spin_unlock_irqrestore(&subpriv->spinlock, flags); if (oldevents != s->async->events) { comedi_event(dev, s); @@ -783,16 +785,16 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub /* * 'cancel' function for an 'INTERRUPT' subdevice. */ -static int dio200_subdev_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; unsigned long flags; - comedi_spin_lock_irqsave(&subpriv->spinlock, flags); + spin_lock_irqsave(&subpriv->spinlock, flags); if (subpriv->active) { dio200_stop_intr(dev, s); } - comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags); + spin_unlock_irqrestore(&subpriv->spinlock, flags); return 0; } @@ -801,8 +803,8 @@ static int dio200_subdev_intr_cancel(struct comedi_device * dev, struct comedi_s * 'do_cmdtest' function for an 'INTERRUPT' subdevice. */ static int -dio200_subdev_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -907,14 +909,14 @@ dio200_subdev_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * /* * 'do_cmd' function for an 'INTERRUPT' subdevice. */ -static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; struct dio200_subdev_intr *subpriv = s->private; unsigned long flags; int event = 0; - comedi_spin_lock_irqsave(&subpriv->spinlock, flags); + spin_lock_irqsave(&subpriv->spinlock, flags); subpriv->active = 1; /* Set up end of acquisition. */ @@ -940,7 +942,7 @@ static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subd event = dio200_start_intr(dev, s); break; } - comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags); + spin_unlock_irqrestore(&subpriv->spinlock, flags); if (event) { comedi_event(dev, s); @@ -953,7 +955,7 @@ static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subd * This function initializes an 'INTERRUPT' subdevice. */ static int -dio200_subdev_intr_init(struct comedi_device * dev, struct comedi_subdevice * s, +dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long iobase, unsigned valid_isns, int has_int_sce) { struct dio200_subdev_intr *subpriv; @@ -998,7 +1000,7 @@ dio200_subdev_intr_init(struct comedi_device * dev, struct comedi_subdevice * s, * This function cleans up an 'INTERRUPT' subdevice. */ static void -dio200_subdev_intr_cleanup(struct comedi_device * dev, struct comedi_subdevice * s) +dio200_subdev_intr_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -1010,7 +1012,7 @@ dio200_subdev_intr_cleanup(struct comedi_device * dev, struct comedi_subdevice * /* * Interrupt service routine. */ -static irqreturn_t dio200_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t dio200_interrupt(int irq, void *d) { struct comedi_device *dev = d; int handled; @@ -1033,8 +1035,8 @@ static irqreturn_t dio200_interrupt(int irq, void *d PT_REGS_ARG) * Handle 'insn_read' for an '8254' counter subdevice. */ static int -dio200_subdev_8254_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int chan = CR_CHAN(insn->chanspec); @@ -1048,8 +1050,8 @@ dio200_subdev_8254_read(struct comedi_device * dev, struct comedi_subdevice * s, * Handle 'insn_write' for an '8254' counter subdevice. */ static int -dio200_subdev_8254_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int chan = CR_CHAN(insn->chanspec); @@ -1063,7 +1065,7 @@ dio200_subdev_8254_write(struct comedi_device * dev, struct comedi_subdevice * s * Set gate source for an '8254' counter subdevice channel. */ static int -dio200_set_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number, +dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, unsigned int gate_src) { unsigned char byte; @@ -1086,7 +1088,7 @@ dio200_set_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_nu * Get gate source for an '8254' counter subdevice channel. */ static int -dio200_get_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number) +dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number) { if (!subpriv->has_clk_gat_sce) return -1; @@ -1100,7 +1102,7 @@ dio200_get_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_nu * Set clock source for an '8254' counter subdevice channel. */ static int -dio200_set_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number, +dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, unsigned int clock_src) { unsigned char byte; @@ -1123,8 +1125,8 @@ dio200_set_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_n * Get clock source for an '8254' counter subdevice channel. */ static int -dio200_get_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number, - unsigned int * period_ns) +dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, + unsigned int *period_ns) { unsigned clock_src; @@ -1142,8 +1144,8 @@ dio200_get_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_n * Handle 'insn_config' for an '8254' counter subdevice. */ static int -dio200_subdev_8254_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int ret; @@ -1194,7 +1196,7 @@ dio200_subdev_8254_config(struct comedi_device * dev, struct comedi_subdevice * * offset is the offset to the 8254 chip. */ static int -dio200_subdev_8254_init(struct comedi_device * dev, struct comedi_subdevice * s, +dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long iobase, unsigned offset, int has_clk_gat_sce) { struct dio200_subdev_8254 *subpriv; @@ -1247,7 +1249,7 @@ dio200_subdev_8254_init(struct comedi_device * dev, struct comedi_subdevice * s, * This function cleans up an '8254' counter subdevice. */ static void -dio200_subdev_8254_cleanup(struct comedi_device * dev, struct comedi_subdevice * s) +dio200_subdev_8254_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -1262,7 +1264,7 @@ dio200_subdev_8254_cleanup(struct comedi_device * dev, struct comedi_subdevice * * in the driver structure, dev->board_ptr contains that * address. */ -static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = 0; @@ -1280,7 +1282,8 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, DIO200_DRIVER_NAME); - if ((ret = alloc_private(dev, sizeof(struct dio200_private))) < 0) { + ret = alloc_private(dev, sizeof(struct dio200_private)); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -1299,7 +1302,8 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i slot = it->options[1]; share_irq = 1; - if ((ret = dio200_find_pci(dev, bus, slot, &pci_dev)) < 0) + ret = dio200_find_pci(dev, bus, slot, &pci_dev); + if (ret < 0) return ret; devpriv->pci_dev = pci_dev; break; @@ -1337,7 +1341,9 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase = iobase; layout = thislayout; - if ((ret = alloc_subdevices(dev, layout->n_subdevs)) < 0) { + + ret = alloc_subdevices(dev, layout->n_subdevs); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -1392,7 +1398,7 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i if (irq) { unsigned long flags = share_irq ? IRQF_SHARED : 0; - if (comedi_request_irq(irq, dio200_interrupt, flags, + if (request_irq(irq, dio200_interrupt, flags, DIO200_DRIVER_NAME, dev) >= 0) { dev->irq = irq; } else { @@ -1429,7 +1435,7 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int dio200_detach(struct comedi_device * dev) +static int dio200_detach(struct comedi_device *dev) { const struct dio200_layout_struct *layout; unsigned n; @@ -1438,7 +1444,7 @@ static int dio200_detach(struct comedi_device * dev) DIO200_DRIVER_NAME); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->subdevices) { layout = thislayout; diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 2027c75feaca..48d7ccb4a3fe 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -27,7 +27,7 @@ Driver: amplc_pc236 Description: Amplicon PC36AT, PCI236 Author: Ian Abbott <abbotti@mev.co.uk> Devices: [Amplicon] PC36AT (pc36at), PCI236 (pci236 or amplc_pc236) -Updated: Wed, 22 Oct 2008 13:40:03 +0100 +Updated: Wed, 01 Apr 2009 15:41:25 +0100 Status: works Configuration options - PC36AT: @@ -45,13 +45,15 @@ as subdevice 0. Subdevice 1 pretends to be a digital input device, but it always returns 0 when read. However, if you run a command with scan_begin_src=TRIG_EXT, -a rising edge on port C bit 7 acts as an external trigger, which can be +a rising edge on port C bit 3 acts as an external trigger, which can be used to wake up tasks. This is like the comedi_parport device, but the only way to physically disable the interrupt on the PC36AT is to remove the IRQ jumper. If no interrupt is connected, then subdevice 1 is unused. */ +#include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_pci.h" @@ -75,19 +77,19 @@ unused. * INTCSR values for PCI236. */ /* Disable interrupt, also clear any interrupt there */ -#define PCI236_INTR_DISABLE ( PLX9052_INTCSR_LI1ENAB_DISABLED \ +#define PCI236_INTR_DISABLE (PLX9052_INTCSR_LI1ENAB_DISABLED \ | PLX9052_INTCSR_LI1POL_HIGH \ | PLX9052_INTCSR_LI2POL_HIGH \ | PLX9052_INTCSR_PCIENAB_DISABLED \ | PLX9052_INTCSR_LI1SEL_EDGE \ - | PLX9052_INTCSR_LI1CLRINT_ASSERTED ) + | PLX9052_INTCSR_LI1CLRINT_ASSERTED) /* Enable interrupt, also clear any interrupt there. */ -#define PCI236_INTR_ENABLE ( PLX9052_INTCSR_LI1ENAB_ENABLED \ +#define PCI236_INTR_ENABLE (PLX9052_INTCSR_LI1ENAB_ENABLED \ | PLX9052_INTCSR_LI1POL_HIGH \ | PLX9052_INTCSR_LI2POL_HIGH \ | PLX9052_INTCSR_PCIENAB_ENABLED \ | PLX9052_INTCSR_LI1SEL_EDGE \ - | PLX9052_INTCSR_LI1CLRINT_ASSERTED ) + | PLX9052_INTCSR_LI1CLRINT_ASSERTED) /* * Board descriptions for Amplicon PC36AT and PCI236. @@ -105,27 +107,27 @@ struct pc236_board { }; static const struct pc236_board pc236_boards[] = { { - name: "pc36at", - fancy_name:"PC36AT", - bustype: isa_bustype, - model: pc36at_model, + .name = "pc36at", + .fancy_name = "PC36AT", + .bustype = isa_bustype, + .model = pc36at_model, }, #ifdef CONFIG_COMEDI_PCI { - name: "pci236", - fancy_name:"PCI236", - devid: PCI_DEVICE_ID_AMPLICON_PCI236, - bustype: pci_bustype, - model: pci236_model, + .name = "pci236", + .fancy_name = "PCI236", + .devid = PCI_DEVICE_ID_AMPLICON_PCI236, + .bustype = pci_bustype, + .model = pci236_model, }, #endif #ifdef CONFIG_COMEDI_PCI { - name: PC236_DRIVER_NAME, - fancy_name:PC236_DRIVER_NAME, - devid: PCI_DEVICE_ID_INVALID, - bustype: pci_bustype, - model: anypci_model, /* wildcard */ + .name = PC236_DRIVER_NAME, + .fancy_name = PC236_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ }, #endif }; @@ -165,16 +167,16 @@ struct pc236_private { * the board, and also about the kernel module that contains * the device code. */ -static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pc236_detach(struct comedi_device * dev); +static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pc236_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pc236 = { - driver_name:PC236_DRIVER_NAME, - module:THIS_MODULE, - attach:pc236_attach, - detach:pc236_detach, - board_name:&pc236_boards[0].name, - offset:sizeof(struct pc236_board), - num_names:sizeof(pc236_boards) / sizeof(struct pc236_board), + .driver_name = PC236_DRIVER_NAME, + .module = THIS_MODULE, + .attach = pc236_attach, + .detach = pc236_detach, + .board_name = &pc236_boards[0].name, + .offset = sizeof(struct pc236_board), + .num_names = ARRAY_SIZE(pc236_boards), }; #ifdef CONFIG_COMEDI_PCI @@ -185,16 +187,16 @@ COMEDI_INITCLEANUP(driver_amplc_pc236); static int pc236_request_region(unsigned minor, unsigned long from, unsigned long extent); -static void pc236_intr_disable(struct comedi_device * dev); -static void pc236_intr_enable(struct comedi_device * dev); -static int pc236_intr_check(struct comedi_device * dev); -static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG); +static void pc236_intr_disable(struct comedi_device *dev); +static void pc236_intr_enable(struct comedi_device *dev); +static int pc236_intr_check(struct comedi_device *dev); +static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static irqreturn_t pc236_interrupt(int irq, void *d); /* * This function looks for a PCI device matching the requested board name, @@ -202,7 +204,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG); */ #ifdef CONFIG_COMEDI_PCI static int -pc236_find_pci(struct comedi_device * dev, int bus, int slot, +pc236_find_pci(struct comedi_device *dev, int bus, int slot, struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -264,7 +266,7 @@ pc236_find_pci(struct comedi_device * dev, int bus, int slot, * in the driver structure, dev->board_ptr contains that * address. */ -static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = 0; @@ -282,7 +284,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. */ - if ((ret = alloc_private(dev, sizeof(struct pc236_private))) < 0) { + ret = alloc_private(dev, sizeof(struct pc236_private)); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -300,7 +303,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it slot = it->options[1]; share_irq = 1; - if ((ret = pc236_find_pci(dev, bus, slot, &pci_dev)) < 0) + ret = pc236_find_pci(dev, bus, slot, &pci_dev); + if (ret < 0) return ret; devpriv->pci_dev = pci_dev; break; @@ -321,7 +325,9 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it /* Enable device and reserve I/O spaces. */ #ifdef CONFIG_COMEDI_PCI if (pci_dev) { - if ((ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME)) < 0) { + + ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! cannot enable PCI device and request regions!\n", dev->minor); @@ -344,7 +350,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. */ - if ((ret = alloc_subdevices(dev, 2)) < 0) { + ret = alloc_subdevices(dev, 2); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -352,7 +359,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it s = dev->subdevices + 0; /* digital i/o subdevice (8255) */ - if ((ret = subdev_8255_init(dev, s, NULL, iobase)) < 0) { + ret = subdev_8255_init(dev, s, NULL, iobase); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -364,7 +372,7 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it if (irq) { unsigned long flags = share_irq ? IRQF_SHARED : 0; - if (comedi_request_irq(irq, pc236_interrupt, flags, + if (request_irq(irq, pc236_interrupt, flags, PC236_DRIVER_NAME, dev) >= 0) { dev->irq = irq; s->type = COMEDI_SUBD_DI; @@ -405,7 +413,7 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pc236_detach(struct comedi_device * dev) +static int pc236_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, PC236_DRIVER_NAME); @@ -413,7 +421,7 @@ static int pc236_detach(struct comedi_device * dev) pc236_intr_disable(dev); } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->subdevices) { subdev_8255_cleanup(dev, dev->subdevices + 0); } @@ -459,17 +467,17 @@ static int pc236_request_region(unsigned minor, unsigned long from, * configured on subdevice 1) and to physically disable the interrupt * (not possible on the PC36AT, except by removing the IRQ jumper!). */ -static void pc236_intr_disable(struct comedi_device * dev) +static void pc236_intr_disable(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->enable_irq = 0; #ifdef CONFIG_COMEDI_PCI if (devpriv->lcr_iobase) outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR); #endif - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } /* @@ -477,17 +485,17 @@ static void pc236_intr_disable(struct comedi_device * dev) * configured on subdevice 1) and to physically enable the interrupt * (not possible on the PC36AT, except by (re)connecting the IRQ jumper!). */ -static void pc236_intr_enable(struct comedi_device * dev) +static void pc236_intr_enable(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->enable_irq = 1; #ifdef CONFIG_COMEDI_PCI if (devpriv->lcr_iobase) outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR); #endif - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } /* @@ -497,12 +505,12 @@ static void pc236_intr_enable(struct comedi_device * dev) * interrupt. * Returns 0 if the interrupt should be ignored. */ -static int pc236_intr_check(struct comedi_device * dev) +static int pc236_intr_check(struct comedi_device *dev) { int retval = 0; unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); if (devpriv->enable_irq) { retval = 1; #ifdef CONFIG_COMEDI_PCI @@ -519,7 +527,7 @@ static int pc236_intr_check(struct comedi_device * dev) } #endif } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return retval; } @@ -528,8 +536,8 @@ static int pc236_intr_check(struct comedi_device * dev) * Input from subdevice 1. * Copied from the comedi_parport driver. */ -static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = 0; return 2; @@ -539,8 +547,8 @@ static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice * * Subdevice 1 command test. * Copied from the comedi_parport driver. */ -static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -617,7 +625,7 @@ static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevic /* * Subdevice 1 command. */ -static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { pc236_intr_enable(dev); @@ -627,7 +635,7 @@ static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * /* * Subdevice 1 cancel command. */ -static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { pc236_intr_disable(dev); @@ -638,7 +646,7 @@ static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * Interrupt service routine. * Based on the comedi_parport driver. */ -static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t pc236_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 1; diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 97ac4157adaf..730b67743f0e 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -74,27 +74,27 @@ struct pc263_board { }; static const struct pc263_board pc263_boards[] = { { - name: "pc263", - fancy_name:"PC263", - bustype: isa_bustype, - model: pc263_model, + .name = "pc263", + .fancy_name = "PC263", + .bustype = isa_bustype, + .model = pc263_model, }, #ifdef CONFIG_COMEDI_PCI { - name: "pci263", - fancy_name:"PCI263", - devid: PCI_DEVICE_ID_AMPLICON_PCI263, - bustype: pci_bustype, - model: pci263_model, + .name = "pci263", + .fancy_name = "PCI263", + .devid = PCI_DEVICE_ID_AMPLICON_PCI263, + .bustype = pci_bustype, + .model = pci263_model, }, #endif #ifdef CONFIG_COMEDI_PCI { - name: PC263_DRIVER_NAME, - fancy_name:PC263_DRIVER_NAME, - devid: PCI_DEVICE_ID_INVALID, - bustype: pci_bustype, - model: anypci_model, /* wildcard */ + .name = PC263_DRIVER_NAME, + .fancy_name = PC263_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ }, #endif }; @@ -132,24 +132,24 @@ struct pc263_private { * the board, and also about the kernel module that contains * the device code. */ -static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pc263_detach(struct comedi_device * dev); +static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pc263_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pc263 = { - driver_name:PC263_DRIVER_NAME, - module:THIS_MODULE, - attach:pc263_attach, - detach:pc263_detach, - board_name:&pc263_boards[0].name, - offset:sizeof(struct pc263_board), - num_names:sizeof(pc263_boards) / sizeof(struct pc263_board), + .driver_name = PC263_DRIVER_NAME, + .module = THIS_MODULE, + .attach = pc263_attach, + .detach = pc263_detach, + .board_name = &pc263_boards[0].name, + .offset = sizeof(struct pc263_board), + .num_names = ARRAY_SIZE(pc263_boards), }; static int pc263_request_region(unsigned minor, unsigned long from, unsigned long extent); -static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * This function looks for a PCI device matching the requested board name, @@ -157,7 +157,7 @@ static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subde */ #ifdef CONFIG_COMEDI_PCI static int -pc263_find_pci(struct comedi_device * dev, int bus, int slot, +pc263_find_pci(struct comedi_device *dev, int bus, int slot, struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -219,7 +219,7 @@ pc263_find_pci(struct comedi_device * dev, int bus, int slot, * in the driver structure, dev->board_ptr contains that * address. */ -static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = 0; @@ -236,7 +236,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it * convenient macro defined in comedidev.h. */ #ifdef CONFIG_COMEDI_PCI - if ((ret = alloc_private(dev, sizeof(struct pc263_private))) < 0) { + ret = alloc_private(dev, sizeof(struct pc263_private)); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -252,7 +253,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it bus = it->options[0]; slot = it->options[1]; - if ((ret = pc263_find_pci(dev, bus, slot, &pci_dev)) < 0) + ret = pc263_find_pci(dev, bus, slot, &pci_dev); + if (ret < 0) return ret; devpriv->pci_dev = pci_dev; break; @@ -273,7 +275,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it /* Enable device and reserve I/O spaces. */ #ifdef CONFIG_COMEDI_PCI if (pci_dev) { - if ((ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME)) < 0) { + ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! cannot enable PCI device and request regions!\n", dev->minor); @@ -294,7 +297,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. */ - if ((ret = alloc_subdevices(dev, 1)) < 0) { + ret = alloc_subdevices(dev, 1); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -303,7 +307,7 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it s = dev->subdevices + 0; /* digital i/o subdevice */ s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_RT; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; @@ -337,7 +341,7 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pc263_detach(struct comedi_device * dev) +static int pc263_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, PC263_DRIVER_NAME); @@ -387,8 +391,8 @@ static int pc263_request_region(unsigned minor, unsigned long from, * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -412,8 +416,8 @@ static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 1) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 770b96648932..d1a64e80cddb 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -103,6 +103,8 @@ Caveats: correctly. */ +#include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_pci.h" @@ -356,23 +358,23 @@ struct pci224_board { static const struct pci224_board pci224_boards[] = { { - name: "pci224", - devid: PCI_DEVICE_ID_AMPLICON_PCI224, - model: pci224_model, - ao_chans:16, - ao_bits: 12, + .name = "pci224", + .devid = PCI_DEVICE_ID_AMPLICON_PCI224, + .model = pci224_model, + .ao_chans = 16, + .ao_bits = 12, }, { - name: "pci234", - devid: PCI_DEVICE_ID_AMPLICON_PCI234, - model: pci234_model, - ao_chans:4, - ao_bits: 16, + .name = "pci234", + .devid = PCI_DEVICE_ID_AMPLICON_PCI234, + .model = pci234_model, + .ao_chans = 4, + .ao_bits = 16, }, { - name: DRIVER_NAME, - devid: PCI_DEVICE_ID_INVALID, - model: any_model, /* wildcard */ + .name = DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .model = any_model, /* wildcard */ }, }; @@ -426,16 +428,16 @@ struct pci224_private { * the board, and also about the kernel module that contains * the device code. */ -static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci224_detach(struct comedi_device * dev); +static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci224_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pci224 = { - driver_name:DRIVER_NAME, - module:THIS_MODULE, - attach:pci224_attach, - detach:pci224_detach, - board_name:&pci224_boards[0].name, - offset:sizeof(struct pci224_board), - num_names:sizeof(pci224_boards) / sizeof(struct pci224_board), + .driver_name = DRIVER_NAME, + .module = THIS_MODULE, + .attach = pci224_attach, + .detach = pci224_detach, + .board_name = &pci224_boards[0].name, + .offset = sizeof(struct pci224_board), + .num_names = ARRAY_SIZE(pci224_boards), }; COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table); @@ -444,7 +446,7 @@ COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table); * Called from the 'insn_write' function to perform a single write. */ static void -pci224_ao_set_data(struct comedi_device * dev, int chan, int range, unsigned int data) +pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data) { unsigned short mangled; @@ -477,8 +479,8 @@ pci224_ao_set_data(struct comedi_device * dev, int chan, int range, unsigned int * 'insn_write' function for AO subdevice. */ static int -pci224_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan, range; @@ -504,8 +506,8 @@ pci224_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, * command. */ static int -pci224_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -532,7 +534,7 @@ pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2, /* * Kills a command running on the AO subdevice. */ -static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; @@ -540,7 +542,7 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice * return; } - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); /* Kill the interrupts. */ devpriv->intsce = 0; outb(0, devpriv->iobase1 + PCI224_INT_SCE); @@ -556,10 +558,10 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice * * routine. */ while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); } - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); /* Reconfigure DAC for insn_write usage. */ outw(0, dev->iobase + PCI224_DACCEN); /* Disable channels. */ devpriv->daccon = COMBINE(devpriv->daccon, @@ -572,7 +574,7 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice * /* * Handles start of acquisition for the AO subdevice. */ -static void pci224_ao_start(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; @@ -585,21 +587,21 @@ static void pci224_ao_start(struct comedi_device * dev, struct comedi_subdevice comedi_event(dev, s); } else { /* Enable interrupts. */ - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); if (cmd->stop_src == TRIG_EXT) { devpriv->intsce = PCI224_INTR_EXT | PCI224_INTR_DAC; } else { devpriv->intsce = PCI224_INTR_DAC; } outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE); - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); } } /* * Handles interrupts from the DAC FIFO. */ -static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int num_scans; @@ -653,7 +655,7 @@ static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subd /* Nothing left to put in the FIFO. */ pci224_ao_stop(dev, s); s->async->events |= COMEDI_CB_OVERFLOW; - rt_printk(KERN_ERR "comedi%d: " + printk(KERN_ERR "comedi%d: " "AO buffer underrun\n", dev->minor); } } @@ -728,7 +730,7 @@ static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subd * Internal trigger function to start acquisition on AO subdevice. */ static int -pci224_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s, +pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { if (trignum != 0) @@ -748,7 +750,7 @@ pci224_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s, * 'do_cmdtest' function for AO subdevice. */ static int -pci224_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd) +pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -1015,7 +1017,7 @@ pci224_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struc /* * 'do_cmd' function for AO subdevice. */ -static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int range; @@ -1153,16 +1155,16 @@ static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s */ switch (cmd->start_src) { case TRIG_INT: - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); s->async->inttrig = &pci224_ao_inttrig_start; - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); break; case TRIG_EXT: /* Enable external interrupt trigger to start acquisition. */ - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); devpriv->intsce |= PCI224_INTR_EXT; outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE); - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); break; } @@ -1172,7 +1174,7 @@ static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s /* * 'cancel' function for AO subdevice. */ -static int pci224_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci224_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { pci224_ao_stop(dev, s); return 0; @@ -1182,7 +1184,7 @@ static int pci224_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * 'munge' data for AO command. */ static void -pci224_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, void *data, +pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int chan_index) { struct comedi_async *async = s->async; @@ -1212,7 +1214,7 @@ pci224_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, void *d /* * Interrupt handler. */ -static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t pci224_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = &dev->subdevices[0]; @@ -1225,14 +1227,14 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG) intstat = inb(devpriv->iobase1 + PCI224_INT_SCE) & 0x3F; if (intstat) { retval = 1; - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); valid_intstat = devpriv->intsce & intstat; /* Temporarily disable interrupt sources. */ curenab = devpriv->intsce & ~intstat; outb(curenab, devpriv->iobase1 + PCI224_INT_SCE); devpriv->intr_running = 1; devpriv->intr_cpuid = THISCPU; - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); if (valid_intstat != 0) { cmd = &s->async->cmd; if (valid_intstat & PCI224_INTR_EXT) { @@ -1248,13 +1250,13 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG) } } /* Reenable interrupt sources. */ - comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags); + spin_lock_irqsave(&devpriv->ao_spinlock, flags); if (curenab != devpriv->intsce) { outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE); } devpriv->intr_running = 0; - comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); } return IRQ_RETVAL(retval); } @@ -1264,7 +1266,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG) * bus and slot. */ static int -pci224_find_pci(struct comedi_device * dev, int bus, int slot, +pci224_find_pci(struct comedi_device *dev, int bus, int slot, struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -1323,7 +1325,7 @@ pci224_find_pci(struct comedi_device * dev, int bus, int slot, * in the driver structure, dev->board_ptr contains that * address. */ -static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; struct pci_dev *pci_dev; @@ -1336,16 +1338,20 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i bus = it->options[0]; slot = it->options[1]; - if ((ret = alloc_private(dev, sizeof(struct pci224_private))) < 0) { + ret = alloc_private(dev, sizeof(struct pci224_private)); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; } - if ((ret = pci224_find_pci(dev, bus, slot, &pci_dev)) < 0) + + ret = pci224_find_pci(dev, bus, slot, &pci_dev); + if (ret < 0) return ret; - devpriv->pci_dev = pci_dev; - if ((ret = comedi_pci_enable(pci_dev, DRIVER_NAME)) < 0) { + devpriv->pci_dev = pci_dev; + ret = comedi_pci_enable(pci_dev, DRIVER_NAME); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! cannot enable PCI device " "and request regions!\n", dev->minor); @@ -1392,7 +1398,8 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase + PCI224_DACCON); /* Allocate subdevices. There is only one! */ - if ((ret = alloc_subdevices(dev, 1)) < 0) { + ret = alloc_subdevices(dev, 1); + if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", dev->minor); return ret; @@ -1471,8 +1478,8 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->board_name = thisboard->name; if (irq) { - ret = comedi_request_irq(irq, pci224_interrupt, IRQF_SHARED, - DRIVER_NAME, dev); + ret = request_irq(irq, pci224_interrupt, IRQF_SHARED, + DRIVER_NAME, dev); if (ret < 0) { printk(KERN_ERR "comedi%d: error! " "unable to allocate irq %u\n", dev->minor, irq); @@ -1503,12 +1510,12 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pci224_detach(struct comedi_device * dev) +static int pci224_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, DRIVER_NAME); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->subdevices) { struct comedi_subdevice *s; diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 0c9e5737e100..21133f068bf3 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -187,9 +187,11 @@ Extra triggered scan functionality, interrupt bug-fix added by Steve Sharples. Support for PCI230+/260+, more triggered scan functionality, and workarounds for (or detection of) various hardware problems added by Ian Abbott. */ + #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "comedi_pci.h" #include "8253.h" @@ -455,46 +457,46 @@ struct pci230_board { }; static const struct pci230_board pci230_boards[] = { { - name: "pci230+", - id: PCI_DEVICE_ID_PCI230, - ai_chans:16, - ai_bits: 16, - ao_chans:2, - ao_bits: 12, - have_dio:1, - min_hwver:1, + .name = "pci230+", + .id = PCI_DEVICE_ID_PCI230, + .ai_chans = 16, + .ai_bits = 16, + .ao_chans = 2, + .ao_bits = 12, + .have_dio = 1, + .min_hwver = 1, }, { - name: "pci260+", - id: PCI_DEVICE_ID_PCI260, - ai_chans:16, - ai_bits: 16, - ao_chans:0, - ao_bits: 0, - have_dio:0, - min_hwver:1, + .name = "pci260+", + .id = PCI_DEVICE_ID_PCI260, + .ai_chans = 16, + .ai_bits = 16, + .ao_chans = 0, + .ao_bits = 0, + .have_dio = 0, + .min_hwver = 1, }, { - name: "pci230", - id: PCI_DEVICE_ID_PCI230, - ai_chans:16, - ai_bits: 12, - ao_chans:2, - ao_bits: 12, - have_dio:1, + .name = "pci230", + .id = PCI_DEVICE_ID_PCI230, + .ai_chans = 16, + .ai_bits = 12, + .ao_chans = 2, + .ao_bits = 12, + .have_dio = 1, }, { - name: "pci260", - id: PCI_DEVICE_ID_PCI260, - ai_chans:16, - ai_bits: 12, - ao_chans:0, - ao_bits: 0, - have_dio:0, + .name = "pci260", + .id = PCI_DEVICE_ID_PCI260, + .ai_chans = 16, + .ai_bits = 12, + .ao_chans = 0, + .ao_bits = 0, + .have_dio = 0, }, { - name: "amplc_pci230", /* Wildcard matches any above */ - id: PCI_DEVICE_ID_INVALID, + .name = "amplc_pci230", /* Wildcard matches any above */ + .id = PCI_DEVICE_ID_INVALID, }, }; @@ -601,46 +603,46 @@ static const unsigned char pci230_ao_bipolar[2] = { 0, 1 }; * the board, and also about the kernel module that contains * the device code. */ -static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci230_detach(struct comedi_device * dev); +static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci230_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pci230 = { - driver_name:"amplc_pci230", - module:THIS_MODULE, - attach:pci230_attach, - detach:pci230_detach, - board_name:&pci230_boards[0].name, - offset:sizeof(pci230_boards[0]), - num_names:sizeof(pci230_boards) / sizeof(pci230_boards[0]), + .driver_name = "amplc_pci230", + .module = THIS_MODULE, + .attach = pci230_attach, + .detach = pci230_detach, + .board_name = &pci230_boards[0].name, + .offset = sizeof(pci230_boards[0]), + .num_names = ARRAY_SIZE(pci230_boards), }; COMEDI_PCI_INITCLEANUP(driver_amplc_pci230, pci230_pci_table); -static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct, +static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, unsigned int mode, uint64_t ns, unsigned int round); static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round); -static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct); -static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG); -static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int pci230_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s); -static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_subdevice * s); -static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subdevice * s); -static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int pci230_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * s); -static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice * s); - -static short pci230_ai_read(struct comedi_device * dev) +static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct); +static irqreturn_t pci230_interrupt(int irq, void *d); +static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s); +static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s); +static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s); + +static short pci230_ai_read(struct comedi_device *dev) { /* Read sample. */ short data = (short) inw(dev->iobase + PCI230_ADCDATA); @@ -658,7 +660,7 @@ static short pci230_ai_read(struct comedi_device * dev) return data; } -static inline unsigned short pci230_ao_mangle_datum(struct comedi_device * dev, +static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev, short datum) { /* If a bipolar range was specified, mangle it (straight binary->twos @@ -674,7 +676,7 @@ static inline unsigned short pci230_ao_mangle_datum(struct comedi_device * dev, return (unsigned short)datum; } -static inline void pci230_ao_write_nofifo(struct comedi_device * dev, short datum, +static inline void pci230_ao_write_nofifo(struct comedi_device *dev, short datum, unsigned int chan) { /* Store unmangled datum to be read back later. */ @@ -685,7 +687,7 @@ static inline void pci230_ao_write_nofifo(struct comedi_device * dev, short datu ? PCI230_DACOUT1 : PCI230_DACOUT2)); } -static inline void pci230_ao_write_fifo(struct comedi_device * dev, short datum, +static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum, unsigned int chan) { /* Store unmangled datum to be read back later. */ @@ -702,7 +704,7 @@ static inline void pci230_ao_write_fifo(struct comedi_device * dev, short datum, * in the driver structure, dev->board_ptr contains that * address. */ -static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase1, iobase2; @@ -874,8 +876,8 @@ static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase + PCI230_ADCCON); /* Register the interrupt handler. */ - irq_hdl = comedi_request_irq(devpriv->pci_dev->irq, pci230_interrupt, - IRQF_SHARED, "amplc_pci230", dev); + irq_hdl = request_irq(devpriv->pci_dev->irq, pci230_interrupt, + IRQF_SHARED, "amplc_pci230", dev); if (irq_hdl < 0) { printk("comedi%d: unable to register irq, " "commands will not be available %d\n", dev->minor, @@ -959,7 +961,7 @@ static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pci230_detach(struct comedi_device * dev) +static int pci230_detach(struct comedi_device *dev) { printk("comedi%d: amplc_pci230: remove\n", dev->minor); @@ -968,7 +970,7 @@ static int pci230_detach(struct comedi_device * dev) subdev_8255_cleanup(dev, dev->subdevices + 2); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv) { if (devpriv->pci_dev) { @@ -982,7 +984,7 @@ static int pci230_detach(struct comedi_device * dev) return 0; } -static int get_resources(struct comedi_device * dev, unsigned int res_mask, +static int get_resources(struct comedi_device *dev, unsigned int res_mask, unsigned char owner) { int ok; @@ -993,7 +995,7 @@ static int get_resources(struct comedi_device * dev, unsigned int res_mask, ok = 1; claimed = 0; - comedi_spin_lock_irqsave(&devpriv->res_spinlock, irqflags); + spin_lock_irqsave(&devpriv->res_spinlock, irqflags); for (b = 1, i = 0; (i < NUM_RESOURCES) && (res_mask != 0); b <<= 1, i++) { if ((res_mask & b) != 0) { @@ -1014,24 +1016,24 @@ static int get_resources(struct comedi_device * dev, unsigned int res_mask, } } } - comedi_spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); return ok; } -static inline int get_one_resource(struct comedi_device * dev, unsigned int resource, +static inline int get_one_resource(struct comedi_device *dev, unsigned int resource, unsigned char owner) { return get_resources(dev, (1U << resource), owner); } -static void put_resources(struct comedi_device * dev, unsigned int res_mask, +static void put_resources(struct comedi_device *dev, unsigned int res_mask, unsigned char owner) { unsigned int i; unsigned int b; unsigned long irqflags; - comedi_spin_lock_irqsave(&devpriv->res_spinlock, irqflags); + spin_lock_irqsave(&devpriv->res_spinlock, irqflags); for (b = 1, i = 0; (i < NUM_RESOURCES) && (res_mask != 0); b <<= 1, i++) { if ((res_mask & b) != 0) { @@ -1041,16 +1043,16 @@ static void put_resources(struct comedi_device * dev, unsigned int res_mask, } } } - comedi_spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); } -static inline void put_one_resource(struct comedi_device * dev, unsigned int resource, +static inline void put_one_resource(struct comedi_device *dev, unsigned int resource, unsigned char owner) { put_resources(dev, (1U << resource), owner); } -static inline void put_all_resources(struct comedi_device * dev, unsigned char owner) +static inline void put_all_resources(struct comedi_device *dev, unsigned char owner) { put_resources(dev, (1U << NUM_RESOURCES) - 1, owner); } @@ -1058,8 +1060,8 @@ static inline void put_all_resources(struct comedi_device * dev, unsigned char o /* * COMEDI_SUBD_AI instruction; */ -static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int n, i; unsigned int chan, range, aref; @@ -1143,12 +1145,12 @@ static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * status = inw(dev->iobase + PCI230_ADCCON); if (!(status & PCI230_ADC_FIFO_EMPTY)) break; - comedi_udelay(1); + udelay(1); } if (i == TIMEOUT) { - /* rt_printk() should be used instead of printk() + /* printk() should be used instead of printk() * whenever the code can be called from real-time. */ - rt_printk("timeout\n"); + printk("timeout\n"); return -ETIMEDOUT; } @@ -1163,8 +1165,8 @@ static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * /* * COMEDI_SUBD_AO instructions; */ -static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan, range; @@ -1191,8 +1193,8 @@ static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -1203,8 +1205,8 @@ static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * return i; } -static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -1416,20 +1418,20 @@ static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pci230_ao_inttrig_scan_begin(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int trig_num) +static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int trig_num) { unsigned long irqflags; if (trig_num != 0) return -EINVAL; - comedi_spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags); + spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags); if (test_bit(AO_CMD_STARTED, &devpriv->state)) { /* Perform scan. */ if (devpriv->hwver < 2) { /* Not using DAC FIFO. */ - comedi_spin_unlock_irqrestore(&devpriv-> + spin_unlock_irqrestore(&devpriv-> ao_stop_spinlock, irqflags); pci230_handle_ao_nofifo(dev, s); comedi_event(dev, s); @@ -1437,18 +1439,18 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device * dev, /* Using DAC FIFO. */ /* Read DACSWTRIG register to trigger conversion. */ inw(dev->iobase + PCI230P2_DACSWTRIG); - comedi_spin_unlock_irqrestore(&devpriv-> + spin_unlock_irqrestore(&devpriv-> ao_stop_spinlock, irqflags); } /* Delay. Should driver be responsible for this? */ /* XXX TODO: See if DAC busy bit can be used. */ - comedi_udelay(8); + udelay(8); } return 1; } -static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -1506,13 +1508,13 @@ static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice if (devpriv->hwver < 2) { /* Not using DAC FIFO. */ /* Enable CT1 timer interrupt. */ - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); devpriv->int_en |= PCI230_INT_ZCLK_CT1; devpriv->ier |= PCI230_INT_ZCLK_CT1; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); - comedi_spin_unlock_irqrestore(&devpriv-> + spin_unlock_irqrestore(&devpriv-> isr_spinlock, irqflags); } /* Set CT1 gate high to start counting. */ @@ -1525,18 +1527,18 @@ static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice } if (devpriv->hwver >= 2) { /* Using DAC FIFO. Enable DAC FIFO interrupt. */ - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); devpriv->int_en |= PCI230P2_INT_DAC; devpriv->ier |= PCI230P2_INT_DAC; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); } } } -static int pci230_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci230_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { if (trig_num != 0) @@ -1548,7 +1550,7 @@ static int pci230_ao_inttrig_start(struct comedi_device * dev, struct comedi_sub return 1; } -static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned short daccon; unsigned int range; @@ -1624,7 +1626,7 @@ static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int pci230_ai_check_scan_period(struct comedi_cmd * cmd) +static int pci230_ai_check_scan_period(struct comedi_cmd *cmd) { unsigned int min_scan_period, chanlist_len; int err = 0; @@ -1648,8 +1650,8 @@ static int pci230_ai_check_scan_period(struct comedi_cmd * cmd) return !err; } -static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -2034,8 +2036,8 @@ static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static void pci230_ai_update_fifo_trigger_level(struct comedi_device * dev, - struct comedi_subdevice * s) +static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int scanlen = cmd->scan_end_arg; @@ -2078,7 +2080,7 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device * dev, } } -static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci230_ai_inttrig_convert(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { unsigned long irqflags; @@ -2086,7 +2088,7 @@ static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_s if (trig_num != 0) return -EINVAL; - comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); + spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); if (test_bit(AI_CMD_STARTED, &devpriv->state)) { unsigned int delayus; @@ -2110,19 +2112,19 @@ static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_s /* single-ended or PCI230+/260+ */ delayus = 4; } - comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); - comedi_udelay(delayus); + udelay(delayus); } else { - comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); } return 1; } -static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int trig_num) +static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int trig_num) { unsigned long irqflags; unsigned char zgat; @@ -2130,7 +2132,7 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev, if (trig_num != 0) return -EINVAL; - comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); + spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); if (test_bit(AI_CMD_STARTED, &devpriv->state)) { /* Trigger scan by waggling CT0 gate source. */ zgat = GAT_CONFIG(0, GAT_GND); @@ -2138,12 +2140,12 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev, zgat = GAT_CONFIG(0, GAT_VCC); outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE); } - comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); return 1; } -static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_ai_start(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long irqflags; unsigned short conv; @@ -2158,11 +2160,11 @@ static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice comedi_event(dev, s); } else { /* Enable ADC FIFO trigger level interrupt. */ - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); devpriv->int_en |= PCI230_INT_ADC; devpriv->ier |= PCI230_INT_ADC; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); /* Update conversion trigger source which is currently set * to CT2 output, which is currently stuck high. */ @@ -2280,7 +2282,7 @@ static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice } } -static int pci230_ai_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci230_ai_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { if (trig_num != 0) @@ -2292,7 +2294,7 @@ static int pci230_ai_inttrig_start(struct comedi_device * dev, struct comedi_sub return 1; } -static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned int i, chan, range, diff; unsigned int res_mask; @@ -2424,7 +2426,7 @@ static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s * FIFO reset (above) and the second FIFO reset (below). Setting the * channel gains and scan list _before_ the first FIFO reset also * helps, though only slightly. */ - comedi_udelay(25); + udelay(25); /* Reset FIFO again. */ outw(adccon | PCI230_ADC_FIFO_RESET, dev->iobase + PCI230_ADCCON); @@ -2532,7 +2534,7 @@ static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round) return; } -static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct, +static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, unsigned int mode, uint64_t ns, unsigned int round) { unsigned int clk_src; @@ -2551,7 +2553,7 @@ static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct, i8254_write(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, count); } -static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct) +static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct) { i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, I8254_MODE1); @@ -2559,7 +2561,7 @@ static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct) } /* Interrupt handler */ -static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t pci230_interrupt(int irq, void *d) { unsigned char status_int, valid_status_int; struct comedi_device *dev = (struct comedi_device *) d; @@ -2573,7 +2575,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_NONE; } - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); valid_status_int = devpriv->int_en & status_int; /* Disable triggered interrupts. * (Only those interrupts that need re-enabling, are, later in the @@ -2582,7 +2584,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG) outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); devpriv->intr_running = 1; devpriv->intr_cpuid = THISCPU; - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); /* * Check the source of interrupt and handle it. @@ -2611,18 +2613,18 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG) } /* Reenable interrupts. */ - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); if (devpriv->ier != devpriv->int_en) { devpriv->ier = devpriv->int_en; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); } devpriv->intr_running = 0; - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); return IRQ_HANDLED; } -static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s) { short data; int i, ret; @@ -2659,7 +2661,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_su /* Loads DAC FIFO (if using it) from buffer. */ /* Returns 0 if AO finished due to completion or error, 1 if still going. */ -static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -2762,7 +2764,7 @@ static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subde return running; } -static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned int events = 0; unsigned int status_fifo; @@ -2861,16 +2863,16 @@ static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice } } -static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long irqflags; unsigned char intsrc; int started; struct comedi_cmd *cmd; - comedi_spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags); + spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags); started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state); - comedi_spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); if (!started) { return; } @@ -2891,17 +2893,17 @@ static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * } /* Disable interrupt and wait for interrupt routine to finish running * unless we are called from the interrupt routine. */ - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); devpriv->int_en &= ~intsrc; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } if (devpriv->ier != devpriv->int_en) { devpriv->ier = devpriv->int_en; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); } - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); if (devpriv->hwver >= 2) { /* Using DAC FIFO. Reset FIFO, clear underrun error, @@ -2916,21 +2918,21 @@ static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * put_all_resources(dev, OWNER_AOCMD); } -static int pci230_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { pci230_ao_stop(dev, s); return 0; } -static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long irqflags; struct comedi_cmd *cmd; int started; - comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); + spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state); - comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); if (!started) { return; } @@ -2945,19 +2947,19 @@ static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * pci230_cancel_ct(dev, 0); } - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); /* Disable ADC interrupt and wait for interrupt routine to finish * running unless we are called from the interrupt routine. */ devpriv->int_en &= ~PCI230_INT_ADC; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); - comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } if (devpriv->ier != devpriv->int_en) { devpriv->ier = devpriv->int_en; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); } - comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); /* Reset FIFO, disable FIFO and set start conversion source to none. * Keep se/diff and bip/uni settings */ @@ -2970,7 +2972,7 @@ static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * put_all_resources(dev, OWNER_AICMD); } -static int pci230_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { pci230_ai_stop(dev, s); return 0; diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index 2efffb14610d..b204793040e2 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -77,7 +77,7 @@ struct pwmbitstype { unsigned sb4:2; }; union pwmcmdtype { - unsigned cmd; // assuming here that int is 32bit + unsigned cmd; /* assuming here that int is 32bit */ struct pwmbitstype bits; }; struct encbitstype { @@ -97,20 +97,20 @@ union encvaluetype { #define C6XDIGIO_TIME_OUT 20 -static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int c6xdigio_detach(struct comedi_device * dev); +static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int c6xdigio_detach(struct comedi_device *dev); struct comedi_driver driver_c6xdigio = { - driver_name:"c6xdigio", - module:THIS_MODULE, - attach:c6xdigio_attach, - detach:c6xdigio_detach, + .driver_name = "c6xdigio", + .module = THIS_MODULE, + .attach = c6xdigio_attach, + .detach = c6xdigio_detach, }; static void C6X_pwmInit(unsigned long baseAddr) { int timeout = 0; -//printk("Inside C6X_pwmInit\n"); +/* printk("Inside C6X_pwmInit\n"); */ WriteByteToHwPort(baseAddr, 0x70); while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0) @@ -148,7 +148,7 @@ static void C6X_pwmOutput(unsigned long baseAddr, unsigned channel, int value) int timeout = 0; unsigned tmp; - //printk("Inside C6X_pwmOutput\n"); + /* printk("Inside C6X_pwmOutput\n"); */ pwm.cmd = value; if (pwm.cmd > 498) @@ -158,7 +158,7 @@ static void C6X_pwmOutput(unsigned long baseAddr, unsigned channel, int value) if (channel == 0) { ppcmd = 0x28; - } else { // if channel == 1 + } else { /* if channel == 1 */ ppcmd = 0x30; } /* endif */ @@ -216,7 +216,7 @@ static int C6X_encInput(unsigned long baseAddr, unsigned channel) int timeout = 0; int tmp; - //printk("Inside C6X_encInput\n"); + /* printk("Inside C6X_encInput\n"); */ enc.value = 0; if (channel == 0) { @@ -304,14 +304,14 @@ static int C6X_encInput(unsigned long baseAddr, unsigned channel) timeout++; } - return (enc.value ^ 0x800000); + return enc.value ^ 0x800000; } static void C6X_encResetAll(unsigned long baseAddr) { unsigned timeout = 0; -//printk("Inside C6X_encResetAll\n"); +/* printk("Inside C6X_encResetAll\n"); */ WriteByteToHwPort(baseAddr, 0x68); while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0) @@ -338,20 +338,20 @@ static void C6X_encResetAll(unsigned long baseAddr) } } -static int c6xdigio_pwmo_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int c6xdigio_pwmo_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { printk("c6xdigio_pwmo_insn_read %x\n", insn->n); return insn->n; } -static int c6xdigio_pwmo_insn_write(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int c6xdigio_pwmo_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); - // printk("c6xdigio_pwmo_insn_write %x\n", insn->n); + /* printk("c6xdigio_pwmo_insn_write %x\n", insn->n); */ for (i = 0; i < insn->n; i++) { C6X_pwmOutput(dev->iobase, chan, data[i]); /* devpriv->ao_readback[chan] = data[i]; */ @@ -359,32 +359,30 @@ static int c6xdigio_pwmo_insn_write(struct comedi_device * dev, return i; } -//static int c6xdigio_ei_init_insn_read(struct comedi_device *dev, -// struct comedi_subdevice *s, -// struct comedi_insn *insn, -// unsigned int *data) -//{ -// printk("c6xdigio_ei_init_insn_read %x\n", insn->n); -// return insn->n; -//} - -//static int c6xdigio_ei_init_insn_write(struct comedi_device *dev, -// struct comedi_subdevice *s, -// struct comedi_insn *insn, -// unsigned int *data) -//{ -// int i; -// int chan = CR_CHAN(insn->chanspec); -// -// C6X_encResetAll( dev->iobase ); -// -// return insn->n; -//} - -static int c6xdigio_ei_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +/* static int c6xdigio_ei_init_insn_read(struct comedi_device *dev, */ +/* struct comedi_subdevice *s, */ +/* struct comedi_insn *insn, */ +/* unsigned int *data) */ +/* { */ +/* printk("c6xdigio_ei_init_insn_read %x\n", insn->n); */ +/* return insn->n; */ +/* } */ + +/* static int c6xdigio_ei_init_insn_write(struct comedi_device *dev, */ +/* struct comedi_subdevice *s, */ +/* struct comedi_insn *insn, */ +/* unsigned int *data) */ +/* { */ +/* int i; */ +/* int chan = CR_CHAN(insn->chanspec); */ +/* *//* C6X_encResetAll( dev->iobase ); */ +/* *//* return insn->n; */ +/* } */ + +static int c6xdigio_ei_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - // printk("c6xdigio_ei__insn_read %x\n", insn->n); + /* printk("c6xdigio_ei__insn_read %x\n", insn->n); */ int n; int chan = CR_CHAN(insn->chanspec); @@ -395,19 +393,19 @@ static int c6xdigio_ei_insn_read(struct comedi_device * dev, return n; } -static void board_init(struct comedi_device * dev) +static void board_init(struct comedi_device *dev) { - //printk("Inside board_init\n"); + /* printk("Inside board_init\n"); */ C6X_pwmInit(dev->iobase); C6X_encResetAll(dev->iobase); } -//static void board_halt(struct comedi_device *dev) { -// C6X_pwmInit(dev->iobase); -//} +/* static void board_halt(struct comedi_device *dev) { */ +/* C6X_pwmInit(dev->iobase); */ +/* } */ /* options[0] - I/O port @@ -417,9 +415,9 @@ static void board_init(struct comedi_device * dev) static const struct pnp_device_id c6xdigio_pnp_tbl[] = { /* Standard LPT Printer Port */ - {.id = "PNP0400",.driver_data = 0}, + {.id = "PNP0400", .driver_data = 0}, /* ECP Printer Port */ - {.id = "PNP0401",.driver_data = 0}, + {.id = "PNP0401", .driver_data = 0}, {} }; @@ -428,7 +426,7 @@ static struct pnp_driver c6xdigio_pnp_driver = { .id_table = c6xdigio_pnp_tbl, }; -static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int result = 0; unsigned long iobase; @@ -444,11 +442,11 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * dev->iobase = iobase; dev->board_name = "c6xdigio"; - result = alloc_subdevices(dev, 2); // 3 with encoder_init write + result = alloc_subdevices(dev, 2); /* 3 with encoder_init write */ if (result < 0) return result; - // Make sure that PnP ports gets activated + /* Make sure that PnP ports gets activated */ pnp_register_driver(&c6xdigio_pnp_driver); irq = it->options[1]; @@ -460,14 +458,14 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * s = dev->subdevices + 0; /* pwm output subdevice */ - s->type = COMEDI_SUBD_AO; // Not sure what to put here + s->type = COMEDI_SUBD_AO; /* Not sure what to put here */ s->subdev_flags = SDF_WRITEABLE; s->n_chan = 2; /* s->trig[0] = c6xdigio_pwmo; */ s->insn_read = c6xdigio_pwmo_insn_read; s->insn_write = c6xdigio_pwmo_insn_write; s->maxdata = 500; - s->range_table = &range_bipolar10; // A suitable lie + s->range_table = &range_bipolar10; /* A suitable lie */ s = dev->subdevices + 1; /* encoder (counter) subdevice */ @@ -479,27 +477,27 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * s->maxdata = 0xffffff; s->range_table = &range_unknown; - // s = dev->subdevices + 2; - // /* pwm output subdevice */ - // s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here - // s->subdev_flags = SDF_WRITEABLE; - // s->n_chan = 1; - // /* s->trig[0] = c6xdigio_ei_init; */ - // s->insn_read = c6xdigio_ei_init_insn_read; - // s->insn_write = c6xdigio_ei_init_insn_write; - // s->maxdata = 0xFFFF; // Really just a don't care - // s->range_table = &range_unknown; // Not sure what to put here - - // I will call this init anyway but more than likely the DSP board will not be connect - // when device driver is loaded. + /* s = dev->subdevices + 2; */ + /* pwm output subdevice */ + /* s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here */ + /* s->subdev_flags = SDF_WRITEABLE; */ + /* s->n_chan = 1; */ + /* s->trig[0] = c6xdigio_ei_init; */ + /* s->insn_read = c6xdigio_ei_init_insn_read; */ + /* s->insn_write = c6xdigio_ei_init_insn_write; */ + /* s->maxdata = 0xFFFF; // Really just a don't care */ + /* s->range_table = &range_unknown; // Not sure what to put here */ + + /* I will call this init anyway but more than likely the DSP board will not be connect */ + /* when device driver is loaded. */ board_init(dev); return 0; } -static int c6xdigio_detach(struct comedi_device * dev) +static int c6xdigio_detach(struct comedi_device *dev) { -// board_halt(dev); // may not need this +/* board_halt(dev); may not need this */ printk("comedi%d: c6xdigio: remove\n", dev->minor); @@ -508,7 +506,7 @@ static int c6xdigio_detach(struct comedi_device * dev) } if (dev->irq) { free_irq(dev->irq, dev); - } // Not using IRQ so I am not sure if I need this + } /* Not using IRQ so I am not sure if I need this */ pnp_unregister_driver(&c6xdigio_pnp_driver); return 0; diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 0bfe4c954eb5..7af245b42e51 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -31,6 +31,7 @@ Status: experimental */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> #include <linux/pci.h> @@ -61,19 +62,19 @@ struct das16cs_board { }; static const struct das16cs_board das16cs_boards[] = { { - device_id:0x0000,/* unknown */ - name: "PC-CARD DAS16/16", - n_ao_chans:0, + .device_id = 0x0000,/* unknown */ + .name = "PC-CARD DAS16/16", + .n_ao_chans = 0, }, { - device_id:0x0039, - name: "PC-CARD DAS16/16-AO", - n_ao_chans:2, + .device_id = 0x0039, + .name = "PC-CARD DAS16/16-AO", + .n_ao_chans = 2, }, { - device_id:0x4009, - name: "PCM-DAS16s/16", - n_ao_chans:0, + .device_id = 0x4009, + .name = "PCM-DAS16s/16", + .n_ao_chans = 0, }, }; @@ -89,13 +90,13 @@ struct das16cs_private { }; #define devpriv ((struct das16cs_private *)dev->private) -static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das16cs_detach(struct comedi_device * dev); +static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das16cs_detach(struct comedi_device *dev); static struct comedi_driver driver_das16cs = { - driver_name:"cb_das16_cs", - module:THIS_MODULE, - attach:das16cs_attach, - detach:das16cs_detach, + .driver_name = "cb_das16_cs", + .module = THIS_MODULE, + .attach = das16cs_attach, + .detach = das16cs_detach, }; static struct pcmcia_device *cur_dev = NULL; @@ -108,26 +109,26 @@ static const struct comedi_lrange das16cs_ai_range = { 4, { } }; -static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG); -static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_timer_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16cs_timer_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); - -static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link) +static irqreturn_t das16cs_interrupt(int irq, void *d); +static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link) { tuple_t tuple; u_short buf[128]; @@ -165,7 +166,7 @@ static const struct das16cs_board *das16cs_probe(struct comedi_device * dev, return NULL; } -static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pcmcia_device *link; struct comedi_subdevice *s; @@ -187,8 +188,8 @@ static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * } printk("\n"); - ret = comedi_request_irq(link->irq.AssignedIRQ, das16cs_interrupt, - IRQF_SHARED, "cb_das16_cs", dev); + ret = request_irq(link->irq.AssignedIRQ, das16cs_interrupt, + IRQF_SHARED, "cb_das16_cs", dev); if (ret < 0) { return ret; } @@ -265,20 +266,20 @@ static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * return 1; } -static int das16cs_detach(struct comedi_device * dev) +static int das16cs_detach(struct comedi_device *dev) { printk("comedi%d: das16cs: remove\n", dev->minor); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } return 0; } -static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t das16cs_interrupt(int irq, void *d) { - //struct comedi_device *dev = d; + /* struct comedi_device *dev = d; */ return IRQ_HANDLED; } @@ -286,8 +287,8 @@ static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG) * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int to; @@ -328,13 +329,13 @@ static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice return i; } -static int das16cs_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { return -EINVAL; } -static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -489,8 +490,8 @@ static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic return 0; } -static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -503,7 +504,7 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice d = data[i]; outw(devpriv->status1, dev->iobase + 4); - comedi_udelay(1); + udelay(1); status1 = devpriv->status1 & ~0xf; if (chan) @@ -513,17 +514,17 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice /* printk("0x%04x\n",status1);*/ outw(status1, dev->iobase + 4); - comedi_udelay(1); + udelay(1); for (bit = 15; bit >= 0; bit--) { int b = (d >> bit) & 0x1; b <<= 1; /* printk("0x%04x\n",status1 | b | 0x0000);*/ outw(status1 | b | 0x0000, dev->iobase + 4); - comedi_udelay(1); + udelay(1); /* printk("0x%04x\n",status1 | b | 0x0004);*/ outw(status1 | b | 0x0004, dev->iobase + 4); - comedi_udelay(1); + udelay(1); } /* make high both DAC0CS and DAC1CS to load new data and update analog output*/ @@ -535,8 +536,8 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -552,8 +553,8 @@ static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -572,8 +573,8 @@ static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subde return 2; } -static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int bits; @@ -610,14 +611,14 @@ static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_sub return insn->n; } -static int das16cs_timer_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return -EINVAL; } -static int das16cs_timer_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return -EINVAL; } @@ -766,15 +767,22 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link) tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; + last_fn = GetFirstTuple; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret != 0) goto cs_failed; + last_fn = GetTupleData; - if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret != 0) goto cs_failed; + last_fn = ParseTuple; - if ((last_ret = pcmcia_parse_tuple(link, &tuple, &parse)) != 0) + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret != 0) goto cs_failed; + link->conf.ConfigBase = parse.config.base; link->conf.Present = parse.config.rmask[0]; @@ -792,13 +800,16 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link) */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; last_fn = GetFirstTuple; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) goto cs_failed; + while (1) { cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); if (pcmcia_get_tuple_data(link, &tuple)) goto next_entry; - if (pcmcia_parse_tuple(link, &tuple, &parse)) + if (pcmcia_parse_tuple(&tuple, &parse)) goto next_entry; if (cfg->flags & CISTPL_CFTABLE_DEFAULT) @@ -844,7 +855,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link) next_entry: last_fn = GetNextTuple; - if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) + + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) goto cs_failed; } @@ -855,7 +868,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link) */ if (link->conf.Attributes & CONF_ENABLE_IRQ) { last_fn = RequestIRQ; - if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) + + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) goto cs_failed; } /* @@ -864,7 +879,8 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link) card and host interface into "Memory and IO" mode. */ last_fn = RequestConfiguration; - if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret) goto cs_failed; /* @@ -973,4 +989,4 @@ void __exit cleanup_module(void) #else COMEDI_INITCLEANUP(driver_das16cs); -#endif //CONFIG_PCMCIA +#endif /* CONFIG_PCMCIA */ diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index fcc551651367..702de1571223 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -63,6 +63,7 @@ analog triggering on 1602 series #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "8253.h" #include "8255.h" @@ -70,14 +71,14 @@ analog triggering on 1602 series #include "comedi_pci.h" #include "comedi_fc.h" -#undef CB_PCIDAS_DEBUG // disable debugging code -//#define CB_PCIDAS_DEBUG // enable debugging code +#undef CB_PCIDAS_DEBUG /* disable debugging code */ +/* #define CB_PCIDAS_DEBUG enable debugging code */ -// PCI vendor number of ComputerBoards/MeasurementComputing +/* PCI vendor number of ComputerBoards/MeasurementComputing */ #define PCI_VENDOR_ID_CB 0x1307 -#define TIMER_BASE 100 // 10MHz master clock -#define AI_BUFFER_SIZE 1024 // maximum fifo size of any supported board -#define AO_BUFFER_SIZE 1024 // maximum fifo size of any supported board +#define TIMER_BASE 100 /* 10MHz master clock */ +#define AI_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */ +#define AO_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */ #define NUM_CHANNELS_8800 8 #define NUM_CHANNELS_7376 1 #define NUM_CHANNELS_8402 2 @@ -85,71 +86,71 @@ analog triggering on 1602 series /* PCI-DAS base addresses */ -// indices of base address regions +/* indices of base address regions */ #define S5933_BADRINDEX 0 #define CONT_STAT_BADRINDEX 1 #define ADC_FIFO_BADRINDEX 2 #define PACER_BADRINDEX 3 #define AO_BADRINDEX 4 -// sizes of io regions +/* sizes of io regions */ #define CONT_STAT_SIZE 10 #define ADC_FIFO_SIZE 4 #define PACER_SIZE 12 #define AO_SIZE 4 /* Control/Status registers */ -#define INT_ADCFIFO 0 // INTERRUPT / ADC FIFO register -#define INT_EOS 0x1 // interrupt end of scan -#define INT_FHF 0x2 // interrupt fifo half full -#define INT_FNE 0x3 // interrupt fifo not empty -#define INT_MASK 0x3 // mask of interrupt select bits -#define INTE 0x4 // interrupt enable -#define DAHFIE 0x8 // dac half full interrupt enable -#define EOAIE 0x10 // end of aquisition interrupt enable -#define DAHFI 0x20 // dac half full read status / write interrupt clear -#define EOAI 0x40 // read end of acq. interrupt status / write clear -#define INT 0x80 // read interrupt status / write clear -#define EOBI 0x200 // read end of burst interrupt status -#define ADHFI 0x400 // read half-full interrupt status -#define ADNEI 0x800 // read fifo not empty interrupt latch status -#define ADNE 0x1000 // read, fifo not empty (realtime, not latched) status -#define DAEMIE 0x1000 // write, dac empty interrupt enable -#define LADFUL 0x2000 // read fifo overflow / write clear -#define DAEMI 0x4000 // dac fifo empty interrupt status / write clear - -#define ADCMUX_CONT 2 // ADC CHANNEL MUX AND CONTROL register +#define INT_ADCFIFO 0 /* INTERRUPT / ADC FIFO register */ +#define INT_EOS 0x1 /* interrupt end of scan */ +#define INT_FHF 0x2 /* interrupt fifo half full */ +#define INT_FNE 0x3 /* interrupt fifo not empty */ +#define INT_MASK 0x3 /* mask of interrupt select bits */ +#define INTE 0x4 /* interrupt enable */ +#define DAHFIE 0x8 /* dac half full interrupt enable */ +#define EOAIE 0x10 /* end of aquisition interrupt enable */ +#define DAHFI 0x20 /* dac half full read status / write interrupt clear */ +#define EOAI 0x40 /* read end of acq. interrupt status / write clear */ +#define INT 0x80 /* read interrupt status / write clear */ +#define EOBI 0x200 /* read end of burst interrupt status */ +#define ADHFI 0x400 /* read half-full interrupt status */ +#define ADNEI 0x800 /* read fifo not empty interrupt latch status */ +#define ADNE 0x1000 /* read, fifo not empty (realtime, not latched) status */ +#define DAEMIE 0x1000 /* write, dac empty interrupt enable */ +#define LADFUL 0x2000 /* read fifo overflow / write clear */ +#define DAEMI 0x4000 /* dac fifo empty interrupt status / write clear */ + +#define ADCMUX_CONT 2 /* ADC CHANNEL MUX AND CONTROL register */ #define BEGIN_SCAN(x) ((x) & 0xf) #define END_SCAN(x) (((x) & 0xf) << 4) #define GAIN_BITS(x) (((x) & 0x3) << 8) -#define UNIP 0x800 // Analog front-end unipolar for range -#define SE 0x400 // Inputs in single-ended mode -#define PACER_MASK 0x3000 // pacer source bits -#define PACER_INT 0x1000 // internal pacer -#define PACER_EXT_FALL 0x2000 // external falling edge -#define PACER_EXT_RISE 0x3000 // external rising edge -#define EOC 0x4000 // adc not busy - -#define TRIG_CONTSTAT 4 // TRIGGER CONTROL/STATUS register -#define SW_TRIGGER 0x1 // software start trigger -#define EXT_TRIGGER 0x2 // external start trigger -#define ANALOG_TRIGGER 0x3 // external analog trigger -#define TRIGGER_MASK 0x3 // mask of bits that determine start trigger -#define TGEN 0x10 // enable external start trigger -#define BURSTE 0x20 // burst mode enable -#define XTRCL 0x80 // clear external trigger - -#define CALIBRATION_REG 6 // CALIBRATION register -#define SELECT_8800_BIT 0x100 // select 8800 caldac -#define SELECT_TRIMPOT_BIT 0x200 // select ad7376 trim pot -#define SELECT_DAC08_BIT 0x400 // select dac08 caldac +#define UNIP 0x800 /* Analog front-end unipolar for range */ +#define SE 0x400 /* Inputs in single-ended mode */ +#define PACER_MASK 0x3000 /* pacer source bits */ +#define PACER_INT 0x1000 /* internal pacer */ +#define PACER_EXT_FALL 0x2000 /* external falling edge */ +#define PACER_EXT_RISE 0x3000 /* external rising edge */ +#define EOC 0x4000 /* adc not busy */ + +#define TRIG_CONTSTAT 4 /* TRIGGER CONTROL/STATUS register */ +#define SW_TRIGGER 0x1 /* software start trigger */ +#define EXT_TRIGGER 0x2 /* external start trigger */ +#define ANALOG_TRIGGER 0x3 /* external analog trigger */ +#define TRIGGER_MASK 0x3 /* mask of bits that determine start trigger */ +#define TGEN 0x10 /* enable external start trigger */ +#define BURSTE 0x20 /* burst mode enable */ +#define XTRCL 0x80 /* clear external trigger */ + +#define CALIBRATION_REG 6 /* CALIBRATION register */ +#define SELECT_8800_BIT 0x100 /* select 8800 caldac */ +#define SELECT_TRIMPOT_BIT 0x200 /* select ad7376 trim pot */ +#define SELECT_DAC08_BIT 0x400 /* select dac08 caldac */ #define CAL_SRC_BITS(x) (((x) & 0x7) << 11) -#define CAL_EN_BIT 0x4000 // read calibration source instead of analog input channel 0 -#define SERIAL_DATA_IN_BIT 0x8000 // serial data stream going to 8800 and 7376 +#define CAL_EN_BIT 0x4000 /* read calibration source instead of analog input channel 0 */ +#define SERIAL_DATA_IN_BIT 0x8000 /* serial data stream going to 8800 and 7376 */ -#define DAC_CSR 0x8 // dac control and status register +#define DAC_CSR 0x8 /* dac control and status register */ enum dac_csr_bits { - DACEN = 0x2, // dac enable - DAC_MODE_UPDATE_BOTH = 0x80, // update both dacs when dac0 is written + DACEN = 0x2, /* dac enable */ + DAC_MODE_UPDATE_BOTH = 0x80, /* update both dacs when dac0 is written */ }; static inline unsigned int DAC_RANGE(unsigned int channel, unsigned int range) { @@ -160,42 +161,42 @@ static inline unsigned int DAC_RANGE_MASK(unsigned int channel) return 0x3 << (8 + 2 * (channel & 0x1)); }; -// bits for 1602 series only +/* bits for 1602 series only */ enum dac_csr_bits_1602 { - DAC_EMPTY = 0x1, // dac fifo empty, read, write clear - DAC_START = 0x4, // start/arm dac fifo operations - DAC_PACER_MASK = 0x18, // bits that set dac pacer source - DAC_PACER_INT = 0x8, // dac internal pacing - DAC_PACER_EXT_FALL = 0x10, // dac external pacing, falling edge - DAC_PACER_EXT_RISE = 0x18, // dac external pacing, rising edge + DAC_EMPTY = 0x1, /* dac fifo empty, read, write clear */ + DAC_START = 0x4, /* start/arm dac fifo operations */ + DAC_PACER_MASK = 0x18, /* bits that set dac pacer source */ + DAC_PACER_INT = 0x8, /* dac internal pacing */ + DAC_PACER_EXT_FALL = 0x10, /* dac external pacing, falling edge */ + DAC_PACER_EXT_RISE = 0x18, /* dac external pacing, rising edge */ }; static inline unsigned int DAC_CHAN_EN(unsigned int channel) { - return 1 << (5 + (channel & 0x1)); // enable channel 0 or 1 + return 1 << (5 + (channel & 0x1)); /* enable channel 0 or 1 */ }; /* analog input fifo */ -#define ADCDATA 0 // ADC DATA register -#define ADCFIFOCLR 2 // ADC FIFO CLEAR +#define ADCDATA 0 /* ADC DATA register */ +#define ADCFIFOCLR 2 /* ADC FIFO CLEAR */ -// pacer, counter, dio registers +/* pacer, counter, dio registers */ #define ADC8254 0 #define DIO_8255 4 #define DAC8254 8 -// analog output registers for 100x, 1200 series +/* analog output registers for 100x, 1200 series */ static inline unsigned int DAC_DATA_REG(unsigned int channel) { return 2 * (channel & 0x1); } /* analog output registers for 1602 series*/ -#define DACDATA 0 // DAC DATA register -#define DACFIFOCLR 2 // DAC FIFO CLEAR +#define DACDATA 0 /* DAC DATA register */ +#define DACFIFOCLR 2 /* DAC FIFO CLEAR */ -// bit in hexadecimal representation of range index that indicates unipolar input range +/* bit in hexadecimal representation of range index that indicates unipolar input range */ #define IS_UNIPOLAR 0x4 -// analog input ranges for most boards +/* analog input ranges for most boards */ static const struct comedi_lrange cb_pcidas_ranges = { 8, { @@ -210,7 +211,7 @@ static const struct comedi_lrange cb_pcidas_ranges = { } }; -// pci-das1001 input ranges +/* pci-das1001 input ranges */ static const struct comedi_lrange cb_pcidas_alt_ranges = { 8, { @@ -225,7 +226,7 @@ static const struct comedi_lrange cb_pcidas_alt_ranges = { } }; -// analog output ranges +/* analog output ranges */ static const struct comedi_lrange cb_pcidas_ao_ranges = { 4, { @@ -244,14 +245,14 @@ enum trimpot_model { struct cb_pcidas_board { const char *name; unsigned short device_id; - int ai_se_chans; // Inputs in single-ended mode - int ai_diff_chans; // Inputs in differential mode - int ai_bits; // analog input resolution - int ai_speed; // fastest conversion period in ns - int ao_nchan; // number of analog out channels - int has_ao_fifo; // analog output has fifo - int ao_scan_speed; // analog output speed for 1602 series (for a scan, not conversion) - int fifo_size; // number of samples fifo can hold + int ai_se_chans; /* Inputs in single-ended mode */ + int ai_diff_chans; /* Inputs in differential mode */ + int ai_bits; /* analog input resolution */ + int ai_speed; /* fastest conversion period in ns */ + int ao_nchan; /* number of analog out channels */ + int has_ao_fifo; /* analog output has fifo */ + int ao_scan_speed; /* analog output speed for 1602 series (for a scan, not conversion) */ + int fifo_size; /* number of samples fifo can hold */ const struct comedi_lrange *ranges; enum trimpot_model trimpot; unsigned has_dac08:1; @@ -259,124 +260,121 @@ struct cb_pcidas_board { static const struct cb_pcidas_board cb_pcidas_boards[] = { { - name: "pci-das1602/16", - device_id:0x1, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 16, - ai_speed:5000, - ao_nchan:2, - has_ao_fifo:1, - ao_scan_speed:10000, - fifo_size:512, - ranges: &cb_pcidas_ranges, - trimpot: AD8402, - has_dac08:1, + .name = "pci-das1602/16", + .device_id = 0x1, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .has_ao_fifo = 1, + .ao_scan_speed = 10000, + .fifo_size = 512, + .ranges = &cb_pcidas_ranges, + .trimpot = AD8402, + .has_dac08 = 1, }, { - name: "pci-das1200", - device_id:0xF, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:3200, - ao_nchan:2, - has_ao_fifo:0, - fifo_size:1024, - ranges: &cb_pcidas_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1200", + .device_id = 0xF, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 3200, + .ao_nchan = 2, + .has_ao_fifo = 0, + .fifo_size = 1024, + .ranges = &cb_pcidas_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, { - name: "pci-das1602/12", - device_id:0x10, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:3200, - ao_nchan:2, - has_ao_fifo:1, - ao_scan_speed:4000, - fifo_size:1024, - ranges: &cb_pcidas_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1602/12", + .device_id = 0x10, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 3200, + .ao_nchan = 2, + .has_ao_fifo = 1, + .ao_scan_speed = 4000, + .fifo_size = 1024, + .ranges = &cb_pcidas_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, { - name: "pci-das1200/jr", - device_id:0x19, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:3200, - ao_nchan:0, - has_ao_fifo:0, - fifo_size:1024, - ranges: &cb_pcidas_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1200/jr", + .device_id = 0x19, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 3200, + .ao_nchan = 0, + .has_ao_fifo = 0, + .fifo_size = 1024, + .ranges = &cb_pcidas_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, { - name: "pci-das1602/16/jr", - device_id:0x1C, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 16, - ai_speed:5000, - ao_nchan:0, - has_ao_fifo:0, - fifo_size:512, - ranges: &cb_pcidas_ranges, - trimpot: AD8402, - has_dac08:1, + .name = "pci-das1602/16/jr", + .device_id = 0x1C, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .has_ao_fifo = 0, + .fifo_size = 512, + .ranges = &cb_pcidas_ranges, + .trimpot = AD8402, + .has_dac08 = 1, }, { - name: "pci-das1000", - device_id:0x4C, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:4000, - ao_nchan:0, - has_ao_fifo:0, - fifo_size:1024, - ranges: &cb_pcidas_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1000", + .device_id = 0x4C, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 4000, + .ao_nchan = 0, + .has_ao_fifo = 0, + .fifo_size = 1024, + .ranges = &cb_pcidas_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, { - name: "pci-das1001", - device_id:0x1a, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:6800, - ao_nchan:2, - has_ao_fifo:0, - fifo_size:1024, - ranges: &cb_pcidas_alt_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1001", + .device_id = 0x1a, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 6800, + .ao_nchan = 2, + .has_ao_fifo = 0, + .fifo_size = 1024, + .ranges = &cb_pcidas_alt_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, { - name: "pci-das1002", - device_id:0x1b, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 12, - ai_speed:6800, - ao_nchan:2, - has_ao_fifo:0, - fifo_size:1024, - ranges: &cb_pcidas_ranges, - trimpot: AD7376, - has_dac08:0, + .name = "pci-das1002", + .device_id = 0x1b, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .ai_speed = 6800, + .ao_nchan = 2, + .has_ao_fifo = 0, + .fifo_size = 1024, + .ranges = &cb_pcidas_ranges, + .trimpot = AD7376, + .has_dac08 = 0, }, }; -// Number of boards in cb_pcidas_boards -#define N_BOARDS (sizeof(cb_pcidas_boards) / sizeof(struct cb_pcidas_board)) - static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = { {PCI_VENDOR_ID_CB, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_CB, 0x000f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -402,28 +400,28 @@ MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table); struct cb_pcidas_private { /* would be useful for a PCI device */ struct pci_dev *pci_dev; - // base addresses + /* base addresses */ unsigned long s5933_config; unsigned long control_status; unsigned long adc_fifo; unsigned long pacer_counter_dio; unsigned long ao_registers; - // divisors of master clock for analog input pacing + /* divisors of master clock for analog input pacing */ unsigned int divisor1; unsigned int divisor2; - volatile unsigned int count; // number of analog input samples remaining - volatile unsigned int adc_fifo_bits; // bits to write to interupt/adcfifo register - volatile unsigned int s5933_intcsr_bits; // bits to write to amcc s5933 interrupt control/status register - volatile unsigned int ao_control_bits; // bits to write to ao control and status register + volatile unsigned int count; /* number of analog input samples remaining */ + volatile unsigned int adc_fifo_bits; /* bits to write to interupt/adcfifo register */ + volatile unsigned int s5933_intcsr_bits; /* bits to write to amcc s5933 interrupt control/status register */ + volatile unsigned int ao_control_bits; /* bits to write to ao control and status register */ short ai_buffer[AI_BUFFER_SIZE]; short ao_buffer[AO_BUFFER_SIZE]; - // divisors of master clock for analog output pacing + /* divisors of master clock for analog output pacing */ unsigned int ao_divisor1; unsigned int ao_divisor2; - volatile unsigned int ao_count; // number of analog output samples remaining - int ao_value[2]; // remember what the analog outputs are set to, to allow readback - unsigned int caldac_value[NUM_CHANNELS_8800]; // for readback of caldac - unsigned int trimpot_value[NUM_CHANNELS_8402]; // for readback of trimpot + volatile unsigned int ao_count; /* number of analog output samples remaining */ + int ao_value[2]; /* remember what the analog outputs are set to, to allow readback */ + unsigned int caldac_value[NUM_CHANNELS_8800]; /* for readback of caldac */ + unsigned int trimpot_value[NUM_CHANNELS_8402]; /* for readback of trimpot */ unsigned int dac08_value; unsigned int calibration_source; }; @@ -440,66 +438,66 @@ struct cb_pcidas_private { * the board, and also about the kernel module that contains * the device code. */ -static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int cb_pcidas_detach(struct comedi_device * dev); +static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int cb_pcidas_detach(struct comedi_device *dev); static struct comedi_driver driver_cb_pcidas = { - driver_name:"cb_pcidas", - module:THIS_MODULE, - attach:cb_pcidas_attach, - detach:cb_pcidas_detach, + .driver_name = "cb_pcidas", + .module = THIS_MODULE, + .attach = cb_pcidas_attach, + .detach = cb_pcidas_detach, }; static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcidas_ao_nofifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcidas_ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s); + struct comedi_insn *insn, unsigned int *data); +static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcidas_ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s); static int cb_pcidas_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *subdev, unsigned int trig_num); -static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG); -static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status); -static int cb_pcidas_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static int cb_pcidas_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns, +static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static irqreturn_t cb_pcidas_interrupt(int irq, void *d); +static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status); +static int cb_pcidas_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int cb_pcidas_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns, int round_flags); -static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int caldac_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcidas_trimpot_write(struct comedi_device * dev, unsigned int channel, +static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int caldac_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int caldac_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int trimpot_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcidas_trimpot_write(struct comedi_device *dev, unsigned int channel, unsigned int value); -static int trimpot_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dac08_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dac08_write(struct comedi_device * dev, unsigned int value); -static int dac08_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int caldac_8800_write(struct comedi_device * dev, unsigned int address, +static int trimpot_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dac08_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dac08_write(struct comedi_device *dev, unsigned int value); +static int dac08_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value); -static int trimpot_7376_write(struct comedi_device * dev, uint8_t value); -static int trimpot_8402_write(struct comedi_device * dev, unsigned int channel, +static int trimpot_7376_write(struct comedi_device *dev, uint8_t value); +static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel, uint8_t value); -static int nvram_read(struct comedi_device * dev, unsigned int address, - uint8_t * data); +static int nvram_read(struct comedi_device *dev, unsigned int address, + uint8_t *data); -static inline unsigned int cal_enable_bits(struct comedi_device * dev) +static inline unsigned int cal_enable_bits(struct comedi_device *dev) { return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source); } @@ -508,7 +506,7 @@ static inline unsigned int cal_enable_bits(struct comedi_device * dev) * Attach is called by the Comedi core to configure the driver * for a particular board. */ -static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; struct pci_dev *pcidev; @@ -531,16 +529,16 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - // is it not a computer boards card? + /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_CB) continue; - // loop through cards supported by this driver - for (index = 0; index < N_BOARDS; index++) { + /* loop through cards supported by this driver */ + for (index = 0; index < ARRAY_SIZE(cb_pcidas_boards); index++) { if (cb_pcidas_boards[index].device_id != pcidev->device) continue; - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { @@ -585,19 +583,19 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig devpriv->ao_registers = pci_resource_start(devpriv->pci_dev, AO_BADRINDEX); } - // disable and clear interrupts on amcc s5933 + /* disable and clear interrupts on amcc s5933 */ outl(INTCSR_INBOX_INTR_STATUS, devpriv->s5933_config + AMCC_OP_REG_INTCSR); - // get irq - if (comedi_request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt, + /* get irq */ + if (request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt, IRQF_SHARED, "cb_pcidas", dev)) { printk(" unable to allocate irq %d\n", devpriv->pci_dev->irq); return -EINVAL; } dev->irq = devpriv->pci_dev->irq; - //Initialize dev->board_name + /* Initialize dev->board_name */ dev->board_name = thisboard->name; /* @@ -628,7 +626,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; s->n_chan = thisboard->ao_nchan; - // analog out resolution is the same as analog input resolution, so use ai_bits + /* analog out resolution is the same as analog input resolution, so use ai_bits */ s->maxdata = (1 << thisboard->ai_bits) - 1; s->range_table = &cb_pcidas_ao_ranges; s->insn_read = cb_pcidas_ao_readback_insn; @@ -650,7 +648,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig s = dev->subdevices + 2; subdev_8255_init(dev, s, NULL, devpriv->pacer_counter_dio + DIO_8255); - // serial EEPROM, + /* serial EEPROM, */ s = dev->subdevices + 3; s->type = COMEDI_SUBD_MEMORY; s->subdev_flags = SDF_READABLE | SDF_INTERNAL; @@ -658,7 +656,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig s->maxdata = 0xff; s->insn_read = eeprom_read_insn; - // 8800 caldac + /* 8800 caldac */ s = dev->subdevices + 4; s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; @@ -669,7 +667,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig for (i = 0; i < s->n_chan; i++) caldac_8800_write(dev, i, s->maxdata / 2); - // trim potentiometer + /* trim potentiometer */ s = dev->subdevices + 5; s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; @@ -685,7 +683,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig for (i = 0; i < s->n_chan; i++) cb_pcidas_trimpot_write(dev, i, s->maxdata / 2); - // dac08 caldac + /* dac08 caldac */ s = dev->subdevices + 6; if (thisboard->has_dac08) { s->type = COMEDI_SUBD_CALIB; @@ -698,13 +696,13 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig } else s->type = COMEDI_SUBD_UNUSED; - // make sure mailbox 4 is empty + /* make sure mailbox 4 is empty */ inl(devpriv->s5933_config + AMCC_OP_REG_IMB4); /* Set bits to enable incoming mailbox interrupts on amcc s5933. */ devpriv->s5933_intcsr_bits = INTCSR_INBOX_BYTE(3) | INTCSR_INBOX_SELECT(3) | INTCSR_INBOX_FULL_INT; - // clear and enable interrupt on amcc s5933 + /* clear and enable interrupt on amcc s5933 */ outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS, devpriv->s5933_config + AMCC_OP_REG_INTCSR); @@ -719,24 +717,24 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int cb_pcidas_detach(struct comedi_device * dev) +static int cb_pcidas_detach(struct comedi_device *dev) { printk("comedi%d: cb_pcidas: remove\n", dev->minor); if (devpriv) { if (devpriv->s5933_config) { - // disable and clear interrupts on amcc s5933 + /* disable and clear interrupts on amcc s5933 */ outl(INTCSR_INBOX_INTR_STATUS, devpriv->s5933_config + AMCC_OP_REG_INTCSR); #ifdef CB_PCIDAS_DEBUG - rt_printk("detaching, incsr is 0x%x\n", + printk("detaching, incsr is 0x%x\n", inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR)); #endif } } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 2); if (devpriv && devpriv->pci_dev) { @@ -753,14 +751,14 @@ static int cb_pcidas_detach(struct comedi_device * dev) * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; unsigned int bits; static const int timeout = 10000; int channel; - // enable calibration input if appropriate + /* enable calibration input if appropriate */ if (insn->chanspec & CR_ALT_SOURCE) { outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG); @@ -769,13 +767,13 @@ static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevic outw(0, devpriv->control_status + CALIBRATION_REG); channel = CR_CHAN(insn->chanspec); } - // set mux limits and gain + /* set mux limits and gain */ bits = BEGIN_SCAN(channel) | END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec)); - // set unipolar/bipolar + /* set unipolar/bipolar */ if (CR_RANGE(insn->chanspec) & IS_UNIPOLAR) bits |= UNIP; - // set singleended/differential + /* set singleended/differential */ if (CR_AREF(insn->chanspec) != AREF_DIFF) bits |= SE; outw(bits, devpriv->control_status + ADCMUX_CONT); @@ -805,7 +803,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevic return n; } -static int ai_config_calibration_source(struct comedi_device * dev, unsigned int * data) +static int ai_config_calibration_source(struct comedi_device *dev, unsigned int *data) { static const int num_calibration_sources = 8; unsigned int source = data[1]; @@ -820,8 +818,8 @@ static int ai_config_calibration_source(struct comedi_device * dev, unsigned int return 2; } -static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int id = data[0]; @@ -836,44 +834,44 @@ static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * return -EINVAL; } -// analog output insn for pcidas-1000 and 1200 series -static int cb_pcidas_ao_nofifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* analog output insn for pcidas-1000 and 1200 series */ +static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel; unsigned long flags; - // set channel and range + /* set channel and range */ channel = CR_CHAN(insn->chanspec); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->ao_control_bits &= ~DAC_MODE_UPDATE_BOTH & ~DAC_RANGE_MASK(channel); devpriv->ao_control_bits |= DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec)); outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // remember value for readback + /* remember value for readback */ devpriv->ao_value[channel] = data[0]; - // send data + /* send data */ outw(data[0], devpriv->ao_registers + DAC_DATA_REG(channel)); return 1; } -// analog output insn for pcidas-1602 series -static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* analog output insn for pcidas-1602 series */ +static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel; unsigned long flags; - // clear dac fifo + /* clear dac fifo */ outw(0, devpriv->ao_registers + DACFIFOCLR); - // set channel and range + /* set channel and range */ channel = CR_CHAN(insn->chanspec); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->ao_control_bits &= ~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) & ~DAC_RANGE_MASK(channel) & ~DAC_PACER_MASK; @@ -881,28 +879,28 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_sub DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec)) | DAC_CHAN_EN(channel) | DAC_START; outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // remember value for readback + /* remember value for readback */ devpriv->ao_value[channel] = data[0]; - // send data + /* send data */ outw(data[0], devpriv->ao_registers + DACDATA); return 1; } -// analog output readback insn -// XXX loses track of analog output value back after an analog ouput command is executed -static int cb_pcidas_ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* analog output readback insn */ +/* XXX loses track of analog output value back after an analog ouput command is executed */ +static int cb_pcidas_ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; return 1; } -static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { uint8_t nvram_data; int retval; @@ -916,16 +914,16 @@ static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int caldac_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int caldac_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const unsigned int channel = CR_CHAN(insn->chanspec); return caldac_8800_write(dev, channel, data[0]); } -static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int caldac_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)]; @@ -933,7 +931,7 @@ static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice } /* 1602/16 pregain offset */ -static int dac08_write(struct comedi_device * dev, unsigned int value) +static int dac08_write(struct comedi_device *dev, unsigned int value) { if (devpriv->dac08_value == value) return 1; @@ -942,32 +940,32 @@ static int dac08_write(struct comedi_device * dev, unsigned int value) outw(cal_enable_bits(dev) | (value & 0xff), devpriv->control_status + CALIBRATION_REG); - comedi_udelay(1); + udelay(1); outw(cal_enable_bits(dev) | SELECT_DAC08_BIT | (value & 0xff), devpriv->control_status + CALIBRATION_REG); - comedi_udelay(1); + udelay(1); outw(cal_enable_bits(dev) | (value & 0xff), devpriv->control_status + CALIBRATION_REG); - comedi_udelay(1); + udelay(1); return 1; } -static int dac08_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dac08_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return dac08_write(dev, data[0]); } -static int dac08_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dac08_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->dac08_value; return 1; } -static int cb_pcidas_trimpot_write(struct comedi_device * dev, +static int cb_pcidas_trimpot_write(struct comedi_device *dev, unsigned int channel, unsigned int value) { if (devpriv->trimpot_value[channel] == value) @@ -990,16 +988,16 @@ static int cb_pcidas_trimpot_write(struct comedi_device * dev, return 1; } -static int trimpot_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int trimpot_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int channel = CR_CHAN(insn->chanspec); return cb_pcidas_trimpot_write(dev, channel, data[0]); } -static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int trimpot_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int channel = CR_CHAN(insn->chanspec); @@ -1008,8 +1006,8 @@ static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -1066,7 +1064,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) err++; - // make sure trigger sources are compatible with each other + /* make sure trigger sources are compatible with each other */ if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW) err++; if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW) @@ -1138,7 +1136,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev if (err) return 4; - // check channel/gain list against card's limitations + /* check channel/gain list against card's limitations */ if (cmd->chanlist) { gain = CR_RANGE(cmd->chanlist[0]); start_chan = CR_CHAN(cmd->chanlist[0]); @@ -1163,31 +1161,31 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev return 0; } -static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int bits; unsigned long flags; - // make sure CAL_EN_BIT is disabled + /* make sure CAL_EN_BIT is disabled */ outw(0, devpriv->control_status + CALIBRATION_REG); - // initialize before settings pacer source and count values + /* initialize before settings pacer source and count values */ outw(0, devpriv->control_status + TRIG_CONTSTAT); - // clear fifo + /* clear fifo */ outw(0, devpriv->adc_fifo + ADCFIFOCLR); - // set mux limits, gain and pacer source + /* set mux limits, gain and pacer source */ bits = BEGIN_SCAN(CR_CHAN(cmd->chanlist[0])) | END_SCAN(CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1])) | GAIN_BITS(CR_RANGE(cmd->chanlist[0])); - // set unipolar/bipolar + /* set unipolar/bipolar */ if (CR_RANGE(cmd->chanlist[0]) & IS_UNIPOLAR) bits |= UNIP; - // set singleended/differential + /* set singleended/differential */ if (CR_AREF(cmd->chanlist[0]) != AREF_DIFF) bits |= SE; - // set pacer source + /* set pacer source */ if (cmd->convert_src == TRIG_EXT || cmd->scan_begin_src == TRIG_EXT) bits |= PACER_EXT_RISE; else @@ -1195,10 +1193,10 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice outw(bits, devpriv->control_status + ADCMUX_CONT); #ifdef CB_PCIDAS_DEBUG - rt_printk("comedi: sent 0x%x to adcmux control\n", bits); + printk("comedi: sent 0x%x to adcmux control\n", bits); #endif - // load counters + /* load counters */ if (cmd->convert_src == TRIG_TIMER) cb_pcidas_load_counters(dev, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); @@ -1206,31 +1204,31 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice cb_pcidas_load_counters(dev, &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); - // set number of conversions + /* set number of conversions */ if (cmd->stop_src == TRIG_COUNT) { devpriv->count = cmd->chanlist_len * cmd->stop_arg; } - // enable interrupts - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* enable interrupts */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->adc_fifo_bits |= INTE; devpriv->adc_fifo_bits &= ~INT_MASK; if (cmd->flags & TRIG_WAKE_EOS) { if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1) - devpriv->adc_fifo_bits |= INT_EOS; // interrupt end of burst + devpriv->adc_fifo_bits |= INT_EOS; /* interrupt end of burst */ else - devpriv->adc_fifo_bits |= INT_FNE; // interrupt fifo not empty + devpriv->adc_fifo_bits |= INT_FNE; /* interrupt fifo not empty */ } else { - devpriv->adc_fifo_bits |= INT_FHF; //interrupt fifo half full + devpriv->adc_fifo_bits |= INT_FHF; /* interrupt fifo half full */ } #ifdef CB_PCIDAS_DEBUG - rt_printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits); + printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits); #endif - // enable (and clear) interrupts + /* enable (and clear) interrupts */ outw(devpriv->adc_fifo_bits | EOAI | INT | LADFUL, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // set start trigger and burst mode + /* set start trigger and burst mode */ bits = 0; if (cmd->start_src == TRIG_NOW) bits |= SW_TRIGGER; @@ -1244,14 +1242,14 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice bits |= BURSTE; outw(bits, devpriv->control_status + TRIG_CONTSTAT); #ifdef CB_PCIDAS_DEBUG - rt_printk("comedi: sent 0x%x to trig control\n", bits); + printk("comedi: sent 0x%x to trig control\n", bits); #endif return 0; } -static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -1347,7 +1345,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdev if (err) return 4; - // check channel/gain list against card's limitations + /* check channel/gain list against card's limitations */ if (cmd->chanlist && cmd->chanlist_len > 1) { if (CR_CHAN(cmd->chanlist[0]) != 0 || CR_CHAN(cmd->chanlist[1]) != 1) { @@ -1363,32 +1361,32 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdev return 0; } -static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int i; unsigned long flags; - // set channel limits, gain - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* set channel limits, gain */ + spin_lock_irqsave(&dev->spinlock, flags); for (i = 0; i < cmd->chanlist_len; i++) { - // enable channel + /* enable channel */ devpriv->ao_control_bits |= DAC_CHAN_EN(CR_CHAN(cmd->chanlist[i])); - // set range + /* set range */ devpriv->ao_control_bits |= DAC_RANGE(CR_CHAN(cmd->chanlist[i]), CR_RANGE(cmd->chanlist[i])); } - // disable analog out before settings pacer source and count values + /* disable analog out before settings pacer source and count values */ outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // clear fifo + /* clear fifo */ outw(0, devpriv->ao_registers + DACFIFOCLR); - // load counters + /* load counters */ if (cmd->scan_begin_src == TRIG_TIMER) { i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->ao_divisor1), &(devpriv->ao_divisor2), @@ -1400,12 +1398,12 @@ static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 2, devpriv->ao_divisor2, 2); } - // set number of conversions + /* set number of conversions */ if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_count = cmd->chanlist_len * cmd->stop_arg; } - // set pacer source - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* set pacer source */ + spin_lock_irqsave(&dev->spinlock, flags); switch (cmd->scan_begin_src) { case TRIG_TIMER: devpriv->ao_control_bits |= DAC_PACER_INT; @@ -1414,12 +1412,12 @@ static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice devpriv->ao_control_bits |= DAC_PACER_EXT_RISE; break; default: - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); comedi_error(dev, "error setting dac pacer source"); return -1; break; } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); async->inttrig = cb_pcidas_ao_inttrig; @@ -1438,7 +1436,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev, if (trig_num != 0) return -EINVAL; - // load up fifo + /* load up fifo */ if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points) num_points = devpriv->ao_count; @@ -1449,34 +1447,34 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev, if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_count -= num_points; } - // write data to board's fifo + /* write data to board's fifo */ outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes); - // enable dac half-full and empty interrupts - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* enable dac half-full and empty interrupts */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->adc_fifo_bits |= DAEMIE | DAHFIE; #ifdef CB_PCIDAS_DEBUG - rt_printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits); + printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits); #endif - // enable and clear interrupts + /* enable and clear interrupts */ outw(devpriv->adc_fifo_bits | DAEMI | DAHFI, devpriv->control_status + INT_ADCFIFO); - // start dac + /* start dac */ devpriv->ao_control_bits |= DAC_START | DACEN | DAC_EMPTY; outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR); #ifdef CB_PCIDAS_DEBUG - rt_printk("comedi: sent 0x%x to dac control\n", + printk("comedi: sent 0x%x to dac control\n", devpriv->ao_control_bits); #endif - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); async->inttrig = NULL; return 0; } -static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t cb_pcidas_interrupt(int irq, void *d) { struct comedi_device *dev = (struct comedi_device *) d; struct comedi_subdevice *s = dev->read_subdev; @@ -1496,16 +1494,16 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) s5933_status = inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR); #ifdef CB_PCIDAS_DEBUG - rt_printk("intcsr 0x%x\n", s5933_status); - rt_printk("mbef 0x%x\n", inl(devpriv->s5933_config + AMCC_OP_REG_MBEF)); + printk("intcsr 0x%x\n", s5933_status); + printk("mbef 0x%x\n", inl(devpriv->s5933_config + AMCC_OP_REG_MBEF)); #endif if ((INTCSR_INTR_ASSERTED & s5933_status) == 0) return IRQ_NONE; - // make sure mailbox 4 is empty + /* make sure mailbox 4 is empty */ inl_p(devpriv->s5933_config + AMCC_OP_REG_IMB4); - // clear interrupt on amcc s5933 + /* clear interrupt on amcc s5933 */ outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS, devpriv->s5933_config + AMCC_OP_REG_INTCSR); @@ -1516,14 +1514,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) } #endif - // check for analog output interrupt + /* check for analog output interrupt */ if (status & (DAHFI | DAEMI)) { handle_ao_interrupt(dev, status); } - // check for analog input interrupts - // if fifo half-full + /* check for analog input interrupts */ + /* if fifo half-full */ if (status & ADHFI) { - // read data + /* read data */ num_samples = half_fifo; if (async->cmd.stop_src == TRIG_COUNT && num_samples > devpriv->count) { @@ -1538,15 +1536,15 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) async->events |= COMEDI_CB_EOA; cb_pcidas_cancel(dev, s); } - // clear half-full interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear half-full interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); - // else if fifo not empty + spin_unlock_irqrestore(&dev->spinlock, flags); + /* else if fifo not empty */ } else if (status & (ADNEI | EOBI)) { for (i = 0; i < timeout; i++) { - // break if fifo is empty + /* break if fifo is empty */ if ((ADNE & inw(devpriv->control_status + INT_ADCFIFO)) == 0) break; @@ -1557,28 +1555,28 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) break; } } - // clear not-empty interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear not-empty interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } else if (status & EOAI) { comedi_error(dev, "bug! encountered end of aquisition interrupt?"); - // clear EOA interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear EOA interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | EOAI, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } - //check for fifo overflow + /* check for fifo overflow */ if (status & LADFUL) { comedi_error(dev, "fifo overflow"); - // clear overflow interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear overflow interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | LADFUL, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); cb_pcidas_cancel(dev, s); async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; } @@ -1588,23 +1586,23 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status) +static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) { struct comedi_subdevice *s = dev->write_subdev; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int half_fifo = thisboard->fifo_size / 2; unsigned int num_points; - unsigned int flags; + unsigned long flags; async->events = 0; if (status & DAEMI) { - // clear dac empty interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear dac empty interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | DAEMI, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); if (inw(devpriv->ao_registers + DAC_CSR) & DAC_EMPTY) { if (cmd->stop_src == TRIG_NONE || (cmd->stop_src == TRIG_COUNT @@ -1618,7 +1616,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status) } else if (status & DAHFI) { unsigned int num_bytes; - // figure out how many points we are writing to fifo + /* figure out how many points we are writing to fifo */ num_points = half_fifo; if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points) @@ -1631,33 +1629,33 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status) if (async->cmd.stop_src == TRIG_COUNT) { devpriv->ao_count -= num_points; } - // write data to board's fifo + /* write data to board's fifo */ outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_points); - // clear half-full interrupt latch - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* clear half-full interrupt latch */ + spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | DAHFI, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } comedi_event(dev, s); } /* cancel analog input command */ -static int cb_pcidas_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int cb_pcidas_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); - // disable interrupts + spin_lock_irqsave(&dev->spinlock, flags); + /* disable interrupts */ devpriv->adc_fifo_bits &= ~INTE & ~EOAIE; outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // disable start trigger source and burst mode + /* disable start trigger source and burst mode */ outw(0, devpriv->control_status + TRIG_CONTSTAT); - // software pacer source + /* software pacer source */ outw(0, devpriv->control_status + ADCMUX_CONT); return 0; @@ -1669,20 +1667,20 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev, { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); - // disable interrupts + spin_lock_irqsave(&dev->spinlock, flags); + /* disable interrupts */ devpriv->adc_fifo_bits &= ~DAHFIE & ~DAEMIE; outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO); - // disable output + /* disable output */ devpriv->ao_control_bits &= ~DACEN & ~DAC_PACER_MASK; outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } -static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns, +static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns, int rounding_flags) { i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1), @@ -1695,7 +1693,7 @@ static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns devpriv->divisor2, 2); } -static void write_calibration_bitstream(struct comedi_device * dev, +static void write_calibration_bitstream(struct comedi_device *dev, unsigned int register_bits, unsigned int bitstream, unsigned int bitstream_length) { @@ -1707,18 +1705,18 @@ static void write_calibration_bitstream(struct comedi_device * dev, register_bits |= SERIAL_DATA_IN_BIT; else register_bits &= ~SERIAL_DATA_IN_BIT; - comedi_udelay(write_delay); + udelay(write_delay); outw(register_bits, devpriv->control_status + CALIBRATION_REG); } } -static int caldac_8800_write(struct comedi_device * dev, unsigned int address, +static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value) { static const int num_caldac_channels = 8; static const int bitstream_length = 11; unsigned int bitstream = ((address & 0x7) << 8) | value; - static const int caldac_8800_comedi_udelay = 1; + static const int caldac_8800_udelay = 1; if (address >= num_caldac_channels) { comedi_error(dev, "illegal caldac channel"); @@ -1733,30 +1731,30 @@ static int caldac_8800_write(struct comedi_device * dev, unsigned int address, write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream, bitstream_length); - comedi_udelay(caldac_8800_comedi_udelay); + udelay(caldac_8800_udelay); outw(cal_enable_bits(dev) | SELECT_8800_BIT, devpriv->control_status + CALIBRATION_REG); - comedi_udelay(caldac_8800_comedi_udelay); + udelay(caldac_8800_udelay); outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG); return 1; } -static int trimpot_7376_write(struct comedi_device * dev, uint8_t value) +static int trimpot_7376_write(struct comedi_device *dev, uint8_t value) { static const int bitstream_length = 7; unsigned int bitstream = value & 0x7f; unsigned int register_bits; - static const int ad7376_comedi_udelay = 1; + static const int ad7376_udelay = 1; register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT; - comedi_udelay(ad7376_comedi_udelay); + udelay(ad7376_udelay); outw(register_bits, devpriv->control_status + CALIBRATION_REG); write_calibration_bitstream(dev, register_bits, bitstream, bitstream_length); - comedi_udelay(ad7376_comedi_udelay); + udelay(ad7376_udelay); outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG); return 0; @@ -1765,22 +1763,22 @@ static int trimpot_7376_write(struct comedi_device * dev, uint8_t value) /* For 1602/16 only * ch 0 : adc gain * ch 1 : adc postgain offset */ -static int trimpot_8402_write(struct comedi_device * dev, unsigned int channel, +static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel, uint8_t value) { static const int bitstream_length = 10; unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff); unsigned int register_bits; - static const int ad8402_comedi_udelay = 1; + static const int ad8402_udelay = 1; register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT; - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); outw(register_bits, devpriv->control_status + CALIBRATION_REG); write_calibration_bitstream(dev, register_bits, bitstream, bitstream_length); - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG); return 0; @@ -1796,12 +1794,12 @@ static int wait_for_nvram_ready(unsigned long s5933_base_addr) AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY) == 0) return 0; - comedi_udelay(1); + udelay(1); } return -1; } -static int nvram_read(struct comedi_device * dev, unsigned int address, uint8_t * data) +static int nvram_read(struct comedi_device *dev, unsigned int address, uint8_t *data) { unsigned long iobase = devpriv->s5933_config; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 1a580bd2247a..210b462868b7 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -85,6 +85,7 @@ TODO: #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include <asm/system.h> #include "comedi_pci.h" @@ -93,17 +94,17 @@ TODO: #include "plx9080.h" #include "comedi_fc.h" -#undef PCIDAS64_DEBUG // disable debugging code -//#define PCIDAS64_DEBUG // enable debugging code +#undef PCIDAS64_DEBUG /* disable debugging code */ +/* #define PCIDAS64_DEBUG enable debugging code */ #ifdef PCIDAS64_DEBUG -#define DEBUG_PRINT(format, args...) rt_printk(format , ## args ) +#define DEBUG_PRINT(format, args...) printk(format , ## args) #else #define DEBUG_PRINT(format, args...) #endif -#define TIMER_BASE 25 // 40MHz master clock -#define PRESCALED_TIMER_BASE 10000 // 100kHz 'prescaled' clock for slow aquisition, maybe I'll support this someday +#define TIMER_BASE 25 /* 40MHz master clock */ +#define PRESCALED_TIMER_BASE 10000 /* 100kHz 'prescaled' clock for slow aquisition, maybe I'll support this someday */ #define DMA_BUFFER_SIZE 0x1000 /* maximum value that can be loaded into board's 24-bit counters*/ @@ -111,41 +112,41 @@ static const int max_counter_value = 0xffffff; /* PCI-DAS64xxx base addresses */ -// indices of base address regions +/* indices of base address regions */ enum base_address_regions { PLX9080_BADDRINDEX = 0, MAIN_BADDRINDEX = 2, DIO_COUNTER_BADDRINDEX = 3, }; -// priv(dev)->main_iobase registers +/* priv(dev)->main_iobase registers */ enum write_only_registers { - INTR_ENABLE_REG = 0x0, // interrupt enable register - HW_CONFIG_REG = 0x2, // hardware config register + INTR_ENABLE_REG = 0x0, /* interrupt enable register */ + HW_CONFIG_REG = 0x2, /* hardware config register */ DAQ_SYNC_REG = 0xc, DAQ_ATRIG_LOW_4020_REG = 0xc, - ADC_CONTROL0_REG = 0x10, // adc control register 0 - ADC_CONTROL1_REG = 0x12, // adc control register 1 + ADC_CONTROL0_REG = 0x10, /* adc control register 0 */ + ADC_CONTROL1_REG = 0x12, /* adc control register 1 */ CALIBRATION_REG = 0x14, - ADC_SAMPLE_INTERVAL_LOWER_REG = 0x16, // lower 16 bits of adc sample interval counter - ADC_SAMPLE_INTERVAL_UPPER_REG = 0x18, // upper 8 bits of adc sample interval counter - ADC_DELAY_INTERVAL_LOWER_REG = 0x1a, // lower 16 bits of delay interval counter - ADC_DELAY_INTERVAL_UPPER_REG = 0x1c, // upper 8 bits of delay interval counter - ADC_COUNT_LOWER_REG = 0x1e, // lower 16 bits of hardware conversion/scan counter - ADC_COUNT_UPPER_REG = 0x20, // upper 8 bits of hardware conversion/scan counter - ADC_START_REG = 0x22, // software trigger to start aquisition - ADC_CONVERT_REG = 0x24, // initiates single conversion - ADC_QUEUE_CLEAR_REG = 0x26, // clears adc queue - ADC_QUEUE_LOAD_REG = 0x28, // loads adc queue + ADC_SAMPLE_INTERVAL_LOWER_REG = 0x16, /* lower 16 bits of adc sample interval counter */ + ADC_SAMPLE_INTERVAL_UPPER_REG = 0x18, /* upper 8 bits of adc sample interval counter */ + ADC_DELAY_INTERVAL_LOWER_REG = 0x1a, /* lower 16 bits of delay interval counter */ + ADC_DELAY_INTERVAL_UPPER_REG = 0x1c, /* upper 8 bits of delay interval counter */ + ADC_COUNT_LOWER_REG = 0x1e, /* lower 16 bits of hardware conversion/scan counter */ + ADC_COUNT_UPPER_REG = 0x20, /* upper 8 bits of hardware conversion/scan counter */ + ADC_START_REG = 0x22, /* software trigger to start aquisition */ + ADC_CONVERT_REG = 0x24, /* initiates single conversion */ + ADC_QUEUE_CLEAR_REG = 0x26, /* clears adc queue */ + ADC_QUEUE_LOAD_REG = 0x28, /* loads adc queue */ ADC_BUFFER_CLEAR_REG = 0x2a, - ADC_QUEUE_HIGH_REG = 0x2c, // high channel for internal queue, use adc_chan_bits() inline above - DAC_CONTROL0_REG = 0x50, // dac control register 0 - DAC_CONTROL1_REG = 0x52, // dac control register 0 - DAC_SAMPLE_INTERVAL_LOWER_REG = 0x54, // lower 16 bits of dac sample interval counter - DAC_SAMPLE_INTERVAL_UPPER_REG = 0x56, // upper 8 bits of dac sample interval counter + ADC_QUEUE_HIGH_REG = 0x2c, /* high channel for internal queue, use adc_chan_bits() inline above */ + DAC_CONTROL0_REG = 0x50, /* dac control register 0 */ + DAC_CONTROL1_REG = 0x52, /* dac control register 0 */ + DAC_SAMPLE_INTERVAL_LOWER_REG = 0x54, /* lower 16 bits of dac sample interval counter */ + DAC_SAMPLE_INTERVAL_UPPER_REG = 0x56, /* upper 8 bits of dac sample interval counter */ DAC_SELECT_REG = 0x60, DAC_START_REG = 0x64, - DAC_BUFFER_CLEAR_REG = 0x66, // clear dac buffer + DAC_BUFFER_CLEAR_REG = 0x66, /* clear dac buffer */ }; static inline unsigned int dac_convert_reg(unsigned int channel) { @@ -161,7 +162,7 @@ static inline unsigned int dac_msb_4020_reg(unsigned int channel) } enum read_only_registers { - HW_STATUS_REG = 0x0, // hardware status register, reading this apparently clears pending interrupts as well + HW_STATUS_REG = 0x0, /* hardware status register, reading this apparently clears pending interrupts as well */ PIPE1_READ_REG = 0x4, ADC_READ_PNTR_REG = 0x8, LOWER_XFER_REG = 0x10, @@ -170,13 +171,13 @@ enum read_only_registers { }; enum read_write_registers { - I8255_4020_REG = 0x48, // 8255 offset, for 4020 only - ADC_QUEUE_FIFO_REG = 0x100, // external channel/gain queue, uses same bits as ADC_QUEUE_LOAD_REG + I8255_4020_REG = 0x48, /* 8255 offset, for 4020 only */ + ADC_QUEUE_FIFO_REG = 0x100, /* external channel/gain queue, uses same bits as ADC_QUEUE_LOAD_REG */ ADC_FIFO_REG = 0x200, /* adc data fifo */ DAC_FIFO_REG = 0x300, /* dac data fifo, has weird interactions with external channel queue */ }; -// priv(dev)->dio_counter_iobase registers +/* priv(dev)->dio_counter_iobase registers */ enum dio_counter_registers { DIO_8255_OFFSET = 0x0, DO_REG = 0x20, @@ -185,47 +186,47 @@ enum dio_counter_registers { DIO_DATA_60XX_REG = 0x48, }; -// bit definitions for write-only registers +/* bit definitions for write-only registers */ enum intr_enable_contents { - ADC_INTR_SRC_MASK = 0x3, // bits that set adc interrupt source - ADC_INTR_QFULL_BITS = 0x0, // interrupt fifo quater full - ADC_INTR_EOC_BITS = 0x1, // interrupt end of conversion - ADC_INTR_EOSCAN_BITS = 0x2, // interrupt end of scan - ADC_INTR_EOSEQ_BITS = 0x3, // interrupt end of sequence (probably wont use this it's pretty fancy) - EN_ADC_INTR_SRC_BIT = 0x4, // enable adc interrupt source - EN_ADC_DONE_INTR_BIT = 0x8, // enable adc aquisition done interrupt + ADC_INTR_SRC_MASK = 0x3, /* bits that set adc interrupt source */ + ADC_INTR_QFULL_BITS = 0x0, /* interrupt fifo quater full */ + ADC_INTR_EOC_BITS = 0x1, /* interrupt end of conversion */ + ADC_INTR_EOSCAN_BITS = 0x2, /* interrupt end of scan */ + ADC_INTR_EOSEQ_BITS = 0x3, /* interrupt end of sequence (probably wont use this it's pretty fancy) */ + EN_ADC_INTR_SRC_BIT = 0x4, /* enable adc interrupt source */ + EN_ADC_DONE_INTR_BIT = 0x8, /* enable adc aquisition done interrupt */ DAC_INTR_SRC_MASK = 0x30, DAC_INTR_QEMPTY_BITS = 0x0, DAC_INTR_HIGH_CHAN_BITS = 0x10, - EN_DAC_INTR_SRC_BIT = 0x40, // enable dac interrupt source + EN_DAC_INTR_SRC_BIT = 0x40, /* enable dac interrupt source */ EN_DAC_DONE_INTR_BIT = 0x80, - EN_ADC_ACTIVE_INTR_BIT = 0x200, // enable adc active interrupt - EN_ADC_STOP_INTR_BIT = 0x400, // enable adc stop trigger interrupt - EN_DAC_ACTIVE_INTR_BIT = 0x800, // enable dac active interrupt - EN_DAC_UNDERRUN_BIT = 0x4000, // enable dac underrun status bit - EN_ADC_OVERRUN_BIT = 0x8000, // enable adc overrun status bit + EN_ADC_ACTIVE_INTR_BIT = 0x200, /* enable adc active interrupt */ + EN_ADC_STOP_INTR_BIT = 0x400, /* enable adc stop trigger interrupt */ + EN_DAC_ACTIVE_INTR_BIT = 0x800, /* enable dac active interrupt */ + EN_DAC_UNDERRUN_BIT = 0x4000, /* enable dac underrun status bit */ + EN_ADC_OVERRUN_BIT = 0x8000, /* enable adc overrun status bit */ }; enum hw_config_contents { - MASTER_CLOCK_4020_MASK = 0x3, // bits that specify master clock source for 4020 - INTERNAL_CLOCK_4020_BITS = 0x1, // use 40 MHz internal master clock for 4020 - BNC_CLOCK_4020_BITS = 0x2, // use BNC input for master clock - EXT_CLOCK_4020_BITS = 0x3, // use dio input for master clock - EXT_QUEUE_BIT = 0x200, // use external channel/gain queue (more versatile than internal queue) - SLOW_DAC_BIT = 0x400, // use 225 nanosec strobe when loading dac instead of 50 nanosec - HW_CONFIG_DUMMY_BITS = 0x2000, // bit with unknown function yet given as default value in pci-das64 manual - DMA_CH_SELECT_BIT = 0x8000, // bit selects channels 1/0 for analog input/output, otherwise 0/1 - FIFO_SIZE_REG = 0x4, // allows adjustment of fifo sizes - DAC_FIFO_SIZE_MASK = 0xff00, // bits that set dac fifo size + MASTER_CLOCK_4020_MASK = 0x3, /* bits that specify master clock source for 4020 */ + INTERNAL_CLOCK_4020_BITS = 0x1, /* use 40 MHz internal master clock for 4020 */ + BNC_CLOCK_4020_BITS = 0x2, /* use BNC input for master clock */ + EXT_CLOCK_4020_BITS = 0x3, /* use dio input for master clock */ + EXT_QUEUE_BIT = 0x200, /* use external channel/gain queue (more versatile than internal queue) */ + SLOW_DAC_BIT = 0x400, /* use 225 nanosec strobe when loading dac instead of 50 nanosec */ + HW_CONFIG_DUMMY_BITS = 0x2000, /* bit with unknown function yet given as default value in pci-das64 manual */ + DMA_CH_SELECT_BIT = 0x8000, /* bit selects channels 1/0 for analog input/output, otherwise 0/1 */ + FIFO_SIZE_REG = 0x4, /* allows adjustment of fifo sizes */ + DAC_FIFO_SIZE_MASK = 0xff00, /* bits that set dac fifo size */ DAC_FIFO_BITS = 0xf800, /* 8k sample ao fifo */ }; #define DAC_FIFO_SIZE 0x2000 enum daq_atrig_low_4020_contents { - EXT_AGATE_BNC_BIT = 0x8000, // use trig/ext clk bnc input for analog gate signal - EXT_STOP_TRIG_BNC_BIT = 0x4000, // use trig/ext clk bnc input for external stop trigger signal - EXT_START_TRIG_BNC_BIT = 0x2000, // use trig/ext clk bnc input for external start trigger signal + EXT_AGATE_BNC_BIT = 0x8000, /* use trig/ext clk bnc input for analog gate signal */ + EXT_STOP_TRIG_BNC_BIT = 0x4000, /* use trig/ext clk bnc input for external stop trigger signal */ + EXT_START_TRIG_BNC_BIT = 0x2000, /* use trig/ext clk bnc input for external start trigger signal */ }; static inline uint16_t analog_trig_low_threshold_bits(uint16_t threshold) { @@ -233,34 +234,34 @@ static inline uint16_t analog_trig_low_threshold_bits(uint16_t threshold) } enum adc_control0_contents { - ADC_GATE_SRC_MASK = 0x3, // bits that select gate - ADC_SOFT_GATE_BITS = 0x1, // software gate - ADC_EXT_GATE_BITS = 0x2, // external digital gate - ADC_ANALOG_GATE_BITS = 0x3, // analog level gate - ADC_GATE_LEVEL_BIT = 0x4, // level-sensitive gate (for digital) - ADC_GATE_POLARITY_BIT = 0x8, // gate active low + ADC_GATE_SRC_MASK = 0x3, /* bits that select gate */ + ADC_SOFT_GATE_BITS = 0x1, /* software gate */ + ADC_EXT_GATE_BITS = 0x2, /* external digital gate */ + ADC_ANALOG_GATE_BITS = 0x3, /* analog level gate */ + ADC_GATE_LEVEL_BIT = 0x4, /* level-sensitive gate (for digital) */ + ADC_GATE_POLARITY_BIT = 0x8, /* gate active low */ ADC_START_TRIG_SOFT_BITS = 0x10, ADC_START_TRIG_EXT_BITS = 0x20, ADC_START_TRIG_ANALOG_BITS = 0x30, ADC_START_TRIG_MASK = 0x30, - ADC_START_TRIG_FALLING_BIT = 0x40, // trig 1 uses falling edge - ADC_EXT_CONV_FALLING_BIT = 0x800, // external pacing uses falling edge - ADC_SAMPLE_COUNTER_EN_BIT = 0x1000, // enable hardware scan counter - ADC_DMA_DISABLE_BIT = 0x4000, // disables dma - ADC_ENABLE_BIT = 0x8000, // master adc enable + ADC_START_TRIG_FALLING_BIT = 0x40, /* trig 1 uses falling edge */ + ADC_EXT_CONV_FALLING_BIT = 0x800, /* external pacing uses falling edge */ + ADC_SAMPLE_COUNTER_EN_BIT = 0x1000, /* enable hardware scan counter */ + ADC_DMA_DISABLE_BIT = 0x4000, /* disables dma */ + ADC_ENABLE_BIT = 0x8000, /* master adc enable */ }; enum adc_control1_contents { - ADC_QUEUE_CONFIG_BIT = 0x1, // should be set for boards with > 16 channels + ADC_QUEUE_CONFIG_BIT = 0x1, /* should be set for boards with > 16 channels */ CONVERT_POLARITY_BIT = 0x10, EOC_POLARITY_BIT = 0x20, - ADC_SW_GATE_BIT = 0x40, // software gate of adc - ADC_DITHER_BIT = 0x200, // turn on extra noise for dithering + ADC_SW_GATE_BIT = 0x40, /* software gate of adc */ + ADC_DITHER_BIT = 0x200, /* turn on extra noise for dithering */ RETRIGGER_BIT = 0x800, ADC_LO_CHANNEL_4020_MASK = 0x300, ADC_HI_CHANNEL_4020_MASK = 0xc00, - TWO_CHANNEL_4020_BITS = 0x1000, // two channel mode for 4020 - FOUR_CHANNEL_4020_BITS = 0x2000, // four channel mode for 4020 + TWO_CHANNEL_4020_BITS = 0x1000, /* two channel mode for 4020 */ + FOUR_CHANNEL_4020_BITS = 0x2000, /* four channel mode for 4020 */ CHANNEL_MODE_4020_MASK = 0x3000, ADC_MODE_MASK = 0xf000, }; @@ -281,10 +282,10 @@ enum calibration_contents { SELECT_8800_BIT = 0x1, SELECT_8402_64XX_BIT = 0x2, SELECT_1590_60XX_BIT = 0x2, - CAL_EN_64XX_BIT = 0x40, // calibration enable for 64xx series + CAL_EN_64XX_BIT = 0x40, /* calibration enable for 64xx series */ SERIAL_DATA_IN_BIT = 0x80, SERIAL_CLOCK_BIT = 0x100, - CAL_EN_60XX_BIT = 0x200, // calibration enable for 60xx series + CAL_EN_60XX_BIT = 0x200, /* calibration enable for 60xx series */ CAL_GAIN_BIT = 0x800, }; /* calibration sources for 6025 are: @@ -308,11 +309,11 @@ static inline uint16_t adc_convert_chan_4020_bits(unsigned int channel) }; enum adc_queue_load_contents { - UNIP_BIT = 0x800, // unipolar/bipolar bit - ADC_SE_DIFF_BIT = 0x1000, // single-ended/ differential bit - ADC_COMMON_BIT = 0x2000, // non-referenced single-ended (common-mode input) - QUEUE_EOSEQ_BIT = 0x4000, // queue end of sequence - QUEUE_EOSCAN_BIT = 0x8000, // queue end of scan + UNIP_BIT = 0x800, /* unipolar/bipolar bit */ + ADC_SE_DIFF_BIT = 0x1000, /* single-ended/ differential bit */ + ADC_COMMON_BIT = 0x2000, /* non-referenced single-ended (common-mode input) */ + QUEUE_EOSEQ_BIT = 0x4000, /* queue end of sequence */ + QUEUE_EOSCAN_BIT = 0x8000, /* queue end of scan */ }; static inline uint16_t adc_chan_bits(unsigned int channel) { @@ -320,7 +321,7 @@ static inline uint16_t adc_chan_bits(unsigned int channel) }; enum dac_control0_contents { - DAC_ENABLE_BIT = 0x8000, // dac controller enable bit + DAC_ENABLE_BIT = 0x8000, /* dac controller enable bit */ DAC_CYCLIC_STOP_BIT = 0x4000, DAC_WAVEFORM_MODE_BIT = 0x100, DAC_EXT_UPDATE_FALLING_BIT = 0x80, @@ -340,14 +341,14 @@ enum dac_control1_contents { DAC_WRITE_POLARITY_BIT = 0x800, /* board-dependent setting */ DAC1_EXT_REF_BIT = 0x200, DAC0_EXT_REF_BIT = 0x100, - DAC_OUTPUT_ENABLE_BIT = 0x80, // dac output enable bit + DAC_OUTPUT_ENABLE_BIT = 0x80, /* dac output enable bit */ DAC_UPDATE_POLARITY_BIT = 0x40, /* board-dependent setting */ DAC_SW_GATE_BIT = 0x20, DAC1_UNIPOLAR_BIT = 0x8, DAC0_UNIPOLAR_BIT = 0x2, }; -// bit definitions for read-only registers +/* bit definitions for read-only registers */ enum hw_status_contents { DAC_UNDERRUN_BIT = 0x1, ADC_OVERRUN_BIT = 0x2, @@ -378,7 +379,7 @@ static inline unsigned int adc_upper_write_ptr_code(uint16_t prepost_bits) return (prepost_bits >> 14) & 0x3; } -// I2C addresses for 4020 +/* I2C addresses for 4020 */ enum i2c_addresses { RANGE_CAL_I2C_ADDR = 0x20, CALDAC0_I2C_ADDR = 0xc, @@ -386,8 +387,8 @@ enum i2c_addresses { }; enum range_cal_i2c_contents { - ADC_SRC_4020_MASK = 0x70, // bits that set what source the adc converter measures - BNC_TRIG_THRESHOLD_0V_BIT = 0x80, // make bnc trig/ext clock threshold 0V instead of 2.5V + ADC_SRC_4020_MASK = 0x70, /* bits that set what source the adc converter measures */ + BNC_TRIG_THRESHOLD_0V_BIT = 0x80, /* make bnc trig/ext clock threshold 0V instead of 2.5V */ }; static inline uint8_t adc_src_4020_bits(unsigned int source) { @@ -395,11 +396,11 @@ static inline uint8_t adc_src_4020_bits(unsigned int source) }; static inline uint8_t attenuate_bit(unsigned int channel) { - // attenuate channel (+-5V input range) + /* attenuate channel (+-5V input range) */ return 1 << (channel & 0x3); }; -// analog input ranges for 64xx boards +/* analog input ranges for 64xx boards */ static const struct comedi_lrange ai_ranges_64xx = { 8, { @@ -468,7 +469,7 @@ static const struct comedi_lrange ai_ranges_6052 = { } }; -// analog input ranges for 4020 board +/* analog input ranges for 4020 board */ static const struct comedi_lrange ai_ranges_4020 = { 2, { @@ -477,7 +478,7 @@ static const struct comedi_lrange ai_ranges_4020 = { } }; -// analog output ranges +/* analog output ranges */ static const struct comedi_lrange ao_ranges_64xx = { 4, { @@ -543,40 +544,40 @@ struct hw_fifo_info { struct pcidas64_board { const char *name; - int device_id; // pci device id - int ai_se_chans; // number of ai inputs in single-ended mode - int ai_bits; // analog input resolution - int ai_speed; // fastest conversion period in ns + int device_id; /* pci device id */ + int ai_se_chans; /* number of ai inputs in single-ended mode */ + int ai_bits; /* analog input resolution */ + int ai_speed; /* fastest conversion period in ns */ const struct comedi_lrange *ai_range_table; - int ao_nchan; // number of analog out channels - int ao_bits; // analog output resolution - int ao_scan_speed; // analog output speed (for a scan, not conversion) + int ao_nchan; /* number of analog out channels */ + int ao_bits; /* analog output resolution */ + int ao_scan_speed; /* analog output speed (for a scan, not conversion) */ const struct comedi_lrange *ao_range_table; const int *ao_range_code; const struct hw_fifo_info *const ai_fifo; - enum register_layout layout; // different board families have slightly different registers + enum register_layout layout; /* different board families have slightly different registers */ unsigned has_8255:1; }; static const struct hw_fifo_info ai_fifo_4020 = { - num_segments:2, - max_segment_length:0x8000, - sample_packing_ratio:2, - fifo_size_reg_mask:0x7f, + .num_segments = 2, + .max_segment_length = 0x8000, + .sample_packing_ratio = 2, + .fifo_size_reg_mask = 0x7f, }; static const struct hw_fifo_info ai_fifo_64xx = { - num_segments:4, - max_segment_length:0x800, - sample_packing_ratio:1, - fifo_size_reg_mask:0x3f, + .num_segments = 4, + .max_segment_length = 0x800, + .sample_packing_ratio = 1, + .fifo_size_reg_mask = 0x3f, }; static const struct hw_fifo_info ai_fifo_60xx = { - num_segments:4, - max_segment_length:0x800, - sample_packing_ratio:1, - fifo_size_reg_mask:0x7f, + .num_segments = 4, + .max_segment_length = 0x800, + .sample_packing_ratio = 1, + .fifo_size_reg_mask = 0x7f, }; /* maximum number of dma transfers we will chain together into a ring @@ -584,7 +585,7 @@ static const struct hw_fifo_info ai_fifo_60xx = { #define MAX_AI_DMA_RING_COUNT (0x80000 / DMA_BUFFER_SIZE) #define MIN_AI_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE) #define AO_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE) -static inline unsigned int ai_dma_ring_count(struct pcidas64_board * board) +static inline unsigned int ai_dma_ring_count(struct pcidas64_board *board) { if (board->layout == LAYOUT_4020) return MAX_AI_DMA_RING_COUNT; @@ -596,84 +597,84 @@ static const int bytes_in_sample = 2; static const struct pcidas64_board pcidas64_boards[] = { { - name: "pci-das6402/16", - device_id:0x1d, - ai_se_chans:64, - ai_bits: 16, - ai_speed:5000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ao_range_table:&ao_ranges_64xx, - ao_range_code:ao_range_code_64xx, - ai_fifo: &ai_fifo_64xx, - has_8255:1, + .name = "pci-das6402/16", + .device_id = 0x1d, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das6402/12", // XXX check - device_id:0x1e, - ai_se_chans:64, - ai_bits: 12, - ai_speed:5000, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ao_range_table:&ao_ranges_64xx, - ao_range_code:ao_range_code_64xx, - ai_fifo: &ai_fifo_64xx, - has_8255:1, + .name = "pci-das6402/12", /* XXX check */ + .device_id = 0x1e, + .ai_se_chans = 64, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m1/16", - device_id:0x35, - ai_se_chans:64, - ai_bits: 16, - ai_speed:1000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ao_range_table:&ao_ranges_64xx, - ao_range_code:ao_range_code_64xx, - ai_fifo: &ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m1/16", + .device_id = 0x35, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 1000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m2/16", - device_id:0x36, - ai_se_chans:64, - ai_bits: 16, - ai_speed:500, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ao_range_table:&ao_ranges_64xx, - ao_range_code:ao_range_code_64xx, - ai_fifo: &ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m2/16", + .device_id = 0x36, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 500, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m3/16", - device_id:0x37, - ai_se_chans:64, - ai_bits: 16, - ai_speed:333, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ao_range_table:&ao_ranges_64xx, - ao_range_code:ao_range_code_64xx, - ai_fifo: &ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m3/16", + .device_id = 0x37, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 333, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, }, { .name = "pci-das6013", @@ -691,334 +692,328 @@ static const struct pcidas64_board pcidas64_boards[] = { .has_8255 = 0, }, { - name: "pci-das6014", - device_id:0x79, - ai_se_chans:16, - ai_bits: 16, - ai_speed:5000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:100000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ao_range_table:&ao_ranges_60xx, - ao_range_code:ao_range_code_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6014", + .device_id = 0x79, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6023", - device_id:0x5d, - ai_se_chans:16, - ai_bits: 12, - ai_speed:5000, - ao_nchan:0, - ao_scan_speed:100000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ao_range_table:&ao_ranges_60xx, - ao_range_code:ao_range_code_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:1, + .name = "pci-das6023", + .device_id = 0x5d, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 1, }, { - name: "pci-das6025", - device_id:0x5e, - ai_se_chans:16, - ai_bits: 12, - ai_speed:5000, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:100000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ao_range_table:&ao_ranges_60xx, - ao_range_code:ao_range_code_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:1, + .name = "pci-das6025", + .device_id = 0x5e, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 1, }, { - name: "pci-das6030", - device_id:0x5f, - ai_se_chans:16, - ai_bits: 16, - ai_speed:10000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6030, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6030", + .device_id = 0x5f, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6031", - device_id:0x60, - ai_se_chans:64, - ai_bits: 16, - ai_speed:10000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:10000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6030, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6031", + .device_id = 0x60, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6032", - device_id:0x61, - ai_se_chans:16, - ai_bits: 16, - ai_speed:10000, - ao_nchan:0, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6032", + .device_id = 0x61, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6033", - device_id:0x62, - ai_se_chans:64, - ai_bits: 16, - ai_speed:10000, - ao_nchan:0, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6033", + .device_id = 0x62, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6034", - device_id:0x63, - ai_se_chans:16, - ai_bits: 16, - ai_speed:5000, - ao_nchan:0, - ao_scan_speed:0, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6034", + .device_id = 0x63, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6035", - device_id:0x64, - ai_se_chans:16, - ai_bits: 16, - ai_speed:5000, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:100000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ao_range_table:&ao_ranges_60xx, - ao_range_code:ao_range_code_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6035", + .device_id = 0x64, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6036", - device_id:0x6f, - ai_se_chans:16, - ai_bits: 16, - ai_speed:5000, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:100000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_60xx, - ao_range_table:&ao_ranges_60xx, - ao_range_code:ao_range_code_60xx, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6036", + .device_id = 0x6f, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6040", - device_id:0x65, - ai_se_chans:16, - ai_bits: 12, - ai_speed:2000, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:1000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6052, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6040", + .device_id = 0x65, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 2000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6052", - device_id:0x66, - ai_se_chans:16, - ai_bits: 16, - ai_speed:3333, - ao_nchan:2, - ao_bits: 16, - ao_scan_speed:3333, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6052, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6052", + .device_id = 0x66, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 3333, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 3333, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6070", - device_id:0x67, - ai_se_chans:16, - ai_bits: 12, - ai_speed:800, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:1000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6052, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6070", + .device_id = 0x67, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 800, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das6071", - device_id:0x68, - ai_se_chans:64, - ai_bits: 12, - ai_speed:800, - ao_nchan:2, - ao_bits: 12, - ao_scan_speed:1000, - layout: LAYOUT_60XX, - ai_range_table:&ai_ranges_6052, - ao_range_table:&ao_ranges_6030, - ao_range_code:ao_range_code_6030, - ai_fifo: &ai_fifo_60xx, - has_8255:0, + .name = "pci-das6071", + .device_id = 0x68, + .ai_se_chans = 64, + .ai_bits = 12, + .ai_speed = 800, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, }, { - name: "pci-das4020/12", - device_id:0x52, - ai_se_chans:4, - ai_bits: 12, - ai_speed:50, - ao_bits: 12, - ao_nchan:2, - ao_scan_speed:0, // no hardware pacing on ao - layout: LAYOUT_4020, - ai_range_table:&ai_ranges_4020, - ao_range_table:&ao_ranges_4020, - ao_range_code:ao_range_code_4020, - ai_fifo: &ai_fifo_4020, - has_8255:1, + .name = "pci-das4020/12", + .device_id = 0x52, + .ai_se_chans = 4, + .ai_bits = 12, + .ai_speed = 50, + .ao_bits = 12, + .ao_nchan = 2, + .ao_scan_speed = 0, /* no hardware pacing on ao */ + .layout = LAYOUT_4020, + .ai_range_table = &ai_ranges_4020, + .ao_range_table = &ao_ranges_4020, + .ao_range_code = ao_range_code_4020, + .ai_fifo = &ai_fifo_4020, + .has_8255 = 1, }, #if 0 { - name: "pci-das6402/16/jr", - device_id:0 // XXX, - ai_se_chans:64, - ai_bits: 16, - ai_speed:5000, - ao_nchan:0, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das6402/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m1/16/jr", - device_id:0 // XXX, - ai_se_chans:64, - ai_bits: 16, - ai_speed:1000, - ao_nchan:0, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m1/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 1000, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m2/16/jr", - device_id:0 // XXX, - ai_se_chans:64, - ai_bits: 16, - ai_speed:500, - ao_nchan:0, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m2/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 500, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m3/16/jr", - device_id:0 // XXX, - ai_se_chans:64, - ai_bits: 16, - ai_speed:333, - ao_nchan:0, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m3/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 333, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m1/14", - device_id:0, // XXX - ai_se_chans:64, - ai_bits: 14, - ai_speed:1000, - ao_nchan:2, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m1/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 1000, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m2/14", - device_id:0, // XXX - ai_se_chans:64, - ai_bits: 14, - ai_speed:500, - ao_nchan:2, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m2/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 500, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, { - name: "pci-das64/m3/14", - device_id:0, // XXX - ai_se_chans:64, - ai_bits: 14, - ai_speed:333, - ao_nchan:2, - ao_scan_speed:10000, - layout: LAYOUT_64XX, - ai_range_table:&ai_ranges_64xx, - ai_fifo: ai_fifo_64xx, - has_8255:1, + .name = "pci-das64/m3/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 333, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, }, #endif }; -// Number of boards in cb_pcidas_boards -static inline unsigned int num_boards(void) -{ - return sizeof(pcidas64_boards) / sizeof(struct pcidas64_board); -} - static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = { {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -1049,7 +1044,7 @@ static inline struct pcidas64_board *board(const struct comedi_device * dev) return (struct pcidas64_board *) dev->board_ptr; } -static inline unsigned short se_diff_bit_6xxx(struct comedi_device * dev, +static inline unsigned short se_diff_bit_6xxx(struct comedi_device *dev, int use_differential) { if ((board(dev)->layout == LAYOUT_64XX && !use_differential) || @@ -1060,50 +1055,50 @@ static inline unsigned short se_diff_bit_6xxx(struct comedi_device * dev, }; struct ext_clock_info { - unsigned int divisor; // master clock divisor to use for scans with external master clock - unsigned int chanspec; // chanspec for master clock input when used as scan begin src + unsigned int divisor; /* master clock divisor to use for scans with external master clock */ + unsigned int chanspec; /* chanspec for master clock input when used as scan begin src */ }; /* this structure is for data unique to this hardware driver. */ struct pcidas64_private { - struct pci_dev *hw_dev; // pointer to board's pci_dev struct - // base addresses (physical) + struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */ + /* base addresses (physical) */ resource_size_t plx9080_phys_iobase; resource_size_t main_phys_iobase; resource_size_t dio_counter_phys_iobase; - // base addresses (ioremapped) + /* base addresses (ioremapped) */ void *plx9080_iobase; void *main_iobase; void *dio_counter_iobase; - // local address (used by dma controller) + /* local address (used by dma controller) */ uint32_t local0_iobase; uint32_t local1_iobase; - volatile unsigned int ai_count; // number of analog input samples remaining - uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT]; // dma buffers for analog input - dma_addr_t ai_buffer_bus_addr[MAX_AI_DMA_RING_COUNT]; // physical addresses of ai dma buffers - struct plx_dma_desc *ai_dma_desc; // array of ai dma descriptors read by plx9080, allocated to get proper alignment - dma_addr_t ai_dma_desc_bus_addr; // physical address of ai dma descriptor array - volatile unsigned int ai_dma_index; // index of the ai dma descriptor/buffer that is currently being used - uint16_t *ao_buffer[AO_DMA_RING_COUNT]; // dma buffers for analog output - dma_addr_t ao_buffer_bus_addr[AO_DMA_RING_COUNT]; // physical addresses of ao dma buffers + volatile unsigned int ai_count; /* number of analog input samples remaining */ + uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT]; /* dma buffers for analog input */ + dma_addr_t ai_buffer_bus_addr[MAX_AI_DMA_RING_COUNT]; /* physical addresses of ai dma buffers */ + struct plx_dma_desc *ai_dma_desc; /* array of ai dma descriptors read by plx9080, allocated to get proper alignment */ + dma_addr_t ai_dma_desc_bus_addr; /* physical address of ai dma descriptor array */ + volatile unsigned int ai_dma_index; /* index of the ai dma descriptor/buffer that is currently being used */ + uint16_t *ao_buffer[AO_DMA_RING_COUNT]; /* dma buffers for analog output */ + dma_addr_t ao_buffer_bus_addr[AO_DMA_RING_COUNT]; /* physical addresses of ao dma buffers */ struct plx_dma_desc *ao_dma_desc; dma_addr_t ao_dma_desc_bus_addr; - volatile unsigned int ao_dma_index; // keeps track of buffer where the next ao sample should go - volatile unsigned long ao_count; // number of analog output samples remaining - volatile unsigned int ao_value[2]; // remember what the analog outputs are set to, to allow readback - unsigned int hw_revision; // stc chip hardware revision number - volatile unsigned int intr_enable_bits; // last bits sent to INTR_ENABLE_REG register - volatile uint16_t adc_control1_bits; // last bits sent to ADC_CONTROL1_REG register - volatile uint16_t fifo_size_bits; // last bits sent to FIFO_SIZE_REG register - volatile uint16_t hw_config_bits; // last bits sent to HW_CONFIG_REG register + volatile unsigned int ao_dma_index; /* keeps track of buffer where the next ao sample should go */ + volatile unsigned long ao_count; /* number of analog output samples remaining */ + volatile unsigned int ao_value[2]; /* remember what the analog outputs are set to, to allow readback */ + unsigned int hw_revision; /* stc chip hardware revision number */ + volatile unsigned int intr_enable_bits; /* last bits sent to INTR_ENABLE_REG register */ + volatile uint16_t adc_control1_bits; /* last bits sent to ADC_CONTROL1_REG register */ + volatile uint16_t fifo_size_bits; /* last bits sent to FIFO_SIZE_REG register */ + volatile uint16_t hw_config_bits; /* last bits sent to HW_CONFIG_REG register */ volatile uint16_t dac_control1_bits; - volatile uint32_t plx_control_bits; // last bits written to plx9080 control register - volatile uint32_t plx_intcsr_bits; // last bits written to plx interrupt control and status register - volatile int calibration_source; // index of calibration source readable through ai ch0 - volatile uint8_t i2c_cal_range_bits; // bits written to i2c calibration/range register - volatile unsigned int ext_trig_falling; // configure digital triggers to trigger on falling edge - // states of various devices stored to enable read-back + volatile uint32_t plx_control_bits; /* last bits written to plx9080 control register */ + volatile uint32_t plx_intcsr_bits; /* last bits written to plx interrupt control and status register */ + volatile int calibration_source; /* index of calibration source readable through ai ch0 */ + volatile uint8_t i2c_cal_range_bits; /* bits written to i2c calibration/range register */ + volatile unsigned int ext_trig_falling; /* configure digital triggers to trigger on falling edge */ + /* states of various devices stored to enable read-back */ unsigned int ad8402_state[2]; unsigned int caldac_state[8]; volatile short ai_cmd_running; @@ -1127,82 +1122,82 @@ static inline struct pcidas64_private *priv(struct comedi_device * dev) * the board, and also about the kernel module that contains * the device code. */ -static int attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int detach(struct comedi_device * dev); +static int attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int detach(struct comedi_device *dev); static struct comedi_driver driver_cb_pcidas = { - driver_name:"cb_pcidas64", - module:THIS_MODULE, - attach:attach, - detach:detach, + .driver_name = "cb_pcidas64", + .module = THIS_MODULE, + .attach = attach, + .detach = detach, }; -static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * subdev, +static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *subdev, unsigned int trig_num); -static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG); -static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static int ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static irqreturn_t handle_interrupt(int irq, void *d); +static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int dio_callback(int dir, int port, int data, unsigned long arg); static int dio_callback_4020(int dir, int port, int data, unsigned long arg); -static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static void ad8402_write(struct comedi_device * dev, unsigned int channel, +static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ad8402_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static void ad8402_write(struct comedi_device *dev, unsigned int channel, unsigned int value); -static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static void check_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd); +static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd); static unsigned int get_divisor(unsigned int ns, unsigned int flags); -static void i2c_write(struct comedi_device * dev, unsigned int address, - const uint8_t * data, unsigned int length); -static void caldac_write(struct comedi_device * dev, unsigned int channel, +static void i2c_write(struct comedi_device *dev, unsigned int address, + const uint8_t *data, unsigned int length); +static void caldac_write(struct comedi_device *dev, unsigned int channel, unsigned int value); -static int caldac_8800_write(struct comedi_device * dev, unsigned int address, +static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value); -//static int dac_1590_write(struct comedi_device *dev, unsigned int dac_a, unsigned int dac_b); -static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_channel, +/* static int dac_1590_write(struct comedi_device *dev, unsigned int dac_a, unsigned int dac_b); */ +static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel, unsigned int value); -static void abort_dma(struct comedi_device * dev, unsigned int channel); -static void disable_plx_interrupts(struct comedi_device * dev); -static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples); -static unsigned int ai_fifo_size(struct comedi_device * dev); -static int set_ai_fifo_segment_length(struct comedi_device * dev, +static void abort_dma(struct comedi_device *dev, unsigned int channel); +static void disable_plx_interrupts(struct comedi_device *dev); +static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples); +static unsigned int ai_fifo_size(struct comedi_device *dev); +static int set_ai_fifo_segment_length(struct comedi_device *dev, unsigned int num_entries); -static void disable_ai_pacing(struct comedi_device * dev); -static void disable_ai_interrupts(struct comedi_device * dev); -static void enable_ai_interrupts(struct comedi_device * dev, const struct comedi_cmd * cmd); +static void disable_ai_pacing(struct comedi_device *dev); +static void disable_ai_interrupts(struct comedi_device *dev); +static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd); static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags); -static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd); +static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd); COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, pcidas64_pci_table); -static unsigned int ai_range_bits_6xxx(const struct comedi_device * dev, +static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev, unsigned int range_index) { const struct comedi_krange *range = @@ -1246,7 +1241,7 @@ static unsigned int ai_range_bits_6xxx(const struct comedi_device * dev, return bits; } -static unsigned int hw_revision(const struct comedi_device * dev, +static unsigned int hw_revision(const struct comedi_device *dev, uint16_t hw_status_bits) { if (board(dev)->layout == LAYOUT_4020) @@ -1255,7 +1250,7 @@ static unsigned int hw_revision(const struct comedi_device * dev, return (hw_status_bits >> 12) & 0xf; } -static void set_dac_range_bits(struct comedi_device * dev, volatile uint16_t * bits, +static void set_dac_range_bits(struct comedi_device *dev, volatile uint16_t *bits, unsigned int channel, unsigned int range) { unsigned int code = board(dev)->ao_range_code[range]; @@ -1269,13 +1264,13 @@ static void set_dac_range_bits(struct comedi_device * dev, volatile uint16_t * b *bits |= code << (2 * channel); }; -static inline int ao_cmd_is_supported(const struct pcidas64_board * board) +static inline int ao_cmd_is_supported(const struct pcidas64_board *board) { return board->ao_nchan && board->layout != LAYOUT_4020; } -// initialize plx9080 chip -static void init_plx9080(struct comedi_device * dev) +/* initialize plx9080 chip */ +static void init_plx9080(struct comedi_device *dev) { uint32_t bits; void *plx_iobase = priv(dev)->plx9080_iobase; @@ -1283,7 +1278,7 @@ static void init_plx9080(struct comedi_device * dev) priv(dev)->plx_control_bits = readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG); - // plx9080 dump + /* plx9080 dump */ DEBUG_PRINT(" plx interrupt status 0x%x\n", readl(plx_iobase + PLX_INTRCS_REG)); DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG)); @@ -1327,35 +1322,35 @@ static void init_plx9080(struct comedi_device * dev) abort_dma(dev, 0); abort_dma(dev, 1); - // configure dma0 mode + /* configure dma0 mode */ bits = 0; - // enable ready input, not sure if this is necessary + /* enable ready input, not sure if this is necessary */ bits |= PLX_DMA_EN_READYIN_BIT; - // enable bterm, not sure if this is necessary + /* enable bterm, not sure if this is necessary */ bits |= PLX_EN_BTERM_BIT; - // enable dma chaining + /* enable dma chaining */ bits |= PLX_EN_CHAIN_BIT; - // enable interrupt on dma done (probably don't need this, since chain never finishes) + /* enable interrupt on dma done (probably don't need this, since chain never finishes) */ bits |= PLX_EN_DMA_DONE_INTR_BIT; - // don't increment local address during transfers (we are transferring from a fixed fifo register) + /* don't increment local address during transfers (we are transferring from a fixed fifo register) */ bits |= PLX_LOCAL_ADDR_CONST_BIT; - // route dma interrupt to pci bus + /* route dma interrupt to pci bus */ bits |= PLX_DMA_INTR_PCI_BIT; - // enable demand mode + /* enable demand mode */ bits |= PLX_DEMAND_MODE_BIT; - // enable local burst mode + /* enable local burst mode */ bits |= PLX_DMA_LOCAL_BURST_EN_BIT; - // 4020 uses 32 bit dma + /* 4020 uses 32 bit dma */ if (board(dev)->layout == LAYOUT_4020) { bits |= PLX_LOCAL_BUS_32_WIDE_BITS; - } else { // localspace0 bus is 16 bits wide + } else { /* localspace0 bus is 16 bits wide */ bits |= PLX_LOCAL_BUS_16_WIDE_BITS; } writel(bits, plx_iobase + PLX_DMA1_MODE_REG); if (ao_cmd_is_supported(board(dev))) writel(bits, plx_iobase + PLX_DMA0_MODE_REG); - // enable interrupts on plx 9080 + /* enable interrupts on plx 9080 */ priv(dev)->plx_intcsr_bits |= ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | ICS_DMA0_E | ICS_DMA1_E; @@ -1365,7 +1360,7 @@ static void init_plx9080(struct comedi_device * dev) /* Allocate and initialize the subdevice structures. */ -static int setup_subdevices(struct comedi_device * dev) +static int setup_subdevices(struct comedi_device *dev) { struct comedi_subdevice *s; void *dio_8255_iobase; @@ -1396,9 +1391,9 @@ static int setup_subdevices(struct comedi_device * dev) if (board(dev)->layout == LAYOUT_4020) { unsigned int i; uint8_t data; - // set adc to read from inputs (not internal calibration sources) + /* set adc to read from inputs (not internal calibration sources) */ priv(dev)->i2c_cal_range_bits = adc_src_4020_bits(4); - // set channels to +-5 volt input ranges + /* set channels to +-5 volt input ranges */ for (i = 0; i < s->n_chan; i++) priv(dev)->i2c_cal_range_bits |= attenuate_bit(i); data = priv(dev)->i2c_cal_range_bits; @@ -1428,7 +1423,7 @@ static int setup_subdevices(struct comedi_device * dev) s->type = COMEDI_SUBD_UNUSED; } - // digital input + /* digital input */ s = dev->subdevices + 2; if (board(dev)->layout == LAYOUT_64XX) { s->type = COMEDI_SUBD_DI; @@ -1440,7 +1435,7 @@ static int setup_subdevices(struct comedi_device * dev) } else s->type = COMEDI_SUBD_UNUSED; - // digital output + /* digital output */ if (board(dev)->layout == LAYOUT_64XX) { s = dev->subdevices + 3; s->type = COMEDI_SUBD_DO; @@ -1469,7 +1464,7 @@ static int setup_subdevices(struct comedi_device * dev) } else s->type = COMEDI_SUBD_UNUSED; - // 8 channel dio for 60xx + /* 8 channel dio for 60xx */ s = dev->subdevices + 5; if (board(dev)->layout == LAYOUT_60XX) { s->type = COMEDI_SUBD_DIO; @@ -1482,7 +1477,7 @@ static int setup_subdevices(struct comedi_device * dev) } else s->type = COMEDI_SUBD_UNUSED; - // caldac + /* caldac */ s = dev->subdevices + 6; s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; @@ -1496,7 +1491,7 @@ static int setup_subdevices(struct comedi_device * dev) for (i = 0; i < s->n_chan; i++) caldac_write(dev, i, s->maxdata / 2); - // 2 channel ad8402 potentiometer + /* 2 channel ad8402 potentiometer */ s = dev->subdevices + 7; if (board(dev)->layout == LAYOUT_64XX) { s->type = COMEDI_SUBD_CALIB; @@ -1510,7 +1505,7 @@ static int setup_subdevices(struct comedi_device * dev) } else s->type = COMEDI_SUBD_UNUSED; - //serial EEPROM, if present + /* serial EEPROM, if present */ s = dev->subdevices + 8; if (readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG) & CTL_EECHK) { s->type = COMEDI_SUBD_MEMORY; @@ -1521,34 +1516,34 @@ static int setup_subdevices(struct comedi_device * dev) } else s->type = COMEDI_SUBD_UNUSED; - // user counter subd XXX + /* user counter subd XXX */ s = dev->subdevices + 9; s->type = COMEDI_SUBD_UNUSED; return 0; } -static void disable_plx_interrupts(struct comedi_device * dev) +static void disable_plx_interrupts(struct comedi_device *dev) { priv(dev)->plx_intcsr_bits = 0; writel(priv(dev)->plx_intcsr_bits, priv(dev)->plx9080_iobase + PLX_INTRCS_REG); } -static void init_stc_registers(struct comedi_device * dev) +static void init_stc_registers(struct comedi_device *dev) { uint16_t bits; unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); - // bit should be set for 6025, although docs say boards with <= 16 chans should be cleared XXX + /* bit should be set for 6025, although docs say boards with <= 16 chans should be cleared XXX */ if (1) priv(dev)->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT; writew(priv(dev)->adc_control1_bits, priv(dev)->main_iobase + ADC_CONTROL1_REG); - // 6402/16 manual says this register must be initialized to 0xff? + /* 6402/16 manual says this register must be initialized to 0xff? */ writew(0xff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); bits = SLOW_DAC_BIT | DMA_CH_SELECT_BIT; @@ -1561,9 +1556,9 @@ static void init_stc_registers(struct comedi_device * dev) writew(0, priv(dev)->main_iobase + DAQ_SYNC_REG); writew(0, priv(dev)->main_iobase + CALIBRATION_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // set fifos to maximum size + /* set fifos to maximum size */ priv(dev)->fifo_size_bits |= DAC_FIFO_BITS; set_ai_fifo_segment_length(dev, board(dev)->ai_fifo->max_segment_length); @@ -1577,11 +1572,11 @@ static void init_stc_registers(struct comedi_device * dev) disable_ai_pacing(dev); }; -int alloc_and_init_dma_members(struct comedi_device * dev) +int alloc_and_init_dma_members(struct comedi_device *dev) { int i; - // alocate pci dma buffers + /* alocate pci dma buffers */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { priv(dev)->ai_buffer[i] = pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE, @@ -1601,7 +1596,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev) } } } - // allocate dma descriptors + /* allocate dma descriptors */ priv(dev)->ai_dma_desc = pci_alloc_consistent(priv(dev)->hw_dev, sizeof(struct plx_dma_desc) * ai_dma_ring_count(board(dev)), @@ -1622,7 +1617,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev) DEBUG_PRINT("ao dma descriptors start at bus addr 0x%x\n", priv(dev)->ao_dma_desc_bus_addr); } - // initialize dma descriptors + /* initialize dma descriptors */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { priv(dev)->ai_dma_desc[i].pci_start_addr = cpu_to_le32(priv(dev)->ai_buffer_bus_addr[i]); @@ -1663,7 +1658,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev) return 0; } -static inline void warn_external_queue(struct comedi_device * dev) +static inline void warn_external_queue(struct comedi_device *dev) { comedi_error(dev, "AO command and AI external channel queue cannot be used simultaneously."); @@ -1697,16 +1692,16 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - // is it not a computer boards card? + /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) continue; - // loop through cards supported by this driver - for (index = 0; index < num_boards(); index++) { + /* loop through cards supported by this driver */ + for (index = 0; index < ARRAY_SIZE(pcidas64_boards); index++) { if (pcidas64_boards[index].device_id != pcidev->device) continue; - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { @@ -1736,7 +1731,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) } pci_set_master(pcidev); - //Initialize dev->board_name + /* Initialize dev->board_name */ dev->board_name = board(dev)->name; priv(dev)->plx9080_phys_iobase = @@ -1746,7 +1741,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) priv(dev)->dio_counter_phys_iobase = pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX); - // remap, won't work with 2.0 kernels but who cares + /* remap, won't work with 2.0 kernels but who cares */ priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase, pci_resource_len(pcidev, PLX9080_BADDRINDEX)); priv(dev)->main_iobase = ioremap(priv(dev)->main_phys_iobase, @@ -1766,7 +1761,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) DEBUG_PRINT(" diocounter remapped to 0x%p\n", priv(dev)->dio_counter_iobase); - // figure out what local addresses are + /* figure out what local addresses are */ local_range = readl(priv(dev)->plx9080_iobase + PLX_LAS0RNG_REG) & LRNG_MEM_MASK; @@ -1798,8 +1793,8 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) printk(" stc hardware revision %i\n", priv(dev)->hw_revision); init_plx9080(dev); init_stc_registers(dev); - // get irq - if (comedi_request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, + /* get irq */ + if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, "cb_pcidas64", dev)) { printk(" unable to allocate irq %u\n", pcidev->irq); return -EINVAL; @@ -1823,14 +1818,14 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int detach(struct comedi_device * dev) +static int detach(struct comedi_device *dev) { unsigned int i; printk("comedi%d: cb_pcidas: remove\n", dev->minor); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (priv(dev)) { if (priv(dev)->hw_dev) { if (priv(dev)->plx9080_iobase) { @@ -1841,7 +1836,7 @@ static int detach(struct comedi_device * dev) iounmap((void *)priv(dev)->main_iobase); if (priv(dev)->dio_counter_iobase) iounmap((void *)priv(dev)->dio_counter_iobase); - // free pci dma buffers + /* free pci dma buffers */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { if (priv(dev)->ai_buffer[i]) pci_free_consistent(priv(dev)->hw_dev, @@ -1858,7 +1853,7 @@ static int detach(struct comedi_device * dev) priv(dev)-> ao_buffer_bus_addr[i]); } - // free dma descriptors + /* free dma descriptors */ if (priv(dev)->ai_dma_desc) pci_free_consistent(priv(dev)->hw_dev, sizeof(struct plx_dma_desc) * @@ -1883,8 +1878,8 @@ static int detach(struct comedi_device * dev) return 0; } -static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits = 0, n, i; unsigned int channel, range, aref; @@ -1896,26 +1891,26 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, range = CR_RANGE(insn->chanspec); aref = CR_AREF(insn->chanspec); - // disable card's analog input interrupt sources and pacing - // 4020 generates dac done interrupts even though they are disabled + /* disable card's analog input interrupt sources and pacing */ + /* 4020 generates dac done interrupts even though they are disabled */ disable_ai_pacing(dev); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); if (insn->chanspec & CR_ALT_FILTER) priv(dev)->adc_control1_bits |= ADC_DITHER_BIT; else priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT; writew(priv(dev)->adc_control1_bits, priv(dev)->main_iobase + ADC_CONTROL1_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); if (board(dev)->layout != LAYOUT_4020) { - // use internal queue + /* use internal queue */ priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT; writew(priv(dev)->hw_config_bits, priv(dev)->main_iobase + HW_CONFIG_REG); - // ALT_SOURCE is internal calibration reference + /* ALT_SOURCE is internal calibration reference */ if (insn->chanspec & CR_ALT_SOURCE) { unsigned int cal_en_bit; @@ -1924,27 +1919,27 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, cal_en_bit = CAL_EN_60XX_BIT; else cal_en_bit = CAL_EN_64XX_BIT; - // select internal reference source to connect to channel 0 + /* select internal reference source to connect to channel 0 */ writew(cal_en_bit | adc_src_bits(priv(dev)-> calibration_source), priv(dev)->main_iobase + CALIBRATION_REG); } else { - // make sure internal calibration source is turned off + /* make sure internal calibration source is turned off */ writew(0, priv(dev)->main_iobase + CALIBRATION_REG); } - // load internal queue + /* load internal queue */ bits = 0; - // set gain + /* set gain */ bits |= ai_range_bits_6xxx(dev, CR_RANGE(insn->chanspec)); - // set single-ended / differential + /* set single-ended / differential */ bits |= se_diff_bit_6xxx(dev, aref == AREF_DIFF); if (aref == AREF_COMMON) bits |= ADC_COMMON_BIT; bits |= adc_chan_bits(channel); - // set stop channel + /* set stop channel */ writew(adc_chan_bits(channel), priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); - // set start channel, and rest of settings + /* set start channel, and rest of settings */ writew(bits, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); } else { uint8_t old_cal_range_bits = priv(dev)->i2c_cal_range_bits; @@ -1955,16 +1950,16 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(priv(dev)-> calibration_source); - } else { //select BNC inputs + } else { /* select BNC inputs */ priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4); } - // select range + /* select range */ if (range == 0) priv(dev)->i2c_cal_range_bits |= attenuate_bit(channel); else priv(dev)->i2c_cal_range_bits &= ~attenuate_bit(channel); - // update calibration/range i2c register only if necessary, as it is very slow + /* update calibration/range i2c register only if necessary, as it is very slow */ if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) { uint8_t i2c_data = priv(dev)->i2c_cal_range_bits; i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data, @@ -1981,14 +1976,14 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, for (n = 0; n < insn->n; n++) { - // clear adc buffer (inside loop for 4020 sake) + /* clear adc buffer (inside loop for 4020 sake) */ writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG); /* trigger conversion, bits sent only matter for 4020 */ writew(adc_convert_chan_4020_bits(CR_CHAN(insn->chanspec)), priv(dev)->main_iobase + ADC_CONVERT_REG); - // wait for data + /* wait for data */ for (i = 0; i < timeout; i++) { bits = readw(priv(dev)->main_iobase + HW_STATUS_REG); DEBUG_PRINT(" pipe bits 0x%x\n", pipe_full_bits(bits)); @@ -2000,12 +1995,12 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, if (pipe_full_bits(bits)) break; } - comedi_udelay(1); + udelay(1); } DEBUG_PRINT(" looped %i times waiting for data\n", i); if (i == timeout) { comedi_error(dev, " analog input read insn timed out"); - rt_printk(" status 0x%x\n", bits); + printk(" status 0x%x\n", bits); return -ETIME; } if (board(dev)->layout == LAYOUT_4020) @@ -2020,7 +2015,7 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, return n; } -static int ai_config_calibration_source(struct comedi_device * dev, unsigned int * data) +static int ai_config_calibration_source(struct comedi_device *dev, unsigned int *data) { unsigned int source = data[1]; int num_calibration_sources; @@ -2040,7 +2035,7 @@ static int ai_config_calibration_source(struct comedi_device * dev, unsigned int return 2; } -static int ai_config_block_size(struct comedi_device * dev, unsigned int * data) +static int ai_config_block_size(struct comedi_device *dev, unsigned int *data) { int fifo_size; const struct hw_fifo_info *const fifo = board(dev)->ai_fifo; @@ -2067,7 +2062,7 @@ static int ai_config_block_size(struct comedi_device * dev, unsigned int * data) return 2; } -static int ai_config_master_clock_4020(struct comedi_device * dev, unsigned int * data) +static int ai_config_master_clock_4020(struct comedi_device *dev, unsigned int *data) { unsigned int divisor = data[4]; int retval = 0; @@ -2092,8 +2087,8 @@ static int ai_config_master_clock_4020(struct comedi_device * dev, unsigned int return retval ? retval : 5; } -// XXX could add support for 60xx series -static int ai_config_master_clock(struct comedi_device * dev, unsigned int * data) +/* XXX could add support for 60xx series */ +static int ai_config_master_clock(struct comedi_device *dev, unsigned int *data) { switch (board(dev)->layout) { @@ -2108,8 +2103,8 @@ static int ai_config_master_clock(struct comedi_device * dev, unsigned int * dat return -EINVAL; } -static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int id = data[0]; @@ -2130,8 +2125,8 @@ static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * return -EINVAL; } -static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -2182,7 +2177,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, /* step 2: make sure trigger sources are unique and mutually compatible */ - // uniqueness check + /* uniqueness check */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) err++; if (cmd->scan_begin_src != TRIG_TIMER && @@ -2196,7 +2191,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) err++; - // compatibility check + /* compatibility check */ if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER) err++; if (cmd->stop_src != TRIG_COUNT && @@ -2220,7 +2215,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, err++; } if (cmd->scan_begin_src == TRIG_TIMER) { - // if scans are timed faster than conversion rate allows + /* if scans are timed faster than conversion rate allows */ if (cmd->convert_arg * cmd->chanlist_len > cmd->scan_begin_arg) { cmd->scan_begin_arg = @@ -2278,7 +2273,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, if (err) return 4; - // make sure user is doesn't change analog reference mid chanlist + /* make sure user is doesn't change analog reference mid chanlist */ if (cmd->chanlist) { aref = CR_AREF(cmd->chanlist[0]); for (i = 1; i < cmd->chanlist_len; i++) { @@ -2289,7 +2284,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, break; } } - // check 4020 chanlist + /* check 4020 chanlist */ if (board(dev)->layout == LAYOUT_4020) { unsigned int first_channel = CR_CHAN(cmd->chanlist[0]); for (i = 1; i < cmd->chanlist_len; i++) { @@ -2315,9 +2310,9 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, return 0; } -static int use_hw_sample_counter(struct comedi_cmd * cmd) +static int use_hw_sample_counter(struct comedi_cmd *cmd) { -// disable for now until I work out a race +/* disable for now until I work out a race */ return 0; if (cmd->stop_src == TRIG_COUNT && cmd->stop_arg <= max_counter_value) @@ -2326,13 +2321,13 @@ static int use_hw_sample_counter(struct comedi_cmd * cmd) return 0; } -static void setup_sample_counters(struct comedi_device * dev, struct comedi_cmd * cmd) +static void setup_sample_counters(struct comedi_device *dev, struct comedi_cmd *cmd) { if (cmd->stop_src == TRIG_COUNT) { - // set software count + /* set software count */ priv(dev)->ai_count = cmd->stop_arg * cmd->chanlist_len; } - // load hardware conversion counter + /* load hardware conversion counter */ if (use_hw_sample_counter(cmd)) { writew(cmd->stop_arg & 0xffff, priv(dev)->main_iobase + ADC_COUNT_LOWER_REG); @@ -2343,7 +2338,7 @@ static void setup_sample_counters(struct comedi_device * dev, struct comedi_cmd } } -static inline unsigned int dma_transfer_size(struct comedi_device * dev) +static inline unsigned int dma_transfer_size(struct comedi_device *dev) { unsigned int num_samples; @@ -2356,71 +2351,71 @@ static inline unsigned int dma_transfer_size(struct comedi_device * dev) return num_samples; } -static void disable_ai_pacing(struct comedi_device * dev) +static void disable_ai_pacing(struct comedi_device *dev) { unsigned long flags; disable_ai_interrupts(dev); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->adc_control1_bits &= ~ADC_SW_GATE_BIT; writew(priv(dev)->adc_control1_bits, priv(dev)->main_iobase + ADC_CONTROL1_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); /* disable pacing, triggering, etc */ writew(ADC_DMA_DISABLE_BIT | ADC_SOFT_GATE_BITS | ADC_GATE_LEVEL_BIT, priv(dev)->main_iobase + ADC_CONTROL0_REG); } -static void disable_ai_interrupts(struct comedi_device * dev) +static void disable_ai_interrupts(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->intr_enable_bits &= ~EN_ADC_INTR_SRC_BIT & ~EN_ADC_DONE_INTR_BIT & ~EN_ADC_ACTIVE_INTR_BIT & ~EN_ADC_STOP_INTR_BIT & ~EN_ADC_OVERRUN_BIT & ~ADC_INTR_SRC_MASK; writew(priv(dev)->intr_enable_bits, priv(dev)->main_iobase + INTR_ENABLE_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits); } -static void enable_ai_interrupts(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd) { uint32_t bits; unsigned long flags; bits = EN_ADC_OVERRUN_BIT | EN_ADC_DONE_INTR_BIT | EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT; - // Use pio transfer and interrupt on end of conversion if TRIG_WAKE_EOS flag is set. + /* Use pio transfer and interrupt on end of conversion if TRIG_WAKE_EOS flag is set. */ if (cmd->flags & TRIG_WAKE_EOS) { - // 4020 doesn't support pio transfers except for fifo dregs + /* 4020 doesn't support pio transfers except for fifo dregs */ if (board(dev)->layout != LAYOUT_4020) bits |= ADC_INTR_EOSCAN_BITS | EN_ADC_INTR_SRC_BIT; } - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->intr_enable_bits |= bits; writew(priv(dev)->intr_enable_bits, priv(dev)->main_iobase + INTR_ENABLE_REG); DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } -static uint32_t ai_convert_counter_6xxx(const struct comedi_device * dev, - const struct comedi_cmd * cmd) +static uint32_t ai_convert_counter_6xxx(const struct comedi_device *dev, + const struct comedi_cmd *cmd) { - // supposed to load counter with desired divisor minus 3 + /* supposed to load counter with desired divisor minus 3 */ return cmd->convert_arg / TIMER_BASE - 3; } -static uint32_t ai_scan_counter_6xxx(struct comedi_device * dev, struct comedi_cmd * cmd) +static uint32_t ai_scan_counter_6xxx(struct comedi_device *dev, struct comedi_cmd *cmd) { uint32_t count; - // figure out how long we need to delay at end of scan + /* figure out how long we need to delay at end of scan */ switch (cmd->scan_begin_src) { case TRIG_TIMER: count = (cmd->scan_begin_arg - @@ -2437,7 +2432,7 @@ static uint32_t ai_scan_counter_6xxx(struct comedi_device * dev, struct comedi_c return count - 3; } -static uint32_t ai_convert_counter_4020(struct comedi_device * dev, struct comedi_cmd * cmd) +static uint32_t ai_convert_counter_4020(struct comedi_device *dev, struct comedi_cmd *cmd) { unsigned int divisor; @@ -2448,20 +2443,20 @@ static uint32_t ai_convert_counter_4020(struct comedi_device * dev, struct comed case TRIG_OTHER: divisor = priv(dev)->ext_clock.divisor; break; - default: // should never happen + default: /* should never happen */ comedi_error(dev, "bug! failed to set ai pacing!"); divisor = 1000; break; } - // supposed to load counter with desired divisor minus 2 for 4020 + /* supposed to load counter with desired divisor minus 2 for 4020 */ return divisor - 2; } -static void select_master_clock_4020(struct comedi_device * dev, - const struct comedi_cmd * cmd) +static void select_master_clock_4020(struct comedi_device *dev, + const struct comedi_cmd *cmd) { - // select internal/external master clock + /* select internal/external master clock */ priv(dev)->hw_config_bits &= ~MASTER_CLOCK_4020_MASK; if (cmd->scan_begin_src == TRIG_OTHER) { int chanspec = priv(dev)->ext_clock.chanspec; @@ -2477,7 +2472,7 @@ static void select_master_clock_4020(struct comedi_device * dev, priv(dev)->main_iobase + HW_CONFIG_REG); } -static void select_master_clock(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void select_master_clock(struct comedi_device *dev, const struct comedi_cmd *cmd) { switch (board(dev)->layout) { case LAYOUT_4020: @@ -2488,12 +2483,12 @@ static void select_master_clock(struct comedi_device * dev, const struct comedi_ } } -static inline void dma_start_sync(struct comedi_device * dev, unsigned int channel) +static inline void dma_start_sync(struct comedi_device *dev, unsigned int channel) { unsigned long flags; - // spinlock for plx dma control/status reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spinlock for plx dma control/status reg */ + spin_lock_irqsave(&dev->spinlock, flags); if (channel) writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, @@ -2502,10 +2497,10 @@ static inline void dma_start_sync(struct comedi_device * dev, unsigned int chann writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } -static void set_ai_pacing(struct comedi_device * dev, struct comedi_cmd * cmd) +static void set_ai_pacing(struct comedi_device *dev, struct comedi_cmd *cmd) { uint32_t convert_counter = 0, scan_counter = 0; @@ -2520,23 +2515,23 @@ static void set_ai_pacing(struct comedi_device * dev, struct comedi_cmd * cmd) scan_counter = ai_scan_counter_6xxx(dev, cmd); } - // load lower 16 bits of convert interval + /* load lower 16 bits of convert interval */ writew(convert_counter & 0xffff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); DEBUG_PRINT("convert counter 0x%x\n", convert_counter); - // load upper 8 bits of convert interval + /* load upper 8 bits of convert interval */ writew((convert_counter >> 16) & 0xff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); - // load lower 16 bits of scan delay + /* load lower 16 bits of scan delay */ writew(scan_counter & 0xffff, priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG); - // load upper 8 bits of scan delay + /* load upper 8 bits of scan delay */ writew((scan_counter >> 16) & 0xff, priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG); DEBUG_PRINT("scan counter 0x%x\n", scan_counter); } -static int use_internal_queue_6xxx(const struct comedi_cmd * cmd) +static int use_internal_queue_6xxx(const struct comedi_cmd *cmd) { int i; for (i = 0; i + 1 < cmd->chanlist_len; i++) { @@ -2552,7 +2547,7 @@ static int use_internal_queue_6xxx(const struct comedi_cmd * cmd) return 1; } -static int setup_channel_queue(struct comedi_device * dev, const struct comedi_cmd * cmd) +static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cmd *cmd) { unsigned short bits; int i; @@ -2563,25 +2558,25 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c writew(priv(dev)->hw_config_bits, priv(dev)->main_iobase + HW_CONFIG_REG); bits = 0; - // set channel + /* set channel */ bits |= adc_chan_bits(CR_CHAN(cmd->chanlist[0])); - // set gain + /* set gain */ bits |= ai_range_bits_6xxx(dev, CR_RANGE(cmd->chanlist[0])); - // set single-ended / differential + /* set single-ended / differential */ bits |= se_diff_bit_6xxx(dev, CR_AREF(cmd->chanlist[0]) == AREF_DIFF); if (CR_AREF(cmd->chanlist[0]) == AREF_COMMON) bits |= ADC_COMMON_BIT; - // set stop channel + /* set stop channel */ writew(adc_chan_bits(CR_CHAN(cmd->chanlist[cmd-> chanlist_len - 1])), priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); - // set start channel, and rest of settings + /* set start channel, and rest of settings */ writew(bits, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); } else { - // use external queue + /* use external queue */ if (dev->write_subdev && dev->write_subdev->busy) { warn_external_queue(dev); return -EBUSY; @@ -2589,26 +2584,26 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c priv(dev)->hw_config_bits |= EXT_QUEUE_BIT; writew(priv(dev)->hw_config_bits, priv(dev)->main_iobase + HW_CONFIG_REG); - // clear DAC buffer to prevent weird interactions + /* clear DAC buffer to prevent weird interactions */ writew(0, priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG); - // clear queue pointer + /* clear queue pointer */ writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG); - // load external queue + /* load external queue */ for (i = 0; i < cmd->chanlist_len; i++) { bits = 0; - // set channel + /* set channel */ bits |= adc_chan_bits(CR_CHAN(cmd-> chanlist[i])); - // set gain + /* set gain */ bits |= ai_range_bits_6xxx(dev, CR_RANGE(cmd->chanlist[i])); - // set single-ended / differential + /* set single-ended / differential */ bits |= se_diff_bit_6xxx(dev, CR_AREF(cmd->chanlist[i]) == AREF_DIFF); if (CR_AREF(cmd->chanlist[i]) == AREF_COMMON) bits |= ADC_COMMON_BIT; - // mark end of queue + /* mark end of queue */ if (i == cmd->chanlist_len - 1) bits |= QUEUE_EOSCAN_BIT | QUEUE_EOSEQ_BIT; @@ -2622,7 +2617,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c /* doing a queue clear is not specified in board docs, * but required for reliable operation */ writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG); - // prime queue holding register + /* prime queue holding register */ writew(0, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); } } else { @@ -2630,9 +2625,9 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c priv(dev)->i2c_cal_range_bits; priv(dev)->i2c_cal_range_bits &= ~ADC_SRC_4020_MASK; - //select BNC inputs + /* select BNC inputs */ priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4); - // select ranges + /* select ranges */ for (i = 0; i < cmd->chanlist_len; i++) { unsigned int channel = CR_CHAN(cmd->chanlist[i]); unsigned int range = CR_RANGE(cmd->chanlist[i]); @@ -2644,7 +2639,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c priv(dev)->i2c_cal_range_bits &= ~attenuate_bit(channel); } - // update calibration/range i2c register only if necessary, as it is very slow + /* update calibration/range i2c register only if necessary, as it is very slow */ if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) { uint8_t i2c_data = priv(dev)->i2c_cal_range_bits; i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data, @@ -2654,7 +2649,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c return 0; } -static inline void load_first_dma_descriptor(struct comedi_device * dev, +static inline void load_first_dma_descriptor(struct comedi_device *dev, unsigned int dma_channel, unsigned int descriptor_bits) { /* The transfer size, pci address, and local address registers @@ -2681,7 +2676,7 @@ static inline void load_first_dma_descriptor(struct comedi_device * dev, } } -static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -2697,7 +2692,7 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) if (retval < 0) return retval; - // make sure internal calibration source is turned off + /* make sure internal calibration source is turned off */ writew(0, priv(dev)->main_iobase + CALIBRATION_REG); set_ai_pacing(dev, cmd); @@ -2706,16 +2701,16 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) enable_ai_interrupts(dev, cmd); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); /* set mode, allow conversions through software gate */ priv(dev)->adc_control1_bits |= ADC_SW_GATE_BIT; priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT; if (board(dev)->layout != LAYOUT_4020) { priv(dev)->adc_control1_bits &= ~ADC_MODE_MASK; if (cmd->convert_src == TRIG_EXT) - priv(dev)->adc_control1_bits |= adc_mode_bits(13); // good old mode 13 + priv(dev)->adc_control1_bits |= adc_mode_bits(13); /* good old mode 13 */ else - priv(dev)->adc_control1_bits |= adc_mode_bits(8); // mode 8. What else could you need? + priv(dev)->adc_control1_bits |= adc_mode_bits(8); /* mode 8. What else could you need? */ } else { priv(dev)->adc_control1_bits &= ~CHANNEL_MODE_4020_MASK; if (cmd->chanlist_len == 4) @@ -2733,22 +2728,22 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) writew(priv(dev)->adc_control1_bits, priv(dev)->main_iobase + ADC_CONTROL1_REG); DEBUG_PRINT("control1 bits 0x%x\n", priv(dev)->adc_control1_bits); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // clear adc buffer + /* clear adc buffer */ writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG); if ((cmd->flags & TRIG_WAKE_EOS) == 0 || board(dev)->layout == LAYOUT_4020) { priv(dev)->ai_dma_index = 0; - // set dma transfer size + /* set dma transfer size */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) priv(dev)->ai_dma_desc[i].transfer_size = cpu_to_le32(dma_transfer_size(dev) * sizeof(uint16_t)); - // give location of first dma descriptor + /* give location of first dma descriptor */ load_first_dma_descriptor(dev, 1, priv(dev)-> ai_dma_desc_bus_addr | PLX_DESC_IN_PCI_BIT | @@ -2767,13 +2762,13 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) writew(bits, priv(dev)->main_iobase + DAQ_ATRIG_LOW_4020_REG); } - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); /* enable pacing, triggering, etc */ bits = ADC_ENABLE_BIT | ADC_SOFT_GATE_BITS | ADC_GATE_LEVEL_BIT; if (cmd->flags & TRIG_WAKE_EOS) bits |= ADC_DMA_DISABLE_BIT; - // set start trigger + /* set start trigger */ if (cmd->start_src == TRIG_EXT) { bits |= ADC_START_TRIG_EXT_BITS; if (cmd->start_arg & CR_INVERT) @@ -2787,9 +2782,9 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) priv(dev)->ai_cmd_running = 1; - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // start aquisition + /* start aquisition */ if (cmd->start_src == TRIG_NOW) { writew(0, priv(dev)->main_iobase + ADC_START_REG); DEBUG_PRINT("soft trig\n"); @@ -2798,8 +2793,8 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -// read num_samples from 16 bit wide ai fifo -static void pio_drain_ai_fifo_16(struct comedi_device * dev) +/* read num_samples from 16 bit wide ai fifo */ +static void pio_drain_ai_fifo_16(struct comedi_device *dev) { struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; @@ -2810,7 +2805,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev) int num_samples; do { - // get least significant 15 bits + /* get least significant 15 bits */ read_index = readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; @@ -2847,7 +2842,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev) } if (num_samples < 0) { - rt_printk(" cb_pcidas64: bug! num_samples < 0\n"); + printk(" cb_pcidas64: bug! num_samples < 0\n"); break; } @@ -2866,7 +2861,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev) * dma transfers (it only supports the use of pio for draining the last remaining * points from the fifo when a data aquisition operation has completed). */ -static void pio_drain_ai_fifo_32(struct comedi_device * dev) +static void pio_drain_ai_fifo_32(struct comedi_device *dev) { struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; @@ -2899,8 +2894,8 @@ static void pio_drain_ai_fifo_32(struct comedi_device * dev) priv(dev)->ai_count -= i; } -// empty fifo -static void pio_drain_ai_fifo(struct comedi_device * dev) +/* empty fifo */ +static void pio_drain_ai_fifo(struct comedi_device *dev) { if (board(dev)->layout == LAYOUT_4020) { pio_drain_ai_fifo_32(dev); @@ -2908,7 +2903,7 @@ static void pio_drain_ai_fifo(struct comedi_device * dev) pio_drain_ai_fifo_16(dev); } -static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) +static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) { struct comedi_async *async = dev->read_subdev->async; uint32_t next_transfer_addr; @@ -2923,7 +2918,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) pci_addr_reg = priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; - // loop until we have read all the full buffers + /* loop until we have read all the full buffers */ for (j = 0, next_transfer_addr = readl(pci_addr_reg); (next_transfer_addr < priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] @@ -2931,7 +2926,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] + DMA_BUFFER_SIZE) && j < ai_dma_ring_count(board(dev)); j++) { - // transfer data from dma buffer to comedi buffer + /* transfer data from dma buffer to comedi buffer */ num_samples = dma_transfer_size(dev); if (async->cmd.stop_src == TRIG_COUNT) { if (num_samples > priv(dev)->ai_count) @@ -2954,7 +2949,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) * unused buffer) */ } -void handle_ai_interrupt(struct comedi_device * dev, unsigned short status, +void handle_ai_interrupt(struct comedi_device *dev, unsigned short status, unsigned int plx_status) { struct comedi_subdevice *s = dev->read_subdev; @@ -2963,15 +2958,15 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status, uint8_t dma1_status; unsigned long flags; - // check for fifo overrun + /* check for fifo overrun */ if (status & ADC_OVERRUN_BIT) { comedi_error(dev, "fifo overrun"); async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; } - // spin lock makes sure noone else changes plx dma control reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spin lock makes sure noone else changes plx dma control reg */ + spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); - if (plx_status & ICS_DMA1_A) { // dma chan 1 interrupt + if (plx_status & ICS_DMA1_A) { /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); DEBUG_PRINT("dma1 status 0x%x\n", dma1_status); @@ -2981,25 +2976,25 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status, } DEBUG_PRINT(" cleared dma ch1 interrupt\n"); } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); if (status & ADC_DONE_BIT) DEBUG_PRINT("adc done interrupt\n"); - // drain fifo with pio + /* drain fifo with pio */ if ((status & ADC_DONE_BIT) || ((cmd->flags & TRIG_WAKE_EOS) && (status & ADC_INTR_PENDING_BIT) && (board(dev)->layout != LAYOUT_4020))) { DEBUG_PRINT("pio fifo drain\n"); - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); if (priv(dev)->ai_cmd_running) { - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); pio_drain_ai_fifo(dev); } else - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } - // if we are have all the data, then quit + /* if we are have all the data, then quit */ if ((cmd->stop_src == TRIG_COUNT && priv(dev)->ai_count <= 0) || (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) { async->events |= COMEDI_CB_EOA; @@ -3008,7 +3003,7 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status, cfc_handle_events(dev, s); } -static inline unsigned int prev_ao_dma_index(struct comedi_device * dev) +static inline unsigned int prev_ao_dma_index(struct comedi_device *dev) { unsigned int buffer_index; @@ -3019,7 +3014,7 @@ static inline unsigned int prev_ao_dma_index(struct comedi_device * dev) return buffer_index; } -static int last_ao_dma_load_completed(struct comedi_device * dev) +static int last_ao_dma_load_completed(struct comedi_device *dev) { unsigned int buffer_index; unsigned int transfer_address; @@ -3038,7 +3033,7 @@ static int last_ao_dma_load_completed(struct comedi_device * dev) return 1; } -static int ao_stopped_by_error(struct comedi_device * dev, const struct comedi_cmd * cmd) +static int ao_stopped_by_error(struct comedi_device *dev, const struct comedi_cmd *cmd) { if (cmd->stop_src == TRIG_NONE) return 1; @@ -3051,7 +3046,7 @@ static int ao_stopped_by_error(struct comedi_device * dev, const struct comedi_c return 0; } -static inline int ao_dma_needs_restart(struct comedi_device * dev, +static inline int ao_dma_needs_restart(struct comedi_device *dev, unsigned short dma_status) { if ((dma_status & PLX_DMA_DONE_BIT) == 0 || @@ -3063,7 +3058,7 @@ static inline int ao_dma_needs_restart(struct comedi_device * dev, return 1; } -static void restart_ao_dma(struct comedi_device * dev) +static void restart_ao_dma(struct comedi_device *dev) { unsigned int dma_desc_bits; @@ -3076,7 +3071,7 @@ static void restart_ao_dma(struct comedi_device * dev) dma_start_sync(dev, 0); } -static void handle_ao_interrupt(struct comedi_device * dev, unsigned short status, +static void handle_ao_interrupt(struct comedi_device *dev, unsigned short status, unsigned int plx_status) { struct comedi_subdevice *s = dev->write_subdev; @@ -3091,10 +3086,10 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu async = s->async; cmd = &async->cmd; - // spin lock makes sure noone else changes plx dma control reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spin lock makes sure noone else changes plx dma control reg */ + spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); - if (plx_status & ICS_DMA0_A) { // dma chan 0 interrupt + if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ if ((dma0_status & PLX_DMA_EN_BIT) && !(dma0_status & PLX_DMA_DONE_BIT)) writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT, @@ -3102,7 +3097,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu else writeb(PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); DEBUG_PRINT("dma0 status 0x%x\n", dma0_status); if (dma0_status & PLX_DMA_EN_BIT) { load_ao_dma(dev, cmd); @@ -3112,7 +3107,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu } DEBUG_PRINT(" cleared dma ch0 interrupt\n"); } else - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); if ((status & DAC_DONE_BIT)) { async->events |= COMEDI_CB_EOA; @@ -3128,7 +3123,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu cfc_handle_events(dev, s); } -static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t handle_interrupt(int irq, void *d) { struct comedi_device *dev = d; unsigned short status; @@ -3152,8 +3147,8 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) handle_ai_interrupt(dev, status, plx_status); handle_ao_interrupt(dev, status, plx_status); - // clear possible plx9080 interrupt sources - if (plx_status & ICS_LDIA) { // clear local doorbell interrupt + /* clear possible plx9080 interrupt sources */ + if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ plx_bits = readl(priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG); writel(plx_bits, priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG); DEBUG_PRINT(" cleared local doorbell bits 0x%x\n", plx_bits); @@ -3164,29 +3159,29 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -void abort_dma(struct comedi_device * dev, unsigned int channel) +void abort_dma(struct comedi_device *dev, unsigned int channel) { unsigned long flags; - // spinlock for plx dma control/status reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spinlock for plx dma control/status reg */ + spin_lock_irqsave(&dev->spinlock, flags); plx9080_abort_dma(priv(dev)->plx9080_iobase, channel); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } -static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); if (priv(dev)->ai_cmd_running == 0) { - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } priv(dev)->ai_cmd_running = 0; - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); disable_ai_pacing(dev); @@ -3196,21 +3191,21 @@ static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int range = CR_RANGE(insn->chanspec); - // do some initializing + /* do some initializing */ writew(0, priv(dev)->main_iobase + DAC_CONTROL0_REG); - // set range + /* set range */ set_dac_range_bits(dev, &priv(dev)->dac_control1_bits, chan, range); writew(priv(dev)->dac_control1_bits, priv(dev)->main_iobase + DAC_CONTROL1_REG); - // write to channel + /* write to channel */ if (board(dev)->layout == LAYOUT_4020) { writew(data[0] & 0xff, priv(dev)->main_iobase + dac_lsb_4020_reg(chan)); @@ -3220,21 +3215,21 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, writew(data[0], priv(dev)->main_iobase + dac_convert_reg(chan)); } - // remember output value + /* remember output value */ priv(dev)->ao_value[chan] = data[0]; return 1; } -static int ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = priv(dev)->ao_value[CR_CHAN(insn->chanspec)]; return 1; } -static void set_dac_control0_reg(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void set_dac_control0_reg(struct comedi_device *dev, const struct comedi_cmd *cmd) { unsigned int bits = DAC_ENABLE_BIT | WAVEFORM_GATE_LEVEL_BIT | WAVEFORM_GATE_ENABLE_BIT | WAVEFORM_GATE_SELECT_BIT; @@ -3254,7 +3249,7 @@ static void set_dac_control0_reg(struct comedi_device * dev, const struct comedi writew(bits, priv(dev)->main_iobase + DAC_CONTROL0_REG); } -static void set_dac_control1_reg(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void set_dac_control1_reg(struct comedi_device *dev, const struct comedi_cmd *cmd) { int i; @@ -3271,7 +3266,7 @@ static void set_dac_control1_reg(struct comedi_device * dev, const struct comedi priv(dev)->main_iobase + DAC_CONTROL1_REG); } -static void set_dac_select_reg(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void set_dac_select_reg(struct comedi_device *dev, const struct comedi_cmd *cmd) { uint16_t bits; unsigned int first_channel, last_channel; @@ -3286,7 +3281,7 @@ static void set_dac_select_reg(struct comedi_device * dev, const struct comedi_c writew(bits, priv(dev)->main_iobase + DAC_SELECT_REG); } -static void set_dac_interval_regs(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void set_dac_interval_regs(struct comedi_device *dev, const struct comedi_cmd *cmd) { unsigned int divisor; @@ -3304,8 +3299,8 @@ static void set_dac_interval_regs(struct comedi_device * dev, const struct comed priv(dev)->main_iobase + DAC_SAMPLE_INTERVAL_UPPER_REG); } -static unsigned int load_ao_dma_buffer(struct comedi_device * dev, - const struct comedi_cmd * cmd) +static unsigned int load_ao_dma_buffer(struct comedi_device *dev, + const struct comedi_cmd *cmd) { unsigned int num_bytes, buffer_index, prev_buffer_index; unsigned int next_bits; @@ -3348,7 +3343,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device * dev, return num_bytes; } -static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd) +static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) { unsigned int num_bytes; unsigned int next_transfer_addr; @@ -3370,7 +3365,7 @@ static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cm } while (num_bytes >= DMA_BUFFER_SIZE); } -static int prep_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd) +static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) { unsigned int num_bytes; int i; @@ -3404,7 +3399,7 @@ static int prep_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd return 0; } -static inline int external_ai_queue_in_use(struct comedi_device * dev) +static inline int external_ai_queue_in_use(struct comedi_device *dev) { if (dev->read_subdev->busy) return 0; @@ -3415,7 +3410,7 @@ static inline int external_ai_queue_in_use(struct comedi_device * dev) return 1; } -static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; @@ -3440,7 +3435,7 @@ static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { struct comedi_cmd *cmd = &s->async->cmd; @@ -3463,8 +3458,8 @@ static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, return 0; } -static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -3503,14 +3498,14 @@ static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, /* step 2: make sure trigger sources are unique and mutually compatible */ - // uniqueness check + /* uniqueness check */ if (cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) err++; if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) err++; - // compatibility check + /* compatibility check */ if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER) err++; if (cmd->stop_src != TRIG_COUNT && @@ -3579,7 +3574,7 @@ static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, return 0; } -static int ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { writew(0x0, priv(dev)->main_iobase + DAC_CONTROL0_REG); abort_dma(dev, 0); @@ -3607,8 +3602,8 @@ static int dio_callback_4020(int dir, int port, int data, unsigned long iobase) } } -static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -3620,13 +3615,13 @@ static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, return 2; } -static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] &= 0xf; - // zero bits we are going to change + /* zero bits we are going to change */ s->state &= ~data[0]; - // set new bits + /* set new bits */ s->state |= data[0] & data[1]; writeb(s->state, priv(dev)->dio_counter_iobase + DO_REG); @@ -3636,8 +3631,8 @@ static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, return 2; } -static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; @@ -3663,8 +3658,8 @@ static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdev return 1; } -static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -3678,7 +3673,7 @@ static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static void caldac_write(struct comedi_device * dev, unsigned int channel, +static void caldac_write(struct comedi_device *dev, unsigned int channel, unsigned int value) { priv(dev)->caldac_state[channel] = value; @@ -3696,8 +3691,8 @@ static void caldac_write(struct comedi_device * dev, unsigned int channel, } } -static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel = CR_CHAN(insn->chanspec); @@ -3711,8 +3706,8 @@ static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int channel = CR_CHAN(insn->chanspec); @@ -3721,18 +3716,18 @@ static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * return 1; } -static void ad8402_write(struct comedi_device * dev, unsigned int channel, +static void ad8402_write(struct comedi_device *dev, unsigned int channel, unsigned int value) { static const int bitstream_length = 10; unsigned int bit, register_bits; unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff); - static const int ad8402_comedi_udelay = 1; + static const int ad8402_udelay = 1; priv(dev)->ad8402_state[channel] = value; register_bits = SELECT_8402_64XX_BIT; - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG); for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) { @@ -3740,20 +3735,20 @@ static void ad8402_write(struct comedi_device * dev, unsigned int channel, register_bits |= SERIAL_DATA_IN_BIT; else register_bits &= ~SERIAL_DATA_IN_BIT; - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG); - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); writew(register_bits | SERIAL_CLOCK_BIT, priv(dev)->main_iobase + CALIBRATION_REG); } - comedi_udelay(ad8402_comedi_udelay); + udelay(ad8402_udelay); writew(0, priv(dev)->main_iobase + CALIBRATION_REG); } /* for pci-das6402/16, channel 0 is analog input gain and channel 1 is offset */ -static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel = CR_CHAN(insn->chanspec); @@ -3769,8 +3764,8 @@ static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ad8402_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int channel = CR_CHAN(insn->chanspec); @@ -3779,7 +3774,7 @@ static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice return 1; } -static uint16_t read_eeprom(struct comedi_device * dev, uint8_t address) +static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) { static const int bitstream_length = 11; static const int read_command = 0x6; @@ -3789,60 +3784,60 @@ static uint16_t read_eeprom(struct comedi_device * dev, uint8_t address) priv(dev)->plx9080_iobase + PLX_CONTROL_REG; uint16_t value; static const int value_length = 16; - static const int eeprom_comedi_udelay = 1; + static const int eeprom_udelay = 1; - comedi_udelay(eeprom_comedi_udelay); + udelay(eeprom_udelay); priv(dev)->plx_control_bits &= ~CTL_EE_CLK & ~CTL_EE_CS; - // make sure we don't send anything to the i2c bus on 4020 + /* make sure we don't send anything to the i2c bus on 4020 */ priv(dev)->plx_control_bits |= CTL_USERO; writel(priv(dev)->plx_control_bits, plx_control_addr); - // activate serial eeprom - comedi_udelay(eeprom_comedi_udelay); + /* activate serial eeprom */ + udelay(eeprom_udelay); priv(dev)->plx_control_bits |= CTL_EE_CS; writel(priv(dev)->plx_control_bits, plx_control_addr); - // write read command and desired memory address + /* write read command and desired memory address */ for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) { - // set bit to be written - comedi_udelay(eeprom_comedi_udelay); + /* set bit to be written */ + udelay(eeprom_udelay); if (bitstream & bit) priv(dev)->plx_control_bits |= CTL_EE_W; else priv(dev)->plx_control_bits &= ~CTL_EE_W; writel(priv(dev)->plx_control_bits, plx_control_addr); - // clock in bit - comedi_udelay(eeprom_comedi_udelay); + /* clock in bit */ + udelay(eeprom_udelay); priv(dev)->plx_control_bits |= CTL_EE_CLK; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(eeprom_comedi_udelay); + udelay(eeprom_udelay); priv(dev)->plx_control_bits &= ~CTL_EE_CLK; writel(priv(dev)->plx_control_bits, plx_control_addr); } - // read back value from eeprom memory location + /* read back value from eeprom memory location */ value = 0; for (bit = 1 << (value_length - 1); bit; bit >>= 1) { - // clock out bit - comedi_udelay(eeprom_comedi_udelay); + /* clock out bit */ + udelay(eeprom_udelay); priv(dev)->plx_control_bits |= CTL_EE_CLK; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(eeprom_comedi_udelay); + udelay(eeprom_udelay); priv(dev)->plx_control_bits &= ~CTL_EE_CLK; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(eeprom_comedi_udelay); + udelay(eeprom_udelay); if (readl(plx_control_addr) & CTL_EE_R) value |= bit; } - // deactivate eeprom serial input - comedi_udelay(eeprom_comedi_udelay); + /* deactivate eeprom serial input */ + udelay(eeprom_udelay); priv(dev)->plx_control_bits &= ~CTL_EE_CS; writel(priv(dev)->plx_control_bits, plx_control_addr); return value; } -static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = read_eeprom(dev, CR_CHAN(insn->chanspec)); @@ -3880,7 +3875,7 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) if (cmd->scan_begin_src == TRIG_TIMER) { scan_divisor = get_divisor(cmd->scan_begin_arg, cmd->flags); if (cmd->convert_src == TRIG_TIMER) { - // XXX check for integer overflows + /* XXX check for integer overflows */ min_scan_divisor = convert_divisor * cmd->chanlist_len; max_scan_divisor = (convert_divisor * cmd->chanlist_len - 1) + @@ -3926,8 +3921,8 @@ static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags) return get_divisor(ns, flags) - 2; } -// adjusts the size of hardware fifo (which determines block size for dma xfers) -static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples) +/* adjusts the size of hardware fifo (which determines block size for dma xfers) */ +static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples) { unsigned int num_fifo_entries; int retval; @@ -3947,15 +3942,15 @@ static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples return num_samples; } -// query length of fifo -static unsigned int ai_fifo_size(struct comedi_device * dev) +/* query length of fifo */ +static unsigned int ai_fifo_size(struct comedi_device *dev) { return priv(dev)->ai_fifo_segment_length * board(dev)->ai_fifo->num_segments * board(dev)->ai_fifo->sample_packing_ratio; } -static int set_ai_fifo_segment_length(struct comedi_device * dev, +static int set_ai_fifo_segment_length(struct comedi_device *dev, unsigned int num_entries) { static const int increment_size = 0x100; @@ -3968,7 +3963,7 @@ static int set_ai_fifo_segment_length(struct comedi_device * dev, if (num_entries > fifo->max_segment_length) num_entries = fifo->max_segment_length; - // 1 == 256 entries, 2 == 512 entries, etc + /* 1 == 256 entries, 2 == 512 entries, etc */ num_increments = (num_entries + increment_size / 2) / increment_size; bits = (~(num_increments - 1)) & fifo->fifo_size_reg_mask; @@ -4006,7 +4001,7 @@ static int set_ai_fifo_segment_length(struct comedi_device * dev, * address 7 == dac channel 1 fine offset */ -static int caldac_8800_write(struct comedi_device * dev, unsigned int address, +static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value) { static const int num_caldac_channels = 8; @@ -4023,28 +4018,28 @@ static int caldac_8800_write(struct comedi_device * dev, unsigned int address, register_bits = 0; if (bitstream & bit) register_bits |= SERIAL_DATA_IN_BIT; - comedi_udelay(caldac_8800_udelay); + udelay(caldac_8800_udelay); writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG); register_bits |= SERIAL_CLOCK_BIT; - comedi_udelay(caldac_8800_udelay); + udelay(caldac_8800_udelay); writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG); } - comedi_udelay(caldac_8800_udelay); + udelay(caldac_8800_udelay); writew(SELECT_8800_BIT, priv(dev)->main_iobase + CALIBRATION_REG); - comedi_udelay(caldac_8800_udelay); + udelay(caldac_8800_udelay); writew(0, priv(dev)->main_iobase + CALIBRATION_REG); - comedi_udelay(caldac_8800_udelay); + udelay(caldac_8800_udelay); return 0; } -// 4020 caldacs -static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_channel, +/* 4020 caldacs */ +static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel, unsigned int value) { uint8_t serial_bytes[3]; uint8_t i2c_addr; enum pointer_bits { - // manual has gain and offset bits switched + /* manual has gain and offset bits switched */ OFFSET_0_2 = 0x1, GAIN_0_2 = 0x2, OFFSET_1_3 = 0x4, @@ -4055,35 +4050,35 @@ static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_chan }; switch (caldac_channel) { - case 0: // chan 0 offset + case 0: /* chan 0 offset */ i2c_addr = CALDAC0_I2C_ADDR; serial_bytes[0] = OFFSET_0_2; break; - case 1: // chan 1 offset + case 1: /* chan 1 offset */ i2c_addr = CALDAC0_I2C_ADDR; serial_bytes[0] = OFFSET_1_3; break; - case 2: // chan 2 offset + case 2: /* chan 2 offset */ i2c_addr = CALDAC1_I2C_ADDR; serial_bytes[0] = OFFSET_0_2; break; - case 3: // chan 3 offset + case 3: /* chan 3 offset */ i2c_addr = CALDAC1_I2C_ADDR; serial_bytes[0] = OFFSET_1_3; break; - case 4: // chan 0 gain + case 4: /* chan 0 gain */ i2c_addr = CALDAC0_I2C_ADDR; serial_bytes[0] = GAIN_0_2; break; - case 5: // chan 1 gain + case 5: /* chan 1 gain */ i2c_addr = CALDAC0_I2C_ADDR; serial_bytes[0] = GAIN_1_3; break; - case 6: // chan 2 gain + case 6: /* chan 2 gain */ i2c_addr = CALDAC1_I2C_ADDR; serial_bytes[0] = GAIN_0_2; break; - case 7: // chan 3 gain + case 7: /* chan 3 gain */ i2c_addr = CALDAC1_I2C_ADDR; serial_bytes[0] = GAIN_1_3; break; @@ -4098,49 +4093,49 @@ static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_chan return 0; } -// Their i2c requires a huge delay on setting clock or data high for some reason -static const int i2c_high_comedi_udelay = 1000; -static const int i2c_low_comedi_udelay = 10; +/* Their i2c requires a huge delay on setting clock or data high for some reason */ +static const int i2c_high_udelay = 1000; +static const int i2c_low_udelay = 10; -// set i2c data line high or low -static void i2c_set_sda(struct comedi_device * dev, int state) +/* set i2c data line high or low */ +static void i2c_set_sda(struct comedi_device *dev, int state) { static const int data_bit = CTL_EE_W; void *plx_control_addr = priv(dev)->plx9080_iobase + PLX_CONTROL_REG; if (state) { - // set data line high + /* set data line high */ priv(dev)->plx_control_bits &= ~data_bit; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(i2c_high_comedi_udelay); - } else // set data line low + udelay(i2c_high_udelay); + } else /* set data line low */ { priv(dev)->plx_control_bits |= data_bit; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(i2c_low_comedi_udelay); + udelay(i2c_low_udelay); } } -// set i2c clock line high or low -static void i2c_set_scl(struct comedi_device * dev, int state) +/* set i2c clock line high or low */ +static void i2c_set_scl(struct comedi_device *dev, int state) { static const int clock_bit = CTL_USERO; void *plx_control_addr = priv(dev)->plx9080_iobase + PLX_CONTROL_REG; if (state) { - // set clock line high + /* set clock line high */ priv(dev)->plx_control_bits &= ~clock_bit; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(i2c_high_comedi_udelay); - } else // set clock line low + udelay(i2c_high_udelay); + } else /* set clock line low */ { priv(dev)->plx_control_bits |= clock_bit; writel(priv(dev)->plx_control_bits, plx_control_addr); - comedi_udelay(i2c_low_comedi_udelay); + udelay(i2c_low_udelay); } } -static void i2c_write_byte(struct comedi_device * dev, uint8_t byte) +static void i2c_write_byte(struct comedi_device *dev, uint8_t byte) { uint8_t bit; unsigned int num_bits = 8; @@ -4157,26 +4152,26 @@ static void i2c_write_byte(struct comedi_device * dev, uint8_t byte) } } -// we can't really read the lines, so fake it -static int i2c_read_ack(struct comedi_device * dev) +/* we can't really read the lines, so fake it */ +static int i2c_read_ack(struct comedi_device *dev) { i2c_set_scl(dev, 0); i2c_set_sda(dev, 1); i2c_set_scl(dev, 1); - return 0; // return fake acknowledge bit + return 0; /* return fake acknowledge bit */ } -// send start bit -static void i2c_start(struct comedi_device * dev) +/* send start bit */ +static void i2c_start(struct comedi_device *dev) { i2c_set_scl(dev, 1); i2c_set_sda(dev, 1); i2c_set_sda(dev, 0); } -// send stop bit -static void i2c_stop(struct comedi_device * dev) +/* send stop bit */ +static void i2c_stop(struct comedi_device *dev) { i2c_set_scl(dev, 0); i2c_set_sda(dev, 0); @@ -4184,32 +4179,32 @@ static void i2c_stop(struct comedi_device * dev) i2c_set_sda(dev, 1); } -static void i2c_write(struct comedi_device * dev, unsigned int address, - const uint8_t * data, unsigned int length) +static void i2c_write(struct comedi_device *dev, unsigned int address, + const uint8_t *data, unsigned int length) { unsigned int i; uint8_t bitstream; static const int read_bit = 0x1; -//XXX need mutex to prevent simultaneous attempts to access eeprom and i2c bus +/* XXX need mutex to prevent simultaneous attempts to access eeprom and i2c bus */ - // make sure we dont send anything to eeprom + /* make sure we dont send anything to eeprom */ priv(dev)->plx_control_bits &= ~CTL_EE_CS; i2c_stop(dev); i2c_start(dev); - // send address and write bit + /* send address and write bit */ bitstream = (address << 1) & ~read_bit; i2c_write_byte(dev, bitstream); - // get acknowledge + /* get acknowledge */ if (i2c_read_ack(dev) != 0) { comedi_error(dev, "i2c write failed: no acknowledge"); i2c_stop(dev); return; } - // write data bytes + /* write data bytes */ for (i = 0; i < length; i++) { i2c_write_byte(dev, data[i]); if (i2c_read_ack(dev) != 0) { diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index ed0a5eb3dd91..8f3629416188 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -51,66 +51,66 @@ Please report success/failure with other different cards to #include "comedi_pci.h" #include "8255.h" -#define PCI_VENDOR_ID_CB 0x1307 // PCI vendor number of ComputerBoards -#define N_BOARDS 10 // Number of boards in cb_pcidda_boards -#define EEPROM_SIZE 128 // number of entries in eeprom -#define MAX_AO_CHANNELS 8 // maximum number of ao channels for supported boards +#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */ +#define N_BOARDS 10 /* Number of boards in cb_pcidda_boards */ +#define EEPROM_SIZE 128 /* number of entries in eeprom */ +#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */ /* PCI-DDA base addresses */ #define DIGITALIO_BADRINDEX 2 - // DIGITAL I/O is pci_dev->resource[2] + /* DIGITAL I/O is pci_dev->resource[2] */ #define DIGITALIO_SIZE 8 - // DIGITAL I/O uses 8 I/O port addresses + /* DIGITAL I/O uses 8 I/O port addresses */ #define DAC_BADRINDEX 3 - // DAC is pci_dev->resource[3] + /* DAC is pci_dev->resource[3] */ /* Digital I/O registers */ -#define PORT1A 0 // PORT 1A DATA +#define PORT1A 0 /* PORT 1A DATA */ -#define PORT1B 1 // PORT 1B DATA +#define PORT1B 1 /* PORT 1B DATA */ -#define PORT1C 2 // PORT 1C DATA +#define PORT1C 2 /* PORT 1C DATA */ -#define CONTROL1 3 // CONTROL REGISTER 1 +#define CONTROL1 3 /* CONTROL REGISTER 1 */ -#define PORT2A 4 // PORT 2A DATA +#define PORT2A 4 /* PORT 2A DATA */ -#define PORT2B 5 // PORT 2B DATA +#define PORT2B 5 /* PORT 2B DATA */ -#define PORT2C 6 // PORT 2C DATA +#define PORT2C 6 /* PORT 2C DATA */ -#define CONTROL2 7 // CONTROL REGISTER 2 +#define CONTROL2 7 /* CONTROL REGISTER 2 */ /* DAC registers */ -#define DACONTROL 0 // D/A CONTROL REGISTER -#define SU 0000001 // Simultaneous update enabled -#define NOSU 0000000 // Simultaneous update disabled -#define ENABLEDAC 0000002 // Enable specified DAC -#define DISABLEDAC 0000000 // Disable specified DAC -#define RANGE2V5 0000000 // 2.5V -#define RANGE5V 0000200 // 5V -#define RANGE10V 0000300 // 10V -#define UNIP 0000400 // Unipolar outputs -#define BIP 0000000 // Bipolar outputs - -#define DACALIBRATION1 4 // D/A CALIBRATION REGISTER 1 -//write bits -#define SERIAL_IN_BIT 0x1 // serial data input for eeprom, caldacs, reference dac +#define DACONTROL 0 /* D/A CONTROL REGISTER */ +#define SU 0000001 /* Simultaneous update enabled */ +#define NOSU 0000000 /* Simultaneous update disabled */ +#define ENABLEDAC 0000002 /* Enable specified DAC */ +#define DISABLEDAC 0000000 /* Disable specified DAC */ +#define RANGE2V5 0000000 /* 2.5V */ +#define RANGE5V 0000200 /* 5V */ +#define RANGE10V 0000300 /* 10V */ +#define UNIP 0000400 /* Unipolar outputs */ +#define BIP 0000000 /* Bipolar outputs */ + +#define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */ +/* write bits */ +#define SERIAL_IN_BIT 0x1 /* serial data input for eeprom, caldacs, reference dac */ #define CAL_CHANNEL_MASK (0x7 << 1) #define CAL_CHANNEL_BITS(channel) (((channel) << 1) & CAL_CHANNEL_MASK) -//read bits +/* read bits */ #define CAL_COUNTER_MASK 0x1f -#define CAL_COUNTER_OVERFLOW_BIT 0x20 // calibration counter overflow status bit -#define AO_BELOW_REF_BIT 0x40 // analog output is less than reference dac voltage -#define SERIAL_OUT_BIT 0x80 // serial data out, for reading from eeprom +#define CAL_COUNTER_OVERFLOW_BIT 0x20 /* calibration counter overflow status bit */ +#define AO_BELOW_REF_BIT 0x40 /* analog output is less than reference dac voltage */ +#define SERIAL_OUT_BIT 0x80 /* serial data out, for reading from eeprom */ -#define DACALIBRATION2 6 // D/A CALIBRATION REGISTER 2 -#define SELECT_EEPROM_BIT 0x1 // send serial data in to eeprom -#define DESELECT_REF_DAC_BIT 0x2 // don't send serial data to MAX542 reference dac -#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) // don't send serial data to caldac n -#define DUMMY_BIT 0x40 // manual says to set this bit with no explanation +#define DACALIBRATION2 6 /* D/A CALIBRATION REGISTER 2 */ +#define SELECT_EEPROM_BIT 0x1 /* send serial data in to eeprom */ +#define DESELECT_REF_DAC_BIT 0x2 /* don't send serial data to MAX542 reference dac */ +#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) /* don't send serial data to caldac n */ +#define DUMMY_BIT 0x40 /* manual says to set this bit with no explanation */ -#define DADATA 8 // FIRST D/A DATA REGISTER (0) +#define DADATA 8 /* FIRST D/A DATA REGISTER (0) */ static const struct comedi_lrange cb_pcidda_ranges = { 6, @@ -131,63 +131,68 @@ static const struct comedi_lrange cb_pcidda_ranges = { */ struct cb_pcidda_board { const char *name; - char status; // Driver status: - // 0 - tested - // 1 - manual read, not tested - // 2 - manual not read + char status; /* Driver status: */ + + /* + * 0 - tested + * 1 - manual read, not tested + * 2 - manual not read + */ + unsigned short device_id; int ao_chans; int ao_bits; const struct comedi_lrange *ranges; }; + static const struct cb_pcidda_board cb_pcidda_boards[] = { { - name: "pci-dda02/12", - status: 1, - device_id:0x20, - ao_chans:2, - ao_bits: 12, - ranges: &cb_pcidda_ranges, + .name = "pci-dda02/12", + .status = 1, + .device_id = 0x20, + .ao_chans = 2, + .ao_bits = 12, + .ranges = &cb_pcidda_ranges, }, { - name: "pci-dda04/12", - status: 1, - device_id:0x21, - ao_chans:4, - ao_bits: 12, - ranges: &cb_pcidda_ranges, + .name = "pci-dda04/12", + .status = 1, + .device_id = 0x21, + .ao_chans = 4, + .ao_bits = 12, + .ranges = &cb_pcidda_ranges, }, { - name: "pci-dda08/12", - status: 0, - device_id:0x22, - ao_chans:8, - ao_bits: 12, - ranges: &cb_pcidda_ranges, + .name = "pci-dda08/12", + .status = 0, + .device_id = 0x22, + .ao_chans = 8, + .ao_bits = 12, + .ranges = &cb_pcidda_ranges, }, { - name: "pci-dda02/16", - status: 2, - device_id:0x23, - ao_chans:2, - ao_bits: 16, - ranges: &cb_pcidda_ranges, + .name = "pci-dda02/16", + .status = 2, + .device_id = 0x23, + .ao_chans = 2, + .ao_bits = 16, + .ranges = &cb_pcidda_ranges, }, { - name: "pci-dda04/16", - status: 2, - device_id:0x24, - ao_chans:4, - ao_bits: 16, - ranges: &cb_pcidda_ranges, + .name = "pci-dda04/16", + .status = 2, + .device_id = 0x24, + .ao_chans = 4, + .ao_bits = 16, + .ranges = &cb_pcidda_ranges, }, { - name: "pci-dda08/16", - status: 0, - device_id:0x25, - ao_chans:8, - ao_bits: 16, - ranges: &cb_pcidda_ranges, + .name = "pci-dda08/16", + .status = 0, + .device_id = 0x25, + .ao_chans = 8, + .ao_bits = 16, + .ranges = &cb_pcidda_ranges, }, }; @@ -219,11 +224,13 @@ struct cb_pcidda_private { unsigned long digitalio; unsigned long dac; - //unsigned long control_status; - //unsigned long adc_fifo; - unsigned int dac_cal1_bits; // bits last written to da calibration register 1 - unsigned int ao_range[MAX_AO_CHANNELS]; // current range settings for output channels - u16 eeprom_data[EEPROM_SIZE]; // software copy of board's eeprom + + /* unsigned long control_status; */ + /* unsigned long adc_fifo; */ + + unsigned int dac_cal1_bits; /* bits last written to da calibration register 1 */ + unsigned int ao_range[MAX_AO_CHANNELS]; /* current range settings for output channels */ + u16 eeprom_data[EEPROM_SIZE]; /* software copy of board's eeprom */ }; /* @@ -232,20 +239,22 @@ struct cb_pcidda_private { */ #define devpriv ((struct cb_pcidda_private *)dev->private) -static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int cb_pcidda_detach(struct comedi_device * dev); -//static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); -static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -//static int cb_pcidda_ai_cmd(struct comedi_device *dev,struct comedi_subdevice *s); -//static int cb_pcidda_ai_cmdtest(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_cmd *cmd); -//static int cb_pcidda_ns_to_timer(unsigned int *ns,int round); -static unsigned int cb_pcidda_serial_in(struct comedi_device * dev); -static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value, +static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int cb_pcidda_detach(struct comedi_device *dev); +/* static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */ +static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +/* static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct *comedi_subdevice *s);*/ +/* static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); */ +/* static int cb_pcidda_ns_to_timer(unsigned int *ns,int *round); */ + +static unsigned int cb_pcidda_serial_in(struct comedi_device *dev); +static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value, unsigned int num_bits); -static unsigned int cb_pcidda_read_eeprom(struct comedi_device * dev, +static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev, unsigned int address); -static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel, +static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel, unsigned int range); /* @@ -255,17 +264,17 @@ static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel * the device code. */ static struct comedi_driver driver_cb_pcidda = { - driver_name:"cb_pcidda", - module:THIS_MODULE, - attach:cb_pcidda_attach, - detach:cb_pcidda_detach, + .driver_name = "cb_pcidda", + .module = THIS_MODULE, + .attach = cb_pcidda_attach, + .detach = cb_pcidda_detach, }; /* * Attach is called by the Comedi core to configure the driver * for a particular board. */ -static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; struct pci_dev *pcidev; @@ -310,7 +319,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig found: devpriv->pci_dev = pcidev; dev->board_ptr = cb_pcidda_boards + index; - // "thisboard" macro can be used from here. + /* "thisboard" macro can be used from here. */ printk("Found %s at requested position\n", thisboard->name); /* @@ -353,11 +362,12 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig s->maxdata = (1 << thisboard->ao_bits) - 1; s->range_table = thisboard->ranges; s->insn_write = cb_pcidda_ao_winsn; -// s->subdev_flags |= SDF_CMD_READ; -// s->do_cmd = cb_pcidda_ai_cmd; -// s->do_cmdtest = cb_pcidda_ai_cmdtest; - // two 8255 digital io subdevices + /* s->subdev_flags |= SDF_CMD_READ; */ + /* s->do_cmd = cb_pcidda_ai_cmd; */ + /* s->do_cmdtest = cb_pcidda_ai_cmdtest; */ + + /* two 8255 digital io subdevices */ s = dev->subdevices + 1; subdev_8255_init(dev, s, NULL, devpriv->digitalio); s = dev->subdevices + 2; @@ -370,7 +380,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig } printk("\n"); - // set calibrations dacs + /* set calibrations dacs */ for (index = 0; index < thisboard->ao_chans; index++) cb_pcidda_calibrate(dev, index, devpriv->ao_range[index]); @@ -385,7 +395,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int cb_pcidda_detach(struct comedi_device * dev) +static int cb_pcidda_detach(struct comedi_device *dev) { /* * Deallocate the I/O ports. @@ -398,7 +408,7 @@ static int cb_pcidda_detach(struct comedi_device * dev) pci_dev_put(devpriv->pci_dev); } } - // cleanup 8255 + /* cleanup 8255 */ if (dev->subdevices) { subdev_8255_cleanup(dev, dev->subdevices + 1); subdev_8255_cleanup(dev, dev->subdevices + 2); @@ -413,7 +423,7 @@ static int cb_pcidda_detach(struct comedi_device * dev) * I will program this later... ;-) */ #if 0 -static int cb_pcidda_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { printk("cb_pcidda_ai_cmd\n"); printk("subdev: %d\n", cmd->subdev); @@ -432,8 +442,8 @@ static int cb_pcidda_ai_cmd(struct comedi_device * dev, struct comedi_subdevice #endif #if 0 -static int cb_pcidda_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -598,8 +608,8 @@ static int cb_pcidda_ns_to_timer(unsigned int *ns, int round) } #endif -static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int command; unsigned int channel, range; @@ -607,7 +617,7 @@ static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevic channel = CR_CHAN(insn->chanspec); range = CR_RANGE(insn->chanspec); - // adjust calibration dacs if range has changed + /* adjust calibration dacs if range has changed */ if (range != devpriv->ao_range[channel]) cb_pcidda_calibrate(dev, channel, range); @@ -647,15 +657,15 @@ static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevic return 1; } -// lowlevel read from eeprom -static unsigned int cb_pcidda_serial_in(struct comedi_device * dev) +/* lowlevel read from eeprom */ +static unsigned int cb_pcidda_serial_in(struct comedi_device *dev) { unsigned int value = 0; int i; - const int value_width = 16; // number of bits wide values are + const int value_width = 16; /* number of bits wide values are */ for (i = 1; i <= value_width; i++) { - // read bits most significant bit first + /* read bits most significant bit first */ if (inw_p(devpriv->dac + DACALIBRATION1) & SERIAL_OUT_BIT) { value |= 1 << (value_width - i); } @@ -664,14 +674,14 @@ static unsigned int cb_pcidda_serial_in(struct comedi_device * dev) return value; } -// lowlevel write to eeprom/dac -static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value, +/* lowlevel write to eeprom/dac */ +static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value, unsigned int num_bits) { int i; for (i = 1; i <= num_bits; i++) { - // send bits most significant bit first + /* send bits most significant bit first */ if (value & (1 << (num_bits - i))) devpriv->dac_cal1_bits |= SERIAL_IN_BIT; else @@ -680,136 +690,137 @@ static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value, } } -// reads a 16 bit value from board's eeprom -static unsigned int cb_pcidda_read_eeprom(struct comedi_device * dev, +/* reads a 16 bit value from board's eeprom */ +static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev, unsigned int address) { unsigned int i; unsigned int cal2_bits; unsigned int value; - const int max_num_caldacs = 4; // one caldac for every two dac channels - const int read_instruction = 0x6; // bits to send to tell eeprom we want to read + const int max_num_caldacs = 4; /* one caldac for every two dac channels */ + const int read_instruction = 0x6; /* bits to send to tell eeprom we want to read */ const int instruction_length = 3; const int address_length = 8; - // send serial output stream to eeprom + /* send serial output stream to eeprom */ cal2_bits = SELECT_EEPROM_BIT | DESELECT_REF_DAC_BIT | DUMMY_BIT; - // deactivate caldacs (one caldac for every two channels) + /* deactivate caldacs (one caldac for every two channels) */ for (i = 0; i < max_num_caldacs; i++) { cal2_bits |= DESELECT_CALDAC_BIT(i); } outw_p(cal2_bits, devpriv->dac + DACALIBRATION2); - // tell eeprom we want to read + /* tell eeprom we want to read */ cb_pcidda_serial_out(dev, read_instruction, instruction_length); - // send address we want to read from + /* send address we want to read from */ cb_pcidda_serial_out(dev, address, address_length); value = cb_pcidda_serial_in(dev); - // deactivate eeprom + /* deactivate eeprom */ cal2_bits &= ~SELECT_EEPROM_BIT; outw_p(cal2_bits, devpriv->dac + DACALIBRATION2); return value; } -// writes to 8 bit calibration dacs -static void cb_pcidda_write_caldac(struct comedi_device * dev, unsigned int caldac, +/* writes to 8 bit calibration dacs */ +static void cb_pcidda_write_caldac(struct comedi_device *dev, unsigned int caldac, unsigned int channel, unsigned int value) { unsigned int cal2_bits; unsigned int i; - const int num_channel_bits = 3; // caldacs use 3 bit channel specification - const int num_caldac_bits = 8; // 8 bit calibration dacs - const int max_num_caldacs = 4; // one caldac for every two dac channels + const int num_channel_bits = 3; /* caldacs use 3 bit channel specification */ + const int num_caldac_bits = 8; /* 8 bit calibration dacs */ + const int max_num_caldacs = 4; /* one caldac for every two dac channels */ /* write 3 bit channel */ cb_pcidda_serial_out(dev, channel, num_channel_bits); - // write 8 bit caldac value + /* write 8 bit caldac value */ cb_pcidda_serial_out(dev, value, num_caldac_bits); - // latch stream into appropriate caldac - // deselect reference dac +/* +* latch stream into appropriate caldac deselect reference dac +*/ cal2_bits = DESELECT_REF_DAC_BIT | DUMMY_BIT; - // deactivate caldacs (one caldac for every two channels) + /* deactivate caldacs (one caldac for every two channels) */ for (i = 0; i < max_num_caldacs; i++) { cal2_bits |= DESELECT_CALDAC_BIT(i); } - // activate the caldac we want + /* activate the caldac we want */ cal2_bits &= ~DESELECT_CALDAC_BIT(caldac); outw_p(cal2_bits, devpriv->dac + DACALIBRATION2); - // deactivate caldac + /* deactivate caldac */ cal2_bits |= DESELECT_CALDAC_BIT(caldac); outw_p(cal2_bits, devpriv->dac + DACALIBRATION2); } -// returns caldac that calibrates given analog out channel +/* returns caldac that calibrates given analog out channel */ static unsigned int caldac_number(unsigned int channel) { return channel / 2; } -// returns caldac channel that provides fine gain for given ao channel +/* returns caldac channel that provides fine gain for given ao channel */ static unsigned int fine_gain_channel(unsigned int ao_channel) { return 4 * (ao_channel % 2); } -// returns caldac channel that provides coarse gain for given ao channel +/* returns caldac channel that provides coarse gain for given ao channel */ static unsigned int coarse_gain_channel(unsigned int ao_channel) { return 1 + 4 * (ao_channel % 2); } -// returns caldac channel that provides coarse offset for given ao channel +/* returns caldac channel that provides coarse offset for given ao channel */ static unsigned int coarse_offset_channel(unsigned int ao_channel) { return 2 + 4 * (ao_channel % 2); } -// returns caldac channel that provides fine offset for given ao channel +/* returns caldac channel that provides fine offset for given ao channel */ static unsigned int fine_offset_channel(unsigned int ao_channel) { return 3 + 4 * (ao_channel % 2); } -// returns eeprom address that provides offset for given ao channel and range +/* returns eeprom address that provides offset for given ao channel and range */ static unsigned int offset_eeprom_address(unsigned int ao_channel, unsigned int range) { return 0x7 + 2 * range + 12 * ao_channel; } -// returns eeprom address that provides gain calibration for given ao channel and range +/* returns eeprom address that provides gain calibration for given ao channel and range */ static unsigned int gain_eeprom_address(unsigned int ao_channel, unsigned int range) { return 0x8 + 2 * range + 12 * ao_channel; } -// returns upper byte of eeprom entry, which gives the coarse adjustment values +/* returns upper byte of eeprom entry, which gives the coarse adjustment values */ static unsigned int eeprom_coarse_byte(unsigned int word) { return (word >> 8) & 0xff; } -// returns lower byte of eeprom entry, which gives the fine adjustment values +/* returns lower byte of eeprom entry, which gives the fine adjustment values */ static unsigned int eeprom_fine_byte(unsigned int word) { return word & 0xff; } -// set caldacs to eeprom values for given channel and range -static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel, +/* set caldacs to eeprom values for given channel and range */ +static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel, unsigned int range) { unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain; - // remember range so we can tell when we need to readjust calibration + /* remember range so we can tell when we need to readjust calibration */ devpriv->ao_range[channel] = range; - // get values from eeprom data + /* get values from eeprom data */ coarse_offset = eeprom_coarse_byte(devpriv-> eeprom_data[offset_eeprom_address(channel, range)]); @@ -823,7 +834,7 @@ static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel eeprom_fine_byte(devpriv-> eeprom_data[gain_eeprom_address(channel, range)]); - // set caldacs + /* set caldacs */ cb_pcidda_write_caldac(dev, caldac_number(channel), coarse_offset_channel(channel), coarse_offset); cb_pcidda_write_caldac(dev, caldac_number(channel), diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c index 71a4b1482e36..dc701273167c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidio.c +++ b/drivers/staging/comedi/drivers/cb_pcidio.c @@ -53,32 +53,32 @@ Passing a zero for an option is the same as leaving it unspecified. * Some drivers use arrays such as this, other do not. */ struct pcidio_board { - const char *name; // anme of the board - int n_8255; // number of 8255 chips on board + const char *name; /* anme of the board */ + int n_8255; /* number of 8255 chips on board */ - // indices of base address regions + /* indices of base address regions */ int pcicontroler_badrindex; int dioregs_badrindex; }; static const struct pcidio_board pcidio_boards[] = { { - name: "pci-dio24", - n_8255: 1, - pcicontroler_badrindex:1, - dioregs_badrindex:2, + .name = "pci-dio24", + .n_8255 = 1, + .pcicontroler_badrindex = 1, + .dioregs_badrindex = 2, }, { - name: "pci-dio24h", - n_8255: 1, - pcicontroler_badrindex:1, - dioregs_badrindex:2, + .name = "pci-dio24h", + .n_8255 = 1, + .pcicontroler_badrindex = 1, + .dioregs_badrindex = 2, }, { - name: "pci-dio48h", - n_8255: 2, - pcicontroler_badrindex:0, - dioregs_badrindex:1, + .name = "pci-dio48h", + .n_8255 = 2, + .pcicontroler_badrindex = 0, + .dioregs_badrindex = 1, }, }; @@ -104,7 +104,7 @@ MODULE_DEVICE_TABLE(pci, pcidio_pci_table); several hardware drivers keep similar information in this structure, feel free to suggest moving the variable to the struct comedi_device struct. */ struct pcidio_private { - int data; // curently unused + int data; /* curently unused */ /* would be useful for a PCI device */ struct pci_dev *pci_dev; @@ -112,7 +112,7 @@ struct pcidio_private { /* used for DO readback, curently unused */ unsigned int do_readback[4]; /* up to 4 unsigned int suffice to hold 96 bits for PCI-DIO96 */ - unsigned long dio_reg_base; // address of port A of the first 8255 chip on board + unsigned long dio_reg_base; /* address of port A of the first 8255 chip on board */ }; /* @@ -127,15 +127,17 @@ struct pcidio_private { * the board, and also about the kernel module that contains * the device code. */ -static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcidio_detach(struct comedi_device * dev); +static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcidio_detach(struct comedi_device *dev); static struct comedi_driver driver_cb_pcidio = { - driver_name:"cb_pcidio", - module:THIS_MODULE, - attach:pcidio_attach, - detach:pcidio_detach, + .driver_name = "cb_pcidio", + .module = THIS_MODULE, + .attach = pcidio_attach, + .detach = pcidio_detach, + /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ + /* Most drivers will support multiple types of boards by * having an array of board structures. These were defined * in pcidio_boards[] above. Note that the element 'name' @@ -152,10 +154,15 @@ static struct comedi_driver driver_cb_pcidio = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ -// The following fields should NOT be initialized if you are dealing with PCI devices -// board_name: pcidio_boards, -// offset: sizeof(struct pcidio_board), -// num_names: sizeof(pcidio_boards) / sizeof(struct pcidio_board), + +/* The following fields should NOT be initialized if you are dealing + * with PCI devices + * + * .board_name = pcidio_boards, + * .offset = sizeof(struct pcidio_board), + * .num_names = sizeof(pcidio_boards) / sizeof(structpcidio_board), + */ + }; /*------------------------------- FUNCTIONS -----------------------------------*/ @@ -166,7 +173,7 @@ static struct comedi_driver driver_cb_pcidio = { * in the driver structure, dev->board_ptr contains that * address. */ -static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev = NULL; int index; @@ -192,19 +199,19 @@ static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * i for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - // is it not a computer boards card? + /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_CB) continue; - // loop through cards supported by this driver + /* loop through cards supported by this driver */ for (index = 0; - index < sizeof pcidio_boards / sizeof(struct pcidio_board); + index < ARRAY_SIZE(pcidio_boards); index++) { if (pcidio_pci_table[index].device != pcidev->device) continue; - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { @@ -267,7 +274,7 @@ static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pcidio_detach(struct comedi_device * dev) +static int pcidio_detach(struct comedi_device *dev) { printk("comedi%d: cb_pcidio: remove\n", dev->minor); if (devpriv) { diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index af705fa092c0..57d250c73abc 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -43,29 +43,30 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "comedi_pci.h" #include "plx9052.h" #include "8255.h" -//#define CBPCIMDAS_DEBUG +/* #define CBPCIMDAS_DEBUG */ #undef CBPCIMDAS_DEBUG /* Registers for the PCIM-DAS1602/16 */ -// sizes of io regions (bytes) -#define BADR0_SIZE 2 //?? +/* sizes of io regions (bytes) */ +#define BADR0_SIZE 2 /* ?? */ #define BADR1_SIZE 4 #define BADR2_SIZE 6 #define BADR3_SIZE 16 #define BADR4_SIZE 4 -//DAC Offsets +/* DAC Offsets */ #define ADC_TRIG 0 #define DAC0_OFFSET 2 #define DAC1_OFFSET 4 -//AI and Counter Constants +/* AI and Counter Constants */ #define MUX_LIMITS 0 #define MAIN_CONN_DIO 1 #define ADC_STAT 2 @@ -86,37 +87,37 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more struct cb_pcimdas_board { const char *name; unsigned short device_id; - int ai_se_chans; // Inputs in single-ended mode - int ai_diff_chans; // Inputs in differential mode - int ai_bits; // analog input resolution - int ai_speed; // fastest conversion period in ns - int ao_nchan; // number of analog out channels - int ao_bits; // analogue output resolution - int has_ao_fifo; // analog output has fifo - int ao_scan_speed; // analog output speed for 1602 series (for a scan, not conversion) - int fifo_size; // number of samples fifo can hold - int dio_bits; // number of dio bits - int has_dio; // has DIO + int ai_se_chans; /* Inputs in single-ended mode */ + int ai_diff_chans; /* Inputs in differential mode */ + int ai_bits; /* analog input resolution */ + int ai_speed; /* fastest conversion period in ns */ + int ao_nchan; /* number of analog out channels */ + int ao_bits; /* analogue output resolution */ + int has_ao_fifo; /* analog output has fifo */ + int ao_scan_speed; /* analog output speed for 1602 series (for a scan, not conversion) */ + int fifo_size; /* number of samples fifo can hold */ + int dio_bits; /* number of dio bits */ + int has_dio; /* has DIO */ const struct comedi_lrange *ranges; }; static const struct cb_pcimdas_board cb_pcimdas_boards[] = { { - name: "PCIM-DAS1602/16", - device_id:0x56, - ai_se_chans:16, - ai_diff_chans:8, - ai_bits: 16, - ai_speed:10000, //?? - ao_nchan:2, - ao_bits: 12, - has_ao_fifo:0, //?? - ao_scan_speed:10000, - //?? - fifo_size:1024, - dio_bits:24, - has_dio: 1, -// ranges: &cb_pcimdas_ranges, + .name = "PCIM-DAS1602/16", + .device_id = 0x56, + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 16, + .ai_speed = 10000, /* ?? */ + .ao_nchan = 2, + .ao_bits = 12, + .has_ao_fifo = 0, /* ?? */ + .ao_scan_speed = 10000, + /* ?? */ + .fifo_size = 1024, + .dio_bits = 24, + .has_dio = 1, +/* .ranges = &cb_pcimdas_ranges, */ }, }; @@ -129,7 +130,7 @@ static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = { MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table); -#define N_BOARDS 1 // Max number of boards supported +#define N_BOARDS 1 /* Max number of boards supported */ /* * Useful for shorthand access to the particular board structure @@ -142,10 +143,10 @@ MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table); struct cb_pcimdas_private { int data; - // would be useful for a PCI device + /* would be useful for a PCI device */ struct pci_dev *pci_dev; - //base addresses + /* base addresses */ unsigned long BADR0; unsigned long BADR1; unsigned long BADR2; @@ -155,11 +156,11 @@ struct cb_pcimdas_private { /* Used for AO readback */ unsigned int ao_readback[2]; - // Used for DIO - unsigned short int port_a; // copy of BADR4+0 - unsigned short int port_b; // copy of BADR4+1 - unsigned short int port_c; // copy of BADR4+2 - unsigned short int dio_mode; // copy of BADR4+3 + /* Used for DIO */ + unsigned short int port_a; /* copy of BADR4+0 */ + unsigned short int port_b; /* copy of BADR4+1 */ + unsigned short int port_c; /* copy of BADR4+2 */ + unsigned short int dio_mode; /* copy of BADR4+3 */ }; @@ -175,21 +176,21 @@ struct cb_pcimdas_private { * the board, and also about the kernel module that contains * the device code. */ -static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int cb_pcimdas_detach(struct comedi_device * dev); +static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int cb_pcimdas_detach(struct comedi_device *dev); static struct comedi_driver driver_cb_pcimdas = { - driver_name:"cb_pcimdas", - module:THIS_MODULE, - attach:cb_pcimdas_attach, - detach:cb_pcimdas_detach, + .driver_name = "cb_pcimdas", + .module = THIS_MODULE, + .attach = cb_pcimdas_attach, + .detach = cb_pcimdas_detach, }; -static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * Attach is called by the Comedi core to configure the driver @@ -197,12 +198,12 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevi * in the driver structure, dev->board_ptr contains that * address. */ -static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; struct pci_dev *pcidev; int index; - //int i; + /* int i; */ printk("comedi%d: cb_pcimdas: ", dev->minor); @@ -220,17 +221,17 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - // is it not a computer boards card? + /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) continue; - // loop through cards supported by this driver + /* loop through cards supported by this driver */ for (index = 0; index < N_BOARDS; index++) { if (cb_pcimdas_boards[index].device_id != pcidev->device) continue; - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { @@ -252,7 +253,7 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig printk("Found %s on bus %i, slot %i\n", cb_pcimdas_boards[index].name, pcidev->bus->number, PCI_SLOT(pcidev->devfn)); - // Warn about non-tested features + /* Warn about non-tested features */ switch (thisboard->device_id) { case 0x56: break; @@ -280,16 +281,16 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig printk("devpriv->BADR4 = 0x%lx\n", devpriv->BADR4); #endif -// Dont support IRQ yet -// // get irq -// if(comedi_request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev )) -// { -// printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq); -// return -EINVAL; -// } -// dev->irq = devpriv->pci_dev->irq; +/* Dont support IRQ yet */ +/* get irq */ +/* if(request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev )) */ +/* { */ +/* printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq); */ +/* return -EINVAL; */ +/* } */ +/* dev->irq = devpriv->pci_dev->irq; */ - //Initialize dev->board_name + /* Initialize dev->board_name */ dev->board_name = thisboard->name; /* @@ -300,24 +301,24 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig return -ENOMEM; s = dev->subdevices + 0; - //dev->read_subdev=s; - // analog input subdevice + /* dev->read_subdev=s; */ + /* analog input subdevice */ s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND; s->n_chan = thisboard->ai_se_chans; s->maxdata = (1 << thisboard->ai_bits) - 1; s->range_table = &range_unknown; - s->len_chanlist = 1; // This is the maximum chanlist length that - // the board can handle + s->len_chanlist = 1; /* This is the maximum chanlist length that */ + /* the board can handle */ s->insn_read = cb_pcimdas_ai_rinsn; s = dev->subdevices + 1; - // analog output subdevice + /* analog output subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = thisboard->ao_nchan; s->maxdata = 1 << thisboard->ao_bits; - s->range_table = &range_unknown; //ranges are hardware settable, but not software readable. + s->range_table = &range_unknown; /* ranges are hardware settable, but not software readable. */ s->insn_write = &cb_pcimdas_ao_winsn; s->insn_read = &cb_pcimdas_ao_rinsn; @@ -342,7 +343,7 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int cb_pcimdas_detach(struct comedi_device * dev) +static int cb_pcimdas_detach(struct comedi_device *dev) { #ifdef CBPCIMDAS_DEBUG if (devpriv) { @@ -355,7 +356,7 @@ static int cb_pcimdas_detach(struct comedi_device * dev) #endif printk("comedi%d: cb_pcimdas: remove\n", dev->minor); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv) { if (devpriv->pci_dev) { if (devpriv->BADR0) { @@ -372,8 +373,8 @@ static int cb_pcimdas_detach(struct comedi_device * dev) * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; unsigned int d; @@ -382,27 +383,27 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi unsigned short chanlims; int maxchans; - // only support sw initiated reads from a single channel + /* only support sw initiated reads from a single channel */ - //check channel number - if ((inb(devpriv->BADR3 + 2) & 0x20) == 0) //differential mode + /* check channel number */ + if ((inb(devpriv->BADR3 + 2) & 0x20) == 0) /* differential mode */ maxchans = thisboard->ai_diff_chans; else maxchans = thisboard->ai_se_chans; if (chan > (maxchans - 1)) - return -ETIMEDOUT; //*** Wrong error code. Fixme. + return -ETIMEDOUT; /* *** Wrong error code. Fixme. */ - //configure for sw initiated read + /* configure for sw initiated read */ d = inb(devpriv->BADR3 + 5); - if ((d & 0x03) > 0) { //only reset if needed. + if ((d & 0x03) > 0) { /* only reset if needed. */ d = d & 0xfd; outb(d, devpriv->BADR3 + 5); } - outb(0x01, devpriv->BADR3 + 6); //set bursting off, conversions on - outb(0x00, devpriv->BADR3 + 7); //set range to 10V. UP/BP is controlled by a switch on the board + outb(0x01, devpriv->BADR3 + 6); /* set bursting off, conversions on */ + outb(0x00, devpriv->BADR3 + 7); /* set range to 10V. UP/BP is controlled by a switch on the board */ - // write channel limits to multiplexer, set Low (bits 0-3) and High (bits 4-7) channels to chan. + /* write channel limits to multiplexer, set Low (bits 0-3) and High (bits 4-7) channels to chan. */ chanlims = chan | (chan << 4); outb(chanlims, devpriv->BADR3 + 0); @@ -411,8 +412,8 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi /* trigger conversion */ outw(0, devpriv->BADR2 + 0); -#define TIMEOUT 1000 //typically takes 5 loops on a lightly loaded Pentium 100MHz, - //this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit. +#define TIMEOUT 1000 /* typically takes 5 loops on a lightly loaded Pentium 100MHz, */ + /* this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit. */ /* wait for conversion to end */ for (i = 0; i < TIMEOUT; i++) { @@ -428,7 +429,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi d = inw(devpriv->BADR2 + 0); /* mangle the data as necessary */ - //d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so no mangle needed. + /* d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so no mangle needed. */ data[n] = d; } @@ -437,8 +438,8 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -465,8 +466,8 @@ static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevi /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index e4c5b460fbd5..57bb1182480d 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -118,15 +118,15 @@ enum DIO_METHODS { static const struct board_struct boards[] = { { - name: "cb_pcimdda06-16", - device_id:PCI_ID_PCIM_DDA06_16, - ao_chans:6, - ao_bits: 16, - dio_chans:24, - dio_method:DIO_8255, - dio_offset:12, - regs_badrindex:3, - reg_sz: 16, + .name = "cb_pcimdda06-16", + .device_id = PCI_ID_PCIM_DDA06_16, + .ao_chans = 6, + .ao_bits = 16, + .dio_chans = 24, + .dio_method = DIO_8255, + .dio_offset = 12, + .regs_badrindex = 3, + .reg_sz = 16, } }; @@ -135,8 +135,6 @@ static const struct board_struct boards[] = { */ #define thisboard ((const struct board_struct *)dev->board_ptr) -/* Number of boards in boards[] */ -#define N_BOARDS (sizeof(boards) / sizeof(struct board_struct)) #define REG_SZ (thisboard->reg_sz) #define REGS_BADRINDEX (thisboard->regs_badrindex) @@ -181,13 +179,13 @@ struct board_private_struct { * the board, and also about the kernel module that contains * the device code. */ -static int attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int detach(struct comedi_device * dev); +static int attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int detach(struct comedi_device *dev); static struct comedi_driver cb_pcimdda_driver = { - driver_name:"cb_pcimdda", - module:THIS_MODULE, - attach:attach, - detach:detach, + .driver_name = "cb_pcimdda", + .module = THIS_MODULE, + .attach = attach, + .detach = detach, }; MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>"); @@ -197,10 +195,10 @@ MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA " MODULE_LICENSE("GPL"); COMEDI_PCI_INITCLEANUP_NOMODULE(cb_pcimdda_driver, pci_table); -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /*--------------------------------------------------------------------------- HELPER FUNCTION DECLARATIONS @@ -209,7 +207,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, /* returns a maxdata value for a given n_bits */ static inline unsigned int figure_out_maxdata(int bits) { - return (((unsigned int) 1 << bits) - 1); + return ((unsigned int) 1 << bits) - 1; } /* @@ -226,7 +224,7 @@ static inline unsigned int figure_out_maxdata(int bits) * * Otherwise, returns a -errno on error */ -static int probe(struct comedi_device * dev, const struct comedi_devconfig * it); +static int probe(struct comedi_device *dev, const struct comedi_devconfig *it); /*--------------------------------------------------------------------------- FUNCTION DEFINITIONS @@ -238,7 +236,7 @@ static int probe(struct comedi_device * dev, const struct comedi_devconfig * it) * in the driver structure, dev->board_ptr contains that * address. */ -static int attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int err; @@ -257,7 +255,8 @@ static int attach(struct comedi_device * dev, struct comedi_devconfig * it) * it is, this is the place to do it. Otherwise, dev->board_ptr * should already be initialized. */ - if ((err = probe(dev, it))) + err = probe(dev, it); + if (err) return err; /* Output some info */ @@ -326,7 +325,7 @@ static int attach(struct comedi_device * dev, struct comedi_devconfig * it) * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int detach(struct comedi_device * dev) +static int detach(struct comedi_device *dev) { if (devpriv) { @@ -352,8 +351,8 @@ static int detach(struct comedi_device * dev) return 0; } -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -391,8 +390,8 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, all AO channels update simultaneously. This is useful for some control applications, I would imagine. */ -static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -425,7 +424,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, * * Otherwise, returns a -errno on error */ -static int probe(struct comedi_device * dev, const struct comedi_devconfig * it) +static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) { struct pci_dev *pcidev; int index; @@ -434,16 +433,16 @@ static int probe(struct comedi_device * dev, const struct comedi_devconfig * it) for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - // is it not a computer boards card? + /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) continue; - // loop through cards supported by this driver - for (index = 0; index < N_BOARDS; index++) { + /* loop through cards supported by this driver */ + for (index = 0; index < ARRAY_SIZE(boards); index++) { if (boards[index].device_id != pcidev->device) continue; - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 1ee489864d3b..45cd41f7fd29 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -210,7 +210,7 @@ static struct comedi_driver driver_bonding = { */ .board_name = &bondingBoards[0].name, .offset = sizeof(struct BondingBoard), - .num_names = sizeof(bondingBoards) / sizeof(struct BondingBoard), + .num_names = ARRAY_SIZE(bondingBoards), }; static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 9fa4cdc84d44..8ab8e733afb6 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -53,7 +53,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data retval = comedi_buf_write_alloc(async, num_bytes); if (retval != num_bytes) { - rt_printk("comedi: buffer overrun\n"); + printk("comedi: buffer overrun\n"); async->events |= COMEDI_CB_OVERFLOW; return 0; } diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index a23339155ffc..f42897de640e 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -82,6 +82,7 @@ pin, which can be used to wake up tasks. */ #include "../comedidev.h" +#include <linux/interrupt.h> #include <linux/ioport.h> #define PARPORT_SIZE 3 @@ -274,7 +275,7 @@ static int parport_intr_cancel(struct comedi_device *dev, struct comedi_subdevic return 0; } -static irqreturn_t parport_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t parport_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 3; @@ -309,8 +310,8 @@ static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it irq = it->options[1]; if (irq) { printk(" irq=%u", irq); - ret = comedi_request_irq(irq, parport_interrupt, 0, - "comedi_parport", dev); + ret = request_irq(irq, parport_interrupt, 0, "comedi_parport", + dev); if (ret < 0) { printk(" irq not available\n"); return -EINVAL; @@ -384,7 +385,7 @@ static int parport_detach(struct comedi_device *dev) release_region(dev->iobase, PARPORT_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; } diff --git a/drivers/staging/comedi/drivers/comedi_rt_timer.c b/drivers/staging/comedi/drivers/comedi_rt_timer.c deleted file mode 100644 index f40c8cffd4bb..000000000000 --- a/drivers/staging/comedi/drivers/comedi_rt_timer.c +++ /dev/null @@ -1,728 +0,0 @@ -/* - comedi/drivers/comedi_rt_timer.c - virtual driver for using RTL timing sources - - Authors: David A. Schleef, Frank M. Hess - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1999,2001 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -************************************************************************** -*/ -/* -Driver: comedi_rt_timer -Description: Command emulator using real-time tasks -Author: ds, fmhess -Devices: -Status: works - -This driver requires RTAI or RTLinux to work correctly. It doesn't -actually drive hardware directly, but calls other drivers and uses -a real-time task to emulate commands for drivers and devices that -are incapable of native commands. Thus, you can get accurately -timed I/O on any device. - -Since the timing is all done in software, sampling jitter is much -higher than with a device that has an on-board timer, and maximum -sample rate is much lower. - -Configuration options: - [0] - minor number of device you wish to emulate commands for - [1] - subdevice number you wish to emulate commands for -*/ -/* -TODO: - Support for digital io commands could be added, except I can't see why - anyone would want to use them - What happens if device we are emulating for is de-configured? -*/ - -#include "../comedidev.h" -#include "../comedilib.h" - -#include "comedi_fc.h" - -#ifdef CONFIG_COMEDI_RTL_V1 -#include <rtl_sched.h> -#include <asm/rt_irq.h> -#endif -#ifdef CONFIG_COMEDI_RTL -#include <rtl.h> -#include <rtl_sched.h> -#include <rtl_compat.h> -#include <asm/div64.h> - -#ifndef RTLINUX_VERSION_CODE -#define RTLINUX_VERSION_CODE 0 -#endif -#ifndef RTLINUX_VERSION -#define RTLINUX_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -// begin hack to workaround broken HRT_TO_8254() function on rtlinux -#if RTLINUX_VERSION_CODE <= RTLINUX_VERSION(3,0,100) -// this function sole purpose is to divide a long long by 838 -static inline RTIME nano2count(long long ns) -{ - do_div(ns, 838); - return ns; -} - -#ifdef rt_get_time() -#undef rt_get_time() -#endif -#define rt_get_time() nano2count(gethrtime()) - -#else - -#define nano2count(x) HRT_TO_8254(x) -#endif -// end hack - -// rtl-rtai compatibility -#define rt_task_wait_period() rt_task_wait() -#define rt_pend_linux_srq(irq) rtl_global_pend_irq(irq) -#define rt_free_srq(irq) rtl_free_soft_irq(irq) -#define rt_request_srq(x,y,z) rtl_get_soft_irq(y,"timer") -#define rt_task_init(a,b,c,d,e,f,g) rt_task_init(a,b,c,d,(e)+1) -#define rt_task_resume(x) rt_task_wakeup(x) -#define rt_set_oneshot_mode() -#define start_rt_timer(x) -#define stop_rt_timer() - -#endif -#ifdef CONFIG_COMEDI_RTAI -#include <rtai.h> -#include <rtai_sched.h> - -#if RTAI_VERSION_CODE < RTAI_MANGLE_VERSION(3,3,0) -#define comedi_rt_task_context_t int -#else -#define comedi_rt_task_context_t long -#endif - -#endif - -/* This defines the fastest speed we will emulate. Note that - * without a watchdog (like in RTAI), we could easily overrun our - * task period because analog input tends to be slow. */ -#define SPEED_LIMIT 100000 /* in nanoseconds */ - -static int timer_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int timer_detach(struct comedi_device * dev); -static int timer_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, - unsigned int trig_num); -static int timer_start_cmd(struct comedi_device * dev, struct comedi_subdevice * s); - -static struct comedi_driver driver_timer = { - module:THIS_MODULE, - driver_name:"comedi_rt_timer", - attach:timer_attach, - detach:timer_detach, -// open: timer_open, -}; - -COMEDI_INITCLEANUP(driver_timer); - -struct timer_private { - comedi_t *device; // device we are emulating commands for - int subd; // subdevice we are emulating commands for - RT_TASK *rt_task; // rt task that starts scans - RT_TASK *scan_task; // rt task that controls conversion timing in a scan - /* io_function can point to either an input or output function - * depending on what kind of subdevice we are emulating for */ - int (*io_function) (struct comedi_device * dev, struct comedi_cmd * cmd, - unsigned int index); - // RTIME has units of 1 = 838 nanoseconds - // time at which first scan started, used to check scan timing - RTIME start; - // time between scans - RTIME scan_period; - // time between conversions in a scan - RTIME convert_period; - // flags - volatile int stop; // indicates we should stop - volatile int rt_task_active; // indicates rt_task is servicing a struct comedi_cmd - volatile int scan_task_active; // indicates scan_task is servicing a struct comedi_cmd - unsigned timer_running:1; -}; -#define devpriv ((struct timer_private *)dev->private) - -static int timer_cancel(struct comedi_device * dev, struct comedi_subdevice * s) -{ - devpriv->stop = 1; - - return 0; -} - -// checks for scan timing error -inline static int check_scan_timing(struct comedi_device * dev, - unsigned long long scan) -{ - RTIME now, timing_error; - - now = rt_get_time(); - timing_error = now - (devpriv->start + scan * devpriv->scan_period); - if (timing_error > devpriv->scan_period) { - comedi_error(dev, "timing error"); - rt_printk("scan started %i ns late\n", timing_error * 838); - return -1; - } - - return 0; -} - -// checks for conversion timing error -inline static int check_conversion_timing(struct comedi_device * dev, - RTIME scan_start, unsigned int conversion) -{ - RTIME now, timing_error; - - now = rt_get_time(); - timing_error = - now - (scan_start + conversion * devpriv->convert_period); - if (timing_error > devpriv->convert_period) { - comedi_error(dev, "timing error"); - rt_printk("conversion started %i ns late\n", - timing_error * 838); - return -1; - } - - return 0; -} - -// devpriv->io_function for an input subdevice -static int timer_data_read(struct comedi_device * dev, struct comedi_cmd * cmd, - unsigned int index) -{ - struct comedi_subdevice *s = dev->read_subdev; - int ret; - unsigned int data; - - ret = comedi_data_read(devpriv->device, devpriv->subd, - CR_CHAN(cmd->chanlist[index]), - CR_RANGE(cmd->chanlist[index]), - CR_AREF(cmd->chanlist[index]), &data); - if (ret < 0) { - comedi_error(dev, "read error"); - return -EIO; - } - if (s->flags & SDF_LSAMPL) { - cfc_write_long_to_buffer(s, data); - } else { - comedi_buf_put(s->async, data); - } - - return 0; -} - -// devpriv->io_function for an output subdevice -static int timer_data_write(struct comedi_device * dev, struct comedi_cmd * cmd, - unsigned int index) -{ - struct comedi_subdevice *s = dev->write_subdev; - unsigned int num_bytes; - short data; - unsigned int long_data; - int ret; - - if (s->flags & SDF_LSAMPL) { - num_bytes = - cfc_read_array_from_buffer(s, &long_data, - sizeof(long_data)); - } else { - num_bytes = cfc_read_array_from_buffer(s, &data, sizeof(data)); - long_data = data; - } - - if (num_bytes == 0) { - comedi_error(dev, "buffer underrun"); - return -EAGAIN; - } - ret = comedi_data_write(devpriv->device, devpriv->subd, - CR_CHAN(cmd->chanlist[index]), - CR_RANGE(cmd->chanlist[index]), - CR_AREF(cmd->chanlist[index]), long_data); - if (ret < 0) { - comedi_error(dev, "write error"); - return -EIO; - } - - return 0; -} - -// devpriv->io_function for DIO subdevices -static int timer_dio_read(struct comedi_device * dev, struct comedi_cmd * cmd, - unsigned int index) -{ - struct comedi_subdevice *s = dev->read_subdev; - int ret; - unsigned int data; - - ret = comedi_dio_bitfield(devpriv->device, devpriv->subd, 0, &data); - if (ret < 0) { - comedi_error(dev, "read error"); - return -EIO; - } - - if (s->flags & SDF_LSAMPL) - cfc_write_long_to_buffer(s, data); - else - cfc_write_to_buffer(s, data); - - return 0; -} - -// performs scans -static void scan_task_func(comedi_rt_task_context_t d) -{ - struct comedi_device *dev = (struct comedi_device *) d; - struct comedi_subdevice *s = dev->subdevices + 0; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - int i, ret; - unsigned long long n; - RTIME scan_start; - - // every struct comedi_cmd causes one execution of while loop - while (1) { - devpriv->scan_task_active = 1; - // each for loop completes one scan - for (n = 0; n < cmd->stop_arg || cmd->stop_src == TRIG_NONE; - n++) { - if (n) { - // suspend task until next scan - ret = rt_task_suspend(devpriv->scan_task); - if (ret < 0) { - comedi_error(dev, - "error suspending scan task"); - async->events |= COMEDI_CB_ERROR; - goto cleanup; - } - } - // check if stop flag was set (by timer_cancel()) - if (devpriv->stop) - goto cleanup; - ret = check_scan_timing(dev, n); - if (ret < 0) { - async->events |= COMEDI_CB_ERROR; - goto cleanup; - } - scan_start = rt_get_time(); - for (i = 0; i < cmd->scan_end_arg; i++) { - // conversion timing - if (cmd->convert_src == TRIG_TIMER && i) { - rt_task_wait_period(); - ret = check_conversion_timing(dev, - scan_start, i); - if (ret < 0) { - async->events |= - COMEDI_CB_ERROR; - goto cleanup; - } - } - ret = devpriv->io_function(dev, cmd, i); - if (ret < 0) { - async->events |= COMEDI_CB_ERROR; - goto cleanup; - } - } - s->async->events |= COMEDI_CB_BLOCK; - comedi_event(dev, s); - s->async->events = 0; - } - - cleanup: - - comedi_unlock(devpriv->device, devpriv->subd); - async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - async->events = 0; - devpriv->scan_task_active = 0; - // suspend task until next struct comedi_cmd - rt_task_suspend(devpriv->scan_task); - } -} - -static void timer_task_func(comedi_rt_task_context_t d) -{ - struct comedi_device *dev = (struct comedi_device *) d; - struct comedi_subdevice *s = dev->subdevices + 0; - struct comedi_cmd *cmd = &s->async->cmd; - int ret; - unsigned long long n; - - // every struct comedi_cmd causes one execution of while loop - while (1) { - devpriv->rt_task_active = 1; - devpriv->scan_task_active = 1; - devpriv->start = rt_get_time(); - - for (n = 0; n < cmd->stop_arg || cmd->stop_src == TRIG_NONE; - n++) { - // scan timing - if (n) - rt_task_wait_period(); - if (devpriv->scan_task_active == 0) { - goto cleanup; - } - ret = rt_task_make_periodic(devpriv->scan_task, - devpriv->start + devpriv->scan_period * n, - devpriv->convert_period); - if (ret < 0) { - comedi_error(dev, "bug!"); - } - } - - cleanup: - - devpriv->rt_task_active = 0; - // suspend until next struct comedi_cmd - rt_task_suspend(devpriv->rt_task); - } -} - -static int timer_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) -{ - struct comedi_insn xinsn = *insn; - - xinsn.data = data; - xinsn.subdev = devpriv->subd; - - return comedi_do_insn(devpriv->device, &xinsn); -} - -static int cmdtest_helper(struct comedi_cmd * cmd, - unsigned int start_src, - unsigned int scan_begin_src, - unsigned int convert_src, - unsigned int scan_end_src, unsigned int stop_src) -{ - int err = 0; - int tmp; - - tmp = cmd->start_src; - cmd->start_src &= start_src; - if (!cmd->start_src || tmp != cmd->start_src) - err++; - - tmp = cmd->scan_begin_src; - cmd->scan_begin_src &= scan_begin_src; - if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) - err++; - - tmp = cmd->convert_src; - cmd->convert_src &= convert_src; - if (!cmd->convert_src || tmp != cmd->convert_src) - err++; - - tmp = cmd->scan_end_src; - cmd->scan_end_src &= scan_end_src; - if (!cmd->scan_end_src || tmp != cmd->scan_end_src) - err++; - - tmp = cmd->stop_src; - cmd->stop_src &= stop_src; - if (!cmd->stop_src || tmp != cmd->stop_src) - err++; - - return err; -} - -static int timer_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) -{ - int err = 0; - unsigned int start_src = 0; - - if (s->type == COMEDI_SUBD_AO) - start_src = TRIG_INT; - else - start_src = TRIG_NOW; - - err = cmdtest_helper(cmd, start_src, /* start_src */ - TRIG_TIMER | TRIG_FOLLOW, /* scan_begin_src */ - TRIG_NOW | TRIG_TIMER, /* convert_src */ - TRIG_COUNT, /* scan_end_src */ - TRIG_COUNT | TRIG_NONE); /* stop_src */ - if (err) - return 1; - - /* step 2: make sure trigger sources are unique and mutually - * compatible */ - - if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT) - err++; - if (cmd->scan_begin_src != TRIG_TIMER && - cmd->scan_begin_src != TRIG_FOLLOW) - err++; - if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_NOW) - err++; - if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) - err++; - if (cmd->scan_begin_src == TRIG_FOLLOW - && cmd->convert_src != TRIG_TIMER) - err++; - if (cmd->convert_src == TRIG_NOW && cmd->scan_begin_src != TRIG_TIMER) - err++; - - if (err) - return 2; - - /* step 3: make sure arguments are trivially compatible */ - // limit frequency, this is fairly arbitrary - if (cmd->scan_begin_src == TRIG_TIMER) { - if (cmd->scan_begin_arg < SPEED_LIMIT) { - cmd->scan_begin_arg = SPEED_LIMIT; - err++; - } - } - if (cmd->convert_src == TRIG_TIMER) { - if (cmd->convert_arg < SPEED_LIMIT) { - cmd->convert_arg = SPEED_LIMIT; - err++; - } - } - // make sure conversion and scan frequencies are compatible - if (cmd->convert_src == TRIG_TIMER && cmd->scan_begin_src == TRIG_TIMER) { - if (cmd->convert_arg * cmd->scan_end_arg > cmd->scan_begin_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; - } - } - if (err) - return 3; - - /* step 4: fix up and arguments */ - if (err) - return 4; - - return 0; -} - -static int timer_cmd(struct comedi_device * dev, struct comedi_subdevice * s) -{ - int ret; - struct comedi_cmd *cmd = &s->async->cmd; - - /* hack attack: drivers are not supposed to do this: */ - dev->rt = 1; - - // make sure tasks have finished cleanup of last struct comedi_cmd - if (devpriv->rt_task_active || devpriv->scan_task_active) - return -EBUSY; - - ret = comedi_lock(devpriv->device, devpriv->subd); - if (ret < 0) { - comedi_error(dev, "failed to obtain lock"); - return ret; - } - switch (cmd->scan_begin_src) { - case TRIG_TIMER: - devpriv->scan_period = nano2count(cmd->scan_begin_arg); - break; - case TRIG_FOLLOW: - devpriv->scan_period = - nano2count(cmd->convert_arg * cmd->scan_end_arg); - break; - default: - comedi_error(dev, "bug setting scan period!"); - return -1; - break; - } - switch (cmd->convert_src) { - case TRIG_TIMER: - devpriv->convert_period = nano2count(cmd->convert_arg); - break; - case TRIG_NOW: - devpriv->convert_period = 1; - break; - default: - comedi_error(dev, "bug setting conversion period!"); - return -1; - break; - } - - if (cmd->start_src == TRIG_NOW) - return timer_start_cmd(dev, s); - - s->async->inttrig = timer_inttrig; - - return 0; -} - -static int timer_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, - unsigned int trig_num) -{ - if (trig_num != 0) - return -EINVAL; - - s->async->inttrig = NULL; - - return timer_start_cmd(dev, s); -} - -static int timer_start_cmd(struct comedi_device * dev, struct comedi_subdevice * s) -{ - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - RTIME now, delay, period; - int ret; - - devpriv->stop = 0; - s->async->events = 0; - - if (cmd->start_src == TRIG_NOW) - delay = nano2count(cmd->start_arg); - else - delay = 0; - - now = rt_get_time(); - /* Using 'period' this way gets around some weird bug in gcc-2.95.2 - * that generates the compile error 'internal error--unrecognizable insn' - * when rt_task_make_period() is called (observed with rtlinux-3.1, linux-2.2.19). - * - fmhess */ - period = devpriv->scan_period; - ret = rt_task_make_periodic(devpriv->rt_task, now + delay, period); - if (ret < 0) { - comedi_error(dev, "error starting rt_task"); - return ret; - } - return 0; -} - -static int timer_attach(struct comedi_device * dev, struct comedi_devconfig * it) -{ - int ret; - struct comedi_subdevice *s, *emul_s; - struct comedi_device *emul_dev; - /* These should probably be devconfig options[] */ - const int timer_priority = 4; - const int scan_priority = timer_priority + 1; - char path[20]; - - printk("comedi%d: timer: ", dev->minor); - - dev->board_name = "timer"; - - if ((ret = alloc_subdevices(dev, 1)) < 0) - return ret; - if ((ret = alloc_private(dev, sizeof(struct timer_private))) < 0) - return ret; - - sprintf(path, "/dev/comedi%d", it->options[0]); - devpriv->device = comedi_open(path); - devpriv->subd = it->options[1]; - - printk("emulating commands for minor %i, subdevice %d\n", - it->options[0], devpriv->subd); - - emul_dev = devpriv->device; - emul_s = emul_dev->subdevices + devpriv->subd; - - // input or output subdevice - s = dev->subdevices + 0; - s->type = emul_s->type; - s->subdev_flags = emul_s->subdev_flags; /* SDF_GROUND (to fool check_driver) */ - s->n_chan = emul_s->n_chan; - s->len_chanlist = 1024; - s->do_cmd = timer_cmd; - s->do_cmdtest = timer_cmdtest; - s->cancel = timer_cancel; - s->maxdata = emul_s->maxdata; - s->range_table = emul_s->range_table; - s->range_table_list = emul_s->range_table_list; - switch (emul_s->type) { - case COMEDI_SUBD_AI: - s->insn_read = timer_insn; - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - devpriv->io_function = timer_data_read; - break; - case COMEDI_SUBD_AO: - s->insn_write = timer_insn; - s->insn_read = timer_insn; - dev->write_subdev = s; - s->subdev_flags |= SDF_CMD_WRITE; - devpriv->io_function = timer_data_write; - break; - case COMEDI_SUBD_DIO: - s->insn_write = timer_insn; - s->insn_read = timer_insn; - s->insn_bits = timer_insn; - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - devpriv->io_function = timer_dio_read; - break; - default: - comedi_error(dev, "failed to determine subdevice type!"); - return -EINVAL; - } - - rt_set_oneshot_mode(); - start_rt_timer(1); - devpriv->timer_running = 1; - - devpriv->rt_task = kzalloc(sizeof(RT_TASK), GFP_KERNEL); - - // initialize real-time tasks - ret = rt_task_init(devpriv->rt_task, timer_task_func, - (comedi_rt_task_context_t) dev, 3000, timer_priority, 0, 0); - if (ret < 0) { - comedi_error(dev, "error initalizing rt_task"); - kfree(devpriv->rt_task); - devpriv->rt_task = 0; - return ret; - } - - devpriv->scan_task = kzalloc(sizeof(RT_TASK), GFP_KERNEL); - - ret = rt_task_init(devpriv->scan_task, scan_task_func, - (comedi_rt_task_context_t) dev, 3000, scan_priority, 0, 0); - if (ret < 0) { - comedi_error(dev, "error initalizing scan_task"); - kfree(devpriv->scan_task); - devpriv->scan_task = 0; - return ret; - } - - return 1; -} - -// free allocated resources -static int timer_detach(struct comedi_device * dev) -{ - printk("comedi%d: timer: remove\n", dev->minor); - - if (devpriv) { - if (devpriv->rt_task) { - rt_task_delete(devpriv->rt_task); - kfree(devpriv->rt_task); - } - if (devpriv->scan_task) { - rt_task_delete(devpriv->scan_task); - kfree(devpriv->scan_task); - } - if (devpriv->timer_running) - stop_rt_timer(); - if (devpriv->device) - comedi_close(devpriv->device); - } - return 0; -} diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index e679328a4f8f..9b8cf62973be 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -55,6 +55,7 @@ zero volts). #include <asm/div64.h> #include "comedi_fc.h" +#include <linux/timer.h> /* Board descriptions */ struct waveform_board { @@ -102,7 +103,7 @@ static struct comedi_driver driver_waveform = { .detach = waveform_detach, .board_name = &waveform_boards[0].name, .offset = sizeof(struct waveform_board), - .num_names = sizeof(waveform_boards) / sizeof(struct waveform_board), + .num_names = ARRAY_SIZE(waveform_boards), }; COMEDI_INITCLEANUP(driver_waveform); diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 1f194a0a45d6..6c58e9990323 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -75,29 +75,29 @@ struct contec_private { #define devpriv ((struct contec_private *)dev->private) -static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int contec_detach(struct comedi_device * dev); +static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int contec_detach(struct comedi_device *dev); static struct comedi_driver driver_contec = { - driver_name:"contec_pci_dio", - module:THIS_MODULE, - attach:contec_attach, - detach:contec_detach, + .driver_name = "contec_pci_dio", + .module = THIS_MODULE, + .attach = contec_attach, + .detach = contec_detach, }; /* Classic digital IO */ -static int contec_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); #if 0 -static int contec_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); +static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); static int contec_ns_to_timer(unsigned int *ns, int round); #endif -static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -164,7 +164,7 @@ static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * i return -EIO; } -static int contec_detach(struct comedi_device * dev) +static int contec_detach(struct comedi_device *dev) { printk("comedi%d: contec: remove\n", dev->minor); @@ -179,8 +179,8 @@ static int contec_detach(struct comedi_device * dev) } #if 0 -static int contec_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { printk("contec_cmdtest called\n"); return 0; @@ -192,8 +192,8 @@ static int contec_ns_to_timer(unsigned int *ns, int round) } #endif -static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { printk("contec_do_insn_bits called\n"); @@ -205,19 +205,19 @@ static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi if (data[0]) { s->state &= ~data[0]; s->state |= data[0] & data[1]; - rt_printk(" out: %d on %lx\n", s->state, + printk(" out: %d on %lx\n", s->state, dev->iobase + thisboard->out_offs); outw(s->state, dev->iobase + thisboard->out_offs); } return 2; } -static int contec_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - rt_printk("contec_di_insn_bits called\n"); - rt_printk(" data: %d %d\n", data[0], data[1]); + printk("contec_di_insn_bits called\n"); + printk(" data: %d %d\n", data[0], data[1]); if (insn->n != 2) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 3b8444f09f28..d4526c616a99 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -119,6 +119,7 @@ Configuration options: #include "../comedidev.h" #include <linux/delay.h> +#include <linux/interrupt.h> #include "comedi_pci.h" #include "8255.h" @@ -129,7 +130,7 @@ Configuration options: #define DAQBOARD2000_DAQ_SIZE 0x1002 #define DAQBOARD2000_PLX_SIZE 0x100 -// Initialization bits for the Serial EEPROM Control Register +/* Initialization bits for the Serial EEPROM Control Register */ #define DAQBOARD2000_SECRProgPinHi 0x8001767e #define DAQBOARD2000_SECRProgPinLo 0x8000767e #define DAQBOARD2000_SECRLocalBusHi 0xc000767e @@ -137,14 +138,14 @@ Configuration options: #define DAQBOARD2000_SECRReloadHi 0xa000767e #define DAQBOARD2000_SECRReloadLo 0x8000767e -// SECR status bits +/* SECR status bits */ #define DAQBOARD2000_EEPROM_PRESENT 0x10000000 -// CPLD status bits +/* CPLD status bits */ #define DAQBOARD2000_CPLD_INIT 0x0002 #define DAQBOARD2000_CPLD_DONE 0x0004 -// Available ranges +/* Available ranges */ static const struct comedi_lrange range_daqboard2000_ai = { 13, { RANGE(-10, 10), RANGE(-5, 5), @@ -168,65 +169,65 @@ static const struct comedi_lrange range_daqboard2000_ao = { 1, { }; struct daqboard2000_hw { - volatile u16 acqControl; // 0x00 - volatile u16 acqScanListFIFO; // 0x02 - volatile u32 acqPacerClockDivLow; // 0x04 - - volatile u16 acqScanCounter; // 0x08 - volatile u16 acqPacerClockDivHigh; // 0x0a - volatile u16 acqTriggerCount; // 0x0c - volatile u16 fill2; // 0x0e - volatile u16 acqResultsFIFO; // 0x10 - volatile u16 fill3; // 0x12 - volatile u16 acqResultsShadow; // 0x14 - volatile u16 fill4; // 0x16 - volatile u16 acqAdcResult; // 0x18 - volatile u16 fill5; // 0x1a - volatile u16 dacScanCounter; // 0x1c - volatile u16 fill6; // 0x1e - - volatile u16 dacControl; // 0x20 - volatile u16 fill7; // 0x22 - volatile s16 dacFIFO; // 0x24 - volatile u16 fill8[2]; // 0x26 - volatile u16 dacPacerClockDiv; // 0x2a - volatile u16 refDacs; // 0x2c - volatile u16 fill9; // 0x2e - - volatile u16 dioControl; // 0x30 - volatile s16 dioP3hsioData; // 0x32 - volatile u16 dioP3Control; // 0x34 - volatile u16 calEepromControl; // 0x36 - volatile s16 dacSetting[4]; // 0x38 - volatile s16 dioP2ExpansionIO8Bit[32]; // 0x40 - - volatile u16 ctrTmrControl; // 0x80 - volatile u16 fill10[3]; // 0x82 - volatile s16 ctrInput[4]; // 0x88 - volatile u16 fill11[8]; // 0x90 - volatile u16 timerDivisor[2]; // 0xa0 - volatile u16 fill12[6]; // 0xa4 - - volatile u16 dmaControl; // 0xb0 - volatile u16 trigControl; // 0xb2 - volatile u16 fill13[2]; // 0xb4 - volatile u16 calEeprom; // 0xb8 - volatile u16 acqDigitalMark; // 0xba - volatile u16 trigDacs; // 0xbc - volatile u16 fill14; // 0xbe - volatile s16 dioP2ExpansionIO16Bit[32]; // 0xc0 + volatile u16 acqControl; /* 0x00 */ + volatile u16 acqScanListFIFO; /* 0x02 */ + volatile u32 acqPacerClockDivLow; /* 0x04 */ + + volatile u16 acqScanCounter; /* 0x08 */ + volatile u16 acqPacerClockDivHigh; /* 0x0a */ + volatile u16 acqTriggerCount; /* 0x0c */ + volatile u16 fill2; /* 0x0e */ + volatile u16 acqResultsFIFO; /* 0x10 */ + volatile u16 fill3; /* 0x12 */ + volatile u16 acqResultsShadow; /* 0x14 */ + volatile u16 fill4; /* 0x16 */ + volatile u16 acqAdcResult; /* 0x18 */ + volatile u16 fill5; /* 0x1a */ + volatile u16 dacScanCounter; /* 0x1c */ + volatile u16 fill6; /* 0x1e */ + + volatile u16 dacControl; /* 0x20 */ + volatile u16 fill7; /* 0x22 */ + volatile s16 dacFIFO; /* 0x24 */ + volatile u16 fill8[2]; /* 0x26 */ + volatile u16 dacPacerClockDiv; /* 0x2a */ + volatile u16 refDacs; /* 0x2c */ + volatile u16 fill9; /* 0x2e */ + + volatile u16 dioControl; /* 0x30 */ + volatile s16 dioP3hsioData; /* 0x32 */ + volatile u16 dioP3Control; /* 0x34 */ + volatile u16 calEepromControl; /* 0x36 */ + volatile s16 dacSetting[4]; /* 0x38 */ + volatile s16 dioP2ExpansionIO8Bit[32]; /* 0x40 */ + + volatile u16 ctrTmrControl; /* 0x80 */ + volatile u16 fill10[3]; /* 0x82 */ + volatile s16 ctrInput[4]; /* 0x88 */ + volatile u16 fill11[8]; /* 0x90 */ + volatile u16 timerDivisor[2]; /* 0xa0 */ + volatile u16 fill12[6]; /* 0xa4 */ + + volatile u16 dmaControl; /* 0xb0 */ + volatile u16 trigControl; /* 0xb2 */ + volatile u16 fill13[2]; /* 0xb4 */ + volatile u16 calEeprom; /* 0xb8 */ + volatile u16 acqDigitalMark; /* 0xba */ + volatile u16 trigDacs; /* 0xbc */ + volatile u16 fill14; /* 0xbe */ + volatile s16 dioP2ExpansionIO16Bit[32]; /* 0xc0 */ }; /* Scan Sequencer programming */ #define DAQBOARD2000_SeqStartScanList 0x0011 #define DAQBOARD2000_SeqStopScanList 0x0010 -// Prepare for acquisition +/* Prepare for acquisition */ #define DAQBOARD2000_AcqResetScanListFifo 0x0004 #define DAQBOARD2000_AcqResetResultsFifo 0x0002 #define DAQBOARD2000_AcqResetConfigPipe 0x0001 -// Acqusition status bits +/* Acqusition status bits */ #define DAQBOARD2000_AcqResultsFIFOMore1Sample 0x0001 #define DAQBOARD2000_AcqResultsFIFOHasValidData 0x0002 #define DAQBOARD2000_AcqResultsFIFOOverrun 0x0004 @@ -239,7 +240,7 @@ struct daqboard2000_hw { #define DAQBOARD2000_DacPacerOverrun 0x0200 #define DAQBOARD2000_AcqHardwareError 0x01c0 -// Scan Sequencer programming +/* Scan Sequencer programming */ #define DAQBOARD2000_SeqStartScanList 0x0011 #define DAQBOARD2000_SeqStopScanList 0x0010 @@ -254,7 +255,7 @@ struct daqboard2000_hw { #define DAQBOARD2000_AdcPacerInternalOutEnable 0x0008 #define DAQBOARD2000_AdcPacerExternalRising 0x0100 -// DAC status +/* DAC status */ #define DAQBOARD2000_DacFull 0x0001 #define DAQBOARD2000_RefBusy 0x0002 #define DAQBOARD2000_TrgBusy 0x0004 @@ -264,7 +265,7 @@ struct daqboard2000_hw { #define DAQBOARD2000_Dac2Busy 0x0040 #define DAQBOARD2000_Dac3Busy 0x0080 -// DAC control +/* DAC control */ #define DAQBOARD2000_Dac0Enable 0x0021 #define DAQBOARD2000_Dac1Enable 0x0031 #define DAQBOARD2000_Dac2Enable 0x0041 @@ -292,18 +293,18 @@ struct daqboard2000_hw { #define DAQBOARD2000_TrigEnable 0x0001 #define DAQBOARD2000_TrigDisable 0x0000 -// Reference Dac Selection +/* Reference Dac Selection */ #define DAQBOARD2000_PosRefDacSelect 0x0100 #define DAQBOARD2000_NegRefDacSelect 0x0000 -static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int daqboard2000_detach(struct comedi_device * dev); +static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int daqboard2000_detach(struct comedi_device *dev); static struct comedi_driver driver_daqboard2000 = { - driver_name:"daqboard2000", - module:THIS_MODULE, - attach:daqboard2000_attach, - detach:daqboard2000_detach, + .driver_name = "daqboard2000", + .module = THIS_MODULE, + .attach = daqboard2000_attach, + .detach = daqboard2000_detach, }; struct daq200_boardtype { @@ -338,17 +339,17 @@ struct daqboard2000_private { #define devpriv ((struct daqboard2000_private *)dev->private) -static void writeAcqScanListEntry(struct comedi_device * dev, u16 entry) +static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) { struct daqboard2000_hw *fpga = devpriv->daq; -// comedi_udelay(4); +/* udelay(4); */ fpga->acqScanListFIFO = entry & 0x00ff; -// comedi_udelay(4); +/* udelay(4); */ fpga->acqScanListFIFO = (entry >> 8) & 0x00ff; } -static void setup_sampling(struct comedi_device * dev, int chan, int gain) +static void setup_sampling(struct comedi_device *dev, int chan, int gain) { u16 word0, word1, word2, word3; @@ -393,8 +394,8 @@ static void setup_sampling(struct comedi_device * dev, int chan, int gain) writeAcqScanListEntry(dev, word3); } -static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; struct daqboard2000_hw *fpga = devpriv->daq; @@ -425,14 +426,14 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s if (fpga->acqControl & DAQBOARD2000_AcqConfigPipeFull) { break; } - //comedi_udelay(2); + /* udelay(2); */ } fpga->acqControl = DAQBOARD2000_AdcPacerEnable; for (timeout = 0; timeout < 20; timeout++) { if (fpga->acqControl & DAQBOARD2000_AcqLogicScanning) { break; } - //comedi_udelay(2); + /* udelay(2); */ } for (timeout = 0; timeout < 20; timeout++) { if (fpga-> @@ -440,7 +441,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s DAQBOARD2000_AcqResultsFIFOHasValidData) { break; } - //comedi_udelay(2); + /* udelay(2); */ } data[i] = fpga->acqResultsFIFO; fpga->acqControl = DAQBOARD2000_AdcPacerDisable; @@ -450,8 +451,8 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s return i; } -static int daqboard2000_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqboard2000_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -463,8 +464,8 @@ static int daqboard2000_ao_insn_read(struct comedi_device * dev, struct comedi_s return i; } -static int daqboard2000_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqboard2000_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -476,54 +477,54 @@ static int daqboard2000_ao_insn_write(struct comedi_device * dev, struct comedi_ * OK, since it works OK without enabling the DAC's, let's keep * it as simple as possible... */ - //fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; comedi_udelay(1000); + /* fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; udelay(1000); */ fpga->dacSetting[chan] = data[i]; for (timeout = 0; timeout < 20; timeout++) { if ((fpga->dacControl & ((chan + 1) * 0x0010)) == 0) { break; } - //comedi_udelay(2); + /* udelay(2); */ } devpriv->ao_readback[chan] = data[i]; /* * Since we never enabled the DAC's, we don't need to disable it... - * fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; comedi_udelay(1000); + * fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; udelay(1000); */ } return i; } -static void daqboard2000_resetLocalBus(struct comedi_device * dev) +static void daqboard2000_resetLocalBus(struct comedi_device *dev) { printk("daqboard2000_resetLocalBus\n"); writel(DAQBOARD2000_SECRLocalBusHi, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); writel(DAQBOARD2000_SECRLocalBusLo, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); } -static void daqboard2000_reloadPLX(struct comedi_device * dev) +static void daqboard2000_reloadPLX(struct comedi_device *dev) { printk("daqboard2000_reloadPLX\n"); writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); writel(DAQBOARD2000_SECRReloadHi, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); } -static void daqboard2000_pulseProgPin(struct comedi_device * dev) +static void daqboard2000_pulseProgPin(struct comedi_device *dev) { printk("daqboard2000_pulseProgPin 1\n"); writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c); - comedi_udelay(10000); + udelay(10000); writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c); - comedi_udelay(10000); /* Not in the original code, but I like symmetry... */ + udelay(10000); /* Not in the original code, but I like symmetry... */ } -static int daqboard2000_pollCPLD(struct comedi_device * dev, int mask) +static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) { int result = 0; int i; @@ -536,17 +537,17 @@ static int daqboard2000_pollCPLD(struct comedi_device * dev, int mask) result = 1; break; } - comedi_udelay(100); + udelay(100); } - comedi_udelay(5); + udelay(5); return result; } -static int daqboard2000_writeCPLD(struct comedi_device * dev, int data) +static int daqboard2000_writeCPLD(struct comedi_device *dev, int data) { int result = 0; - comedi_udelay(10); + udelay(10); writew(data, devpriv->daq + 0x1000); if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) == DAQBOARD2000_CPLD_INIT) { @@ -555,7 +556,7 @@ static int daqboard2000_writeCPLD(struct comedi_device * dev, int data) return result; } -static int initialize_daqboard2000(struct comedi_device * dev, +static int initialize_daqboard2000(struct comedi_device *dev, unsigned char *cpld_array, int len) { int result = -EIO; @@ -613,75 +614,75 @@ static int initialize_daqboard2000(struct comedi_device * dev, return result; } -static void daqboard2000_adcStopDmaTransfer(struct comedi_device * dev) +static void daqboard2000_adcStopDmaTransfer(struct comedi_device *dev) { /* printk("Implement: daqboard2000_adcStopDmaTransfer\n");*/ } -static void daqboard2000_adcDisarm(struct comedi_device * dev) +static void daqboard2000_adcDisarm(struct comedi_device *dev) { struct daqboard2000_hw *fpga = devpriv->daq; /* Disable hardware triggers */ - comedi_udelay(2); + udelay(2); fpga->trigControl = DAQBOARD2000_TrigAnalog | DAQBOARD2000_TrigDisable; - comedi_udelay(2); + udelay(2); fpga->trigControl = DAQBOARD2000_TrigTTL | DAQBOARD2000_TrigDisable; /* Stop the scan list FIFO from loading the configuration pipe */ - comedi_udelay(2); + udelay(2); fpga->acqControl = DAQBOARD2000_SeqStopScanList; /* Stop the pacer clock */ - comedi_udelay(2); + udelay(2); fpga->acqControl = DAQBOARD2000_AdcPacerDisable; /* Stop the input dma (abort channel 1) */ daqboard2000_adcStopDmaTransfer(dev); } -static void daqboard2000_activateReferenceDacs(struct comedi_device * dev) +static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) { struct daqboard2000_hw *fpga = devpriv->daq; int timeout; - // Set the + reference dac value in the FPGA + /* Set the + reference dac value in the FPGA */ fpga->refDacs = 0x80 | DAQBOARD2000_PosRefDacSelect; for (timeout = 0; timeout < 20; timeout++) { if ((fpga->dacControl & DAQBOARD2000_RefBusy) == 0) { break; } - comedi_udelay(2); + udelay(2); } /* printk("DAQBOARD2000_PosRefDacSelect %d\n", timeout);*/ - // Set the - reference dac value in the FPGA + /* Set the - reference dac value in the FPGA */ fpga->refDacs = 0x80 | DAQBOARD2000_NegRefDacSelect; for (timeout = 0; timeout < 20; timeout++) { if ((fpga->dacControl & DAQBOARD2000_RefBusy) == 0) { break; } - comedi_udelay(2); + udelay(2); } /* printk("DAQBOARD2000_NegRefDacSelect %d\n", timeout);*/ } -static void daqboard2000_initializeCtrs(struct comedi_device * dev) +static void daqboard2000_initializeCtrs(struct comedi_device *dev) { /* printk("Implement: daqboard2000_initializeCtrs\n");*/ } -static void daqboard2000_initializeTmrs(struct comedi_device * dev) +static void daqboard2000_initializeTmrs(struct comedi_device *dev) { /* printk("Implement: daqboard2000_initializeTmrs\n");*/ } -static void daqboard2000_dacDisarm(struct comedi_device * dev) +static void daqboard2000_dacDisarm(struct comedi_device *dev) { /* printk("Implement: daqboard2000_dacDisarm\n");*/ } -static void daqboard2000_initializeAdc(struct comedi_device * dev) +static void daqboard2000_initializeAdc(struct comedi_device *dev) { daqboard2000_adcDisarm(dev); daqboard2000_activateReferenceDacs(dev); @@ -689,7 +690,7 @@ static void daqboard2000_initializeAdc(struct comedi_device * dev) daqboard2000_initializeTmrs(dev); } -static void daqboard2000_initializeDac(struct comedi_device * dev) +static void daqboard2000_initializeDac(struct comedi_device *dev) { daqboard2000_dacDisarm(dev); } @@ -717,7 +718,7 @@ static int daqboard2000_8255_cb(int dir, int port, int data, return result; } -static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int result = 0; struct comedi_subdevice *s; @@ -772,7 +773,8 @@ static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconf } } - if ((result = comedi_pci_enable(card, "daqboard2000")) < 0) { + result = comedi_pci_enable(card, "daqboard2000"); + if (result < 0) { printk(" failed to enable PCI device and request regions\n"); return -EIO; } @@ -849,7 +851,7 @@ static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconf return result; } -static int daqboard2000_detach(struct comedi_device * dev) +static int daqboard2000_detach(struct comedi_device *dev) { printk("comedi%d: daqboard2000: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index e4563331e963..c20cd8feb13d 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -65,12 +65,12 @@ driver. #define PCI_DEVICE_ID_PCIDAS08 0x29 #define PCIDAS08_SIZE 0x54 -// pci configuration registers +/* pci configuration registers */ #define INTCSR 0x4c #define INTR1_ENABLE 0x1 #define INTR1_HIGH_POLARITY 0x2 #define PCI_INTR_ENABLE 0x40 -#define INTR1_EDGE_TRIG 0x100 // requires high polarity +#define INTR1_EDGE_TRIG 0x100 /* requires high polarity */ #define CNTRL 0x50 #define CNTRL_DIR 0x2 #define CNTRL_INTR 0x4 @@ -154,20 +154,20 @@ driver. /* gainlist same as _pgx_ below */ -static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das08ao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static void i8254_set_mode_low(unsigned int base, int channel, unsigned int mode); @@ -248,211 +248,211 @@ static const int *const das08_gainlists[] = { static const struct das08_board_struct das08_boards[] = { { - name: "isa-das08", // cio-das08.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pg_none, - ai_encoding:das08_encode12, - ao: NULL, - ao_nbits:12, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:8, - i8254_offset:4, - iosize: 16, // unchecked + .name = "isa-das08", /* cio-das08.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .ao = NULL, + .ao_nbits = 12, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 8, + .i8254_offset = 4, + .iosize = 16, /* unchecked */ }, { - name: "das08-pgm", // cio-das08pgx.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgm, - ai_encoding:das08_encode12, - ao: NULL, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-pgm", /* cio-das08pgx.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgm, + .ai_encoding = das08_encode12, + .ao = NULL, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08-pgh", // cio-das08pgx.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgh, - ai_encoding:das08_encode12, - ao: NULL, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-pgh", /* cio-das08pgx.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgh, + .ai_encoding = das08_encode12, + .ao = NULL, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08-pgl", // cio-das08pgx.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgl, - ai_encoding:das08_encode12, - ao: NULL, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-pgl", /* cio-das08pgx.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgl, + .ai_encoding = das08_encode12, + .ao = NULL, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08-aoh", // cio-das08_aox.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgh, - ai_encoding:das08_encode12, - ao: das08ao_ao_winsn, // 8 - ao_nbits:12, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0x0c, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-aoh", /* cio-das08_aox.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgh, + .ai_encoding = das08_encode12, + .ao = das08ao_ao_winsn, /* 8 */ + .ao_nbits = 12, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08-aol", // cio-das08_aox.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgl, - ai_encoding:das08_encode12, - ao: das08ao_ao_winsn, // 8 - ao_nbits:12, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0x0c, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-aol", /* cio-das08_aox.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgl, + .ai_encoding = das08_encode12, + .ao = das08ao_ao_winsn, /* 8 */ + .ao_nbits = 12, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08-aom", // cio-das08_aox.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pgm, - ai_encoding:das08_encode12, - ao: das08ao_ao_winsn, // 8 - ao_nbits:12, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0x0c, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08-aom", /* cio-das08_aox.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pgm, + .ai_encoding = das08_encode12, + .ao = das08ao_ao_winsn, /* 8 */ + .ao_nbits = 12, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, { - name: "das08/jr-ao", // cio-das08-jr-ao.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pg_none, - ai_encoding:das08_encode12, - ao: das08jr_ao_winsn, - ao_nbits:12, - di: das08jr_di_rbits, - do_: das08jr_do_wbits, - do_nchan:8, - i8255_offset:0, - i8254_offset:0, - iosize: 16, // unchecked + .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .ao = das08jr_ao_winsn, + .ao_nbits = 12, + .di = das08jr_di_rbits, + .do_ = das08jr_do_wbits, + .do_nchan = 8, + .i8255_offset = 0, + .i8254_offset = 0, + .iosize = 16, /* unchecked */ }, { - name: "das08jr-16-ao", // cio-das08jr-16-ao.pdf - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:16, - ai_pg: das08_pg_none, - ai_encoding:das08_encode12, - ao: das08jr_ao_winsn, - ao_nbits:16, - di: das08jr_di_rbits, - do_: das08jr_do_wbits, - do_nchan:8, - i8255_offset:0, - i8254_offset:0x04, - iosize: 16, // unchecked + .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */ + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 16, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .ao = das08jr_ao_winsn, + .ao_nbits = 16, + .di = das08jr_di_rbits, + .do_ = das08jr_do_wbits, + .do_nchan = 8, + .i8255_offset = 0, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ }, #ifdef CONFIG_COMEDI_PCI { - name: "das08", // pci-das08 - id: PCI_DEVICE_ID_PCIDAS08, - bustype: pci, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_bipolar5, - ai_encoding:das08_encode12, - ao: NULL, - ao_nbits:0, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0, - i8254_offset:4, - iosize: 8, + .name = "das08", /* pci-das08 */ + .id = PCI_DEVICE_ID_PCIDAS08, + .bustype = pci, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_bipolar5, + .ai_encoding = das08_encode12, + .ao = NULL, + .ao_nbits = 0, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 4, + .iosize = 8, }, #endif { - name: "pc104-das08", - bustype: pc104, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_pg_none, - ai_encoding:das08_encode12, - ao: NULL, - ao_nbits:0, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:4, - i8255_offset:0, - i8254_offset:4, - iosize: 16, // unchecked + .name = "pc104-das08", + .bustype = pc104, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .ao = NULL, + .ao_nbits = 0, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 4, + .iosize = 16, /* unchecked */ }, #if 0 { - name: "das08/f", + .name = "das08/f", }, { - name: "das08jr", + .name = "das08jr", }, #endif { - name: "das08jr/16", - bustype: isa, - ai: das08_ai_rinsn, - ai_nbits:16, - ai_pg: das08_pg_none, - ai_encoding:das08_encode16, - ao: NULL, - ao_nbits:0, - di: das08jr_di_rbits, - do_: das08jr_do_wbits, - do_nchan:8, - i8255_offset:0, - i8254_offset:0, - iosize: 16, // unchecked + .name = "das08jr/16", + .bustype = isa, + .ai = das08_ai_rinsn, + .ai_nbits = 16, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode16, + .ao = NULL, + .ao_nbits = 0, + .di = das08jr_di_rbits, + .do_ = das08jr_do_wbits, + .do_nchan = 8, + .i8255_offset = 0, + .i8254_offset = 0, + .iosize = 16, /* unchecked */ }, #if 0 { - name: "das48-pga", // cio-das48-pga.pdf + .name = "das48-pga", /* cio-das48-pga.pdf */ }, { - name: "das08-pga-g2", // a KM board + .name = "das08-pga-g2", /* a KM board */ }, #endif }; @@ -460,39 +460,39 @@ static const struct das08_board_struct das08_boards[] = { #ifdef CONFIG_COMEDI_PCMCIA struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = { { - name: "pcm-das08", - id: 0x0, // XXX - bustype: pcmcia, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_bipolar5, - ai_encoding:das08_pcm_encode12, - ao: NULL, - ao_nbits:0, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:3, - i8255_offset:0, - i8254_offset:0, - iosize: 16, + .name = "pcm-das08", + .id = 0x0, /* XXX */ + .bustype = pcmcia, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_bipolar5, + .ai_encoding = das08_pcm_encode12, + .ao = NULL, + .ao_nbits = 0, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 3, + .i8255_offset = 0, + .i8254_offset = 0, + .iosize = 16, }, - // duplicate so driver name can be used also + /* duplicate so driver name can be used also */ { - name: "das08_cs", - id: 0x0, // XXX - bustype: pcmcia, - ai: das08_ai_rinsn, - ai_nbits:12, - ai_pg: das08_bipolar5, - ai_encoding:das08_pcm_encode12, - ao: NULL, - ao_nbits:0, - di: das08_di_rbits, - do_: das08_do_wbits, - do_nchan:3, - i8255_offset:0, - i8254_offset:0, - iosize: 16, + .name = "das08_cs", + .id = 0x0, /* XXX */ + .bustype = pcmcia, + .ai = das08_ai_rinsn, + .ai_nbits = 12, + .ai_pg = das08_bipolar5, + .ai_encoding = das08_pcm_encode12, + .ao = NULL, + .ao_nbits = 0, + .di = das08_di_rbits, + .do_ = das08_do_wbits, + .do_nchan = 3, + .i8255_offset = 0, + .i8254_offset = 0, + .iosize = 16, }, }; #endif @@ -512,8 +512,8 @@ MODULE_DEVICE_TABLE(pci, das08_pci_table); #define TIMEOUT 100000 -static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int chan; @@ -528,7 +528,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * inb(dev->iobase + DAS08_MSB); /* set multiplexer */ - spin_lock(&dev->spinlock); // lock to prevent race with digital output + spin_lock(&dev->spinlock); /* lock to prevent race with digital output */ devpriv->do_mux_bits &= ~DAS08_MUX_MASK; devpriv->do_mux_bits |= DAS08_MUX(chan); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); @@ -545,7 +545,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * /* clear over-range bits for 16-bit boards */ if (thisboard->ai_nbits == 16) if (inb(dev->iobase + DAS08_MSB) & 0x80) - rt_printk("das08: over-range\n"); + printk("das08: over-range\n"); /* trigger conversion */ outb_p(0, dev->iobase + DAS08_TRIG_12BIT); @@ -555,7 +555,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * break; } if (i == TIMEOUT) { - rt_printk("das08: timeout\n"); + printk("das08: timeout\n"); return -ETIME; } msb = inb(dev->iobase + DAS08_MSB); @@ -579,8 +579,8 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS)); @@ -588,19 +588,19 @@ static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int wbits; - // get current settings of digital output lines + /* get current settings of digital output lines */ wbits = (devpriv->do_mux_bits >> 4) & 0xf; - // null bits we are going to set + /* null bits we are going to set */ wbits &= ~data[0]; - // set new bit values + /* set new bit values */ wbits |= data[0] & data[1]; - // remember digital output bits - spin_lock(&dev->spinlock); // prevent race with setting of analog input mux + /* remember digital output bits */ + spin_lock(&dev->spinlock); /* prevent race with setting of analog input mux */ devpriv->do_mux_bits &= ~DAS08_DO_MASK; devpriv->do_mux_bits |= DAS08_OP(wbits); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); @@ -611,8 +611,8 @@ static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = inb(dev->iobase + DAS08JR_DIO); @@ -620,12 +620,12 @@ static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - // null bits we are going to set + /* null bits we are going to set */ devpriv->do_bits &= ~data[0]; - // set new bit values + /* set new bit values */ devpriv->do_bits |= data[0] & data[1]; outb(devpriv->do_bits, dev->iobase + DAS08JR_DIO); @@ -634,8 +634,8 @@ static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int lsb, msb; @@ -668,8 +668,8 @@ static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * a different method to force an update. * */ -static int das08ao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int lsb, msb; @@ -782,31 +782,31 @@ static unsigned int i8254_read_status(struct i8254_struct *st, int channel) return i8254_read_status_low(st->iobase, chan); } -static int das08_counter_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_counter_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = insn->chanspec; - //printk("Reading counter channel %d ",chan); + /* printk("Reading counter channel %d ",chan); */ data[0] = i8254_read_channel(&devpriv->i8254, chan); - //printk("=> 0x%08X\n",data[0]); + /* printk("=> 0x%08X\n",data[0]); */ return 1; } -static int das08_counter_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_counter_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = insn->chanspec; - //printk("Writing counter channel %d with 0x%04X\n",chan,data[0]); + /* printk("Writing counter channel %d with 0x%04X\n",chan,data[0]); */ i8254_write_channel(&devpriv->i8254, chan, data[0]); return 1; } -static int das08_counter_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das08_counter_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = insn->chanspec; @@ -827,25 +827,25 @@ static int das08_counter_config(struct comedi_device * dev, struct comedi_subdev return 2; } -static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it); +static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it); static struct comedi_driver driver_das08 = { - driver_name: DRV_NAME, - module:THIS_MODULE, - attach:das08_attach, - detach:das08_common_detach, - board_name:&das08_boards[0].name, - num_names:sizeof(das08_boards) / + .driver_name = DRV_NAME, + .module = THIS_MODULE, + .attach = das08_attach, + .detach = das08_common_detach, + .board_name = &das08_boards[0].name, + .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct), - offset:sizeof(struct das08_board_struct), + .offset = sizeof(struct das08_board_struct), }; -int das08_common_attach(struct comedi_device * dev, unsigned long iobase) +int das08_common_attach(struct comedi_device *dev, unsigned long iobase) { struct comedi_subdevice *s; int ret; - // allocate ioports for non-pcmcia, non-pci boards + /* allocate ioports for non-pcmcia, non-pci boards */ if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) { printk(" iobase 0x%lx\n", iobase); if (!request_region(iobase, thisboard->iosize, DRV_NAME)) { @@ -857,7 +857,8 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase) dev->board_name = thisboard->name; - if ((ret = alloc_subdevices(dev, 6)) < 0) + ret = alloc_subdevices(dev, 6); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -880,7 +881,7 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase) /* ao */ if (thisboard->ao) { s->type = COMEDI_SUBD_AO; -// XXX lacks read-back insn +/* XXX lacks read-back insn */ s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = (1 << thisboard->ao_nbits) - 1; @@ -952,7 +953,7 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase) return 0; } -static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; unsigned long iobase; @@ -961,11 +962,12 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it struct pci_dev *pdev; #endif - if ((ret = alloc_private(dev, sizeof(struct das08_private_struct))) < 0) + ret = alloc_private(dev, sizeof(struct das08_private_struct)); + if (ret < 0) return ret; printk("comedi%d: das08: ", dev->minor); - // deal with a pci board + /* deal with a pci board */ if (thisboard->bustype == pci) { #ifdef CONFIG_COMEDI_PCI if (it->options[0] || it->options[1]) { @@ -973,7 +975,7 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it it->options[0], it->options[1]); } printk("\n"); - // find card + /* find card */ for (pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pdev != NULL; pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) { @@ -995,12 +997,12 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it return -EIO; } devpriv->pdev = pdev; - // enable PCI device and reserve I/O spaces + /* enable PCI device and reserve I/O spaces */ if (comedi_pci_enable(pdev, DRV_NAME)) { printk(" Error enabling PCI device and requesting regions\n"); return -EIO; } - // read base addresses + /* read base addresses */ pci_iobase = pci_resource_start(pdev, 1); iobase = pci_resource_start(pdev, 2); printk("pcibase 0x%lx iobase 0x%lx\n", pci_iobase, iobase); @@ -1028,14 +1030,14 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it return das08_common_attach(dev, iobase); } -int das08_common_detach(struct comedi_device * dev) +int das08_common_detach(struct comedi_device *dev) { printk(KERN_INFO "comedi%d: das08: remove\n", dev->minor); if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 4); - // deallocate ioports for non-pcmcia, non-pci boards + /* deallocate ioports for non-pcmcia, non-pci boards */ if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) { if (dev->iobase) release_region(dev->iobase, thisboard->iosize); diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 69089ce690f2..7cdb3fc4daee 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -25,14 +25,14 @@ #define _DAS08_H enum das08_bustype { isa, pci, pcmcia, pc104 }; -// different ways ai data is encoded in first two registers +/* different ways ai data is encoded in first two registers */ enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 }; enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, das08_pgm }; struct das08_board_struct { const char *name; - unsigned int id; // id for pci/pcmcia boards + unsigned int id; /* id for pci/pcmcia boards */ enum das08_bustype bustype; void *ai; unsigned int ai_nbits; @@ -45,13 +45,13 @@ struct das08_board_struct { unsigned int do_nchan; unsigned int i8255_offset; unsigned int i8254_offset; - unsigned int iosize; // number of ioports used + unsigned int iosize; /* number of ioports used */ }; struct i8254_struct { - int channels; // available channels. Some could be used internally. - int logic2phys[3]; // to know which physical channel is. - int mode[3]; // the index is the real counter. + int channels; /* available channels. Some could be used internally. */ + int logic2phys[3]; /* to know which physical channel is. */ + int mode[3]; /* the index is the real counter. */ unsigned int iobase; }; @@ -61,18 +61,18 @@ struct i8254_struct { #define I8254_CTRL 3 struct das08_private_struct { - unsigned int do_mux_bits; // bits for do/mux register on boards without seperate do register - unsigned int do_bits; // bits for do register on boards with register dedicated to digital out only + unsigned int do_mux_bits; /* bits for do/mux register on boards without seperate do register */ + unsigned int do_bits; /* bits for do register on boards with register dedicated to digital out only */ const unsigned int *pg_gainlist; - struct pci_dev *pdev; // struct for pci-das08 - unsigned int pci_iobase; // additional base address for pci-das08 + struct pci_dev *pdev; /* struct for pci-das08 */ + unsigned int pci_iobase; /* additional base address for pci-das08 */ struct i8254_struct i8254; }; #define NUM_DAS08_CS_BOARDS 2 extern struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS]; -int das08_common_attach(struct comedi_device * dev, unsigned long iobase); -int das08_common_detach(struct comedi_device * dev); +int das08_common_attach(struct comedi_device *dev, unsigned long iobase); +int das08_common_detach(struct comedi_device *dev); #endif /* _DAS08_H */ diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index be6c88788c4b..8e4464100e1e 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -46,7 +46,7 @@ Command support does not exist, but could be added for this board. #include "das08.h" -// pcmcia includes +/* pcmcia includes */ #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> #include <pcmcia/cistpl.h> @@ -56,30 +56,31 @@ static struct pcmcia_device *cur_dev = NULL; #define thisboard ((const struct das08_board_struct *)dev->board_ptr) -static int das08_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it); +static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it); static struct comedi_driver driver_das08_cs = { - driver_name:"das08_cs", - module:THIS_MODULE, - attach:das08_cs_attach, - detach:das08_common_detach, - board_name:&das08_cs_boards[0].name, - num_names:sizeof(das08_cs_boards) / + .driver_name = "das08_cs", + .module = THIS_MODULE, + .attach = das08_cs_attach, + .detach = das08_common_detach, + .board_name = &das08_cs_boards[0].name, + .num_names = sizeof(das08_cs_boards) / sizeof(struct das08_board_struct), - offset:sizeof(struct das08_board_struct), + .offset = sizeof(struct das08_board_struct), }; -static int das08_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; unsigned long iobase; - struct pcmcia_device *link = cur_dev; // XXX hack + struct pcmcia_device *link = cur_dev; /* XXX hack */ - if ((ret = alloc_private(dev, sizeof(struct das08_private_struct))) < 0) + ret = alloc_private(dev, sizeof(struct das08_private_struct)); + if (ret < 0) return ret; printk("comedi%d: das08_cs: ", dev->minor); - // deal with a pci board + /* deal with a pci board */ if (thisboard->bustype == pcmcia) { if (link == NULL) { @@ -264,14 +265,23 @@ static void das08_pcmcia_config(struct pcmcia_device *link) tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; last_fn = GetFirstTuple; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) goto cs_failed; + last_fn = GetTupleData; - if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) goto cs_failed; + last_fn = ParseTuple; - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) goto cs_failed; + link->conf.ConfigBase = parse.config.base; link->conf.Present = parse.config.rmask[0]; @@ -289,13 +299,20 @@ static void das08_pcmcia_config(struct pcmcia_device *link) */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; last_fn = GetFirstTuple; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) goto cs_failed; + while (1) { cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); - if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) goto next_entry; - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) goto next_entry; if (cfg->flags & CISTPL_CFTABLE_DEFAULT) @@ -341,13 +358,16 @@ static void das08_pcmcia_config(struct pcmcia_device *link) next_entry: last_fn = GetNextTuple; - if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) + + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) goto cs_failed; } if (link->conf.Attributes & CONF_ENABLE_IRQ) { last_fn = RequestIRQ; - if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) goto cs_failed; } @@ -357,7 +377,8 @@ static void das08_pcmcia_config(struct pcmcia_device *link) card and host interface into "Memory and IO" mode. */ last_fn = RequestConfiguration; - if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret) goto cs_failed; /* diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 6b6b042099de..59af86a8bbfb 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -79,6 +79,7 @@ Computer boards manuals also available from their website www.measurementcomputi */ #include <linux/pci.h> +#include <linux/interrupt.h> #include <asm/dma.h> #include "../comedidev.h" @@ -87,16 +88,16 @@ Computer boards manuals also available from their website www.measurementcomputi #include "comedi_fc.h" #undef DEBUG -//#define DEBUG +/* #define DEBUG */ #ifdef DEBUG -#define DEBUG_PRINT(format, args...) rt_printk("das16: " format, ## args) +#define DEBUG_PRINT(format, args...) printk("das16: " format, ## args) #else #define DEBUG_PRINT(format, args...) #endif -#define DAS16_SIZE 20 // number of ioports -#define DAS16_DMA_SIZE 0xff00 // size in bytes of allocated dma buffer +#define DAS16_SIZE 20 /* number of ioports */ +#define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */ /* cio-das16.pdf @@ -184,7 +185,7 @@ Computer boards manuals also available from their website www.measurementcomputi */ -static const int sample_size = 2; // size in bytes of a sample from board +static const int sample_size = 2; /* size in bytes of a sample from board */ #define DAS16_TRIG 0 #define DAS16_AI_LSB 0 @@ -265,7 +266,7 @@ static const struct comedi_lrange range_das1x02_unip = { 4, { } }; static const struct comedi_lrange range_das16jr = { 9, { - // also used by 16/330 + /* also used by 16/330 */ BIP_RANGE(10), BIP_RANGE(5), BIP_RANGE(2.5), @@ -326,40 +327,40 @@ struct munge_info { unsigned have_byte:1; }; -static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); - -static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s); -static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void das16_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s); +static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void das16_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *array, unsigned int num_bytes, unsigned int start_chan_index); -static void das16_reset(struct comedi_device * dev); -static irqreturn_t das16_dma_interrupt(int irq, void *d PT_REGS_ARG); +static void das16_reset(struct comedi_device *dev); +static irqreturn_t das16_dma_interrupt(int irq, void *d); static void das16_timer_interrupt(unsigned long arg); -static void das16_interrupt(struct comedi_device * dev); +static void das16_interrupt(struct comedi_device *dev); -static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns, +static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, int flags); -static int das1600_mode_detect(struct comedi_device * dev); -static unsigned int das16_suggest_transfer_size(struct comedi_device * dev, +static int das1600_mode_detect(struct comedi_device *dev); +static unsigned int das16_suggest_transfer_size(struct comedi_device *dev, struct comedi_cmd cmd); -static void reg_dump(struct comedi_device * dev); +static void reg_dump(struct comedi_device *dev); struct das16_board { const char *name; void *ai; unsigned int ai_nbits; - unsigned int ai_speed; // max conversion speed in nanosec + unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_pg; void *ao; unsigned int ao_nbits; @@ -375,339 +376,337 @@ struct das16_board { static const struct das16_board das16_boards[] = { { - name: "das-16", - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:15000, - ai_pg: das16_pg_none, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x10, - i8254_offset:0x0c, - size: 0x14, - id: 0x00, + .name = "das-16", + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 15000, + .ai_pg = das16_pg_none, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, }, { - name: "das-16g", - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:15000, - ai_pg: das16_pg_none, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x10, - i8254_offset:0x0c, - size: 0x14, - id: 0x00, + .name = "das-16g", + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 15000, + .ai_pg = das16_pg_none, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, }, { - name: "das-16f", - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:8500, - ai_pg: das16_pg_none, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x10, - i8254_offset:0x0c, - size: 0x14, - id: 0x00, + .name = "das-16f", + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 8500, + .ai_pg = das16_pg_none, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, }, { - name: "cio-das16", // cio-das16.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:20000, - ai_pg: das16_pg_none, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x10, - i8254_offset:0x0c, - size: 0x14, - id: 0x80, + .name = "cio-das16", /* cio-das16.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 20000, + .ai_pg = das16_pg_none, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x80, }, { - name: "cio-das16/f", // das16.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_none, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x10, - i8254_offset:0x0c, - size: 0x14, - id: 0x80, + .name = "cio-das16/f", /* das16.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_none, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x80, }, { - name: "cio-das16/jr", // cio-das16jr.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:7692, - ai_pg: das16_pg_16jr, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x10, - id: 0x00, + .name = "cio-das16/jr", /* cio-das16jr.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 7692, + .ai_pg = das16_pg_16jr, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, }, { - name: "pc104-das16jr", // pc104-das16jr_xx.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:3300, - ai_pg: das16_pg_16jr, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x10, - id: 0x00, + .name = "pc104-das16jr", /* pc104-das16jr_xx.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 3300, + .ai_pg = das16_pg_16jr, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, }, { - name: "cio-das16jr/16", // cio-das16jr_16.pdf - ai: das16_ai_rinsn, - ai_nbits:16, - ai_speed:10000, - ai_pg: das16_pg_16jr_16, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x10, - id: 0x00, + .name = "cio-das16jr/16", /* cio-das16jr_16.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 16, + .ai_speed = 10000, + .ai_pg = das16_pg_16jr_16, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, }, { - name: "pc104-das16jr/16", // pc104-das16jr_xx.pdf - ai: das16_ai_rinsn, - ai_nbits:16, - ai_speed:10000, - ai_pg: das16_pg_16jr_16, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x10, - id: 0x00, + .name = "pc104-das16jr/16", /* pc104-das16jr_xx.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 16, + .ai_speed = 10000, + .ai_pg = das16_pg_16jr_16, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, }, { - name: "das-1201", // 4924.pdf (keithley user's manual) - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:20000, - ai_pg: das16_pg_none, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0x20, + .name = "das-1201", /* 4924.pdf (keithley user's manual) */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 20000, + .ai_pg = das16_pg_none, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0x20, }, { - name: "das-1202", // 4924.pdf (keithley user's manual) - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_none, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0x20, + .name = "das-1202", /* 4924.pdf (keithley user's manual) */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_none, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0x20, }, { - name: "das-1401", // 4919.pdf and 4922.pdf (keithley user's manual) - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_1601, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x0, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 + .name = "das-1401", /* 4919.pdf and 4922.pdf (keithley user's manual) */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_1601, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ }, { - name: "das-1402", // 4919.pdf and 4922.pdf (keithley user's manual) - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_1602, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x0, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 + .name = "das-1402", /* 4919.pdf and 4922.pdf (keithley user's manual) */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ }, { - name: "das-1601", // 4919.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_1601, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "das-1601", /* 4919.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_1601, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "das-1602", // 4919.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_1602, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "das-1602", /* 4919.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1401/12", // cio-das1400_series.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:6250, - ai_pg: das16_pg_1601, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1401/12", /* cio-das1400_series.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 6250, + .ai_pg = das16_pg_1601, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1402/12", // cio-das1400_series.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:6250, - ai_pg: das16_pg_1602, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1402/12", /* cio-das1400_series.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 6250, + .ai_pg = das16_pg_1602, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1402/16", // cio-das1400_series.pdf - ai: das16_ai_rinsn, - ai_nbits:16, - ai_speed:10000, - ai_pg: das16_pg_1602, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1402/16", /* cio-das1400_series.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 16, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1601/12", // cio-das160x-1x.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:6250, - ai_pg: das16_pg_1601, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1601/12", /* cio-das160x-1x.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 6250, + .ai_pg = das16_pg_1601, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1602/12", // cio-das160x-1x.pdf - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:10000, - ai_pg: das16_pg_1602, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1602/12", /* cio-das160x-1x.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das1602/16", // cio-das160x-1x.pdf - ai: das16_ai_rinsn, - ai_nbits:16, - ai_speed:10000, - ai_pg: das16_pg_1602, - ao: das16_ao_winsn, - ao_nbits:12, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0x400, - i8254_offset:0x0c, - size: 0x408, - id: 0xc0}, + .name = "cio-das1602/16", /* cio-das160x-1x.pdf */ + .ai = das16_ai_rinsn, + .ai_nbits = 16, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .ao = das16_ao_winsn, + .ao_nbits = 12, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0}, { - name: "cio-das16/330", // ? - ai: das16_ai_rinsn, - ai_nbits:12, - ai_speed:3030, - ai_pg: das16_pg_16jr, - ao: NULL, - di: das16_di_rbits, - do_: das16_do_wbits, - i8255_offset:0, - i8254_offset:0x0c, - size: 0x14, - id: 0xf0}, + .name = "cio-das16/330", /* ? */ + .ai = das16_ai_rinsn, + .ai_nbits = 12, + .ai_speed = 3030, + .ai_pg = das16_pg_16jr, + .ao = NULL, + .di = das16_di_rbits, + .do_ = das16_do_wbits, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0xf0}, #if 0 { - name: "das16/330i", // ? + .name = "das16/330i", /* ? */ }, { - name: "das16/jr/ctr5", // ? + .name = "das16/jr/ctr5", /* ? */ }, { - name: "cio-das16/m1/16", // cio-das16_m1_16.pdf, this board is a bit quirky, no dma + .name = "cio-das16/m1/16", /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */ }, #endif }; -#define n_das16_boards ((sizeof(das16_boards))/(sizeof(struct das16_board))) - -static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das16_detach(struct comedi_device * dev); +static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das16_detach(struct comedi_device *dev); static struct comedi_driver driver_das16 = { - driver_name:"das16", - module:THIS_MODULE, - attach:das16_attach, - detach:das16_detach, - board_name:&das16_boards[0].name, - num_names:n_das16_boards, - offset:sizeof(das16_boards[0]), + .driver_name = "das16", + .module = THIS_MODULE, + .attach = das16_attach, + .detach = das16_detach, + .board_name = &das16_boards[0].name, + .num_names = ARRAY_SIZE(das16_boards), + .offset = sizeof(das16_boards[0]), }; #define DAS16_TIMEOUT 1000 @@ -719,31 +718,31 @@ static inline int timer_period(void) return HZ / 20; } struct das16_private_struct { - unsigned int ai_unipolar; // unipolar flag - unsigned int ai_singleended; // single ended flag - unsigned int clockbase; // master clock speed in ns - volatile unsigned int control_state; // dma, interrupt and trigger control bits - volatile unsigned long adc_byte_count; // number of bytes remaining - unsigned int divisor1; // divisor dividing master clock to get conversion frequency - unsigned int divisor2; // divisor dividing master clock to get conversion frequency - unsigned int dma_chan; // dma channel + unsigned int ai_unipolar; /* unipolar flag */ + unsigned int ai_singleended; /* single ended flag */ + unsigned int clockbase; /* master clock speed in ns */ + volatile unsigned int control_state; /* dma, interrupt and trigger control bits */ + volatile unsigned long adc_byte_count; /* number of bytes remaining */ + unsigned int divisor1; /* divisor dividing master clock to get conversion frequency */ + unsigned int divisor2; /* divisor dividing master clock to get conversion frequency */ + unsigned int dma_chan; /* dma channel */ uint16_t *dma_buffer[2]; dma_addr_t dma_buffer_addr[2]; unsigned int current_buffer; - volatile unsigned int dma_transfer_size; // target number of bytes to transfer per dma shot - // user-defined analog input and output ranges defined from config options + volatile unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */ + /* user-defined analog input and output ranges defined from config options */ struct comedi_lrange *user_ai_range_table; struct comedi_lrange *user_ao_range_table; - struct timer_list timer; // for timed interrupt + struct timer_list timer; /* for timed interrupt */ volatile short timer_running; - volatile short timer_mode; // true if using timer mode + volatile short timer_mode; /* true if using timer mode */ }; #define devpriv ((struct das16_private_struct *)(dev->private)) #define thisboard ((struct das16_board *)(dev->board_ptr)) -static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0, tmp; int gain, start_chan, i; @@ -757,7 +756,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * tmp = cmd->scan_begin_src; mask = TRIG_FOLLOW; - // if board supports burst mode + /* if board supports burst mode */ if (thisboard->size > 0x400) mask |= TRIG_TIMER | TRIG_EXT; cmd->scan_begin_src &= mask; @@ -766,7 +765,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * tmp = cmd->convert_src; mask = TRIG_TIMER | TRIG_EXT; - // if board supports burst mode + /* if board supports burst mode */ if (thisboard->size > 0x400) mask |= TRIG_NOW; cmd->convert_src &= mask; @@ -797,7 +796,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT) err++; - // make sure scan_begin_src and convert_src dont conflict + /* make sure scan_begin_src and convert_src dont conflict */ if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW) err++; if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW) @@ -824,7 +823,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * cmd->scan_end_arg = cmd->chanlist_len; err++; } - // check against maximum frequency + /* check against maximum frequency */ if (cmd->scan_begin_src == TRIG_TIMER) { if (cmd->scan_begin_arg < thisboard->ai_speed * cmd->chanlist_len) { @@ -849,10 +848,10 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * if (err) return 3; - // step 4: fix up arguments + /* step 4: fix up arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { unsigned int tmp = cmd->scan_begin_arg; - // set divisors, correct timing arguments + /* set divisors, correct timing arguments */ i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK); @@ -860,7 +859,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * } if (cmd->convert_src == TRIG_TIMER) { unsigned int tmp = cmd->convert_arg; - // set divisors, correct timing arguments + /* set divisors, correct timing arguments */ i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK); @@ -869,7 +868,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * if (err) return 4; - // check channel/gain list against card's limitations + /* check channel/gain list against card's limitations */ if (cmd->chanlist) { gain = CR_RANGE(cmd->chanlist[0]); start_chan = CR_CHAN(cmd->chanlist[0]); @@ -893,7 +892,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -916,11 +915,11 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * devpriv->adc_byte_count = cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t); - // disable conversions for das1600 mode + /* disable conversions for das1600 mode */ if (thisboard->size > 0x400) { outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV); } - // set scan limits + /* set scan limits */ byte = CR_CHAN(cmd->chanlist[0]); byte |= CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]) << 4; outb(byte, dev->iobase + DAS16_MUX); @@ -945,7 +944,7 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * if (thisboard->size > 0x400) { if (cmd->convert_src == TRIG_NOW) { outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST); - // set burst length + /* set burst length */ byte |= BURST_LEN_BITS(cmd->chanlist_len - 1); } else { outb(0, dev->iobase + DAS1600_BURST); @@ -953,7 +952,7 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * } outb(byte, dev->iobase + DAS16_PACER); - // set up dma transfer + /* set up dma transfer */ flags = claim_dma_lock(); disable_dma(devpriv->dma_chan); /* clear flip-flop to make sure 2-byte registers for @@ -962,13 +961,13 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * devpriv->current_buffer = 0; set_dma_addr(devpriv->dma_chan, devpriv->dma_buffer_addr[devpriv->current_buffer]); - // set appropriate size of transfer + /* set appropriate size of transfer */ devpriv->dma_transfer_size = das16_suggest_transfer_size(dev, *cmd); set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); enable_dma(devpriv->dma_chan); release_dma_lock(flags); - // set up interrupt + /* set up interrupt */ if (devpriv->timer_mode) { devpriv->timer_running = 1; devpriv->timer.expires = jiffies + timer_period(); @@ -996,18 +995,18 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); /* disable interrupts, dma and pacer clocked conversions */ devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE; outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); if (devpriv->dma_chan) disable_dma(devpriv->dma_chan); - // disable SW timer + /* disable SW timer */ if (devpriv->timer_mode && devpriv->timer_running) { devpriv->timer_running = 0; del_timer(&devpriv->timer); @@ -1018,12 +1017,12 @@ static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s) outb(0, dev->iobase + DAS1600_BURST); } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } -static void das16_reset(struct comedi_device * dev) +static void das16_reset(struct comedi_device *dev) { outb(0, dev->iobase + DAS16_STATUS); outb(0, dev->iobase + DAS16_CONTROL); @@ -1031,15 +1030,15 @@ static void das16_reset(struct comedi_device * dev) outb(0, dev->iobase + DAS16_CNTR_CONTROL); } -static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int range; int chan; int msb, lsb; - // disable interrupts and pacing + /* disable interrupts and pacing */ devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK; outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); @@ -1064,7 +1063,7 @@ static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * break; } if (i == DAS16_TIMEOUT) { - rt_printk("das16: timeout\n"); + printk("das16: timeout\n"); return -ETIME; } msb = inb(dev->iobase + DAS16_AI_MSB); @@ -1079,8 +1078,8 @@ static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -1091,17 +1090,17 @@ static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int wbits; - // only set bits that have been masked + /* only set bits that have been masked */ data[0] &= 0xf; wbits = s->state; - // zero bits that have been masked + /* zero bits that have been masked */ wbits &= ~data[0]; - // set masked bits + /* set masked bits */ wbits |= data[0] & data[1]; s->state = wbits; data[1] = wbits; @@ -1111,8 +1110,8 @@ static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int lsb, msb; @@ -1135,7 +1134,7 @@ static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * return i; } -static irqreturn_t das16_dma_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t das16_dma_interrupt(int irq, void *d) { int status; struct comedi_device *dev = d; @@ -1169,7 +1168,7 @@ static void das16_timer_interrupt(unsigned long arg) an even transfer count after disabling dma channel. */ -static int disable_dma_on_even(struct comedi_device * dev) +static int disable_dma_on_even(struct comedi_device *dev) { int residue; int i; @@ -1182,7 +1181,7 @@ static int disable_dma_on_even(struct comedi_device * dev) enable_dma(devpriv->dma_chan); for (j = 0; j < enable_timeout; ++j) { int new_residue; - comedi_udelay(2); + udelay(2); new_residue = get_dma_residue(devpriv->dma_chan); if (new_residue != residue) break; @@ -1197,7 +1196,7 @@ static int disable_dma_on_even(struct comedi_device * dev) return residue; } -static void das16_interrupt(struct comedi_device * dev) +static void das16_interrupt(struct comedi_device *dev) { unsigned long dma_flags, spin_flags; struct comedi_subdevice *s = dev->read_subdev; @@ -1210,7 +1209,7 @@ static void das16_interrupt(struct comedi_device * dev) comedi_error(dev, "premature interrupt"); return; } - // initialize async here to make sure it is not NULL + /* initialize async here to make sure it is not NULL */ async = s->async; cmd = &async->cmd; @@ -1219,9 +1218,9 @@ static void das16_interrupt(struct comedi_device * dev) return; } - comedi_spin_lock_irqsave(&dev->spinlock, spin_flags); + spin_lock_irqsave(&dev->spinlock, spin_flags); if ((devpriv->control_state & DMA_ENABLE) == 0) { - comedi_spin_unlock_irqrestore(&dev->spinlock, spin_flags); + spin_unlock_irqrestore(&dev->spinlock, spin_flags); DEBUG_PRINT("interrupt while dma disabled?\n"); return; } @@ -1230,7 +1229,7 @@ static void das16_interrupt(struct comedi_device * dev) clear_dma_ff(devpriv->dma_chan); residue = disable_dma_on_even(dev); - // figure out how many points to read + /* figure out how many points to read */ if (residue > devpriv->dma_transfer_size) { comedi_error(dev, "residue > transfer size!\n"); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; @@ -1247,12 +1246,12 @@ static void das16_interrupt(struct comedi_device * dev) devpriv->current_buffer = (devpriv->current_buffer + 1) % 2; devpriv->adc_byte_count -= num_bytes; - // figure out how many bytes for next transfer + /* figure out how many bytes for next transfer */ if (cmd->stop_src == TRIG_COUNT && devpriv->timer_mode == 0 && devpriv->dma_transfer_size > devpriv->adc_byte_count) devpriv->dma_transfer_size = devpriv->adc_byte_count; - // re-enable dma + /* re-enable dma */ if ((async->events & COMEDI_CB_EOA) == 0) { set_dma_addr(devpriv->dma_chan, devpriv->dma_buffer_addr[devpriv->current_buffer]); @@ -1265,7 +1264,7 @@ static void das16_interrupt(struct comedi_device * dev) } release_dma_lock(dma_flags); - comedi_spin_unlock_irqrestore(&dev->spinlock, spin_flags); + spin_unlock_irqrestore(&dev->spinlock, spin_flags); cfc_write_array_to_buffer(s, devpriv->dma_buffer[buffer_index], num_bytes); @@ -1273,7 +1272,7 @@ static void das16_interrupt(struct comedi_device * dev) cfc_handle_events(dev, s); } -static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns, +static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, int rounding_flags) { i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), @@ -1286,7 +1285,7 @@ static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns, return ns; } -static void reg_dump(struct comedi_device * dev) +static void reg_dump(struct comedi_device *dev) { DEBUG_PRINT("********DAS1600 REGISTER DUMP********\n"); DEBUG_PRINT("DAS16_MUX: %x\n", inb(dev->iobase + DAS16_MUX)); @@ -1304,7 +1303,7 @@ static void reg_dump(struct comedi_device * dev) inb(dev->iobase + DAS1600_STATUS_B)); } -static int das16_probe(struct comedi_device * dev, struct comedi_devconfig * it) +static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) { int status; int diobits; @@ -1338,7 +1337,7 @@ static int das16_probe(struct comedi_device * dev, struct comedi_devconfig * it) return 0; } -static int das1600_mode_detect(struct comedi_device * dev) +static int das1600_mode_detect(struct comedi_device *dev) { int status = 0; @@ -1366,7 +1365,7 @@ static int das1600_mode_detect(struct comedi_device * dev) * 3 Clock speed (in MHz) */ -static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret; @@ -1391,7 +1390,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it printk("comedi%d: das16:", dev->minor); - // check that clock setting is valid + /* check that clock setting is valid */ if (it->options[3]) { if (it->options[3] != 0 && it->options[3] != 1 && it->options[3] != 10) { @@ -1400,7 +1399,8 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it } } - if ((ret = alloc_private(dev, sizeof(struct das16_private_struct))) < 0) + ret = alloc_private(dev, sizeof(struct das16_private_struct)); + if (ret < 0) return ret; if (thisboard->size < 0x400) { @@ -1431,27 +1431,28 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it dev->iobase = iobase; - // probe id bits to make sure they are consistent + /* probe id bits to make sure they are consistent */ if (das16_probe(dev, it)) { printk(" id bits do not match selected board, aborting\n"); return -EINVAL; } dev->board_name = thisboard->name; - // get master clock speed + /* get master clock speed */ if (thisboard->size < 0x400) { if (it->options[3]) devpriv->clockbase = 1000 / it->options[3]; else - devpriv->clockbase = 1000; // 1 MHz default + devpriv->clockbase = 1000; /* 1 MHz default */ } else { das1600_mode_detect(dev); } /* now for the irq */ if (irq > 1 && irq < 8) { - if ((ret = comedi_request_irq(irq, das16_dma_interrupt, 0, - "das16", dev)) < 0) + ret = request_irq(irq, das16_dma_interrupt, 0, "das16", dev); + + if (ret < 0) return ret; dev->irq = irq; printk(" ( irq = %u )", irq); @@ -1462,10 +1463,10 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it return -EINVAL; } - // initialize dma + /* initialize dma */ dma_chan = it->options[2]; if (dma_chan == 1 || dma_chan == 3) { - // allocate dma buffers + /* allocate dma buffers */ int i; for (i = 0; i < 2; i++) { devpriv->dma_buffer[i] = pci_alloc_consistent(NULL, @@ -1491,27 +1492,27 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it return -EINVAL; } - // get any user-defined input range + /* get any user-defined input range */ if (thisboard->ai_pg == das16_pg_none && (it->options[4] || it->options[5])) { - // allocate single-range range table + /* allocate single-range range table */ devpriv->user_ai_range_table = kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange), GFP_KERNEL); - // initialize ai range + /* initialize ai range */ devpriv->user_ai_range_table->length = 1; user_ai_range = devpriv->user_ai_range_table->range; user_ai_range->min = it->options[4]; user_ai_range->max = it->options[5]; user_ai_range->flags = UNIT_volt; } - // get any user-defined output range + /* get any user-defined output range */ if (it->options[6] || it->options[7]) { - // allocate single-range range table + /* allocate single-range range table */ devpriv->user_ao_range_table = kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange), GFP_KERNEL); - // initialize ao range + /* initialize ao range */ devpriv->user_ao_range_table->length = 1; user_ao_range = devpriv->user_ao_range_table->range; user_ao_range->min = it->options[6]; @@ -1526,7 +1527,8 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it } devpriv->timer_mode = timer_mode ? 1 : 0; - if ((ret = alloc_subdevices(dev, 5)) < 0) + ret = alloc_subdevices(dev, 5); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -1545,7 +1547,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it s->subdev_flags |= SDF_DIFF; } s->maxdata = (1 << thisboard->ai_nbits) - 1; - if (devpriv->user_ai_range_table) { // user defined ai range + if (devpriv->user_ai_range_table) { /* user defined ai range */ s->range_table = devpriv->user_ai_range_table; } else if (devpriv->ai_unipolar) { s->range_table = das16_ai_uni_lranges[thisboard->ai_pg]; @@ -1568,7 +1570,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = (1 << thisboard->ao_nbits) - 1; - if (devpriv->user_ao_range_table) { // user defined ao range + if (devpriv->user_ao_range_table) { /* user defined ao range */ s->range_table = devpriv->user_ao_range_table; } else { s->range_table = &range_unknown; @@ -1600,7 +1602,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = thisboard->do_; - // initialize digital output lines + /* initialize digital output lines */ outb(s->state, dev->iobase + DAS16_DIO); } else { s->type = COMEDI_SUBD_UNUSED; @@ -1620,7 +1622,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it devpriv->control_state = DAS16_IRQ(dev->irq); outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); - // turn on das1600 mode if available + /* turn on das1600 mode if available */ if (thisboard->size > 0x400) { outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE); outb(0, dev->iobase + DAS1600_CONV); @@ -1630,7 +1632,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it return 0; } -static int das16_detach(struct comedi_device * dev) +static int das16_detach(struct comedi_device *dev) { printk("comedi%d: das16: remove\n", dev->minor); @@ -1656,7 +1658,7 @@ static int das16_detach(struct comedi_device * dev) } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) { if (thisboard->size < 0x400) { @@ -1673,8 +1675,8 @@ static int das16_detach(struct comedi_device * dev) COMEDI_INITCLEANUP(driver_das16); -// utility function that suggests a dma transfer size in bytes -static unsigned int das16_suggest_transfer_size(struct comedi_device * dev, +/* utility function that suggests a dma transfer size in bytes */ +static unsigned int das16_suggest_transfer_size(struct comedi_device *dev, struct comedi_cmd cmd) { unsigned int size; @@ -1692,18 +1694,18 @@ static unsigned int das16_suggest_transfer_size(struct comedi_device * dev, freq = 1000000000 / cmd.convert_arg; else if (cmd.scan_begin_src == TRIG_TIMER) freq = (1000000000 / cmd.scan_begin_arg) * cmd.chanlist_len; - // return some default value + /* return some default value */ else freq = 0xffffffff; if (cmd.flags & TRIG_WAKE_EOS) { size = sample_size * cmd.chanlist_len; } else { - // make buffer fill in no more than 1/3 second + /* make buffer fill in no more than 1/3 second */ size = (freq / 3) * sample_size; } - // set a minimum and maximum size allowed + /* set a minimum and maximum size allowed */ if (size > DAS16_DMA_SIZE) size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size; else if (size < sample_size) @@ -1715,7 +1717,7 @@ static unsigned int das16_suggest_transfer_size(struct comedi_device * dev, return size; } -static void das16_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static void das16_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *array, unsigned int num_bytes, unsigned int start_chan_index) { unsigned int i, num_samples = num_bytes / sizeof(short); diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 0e423e199ed6..3da8bf47cbf6 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -59,6 +59,7 @@ irq can be omitted, although the cmd interface will not work without it. */ #include <linux/ioport.h> +#include <linux/interrupt.h> #include "../comedidev.h" #include "8255.h" @@ -68,9 +69,9 @@ irq can be omitted, although the cmd interface will not work without it. #define DAS16M1_SIZE 16 #define DAS16M1_SIZE2 8 -#define DAS16M1_XTAL 100 //10 MHz master clock +#define DAS16M1_XTAL 100 /* 10 MHz master clock */ -#define FIFO_SIZE 1024 // 1024 sample fifo +#define FIFO_SIZE 1024 /* 1024 sample fifo */ /* CIO-DAS16_M1.pdf @@ -92,7 +93,7 @@ irq can be omitted, although the cmd interface will not work without it. */ -#define DAS16M1_AI 0 // 16-bit wide register +#define DAS16M1_AI 0 /* 16-bit wide register */ #define AI_CHAN(x) ((x) & 0xf) #define DAS16M1_CS 2 #define EXT_TRIG_BIT 0x1 @@ -131,23 +132,23 @@ static const struct comedi_lrange range_das16m1 = { 9, } }; -static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s); -static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s); +static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static int das16m1_poll(struct comedi_device * dev, struct comedi_subdevice * s); -static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG); -static void das16m1_handler(struct comedi_device * dev, unsigned int status); +static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s); +static irqreturn_t das16m1_interrupt(int irq, void *d); +static void das16m1_handler(struct comedi_device *dev, unsigned int status); -static unsigned int das16m1_set_pacer(struct comedi_device * dev, unsigned int ns, +static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns, int round_flag); static int das16m1_irq_bits(unsigned int irq); @@ -159,36 +160,34 @@ struct das16m1_board { static const struct das16m1_board das16m1_boards[] = { { - name: "cio-das16/m1", // CIO-DAS16_M1.pdf - ai_speed:1000, // 1MHz max speed + .name = "cio-das16/m1", /* CIO-DAS16_M1.pdf */ + .ai_speed = 1000, /* 1MHz max speed */ }, }; -#define das16m1_num_boards ((sizeof(das16m1_boards)) / (sizeof(das16m1_boards[0]))) - -static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das16m1_detach(struct comedi_device * dev); +static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das16m1_detach(struct comedi_device *dev); static struct comedi_driver driver_das16m1 = { - driver_name:"das16m1", - module:THIS_MODULE, - attach:das16m1_attach, - detach:das16m1_detach, - board_name:&das16m1_boards[0].name, - num_names:das16m1_num_boards, - offset:sizeof(das16m1_boards[0]), + .driver_name = "das16m1", + .module = THIS_MODULE, + .attach = das16m1_attach, + .detach = das16m1_detach, + .board_name = &das16m1_boards[0].name, + .num_names = ARRAY_SIZE(das16m1_boards), + .offset = sizeof(das16m1_boards[0]), }; struct das16m1_private_struct { unsigned int control_state; - volatile unsigned int adc_count; // number of samples completed + volatile unsigned int adc_count; /* number of samples completed */ /* initial value in lower half of hardware conversion counter, * needed to keep track of whether new count has been loaded into * counter yet (loaded by first sample conversion) */ u16 initial_hw_count; short ai_buffer[FIFO_SIZE]; - unsigned int do_bits; // saves status of digital output bits - unsigned int divisor1; // divides master clock to obtain conversion speed - unsigned int divisor2; // divides master clock to obtain conversion speed + unsigned int do_bits; /* saves status of digital output bits */ + unsigned int divisor1; /* divides master clock to obtain conversion speed */ + unsigned int divisor2; /* divides master clock to obtain conversion speed */ }; #define devpriv ((struct das16m1_private_struct *)(dev->private)) #define thisboard ((const struct das16m1_board *)(dev->board_ptr)) @@ -200,8 +199,8 @@ static inline short munge_sample(short data) return (data >> 4) & 0xfff; } -static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { unsigned int err = 0, tmp, i; @@ -299,10 +298,10 @@ static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice if (err) return 4; - // check chanlist against board's peculiarities + /* check chanlist against board's peculiarities */ if (cmd->chanlist && cmd->chanlist_len > 1) { for (i = 0; i < cmd->chanlist_len; i++) { - // even/odd channels must go into even/odd queue addresses + /* even/odd channels must go into even/odd queue addresses */ if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) { comedi_error(dev, "bad chanlist:\n" " even/odd channels must go have even/odd chanlist indices"); @@ -322,7 +321,7 @@ static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -337,7 +336,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice devpriv->control_state &= ~INTE & ~PACER_MASK; outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); - // set software count + /* set software count */ devpriv->adc_count = 0; /* Initialize lower half of hardware counter, used to determine how * many samples are in fifo. Value doesn't actually load into counter @@ -361,7 +360,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice das16m1_set_pacer(dev, cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); - // set control & status register + /* set control & status register */ byte = 0; /* if we are using external start trigger (also board dislikes having * both start and conversion triggers external simultaneously) */ @@ -385,7 +384,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { devpriv->control_state &= ~INTE & ~PACER_MASK; outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); @@ -393,8 +392,8 @@ static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int byte; @@ -430,8 +429,8 @@ static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice return n; } -static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -442,17 +441,17 @@ static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int wbits; - // only set bits that have been masked + /* only set bits that have been masked */ data[0] &= 0xf; wbits = devpriv->do_bits; - // zero bits that have been masked + /* zero bits that have been masked */ wbits &= ~data[0]; - // set masked bits + /* set masked bits */ wbits |= data[0] & data[1]; devpriv->do_bits = wbits; data[1] = wbits; @@ -462,21 +461,21 @@ static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int das16m1_poll(struct comedi_device * dev, struct comedi_subdevice * s) +static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; unsigned int status; - // prevent race with interrupt handler - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* prevent race with interrupt handler */ + spin_lock_irqsave(&dev->spinlock, flags); status = inb(dev->iobase + DAS16M1_CS); das16m1_handler(dev, status); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return s->async->buf_write_count - s->async->buf_read_count; } -static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t das16m1_interrupt(int irq, void *d) { int status; struct comedi_device *dev = d; @@ -485,7 +484,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG) comedi_error(dev, "premature interrupt"); return IRQ_HANDLED; } - // prevent race with comedi_poll() + /* prevent race with comedi_poll() */ spin_lock(&dev->spinlock); status = inb(dev->iobase + DAS16M1_CS); @@ -505,7 +504,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static void munge_sample_array(short * array, unsigned int num_elements) +static void munge_sample_array(short *array, unsigned int num_elements) { unsigned int i; @@ -514,7 +513,7 @@ static void munge_sample_array(short * array, unsigned int num_elements) } } -static void das16m1_handler(struct comedi_device * dev, unsigned int status) +static void das16m1_handler(struct comedi_device *dev, unsigned int status) { struct comedi_subdevice *s; struct comedi_async *async; @@ -527,7 +526,7 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status) async->events = 0; cmd = &async->cmd; - // figure out how many samples are in fifo + /* figure out how many samples are in fifo */ hw_counter = i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1); /* make sure hardware counter reading is not bogus due to initial value * not having been loaded yet */ @@ -542,12 +541,12 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status) * hardware counter. Work it out, and this is what you get. */ num_samples = -hw_counter - devpriv->adc_count; } - // check if we only need some of the points + /* check if we only need some of the points */ if (cmd->stop_src == TRIG_COUNT) { if (num_samples > cmd->stop_arg * cmd->chanlist_len) num_samples = cmd->stop_arg * cmd->chanlist_len; } - // make sure we dont try to get too many points if fifo has overrun + /* make sure we dont try to get too many points if fifo has overrun */ if (num_samples > FIFO_SIZE) num_samples = FIFO_SIZE; insw(dev->iobase, devpriv->ai_buffer, num_samples); @@ -578,7 +577,7 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status) /* This function takes a time in nanoseconds and sets the * * 2 pacer clocks to the closest frequency possible. It also * * returns the actual sampling period. */ -static unsigned int das16m1_set_pacer(struct comedi_device * dev, unsigned int ns, +static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns, int rounding_flags) { i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1), @@ -626,7 +625,7 @@ static int das16m1_irq_bits(unsigned int irq) return -1; break; } - return (ret << 4); + return ret << 4; } /* @@ -635,7 +634,7 @@ static int das16m1_irq_bits(unsigned int irq) * 1 IRQ */ -static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret; @@ -646,8 +645,8 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * printk("comedi%d: das16m1:", dev->minor); - if ((ret = alloc_private(dev, - sizeof(struct das16m1_private_struct))) < 0) + ret = alloc_private(dev, sizeof(struct das16m1_private_struct)); + if (ret < 0) return ret; dev->board_name = thisboard->name; @@ -669,10 +668,10 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * /* now for the irq */ irq = it->options[1]; - // make sure it is valid + /* make sure it is valid */ if (das16m1_irq_bits(irq) >= 0) { - ret = comedi_request_irq(irq, das16m1_interrupt, 0, - driver_das16m1.driver_name, dev); + ret = request_irq(irq, das16m1_interrupt, 0, + driver_das16m1.driver_name, dev); if (ret < 0) { printk(", irq unavailable\n"); return ret; @@ -687,7 +686,8 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * return -EINVAL; } - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -728,10 +728,10 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * /* 8255 */ subdev_8255_init(dev, s, NULL, dev->iobase + DAS16M1_82C55); - // disable upper half of hardware conversion counter so it doesn't mess with us + /* disable upper half of hardware conversion counter so it doesn't mess with us */ outb(TOTAL_CLEAR, dev->iobase + DAS16M1_8254_FIRST_CNTRL); - // initialize digital output lines + /* initialize digital output lines */ outb(devpriv->do_bits, dev->iobase + DAS16M1_DIO); /* set the interrupt level */ @@ -744,17 +744,17 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int das16m1_detach(struct comedi_device * dev) +static int das16m1_detach(struct comedi_device *dev) { printk("comedi%d: das16m1: remove\n", dev->minor); -// das16m1_reset(dev); +/* das16m1_reset(dev); */ if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 3); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) { release_region(dev->iobase, DAS16M1_SIZE); diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index cd4cd4e6a79b..a3434088c9e6 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -100,6 +100,7 @@ TODO: read insn for analog out */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -108,12 +109,12 @@ TODO: #include "8253.h" #include "comedi_fc.h" -// misc. defines -#define DAS1800_SIZE 16 //uses 16 io addresses -#define FIFO_SIZE 1024 // 1024 sample fifo -#define TIMER_BASE 200 // 5 Mhz master clock -#define UNIPOLAR 0x4 // bit that determines whether input range is uni/bipolar -#define DMA_BUF_SIZE 0x1ff00 // size in bytes of dma buffers +/* misc. defines */ +#define DAS1800_SIZE 16 /* uses 16 io addresses */ +#define FIFO_SIZE 1024 /* 1024 sample fifo */ +#define TIMER_BASE 200 /* 5 Mhz master clock */ +#define UNIPOLAR 0x4 /* bit that determines whether input range is uni/bipolar */ +#define DMA_BUF_SIZE 0x1ff00 /* size in bytes of dma buffers */ /* Registers for the das1800 */ #define DAS1800_FIFO 0x0 @@ -138,7 +139,7 @@ TODO: #define DMA_CH5_CH6 0x5 #define DMA_CH6_CH7 0x6 #define DMA_CH7_CH5 0x7 -#define DMA_ENABLED 0x3 //mask used to determine if dma is enabled +#define DMA_ENABLED 0x3 /* mask used to determine if dma is enabled */ #define DMA_DUAL 0x4 #define IRQ3 0x8 #define IRQ5 0x10 @@ -156,7 +157,7 @@ TODO: #define SD 0x40 #define UB 0x80 #define DAS1800_STATUS 0x7 -// bits that prevent interrupt status bits (and CVEN) from being cleared on write +/* bits that prevent interrupt status bits (and CVEN) from being cleared on write */ #define CLEAR_INTR_MASK (CVEN_MASK | 0x1f) #define INT 0x1 #define DMATC 0x2 @@ -164,14 +165,14 @@ TODO: #define OVF 0x10 #define FHF 0x20 #define FNE 0x40 -#define CVEN_MASK 0x40 // masks CVEN on write +#define CVEN_MASK 0x40 /* masks CVEN on write */ #define CVEN 0x80 #define DAS1800_BURST_LENGTH 0x8 #define DAS1800_BURST_RATE 0x9 #define DAS1800_QRAM_ADDRESS 0xa #define DAS1800_COUNTER 0xc -#define IOBASE2 0x400 //offset of additional ioports used on 'ao' cards +#define IOBASE2 0x400 /* offset of additional ioports used on 'ao' cards */ enum { das1701st, das1701st_da, das1702st, das1702st_da, das1702hr, @@ -180,39 +181,39 @@ enum { das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao }; -static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das1800_detach(struct comedi_device * dev); -static int das1800_probe(struct comedi_device * dev); -static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG); -static int das1800_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s); -static void das1800_ai_handler(struct comedi_device * dev); -static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevice * s, +static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das1800_detach(struct comedi_device *dev); +static int das1800_probe(struct comedi_device *dev); +static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static irqreturn_t das1800_interrupt(int irq, void *d); +static int das1800_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s); +static void das1800_ai_handler(struct comedi_device *dev); +static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int status); -static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevice * s); -static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_subdevice * s, - unsigned int channel, uint16_t * buffer); -static void das1800_handle_fifo_half_full(struct comedi_device * dev, - struct comedi_subdevice * s); -static void das1800_handle_fifo_not_empty(struct comedi_device * dev, - struct comedi_subdevice * s); -static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das1800_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); - -static int das1800_set_frequency(struct comedi_device * dev); +static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice *s); +static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned int channel, uint16_t *buffer); +static void das1800_handle_fifo_half_full(struct comedi_device *dev, + struct comedi_subdevice *s); +static void das1800_handle_fifo_not_empty(struct comedi_device *dev, + struct comedi_subdevice *s); +static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int das1800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das1800_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das1800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das1800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +static int das1800_set_frequency(struct comedi_device *dev); static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode); -static unsigned int suggest_transfer_size(struct comedi_cmd * cmd); +static unsigned int suggest_transfer_size(struct comedi_cmd *cmd); -// analog input ranges +/* analog input ranges */ static const struct comedi_lrange range_ai_das1801 = { 8, { @@ -259,202 +260,202 @@ struct das1800_board { */ static const struct das1800_board das1800_boards[] = { { - name: "das-1701st", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1801, + .name = "das-1701st", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1801, }, { - name: "das-1701st-da", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:1, - ao_n_chan:4, - range_ai:&range_ai_das1801, + .name = "das-1701st-da", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 1, + .ao_n_chan = 4, + .range_ai = &range_ai_das1801, }, { - name: "das-1702st", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1802, + .name = "das-1702st", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1802, }, { - name: "das-1702st-da", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:1, - ao_n_chan:4, - range_ai:&range_ai_das1802, + .name = "das-1702st-da", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 1, + .ao_n_chan = 4, + .range_ai = &range_ai_das1802, }, { - name: "das-1702hr", - ai_speed:20000, - resolution:16, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1802, + .name = "das-1702hr", + .ai_speed = 20000, + .resolution = 16, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1802, }, { - name: "das-1702hr-da", - ai_speed:20000, - resolution:16, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:1, - ao_n_chan:2, - range_ai:&range_ai_das1802, + .name = "das-1702hr-da", + .ai_speed = 20000, + .resolution = 16, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 1, + .ao_n_chan = 2, + .range_ai = &range_ai_das1802, }, { - name: "das-1701ao", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:2, - ao_n_chan:2, - range_ai:&range_ai_das1801, + .name = "das-1701ao", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 2, + .ao_n_chan = 2, + .range_ai = &range_ai_das1801, }, { - name: "das-1702ao", - ai_speed:6250, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:2, - ao_n_chan:2, - range_ai:&range_ai_das1802, + .name = "das-1702ao", + .ai_speed = 6250, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 2, + .ao_n_chan = 2, + .range_ai = &range_ai_das1802, }, { - name: "das-1801st", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1801, + .name = "das-1801st", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1801, }, { - name: "das-1801st-da", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:4, - range_ai:&range_ai_das1801, + .name = "das-1801st-da", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 4, + .range_ai = &range_ai_das1801, }, { - name: "das-1802st", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1802, + .name = "das-1802st", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1802, }, { - name: "das-1802st-da", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:1, - ao_n_chan:4, - range_ai:&range_ai_das1802, + .name = "das-1802st-da", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 1, + .ao_n_chan = 4, + .range_ai = &range_ai_das1802, }, { - name: "das-1802hr", - ai_speed:10000, - resolution:16, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:0, - ao_n_chan:0, - range_ai:&range_ai_das1802, + .name = "das-1802hr", + .ai_speed = 10000, + .resolution = 16, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 0, + .ao_n_chan = 0, + .range_ai = &range_ai_das1802, }, { - name: "das-1802hr-da", - ai_speed:10000, - resolution:16, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:1, - ao_n_chan:2, - range_ai:&range_ai_das1802, + .name = "das-1802hr-da", + .ai_speed = 10000, + .resolution = 16, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 1, + .ao_n_chan = 2, + .range_ai = &range_ai_das1802, }, { - name: "das-1801hc", - ai_speed:3000, - resolution:12, - qram_len:64, - common: 0, - do_n_chan:8, - ao_ability:1, - ao_n_chan:2, - range_ai:&range_ai_das1801, + .name = "das-1801hc", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 64, + .common = 0, + .do_n_chan = 8, + .ao_ability = 1, + .ao_n_chan = 2, + .range_ai = &range_ai_das1801, }, { - name: "das-1802hc", - ai_speed:3000, - resolution:12, - qram_len:64, - common: 0, - do_n_chan:8, - ao_ability:1, - ao_n_chan:2, - range_ai:&range_ai_das1802, + .name = "das-1802hc", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 64, + .common = 0, + .do_n_chan = 8, + .ao_ability = 1, + .ao_n_chan = 2, + .range_ai = &range_ai_das1802, }, { - name: "das-1801ao", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:2, - ao_n_chan:2, - range_ai:&range_ai_das1801, + .name = "das-1801ao", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 2, + .ao_n_chan = 2, + .range_ai = &range_ai_das1801, }, { - name: "das-1802ao", - ai_speed:3000, - resolution:12, - qram_len:256, - common: 1, - do_n_chan:4, - ao_ability:2, - ao_n_chan:2, - range_ai:&range_ai_das1802, + .name = "das-1802ao", + .ai_speed = 3000, + .resolution = 12, + .qram_len = 256, + .common = 1, + .do_n_chan = 4, + .ao_ability = 2, + .ao_n_chan = 2, + .range_ai = &range_ai_das1802, }, }; @@ -485,7 +486,7 @@ struct das1800_private { #define devpriv ((struct das1800_private *)dev->private) -// analog out range for boards with basic analog out +/* analog out range for boards with basic analog out */ static const struct comedi_lrange range_ao_1 = { 1, { @@ -493,7 +494,7 @@ static const struct comedi_lrange range_ao_1 = { } }; -// analog out range for 'ao' boards +/* analog out range for 'ao' boards */ /* static const struct comedi_lrange range_ao_2 = { 2, @@ -505,13 +506,13 @@ static const struct comedi_lrange range_ao_2 = { */ static struct comedi_driver driver_das1800 = { - driver_name:"das1800", - module:THIS_MODULE, - attach:das1800_attach, - detach:das1800_detach, - num_names:sizeof(das1800_boards) / sizeof(struct das1800_board), - board_name:&das1800_boards[0].name, - offset:sizeof(struct das1800_board), + .driver_name = "das1800", + .module = THIS_MODULE, + .attach = das1800_attach, + .detach = das1800_detach, + .num_names = ARRAY_SIZE(das1800_boards), + .board_name = &das1800_boards[0].name, + .offset = sizeof(struct das1800_board), }; /* @@ -520,31 +521,31 @@ static struct comedi_driver driver_das1800 = { */ COMEDI_INITCLEANUP(driver_das1800); -static int das1800_init_dma(struct comedi_device * dev, unsigned int dma0, +static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0, unsigned int dma1) { unsigned long flags; - // need an irq to do dma + /* need an irq to do dma */ if (dev->irq && dma0) { - //encode dma0 and dma1 into 2 digit hexadecimal for switch + /* encode dma0 and dma1 into 2 digit hexadecimal for switch */ switch ((dma0 & 0x7) | (dma1 << 4)) { - case 0x5: // dma0 == 5 + case 0x5: /* dma0 == 5 */ devpriv->dma_bits |= DMA_CH5; break; - case 0x6: // dma0 == 6 + case 0x6: /* dma0 == 6 */ devpriv->dma_bits |= DMA_CH6; break; - case 0x7: // dma0 == 7 + case 0x7: /* dma0 == 7 */ devpriv->dma_bits |= DMA_CH7; break; - case 0x65: // dma0 == 5, dma1 == 6 + case 0x65: /* dma0 == 5, dma1 == 6 */ devpriv->dma_bits |= DMA_CH5_CH6; break; - case 0x76: // dma0 == 6, dma1 == 7 + case 0x76: /* dma0 == 6, dma1 == 7 */ devpriv->dma_bits |= DMA_CH6_CH7; break; - case 0x57: // dma0 == 7, dma1 == 5 + case 0x57: /* dma0 == 7, dma1 == 5 */ devpriv->dma_bits |= DMA_CH7_CH5; break; default: @@ -590,7 +591,7 @@ static int das1800_init_dma(struct comedi_device * dev, unsigned int dma0, return 0; } -static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = it->options[0]; @@ -638,7 +639,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * dev->board_ptr = das1800_boards + board; dev->board_name = thisboard->name; - // if it is an 'ao' board with fancy analog out then we need extra io ports + /* if it is an 'ao' board with fancy analog out then we need extra io ports */ if (thisboard->ao_ability == 2) { iobase2 = iobase + IOBASE2; if (!request_region(iobase2, DAS1800_SIZE, @@ -651,7 +652,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * /* grab our IRQ */ if (irq) { - if (comedi_request_irq(irq, das1800_interrupt, 0, + if (request_irq(irq, das1800_interrupt, 0, driver_das1800.driver_name, dev)) { printk(" unable to allocate irq %u\n", irq); return -EINVAL; @@ -659,7 +660,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * } dev->irq = irq; - // set bits that tell card which irq to use + /* set bits that tell card which irq to use */ switch (irq) { case 0: break; @@ -751,12 +752,12 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * das1800_cancel(dev, dev->read_subdev); - // initialize digital out channels + /* initialize digital out channels */ outb(devpriv->do_bits, dev->iobase + DAS1800_DIGITAL); - // initialize analog out channels + /* initialize analog out channels */ if (thisboard->ao_ability == 1) { - // select 'update' dac channel for baseAddress + 0x0 + /* select 'update' dac channel for baseAddress + 0x0 */ outb(DAC(thisboard->ao_n_chan - 1), dev->iobase + DAS1800_SELECT); outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC); @@ -765,13 +766,13 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; }; -static int das1800_detach(struct comedi_device * dev) +static int das1800_detach(struct comedi_device *dev) { /* only free stuff if it has been allocated by _attach */ if (dev->iobase) release_region(dev->iobase, DAS1800_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->private) { if (devpriv->iobase2) release_region(devpriv->iobase2, DAS1800_SIZE); @@ -793,7 +794,7 @@ static int das1800_detach(struct comedi_device * dev) /* probes and checks das-1800 series board type */ -static int das1800_probe(struct comedi_device * dev) +static int das1800_probe(struct comedi_device *dev) { int id; int board; @@ -867,19 +868,19 @@ static int das1800_probe(struct comedi_device * dev) return -1; } -static int das1800_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s) +static int das1800_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - // prevent race with interrupt handler - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* prevent race with interrupt handler */ + spin_lock_irqsave(&dev->spinlock, flags); das1800_ai_handler(dev); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return s->async->buf_write_count - s->async->buf_read_count; } -static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t das1800_interrupt(int irq, void *d) { struct comedi_device *dev = d; unsigned int status; @@ -901,15 +902,15 @@ static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG) } /* clear the interrupt status bit INT */ outb(CLEAR_INTR_MASK & ~INT, dev->iobase + DAS1800_STATUS); - // handle interrupt + /* handle interrupt */ das1800_ai_handler(dev); spin_unlock(&dev->spinlock); return IRQ_HANDLED; } -// the guts of the interrupt handler, that is shared with das1800_ai_poll -static void das1800_ai_handler(struct comedi_device * dev) +/* the guts of the interrupt handler, that is shared with das1800_ai_poll */ +static void das1800_ai_handler(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + 0; /* analog input subdevice */ struct comedi_async *async = s->async; @@ -917,22 +918,22 @@ static void das1800_ai_handler(struct comedi_device * dev) unsigned int status = inb(dev->iobase + DAS1800_STATUS); async->events = 0; - // select adc for base address + 0 + /* select adc for base address + 0 */ outb(ADC, dev->iobase + DAS1800_SELECT); - // dma buffer full + /* dma buffer full */ if (devpriv->irq_dma_bits & DMA_ENABLED) { - // look for data from dma transfer even if dma terminal count hasn't happened yet + /* look for data from dma transfer even if dma terminal count hasn't happened yet */ das1800_handle_dma(dev, s, status); - } else if (status & FHF) { // if fifo half full + } else if (status & FHF) { /* if fifo half full */ das1800_handle_fifo_half_full(dev, s); - } else if (status & FNE) { // if fifo not empty + } else if (status & FNE) { /* if fifo not empty */ das1800_handle_fifo_not_empty(dev, s); } async->events |= COMEDI_CB_BLOCK; /* if the card's fifo has overflowed */ if (status & OVF) { - // clear OVF interrupt bit + /* clear OVF interrupt bit */ outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS); comedi_error(dev, "DAS1800 FIFO overflow"); das1800_cancel(dev, s); @@ -940,19 +941,19 @@ static void das1800_ai_handler(struct comedi_device * dev) comedi_event(dev, s); return; } - // stop taking data if appropriate + /* stop taking data if appropriate */ /* stop_src TRIG_EXT */ if (status & CT0TC) { - // clear CT0TC interrupt bit + /* clear CT0TC interrupt bit */ outb(CLEAR_INTR_MASK & ~CT0TC, dev->iobase + DAS1800_STATUS); - // make sure we get all remaining data from board before quitting + /* make sure we get all remaining data from board before quitting */ if (devpriv->irq_dma_bits & DMA_ENABLED) das1800_flush_dma(dev, s); else das1800_handle_fifo_not_empty(dev, s); das1800_cancel(dev, s); /* disable hardware conversions */ async->events |= COMEDI_CB_EOA; - } else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) { // stop_src TRIG_COUNT + } else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) { /* stop_src TRIG_COUNT */ das1800_cancel(dev, s); /* disable hardware conversions */ async->events |= COMEDI_CB_EOA; } @@ -962,7 +963,7 @@ static void das1800_ai_handler(struct comedi_device * dev) return; } -static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevice * s, +static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int status) { unsigned long flags; @@ -971,7 +972,7 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi flags = claim_dma_lock(); das1800_flush_dma_channel(dev, s, devpriv->dma_current, devpriv->dma_current_buf); - // re-enable dma channel + /* re-enable dma channel */ set_dma_addr(devpriv->dma_current, virt_to_bus(devpriv->dma_current_buf)); set_dma_count(devpriv->dma_current, devpriv->dma_transfer_size); @@ -979,11 +980,11 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi release_dma_lock(flags); if (status & DMATC) { - // clear DMATC interrupt bit + /* clear DMATC interrupt bit */ outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS); - // switch dma channels for next time, if appropriate + /* switch dma channels for next time, if appropriate */ if (dual_dma) { - // read data from the other channel next time + /* read data from the other channel next time */ if (devpriv->dma_current == devpriv->dma0) { devpriv->dma_current = devpriv->dma1; devpriv->dma_current_buf = devpriv->ai_buf1; @@ -997,14 +998,14 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi return; } -static inline uint16_t munge_bipolar_sample(const struct comedi_device * dev, +static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev, uint16_t sample) { sample += 1 << (thisboard->resolution - 1); return sample; } -static void munge_data(struct comedi_device * dev, uint16_t * array, +static void munge_data(struct comedi_device *dev, uint16_t *array, unsigned int num_elements) { unsigned int i; @@ -1023,8 +1024,8 @@ static void munge_data(struct comedi_device * dev, uint16_t * array, /* Utility function used by das1800_flush_dma() and das1800_handle_dma(). * Assumes dma lock is held */ -static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_subdevice * s, - unsigned int channel, uint16_t * buffer) +static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned int channel, uint16_t *buffer) { unsigned int num_bytes, num_samples; struct comedi_cmd *cmd = &s->async->cmd; @@ -1035,7 +1036,7 @@ static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_ * get set correctly */ clear_dma_ff(channel); - // figure out how many points to read + /* figure out how many points to read */ num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel); num_samples = num_bytes / sizeof(short); @@ -1053,7 +1054,7 @@ static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_ /* flushes remaining data from board when external trigger has stopped aquisition * and we are using dma transfers */ -static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevice * s) +static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL; @@ -1063,7 +1064,7 @@ static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevic devpriv->dma_current_buf); if (dual_dma) { - // switch to other channel and flush it + /* switch to other channel and flush it */ if (devpriv->dma_current == devpriv->dma0) { devpriv->dma_current = devpriv->dma1; devpriv->dma_current_buf = devpriv->ai_buf1; @@ -1077,14 +1078,14 @@ static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevic release_dma_lock(flags); - // get any remaining samples in fifo + /* get any remaining samples in fifo */ das1800_handle_fifo_not_empty(dev, s); return; } -static void das1800_handle_fifo_half_full(struct comedi_device * dev, - struct comedi_subdevice * s) +static void das1800_handle_fifo_half_full(struct comedi_device *dev, + struct comedi_subdevice *s) { int numPoints = 0; /* number of points to read */ struct comedi_cmd *cmd = &s->async->cmd; @@ -1102,8 +1103,8 @@ static void das1800_handle_fifo_half_full(struct comedi_device * dev, return; } -static void das1800_handle_fifo_not_empty(struct comedi_device * dev, - struct comedi_subdevice * s) +static void das1800_handle_fifo_not_empty(struct comedi_device *dev, + struct comedi_subdevice *s) { short dpnt; int unipolar; @@ -1126,7 +1127,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device * dev, return; } -static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */ outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */ @@ -1139,8 +1140,8 @@ static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice * } /* test analog input cmd */ -static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -1180,7 +1181,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde /* step 2: make sure trigger sources are unique and mutually compatible */ - // uniqueness check + /* uniqueness check */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) err++; if (cmd->scan_begin_src != TRIG_FOLLOW && @@ -1192,7 +1193,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) err++; - //compatibility check + /* compatibility check */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_TIMER) err++; @@ -1244,7 +1245,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - // if we are not in burst mode + /* if we are not in burst mode */ if (cmd->scan_begin_src == TRIG_FOLLOW) { tmp_arg = cmd->convert_arg; /* calculate counter values that give desired timing */ @@ -1255,9 +1256,9 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde if (tmp_arg != cmd->convert_arg) err++; } - // if we are in burst mode + /* if we are in burst mode */ else { - // check that convert_arg is compatible + /* check that convert_arg is compatible */ tmp_arg = cmd->convert_arg; cmd->convert_arg = burst_convert_arg(cmd->convert_arg, @@ -1266,7 +1267,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde err++; if (cmd->scan_begin_src == TRIG_TIMER) { - // if scans are timed faster than conversion rate allows + /* if scans are timed faster than conversion rate allows */ if (cmd->convert_arg * cmd->chanlist_len > cmd->scan_begin_arg) { cmd->scan_begin_arg = @@ -1290,7 +1291,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde if (err) return 4; - // make sure user is not trying to mix unipolar and bipolar ranges + /* make sure user is not trying to mix unipolar and bipolar ranges */ if (cmd->chanlist) { unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR; for (i = 1; i < cmd->chanlist_len; i++) { @@ -1311,14 +1312,14 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde /* analog input cmd interface */ -// first, some utility functions used in the main ai_do_cmd() +/* first, some utility functions used in the main ai_do_cmd() */ -// returns appropriate bits for control register a, depending on command +/* returns appropriate bits for control register a, depending on command */ static int control_a_bits(struct comedi_cmd cmd) { int control_a; - control_a = FFEN; //enable fifo + control_a = FFEN; /* enable fifo */ if (cmd.stop_src == TRIG_EXT) { control_a |= ATEN; } @@ -1336,7 +1337,7 @@ static int control_a_bits(struct comedi_cmd cmd) return control_a; } -// returns appropriate bits for control register c, depending on command +/* returns appropriate bits for control register c, depending on command */ static int control_c_bits(struct comedi_cmd cmd) { int control_c; @@ -1346,7 +1347,7 @@ static int control_c_bits(struct comedi_cmd cmd) * select unipolar / bipolar */ aref = CR_AREF(cmd.chanlist[0]); - control_c = UQEN; //enable upper qram addresses + control_c = UQEN; /* enable upper qram addresses */ if (aref != AREF_DIFF) control_c |= SD; if (aref == AREF_COMMON) @@ -1355,7 +1356,7 @@ static int control_c_bits(struct comedi_cmd cmd) if (CR_RANGE(cmd.chanlist[0]) & UNIPOLAR) control_c |= UB; switch (cmd.scan_begin_src) { - case TRIG_FOLLOW: // not in burst mode + case TRIG_FOLLOW: /* not in burst mode */ switch (cmd.convert_src) { case TRIG_TIMER: /* trig on cascaded counters */ @@ -1370,11 +1371,11 @@ static int control_c_bits(struct comedi_cmd cmd) } break; case TRIG_TIMER: - // burst mode with internal pacer clock + /* burst mode with internal pacer clock */ control_c |= BMDE | IPCLK; break; case TRIG_EXT: - // burst mode with external trigger + /* burst mode with external trigger */ control_c |= BMDE | XPCLK; break; default: @@ -1384,12 +1385,12 @@ static int control_c_bits(struct comedi_cmd cmd) return control_c; } -// sets up counters -static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd) +/* sets up counters */ +static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd) { - // setup cascaded counters for conversion/scan frequency + /* setup cascaded counters for conversion/scan frequency */ switch (cmd.scan_begin_src) { - case TRIG_FOLLOW: // not in burst mode + case TRIG_FOLLOW: /* not in burst mode */ if (cmd.convert_src == TRIG_TIMER) { /* set conversion frequency */ i8253_cascade_ns_to_timer_2div(TIMER_BASE, @@ -1401,7 +1402,7 @@ static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd) } } break; - case TRIG_TIMER: // in burst mode + case TRIG_TIMER: /* in burst mode */ /* set scan frequency */ i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd.scan_begin_arg), @@ -1414,17 +1415,17 @@ static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd) break; } - // setup counter 0 for 'about triggering' + /* setup counter 0 for 'about triggering' */ if (cmd.stop_src == TRIG_EXT) { - // load counter 0 in mode 0 + /* load counter 0 in mode 0 */ i8254_load(dev->iobase + DAS1800_COUNTER, 0, 0, 1, 0); } return 0; } -// sets up dma -static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd) +/* sets up dma */ +static void setup_dma(struct comedi_device *dev, struct comedi_cmd cmd) { unsigned long lock_flags; const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL; @@ -1440,19 +1441,19 @@ static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd) * count and address get set correctly */ clear_dma_ff(devpriv->dma0); set_dma_addr(devpriv->dma0, virt_to_bus(devpriv->ai_buf0)); - // set appropriate size of transfer + /* set appropriate size of transfer */ set_dma_count(devpriv->dma0, devpriv->dma_transfer_size); devpriv->dma_current = devpriv->dma0; devpriv->dma_current_buf = devpriv->ai_buf0; enable_dma(devpriv->dma0); - // set up dual dma if appropriate + /* set up dual dma if appropriate */ if (dual_dma) { disable_dma(devpriv->dma1); /* clear flip-flop to make sure 2-byte registers for * count and address get set correctly */ clear_dma_ff(devpriv->dma1); set_dma_addr(devpriv->dma1, virt_to_bus(devpriv->ai_buf1)); - // set appropriate size of transfer + /* set appropriate size of transfer */ set_dma_count(devpriv->dma1, devpriv->dma_transfer_size); enable_dma(devpriv->dma1); } @@ -1461,17 +1462,17 @@ static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd) return; } -// programs channel/gain list into card -static void program_chanlist(struct comedi_device * dev, struct comedi_cmd cmd) +/* programs channel/gain list into card */ +static void program_chanlist(struct comedi_device *dev, struct comedi_cmd cmd) { int i, n, chan_range; unsigned long irq_flags; - const int range_mask = 0x3; //masks unipolar/bipolar bit off range + const int range_mask = 0x3; /* masks unipolar/bipolar bit off range */ const int range_bitshift = 8; n = cmd.chanlist_len; - // spinlock protects indirect addressing - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + /* spinlock protects indirect addressing */ + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */ outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*set QRAM address start */ /* make channel / gain list */ @@ -1483,13 +1484,13 @@ static void program_chanlist(struct comedi_device * dev, struct comedi_cmd cmd) outw(chan_range, dev->iobase + DAS1800_QRAM); } outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*finish write to QRAM */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return; } -// analog input do_cmd -static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +/* analog input do_cmd */ +static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int ret; int control_a, control_c; @@ -1509,22 +1510,22 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice } else { devpriv->irq_dma_bits |= devpriv->dma_bits; } - // interrupt on end of conversion for TRIG_WAKE_EOS + /* interrupt on end of conversion for TRIG_WAKE_EOS */ if (cmd.flags & TRIG_WAKE_EOS) { - // interrupt fifo not empty + /* interrupt fifo not empty */ devpriv->irq_dma_bits &= ~FIMD; } else { - // interrupt fifo half full + /* interrupt fifo half full */ devpriv->irq_dma_bits |= FIMD; } - // determine how many conversions we need + /* determine how many conversions we need */ if (cmd.stop_src == TRIG_COUNT) { devpriv->count = cmd.stop_arg * cmd.chanlist_len; } das1800_cancel(dev, s); - // determine proper bits for control registers + /* determine proper bits for control registers */ control_a = control_a_bits(cmd); control_c = control_c_bits(cmd); @@ -1537,14 +1538,14 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice } setup_dma(dev, cmd); outb(control_c, dev->iobase + DAS1800_CONTROL_C); - // set conversion rate and length for burst mode + /* set conversion rate and length for burst mode */ if (control_c & BMDE) { - // program conversion period with number of microseconds minus 1 + /* program conversion period with number of microseconds minus 1 */ outb(cmd.convert_arg / 1000 - 1, dev->iobase + DAS1800_BURST_RATE); outb(cmd.chanlist_len - 1, dev->iobase + DAS1800_BURST_LENGTH); } - outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); // enable irq/dma + outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); /* enable irq/dma */ outb(control_a, dev->iobase + DAS1800_CONTROL_A); /* enable fifo and triggering */ outb(CVEN, dev->iobase + DAS1800_STATUS); /* enable conversions */ @@ -1552,8 +1553,8 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice } /* read analog input */ -static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das1800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int chan, range, aref, chan_range; @@ -1582,7 +1583,7 @@ static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice /* mask of unipolar/bipolar bit from range */ range = CR_RANGE(insn->chanspec) & 0x3; chan_range = chan | (range << 8); - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */ outb(0x0, dev->iobase + DAS1800_QRAM_ADDRESS); /* set QRAM address start */ outw(chan_range, dev->iobase + DAS1800_QRAM); @@ -1606,43 +1607,43 @@ static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice dpnt += 1 << (thisboard->resolution - 1); data[n] = dpnt; } - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return n; } /* writes to an analog output channel */ -static int das1800_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das1800_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); -// int range = CR_RANGE(insn->chanspec); +/* int range = CR_RANGE(insn->chanspec); */ int update_chan = thisboard->ao_n_chan - 1; short output; unsigned long irq_flags; - // card expects two's complement data + /* card expects two's complement data */ output = data[0] - (1 << (thisboard->resolution - 1)); - // if the write is to the 'update' channel, we need to remember its value + /* if the write is to the 'update' channel, we need to remember its value */ if (chan == update_chan) devpriv->ao_update_bits = output; - // write to channel - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + /* write to channel */ + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(DAC(chan), dev->iobase + DAS1800_SELECT); /* select dac channel for baseAddress + 0x0 */ outw(output, dev->iobase + DAS1800_DAC); - // now we need to write to 'update' channel to update all dac channels + /* now we need to write to 'update' channel to update all dac channels */ if (chan != update_chan) { outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); /* select 'update' channel for baseAddress + 0x0 */ outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC); } - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return 1; } /* reads from digital input channels */ -static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das1800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inb(dev->iobase + DAS1800_DIGITAL) & 0xf; @@ -1652,12 +1653,12 @@ static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice } /* writes to digital output channels */ -static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das1800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int wbits; - // only set bits that have been masked + /* only set bits that have been masked */ data[0] &= (1 << s->n_chan) - 1; wbits = devpriv->do_bits; wbits &= ~data[0]; @@ -1672,15 +1673,15 @@ static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice } /* loads counters with divisor1, divisor2 from private structure */ -static int das1800_set_frequency(struct comedi_device * dev) +static int das1800_set_frequency(struct comedi_device *dev) { int err = 0; - // counter 1, mode 2 + /* counter 1, mode 2 */ if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1, 2)) err++; - // counter 2, mode 2 + /* counter 2, mode 2 */ if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2, 2)) err++; @@ -1697,11 +1698,11 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) { unsigned int micro_sec; - // in burst mode, the maximum conversion time is 64 microseconds + /* in burst mode, the maximum conversion time is 64 microseconds */ if (convert_arg > 64000) convert_arg = 64000; - // the conversion time must be an integral number of microseconds + /* the conversion time must be an integral number of microseconds */ switch (round_mode) { case TRIG_ROUND_NEAREST: default: @@ -1715,21 +1716,21 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) break; } - // return number of nanoseconds + /* return number of nanoseconds */ return micro_sec * 1000; } -// utility function that suggests a dma transfer size based on the conversion period 'ns' -static unsigned int suggest_transfer_size(struct comedi_cmd * cmd) +/* utility function that suggests a dma transfer size based on the conversion period 'ns' */ +static unsigned int suggest_transfer_size(struct comedi_cmd *cmd) { unsigned int size = DMA_BUF_SIZE; - static const int sample_size = 2; // size in bytes of one sample from board - unsigned int fill_time = 300000000; // target time in nanoseconds for filling dma buffer - unsigned int max_size; // maximum size we will allow for a transfer + static const int sample_size = 2; /* size in bytes of one sample from board */ + unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */ + unsigned int max_size; /* maximum size we will allow for a transfer */ - // make dma buffer fill in 0.3 seconds for timed modes + /* make dma buffer fill in 0.3 seconds for timed modes */ switch (cmd->scan_begin_src) { - case TRIG_FOLLOW: // not in burst mode + case TRIG_FOLLOW: /* not in burst mode */ if (cmd->convert_src == TRIG_TIMER) size = (fill_time / cmd->convert_arg) * sample_size; break; @@ -1742,9 +1743,9 @@ static unsigned int suggest_transfer_size(struct comedi_cmd * cmd) break; } - // set a minimum and maximum size allowed + /* set a minimum and maximum size allowed */ max_size = DMA_BUF_SIZE; - // if we are taking limited number of conversions, limit transfer size to that + /* if we are taking limited number of conversions, limit transfer size to that */ if (cmd->stop_src == TRIG_COUNT && cmd->stop_arg * cmd->chanlist_len * sample_size < max_size) max_size = cmd->stop_arg * cmd->chanlist_len * sample_size; diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 2a8ca0525104..0114eb935305 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -38,6 +38,7 @@ Devices: [Keithley Metrabyte] DAS6402 (das6402) This driver has suffered bitrot. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -98,13 +99,13 @@ This driver has suffered bitrot. #define C2 0x80 #define RWLH 0x30 -static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das6402_detach(struct comedi_device * dev); +static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das6402_detach(struct comedi_device *dev); static struct comedi_driver driver_das6402 = { - driver_name:"das6402", - module:THIS_MODULE, - attach:das6402_attach, - detach:das6402_detach, + .driver_name = "das6402", + .module = THIS_MODULE, + .attach = das6402_attach, + .detach = das6402_detach, }; COMEDI_INITCLEANUP(driver_das6402); @@ -116,9 +117,9 @@ struct das6402_private { }; #define devpriv ((struct das6402_private *)dev->private) -static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subdevice * s); +static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s); -static void das6402_setcounter(struct comedi_device * dev) +static void das6402_setcounter(struct comedi_device *dev) { BYTE p; unsigned short ctrlwrd; @@ -151,7 +152,7 @@ static void das6402_setcounter(struct comedi_device * dev) outb_p(p, dev->iobase + 14); } -static irqreturn_t intr_handler(int irq, void *d PT_REGS_ARG) +static irqreturn_t intr_handler(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices; @@ -186,7 +187,7 @@ static irqreturn_t intr_handler(int irq, void *d PT_REGS_ARG) } #if 0 -static void das6402_ai_fifo_read(struct comedi_device * dev, short * data, int n) +static void das6402_ai_fifo_read(struct comedi_device *dev, short *data, int n) { int i; @@ -195,7 +196,7 @@ static void das6402_ai_fifo_read(struct comedi_device * dev, short * data, int n } #endif -static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subdevice * s) +static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s) { while (1) { if (!(inb(dev->iobase + 8) & 0x01)) @@ -204,7 +205,7 @@ static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subd } } -static int das6402_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int das6402_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { /* * This function should reset the board from whatever condition it @@ -226,8 +227,8 @@ static int das6402_ai_cancel(struct comedi_device * dev, struct comedi_subdevice } #ifdef unused -static int das6402_ai_mode2(struct comedi_device * dev, struct comedi_subdevice * s, - comedi_trig * it) +static int das6402_ai_mode2(struct comedi_device *dev, struct comedi_subdevice *s, + comedi_trig *it) { devpriv->das6402_ignoreirq = 1; @@ -249,7 +250,7 @@ static int das6402_ai_mode2(struct comedi_device * dev, struct comedi_subdevice } #endif -static int board_init(struct comedi_device * dev) +static int board_init(struct comedi_device *dev) { BYTE b; @@ -289,17 +290,17 @@ static int board_init(struct comedi_device * dev) return 0; } -static int das6402_detach(struct comedi_device * dev) +static int das6402_detach(struct comedi_device *dev) { if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, DAS6402_SIZE); return 0; } -static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned int irq; unsigned long iobase; @@ -324,17 +325,19 @@ static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * irq = it->options[0]; printk(" ( irq = %u )", irq); - ret = comedi_request_irq(irq, intr_handler, 0, "das6402", dev); + ret = request_irq(irq, intr_handler, 0, "das6402", dev); if (ret < 0) { printk("irq conflict\n"); return ret; } dev->irq = irq; - if ((ret = alloc_private(dev, sizeof(struct das6402_private))) < 0) + ret = alloc_private(dev, sizeof(struct das6402_private)); + if (ret < 0) return ret; - if ((ret = alloc_subdevices(dev, 1)) < 0) + ret = alloc_subdevices(dev, 1); + if (ret < 0) return ret; /* ai subdevice */ @@ -342,7 +345,7 @@ static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND; s->n_chan = 8; - //s->trig[2]=das6402_ai_mode2; + /* s->trig[2]=das6402_ai_mode2; */ s->cancel = das6402_ai_cancel; s->maxdata = (1 << 12) - 1; s->len_chanlist = 16; /* ? */ diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 7a6656bf809c..70e9d699c7a3 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -62,6 +62,7 @@ cmd triggers supported: */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -72,7 +73,7 @@ cmd triggers supported: #define DAS800_SIZE 8 #define TIMER_BASE 1000 -#define N_CHAN_AI 8 // number of analog input channels +#define N_CHAN_AI 8 /* number of analog input channels */ /* Registers for the das800 */ @@ -94,8 +95,8 @@ cmd triggers supported: #define IRQ 0x8 #define BUSY 0x80 #define DAS800_GAIN 3 -#define CIO_FFOV 0x8 // fifo overflow for cio-das802/16 -#define CIO_ENHF 0x90 // interrupt fifo half full for cio-das802/16 +#define CIO_FFOV 0x8 /* fifo overflow for cio-das802/16 */ +#define CIO_ENHF 0x90 /* interrupt fifo half full for cio-das802/16 */ #define CONTROL1 0x80 #define CONV_CONTROL 0xa0 #define SCAN_LIMITS 0xc0 @@ -113,7 +114,7 @@ struct das800_board { int resolution; }; -//analog input ranges +/* analog input ranges */ static const struct comedi_lrange range_das800_ai = { 1, { @@ -184,46 +185,46 @@ enum { das800, ciodas800, das801, ciodas801, das802, ciodas802, ciodas80216 }; static const struct das800_board das800_boards[] = { { - name: "das-800", - ai_speed:25000, - ai_range:&range_das800_ai, - resolution:12, + .name = "das-800", + .ai_speed = 25000, + .ai_range = &range_das800_ai, + .resolution = 12, }, { - name: "cio-das800", - ai_speed:20000, - ai_range:&range_das800_ai, - resolution:12, + .name = "cio-das800", + .ai_speed = 20000, + .ai_range = &range_das800_ai, + .resolution = 12, }, { - name: "das-801", - ai_speed:25000, - ai_range:&range_das801_ai, - resolution:12, + .name = "das-801", + .ai_speed = 25000, + .ai_range = &range_das801_ai, + .resolution = 12, }, { - name: "cio-das801", - ai_speed:20000, - ai_range:&range_cio_das801_ai, - resolution:12, + .name = "cio-das801", + .ai_speed = 20000, + .ai_range = &range_cio_das801_ai, + .resolution = 12, }, { - name: "das-802", - ai_speed:25000, - ai_range:&range_das802_ai, - resolution:12, + .name = "das-802", + .ai_speed = 25000, + .ai_range = &range_das802_ai, + .resolution = 12, }, { - name: "cio-das802", - ai_speed:20000, - ai_range:&range_das802_ai, - resolution:12, + .name = "cio-das802", + .ai_speed = 20000, + .ai_range = &range_das802_ai, + .resolution = 12, }, { - name: "cio-das802/16", - ai_speed:10000, - ai_range:&range_das80216_ai, - resolution:16, + .name = "cio-das802/16", + .ai_speed = 10000, + .ai_range = &range_das80216_ai, + .resolution = 16, }, }; @@ -242,47 +243,47 @@ struct das800_private { #define devpriv ((struct das800_private *)dev->private) -static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int das800_detach(struct comedi_device * dev); -static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das800_detach(struct comedi_device *dev); +static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static struct comedi_driver driver_das800 = { - driver_name:"das800", - module:THIS_MODULE, - attach:das800_attach, - detach:das800_detach, - num_names:sizeof(das800_boards) / sizeof(struct das800_board), - board_name:&das800_boards[0].name, - offset:sizeof(struct das800_board), + .driver_name = "das800", + .module = THIS_MODULE, + .attach = das800_attach, + .detach = das800_detach, + .num_names = ARRAY_SIZE(das800_boards), + .board_name = &das800_boards[0].name, + .offset = sizeof(struct das800_board), }; -static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG); -static void enable_das800(struct comedi_device * dev); -static void disable_das800(struct comedi_device * dev); -static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int das800_probe(struct comedi_device * dev); -static int das800_set_frequency(struct comedi_device * dev); +static irqreturn_t das800_interrupt(int irq, void *d); +static void enable_das800(struct comedi_device *dev); +static void disable_das800(struct comedi_device *dev); +static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das800_probe(struct comedi_device *dev); +static int das800_set_frequency(struct comedi_device *dev); /* checks and probes das-800 series board type */ -static int das800_probe(struct comedi_device * dev) +static int das800_probe(struct comedi_device *dev) { int id_bits; unsigned long irq_flags; int board; - // 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + /* 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing */ + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(ID, dev->iobase + DAS800_GAIN); /* select base address + 7 to be ID register */ id_bits = inb(dev->iobase + DAS800_ID) & 0x3; /* get id bits */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); board = thisboard - das800_boards; @@ -343,7 +344,7 @@ static int das800_probe(struct comedi_device * dev) COMEDI_INITCLEANUP(driver_das800); /* interrupt service routine */ -static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t das800_interrupt(int irq, void *d) { short i; /* loop index */ short dataPoint = 0; @@ -352,8 +353,8 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) struct comedi_async *async; int status; unsigned long irq_flags; - static const int max_loops = 128; // half-fifo size for cio-das802/16 - // flags + static const int max_loops = 128; /* half-fifo size for cio-das802/16 */ + /* flags */ int fifo_empty = 0; int fifo_overflow = 0; @@ -369,13 +370,13 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) */ async = s->async; - // if hardware conversions are not enabled, then quit - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + /* if hardware conversions are not enabled, then quit */ + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */ status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN; /* don't release spinlock yet since we want to make sure noone else disables hardware conversions */ if (status == 0) { - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return IRQ_HANDLED; } @@ -390,7 +391,7 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) if (fifo_overflow) break; } else { - fifo_empty = 0; // cio-das802/16 has no fifo empty status bit + fifo_empty = 0; /* cio-das802/16 has no fifo empty status bit */ } if (fifo_empty) { break; @@ -410,12 +411,12 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) /* check for fifo overflow */ if (thisboard->resolution == 12) { fifo_overflow = dataPoint & FIFO_OVF; - // else cio-das802/16 + /* else cio-das802/16 */ } else { fifo_overflow = inb(dev->iobase + DAS800_GAIN) & CIO_FFOV; } if (fifo_overflow) { - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); comedi_error(dev, "DAS800 FIFO overflow"); das800_cancel(dev, dev->subdevices + 0); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; @@ -429,10 +430,10 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */ outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); /* otherwise, stop taking data */ } else { - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); disable_das800(dev); /* diable hardware triggered conversions */ async->events |= COMEDI_CB_EOA; } @@ -441,7 +442,7 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = it->options[0]; @@ -484,7 +485,7 @@ static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * i return -EINVAL; } if (irq) { - if (comedi_request_irq(irq, das800_interrupt, 0, "das800", dev)) { + if (request_irq(irq, das800_interrupt, 0, "das800", dev)) { printk("unable to allocate irq %u\n", irq); return -EINVAL; } @@ -531,15 +532,15 @@ static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * i disable_das800(dev); /* initialize digital out channels */ - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */ outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); return 0; }; -static int das800_detach(struct comedi_device * dev) +static int das800_detach(struct comedi_device *dev) { printk("comedi%d: das800: remove\n", dev->minor); @@ -547,11 +548,11 @@ static int das800_detach(struct comedi_device * dev) if (dev->iobase) release_region(dev->iobase, DAS800_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; }; -static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { devpriv->forever = 0; devpriv->count = 0; @@ -560,32 +561,32 @@ static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s } /* enable_das800 makes the card start taking hardware triggered conversions */ -static void enable_das800(struct comedi_device * dev) +static void enable_das800(struct comedi_device *dev) { unsigned long irq_flags; - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); - // enable fifo-half full interrupts for cio-das802/16 + spin_lock_irqsave(&dev->spinlock, irq_flags); + /* enable fifo-half full interrupts for cio-das802/16 */ if (thisboard->resolution == 16) outb(CIO_ENHF, dev->iobase + DAS800_GAIN); outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */ outb(CONV_HCEN, dev->iobase + DAS800_CONV_CONTROL); /* enable hardware triggering */ outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */ outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); /* enable card's interrupt */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); } /* disable_das800 stops hardware triggered conversions */ -static void disable_das800(struct comedi_device * dev) +static void disable_das800(struct comedi_device *dev) { unsigned long irq_flags; - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */ outb(0x0, dev->iobase + DAS800_CONV_CONTROL); /* disable hardware triggering of conversions */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); } -static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -684,7 +685,7 @@ static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdev if (err) return 4; - // check channel/gain list against card's limitations + /* check channel/gain list against card's limitations */ if (cmd->chanlist) { gain = CR_RANGE(cmd->chanlist[0]); startChan = CR_CHAN(cmd->chanlist[0]); @@ -709,7 +710,7 @@ static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdev return 0; } -static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int startChan, endChan, scan, gain; int conv_bits; @@ -729,10 +730,10 @@ static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice endChan = (startChan + async->cmd.chanlist_len - 1) % 8; scan = (endChan << 3) | startChan; - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(SCAN_LIMITS, dev->iobase + DAS800_GAIN); /* select base address + 2 to be scan limits register */ outb(scan, dev->iobase + DAS800_SCAN_LIMITS); /* set scan limits */ - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); /* set gain */ gain = CR_RANGE(async->cmd.chanlist[0]); @@ -779,17 +780,17 @@ static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice break; } - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */ outb(conv_bits, dev->iobase + DAS800_CONV_CONTROL); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); async->events = 0; enable_das800(dev); return 0; } -static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int chan; @@ -803,10 +804,10 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * /* set multiplexer */ chan = CR_CHAN(insn->chanspec); - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */ outb(chan | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); /* set gain / range */ range = CR_RANGE(insn->chanspec); @@ -815,7 +816,7 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * range &= 0xf; outb(range, dev->iobase + DAS800_GAIN); - comedi_udelay(5); + udelay(5); for (n = 0; n < insn->n; n++) { /* trigger conversion */ @@ -842,8 +843,8 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -855,23 +856,23 @@ static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int wbits; unsigned long irq_flags; - // only set bits that have been masked + /* only set bits that have been masked */ data[0] &= 0xf; wbits = devpriv->do_bits >> 4; wbits &= ~data[0]; wbits |= data[0] & data[1]; devpriv->do_bits = wbits << 4; - comedi_spin_lock_irqsave(&dev->spinlock, irq_flags); + spin_lock_irqsave(&dev->spinlock, irq_flags); outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */ outb(devpriv->do_bits | CONTROL1_INTE, dev->iobase + DAS800_CONTROL1); - comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); data[1] = wbits; @@ -879,7 +880,7 @@ static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * } /* loads counters with divisor1, divisor2 from private structure */ -static int das800_set_frequency(struct comedi_device * dev) +static int das800_set_frequency(struct comedi_device *dev) { int err = 0; diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 829083651edc..573cbe72b20b 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -74,6 +74,7 @@ Configuration Options: * options that are used with comedi_config. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -114,8 +115,8 @@ Configuration Options: #define DMM32AT_DIOC 0x0e #define DMM32AT_DIOCONF 0x0f -#define dmm_inb(cdev,reg) inb((cdev->iobase)+reg) -#define dmm_outb(cdev,reg,valu) outb(valu,(cdev->iobase)+reg) +#define dmm_inb(cdev, reg) inb((cdev->iobase)+reg) +#define dmm_outb(cdev, reg, valu) outb(valu, (cdev->iobase)+reg) /* Board register values. */ @@ -213,15 +214,15 @@ struct dmm32at_board { }; static const struct dmm32at_board dmm32at_boards[] = { { - name: "dmm32at", - ai_chans:32, - ai_bits: 16, - ai_ranges:&dmm32at_airanges, - ao_chans:4, - ao_bits: 12, - ao_ranges:&dmm32at_aoranges, - have_dio:1, - dio_chans:24, + .name = "dmm32at", + .ai_chans = 32, + .ai_bits = 16, + .ai_ranges = &dmm32at_airanges, + .ao_chans = 4, + .ao_bits = 12, + .ao_ranges = &dmm32at_aoranges, + .have_dio = 1, + .dio_chans = 24, }, }; @@ -258,13 +259,13 @@ struct dmm32at_private { * the board, and also about the kernel module that contains * the device code. */ -static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dmm32at_detach(struct comedi_device * dev); +static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dmm32at_detach(struct comedi_device *dev); static struct comedi_driver driver_dmm32at = { - driver_name:"dmm32at", - module:THIS_MODULE, - attach:dmm32at_attach, - detach:dmm32at_detach, + .driver_name = "dmm32at", + .module = THIS_MODULE, + .attach = dmm32at_attach, + .detach = dmm32at_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -283,29 +284,29 @@ static struct comedi_driver driver_dmm32at = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&dmm32at_boards[0].name, - offset:sizeof(struct dmm32at_board), - num_names:sizeof(dmm32at_boards) / sizeof(struct dmm32at_board), + .board_name = &dmm32at_boards[0].name, + .offset = sizeof(struct dmm32at_board), + .num_names = ARRAY_SIZE(dmm32at_boards), }; /* prototypes for driver functions below */ -static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int dmm32at_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int dmm32at_ns_to_timer(unsigned int *ns, int round); -static irqreturn_t dmm32at_isr(int irq, void *d PT_REGS_ARG); -void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec); +static irqreturn_t dmm32at_isr(int irq, void *d); +void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec); /* * Attach is called by the Comedi core to configure the driver @@ -313,7 +314,7 @@ void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec); * in the driver structure, dev->board_ptr contains that * address. */ -static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; struct comedi_subdevice *s; @@ -380,8 +381,7 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * /* board is there, register interrupt */ if (irq) { - ret = comedi_request_irq(irq, dmm32at_isr, 0, thisboard->name, - dev); + ret = request_irq(irq, dmm32at_isr, 0, thisboard->name, dev); if (ret < 0) { printk("irq conflict\n"); return ret; @@ -394,7 +394,7 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * * it is, this is the place to do it. Otherwise, dev->board_ptr * should already be initialized. */ - //dev->board_ptr = dmm32at_probe(dev); + /* dev->board_ptr = dmm32at_probe(dev); */ /* * Initialize dev->board_name. Note that we can use the "thisboard" @@ -481,11 +481,11 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int dmm32at_detach(struct comedi_device * dev) +static int dmm32at_detach(struct comedi_device *dev) { printk("comedi%d: dmm32at: remove\n", dev->minor); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, DMM32AT_MEMSIZE); @@ -497,8 +497,8 @@ static int dmm32at_detach(struct comedi_device * dev) * mode. */ -static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; unsigned int d; @@ -512,7 +512,7 @@ static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice chan = CR_CHAN(insn->chanspec) & (s->n_chan - 1); range = CR_RANGE(insn->chanspec); - //printk("channel=0x%02x, range=%d\n",chan,range); + /* printk("channel=0x%02x, range=%d\n",chan,range); */ /* zero scan and fifo control and reset fifo */ dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET); @@ -568,14 +568,14 @@ static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice return n; } -static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; int start_chan, gain, i; - //printk("dmmat32 in command test\n"); + /* printk("dmmat32 in command test\n"); */ /* cmdtest tests a particular command to see if it is valid. * Using the cmdtest ioctl, a user can create a valid cmd @@ -752,7 +752,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic return 0; } -static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int i, range; @@ -822,13 +822,13 @@ static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } -static int dmm32at_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { devpriv->ai_scans_left = 1; return 0; } -static irqreturn_t dmm32at_isr(int irq, void *d PT_REGS_ARG) +static irqreturn_t dmm32at_isr(int irq, void *d) { unsigned char intstat; unsigned int samp; @@ -893,8 +893,8 @@ static int dmm32at_ns_to_timer(unsigned int *ns, int round) return *ns; } -static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -910,7 +910,7 @@ static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice lo = data[i] & 0x00ff; /* high byte also contains channel number */ hi = (data[i] >> 8) + chan * (1 << 6); - //printk("writing 0x%02x 0x%02x\n",hi,lo); + /* printk("writing 0x%02x 0x%02x\n",hi,lo); */ /* write the low and high values to the board */ dmm_outb(dev, DMM32AT_DACLSB, lo); dmm_outb(dev, DMM32AT_DACMSB, hi); @@ -936,8 +936,8 @@ static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -953,8 +953,8 @@ static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned char diobits; @@ -967,7 +967,7 @@ static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subde s->state &= ~data[0]; s->state |= data[0] & data[1]; /* Write out the new digital output lines */ - //outw(s->state,dev->iobase + DMM32AT_DIO); + /* outw(s->state,dev->iobase + DMM32AT_DIO); */ } /* get access to the DIO regs */ @@ -998,16 +998,16 @@ static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subde /* on return, data[1] contains the value of the digital * input and output lines. */ - //data[1]=inw(dev->iobase + DMM32AT_DIO); + /* data[1]=inw(dev->iobase + DMM32AT_DIO); */ /* or we could just return the software copy of the output values if * it was a purely digital output subdevice */ - //data[1]=s->state; + /* data[1]=s->state; */ return 2; } -static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned char chanbit; int chan = CR_CHAN(insn->chanspec); @@ -1043,7 +1043,7 @@ static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_sub return 1; } -void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec) +void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) { unsigned char lo1, lo2, hi2; unsigned short both2; diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 5e0eed835d1a..25a9b213b6f1 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -88,19 +88,19 @@ Configuration options: #define DT2801_STATUS 1 #define DT2801_CMD 1 -static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt2801_detach(struct comedi_device * dev); +static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt2801_detach(struct comedi_device *dev); static struct comedi_driver driver_dt2801 = { - driver_name:"dt2801", - module:THIS_MODULE, - attach:dt2801_attach, - detach:dt2801_detach, + .driver_name = "dt2801", + .module = THIS_MODULE, + .attach = dt2801_attach, + .detach = dt2801_detach, }; COMEDI_INITCLEANUP(driver_dt2801); #if 0 -// ignore 'defined but not used' warning +/* ignore 'defined but not used' warning */ static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, { RANGE(-10, 10), RANGE(-5, 5), @@ -118,7 +118,7 @@ static const struct comedi_lrange range_dt2801_ai_pgl_bipolar = { 4, { }; #if 0 -// ignore 'defined but not used' warning +/* ignore 'defined but not used' warning */ static const struct comedi_lrange range_dt2801_ai_pgh_unipolar = { 4, { RANGE(0, 10), RANGE(0, 5), @@ -152,72 +152,71 @@ struct dt2801_board { */ static const struct dt2801_board boardtypes[] = { { - name: "dt2801", - boardcode:0x09, - ad_diff: 2, - ad_chan: 16, - adbits: 12, - adrangetype:0, - dabits: 12}, + .name = "dt2801", + .boardcode = 0x09, + .ad_diff = 2, + .ad_chan = 16, + .adbits = 12, + .adrangetype = 0, + .dabits = 12}, { - name: "dt2801-a", - boardcode:0x52, - ad_diff: 2, - ad_chan: 16, - adbits: 12, - adrangetype:0, - dabits: 12}, + .name = "dt2801-a", + .boardcode = 0x52, + .ad_diff = 2, + .ad_chan = 16, + .adbits = 12, + .adrangetype = 0, + .dabits = 12}, { - name: "dt2801/5716a", - boardcode:0x82, - ad_diff: 1, - ad_chan: 16, - adbits: 16, - adrangetype:1, - dabits: 12}, + .name = "dt2801/5716a", + .boardcode = 0x82, + .ad_diff = 1, + .ad_chan = 16, + .adbits = 16, + .adrangetype = 1, + .dabits = 12}, { - name: "dt2805", - boardcode:0x12, - ad_diff: 1, - ad_chan: 16, - adbits: 12, - adrangetype:0, - dabits: 12}, + .name = "dt2805", + .boardcode = 0x12, + .ad_diff = 1, + .ad_chan = 16, + .adbits = 12, + .adrangetype = 0, + .dabits = 12}, { - name: "dt2805/5716a", - boardcode:0x92, - ad_diff: 1, - ad_chan: 16, - adbits: 16, - adrangetype:1, - dabits: 12}, + .name = "dt2805/5716a", + .boardcode = 0x92, + .ad_diff = 1, + .ad_chan = 16, + .adbits = 16, + .adrangetype = 1, + .dabits = 12}, { - name: "dt2808", - boardcode:0x20, - ad_diff: 0, - ad_chan: 16, - adbits: 12, - adrangetype:2, - dabits: 8}, + .name = "dt2808", + .boardcode = 0x20, + .ad_diff = 0, + .ad_chan = 16, + .adbits = 12, + .adrangetype = 2, + .dabits = 8}, { - name: "dt2818", - boardcode:0xa2, - ad_diff: 0, - ad_chan: 4, - adbits: 12, - adrangetype:0, - dabits: 12}, + .name = "dt2818", + .boardcode = 0xa2, + .ad_diff = 0, + .ad_chan = 4, + .adbits = 12, + .adrangetype = 0, + .dabits = 12}, { - name: "dt2809", - boardcode:0xb0, - ad_diff: 0, - ad_chan: 8, - adbits: 12, - adrangetype:1, - dabits: 12}, + .name = "dt2809", + .boardcode = 0xb0, + .ad_diff = 0, + .ad_chan = 8, + .adbits = 12, + .adrangetype = 1, + .dabits = 12}, }; -#define n_boardtypes ((sizeof(boardtypes))/(sizeof(boardtypes[0]))) #define boardtype (*(const struct dt2801_board *)dev->board_ptr) struct dt2801_private { @@ -228,16 +227,16 @@ struct dt2801_private { #define devpriv ((struct dt2801_private *)dev->private) -static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2801_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* These are the low-level routines: writecommand: write a command to the board @@ -248,7 +247,7 @@ static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subd /* Only checks DataOutReady-flag, not the Ready-flag as it is done in the examples of the manual. I don't see why this should be necessary. */ -static int dt2801_readdata(struct comedi_device * dev, int *data) +static int dt2801_readdata(struct comedi_device *dev, int *data) { int stat = 0; int timeout = DT2801_TIMEOUT; @@ -267,7 +266,7 @@ static int dt2801_readdata(struct comedi_device * dev, int *data) return -ETIME; } -static int dt2801_readdata2(struct comedi_device * dev, int *data) +static int dt2801_readdata2(struct comedi_device *dev, int *data) { int lb, hb; int ret; @@ -283,7 +282,7 @@ static int dt2801_readdata2(struct comedi_device * dev, int *data) return 0; } -static int dt2801_writedata(struct comedi_device * dev, unsigned int data) +static int dt2801_writedata(struct comedi_device *dev, unsigned int data) { int stat = 0; int timeout = DT2801_TIMEOUT; @@ -309,7 +308,7 @@ static int dt2801_writedata(struct comedi_device * dev, unsigned int data) return -ETIME; } -static int dt2801_writedata2(struct comedi_device * dev, unsigned int data) +static int dt2801_writedata2(struct comedi_device *dev, unsigned int data) { int ret; @@ -323,7 +322,7 @@ static int dt2801_writedata2(struct comedi_device * dev, unsigned int data) return 0; } -static int dt2801_wait_for_ready(struct comedi_device * dev) +static int dt2801_wait_for_ready(struct comedi_device *dev) { int timeout = DT2801_TIMEOUT; int stat; @@ -346,7 +345,7 @@ static int dt2801_wait_for_ready(struct comedi_device * dev) return -ETIME; } -static int dt2801_writecmd(struct comedi_device * dev, int command) +static int dt2801_writecmd(struct comedi_device *dev, int command) { int stat; @@ -364,7 +363,7 @@ static int dt2801_writecmd(struct comedi_device * dev, int command) return 0; } -static int dt2801_reset(struct comedi_device * dev) +static int dt2801_reset(struct comedi_device *dev) { int board_code = 0; unsigned int stat; @@ -381,11 +380,11 @@ static int dt2801_reset(struct comedi_device * dev) inb_p(dev->iobase + DT2801_DATA); DPRINTK("dt2801: stop\n"); - //dt2801_writecmd(dev,DT_C_STOP); + /* dt2801_writecmd(dev,DT_C_STOP); */ outb_p(DT_C_STOP, dev->iobase + DT2801_CMD); - //dt2801_wait_for_ready(dev); - comedi_udelay(100); + /* dt2801_wait_for_ready(dev); */ + udelay(100); timeout = 10000; do { stat = inb_p(dev->iobase + DT2801_STATUS); @@ -395,14 +394,15 @@ static int dt2801_reset(struct comedi_device * dev) if (!timeout) { printk("dt2801: timeout 1 status=0x%02x\n", stat); } - //printk("dt2801: reading dummy\n"); - //dt2801_readdata(dev,&board_code); + + /* printk("dt2801: reading dummy\n"); */ + /* dt2801_readdata(dev,&board_code); */ DPRINTK("dt2801: reset\n"); outb_p(DT_C_RESET, dev->iobase + DT2801_CMD); - //dt2801_writecmd(dev,DT_C_RESET); + /* dt2801_writecmd(dev,DT_C_RESET); */ - comedi_udelay(100); + udelay(100); timeout = 10000; do { stat = inb_p(dev->iobase + DT2801_STATUS); @@ -421,7 +421,7 @@ static int dt2801_reset(struct comedi_device * dev) return board_code; } -static int probe_number_of_ai_chans(struct comedi_device * dev) +static int probe_number_of_ai_chans(struct comedi_device *dev) { int n_chans; int stat; @@ -482,7 +482,7 @@ static const struct comedi_lrange *ai_range_lkup(int type, int opt) [4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] [5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] */ -static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -505,7 +505,7 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i if (!board_code) board_code = dt2801_reset(dev); - for (type = 0; type < n_boardtypes; type++) { + for (type = 0; type < ARRAY_SIZE(boardtypes); type++) { if (boardtypes[type].boardcode == board_code) goto havetype; } @@ -520,10 +520,12 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i n_ai_chans = probe_number_of_ai_chans(dev); printk(" (ai channels = %d)", n_ai_chans); - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) goto out; - if ((ret = alloc_private(dev, sizeof(struct dt2801_private))) < 0) + ret = alloc_private(dev, sizeof(struct dt2801_private)); + if (ret < 0) goto out; dev->board_name = boardtype.name; @@ -583,7 +585,7 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i return ret; } -static int dt2801_detach(struct comedi_device * dev) +static int dt2801_detach(struct comedi_device *dev) { if (dev->iobase) release_region(dev->iobase, DT2801_IOSIZE); @@ -591,7 +593,7 @@ static int dt2801_detach(struct comedi_device * dev) return 0; } -static int dt2801_error(struct comedi_device * dev, int stat) +static int dt2801_error(struct comedi_device *dev, int stat) { if (stat < 0) { if (stat == -ETIME) { @@ -609,8 +611,8 @@ static int dt2801_error(struct comedi_device * dev, int stat) return -EIO; } -static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int d; int stat; @@ -631,16 +633,16 @@ static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int dt2801_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; return 1; } -static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { dt2801_writecmd(dev, DT_C_WRITE_DAIM); dt2801_writedata(dev, CR_CHAN(insn->chanspec)); @@ -651,8 +653,8 @@ static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdev return 1; } -static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int which = 0; @@ -675,8 +677,8 @@ static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int which = 0; diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 795932ec67d3..7853902be621 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -45,6 +45,7 @@ Configuration options: [4] - D/A 1 range (same choices) */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -214,30 +215,30 @@ static const struct dt2811_board boardtypes[] = { #define this_board ((const struct dt2811_board *)dev->board_ptr) -static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt2811_detach(struct comedi_device * dev); +static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt2811_detach(struct comedi_device *dev); static struct comedi_driver driver_dt2811 = { - driver_name:"dt2811", - module:THIS_MODULE, - attach:dt2811_attach, - detach:dt2811_detach, - board_name:&boardtypes[0].name, - num_names:sizeof(boardtypes) / sizeof(struct dt2811_board), - offset:sizeof(struct dt2811_board), + .driver_name = "dt2811", + .module = THIS_MODULE, + .attach = dt2811_attach, + .detach = dt2811_detach, + .board_name = &boardtypes[0].name, + .num_names = ARRAY_SIZE(boardtypes), + .offset = sizeof(struct dt2811_board), }; COMEDI_INITCLEANUP(driver_dt2811); -static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int dt2811_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); enum { card_2811_pgh, card_2811_pgl }; @@ -265,7 +266,7 @@ static const struct comedi_lrange *dac_range_types[] = { #define DT2811_TIMEOUT 5 #if 0 -static irqreturn_t dt2811_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t dt2811_interrupt(int irq, void *d) { int lo, hi; int data; @@ -311,11 +312,12 @@ static irqreturn_t dt2811_interrupt(int irq, void *d PT_REGS_ARG) 2 == unipolar 5V (0V -- +5V) */ -static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - //int i, irq; - //unsigned long irqs; - //long flags; + /* int i, irq; */ + /* unsigned long irqs; */ + /* long flags; */ + int ret; struct comedi_subdevice *s; unsigned long iobase; @@ -334,7 +336,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i #if 0 outb(0, dev->iobase + DT2811_ADCSR); - comedi_udelay(100); + udelay(100); i = inb(dev->iobase + DT2811_ADDATLO); i = inb(dev->iobase + DT2811_ADDATHI); #endif @@ -350,7 +352,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase + DT2811_ADCSR); outb(0, dev->iobase + DT2811_ADGCR); - comedi_udelay(100); + udelay(100); irq = probe_irq_off(irqs); restore_flags(flags); @@ -365,7 +367,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i i = inb(dev->iobase + DT2811_ADDATLO); i = inb(dev->iobase + DT2811_ADDATHI); printk("(irq = %d)\n", irq); - ret = comedi_request_irq(irq, dt2811_interrupt, 0, + ret = request_irq(irq, dt2811_interrupt, 0, driver_name, dev); if (ret < 0) return -EIO; @@ -378,10 +380,14 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i } #endif - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct dt2811_private))) < 0) + + ret = alloc_private(dev, sizeof(struct dt2811_private)); + if (ret < 0) return ret; + switch (it->options[2]) { case 0: devpriv->adc_mux = adc_singleended; @@ -479,12 +485,12 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int dt2811_detach(struct comedi_device * dev) +static int dt2811_detach(struct comedi_device *dev) { printk("comedi%d: dt2811: remove\n", dev->minor); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->iobase) { release_region(dev->iobase, DT2811_SIZE); @@ -493,8 +499,8 @@ static int dt2811_detach(struct comedi_device * dev) return 0; } -static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int timeout = DT2811_TIMEOUT; @@ -520,7 +526,7 @@ static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice * #if 0 /* Wow. This is code from the Comedi stone age. But it hasn't been * replaced, so I'll let it stay. */ -int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig) +int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig) { struct comedi_device *dev = comedi_devices + minor; @@ -531,7 +537,7 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig) case COMEDI_MDEMAND: dev->ntrig = adtrig->n - 1; /*printk("dt2811: AD soft trigger\n"); */ - /*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); *//* not neccessary */ + /*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); */ /* not neccessary */ outb(dev->curadchan, dev->iobase + DT2811_ADGCR); do_gettimeofday(&trigtime); break; @@ -544,8 +550,8 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig) } #endif -static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -562,8 +568,8 @@ static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice * return i; } -static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -577,8 +583,8 @@ static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -588,8 +594,8 @@ static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int dt2811_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 8320139160a4..5906ddddf65c 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -39,6 +39,7 @@ a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In addition, the clock does not seem to be very accurate. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -59,18 +60,18 @@ addition, the clock does not seem to be very accurate. #define DT2814_ENB 0x10 #define DT2814_CHANMASK 0x0f -static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt2814_detach(struct comedi_device * dev); +static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt2814_detach(struct comedi_device *dev); static struct comedi_driver driver_dt2814 = { - driver_name:"dt2814", - module:THIS_MODULE, - attach:dt2814_attach, - detach:dt2814_detach, + .driver_name = "dt2814", + .module = THIS_MODULE, + .attach = dt2814_attach, + .detach = dt2814_detach, }; COMEDI_INITCLEANUP(driver_dt2814); -static irqreturn_t dt2814_interrupt(int irq, void *dev PT_REGS_ARG); +static irqreturn_t dt2814_interrupt(int irq, void *dev); struct dt2814_private { @@ -83,8 +84,8 @@ struct dt2814_private { #define DT2814_TIMEOUT 10 #define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */ -static int dt2814_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2814_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i, hi, lo; int chan; @@ -97,7 +98,7 @@ static int dt2814_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi for (i = 0; i < DT2814_TIMEOUT; i++) { status = inb(dev->iobase + DT2814_CSR); printk("dt2814: status: %02x\n", status); - comedi_udelay(10); + udelay(10); if (status & DT2814_FINISH) break; } @@ -134,8 +135,8 @@ static int dt2814_ns_to_timer(unsigned int *ns, unsigned int flags) return i; } -static int dt2814_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int dt2814_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -226,7 +227,7 @@ static int dt2814_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int dt2814_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int chan; @@ -245,7 +246,7 @@ static int dt2814_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s } -static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int i, irq; int ret; @@ -262,7 +263,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->board_name = "dt2814"; outb(0, dev->iobase + DT2814_CSR); - comedi_udelay(100); + udelay(100); if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) { printk("reset error (fatal)\n"); return -EIO; @@ -279,7 +280,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i outb(0, dev->iobase + DT2814_CSR); - comedi_udelay(100); + udelay(100); irq = probe_irq_off(irqs); restore_flags(flags); @@ -293,7 +294,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i #endif dev->irq = 0; if (irq > 0) { - if (comedi_request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) { + if (request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) { printk("(irq %d unavailable)\n", irq); } else { printk("( irq = %d )\n", irq); @@ -309,9 +310,12 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i #endif } - if ((ret = alloc_subdevices(dev, 1)) < 0) + ret = alloc_subdevices(dev, 1); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct dt2814_private))) < 0) + + ret = alloc_private(dev, sizeof(struct dt2814_private)); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -329,12 +333,12 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int dt2814_detach(struct comedi_device * dev) +static int dt2814_detach(struct comedi_device *dev) { printk("comedi%d: dt2814: remove\n", dev->minor); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->iobase) { release_region(dev->iobase, DT2814_SIZE); @@ -343,7 +347,7 @@ static int dt2814_detach(struct comedi_device * dev) return 0; } -static irqreturn_t dt2814_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t dt2814_interrupt(int irq, void *d) { int lo, hi; struct comedi_device *dev = d; diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index fccec8a77d50..b42dec60e1b7 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -75,18 +75,18 @@ static const struct comedi_lrange range_dt2815_ao_20_current = { 1, { #define DT2815_DATA 0 #define DT2815_STATUS 1 -static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt2815_detach(struct comedi_device * dev); +static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt2815_detach(struct comedi_device *dev); static struct comedi_driver driver_dt2815 = { - driver_name:"dt2815", - module:THIS_MODULE, - attach:dt2815_attach, - detach:dt2815_detach, + .driver_name = "dt2815", + .module = THIS_MODULE, + .attach = dt2815_attach, + .detach = dt2815_detach, }; COMEDI_INITCLEANUP(driver_dt2815); -static void dt2815_free_resources(struct comedi_device * dev); +static void dt2815_free_resources(struct comedi_device *dev); struct dt2815_private { @@ -97,7 +97,7 @@ struct dt2815_private { #define devpriv ((struct dt2815_private *)dev->private) -static int dt2815_wait_for_status(struct comedi_device * dev, int status) +static int dt2815_wait_for_status(struct comedi_device *dev, int status) { int i; @@ -108,8 +108,8 @@ static int dt2815_wait_for_status(struct comedi_device * dev, int status) return status; } -static int dt2815_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2815_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -121,8 +121,8 @@ static int dt2815_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -135,7 +135,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice * status = dt2815_wait_for_status(dev, 0x00); if (status != 0) { - rt_printk + printk ("dt2815: failed to write low byte on %d reason %x\n", chan, status); return -EBUSY; @@ -145,7 +145,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice * status = dt2815_wait_for_status(dev, 0x10); if (status != 0x10) { - rt_printk + printk ("dt2815: failed to write high byte on %d reason %x\n", chan, status); return -EBUSY; @@ -179,7 +179,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice * 1 == current */ -static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int i; @@ -226,7 +226,7 @@ static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * i /* This is incredibly slow (approx 20 ms) */ unsigned int status; - comedi_udelay(1000); + udelay(1000); status = inb(dev->iobase + DT2815_STATUS); if (status == 4) { unsigned int program; @@ -248,13 +248,13 @@ static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static void dt2815_free_resources(struct comedi_device * dev) +static void dt2815_free_resources(struct comedi_device *dev) { if (dev->iobase) release_region(dev->iobase, DT2815_SIZE); } -static int dt2815_detach(struct comedi_device * dev) +static int dt2815_detach(struct comedi_device *dev) { printk("comedi%d: dt2815: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 2dc396a44e6f..b36f85632f87 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -47,19 +47,19 @@ Configuration options: #define DT2817_CR 0 #define DT2817_DATA 1 -static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt2817_detach(struct comedi_device * dev); +static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt2817_detach(struct comedi_device *dev); static struct comedi_driver driver_dt2817 = { - driver_name:"dt2817", - module:THIS_MODULE, - attach:dt2817_attach, - detach:dt2817_detach, + .driver_name = "dt2817", + .module = THIS_MODULE, + .attach = dt2817_attach, + .detach = dt2817_detach, }; COMEDI_INITCLEANUP(driver_dt2817); -static int dt2817_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int mask; int chan; @@ -96,8 +96,8 @@ static int dt2817_dio_insn_config(struct comedi_device * dev, struct comedi_subd return 1; } -static int dt2817_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt2817_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int changed; @@ -131,7 +131,7 @@ static int dt2817_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; struct comedi_subdevice *s; @@ -146,7 +146,8 @@ static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase = iobase; dev->board_name = "dt2817"; - if ((ret = alloc_subdevices(dev, 1)) < 0) + ret = alloc_subdevices(dev, 1); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -167,7 +168,7 @@ static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int dt2817_detach(struct comedi_device * dev) +static int dt2817_detach(struct comedi_device *dev) { printk("comedi%d: dt2817: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 4882c3e679cc..22b7304af396 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -209,132 +209,132 @@ struct dt282x_board { }; static const struct dt282x_board boardtypes[] = { - {name:"dt2821", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:20000, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt2821-f", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:6500, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt2821-g", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:4000, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt2823", - adbits: 16, - adchan_se:0, - adchan_di:4, - ai_speed:10000, - ispgl: 0, - dachan: 2, - dabits: 16, - }, - {name:"dt2824-pgh", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:20000, - ispgl: 0, - dachan: 0, - dabits: 0, - }, - {name:"dt2824-pgl", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:20000, - ispgl: 1, - dachan: 0, - dabits: 0, - }, - {name:"dt2825", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:20000, - ispgl: 1, - dachan: 2, - dabits: 12, - }, - {name:"dt2827", - adbits: 16, - adchan_se:0, - adchan_di:4, - ai_speed:10000, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt2828", - adbits: 12, - adchan_se:4, - adchan_di:0, - ai_speed:10000, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt2829", - adbits: 16, - adchan_se:8, - adchan_di:0, - ai_speed:33250, - ispgl: 0, - dachan: 2, - dabits: 16, - }, - {name:"dt21-ez", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:10000, - ispgl: 0, - dachan: 2, - dabits: 12, - }, - {name:"dt23-ez", - adbits: 16, - adchan_se:16, - adchan_di:8, - ai_speed:10000, - ispgl: 0, - dachan: 0, - dabits: 0, - }, - {name:"dt24-ez", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:10000, - ispgl: 0, - dachan: 0, - dabits: 0, - }, - {name:"dt24-ez-pgl", - adbits: 12, - adchan_se:16, - adchan_di:8, - ai_speed:10000, - ispgl: 1, - dachan: 0, - dabits: 0, - }, + {.name = "dt2821", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 20000, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2821-f", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 6500, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2821-g", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 4000, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2823", + .adbits = 16, + .adchan_se = 0, + .adchan_di = 4, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 2, + .dabits = 16, + }, + {.name = "dt2824-pgh", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 20000, + .ispgl = 0, + .dachan = 0, + .dabits = 0, + }, + {.name = "dt2824-pgl", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 20000, + .ispgl = 1, + .dachan = 0, + .dabits = 0, + }, + {.name = "dt2825", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 20000, + .ispgl = 1, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2827", + .adbits = 16, + .adchan_se = 0, + .adchan_di = 4, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2828", + .adbits = 12, + .adchan_se = 4, + .adchan_di = 0, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt2829", + .adbits = 16, + .adchan_se = 8, + .adchan_di = 0, + .ai_speed = 33250, + .ispgl = 0, + .dachan = 2, + .dabits = 16, + }, + {.name = "dt21-ez", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt23-ez", + .adbits = 16, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 0, + .dabits = 0, + }, + {.name = "dt24-ez", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 10000, + .ispgl = 0, + .dachan = 0, + .dabits = 0, + }, + {.name = "dt24-ez-pgl", + .adbits = 12, + .adchan_se = 16, + .adchan_di = 8, + .ai_speed = 10000, + .ispgl = 1, + .dachan = 0, + .dabits = 0, + }, }; #define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board) @@ -374,51 +374,51 @@ struct dt282x_private { * Some useless abstractions */ #define chan_to_DAC(a) ((a)&1) -#define update_dacsr(a) outw(devpriv->dacsr|(a),dev->iobase+DT2821_DACSR) -#define update_adcsr(a) outw(devpriv->adcsr|(a),dev->iobase+DT2821_ADCSR) +#define update_dacsr(a) outw(devpriv->dacsr|(a), dev->iobase+DT2821_DACSR) +#define update_adcsr(a) outw(devpriv->adcsr|(a), dev->iobase+DT2821_ADCSR) #define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY) #define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE) -#define update_supcsr(a) outw(devpriv->supcsr|(a),dev->iobase+DT2821_SUPCSR) +#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR) /* * danger! macro abuse... a is the expression to wait on, and b is * the statement(s) to execute if it doesn't happen. */ -#define wait_for(a,b) \ +#define wait_for(a, b) \ do{ \ int _i; \ - for(_i=0;_i<DT2821_TIMEOUT;_i++){ \ - if(a){_i=0;break;} \ - comedi_udelay(5); \ + for (_i=0;_i<DT2821_TIMEOUT;_i++){ \ + if (a){_i=0;break;} \ + udelay(5); \ } \ - if(_i){b} \ - }while(0) + if (_i){b} \ + }while (0) -static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt282x_detach(struct comedi_device * dev); +static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt282x_detach(struct comedi_device *dev); static struct comedi_driver driver_dt282x = { - driver_name:"dt282x", - module:THIS_MODULE, - attach:dt282x_attach, - detach:dt282x_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct dt282x_board), + .driver_name = "dt282x", + .module = THIS_MODULE, + .attach = dt282x_attach, + .detach = dt282x_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct dt282x_board), }; COMEDI_INITCLEANUP(driver_dt282x); -static void free_resources(struct comedi_device * dev); -static int prep_ai_dma(struct comedi_device * dev, int chan, int size); -static int prep_ao_dma(struct comedi_device * dev, int chan, int size); -static int dt282x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static void free_resources(struct comedi_device *dev); +static int prep_ai_dma(struct comedi_device *dev, int chan, int size); +static int prep_ao_dma(struct comedi_device *dev, int chan, int size); +static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int dt282x_ns_to_timer(int *nanosec, int round_mode); -static void dt282x_disable_dma(struct comedi_device * dev); +static void dt282x_disable_dma(struct comedi_device *dev); -static int dt282x_grab_dma(struct comedi_device * dev, int dma1, int dma2); +static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2); -static void dt282x_munge(struct comedi_device * dev, short * buf, +static void dt282x_munge(struct comedi_device *dev, short *buf, unsigned int nbytes) { unsigned int i; @@ -440,7 +440,7 @@ static void dt282x_munge(struct comedi_device * dev, short * buf, } } -static void dt282x_ao_dma_interrupt(struct comedi_device * dev) +static void dt282x_ao_dma_interrupt(struct comedi_device *dev) { void *ptr; int size; @@ -463,7 +463,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device * dev) size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize); if (size == 0) { - rt_printk("dt282x: AO underrun\n"); + printk("dt282x: AO underrun\n"); dt282x_ao_cancel(dev, s); s->async->events |= COMEDI_CB_OVERFLOW; return; @@ -472,7 +472,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device * dev) return; } -static void dt282x_ai_dma_interrupt(struct comedi_device * dev) +static void dt282x_ai_dma_interrupt(struct comedi_device *dev) { void *ptr; int size; @@ -524,7 +524,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device * dev) prep_ai_dma(dev, i, 0); } -static int prep_ai_dma(struct comedi_device * dev, int dma_index, int n) +static int prep_ai_dma(struct comedi_device *dev, int dma_index, int n) { int dma_chan; unsigned long dma_ptr; @@ -555,7 +555,7 @@ static int prep_ai_dma(struct comedi_device * dev, int dma_index, int n) return n; } -static int prep_ao_dma(struct comedi_device * dev, int dma_index, int n) +static int prep_ao_dma(struct comedi_device *dev, int dma_index, int n) { int dma_chan; unsigned long dma_ptr; @@ -577,7 +577,7 @@ static int prep_ao_dma(struct comedi_device * dev, int dma_index, int n) return n; } -static irqreturn_t dt282x_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t dt282x_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s; @@ -653,7 +653,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_RETVAL(handled); } -static void dt282x_load_changain(struct comedi_device * dev, int n, +static void dt282x_load_changain(struct comedi_device *dev, int n, unsigned int *chanlist) { unsigned int i; @@ -674,8 +674,8 @@ static void dt282x_load_changain(struct comedi_device * dev, int n, * - preload multiplexer * - trigger conversion and wait for it to finish */ -static int dt282x_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; @@ -706,8 +706,8 @@ static int dt282x_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int dt282x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -818,7 +818,7 @@ static int dt282x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int dt282x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int timer; @@ -879,7 +879,7 @@ static int dt282x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static void dt282x_disable_dma(struct comedi_device * dev) +static void dt282x_disable_dma(struct comedi_device *dev) { if (devpriv->usedma) { disable_dma(devpriv->dma[0].chan); @@ -887,7 +887,7 @@ static void dt282x_disable_dma(struct comedi_device * dev) } } -static int dt282x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { dt282x_disable_dma(dev); @@ -937,16 +937,16 @@ static int dt282x_ns_to_timer(int *nanosec, int round_mode) * offset binary if necessary, loads the data into the DAC * data register, and performs the conversion. */ -static int dt282x_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt282x_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->ao[CR_CHAN(insn->chanspec)]; return 1; } -static int dt282x_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { short d; unsigned int chan; @@ -978,8 +978,8 @@ static int dt282x_ao_insn_write(struct comedi_device * dev, struct comedi_subdev return 1; } -static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -1029,7 +1029,7 @@ static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice cmd->start_arg = 0; err++; } - if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) { + if (cmd->scan_begin_arg < 5000 /* XXX unknown */) { cmd->scan_begin_arg = 5000; err++; } @@ -1069,7 +1069,7 @@ static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice } -static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int x) { int size; @@ -1080,7 +1080,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf, devpriv->dma_maxsize); if (size == 0) { - rt_printk("dt282x: AO underrun\n"); + printk("dt282x: AO underrun\n"); return -EPIPE; } prep_ao_dma(dev, 0, size); @@ -1088,7 +1088,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf, devpriv->dma_maxsize); if (size == 0) { - rt_printk("dt282x: AO underrun\n"); + printk("dt282x: AO underrun\n"); return -EPIPE; } prep_ao_dma(dev, 1, size); @@ -1099,7 +1099,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int dt282x_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int timer; struct comedi_cmd *cmd = &s->async->cmd; @@ -1132,7 +1132,7 @@ static int dt282x_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { dt282x_disable_dma(dev); @@ -1145,8 +1145,8 @@ static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int dt282x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -1159,8 +1159,8 @@ static int dt282x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int dt282x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt282x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int mask; @@ -1240,7 +1240,7 @@ enum { opt_iobase = 0, opt_irq, opt_dma1, opt_dma2, /* i/o base, irq, dma channe 9 ao0 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V 10 ao1 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V */ -static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int i, irq; int ret; @@ -1298,19 +1298,18 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i /* trigger interrupt */ - comedi_udelay(100); + udelay(100); irq = probe_irq_off(irqs); restore_flags(flags); - if (0 /* error */ ) { + if (0 /* error */) { printk(" error probing irq (bad)"); } } #endif if (irq > 0) { printk(" ( irq = %d )", irq); - ret = comedi_request_irq(irq, dt282x_interrupt, 0, "dt282x", - dev); + ret = request_irq(irq, dt282x_interrupt, 0, "dt282x", dev); if (ret < 0) { printk(" failed to get irq\n"); return -EIO; @@ -1326,7 +1325,8 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i #endif } - if ((ret = alloc_private(dev, sizeof(struct dt282x_private))) < 0) + ret = alloc_private(dev, sizeof(struct dt282x_private)); + if (ret < 0) return ret; ret = dt282x_grab_dma(dev, it->options[opt_dma1], @@ -1334,7 +1334,8 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i if (ret < 0) return ret; - if ((ret = alloc_subdevices(dev, 3)) < 0) + ret = alloc_subdevices(dev, 3); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -1358,7 +1359,9 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->ad_2scomp = it->options[opt_ai_twos]; s++; - if ((s->n_chan = boardtype.dachan)) { + + s->n_chan = boardtype.dachan; + if (s->n_chan) { /* ao subsystem */ s->type = COMEDI_SUBD_AO; dev->write_subdev = s; @@ -1396,10 +1399,10 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static void free_resources(struct comedi_device * dev) +static void free_resources(struct comedi_device *dev) { if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->iobase) release_region(dev->iobase, DT2821_SIZE); @@ -1415,7 +1418,7 @@ static void free_resources(struct comedi_device * dev) } } -static int dt282x_detach(struct comedi_device * dev) +static int dt282x_detach(struct comedi_device *dev) { printk("comedi%d: dt282x: remove\n", dev->minor); @@ -1424,7 +1427,7 @@ static int dt282x_detach(struct comedi_device * dev) return 0; } -static int dt282x_grab_dma(struct comedi_device * dev, int dma1, int dma2) +static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) { int ret; diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index d9467984706e..2af8b59f9061 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -59,6 +59,7 @@ AO commands are not supported. #define DEBUG 1 +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -95,69 +96,69 @@ struct dt3k_boardtype { static const struct dt3k_boardtype dt3k_boardtypes[] = { - {name:"dt3001", - device_id:0x22, - adchan: 16, - adbits: 12, - adrange: &range_dt3000_ai, - ai_speed:3000, - dachan: 2, - dabits: 12, - }, - {name:"dt3001-pgl", - device_id:0x27, - adchan: 16, - adbits: 12, - adrange: &range_dt3000_ai_pgl, - ai_speed:3000, - dachan: 2, - dabits: 12, - }, - {name:"dt3002", - device_id:0x23, - adchan: 32, - adbits: 12, - adrange: &range_dt3000_ai, - ai_speed:3000, - dachan: 0, - dabits: 0, - }, - {name:"dt3003", - device_id:0x24, - adchan: 64, - adbits: 12, - adrange: &range_dt3000_ai, - ai_speed:3000, - dachan: 2, - dabits: 12, - }, - {name:"dt3003-pgl", - device_id:0x28, - adchan: 64, - adbits: 12, - adrange: &range_dt3000_ai_pgl, - ai_speed:3000, - dachan: 2, - dabits: 12, - }, - {name:"dt3004", - device_id:0x25, - adchan: 16, - adbits: 16, - adrange: &range_dt3000_ai, - ai_speed:10000, - dachan: 2, - dabits: 12, - }, - {name:"dt3005", /* a.k.a. 3004-200 */ - device_id:0x26, - adchan: 16, - adbits: 16, - adrange: &range_dt3000_ai, - ai_speed:5000, - dachan: 2, - dabits: 12, - }, + {.name = "dt3001", + .device_id = 0x22, + .adchan = 16, + .adbits = 12, + .adrange = &range_dt3000_ai, + .ai_speed = 3000, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt3001-pgl", + .device_id = 0x27, + .adchan = 16, + .adbits = 12, + .adrange = &range_dt3000_ai_pgl, + .ai_speed = 3000, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt3002", + .device_id = 0x23, + .adchan = 32, + .adbits = 12, + .adrange = &range_dt3000_ai, + .ai_speed = 3000, + .dachan = 0, + .dabits = 0, + }, + {.name = "dt3003", + .device_id = 0x24, + .adchan = 64, + .adbits = 12, + .adrange = &range_dt3000_ai, + .ai_speed = 3000, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt3003-pgl", + .device_id = 0x28, + .adchan = 64, + .adbits = 12, + .adrange = &range_dt3000_ai_pgl, + .ai_speed = 3000, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt3004", + .device_id = 0x25, + .adchan = 16, + .adbits = 16, + .adrange = &range_dt3000_ai, + .ai_speed = 10000, + .dachan = 2, + .dabits = 12, + }, + {.name = "dt3005", /* a.k.a. 3004-200 */ + .device_id = 0x26, + .adchan = 16, + .adbits = 16, + .adrange = &range_dt3000_ai, + .ai_speed = 5000, + .dachan = 2, + .dabits = 12, + }, }; #define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype) @@ -275,28 +276,28 @@ struct dt3k_private { #define devpriv ((struct dt3k_private *)dev->private) -static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dt3000_detach(struct comedi_device * dev); +static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dt3000_detach(struct comedi_device *dev); static struct comedi_driver driver_dt3000 = { - driver_name:"dt3000", - module:THIS_MODULE, - attach:dt3000_attach, - detach:dt3000_detach, + .driver_name = "dt3000", + .module = THIS_MODULE, + .attach = dt3000_attach, + .detach = dt3000_detach, }; COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table); -static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevice * s); +static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s); static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg, unsigned int round_mode); -static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); #ifdef DEBUG static void debug_intr_flags(unsigned int flags); #endif #define TIMEOUT 100 -static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd) +static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd) { int i; unsigned int status = 0; @@ -307,7 +308,7 @@ static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd) status = readw(devpriv->io_addr + DPR_Command_Mbx); if ((status & DT3000_COMPLETION_MASK) != DT3000_NOTPROCESSED) break; - comedi_udelay(1); + udelay(1); } if ((status & DT3000_COMPLETION_MASK) == DT3000_NOERROR) { return 0; @@ -318,7 +319,7 @@ static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd) return -ETIME; } -static unsigned int dt3k_readsingle(struct comedi_device * dev, unsigned int subsys, +static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subsys, unsigned int chan, unsigned int gain) { writew(subsys, devpriv->io_addr + DPR_SubSys); @@ -331,7 +332,7 @@ static unsigned int dt3k_readsingle(struct comedi_device * dev, unsigned int sub return readw(devpriv->io_addr + DPR_Params(2)); } -static void dt3k_writesingle(struct comedi_device * dev, unsigned int subsys, +static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys, unsigned int chan, unsigned int data) { writew(subsys, devpriv->io_addr + DPR_SubSys); @@ -345,9 +346,9 @@ static void dt3k_writesingle(struct comedi_device * dev, unsigned int subsys, static int debug_n_ints = 0; -// FIXME! Assumes shared interrupt is for this card. -// What's this debug_n_ints stuff? Obviously needs some work... -static irqreturn_t dt3k_interrupt(int irq, void *d PT_REGS_ARG) +/* FIXME! Assumes shared interrupt is for this card. */ +/* What's this debug_n_ints stuff? Obviously needs some work... */ +static irqreturn_t dt3k_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s; @@ -400,7 +401,7 @@ static void debug_intr_flags(unsigned int flags) } #endif -static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevice * s) +static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s) { int front; int rear; @@ -429,8 +430,8 @@ static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevi writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear); } -static int dt3k_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -591,7 +592,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec, return (prescale << 16) | (divider); } -static int dt3k_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int i; @@ -659,7 +660,7 @@ static int dt3k_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { int ret; @@ -671,8 +672,8 @@ static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int dt3k_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; unsigned int chan, gain, aref; @@ -689,8 +690,8 @@ static int dt3k_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s, return i; } -static int dt3k_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; unsigned int chan; @@ -704,8 +705,8 @@ static int dt3k_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, return i; } -static int dt3k_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; unsigned int chan; @@ -718,7 +719,7 @@ static int dt3k_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice return i; } -static void dt3k_dio_config(struct comedi_device * dev, int bits) +static void dt3k_dio_config(struct comedi_device *dev, int bits) { /* XXX */ writew(SUBS_DOUT, devpriv->io_addr + DPR_SubSys); @@ -733,8 +734,8 @@ static void dt3k_dio_config(struct comedi_device * dev, int bits) dt3k_send_cmd(dev, CMD_CONFIG); } -static int dt3k_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int mask; @@ -764,8 +765,8 @@ static int dt3k_dio_insn_config(struct comedi_device * dev, struct comedi_subdev return insn->n; } -static int dt3k_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -780,8 +781,8 @@ static int dt3k_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic return 2; } -static int dt3k_mem_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dt3k_mem_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int addr = CR_CHAN(insn->chanspec); int i; @@ -799,9 +800,9 @@ static int dt3k_mem_insn_read(struct comedi_device * dev, struct comedi_subdevic return i; } -static int dt_pci_probe(struct comedi_device * dev, int bus, int slot); +static int dt_pci_probe(struct comedi_device *dev, int bus, int slot); -static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int bus, slot; @@ -811,7 +812,8 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i bus = it->options[0]; slot = it->options[1]; - if ((ret = alloc_private(dev, sizeof(struct dt3k_private))) < 0) + ret = alloc_private(dev, sizeof(struct dt3k_private)); + if (ret < 0) return ret; ret = dt_pci_probe(dev, bus, slot); @@ -824,14 +826,15 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->board_name = this_board->name; - if (comedi_request_irq(devpriv->pci_dev->irq, dt3k_interrupt, - IRQF_SHARED, "dt3000", dev)) { + if (request_irq(devpriv->pci_dev->irq, dt3k_interrupt, IRQF_SHARED, + "dt3000", dev)) { printk(" unable to allocate IRQ %u\n", devpriv->pci_dev->irq); return -EINVAL; } dev->irq = devpriv->pci_dev->irq; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; s = dev->subdevices; @@ -890,10 +893,10 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int dt3000_detach(struct comedi_device * dev) +static int dt3000_detach(struct comedi_device *dev) { if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv) { if (devpriv->pci_dev) { @@ -911,9 +914,9 @@ static int dt3000_detach(struct comedi_device * dev) } static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board); -static int setup_pci(struct comedi_device * dev); +static int setup_pci(struct comedi_device *dev); -static int dt_pci_probe(struct comedi_device * dev, int bus, int slot) +static int dt_pci_probe(struct comedi_device *dev, int bus, int slot) { int board; int ret; @@ -935,13 +938,14 @@ static int dt_pci_probe(struct comedi_device * dev, int bus, int slot) if (!devpriv->pci_dev) return 0; - if ((ret = setup_pci(dev)) < 0) + ret = setup_pci(dev); + if (ret < 0) return ret; return 1; } -static int setup_pci(struct comedi_device * dev) +static int setup_pci(struct comedi_device *dev) { resource_size_t addr; int ret; diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 6d7bb37d2b1c..b8657c47d4cc 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -42,30 +42,30 @@ static const struct comedi_lrange range_fl512 = { 4, { } }; -static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int fl512_detach(struct comedi_device * dev); +static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int fl512_detach(struct comedi_device *dev); static struct comedi_driver driver_fl512 = { - driver_name:"fl512", - module:THIS_MODULE, - attach:fl512_attach, - detach:fl512_detach, + .driver_name = "fl512", + .module = THIS_MODULE, + .attach = fl512_attach, + .detach = fl512_detach, }; COMEDI_INITCLEANUP(driver_fl512); -static int fl512_ai_insn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); -static int fl512_ao_insn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); -static int fl512_ao_insn_readback(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int fl512_ai_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int fl512_ao_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int fl512_ao_insn_readback(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* * fl512_ai_insn : this is the analog input function */ -static int fl512_ai_insn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int fl512_ai_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int n; unsigned int lo_byte, hi_byte; @@ -78,7 +78,7 @@ static int fl512_ai_insn(struct comedi_device * dev, outb(chan, iobase + 2); /* select chan */ outb(0, iobase + 3); /* start conversion */ /* XXX should test "done" flag instead of delay */ - comedi_udelay(30); /* sleep 30 usec */ + udelay(30); /* sleep 30 usec */ lo_byte = inb(iobase + 2); /* low 8 byte */ hi_byte = inb(iobase + 3) & 0xf; /* high 4 bit and mask */ data[n] = lo_byte + (hi_byte << 8); @@ -89,8 +89,8 @@ static int fl512_ai_insn(struct comedi_device * dev, /* * fl512_ao_insn : used to write to a DA port n times */ -static int fl512_ao_insn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int fl512_ao_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); /* get chan to write */ @@ -110,8 +110,8 @@ static int fl512_ao_insn(struct comedi_device * dev, * fl512_ao_insn_readback : used to read previous values written to * DA port */ -static int fl512_ao_insn_readback(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int fl512_ao_insn_readback(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -126,7 +126,7 @@ static int fl512_ao_insn_readback(struct comedi_device * dev, /* * start attach */ -static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned long iobase; struct comedi_subdevice *s; /* pointer to the subdevice: @@ -177,7 +177,7 @@ static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it return 1; } -static int fl512_detach(struct comedi_device * dev) +static int fl512_detach(struct comedi_device *dev) { if (dev->iobase) release_region(dev->iobase, FL512_SIZE); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 49e5c86c2dd8..b156ae717ae4 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -45,6 +45,7 @@ support could be added to this driver. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -52,31 +53,31 @@ support could be added to this driver. #include "plx9080.h" #include "comedi_fc.h" -static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int hpdi_detach(struct comedi_device * dev); -void abort_dma(struct comedi_device * dev, unsigned int channel); -static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int hpdi_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG); -static int dio_config_block_size(struct comedi_device * dev, unsigned int * data); +static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int hpdi_detach(struct comedi_device *dev); +void abort_dma(struct comedi_device *dev, unsigned int channel); +static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static irqreturn_t handle_interrupt(int irq, void *d); +static int dio_config_block_size(struct comedi_device *dev, unsigned int *data); -#undef HPDI_DEBUG // disable debugging messages -//#define HPDI_DEBUG // enable debugging code +#undef HPDI_DEBUG /* disable debugging messages */ +/* #define HPDI_DEBUG enable debugging code */ #ifdef HPDI_DEBUG -#define DEBUG_PRINT(format, args...) rt_printk(format , ## args ) +#define DEBUG_PRINT(format, args...) printk(format , ## args) #else #define DEBUG_PRINT(format, args...) #endif -#define TIMER_BASE 50 // 20MHz master clock +#define TIMER_BASE 50 /* 20MHz master clock */ #define DMA_BUFFER_SIZE 0x10000 #define NUM_DMA_BUFFERS 4 #define NUM_DMA_DESCRIPTORS 256 -// indices of base address regions +/* indices of base address regions */ enum base_address_regions { PLX9080_BADDRINDEX = 0, HPDI_BADDRINDEX = 2, @@ -109,13 +110,13 @@ enum hpdi_registers { int command_channel_valid(unsigned int channel) { if (channel == 0 || channel > 6) { - rt_printk("gsc_hpdi: bug! invalid cable command channel\n"); + printk("gsc_hpdi: bug! invalid cable command channel\n"); return 0; } return 1; } -// bit definitions +/* bit definitions */ enum firmware_revision_bits { FEATURES_REG_PRESENT_BIT = 0x8000, @@ -184,7 +185,7 @@ enum board_status_bits { uint32_t almost_full_bits(unsigned int num_words) { -// XXX need to add or subtract one? +/* XXX need to add or subtract one? */ return (num_words << 16) & 0xff0000; } @@ -194,7 +195,7 @@ uint32_t almost_empty_bits(unsigned int num_words) } unsigned int almost_full_num_words(uint32_t bits) { -// XXX need to add or subtract one? +/* XXX need to add or subtract one? */ return (bits >> 16) & 0xffff; } unsigned int almost_empty_num_words(uint32_t bits) @@ -263,31 +264,26 @@ uint32_t intr_active_high_bit(int interrupt_source) struct hpdi_board { char *name; - int device_id; // pci device id - int subdevice_id; // pci subdevice id + int device_id; /* pci device id */ + int subdevice_id; /* pci subdevice id */ }; static const struct hpdi_board hpdi_boards[] = { { - name: "pci-hpdi32", - device_id:PCI_DEVICE_ID_PLX_9080, - subdevice_id:0x2400, + .name = "pci-hpdi32", + .device_id = PCI_DEVICE_ID_PLX_9080, + .subdevice_id = 0x2400, }, #if 0 { - name: "pxi-hpdi32", - device_id:0x9656, - subdevice_id:0x2705, + .name = "pxi-hpdi32", + .device_id = 0x9656, + .subdevice_id = 0x2705, }, #endif }; -static inline unsigned int num_boards(void) -{ - return sizeof(hpdi_boards) / sizeof(struct hpdi_board); -} - static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = { {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400, 0, 0, 0}, @@ -303,25 +299,25 @@ static inline struct hpdi_board *board(const struct comedi_device * dev) struct hpdi_private { - struct pci_dev *hw_dev; // pointer to board's pci_dev struct - // base addresses (physical) + struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */ + /* base addresses (physical) */ resource_size_t plx9080_phys_iobase; resource_size_t hpdi_phys_iobase; - // base addresses (ioremapped) + /* base addresses (ioremapped) */ void *plx9080_iobase; void *hpdi_iobase; - uint32_t *dio_buffer[NUM_DMA_BUFFERS]; // dma buffers - dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; // physical addresses of dma buffers - struct plx_dma_desc *dma_desc; // array of dma descriptors read by plx9080, allocated to get proper alignment - dma_addr_t dma_desc_phys_addr; // physical address of dma descriptor array + uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ + dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; /* physical addresses of dma buffers */ + struct plx_dma_desc *dma_desc; /* array of dma descriptors read by plx9080, allocated to get proper alignment */ + dma_addr_t dma_desc_phys_addr; /* physical address of dma descriptor array */ unsigned int num_dma_descriptors; - uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; // pointer to start of buffers indexed by descriptor - volatile unsigned int dma_desc_index; // index of the dma descriptor that is currently being used + uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; /* pointer to start of buffers indexed by descriptor */ + volatile unsigned int dma_desc_index; /* index of the dma descriptor that is currently being used */ unsigned int tx_fifo_size; unsigned int rx_fifo_size; volatile unsigned long dio_count; - volatile uint32_t bits[24]; // software copies of values written to hpdi registers - volatile unsigned int block_size; // number of bytes at which to generate COMEDI_CB_BLOCK events + volatile uint32_t bits[24]; /* software copies of values written to hpdi registers */ + volatile unsigned int block_size; /* number of bytes at which to generate COMEDI_CB_BLOCK events */ unsigned dio_config_output:1; }; @@ -332,16 +328,16 @@ static inline struct hpdi_private *priv(struct comedi_device * dev) } static struct comedi_driver driver_hpdi = { - driver_name:"gsc_hpdi", - module:THIS_MODULE, - attach:hpdi_attach, - detach:hpdi_detach, + .driver_name = "gsc_hpdi", + .module = THIS_MODULE, + .attach = hpdi_attach, + .detach = hpdi_detach, }; COMEDI_PCI_INITCLEANUP(driver_hpdi, hpdi_pci_table); -static int dio_config_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: @@ -368,18 +364,18 @@ static int dio_config_insn(struct comedi_device * dev, struct comedi_subdevice * return -EINVAL; } -static void disable_plx_interrupts(struct comedi_device * dev) +static void disable_plx_interrupts(struct comedi_device *dev) { writel(0, priv(dev)->plx9080_iobase + PLX_INTRCS_REG); } -// initialize plx9080 chip -static void init_plx9080(struct comedi_device * dev) +/* initialize plx9080 chip */ +static void init_plx9080(struct comedi_device *dev) { uint32_t bits; void *plx_iobase = priv(dev)->plx9080_iobase; - // plx9080 dump + /* plx9080 dump */ DEBUG_PRINT(" plx interrupt status 0x%x\n", readl(plx_iobase + PLX_INTRCS_REG)); DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG)); @@ -417,21 +413,21 @@ static void init_plx9080(struct comedi_device * dev) abort_dma(dev, 0); abort_dma(dev, 1); - // configure dma0 mode + /* configure dma0 mode */ bits = 0; - // enable ready input + /* enable ready input */ bits |= PLX_DMA_EN_READYIN_BIT; - // enable dma chaining + /* enable dma chaining */ bits |= PLX_EN_CHAIN_BIT; - // enable interrupt on dma done (probably don't need this, since chain never finishes) + /* enable interrupt on dma done (probably don't need this, since chain never finishes) */ bits |= PLX_EN_DMA_DONE_INTR_BIT; - // don't increment local address during transfers (we are transferring from a fixed fifo register) + /* don't increment local address during transfers (we are transferring from a fixed fifo register) */ bits |= PLX_LOCAL_ADDR_CONST_BIT; - // route dma interrupt to pci bus + /* route dma interrupt to pci bus */ bits |= PLX_DMA_INTR_PCI_BIT; - // enable demand mode + /* enable demand mode */ bits |= PLX_DEMAND_MODE_BIT; - // enable local burst mode + /* enable local burst mode */ bits |= PLX_DMA_LOCAL_BURST_EN_BIT; bits |= PLX_LOCAL_BUS_32_WIDE_BITS; writel(bits, plx_iobase + PLX_DMA0_MODE_REG); @@ -439,7 +435,7 @@ static void init_plx9080(struct comedi_device * dev) /* Allocate and initialize the subdevice structures. */ -static int setup_subdevices(struct comedi_device * dev) +static int setup_subdevices(struct comedi_device *dev) { struct comedi_subdevice *s; @@ -465,12 +461,12 @@ static int setup_subdevices(struct comedi_device * dev) return 0; } -static int init_hpdi(struct comedi_device * dev) +static int init_hpdi(struct comedi_device *dev) { uint32_t plx_intcsr_bits; writel(BOARD_RESET_BIT, priv(dev)->hpdi_iobase + BOARD_CONTROL_REG); - comedi_udelay(10); + udelay(10); writel(almost_empty_bits(32) | almost_full_bits(32), priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG); @@ -484,7 +480,7 @@ static int init_hpdi(struct comedi_device * dev) writel(0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG); - // enable interrupts + /* enable interrupts */ plx_intcsr_bits = ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | ICS_DMA0_E; @@ -493,8 +489,8 @@ static int init_hpdi(struct comedi_device * dev) return 0; } -// setup dma descriptors so a link completes every 'transfer_size' bytes -static int setup_dma_descriptors(struct comedi_device * dev, +/* setup dma descriptors so a link completes every 'transfer_size' bytes */ +static int setup_dma_descriptors(struct comedi_device *dev, unsigned int transfer_size) { unsigned int buffer_index, buffer_offset; @@ -545,7 +541,7 @@ static int setup_dma_descriptors(struct comedi_device * dev, (unsigned long)priv(dev)->dma_desc[i].next); } priv(dev)->num_dma_descriptors = i; - // fix last descriptor to point back to first + /* fix last descriptor to point back to first */ priv(dev)->dma_desc[i - 1].next = cpu_to_le32(priv(dev)->dma_desc_phys_addr | next_bits); DEBUG_PRINT(" desc %i next fixup 0x%lx\n", i - 1, @@ -556,7 +552,7 @@ static int setup_dma_descriptors(struct comedi_device * dev, return transfer_size; } -static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci_dev *pcidev; int i; @@ -568,14 +564,14 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) return -ENOMEM; pcidev = NULL; - for (i = 0; i < num_boards() && dev->board_ptr == NULL; i++) { + for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) { do { pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX, hpdi_boards[i].device_id, PCI_VENDOR_ID_PLX, hpdi_boards[i].subdevice_id, pcidev); - // was a particular bus/slot requested? + /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - // are we on the wrong bus/slot? + /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) @@ -603,7 +599,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) } pci_set_master(pcidev); - //Initialize dev->board_name + /* Initialize dev->board_name */ dev->board_name = board(dev)->name; priv(dev)->plx9080_phys_iobase = @@ -611,7 +607,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) priv(dev)->hpdi_phys_iobase = pci_resource_start(pcidev, HPDI_BADDRINDEX); - // remap, won't work with 2.0 kernels but who cares + /* remap, won't work with 2.0 kernels but who cares */ priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase, pci_resource_len(pcidev, PLX9080_BADDRINDEX)); priv(dev)->hpdi_iobase = ioremap(priv(dev)->hpdi_phys_iobase, @@ -626,8 +622,8 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) init_plx9080(dev); - // get irq - if (comedi_request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, + /* get irq */ + if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, driver_hpdi.driver_name, dev)) { printk(" unable to allocate irq %u\n", pcidev->irq); return -EINVAL; @@ -636,7 +632,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) printk(" irq %u\n", dev->irq); - // alocate pci dma buffers + /* alocate pci dma buffers */ for (i = 0; i < NUM_DMA_BUFFERS; i++) { priv(dev)->dio_buffer[i] = pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE, @@ -645,7 +641,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) priv(dev)->dio_buffer[i], (unsigned long)priv(dev)->dio_buffer_phys_addr[i]); } - // allocate dma descriptors + /* allocate dma descriptors */ priv(dev)->dma_desc = pci_alloc_consistent(priv(dev)->hw_dev, sizeof(struct plx_dma_desc) * NUM_DMA_DESCRIPTORS, &priv(dev)->dma_desc_phys_addr); @@ -665,14 +661,14 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it) return init_hpdi(dev); } -static int hpdi_detach(struct comedi_device * dev) +static int hpdi_detach(struct comedi_device *dev) { unsigned int i; printk("comedi%d: gsc_hpdi: remove\n", dev->minor); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (priv(dev)) { if (priv(dev)->hw_dev) { if (priv(dev)->plx9080_iobase) { @@ -681,7 +677,7 @@ static int hpdi_detach(struct comedi_device * dev) } if (priv(dev)->hpdi_iobase) iounmap((void *)priv(dev)->hpdi_iobase); - // free pci dma buffers + /* free pci dma buffers */ for (i = 0; i < NUM_DMA_BUFFERS; i++) { if (priv(dev)->dio_buffer[i]) pci_free_consistent(priv(dev)->hw_dev, @@ -690,7 +686,7 @@ static int hpdi_detach(struct comedi_device * dev) priv(dev)-> dio_buffer_phys_addr[i]); } - // free dma descriptors + /* free dma descriptors */ if (priv(dev)->dma_desc) pci_free_consistent(priv(dev)->hw_dev, sizeof(struct plx_dma_desc) * @@ -706,7 +702,7 @@ static int hpdi_detach(struct comedi_device * dev) return 0; } -static int dio_config_block_size(struct comedi_device * dev, unsigned int * data) +static int dio_config_block_size(struct comedi_device *dev, unsigned int *data) { unsigned int requested_block_size; int retval; @@ -722,8 +718,8 @@ static int dio_config_block_size(struct comedi_device * dev, unsigned int * data return 2; } -static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -761,7 +757,7 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, /* step 2: make sure trigger sources are unique and mutually compatible */ - // uniqueness check + /* uniqueness check */ if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) err++; @@ -807,7 +803,7 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, if (cmd->chanlist) { for (i = 1; i < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i]) != i) { - // XXX could support 8 channels or 16 channels + /* XXX could support 8 channels or 16 channels */ comedi_error(dev, "chanlist must be channels 0 to 31 in order"); err++; @@ -822,8 +818,8 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, return 0; } -static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { if (priv(dev)->dio_config_output) { return -EINVAL; @@ -831,14 +827,14 @@ static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s return di_cmd_test(dev, s, cmd); } -static inline void hpdi_writel(struct comedi_device * dev, uint32_t bits, +static inline void hpdi_writel(struct comedi_device *dev, uint32_t bits, unsigned int offset) { writel(bits | priv(dev)->bits[offset / sizeof(uint32_t)], priv(dev)->hpdi_iobase + offset); } -static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { uint32_t bits; unsigned long flags; @@ -860,28 +856,28 @@ static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s) writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG); writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG); - // give location of first dma descriptor + /* give location of first dma descriptor */ bits = priv(dev)-> dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI; writel(bits, priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG); - // spinlock for plx dma control/status reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); - // enable dma transfer + /* spinlock for plx dma control/status reg */ + spin_lock_irqsave(&dev->spinlock, flags); + /* enable dma transfer */ writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); if (cmd->stop_src == TRIG_COUNT) priv(dev)->dio_count = cmd->stop_arg; else priv(dev)->dio_count = 1; - // clear over/under run status flags + /* clear over/under run status flags */ writel(RX_UNDERRUN_BIT | RX_OVERRUN_BIT, priv(dev)->hpdi_iobase + BOARD_STATUS_REG); - // enable interrupts + /* enable interrupts */ writel(intr_bit(RX_FULL_INTR), priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG); @@ -891,7 +887,7 @@ static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { if (priv(dev)->dio_config_output) { return -EINVAL; @@ -899,7 +895,7 @@ static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return di_cmd(dev, s); } -static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) +static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) { struct comedi_async *async = dev->read_subdev->async; uint32_t next_transfer_addr; @@ -914,7 +910,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) pci_addr_reg = priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; - // loop until we have read all the full buffers + /* loop until we have read all the full buffers */ j = 0; for (next_transfer_addr = readl(pci_addr_reg); (next_transfer_addr < @@ -925,7 +921,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) dma_desc_index].pci_start_addr) + priv(dev)->block_size) && j < priv(dev)->num_dma_descriptors; j++) { - // transfer data from dma buffer to comedi buffer + /* transfer data from dma buffer to comedi buffer */ num_samples = priv(dev)->block_size / sizeof(uint32_t); if (async->cmd.stop_src == TRIG_COUNT) { if (num_samples > priv(dev)->dio_count) @@ -942,10 +938,10 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel) priv(dev)->dma_desc[priv(dev)->dma_desc_index].next); DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr); } - // XXX check for buffer overrun somehow + /* XXX check for buffer overrun somehow */ } -static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t handle_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; @@ -975,10 +971,10 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) writel(hpdi_intr_status, priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG); } - // spin lock makes sure noone else changes plx dma control reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spin lock makes sure noone else changes plx dma control reg */ + spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); - if (plx_status & ICS_DMA0_A) { // dma chan 0 interrupt + if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); @@ -988,23 +984,23 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) } DEBUG_PRINT(" cleared dma ch0 interrupt\n"); } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // spin lock makes sure noone else changes plx dma control reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spin lock makes sure noone else changes plx dma control reg */ + spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); - if (plx_status & ICS_DMA1_A) // XXX - { // dma chan 1 interrupt + if (plx_status & ICS_DMA1_A) /* XXX */ + { /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); DEBUG_PRINT("dma1 status 0x%x\n", dma1_status); DEBUG_PRINT(" cleared dma ch1 interrupt\n"); } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // clear possible plx9080 interrupt sources - if (plx_status & ICS_LDIA) { // clear local doorbell interrupt + /* clear possible plx9080 interrupt sources */ + if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ plx_bits = readl(priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG); writel(plx_bits, priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG); DEBUG_PRINT(" cleared local doorbell bits 0x%x\n", plx_bits); @@ -1036,19 +1032,19 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -void abort_dma(struct comedi_device * dev, unsigned int channel) +void abort_dma(struct comedi_device *dev, unsigned int channel) { unsigned long flags; - // spinlock for plx dma control/status reg - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* spinlock for plx dma control/status reg */ + spin_lock_irqsave(&dev->spinlock, flags); plx9080_abort_dma(priv(dev)->plx9080_iobase, channel); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); } -static int hpdi_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { hpdi_writel(dev, 0, BOARD_CONTROL_REG); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 15fce0190b2f..984f995149b6 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -50,6 +50,7 @@ Options: [1] - PCI slot number */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -282,7 +283,7 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde readw(devpriv->io_addr + ICP_MULTI_ADC_CSR)); #endif - comedi_udelay(1); + udelay(1); #ifdef ICP_MULTI_EXTDEBUG printk("icp multi C n=%d ST=%4x\n", n, @@ -304,7 +305,7 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde ICP_MULTI_ADC_CSR)); #endif - comedi_udelay(1); + udelay(1); } /* If we reach here, a timeout has occurred */ @@ -411,7 +412,7 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd ICP_MULTI_DAC_CSR)); #endif - comedi_udelay(1); + udelay(1); } /* If we reach here, a timeout has occurred */ @@ -618,7 +619,7 @@ static int icp_multi_insn_write_ctr(struct comedi_device *dev, struct comedi_sub ============================================================================== */ -static irqreturn_t interrupt_service_icp_multi(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_service_icp_multi(int irq, void *d) { struct comedi_device *dev = d; int int_no; @@ -842,7 +843,7 @@ static int icp_multi_reset(struct comedi_device *dev) devpriv->io_addr + ICP_MULTI_DAC_CSR); /* Delay to allow DAC time to recover */ - comedi_udelay(1); + udelay(1); } /* Digital outputs to 0 */ writew(0, devpriv->io_addr + ICP_MULTI_DO); @@ -954,7 +955,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig * if (this_board->have_irq) { if (irq) { - if (comedi_request_irq(irq, interrupt_service_icp_multi, + if (request_irq(irq, interrupt_service_icp_multi, IRQF_SHARED, "Inova Icp Multi", dev)) { printk(", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ @@ -1072,7 +1073,7 @@ static int icp_multi_detach(struct comedi_device *dev) icp_multi_reset(dev); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->private && devpriv->io_addr) iounmap(devpriv->io_addr); diff --git a/drivers/staging/comedi/drivers/icp_multi.h b/drivers/staging/comedi/drivers/icp_multi.h index 21d84766fea8..354ba8f14f81 100644 --- a/drivers/staging/comedi/drivers/icp_multi.h +++ b/drivers/staging/comedi/drivers/icp_multi.h @@ -168,14 +168,14 @@ static int pci_card_alloc(struct pcilst_struct *inova) int i; if (!inova) { - rt_printk(" - BUG!! inova is NULL!\n"); + printk(" - BUG!! inova is NULL!\n"); return -1; } if (inova->used) return 1; if (comedi_pci_enable(inova->pcidev, "icp_multi")) { - rt_printk(" - Can't enable PCI device and request regions!\n"); + printk(" - Can't enable PCI device and request regions!\n"); return -1; } /* Resources will be accurate now. */ @@ -248,19 +248,19 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id, card = find_free_pci_card_by_device(vendor_id, device_id); if (card == NULL) { - rt_printk(" - Unused card not found in system!\n"); + printk(" - Unused card not found in system!\n"); return NULL; } } else { switch (find_free_pci_card_by_position(vendor_id, device_id, pci_bus, pci_slot, &card)) { case 1: - rt_printk + printk (" - Card not found on requested position b:s %d:%d!\n", pci_bus, pci_slot); return NULL; case 2: - rt_printk + printk (" - Card on requested position is used b:s %d:%d!\n", pci_bus, pci_slot); return NULL; @@ -270,7 +270,7 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id, err = pci_card_alloc(card); if (err != 0) { if (err > 0) - rt_printk(" - Can't allocate card!\n"); + printk(" - Can't allocate card!\n"); /* else: error already printed. */ return NULL; } diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 80825ba25418..a90d65fde31e 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -158,21 +158,21 @@ struct pci20xxx_private { #define devpriv ((struct pci20xxx_private *)dev->private) #define CHAN (CR_CHAN(it->chanlist[0])) -static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pci20xxx_detach(struct comedi_device * dev); +static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci20xxx_detach(struct comedi_device *dev); static struct comedi_driver driver_pci20xxx = { - driver_name:"ii_pci20kc", - module:THIS_MODULE, - attach:pci20xxx_attach, - detach:pci20xxx_detach, + .driver_name = "ii_pci20kc", + .module = THIS_MODULE, + .attach = pci20xxx_attach, + .detach = pci20xxx_detach, }; -static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, int opt0, int opt1); -static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, int opt0, int opt1); -static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice * s); +static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s); /* options[0] Board base address @@ -201,7 +201,7 @@ static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice 1 == unipolar 10V (0V -- +10V) 2 == bipolar 5V (-5V -- +5V) */ -static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned char i; int ret; @@ -209,9 +209,12 @@ static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * struct comedi_subdevice *s; union pci20xxx_subdev_private *sdp; - if ((ret = alloc_subdevices(dev, 1 + PCI20000_MODULES)) < 0) + ret = alloc_subdevices(dev, 1 + PCI20000_MODULES); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct pci20xxx_private))) < 0) + + ret = alloc_private(dev, sizeof(struct pci20xxx_private)); + if (ret < 0) return ret; devpriv->ioaddr = (void *)(unsigned long)it->options[0]; @@ -263,7 +266,7 @@ static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * return 1; } -static int pci20xxx_detach(struct comedi_device * dev) +static int pci20xxx_detach(struct comedi_device *dev) { printk("comedi%d: pci20xxx: remove\n", dev->minor); @@ -272,10 +275,10 @@ static int pci20xxx_detach(struct comedi_device * dev) /* pci20006m */ -static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static const struct comedi_lrange *pci20006_range_list[] = { &range_bipolar10, @@ -283,7 +286,7 @@ static const struct comedi_lrange *pci20006_range_list[] = { &range_bipolar5, }; -static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, int opt0, int opt1) { union pci20xxx_subdev_private *sdp = s->private; @@ -308,8 +311,8 @@ static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; @@ -318,8 +321,8 @@ static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevic return 1; } -static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; int hi, lo; @@ -351,8 +354,8 @@ static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevi /* PCI20341M */ -static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; @@ -368,7 +371,7 @@ static const struct comedi_lrange *const pci20341_ranges[] = { &range_bipolar0_025, }; -static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s, +static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, int opt0, int opt1) { union pci20xxx_subdev_private *sdp = s->private; @@ -399,8 +402,8 @@ static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; unsigned int i = 0, j = 0; @@ -445,14 +448,14 @@ static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevic /* native DIO */ -static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdevice * s); -static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* initialize struct pci20xxx_private */ -static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice * s) +static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s) { s->type = COMEDI_SUBD_DIO; @@ -471,8 +474,8 @@ static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int mask, bits; @@ -496,8 +499,8 @@ static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_su return 1; } -static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask = data[0]; @@ -526,7 +529,7 @@ static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subd return 2; } -static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned char control_01; unsigned char control_23; @@ -582,7 +585,7 @@ static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdev } #if 0 -static void pci20xxx_do(struct comedi_device * dev, struct comedi_subdevice * s) +static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) { /* XXX if the channel is configured for input, does this do bad things? */ @@ -595,7 +598,7 @@ static void pci20xxx_do(struct comedi_device * dev, struct comedi_subdevice * s) writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3); } -static unsigned int pci20xxx_di(struct comedi_device * dev, struct comedi_subdevice * s) +static unsigned int pci20xxx_di(struct comedi_device *dev, struct comedi_subdevice *s) { /* XXX same note as above */ unsigned int bits; diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index a3c887f3b2c6..e3c3adc282e2 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -45,72 +45,25 @@ Devices: [JR3] PCI force sensor board (jr3_pci) #include <linux/delay.h> #include <linux/ctype.h> #include <linux/firmware.h> +#include <linux/jiffies.h> +#include <linux/timer.h> #include "comedi_pci.h" #include "jr3_pci.h" -/* Hotplug firmware loading stuff */ - -static void comedi_fw_release(struct device *dev) -{ - printk(KERN_DEBUG "firmware_sample_driver: ghost_release\n"); -} - -static struct device comedi_fw_device = { - .init_name = "comedi", - .release = comedi_fw_release -}; - -typedef int comedi_firmware_callback(struct comedi_device * dev, - const u8 * data, size_t size); - -static int comedi_load_firmware(struct comedi_device * dev, - char *name, comedi_firmware_callback cb) -{ - int result = 0; - const struct firmware *fw; - char *firmware_path; - static const char *prefix = "comedi/"; - - firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL); - if (!firmware_path) { - result = -ENOMEM; - } else { - firmware_path[0] = '\0'; - strcat(firmware_path, prefix); - strcat(firmware_path, name); - result = device_register(&comedi_fw_device); - if (result == 0) { - result = request_firmware(&fw, firmware_path, - &comedi_fw_device); - if (result == 0) { - if (!cb) { - result = -EINVAL; - } else { - result = cb(dev, fw->data, fw->size); - } - release_firmware(fw); - } - device_unregister(&comedi_fw_device); - } - kfree(firmware_path); - } - return result; -} - #define PCI_VENDOR_ID_JR3 0x1762 #define PCI_DEVICE_ID_JR3_1_CHANNEL 0x3111 #define PCI_DEVICE_ID_JR3_2_CHANNEL 0x3112 #define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113 #define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114 -static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int jr3_pci_detach(struct comedi_device * dev); +static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int jr3_pci_detach(struct comedi_device *dev); static struct comedi_driver driver_jr3_pci = { - driver_name:"jr3_pci", - module:THIS_MODULE, - attach:jr3_pci_attach, - detach:jr3_pci_detach, + .driver_name = "jr3_pci", + .module = THIS_MODULE, + .attach = jr3_pci_attach, + .detach = jr3_pci_detach, }; static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = { @@ -168,6 +121,41 @@ struct jr3_pci_subdev_private { int retries; }; +/* Hotplug firmware loading stuff */ + +typedef int comedi_firmware_callback(struct comedi_device *dev, + const u8 *data, size_t size); + +static int comedi_load_firmware(struct comedi_device *dev, char *name, + comedi_firmware_callback cb) +{ + int result = 0; + const struct firmware *fw; + char *firmware_path; + static const char *prefix = "comedi/"; + struct jr3_pci_dev_private *devpriv = dev->private; + + firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL); + if (!firmware_path) { + result = -ENOMEM; + } else { + firmware_path[0] = '\0'; + strcat(firmware_path, prefix); + strcat(firmware_path, name); + result = request_firmware(&fw, firmware_path, + &devpriv->pci_dev->dev); + if (result == 0) { + if (!cb) + result = -EINVAL; + else + result = cb(dev, fw->data, fw->size); + release_firmware(fw); + } + kfree(firmware_path); + } + return result; +} + static struct poll_delay_t poll_delay_min_max(int min, int max) { struct poll_delay_t result; @@ -194,15 +182,15 @@ static void set_transforms(volatile struct jr3_channel *channel, { int i; - num &= 0x000f; // Make sure that 0 <= num <= 15 + num &= 0x000f; /* Make sure that 0 <= num <= 15 */ for (i = 0; i < 8; i++) { set_u16(&channel->transforms[num].link[i].link_type, transf.link[i].link_type); - comedi_udelay(1); + udelay(1); set_s16(&channel->transforms[num].link[i].link_amount, transf.link[i].link_amount); - comedi_udelay(1); + udelay(1); if (transf.link[i].link_type == end_x_form) { break; } @@ -273,8 +261,8 @@ static struct six_axis_t get_max_full_scales(volatile struct jr3_channel *channe return result; } -static int jr3_pci_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int result; struct jr3_pci_subdev_private *p; @@ -389,7 +377,7 @@ static int jr3_pci_ai_insn_read(struct comedi_device * dev, struct comedi_subdev return result; } -static void jr3_pci_open(struct comedi_device * dev) +static void jr3_pci_open(struct comedi_device *dev) { int i; struct jr3_pci_dev_private *devpriv = dev->private; @@ -406,14 +394,14 @@ static void jr3_pci_open(struct comedi_device * dev) } } -int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val) +int read_idm_word(const u8 *data, size_t size, int *pos, unsigned int *val) { int result = 0; if (pos != 0 && val != 0) { - // Skip over non hex + /* Skip over non hex */ for (; *pos < size && !isxdigit(data[*pos]); (*pos)++) { } - // Collect value + /* Collect value */ *val = 0; for (; *pos < size && isxdigit(data[*pos]); (*pos)++) { char ch = tolower(data[*pos]); @@ -428,7 +416,7 @@ int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val) return result; } -static int jr3_download_firmware(struct comedi_device * dev, const u8 * data, +static int jr3_download_firmware(struct comedi_device *dev, const u8 *data, size_t size) { /* @@ -485,17 +473,17 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data, count, addr); while (more && count > 0) { if (addr & 0x4000) { - // 16 bit data, never seen in real life!! + /* 16 bit data, never seen in real life!! */ unsigned int data1; more = more && read_idm_word(data, size, &pos, &data1); count--; - // printk("jr3_data, not tested\n"); - // jr3[addr + 0x20000 * pnum] = data1; + /* printk("jr3_data, not tested\n"); */ + /* jr3[addr + 0x20000 * pnum] = data1; */ } else { - // Download 24 bit program + /* Download 24 bit program */ unsigned int data1, data2; more = more @@ -510,12 +498,12 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data, channel[i]. program_low [addr], data1); - comedi_udelay(1); + udelay(1); set_u16(&p->iobase-> channel[i]. program_high [addr], data2); - comedi_udelay(1); + udelay(1); } } @@ -527,7 +515,7 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data, return result; } -static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) +static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s) { struct poll_delay_t result = poll_delay_min_max(1000, 2000); struct jr3_pci_subdev_private *p = s->private; @@ -541,7 +529,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) p->errors = errors; } if (errors & (watch_dog | watch_dog2 | sensor_change)) { - // Sensor communication lost, force poll mode + /* Sensor communication lost, force poll mode */ p->state = state_jr3_poll; } @@ -551,9 +539,10 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) u16 serial_no = get_u16(&channel->serial_no); if ((errors & (watch_dog | watch_dog2)) || model_no == 0 || serial_no == 0) { - // Still no sensor, keep on polling. Since it takes up to - // 10 seconds for offsets to stabilize, polling each - // second should suffice. +/* + * Still no sensor, keep on polling. Since it takes up to 10 seconds + * for offsets to stabilize, polling each second should suffice. + */ result = poll_delay_min_max(1000, 2000); } else { p->retries = 0; @@ -566,7 +555,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) case state_jr3_init_wait_for_offset:{ p->retries++; if (p->retries < 10) { - // Wait for offeset to stabilize (< 10 s according to manual) + /* Wait for offeset to stabilize (< 10 s according to manual) */ result = poll_delay_min_max(1000, 2000); } else { struct transform_t transf; @@ -582,7 +571,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) printk("Sensor Serial = %i\n", p->serial_no); - // Transformation all zeros + /* Transformation all zeros */ transf.link[0].link_type = (enum link_types)0; transf.link[0].link_amount = 0; @@ -600,7 +589,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) use_transform(channel, 0); p->state = state_jr3_init_transform_complete; - result = poll_delay_min_max(20, 100); // Allow 20 ms for completion + result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */ } } break; case state_jr3_init_transform_complete:{ @@ -608,7 +597,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) printk("state_jr3_init_transform_complete complete = %d\n", is_complete(channel)); result = poll_delay_min_max(20, 100); } else { - // Set full scale + /* Set full scale */ struct six_axis_t min_full_scale; struct six_axis_t max_full_scale; @@ -639,7 +628,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) p->state = state_jr3_init_set_full_scale_complete; - result = poll_delay_min_max(20, 100); // Allow 20 ms for completion + result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */ } } break; @@ -650,7 +639,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) } else { volatile struct force_array *full_scale; - // Use ranges in kN or we will overflow arount 2000N! + /* Use ranges in kN or we will overflow arount 2000N! */ full_scale = &channel->full_scale; p->range[0].range.min = -get_s16(&full_scale->fx) * @@ -679,10 +668,10 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) -get_s16(&full_scale->mz) * 100; p->range[5].range.max = get_s16(&full_scale->mz) * 100; - p->range[6].range.min = -get_s16(&full_scale->v1) * 100; // ?? - p->range[6].range.max = get_s16(&full_scale->v1) * 100; // ?? - p->range[7].range.min = -get_s16(&full_scale->v2) * 100; // ?? - p->range[7].range.max = get_s16(&full_scale->v2) * 100; // ?? + p->range[6].range.min = -get_s16(&full_scale->v1) * 100; /* ?? */ + p->range[6].range.max = get_s16(&full_scale->v1) * 100; /* ?? */ + p->range[7].range.min = -get_s16(&full_scale->v2) * 100; /* ?? */ + p->range[7].range.max = get_s16(&full_scale->v2) * 100; /* ?? */ p->range[8].range.min = 0; p->range[8].range.max = 65535; @@ -701,7 +690,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s) use_offset(channel, 0); p->state = state_jr3_init_use_offset_complete; - result = poll_delay_min_max(40, 100); // Allow 40 ms for completion + result = poll_delay_min_max(40, 100); /* Allow 40 ms for completion */ } } break; @@ -747,10 +736,10 @@ static void jr3_pci_poll_dev(unsigned long data) int delay; int i; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); delay = 1000; now = jiffies; - // Poll all channels that are ready to be polled + /* Poll all channels that are ready to be polled */ for (i = 0; i < devpriv->n_channels; i++) { struct jr3_pci_subdev_private *subdevpriv = dev->subdevices[i].private; if (now > subdevpriv->next_time_min) { @@ -762,19 +751,21 @@ static void jr3_pci_poll_dev(unsigned long data) subdevpriv->next_time_max = jiffies + msecs_to_jiffies(sub_delay.max); if (sub_delay.max && sub_delay.max < delay) { - // Wake up as late as possible -> poll as many channels as - // possible at once +/* +* Wake up as late as possible -> poll as many channels as possible +* at once +*/ delay = sub_delay.max; } } } - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); devpriv->timer.expires = jiffies + msecs_to_jiffies(delay); add_timer(&devpriv->timer); } -static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int result = 0; struct pci_dev *card = NULL; @@ -845,9 +836,12 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * devpriv->pci_dev = card; dev->board_name = "jr3_pci"; } - if ((result = comedi_pci_enable(card, "jr3_pci")) < 0) { + + result = comedi_pci_enable(card, "jr3_pci"); + if (result < 0) { return -EIO; } + devpriv->pci_enabled = 1; devpriv->iobase = ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t)); result = alloc_subdevices(dev, devpriv->n_channels); @@ -881,7 +875,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * p->range[j].range.max = 1000000; for (k = 0; k < 7; k++) { p->range_table_list[j + k * 8] = - (struct comedi_lrange *) & p->range[j]; + (struct comedi_lrange *) &p->range[j]; p->maxdata_list[j + k * 8] = 0x7fff; } } @@ -890,12 +884,12 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * p->range[8].range.max = 65536; p->range_table_list[56] = - (struct comedi_lrange *) & p->range[8]; + (struct comedi_lrange *) &p->range[8]; p->range_table_list[57] = - (struct comedi_lrange *) & p->range[8]; + (struct comedi_lrange *) &p->range[8]; p->maxdata_list[56] = 0xffff; p->maxdata_list[57] = 0xffff; - // Channel specific range and maxdata + /* Channel specific range and maxdata */ dev->subdevices[i].range_table = 0; dev->subdevices[i].range_table_list = p->range_table_list; @@ -904,7 +898,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * } } - // Reset DSP card + /* Reset DSP card */ devpriv->iobase->channel[0].reset = 0; result = comedi_load_firmware(dev, "jr3pci.idm", jr3_download_firmware); @@ -913,13 +907,18 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * if (result < 0) { goto out; } - // TODO: use firmware to load preferred offset tables. Suggested format: - // model serial Fx Fy Fz Mx My Mz\n - // - // comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware); +/* + * TODO: use firmware to load preferred offset tables. Suggested + * format: + * model serial Fx Fy Fz Mx My Mz\n + * + * comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware); + */ - // It takes a few milliseconds for software to settle - // as much as we can read firmware version +/* + * It takes a few milliseconds for software to settle as much as we + * can read firmware version + */ msleep_interruptible(25); for (i = 0; i < 0x18; i++) { printk("%c", @@ -927,7 +926,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * copyright[i]) >> 8); } - // Start card timer + /* Start card timer */ for (i = 0; i < devpriv->n_channels; i++) { struct jr3_pci_subdev_private *p = dev->subdevices[i].private; @@ -944,7 +943,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * return result; } -static int jr3_pci_detach(struct comedi_device * dev) +static int jr3_pci_detach(struct comedi_device *dev) { int i; struct jr3_pci_dev_private *devpriv = dev->private; diff --git a/drivers/staging/comedi/drivers/jr3_pci.h b/drivers/staging/comedi/drivers/jr3_pci.h index 3585f2941bca..4f4bfb24c6d6 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.h +++ b/drivers/staging/comedi/drivers/jr3_pci.h @@ -2,22 +2,22 @@ * is 16 bits, but aligned on a 32 bit PCI boundary */ -static inline u16 get_u16(volatile const u32 * p) +static inline u16 get_u16(volatile const u32 *p) { return (u16) readl(p); } -static inline void set_u16(volatile u32 * p, u16 val) +static inline void set_u16(volatile u32 *p, u16 val) { writel(val, p); } -static inline s16 get_s16(volatile const s32 * p) +static inline s16 get_s16(volatile const s32 *p) { return (s16) readl(p); } -static inline void set_s16(volatile s32 * p, s16 val) +static inline void set_s16(volatile s32 *p, s16 val) { writel(val, p); } diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 79f6fe5646c5..b49aed5c4a02 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -48,8 +48,8 @@ Kolter Electronic PCI Counter Card. /*-- function prototypes ----------------------------------------------------*/ -static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int cnt_detach(struct comedi_device * dev); +static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int cnt_detach(struct comedi_device *dev); static DEFINE_PCI_DEVICE_TABLE(cnt_pci_table) = { {PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, @@ -72,10 +72,10 @@ struct cnt_board_struct { static const struct cnt_board_struct cnt_boards[] = { { - name: CNT_DRIVER_NAME, - device_id:CNT_CARD_DEVICE_ID, - cnt_channel_nbr:3, - cnt_bits:24} + .name = CNT_DRIVER_NAME, + .device_id = CNT_CARD_DEVICE_ID, + .cnt_channel_nbr = 3, + .cnt_bits = 24} }; #define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct)) @@ -91,10 +91,10 @@ struct cnt_device_private { #define devpriv ((struct cnt_device_private *)dev->private) static struct comedi_driver cnt_driver = { - driver_name:CNT_DRIVER_NAME, - module:THIS_MODULE, - attach:cnt_attach, - detach:cnt_detach, + .driver_name = CNT_DRIVER_NAME, + .module = THIS_MODULE, + .attach = cnt_attach, + .detach = cnt_detach, }; COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table); @@ -103,8 +103,8 @@ COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table); /* This should be used only for resetting the counters; maybe it is better to make a special command 'reset'. */ -static int cnt_winsn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int cnt_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); @@ -123,8 +123,8 @@ static int cnt_winsn(struct comedi_device * dev, /*-- counter read -----------------------------------------------------------*/ -static int cnt_rinsn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int cnt_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { unsigned char a0, a1, a2, a3, a4; int chan = CR_CHAN(insn->chanspec); @@ -148,7 +148,7 @@ static int cnt_rinsn(struct comedi_device * dev, /*-- attach -----------------------------------------------------------------*/ -static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *subdevice; struct pci_dev *pci_device; @@ -157,9 +157,9 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) int error, i; /* allocate device private structure */ - if ((error = alloc_private(dev, sizeof(struct cnt_device_private))) < 0) { + error = alloc_private(dev, sizeof(struct cnt_device_private)); + if (error < 0) return error; - } /* Probe the device to determine what device in the series it is. */ for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); @@ -203,7 +203,8 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) dev->board_name = board->name; /* enable PCI device and request regions */ - if ((error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME)) < 0) { + error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME); + if (error < 0) { printk("comedi%d: failed to enable PCI device and request regions!\n", dev->minor); return error; } @@ -213,9 +214,9 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) dev->iobase = io_base; /* allocate the subdevice structures */ - if ((error = alloc_subdevices(dev, 1)) < 0) { + error = alloc_subdevices(dev, 1); + if (error < 0) return error; - } subdevice = dev->subdevices + 0; dev->read_subdev = subdevice; @@ -227,10 +228,10 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) subdevice->insn_read = cnt_rinsn; subdevice->insn_write = cnt_winsn; - // select 20MHz clock + /* select 20MHz clock */ outb(3, dev->iobase + 248); - // reset all counters + /* reset all counters */ outb(0, dev->iobase); outb(0, dev->iobase + 0x20); outb(0, dev->iobase + 0x40); @@ -241,7 +242,7 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it) /*-- detach -----------------------------------------------------------------*/ -static int cnt_detach(struct comedi_device * dev) +static int cnt_detach(struct comedi_device *dev) { if (devpriv && devpriv->pcidev) { if (dev->iobase) { diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 12481a032b9f..236845871735 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -51,6 +51,7 @@ broken. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -113,7 +114,7 @@ static const struct me4000_board me4000_boards[] = { {0}, }; -#define ME4000_BOARD_VERSIONS (sizeof(me4000_boards) / sizeof(struct me4000_board) - 1) +#define ME4000_BOARD_VERSIONS (ARRAY_SIZE(me4000_boards) - 1) /*----------------------------------------------------------------------------- Comedi function prototypes @@ -183,7 +184,7 @@ static int ai_prepare(struct comedi_device *dev, static int ai_write_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); -static irqreturn_t me4000_ai_isr(int irq, void *dev_id PT_REGS_ARG); +static irqreturn_t me4000_ai_isr(int irq, void *dev_id); static int me4000_ai_do_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); @@ -283,7 +284,7 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_read = me4000_ai_insn_read; if (info->irq > 0) { - if (comedi_request_irq(info->irq, me4000_ai_isr, + if (request_irq(info->irq, me4000_ai_isr, IRQF_SHARED, "ME-4000", dev)) { printk("comedi%d: me4000: me4000_attach(): Unable to allocate irq\n", dev->minor); } else { @@ -1740,7 +1741,7 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, return 0; } -static irqreturn_t me4000_ai_isr(int irq, void *dev_id PT_REGS_ARG) +static irqreturn_t me4000_ai_isr(int irq, void *dev_id) { unsigned int tmp; struct comedi_device *dev = dev_id; diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 0f023d009e61..f21cecaa2e09 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -50,6 +50,7 @@ from http://www.comedi.org */ +#include <linux/interrupt.h> #include "../comedidev.h" #include "comedi_pci.h" diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index ae9017744537..22a4029c30b5 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -258,7 +258,7 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, struct mite_channel *channel = NULL; /* spin lock so mite_release_channel can be called safely from interrupts */ - comedi_spin_lock_irqsave(&mite->lock, flags); + spin_lock_irqsave(&mite->lock, flags); for (i = min_channel; i <= max_channel; ++i) { if (mite->channel_allocated[i] == 0) { mite->channel_allocated[i] = 1; @@ -267,7 +267,7 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, break; } } - comedi_spin_unlock_irqrestore(&mite->lock, flags); + spin_unlock_irqrestore(&mite->lock, flags); return channel; } @@ -277,7 +277,7 @@ void mite_release_channel(struct mite_channel *mite_chan) unsigned long flags; /* spin lock to prevent races with mite_request_channel */ - comedi_spin_lock_irqsave(&mite->lock, flags); + spin_lock_irqsave(&mite->lock, flags); if (mite->channel_allocated[mite_chan->channel]) { mite_dma_disarm(mite_chan); mite_dma_reset(mite_chan); @@ -292,7 +292,7 @@ MITE_CHCR reg isn't changed while dma is still active!) */ mite_chan->ring = NULL; mmiowb(); } - comedi_spin_unlock_irqrestore(&mite->lock, flags); + spin_unlock_irqrestore(&mite->lock, flags); } void mite_dma_arm(struct mite_channel *mite_chan) @@ -307,11 +307,11 @@ void mite_dma_arm(struct mite_channel *mite_chan) smp_mb(); /* arm */ chor = CHOR_START; - comedi_spin_lock_irqsave(&mite->lock, flags); + spin_lock_irqsave(&mite->lock, flags); mite_chan->done = 0; writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); mmiowb(); - comedi_spin_unlock_irqrestore(&mite->lock, flags); + spin_unlock_irqrestore(&mite->lock, flags); /* mite_dma_tcr(mite, channel); */ } @@ -413,7 +413,7 @@ void mite_prep_dma(struct mite_channel *mite_chan, mcr |= CR_PSIZE32; break; default: - rt_printk + printk ("mite: bug! invalid mem bit width for dma transfer\n"); break; } @@ -433,7 +433,7 @@ void mite_prep_dma(struct mite_channel *mite_chan, dcr |= CR_PSIZE32; break; default: - rt_printk + printk ("mite: bug! invalid dev bit width for dma transfer\n"); break; } @@ -539,7 +539,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * as nbytes = mite_bytes_written_to_memory_lb(mite_chan); if ((int)(mite_bytes_written_to_memory_ub(mite_chan) - old_alloc_count) > 0) { - rt_printk("mite: DMA overwrite of free area\n"); + printk("mite: DMA overwrite of free area\n"); async->events |= COMEDI_CB_OVERFLOW; return -1; } @@ -581,7 +581,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * a (int)(nbytes_ub - stop_count) > 0) nbytes_ub = stop_count; if ((int)(nbytes_ub - old_alloc_count) > 0) { - rt_printk("mite: DMA underrun\n"); + printk("mite: DMA underrun\n"); async->events |= COMEDI_CB_OVERFLOW; return -1; } @@ -602,7 +602,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan) unsigned status; unsigned long flags; - comedi_spin_lock_irqsave(&mite->lock, flags); + spin_lock_irqsave(&mite->lock, flags); status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel)); if (status & CHSR_DONE) { mite_chan->done = 1; @@ -610,7 +610,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan) mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } mmiowb(); - comedi_spin_unlock_irqrestore(&mite->lock, flags); + spin_unlock_irqrestore(&mite->lock, flags); return status; } @@ -621,9 +621,9 @@ int mite_done(struct mite_channel *mite_chan) int done; mite_get_status(mite_chan); - comedi_spin_lock_irqsave(&mite->lock, flags); + spin_lock_irqsave(&mite->lock, flags); done = mite_chan->done; - comedi_spin_unlock_irqrestore(&mite->lock, flags); + spin_unlock_irqrestore(&mite->lock, flags); return done; } diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index cdaf8a31688a..31942319aa38 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -405,7 +405,7 @@ static inline int CR_RL(unsigned int retry_limit) value++; } if (value > 0x7) - rt_printk("comedi: bug! retry_limit too large\n"); + printk("comedi: bug! retry_limit too large\n"); return (value & 0x7) << 21; } diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index a151602929d9..4a0e647f631a 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -61,19 +61,19 @@ Configuration Options: #include <linux/ioport.h> #include <linux/delay.h> -// Consecutive I/O port addresses +/* Consecutive I/O port addresses */ #define MPC624_SIZE 16 -// Offsets of different ports -#define MPC624_MASTER_CONTROL 0 // not used -#define MPC624_GNMUXCH 1 // Gain, Mux, Channel of ADC -#define MPC624_ADC 2 // read/write to/from ADC -#define MPC624_EE 3 // read/write to/from serial EEPROM via I2C -#define MPC624_LEDS 4 // write to LEDs -#define MPC624_DIO 5 // read/write to/from digital I/O ports -#define MPC624_IRQ_MASK 6 // IRQ masking enable/disable +/* Offsets of different ports */ +#define MPC624_MASTER_CONTROL 0 /* not used */ +#define MPC624_GNMUXCH 1 /* Gain, Mux, Channel of ADC */ +#define MPC624_ADC 2 /* read/write to/from ADC */ +#define MPC624_EE 3 /* read/write to/from serial EEPROM via I2C */ +#define MPC624_LEDS 4 /* write to LEDs */ +#define MPC624_DIO 5 /* read/write to/from digital I/O ports */ +#define MPC624_IRQ_MASK 6 /* IRQ masking enable/disable */ -// Register bits' names +/* Register bits' names */ #define MPC624_ADBUSY (1<<5) #define MPC624_ADSDO (1<<4) #define MPC624_ADFO (1<<3) @@ -81,19 +81,19 @@ Configuration Options: #define MPC624_ADSCK (1<<1) #define MPC624_ADSDI (1<<0) -// SDI Speed/Resolution Programming bits +/* SDI Speed/Resolution Programming bits */ #define MPC624_OSR4 (1<<31) #define MPC624_OSR3 (1<<30) #define MPC624_OSR2 (1<<29) #define MPC624_OSR1 (1<<28) #define MPC624_OSR0 (1<<27) -// 32-bit output value bits' names +/* 32-bit output value bits' names */ #define MPC624_EOC_BIT (1<<31) #define MPC624_DMY_BIT (1<<30) #define MPC624_SGN_BIT (1<<29) -// Convertion speeds +/* Convertion speeds */ /* OSR4 OSR3 OSR2 OSR1 OSR0 Convertion rate RMS noise ENOB^ * X 0 0 0 1 3.52kHz 23uV 17 * X 0 0 1 0 1.76kHz 3.5uV 20 @@ -110,123 +110,123 @@ Configuration Options: */ #define MPC624_SPEED_3_52_kHz (MPC624_OSR4 | MPC624_OSR0) -#define MPC624_SPEED_1_76_kHz (MPC624_OSR4 | MPC624_OSR1 ) +#define MPC624_SPEED_1_76_kHz (MPC624_OSR4 | MPC624_OSR1) #define MPC624_SPEED_880_Hz (MPC624_OSR4 | MPC624_OSR1 | MPC624_OSR0) -#define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2 ) +#define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2) #define MPC624_SPEED_220_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR0) -#define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 ) +#define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1) #define MPC624_SPEED_55_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0) -#define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3 ) +#define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3) #define MPC624_SPEED_13_75_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR0) #define MPC624_SPEED_6_875_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0) -//---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- */ struct skel_private { - unsigned long int ulConvertionRate; // set by mpc624_attach() from driver's parameters + unsigned long int ulConvertionRate; /* set by mpc624_attach() from driver's parameters */ }; #define devpriv ((struct skel_private *)dev->private) -//---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- */ static const struct comedi_lrange range_mpc624_bipolar1 = { 1, { -// BIP_RANGE(1.01) // this is correct, - // but my MPC-624 actually seems to have a range of 2.02 +/* BIP_RANGE(1.01) this is correct, */ + /* but my MPC-624 actually seems to have a range of 2.02 */ BIP_RANGE(2.02) } }; static const struct comedi_lrange range_mpc624_bipolar10 = { 1, { -// BIP_RANGE(10.1) // this is correct, - // but my MPC-624 actually seems to have a range of 20.2 +/* BIP_RANGE(10.1) this is correct, */ + /* but my MPC-624 actually seems to have a range of 20.2 */ BIP_RANGE(20.2) } }; -//---------------------------------------------------------------------------- -static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int mpc624_detach(struct comedi_device * dev); -//---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- */ +static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int mpc624_detach(struct comedi_device *dev); +/* ---------------------------------------------------------------------------- */ static struct comedi_driver driver_mpc624 = { - driver_name:"mpc624", - module:THIS_MODULE, - attach:mpc624_attach, - detach:mpc624_detach + .driver_name = "mpc624", + .module = THIS_MODULE, + .attach = mpc624_attach, + .detach = mpc624_detach }; -//---------------------------------------------------------------------------- -static int mpc624_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -//---------------------------------------------------------------------------- -static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * it) +/* ---------------------------------------------------------------------------- */ +static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +/* ---------------------------------------------------------------------------- */ +static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; iobase = it->options[0]; - rt_printk("comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase); + printk("comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase); if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) { - rt_printk("I/O port(s) in use\n"); + printk("I/O port(s) in use\n"); return -EIO; } dev->iobase = iobase; dev->board_name = "mpc624"; - // Private structure initialization + /* Private structure initialization */ if (alloc_private(dev, sizeof(struct skel_private)) < 0) return -ENOMEM; switch (it->options[1]) { case 0: devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz; - rt_printk("3.52 kHz, "); + printk("3.52 kHz, "); break; case 1: devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz; - rt_printk("1.76 kHz, "); + printk("1.76 kHz, "); break; case 2: devpriv->ulConvertionRate = MPC624_SPEED_880_Hz; - rt_printk("880 Hz, "); + printk("880 Hz, "); break; case 3: devpriv->ulConvertionRate = MPC624_SPEED_440_Hz; - rt_printk("440 Hz, "); + printk("440 Hz, "); break; case 4: devpriv->ulConvertionRate = MPC624_SPEED_220_Hz; - rt_printk("220 Hz, "); + printk("220 Hz, "); break; case 5: devpriv->ulConvertionRate = MPC624_SPEED_110_Hz; - rt_printk("110 Hz, "); + printk("110 Hz, "); break; case 6: devpriv->ulConvertionRate = MPC624_SPEED_55_Hz; - rt_printk("55 Hz, "); + printk("55 Hz, "); break; case 7: devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz; - rt_printk("27.5 Hz, "); + printk("27.5 Hz, "); break; case 8: devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz; - rt_printk("13.75 Hz, "); + printk("13.75 Hz, "); break; case 9: devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz; - rt_printk("6.875 Hz, "); + printk("6.875 Hz, "); break; default: - rt_printk + printk ("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, "); devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz; } - // Subdevices structures + /* Subdevices structures */ if (alloc_subdevices(dev, 1) < 0) return -ENOMEM; @@ -237,29 +237,29 @@ static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * i switch (it->options[1]) { default: s->maxdata = 0x3FFFFFFF; - rt_printk("30 bit, "); + printk("30 bit, "); } switch (it->options[1]) { case 0: s->range_table = &range_mpc624_bipolar1; - rt_printk("1.01V]: "); + printk("1.01V]: "); break; default: s->range_table = &range_mpc624_bipolar10; - rt_printk("10.1V]: "); + printk("10.1V]: "); } s->len_chanlist = 1; s->insn_read = mpc624_ai_rinsn; - rt_printk("attached\n"); + printk("attached\n"); return 1; } -static int mpc624_detach(struct comedi_device * dev) +static int mpc624_detach(struct comedi_device *dev) { - rt_printk("comedi%d: mpc624: remove\n", dev->minor); + printk("comedi%d: mpc624: remove\n", dev->minor); if (dev->iobase) release_region(dev->iobase, MPC624_SIZE); @@ -267,119 +267,119 @@ static int mpc624_detach(struct comedi_device * dev) return 0; } -// Timeout 200ms +/* Timeout 200ms */ #define TIMEOUT 200 -static int mpc624_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; unsigned long int data_in, data_out; unsigned char ucPort; - // WARNING: We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc + /* WARNING: We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc */ outb(insn->chanspec, dev->iobase + MPC624_GNMUXCH); -// rt_printk("Channel %d: \n", insn->chanspec); +/* printk("Channel %d: \n", insn->chanspec); */ if (!insn->n) { - rt_printk("MPC624: Warning, no data to aquire\n"); + printk("MPC624: Warning, no data to aquire\n"); return 0; } for (n = 0; n < insn->n; n++) { - // Trigger the convertion + /* Trigger the convertion */ outb(MPC624_ADSCK, dev->iobase + MPC624_ADC); - comedi_udelay(1); + udelay(1); outb(MPC624_ADCS | MPC624_ADSCK, dev->iobase + MPC624_ADC); - comedi_udelay(1); + udelay(1); outb(0, dev->iobase + MPC624_ADC); - comedi_udelay(1); + udelay(1); - // Wait for the convertion to end + /* Wait for the convertion to end */ for (i = 0; i < TIMEOUT; i++) { ucPort = inb(dev->iobase + MPC624_ADC); if (ucPort & MPC624_ADBUSY) - comedi_udelay(1000); + udelay(1000); else break; } if (i == TIMEOUT) { - rt_printk("MPC624: timeout (%dms)\n", TIMEOUT); + printk("MPC624: timeout (%dms)\n", TIMEOUT); data[n] = 0; return -ETIMEDOUT; } - // Start reading data + /* Start reading data */ data_in = 0; data_out = devpriv->ulConvertionRate; - comedi_udelay(1); + udelay(1); for (i = 0; i < 32; i++) { - // Set the clock low + /* Set the clock low */ outb(0, dev->iobase + MPC624_ADC); - comedi_udelay(1); + udelay(1); - if (data_out & (1 << 31)) // the next bit is a 1 + if (data_out & (1 << 31)) /* the next bit is a 1 */ { - // Set the ADSDI line (send to MPC624) + /* Set the ADSDI line (send to MPC624) */ outb(MPC624_ADSDI, dev->iobase + MPC624_ADC); - comedi_udelay(1); - // Set the clock high + udelay(1); + /* Set the clock high */ outb(MPC624_ADSCK | MPC624_ADSDI, dev->iobase + MPC624_ADC); - } else // the next bit is a 0 + } else /* the next bit is a 0 */ { - // Set the ADSDI line (send to MPC624) + /* Set the ADSDI line (send to MPC624) */ outb(0, dev->iobase + MPC624_ADC); - comedi_udelay(1); - // Set the clock high + udelay(1); + /* Set the clock high */ outb(MPC624_ADSCK, dev->iobase + MPC624_ADC); } - // Read ADSDO on high clock (receive from MPC624) - comedi_udelay(1); + /* Read ADSDO on high clock (receive from MPC624) */ + udelay(1); data_in <<= 1; data_in |= (inb(dev->iobase + MPC624_ADC) & MPC624_ADSDO) >> 4; - comedi_udelay(1); + udelay(1); data_out <<= 1; } - // Received 32-bit long value consist of: - // 31: EOC (End Of Transmission) bit - should be 0 - // 30: DMY (Dummy) bit - should be 0 - // 29: SIG (Sign) bit - 1 if the voltage is positive, 0 if negative - // 28: MSB (Most Significant Bit) - the first bit of convertion result - // .... - // 05: LSB (Least Significant Bit) - the last bit of convertion result - // 04: sub-LSB - sub-LSBs are basically noise, but when - // 03: sub-LSB averaged properly, they can increase convertion - // 02: sub-LSB precision up to 29 bits; they can be discarded - // 01: sub-LSB without loss of resolution. - // 00: sub-LSB + /* Received 32-bit long value consist of: */ + /* 31: EOC (End Of Transmission) bit - should be 0 */ + /* 30: DMY (Dummy) bit - should be 0 */ + /* 29: SIG (Sign) bit - 1 if the voltage is positive, 0 if negative */ + /* 28: MSB (Most Significant Bit) - the first bit of convertion result */ + /* .... */ + /* 05: LSB (Least Significant Bit) - the last bit of convertion result */ + /* 04: sub-LSB - sub-LSBs are basically noise, but when */ + /* 03: sub-LSB averaged properly, they can increase convertion */ + /* 02: sub-LSB precision up to 29 bits; they can be discarded */ + /* 01: sub-LSB without loss of resolution. */ + /* 00: sub-LSB */ if (data_in & MPC624_EOC_BIT) - rt_printk("MPC624: EOC bit is set (data_in=%lu)!", + printk("MPC624: EOC bit is set (data_in=%lu)!", data_in); if (data_in & MPC624_DMY_BIT) - rt_printk("MPC624: DMY bit is set (data_in=%lu)!", + printk("MPC624: DMY bit is set (data_in=%lu)!", data_in); - if (data_in & MPC624_SGN_BIT) // check the sign bit - { // The voltage is positive - data_in &= 0x3FFFFFFF; // EOC and DMY should be 0, but we will mask them out just to be sure - data[n] = data_in; // comedi operates on unsigned numbers, so we don't clear the SGN bit - // SGN bit is still set! It's correct, since we're converting to unsigned. - } else { // The voltage is negative - // data_in contains a number in 30-bit two's complement code and we must deal with it + if (data_in & MPC624_SGN_BIT) /* check the sign bit */ + { /* The voltage is positive */ + data_in &= 0x3FFFFFFF; /* EOC and DMY should be 0, but we will mask them out just to be sure */ + data[n] = data_in; /* comedi operates on unsigned numbers, so we don't clear the SGN bit */ + /* SGN bit is still set! It's correct, since we're converting to unsigned. */ + } else { /* The voltage is negative */ + /* data_in contains a number in 30-bit two's complement code and we must deal with it */ data_in |= MPC624_SGN_BIT; data_in = ~data_in; data_in += 1; data_in &= ~(MPC624_EOC_BIT | MPC624_DMY_BIT); - // clear EOC and DMY bits + /* clear EOC and DMY bits */ data_in = 0x20000000 - data_in; data[n] = data_in; } } - // Return the number of samples read/written + /* Return the number of samples read/written */ return n; } diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c index bac0a7bb9cbd..c7ee3ef10130 100644 --- a/drivers/staging/comedi/drivers/mpc8260cpm.c +++ b/drivers/staging/comedi/drivers/mpc8260cpm.c @@ -46,23 +46,23 @@ struct mpc8260cpm_private { #define devpriv ((struct mpc8260cpm_private *)dev->private) -static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int mpc8260cpm_detach(struct comedi_device * dev); +static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int mpc8260cpm_detach(struct comedi_device *dev); static struct comedi_driver driver_mpc8260cpm = { - driver_name:"mpc8260cpm", - module:THIS_MODULE, - attach:mpc8260cpm_attach, - detach:mpc8260cpm_detach, + .driver_name = "mpc8260cpm", + .module = THIS_MODULE, + .attach = mpc8260cpm_attach, + .detach = mpc8260cpm_detach, }; COMEDI_INITCLEANUP(driver_mpc8260cpm); -static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int mpc8260cpm_dio_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int i; @@ -93,7 +93,7 @@ static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig return 1; } -static int mpc8260cpm_detach(struct comedi_device * dev) +static int mpc8260cpm_detach(struct comedi_device *dev) { printk("comedi%d: mpc8260cpm: remove\n", dev->minor); @@ -114,8 +114,8 @@ static unsigned long *cpm_pdat(int port) } } -static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; unsigned int d; @@ -157,8 +157,8 @@ static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subde return 1; } -static int mpc8260cpm_dio_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int port; unsigned long *p; diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 9e47574171de..f7cce6cc7766 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -29,6 +29,7 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3) */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -82,13 +83,13 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3) #define MULTIQ3_TIMEOUT 30 -static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int multiq3_detach(struct comedi_device * dev); +static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int multiq3_detach(struct comedi_device *dev); static struct comedi_driver driver_multiq3 = { - driver_name:"multiq3", - module:THIS_MODULE, - attach:multiq3_attach, - detach:multiq3_detach, + .driver_name = "multiq3", + .module = THIS_MODULE, + .attach = multiq3_attach, + .detach = multiq3_detach, }; COMEDI_INITCLEANUP(driver_multiq3); @@ -98,8 +99,8 @@ struct multiq3_private { }; #define devpriv ((struct multiq3_private *)dev->private) -static int multiq3_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int chan; @@ -134,8 +135,8 @@ static int multiq3_ai_insn_read(struct comedi_device * dev, struct comedi_subdev return n; } -static int multiq3_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -147,8 +148,8 @@ static int multiq3_ao_insn_read(struct comedi_device * dev, struct comedi_subdev return i; } -static int multiq3_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -165,8 +166,8 @@ static int multiq3_ao_insn_write(struct comedi_device * dev, struct comedi_subde return i; } -static int multiq3_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -176,8 +177,8 @@ static int multiq3_di_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int multiq3_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -191,8 +192,8 @@ static int multiq3_do_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int multiq3_encoder_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int multiq3_encoder_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -212,7 +213,7 @@ static int multiq3_encoder_insn_read(struct comedi_device * dev, struct comedi_s return n; } -static void encoder_reset(struct comedi_device * dev) +static void encoder_reset(struct comedi_device *dev) { int chan; for (chan = 0; chan < dev->subdevices[4].n_chan; chan++) { @@ -235,7 +236,7 @@ static void encoder_reset(struct comedi_device * dev) options[2] - number of encoder chips installed */ -static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int result = 0; unsigned long iobase; @@ -318,7 +319,7 @@ static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int multiq3_detach(struct comedi_device * dev) +static int multiq3_detach(struct comedi_device *dev) { printk("comedi%d: multiq3: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index e01ecb6760f9..67adc97265bd 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -41,6 +41,7 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800 #define DEBUG 1 #define DEBUG_FLAGS +#include <linux/interrupt.h> #include "../comedidev.h" #include "mite.h" @@ -75,13 +76,13 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800 #define Rising_Edge_Detection_Enable(x) (0x018+(x)) #define Falling_Edge_Detection_Enable(x) (0x020+(x)) -static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int ni6527_detach(struct comedi_device * dev); +static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int ni6527_detach(struct comedi_device *dev); static struct comedi_driver driver_ni6527 = { - driver_name:"ni6527", - module:THIS_MODULE, - attach:ni6527_attach, - detach:ni6527_detach, + .driver_name = "ni6527", + .module = THIS_MODULE, + .attach = ni6527_attach, + .detach = ni6527_detach, }; struct ni6527_board { @@ -92,12 +93,12 @@ struct ni6527_board { static const struct ni6527_board ni6527_boards[] = { { - dev_id: 0x2b20, - name: "pci-6527", + .dev_id = 0x2b20, + .name = "pci-6527", }, { - dev_id: 0x2b10, - name: "pxi-6527", + .dev_id = 0x2b10, + .name = "pxi-6527", }, }; @@ -120,10 +121,10 @@ struct ni6527_private { #define devpriv ((struct ni6527_private *)dev->private) -static int ni6527_find_device(struct comedi_device * dev, int bus, int slot); +static int ni6527_find_device(struct comedi_device *dev, int bus, int slot); -static int ni6527_di_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); unsigned int interval; @@ -170,8 +171,8 @@ static int ni6527_di_insn_config(struct comedi_device * dev, struct comedi_subde return 2; } -static int ni6527_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni6527_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -183,8 +184,8 @@ static int ni6527_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int ni6527_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni6527_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -212,7 +213,7 @@ static int ni6527_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static irqreturn_t ni6527_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t ni6527_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 2; @@ -233,8 +234,8 @@ static irqreturn_t ni6527_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static int ni6527_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni6527_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -309,9 +310,9 @@ static int ni6527_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int ni6527_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni6527_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - //struct comedi_cmd *cmd = &s->async->cmd; + /* struct comedi_cmd *cmd = &s->async->cmd; */ writeb(ClrEdge | ClrOverflow, devpriv->mite->daq_io_addr + Clear_Register); @@ -322,15 +323,15 @@ static int ni6527_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int ni6527_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni6527_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control); return 0; } -static int ni6527_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni6527_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -339,8 +340,8 @@ static int ni6527_intr_insn_bits(struct comedi_device * dev, struct comedi_subde return 2; } -static int ni6527_intr_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni6527_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -364,14 +365,15 @@ static int ni6527_intr_insn_config(struct comedi_device * dev, struct comedi_sub return 2; } -static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret; printk("comedi%d: ni6527:", dev->minor); - if ((ret = alloc_private(dev, sizeof(struct ni6527_private))) < 0) + ret = alloc_private(dev, sizeof(struct ni6527_private)); + if (ret < 0) return ret; ret = ni6527_find_device(dev, it->options[0], it->options[1]); @@ -389,7 +391,8 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i printk(" ID=0x%02x", readb(devpriv->mite->daq_io_addr + ID_Register)); - if ((ret = alloc_subdevices(dev, 3)) < 0) + ret = alloc_subdevices(dev, 3); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -430,8 +433,8 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->mite->daq_io_addr + Clear_Register); writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control); - ret = comedi_request_irq(mite_irq(devpriv->mite), ni6527_interrupt, - IRQF_SHARED, "ni6527", dev); + ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt, + IRQF_SHARED, "ni6527", dev); if (ret < 0) { printk(" irq not available"); } else @@ -442,7 +445,7 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int ni6527_detach(struct comedi_device * dev) +static int ni6527_detach(struct comedi_device *dev) { if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) { writeb(0x00, @@ -450,7 +453,7 @@ static int ni6527_detach(struct comedi_device * dev) } if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (devpriv && devpriv->mite) { @@ -460,7 +463,7 @@ static int ni6527_detach(struct comedi_device * dev) return 0; } -static int ni6527_find_device(struct comedi_device * dev, int bus, int slot) +static int ni6527_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; int i; diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 6e85da16a241..35708503dec3 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -50,6 +50,7 @@ except maybe the 6514. #define _GNU_SOURCE #define DEBUG 1 #define DEBUG_FLAGS +#include <linux/interrupt.h> #include "../comedidev.h" #include "mite.h" @@ -102,13 +103,13 @@ static inline unsigned Filter_Enable(unsigned port) #define OverflowIntEnable 0x02 #define EdgeIntEnable 0x01 -static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int ni_65xx_detach(struct comedi_device * dev); +static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int ni_65xx_detach(struct comedi_device *dev); static struct comedi_driver driver_ni_65xx = { - driver_name:"ni_65xx", - module:THIS_MODULE, - attach:ni_65xx_attach, - detach:ni_65xx_detach, + .driver_name = "ni_65xx", + .module = THIS_MODULE, + .attach = ni_65xx_attach, + .detach = ni_65xx_detach, }; struct ni_65xx_board { @@ -123,120 +124,120 @@ struct ni_65xx_board { static const struct ni_65xx_board ni_65xx_boards[] = { { - dev_id: 0x7085, - name: "pci-6509", - num_dio_ports:12, - invert_outputs:0}, + .dev_id = 0x7085, + .name = "pci-6509", + .num_dio_ports = 12, + .invert_outputs = 0}, { - dev_id: 0x1710, - name: "pxi-6509", - num_dio_ports:12, - invert_outputs:0}, + .dev_id = 0x1710, + .name = "pxi-6509", + .num_dio_ports = 12, + .invert_outputs = 0}, { - dev_id: 0x7124, - name: "pci-6510", - num_di_ports:4}, + .dev_id = 0x7124, + .name = "pci-6510", + .num_di_ports = 4}, { - dev_id: 0x70c3, - name: "pci-6511", - num_di_ports:8}, + .dev_id = 0x70c3, + .name = "pci-6511", + .num_di_ports = 8}, { - dev_id: 0x70d3, - name: "pxi-6511", - num_di_ports:8}, + .dev_id = 0x70d3, + .name = "pxi-6511", + .num_di_ports = 8}, { - dev_id: 0x70cc, - name: "pci-6512", - num_do_ports:8}, + .dev_id = 0x70cc, + .name = "pci-6512", + .num_do_ports = 8}, { - dev_id: 0x70d2, - name: "pxi-6512", - num_do_ports:8}, + .dev_id = 0x70d2, + .name = "pxi-6512", + .num_do_ports = 8}, { - dev_id: 0x70c8, - name: "pci-6513", - num_do_ports:8, - invert_outputs:1}, + .dev_id = 0x70c8, + .name = "pci-6513", + .num_do_ports = 8, + .invert_outputs = 1}, { - dev_id: 0x70d1, - name: "pxi-6513", - num_do_ports:8, - invert_outputs:1}, + .dev_id = 0x70d1, + .name = "pxi-6513", + .num_do_ports = 8, + .invert_outputs = 1}, { - dev_id: 0x7088, - name: "pci-6514", - num_di_ports:4, - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x7088, + .name = "pci-6514", + .num_di_ports = 4, + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x70CD, - name: "pxi-6514", - num_di_ports:4, - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x70CD, + .name = "pxi-6514", + .num_di_ports = 4, + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x7087, - name: "pci-6515", - num_di_ports:4, - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x7087, + .name = "pci-6515", + .num_di_ports = 4, + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x70c9, - name: "pxi-6515", - num_di_ports:4, - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x70c9, + .name = "pxi-6515", + .num_di_ports = 4, + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x7125, - name: "pci-6516", - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x7125, + .name = "pci-6516", + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x7126, - name: "pci-6517", - num_do_ports:4, - invert_outputs:1}, + .dev_id = 0x7126, + .name = "pci-6517", + .num_do_ports = 4, + .invert_outputs = 1}, { - dev_id: 0x7127, - name: "pci-6518", - num_di_ports:2, - num_do_ports:2, - invert_outputs:1}, + .dev_id = 0x7127, + .name = "pci-6518", + .num_di_ports = 2, + .num_do_ports = 2, + .invert_outputs = 1}, { - dev_id: 0x7128, - name: "pci-6519", - num_di_ports:2, - num_do_ports:2, - invert_outputs:1}, + .dev_id = 0x7128, + .name = "pci-6519", + .num_di_ports = 2, + .num_do_ports = 2, + .invert_outputs = 1}, { - dev_id: 0x71c5, - name: "pci-6520", - num_di_ports:1, - num_do_ports:1, + .dev_id = 0x71c5, + .name = "pci-6520", + .num_di_ports = 1, + .num_do_ports = 1, }, { - dev_id: 0x718b, - name: "pci-6521", - num_di_ports:1, - num_do_ports:1, + .dev_id = 0x718b, + .name = "pci-6521", + .num_di_ports = 1, + .num_do_ports = 1, }, { - dev_id: 0x718c, - name: "pxi-6521", - num_di_ports:1, - num_do_ports:1, + .dev_id = 0x718c, + .name = "pxi-6521", + .num_di_ports = 1, + .num_do_ports = 1, }, { - dev_id: 0x70a9, - name: "pci-6528", - num_di_ports:3, - num_do_ports:3, + .dev_id = 0x70a9, + .name = "pci-6528", + .num_di_ports = 3, + .num_do_ports = 3, }, { - dev_id: 0x7086, - name: "pxi-6528", - num_di_ports:3, - num_do_ports:3, + .dev_id = 0x7086, + .name = "pxi-6528", + .num_di_ports = 3, + .num_do_ports = 3, }, }; @@ -249,7 +250,7 @@ static inline unsigned ni_65xx_port_by_channel(unsigned channel) { return channel / ni_65xx_channels_per_port; } -static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board * board) +static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board *board) { return board->num_dio_ports + board->num_di_ports + board->num_do_ports; } @@ -312,10 +313,10 @@ static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void) return subdev_private; } -static int ni_65xx_find_device(struct comedi_device * dev, int bus, int slot); +static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot); -static int ni_65xx_config_filter(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_65xx_config_filter(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const unsigned chan = CR_CHAN(insn->chanspec); const unsigned port = @@ -353,8 +354,8 @@ static int ni_65xx_config_filter(struct comedi_device * dev, struct comedi_subde return 2; } -static int ni_65xx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_65xx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned port; @@ -392,8 +393,8 @@ static int ni_65xx_dio_insn_config(struct comedi_device * dev, struct comedi_sub return -EINVAL; } -static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned base_bitfield_channel; const unsigned max_ports_per_bitfield = 5; @@ -437,12 +438,12 @@ static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subde writeb(bits, private(dev)->mite->daq_io_addr + Port_Data(port)); -// rt_printk("wrote 0x%x to port %i\n", bits, port); +/* printk("wrote 0x%x to port %i\n", bits, port); */ } port_read_bits = readb(private(dev)->mite->daq_io_addr + Port_Data(port)); -// rt_printk("read 0x%x from port %i\n", port_read_bits, port); +/* printk("read 0x%x from port %i\n", port_read_bits, port); */ if (bitshift > 0) { port_read_bits <<= bitshift; } else { @@ -454,7 +455,7 @@ static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subde return insn->n; } -static irqreturn_t ni_65xx_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t ni_65xx_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 2; @@ -475,8 +476,8 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static int ni_65xx_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_65xx_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -551,9 +552,9 @@ static int ni_65xx_intr_cmdtest(struct comedi_device * dev, struct comedi_subdev return 0; } -static int ni_65xx_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_65xx_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - //struct comedi_cmd *cmd = &s->async->cmd; + /* struct comedi_cmd *cmd = &s->async->cmd; */ writeb(ClrEdge | ClrOverflow, private(dev)->mite->daq_io_addr + Clear_Register); @@ -564,7 +565,7 @@ static int ni_65xx_intr_cmd(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int ni_65xx_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_65xx_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { writeb(0x00, private(dev)->mite->daq_io_addr + Master_Interrupt_Control); @@ -572,8 +573,8 @@ static int ni_65xx_intr_cancel(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int ni_65xx_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_65xx_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -582,8 +583,8 @@ static int ni_65xx_intr_insn_bits(struct comedi_device * dev, struct comedi_subd return 2; } -static int ni_65xx_intr_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_65xx_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -619,7 +620,7 @@ static int ni_65xx_intr_insn_config(struct comedi_device * dev, struct comedi_su return 2; } -static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned i; @@ -627,7 +628,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * printk("comedi%d: ni_65xx:", dev->minor); - if ((ret = alloc_private(dev, sizeof(struct ni_65xx_private))) < 0) + ret = alloc_private(dev, sizeof(struct ni_65xx_private)); + if (ret < 0) return ret; ret = ni_65xx_find_device(dev, it->options[0], it->options[1]); @@ -647,7 +649,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * printk(" ID=0x%02x", readb(private(dev)->mite->daq_io_addr + ID_Register)); - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -700,7 +703,7 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * return -ENOMEM; sprivate(s)->base_port = 0; for (i = 0; i < board(dev)->num_dio_ports; ++i) { - // configure all ports for input + /* configure all ports for input */ writeb(0x1, private(dev)->mite->daq_io_addr + Port_Select(i)); @@ -740,8 +743,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * /* Set filter interval to 0 (32bit reg) */ writeb(0x00000000, private(dev)->mite->daq_io_addr + Filter_Interval); - ret = comedi_request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED, - "ni_65xx", dev); + ret = request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED, + "ni_65xx", dev); if (ret < 0) { dev->irq = 0; printk(" irq not available"); @@ -752,7 +755,7 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int ni_65xx_detach(struct comedi_device * dev) +static int ni_65xx_detach(struct comedi_device *dev) { if (private(dev) && private(dev)->mite && private(dev)->mite->daq_io_addr) { @@ -762,7 +765,7 @@ static int ni_65xx_detach(struct comedi_device * dev) } if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (private(dev)) { @@ -780,7 +783,7 @@ static int ni_65xx_detach(struct comedi_device * dev) return 0; } -static int ni_65xx_find_device(struct comedi_device * dev, int bus, int slot) +static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; int i; diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 14e35ba721e9..11e9b0411805 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -40,6 +40,7 @@ DAQ 6601/6602 User Manual (NI 322137B-01) */ +#include <linux/interrupt.h> #include "../comedidev.h" #include "mite.h" #include "ni_tio.h" @@ -51,7 +52,7 @@ enum ni_660x_constants { }; #define NUM_PFI_CHANNELS 40 -// really there are only up to 3 dma channels, but the register layout allows for 4 +/* really there are only up to 3 dma channels, but the register layout allows for 4 */ #define MAX_DMA_CHANNEL 4 /* See Register-Level Programmer Manual page 3.1 */ @@ -194,10 +195,10 @@ static inline unsigned NI_660X_GPCT_SUBDEV(unsigned index) struct NI_660xRegisterData { - const char *name; // Register Name - int offset; // Offset from base address from GPCT chip + const char *name; /* Register Name */ + int offset; /* Offset from base address from GPCT chip */ enum ni_660x_register_direction direction; - enum ni_660x_register_width size; // 1 byte, 2 bytes, or 4 bytes + enum ni_660x_register_width size; /* 1 byte, 2 bytes, or 4 bytes */ }; @@ -302,12 +303,12 @@ static const struct NI_660xRegisterData registerData[NumRegisters] = { {"IO Config Register 38-39", 0x7A2, NI_660x_READ_WRITE, DATA_2B} }; -// kind of ENABLE for the second counter +/* kind of ENABLE for the second counter */ enum clock_config_register_bits { CounterSwap = 0x1 << 21 }; -// ioconfigreg +/* ioconfigreg */ static inline unsigned ioconfig_bitshift(unsigned pfi_channel) { if (pfi_channel % 2) @@ -334,7 +335,7 @@ static inline unsigned pfi_input_select_bits(unsigned pfi_channel, return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel)); } -// dma configuration register bits +/* dma configuration register bits */ static inline unsigned dma_select_mask(unsigned dma_channel) { BUG_ON(dma_channel >= MAX_DMA_CHANNEL); @@ -374,7 +375,7 @@ enum global_interrupt_config_register_bits { Global_Int_Enable_Bit = 0x80000000 }; -// Offset of the GPCT chips from the base-adress of the card +/* Offset of the GPCT chips from the base-adress of the card */ static const unsigned GPCT_OFFSET[2] = { 0x0, 0x800 }; /* First chip is at base-address + 0x00, etc. */ @@ -387,24 +388,24 @@ struct ni_660x_board { static const struct ni_660x_board ni_660x_boards[] = { { - dev_id: 0x2c60, - name: "PCI-6601", - n_chips: 1, + .dev_id = 0x2c60, + .name = "PCI-6601", + .n_chips = 1, }, { - dev_id: 0x1310, - name: "PCI-6602", - n_chips: 2, + .dev_id = 0x1310, + .name = "PCI-6602", + .n_chips = 2, }, { - dev_id: 0x1360, - name: "PXI-6602", - n_chips: 2, + .dev_id = 0x1360, + .name = "PXI-6602", + .n_chips = 2, }, { - dev_id: 0x2cc0, - name: "PXI-6608", - n_chips: 2, + .dev_id = 0x2cc0, + .name = "PXI-6608", + .n_chips = 2, }, }; @@ -428,6 +429,8 @@ struct ni_660x_private { struct mite_dma_descriptor_ring *mite_rings[NI_660X_MAX_NUM_CHIPS][counters_per_chip]; spinlock_t mite_channel_lock; + /* interrupt_lock prevents races between interrupt and comedi_poll */ + spinlock_t interrupt_lock; unsigned dma_configuration_soft_copies[NI_660X_MAX_NUM_CHIPS]; spinlock_t soft_reg_copy_lock; unsigned short pfi_output_selects[NUM_PFI_CHANNELS]; @@ -446,40 +449,40 @@ static inline const struct ni_660x_board *board(struct comedi_device * dev) #define n_ni_660x_boards (sizeof(ni_660x_boards)/sizeof(ni_660x_boards[0])) -static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int ni_660x_detach(struct comedi_device * dev); -static void init_tio_chip(struct comedi_device * dev, int chipset); -static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_channel, +static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int ni_660x_detach(struct comedi_device *dev); +static void init_tio_chip(struct comedi_device *dev, int chipset); +static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel, unsigned output_select); static struct comedi_driver driver_ni_660x = { - driver_name:"ni_660x", - module:THIS_MODULE, - attach:ni_660x_attach, - detach:ni_660x_detach, + .driver_name = "ni_660x", + .module = THIS_MODULE, + .attach = ni_660x_attach, + .detach = ni_660x_detach, }; COMEDI_PCI_INITCLEANUP(driver_ni_660x, ni_660x_pci_table); -static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot); -static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan, +static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot); +static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source); /* Possible instructions for a GPCT */ -static int ni_660x_GPCT_rinsn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); -static int ni_660x_GPCT_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); -static int ni_660x_GPCT_winsn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int ni_660x_GPCT_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int ni_660x_GPCT_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int ni_660x_GPCT_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* Possible instructions for Digital IO */ -static int ni_660x_dio_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); -static int ni_660x_dio_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int ni_660x_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int ni_660x_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static inline unsigned ni_660x_num_counters(struct comedi_device * dev) +static inline unsigned ni_660x_num_counters(struct comedi_device *dev) { return board(dev)->n_chips * counters_per_chip; } @@ -693,8 +696,8 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg) ni_660x_register = G3InterruptEnable; break; default: - rt_printk("%s: unhandled register 0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: unhandled register 0x%x in switch.\n", + __func__, reg); BUG(); return 0; break; @@ -702,7 +705,7 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg) return ni_660x_register; } -static inline void ni_660x_write_register(struct comedi_device * dev, +static inline void ni_660x_write_register(struct comedi_device *dev, unsigned chip_index, unsigned bits, enum NI_660x_Register reg) { void *const write_address = @@ -717,14 +720,14 @@ static inline void ni_660x_write_register(struct comedi_device * dev, writel(bits, write_address); break; default: - rt_printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", - __FILE__, __FUNCTION__, reg); + printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", + __FILE__, __func__, reg); BUG(); break; } } -static inline unsigned ni_660x_read_register(struct comedi_device * dev, +static inline unsigned ni_660x_read_register(struct comedi_device *dev, unsigned chip_index, enum NI_660x_Register reg) { void *const read_address = @@ -739,8 +742,8 @@ static inline unsigned ni_660x_read_register(struct comedi_device * dev, return readl(read_address); break; default: - rt_printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", - __FILE__, __FUNCTION__, reg); + printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", + __FILE__, __func__, reg); BUG(); break; } @@ -771,11 +774,11 @@ static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private return priv->mite_rings[counter->chip_index][counter->counter_index]; } -static inline void ni_660x_set_dma_channel(struct comedi_device * dev, +static inline void ni_660x_set_dma_channel(struct comedi_device *dev, unsigned mite_channel, struct ni_gpct *counter) { unsigned long flags; - comedi_spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); + spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); private(dev)->dma_configuration_soft_copies[counter->chip_index] &= ~dma_select_mask(mite_channel); private(dev)->dma_configuration_soft_copies[counter->chip_index] |= @@ -786,14 +789,14 @@ static inline void ni_660x_set_dma_channel(struct comedi_device * dev, chip_index] | dma_reset_bit(mite_channel), DMAConfigRegister); mmiowb(); - comedi_spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); + spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); } -static inline void ni_660x_unset_dma_channel(struct comedi_device * dev, +static inline void ni_660x_unset_dma_channel(struct comedi_device *dev, unsigned mite_channel, struct ni_gpct *counter) { unsigned long flags; - comedi_spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); + spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); private(dev)->dma_configuration_soft_copies[counter->chip_index] &= ~dma_select_mask(mite_channel); private(dev)->dma_configuration_soft_copies[counter->chip_index] |= @@ -802,22 +805,22 @@ static inline void ni_660x_unset_dma_channel(struct comedi_device * dev, private(dev)->dma_configuration_soft_copies[counter-> chip_index], DMAConfigRegister); mmiowb(); - comedi_spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); + spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); } -static int ni_660x_request_mite_channel(struct comedi_device * dev, +static int ni_660x_request_mite_channel(struct comedi_device *dev, struct ni_gpct *counter, enum comedi_io_direction direction) { unsigned long flags; struct mite_channel *mite_chan; - comedi_spin_lock_irqsave(&private(dev)->mite_channel_lock, flags); + spin_lock_irqsave(&private(dev)->mite_channel_lock, flags); BUG_ON(counter->mite_chan); mite_chan = mite_request_channel(private(dev)->mite, mite_ring(private(dev), counter)); if (mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock, + spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel for counter."); @@ -826,15 +829,15 @@ static int ni_660x_request_mite_channel(struct comedi_device * dev, mite_chan->dir = direction; ni_tio_set_mite_channel(counter, mite_chan); ni_660x_set_dma_channel(dev, mite_chan->channel, counter); - comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); + spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); return 0; } -void ni_660x_release_mite_channel(struct comedi_device * dev, struct ni_gpct *counter) +void ni_660x_release_mite_channel(struct comedi_device *dev, struct ni_gpct *counter) { unsigned long flags; - comedi_spin_lock_irqsave(&private(dev)->mite_channel_lock, flags); + spin_lock_irqsave(&private(dev)->mite_channel_lock, flags); if (counter->mite_chan) { struct mite_channel *mite_chan = counter->mite_chan; @@ -842,15 +845,15 @@ void ni_660x_release_mite_channel(struct comedi_device * dev, struct ni_gpct *co ni_tio_set_mite_channel(counter, NULL); mite_release_channel(mite_chan); } - comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); + spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); } -static int ni_660x_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_660x_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int retval; struct ni_gpct *counter = subdev_to_counter(s); -// const struct comedi_cmd *cmd = &s->async->cmd; +/* const struct comedi_cmd *cmd = &s->async->cmd; */ retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT); if (retval) { @@ -864,15 +867,15 @@ static int ni_660x_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return retval; } -static int ni_660x_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_660x_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { struct ni_gpct *counter = subdev_to_counter(s); return ni_tio_cmdtest(counter, cmd); } -static int ni_660x_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_660x_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct ni_gpct *counter = subdev_to_counter(s); int retval; @@ -882,7 +885,7 @@ static int ni_660x_cancel(struct comedi_device * dev, struct comedi_subdevice * return retval; } -static void set_tio_counterswap(struct comedi_device * dev, int chipset) +static void set_tio_counterswap(struct comedi_device *dev, int chipset) { /* See P. 3.5 of the Register-Level Programming manual. The CounterSwap bit has to be set on the second chip, otherwise @@ -895,8 +898,8 @@ static void set_tio_counterswap(struct comedi_device * dev, int chipset) ni_660x_write_register(dev, chipset, 0, ClockConfigRegister); } -static void ni_660x_handle_gpct_interrupt(struct comedi_device * dev, - struct comedi_subdevice * s) +static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev, + struct comedi_subdevice *s) { ni_tio_handle_interrupt(subdev_to_counter(s), s); if (s->async->events) { @@ -909,23 +912,38 @@ static void ni_660x_handle_gpct_interrupt(struct comedi_device * dev, } } -static irqreturn_t ni_660x_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t ni_660x_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s; unsigned i; + unsigned long flags; if (dev->attached == 0) return IRQ_NONE; + /* lock to avoid race with comedi_poll */ + spin_lock_irqsave(&private(dev)->interrupt_lock, flags); smp_mb(); for (i = 0; i < ni_660x_num_counters(dev); ++i) { s = dev->subdevices + NI_660X_GPCT_SUBDEV(i); ni_660x_handle_gpct_interrupt(dev, s); } + spin_unlock_irqrestore(&private(dev)->interrupt_lock, flags); return IRQ_HANDLED; } -static int ni_660x_buf_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_660x_input_poll(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned long flags; + /* lock to avoid race with comedi_poll */ + spin_lock_irqsave(&private(dev)->interrupt_lock, flags); + mite_sync_input_dma(subdev_to_counter(s)->mite_chan, s->async); + spin_unlock_irqrestore(&private(dev)->interrupt_lock, flags); + return comedi_buf_read_n_available(s->async); +} + +static int ni_660x_buf_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; @@ -938,14 +956,17 @@ static int ni_660x_buf_change(struct comedi_device * dev, struct comedi_subdevic return 0; } -static int ni_660x_allocate_private(struct comedi_device * dev) +static int ni_660x_allocate_private(struct comedi_device *dev) { int retval; unsigned i; - if ((retval = alloc_private(dev, sizeof(struct ni_660x_private))) < 0) + retval = alloc_private(dev, sizeof(struct ni_660x_private)); + if (retval < 0) return retval; + spin_lock_init(&private(dev)->mite_channel_lock); + spin_lock_init(&private(dev)->interrupt_lock); spin_lock_init(&private(dev)->soft_reg_copy_lock); for (i = 0; i < NUM_PFI_CHANNELS; ++i) { private(dev)->pfi_output_selects[i] = pfi_output_select_counter; @@ -953,7 +974,7 @@ static int ni_660x_allocate_private(struct comedi_device * dev) return 0; } -static int ni_660x_alloc_mite_rings(struct comedi_device * dev) +static int ni_660x_alloc_mite_rings(struct comedi_device *dev) { unsigned i; unsigned j; @@ -970,7 +991,7 @@ static int ni_660x_alloc_mite_rings(struct comedi_device * dev) return 0; } -static void ni_660x_free_mite_rings(struct comedi_device * dev) +static void ni_660x_free_mite_rings(struct comedi_device *dev) { unsigned i; unsigned j; @@ -982,7 +1003,7 @@ static void ni_660x_free_mite_rings(struct comedi_device * dev) } } -static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret; @@ -1031,7 +1052,7 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * s->insn_bits = ni_660x_dio_insn_bits; s->insn_config = ni_660x_dio_insn_config; s->io_bits = 0; /* all bits default to input */ - // we use the ioconfig registers to control dio direction, so zero output enables in stc dio control reg + /* we use the ioconfig registers to control dio direction, so zero output enables in stc dio control reg */ ni_660x_write_register(dev, 0, 0, STCDIOControl); private(dev)->counter_dev = ni_gpct_device_construct(dev, @@ -1055,6 +1076,7 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * s->len_chanlist = 1; s->do_cmdtest = &ni_660x_cmdtest; s->cancel = &ni_660x_cancel; + s->poll = &ni_660x_input_poll; s->async_dma_dir = DMA_BIDIRECTIONAL; s->buf_change = &ni_660x_buf_change; s->private = &private(dev)->counter_dev->counters[i]; @@ -1086,9 +1108,9 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * for (i = 0; i < board(dev)->n_chips; ++i) { set_tio_counterswap(dev, i); } - if ((ret = comedi_request_irq(mite_irq(private(dev)->mite), - &ni_660x_interrupt, IRQF_SHARED, "ni_660x", - dev)) < 0) { + ret = request_irq(mite_irq(private(dev)->mite), ni_660x_interrupt, + IRQF_SHARED, "ni_660x", dev); + if (ret < 0) { printk(" irq not available\n"); return ret; } @@ -1102,13 +1124,13 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int ni_660x_detach(struct comedi_device * dev) +static int ni_660x_detach(struct comedi_device *dev) { printk("comedi%d: ni_660x: remove\n", dev->minor); /* Free irq */ if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->private) { if (private(dev)->counter_dev) @@ -1122,17 +1144,17 @@ static int ni_660x_detach(struct comedi_device * dev) } static int -ni_660x_GPCT_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +ni_660x_GPCT_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return ni_tio_rinsn(subdev_to_counter(s), insn, data); } -static void init_tio_chip(struct comedi_device * dev, int chipset) +static void init_tio_chip(struct comedi_device *dev, int chipset) { unsigned i; - // init dma configuration register + /* init dma configuration register */ private(dev)->dma_configuration_soft_copies[chipset] = 0; for (i = 0; i < MAX_DMA_CHANNEL; ++i) { private(dev)->dma_configuration_soft_copies[chipset] |= @@ -1142,26 +1164,26 @@ static void init_tio_chip(struct comedi_device * dev, int chipset) ni_660x_write_register(dev, chipset, private(dev)->dma_configuration_soft_copies[chipset], DMAConfigRegister); - for(i = 0; i < NUM_PFI_CHANNELS; ++i) + for (i = 0; i < NUM_PFI_CHANNELS; ++i) { ni_660x_write_register(dev, chipset, 0, IOConfigReg(i)); } } static int -ni_660x_GPCT_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +ni_660x_GPCT_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return ni_tio_insn_config(subdev_to_counter(s), insn, data); } -static int ni_660x_GPCT_winsn(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_660x_GPCT_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { return ni_tio_winsn(subdev_to_counter(s), insn, data); } -static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot) +static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; int i; @@ -1188,12 +1210,12 @@ static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot) return -EIO; } -static int ni_660x_dio_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_660x_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { unsigned base_bitfield_channel = CR_CHAN(insn->chanspec); - // Check if we have to write some bits + /* Check if we have to write some bits */ if (data[0]) { s->state &= ~(data[0] << base_bitfield_channel); s->state |= (data[0] & data[1]) << base_bitfield_channel; @@ -1208,7 +1230,7 @@ static int ni_660x_dio_insn_bits(struct comedi_device * dev, return 2; } -static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_channel, +static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel, unsigned output_select) { static const unsigned counter_4_7_first_pfi = 8; @@ -1218,8 +1240,8 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c unsigned active_bits; unsigned idle_bits; - if(board(dev)->n_chips > 1) { - if(output_select == pfi_output_select_counter && + if (board (dev)->n_chips > 1) { + if (output_select == pfi_output_select_counter && pfi_channel >= counter_4_7_first_pfi && pfi_channel <= counter_4_7_last_pfi) { active_chipset = 1; @@ -1230,7 +1252,7 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c } } - if(idle_chipset != active_chipset) { + if (idle_chipset != active_chipset) { idle_bits = ni_660x_read_register(dev, idle_chipset, IOConfigReg(pfi_channel)); idle_bits &= ~pfi_output_select_mask(pfi_channel); idle_bits |= pfi_output_select_bits(pfi_channel, pfi_output_select_high_Z); @@ -1243,7 +1265,7 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c ni_660x_write_register(dev, active_chipset, active_bits, IOConfigReg(pfi_channel)); } -static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan, +static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { if (source > num_pfi_output_selects) @@ -1266,13 +1288,13 @@ static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan, return 0; } -static unsigned ni_660x_get_pfi_routing(struct comedi_device * dev, unsigned chan) +static unsigned ni_660x_get_pfi_routing(struct comedi_device *dev, unsigned chan) { BUG_ON(chan >= NUM_PFI_CHANNELS); return private(dev)->pfi_output_selects[chan]; } -static void ni660x_config_filter(struct comedi_device * dev, unsigned pfi_channel, +static void ni660x_config_filter(struct comedi_device *dev, unsigned pfi_channel, enum ni_gpct_filter_select filter) { unsigned bits = ni_660x_read_register(dev, 0, IOConfigReg(pfi_channel)); @@ -1281,8 +1303,8 @@ static void ni660x_config_filter(struct comedi_device * dev, unsigned pfi_channe ni_660x_write_register(dev, 0, bits, IOConfigReg(pfi_channel)); } -static int ni_660x_dio_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_660x_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index d1312e073a65..71f7d3ab3aa1 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -41,6 +41,7 @@ Commands are not supported. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include "mite.h" @@ -69,29 +70,29 @@ struct ni_670x_board { static const struct ni_670x_board ni_670x_boards[] = { { - dev_id: 0x2c90, - name: "PCI-6703", - ao_chans:16, - ao_bits: 16, + .dev_id = 0x2c90, + .name = "PCI-6703", + .ao_chans = 16, + .ao_bits = 16, }, { - dev_id: 0x1920, - name: "PXI-6704", - ao_chans:32, - ao_bits: 16, + .dev_id = 0x1920, + .name = "PXI-6704", + .ao_chans = 32, + .ao_bits = 16, }, { - dev_id: 0x1290, - name: "PCI-6704", - ao_chans:32, - ao_bits: 16, + .dev_id = 0x1290, + .name = "PCI-6704", + .ao_chans = 32, + .ao_bits = 16, }, }; static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = { {PCI_VENDOR_ID_NATINST, 0x2c90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_NATINST, 0x1920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - //{ PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + /* { PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ {0} }; @@ -111,32 +112,32 @@ struct ni_670x_private { #define devpriv ((struct ni_670x_private *)dev->private) #define n_ni_670x_boards (sizeof(ni_670x_boards)/sizeof(ni_670x_boards[0])) -static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int ni_670x_detach(struct comedi_device * dev); +static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int ni_670x_detach(struct comedi_device *dev); static struct comedi_driver driver_ni_670x = { - driver_name:"ni_670x", - module:THIS_MODULE, - attach:ni_670x_attach, - detach:ni_670x_detach, + .driver_name = "ni_670x", + .module = THIS_MODULE, + .attach = ni_670x_attach, + .detach = ni_670x_detach, }; COMEDI_PCI_INITCLEANUP(driver_ni_670x, ni_670x_pci_table); static struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} }; -static int ni_670x_find_device(struct comedi_device * dev, int bus, int slot); +static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot); -static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret; @@ -144,7 +145,8 @@ static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * printk("comedi%d: ni_670x: ", dev->minor); - if ((ret = alloc_private(dev, sizeof(struct ni_670x_private))) < 0) + ret = alloc_private(dev, sizeof(struct ni_670x_private)); + if (ret < 0) return ret; ret = ni_670x_find_device(dev, it->options[0], it->options[1]); @@ -205,7 +207,7 @@ static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * return 1; } -static int ni_670x_detach(struct comedi_device * dev) +static int ni_670x_detach(struct comedi_device *dev) { printk("comedi%d: ni_670x: remove\n", dev->minor); @@ -216,13 +218,13 @@ static int ni_670x_detach(struct comedi_device * dev) mite_unsetup(devpriv->mite); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; } -static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -247,8 +249,8 @@ static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice return i; } -static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -259,8 +261,8 @@ static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice return i; } -static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -281,8 +283,8 @@ static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subde return 2; } -static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); @@ -308,7 +310,7 @@ static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_sub return insn->n; } -static int ni_670x_find_device(struct comedi_device * dev, int bus, int slot) +static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; int i; diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 5d45bf24a5ef..45c6809031db 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -64,6 +64,7 @@ TRIG_WAKE_EOS */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -73,10 +74,10 @@ TRIG_WAKE_EOS #include "comedi_fc.h" #define A2150_SIZE 28 -#define A2150_DMA_BUFFER_SIZE 0xff00 // size in bytes of dma buffer +#define A2150_DMA_BUFFER_SIZE 0xff00 /* size in bytes of dma buffer */ -//#define A2150_DEBUG // enable debugging code -#undef A2150_DEBUG // disable debugging code +/* #define A2150_DEBUG enable debugging code */ +#undef A2150_DEBUG /* disable debugging code */ /* Registers and bits */ #define CONFIG_REG 0x0 @@ -85,48 +86,48 @@ TRIG_WAKE_EOS #define CLOCK_SELECT_BITS(x) (((x) & 0x3) << 3) #define CLOCK_DIVISOR_BITS(x) (((x) & 0x3) << 5) #define CLOCK_MASK (0xf << 3) -#define ENABLE0_BIT 0x80 // enable (don't internally ground) channels 0 and 1 -#define ENABLE1_BIT 0x100 // enable (don't internally ground) channels 2 and 3 -#define AC0_BIT 0x200 // ac couple channels 0,1 -#define AC1_BIT 0x400 // ac couple channels 2,3 -#define APD_BIT 0x800 // analog power down -#define DPD_BIT 0x1000 // digital power down -#define TRIGGER_REG 0x2 // trigger config register +#define ENABLE0_BIT 0x80 /* enable (don't internally ground) channels 0 and 1 */ +#define ENABLE1_BIT 0x100 /* enable (don't internally ground) channels 2 and 3 */ +#define AC0_BIT 0x200 /* ac couple channels 0,1 */ +#define AC1_BIT 0x400 /* ac couple channels 2,3 */ +#define APD_BIT 0x800 /* analog power down */ +#define DPD_BIT 0x1000 /* digital power down */ +#define TRIGGER_REG 0x2 /* trigger config register */ #define POST_TRIGGER_BITS 0x2 #define DELAY_TRIGGER_BITS 0x3 -#define HW_TRIG_EN 0x10 // enable hardware trigger -#define FIFO_START_REG 0x6 // software start aquistion trigger -#define FIFO_RESET_REG 0x8 // clears fifo + fifo flags -#define FIFO_DATA_REG 0xa // read data -#define DMA_TC_CLEAR_REG 0xe // clear dma terminal count interrupt -#define STATUS_REG 0x12 // read only -#define FNE_BIT 0x1 // fifo not empty -#define OVFL_BIT 0x8 // fifo overflow -#define EDAQ_BIT 0x10 // end of aquisition interrupt -#define DCAL_BIT 0x20 // offset calibration in progress -#define INTR_BIT 0x40 // interrupt has occured -#define DMA_TC_BIT 0x80 // dma terminal count interrupt has occured +#define HW_TRIG_EN 0x10 /* enable hardware trigger */ +#define FIFO_START_REG 0x6 /* software start aquistion trigger */ +#define FIFO_RESET_REG 0x8 /* clears fifo + fifo flags */ +#define FIFO_DATA_REG 0xa /* read data */ +#define DMA_TC_CLEAR_REG 0xe /* clear dma terminal count interrupt */ +#define STATUS_REG 0x12 /* read only */ +#define FNE_BIT 0x1 /* fifo not empty */ +#define OVFL_BIT 0x8 /* fifo overflow */ +#define EDAQ_BIT 0x10 /* end of aquisition interrupt */ +#define DCAL_BIT 0x20 /* offset calibration in progress */ +#define INTR_BIT 0x40 /* interrupt has occured */ +#define DMA_TC_BIT 0x80 /* dma terminal count interrupt has occured */ #define ID_BITS(x) (((x) >> 8) & 0x3) -#define IRQ_DMA_CNTRL_REG 0x12 // write only -#define DMA_CHAN_BITS(x) ((x) & 0x7) // sets dma channel -#define DMA_EN_BIT 0x8 // enables dma -#define IRQ_LVL_BITS(x) (((x) & 0xf) << 4) // sets irq level -#define FIFO_INTR_EN_BIT 0x100 // enable fifo interrupts -#define FIFO_INTR_FHF_BIT 0x200 // interrupt fifo half full -#define DMA_INTR_EN_BIT 0x800 // enable interrupt on dma terminal count -#define DMA_DEM_EN_BIT 0x1000 // enables demand mode dma +#define IRQ_DMA_CNTRL_REG 0x12 /* write only */ +#define DMA_CHAN_BITS(x) ((x) & 0x7) /* sets dma channel */ +#define DMA_EN_BIT 0x8 /* enables dma */ +#define IRQ_LVL_BITS(x) (((x) & 0xf) << 4) /* sets irq level */ +#define FIFO_INTR_EN_BIT 0x100 /* enable fifo interrupts */ +#define FIFO_INTR_FHF_BIT 0x200 /* interrupt fifo half full */ +#define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */ +#define DMA_DEM_EN_BIT 0x1000 /* enables demand mode dma */ #define I8253_BASE_REG 0x14 #define I8253_MODE_REG 0x17 -#define HW_COUNT_DISABLE 0x30 // disable hardware counting of conversions +#define HW_COUNT_DISABLE 0x30 /* disable hardware counting of conversions */ struct a2150_board { const char *name; - int clock[4]; // master clock periods, in nanoseconds - int num_clocks; // number of available master clock speeds - int ai_speed; // maximum conversion rate in nanoseconds + int clock[4]; /* master clock periods, in nanoseconds */ + int num_clocks; /* number of available master clock speeds */ + int ai_speed; /* maximum conversion rate in nanoseconds */ }; -//analog input range +/* analog input range */ static const struct comedi_lrange range_a2150 = { 1, { @@ -134,20 +135,20 @@ static const struct comedi_lrange range_a2150 = { } }; -// enum must match board indices +/* enum must match board indices */ enum { a2150_c, a2150_s }; static const struct a2150_board a2150_boards[] = { { - name: "at-a2150c", - clock: {31250, 22676, 20833, 19531}, - num_clocks:4, - ai_speed:19531, + .name = "at-a2150c", + .clock = {31250, 22676, 20833, 19531}, + .num_clocks = 4, + .ai_speed = 19531, }, { - name: "at-a2150s", - clock: {62500, 50000, 41667, 0}, - num_clocks:3, - ai_speed:41667, + .name = "at-a2150s", + .clock = {62500, 50000, 41667, 0}, + .num_clocks = 3, + .ai_speed = 41667, }, }; @@ -159,37 +160,37 @@ static const struct a2150_board a2150_boards[] = { struct a2150_private { volatile unsigned int count; /* number of data points left to be taken */ - unsigned int dma; // dma channel - s16 *dma_buffer; // dma buffer - unsigned int dma_transfer_size; // size in bytes of dma transfers - int irq_dma_bits; // irq/dma register bits - int config_bits; // config register bits + unsigned int dma; /* dma channel */ + s16 *dma_buffer; /* dma buffer */ + unsigned int dma_transfer_size; /* size in bytes of dma transfers */ + int irq_dma_bits; /* irq/dma register bits */ + int config_bits; /* config register bits */ }; #define devpriv ((struct a2150_private *)dev->private) -static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int a2150_detach(struct comedi_device * dev); -static int a2150_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int a2150_detach(struct comedi_device *dev); +static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static struct comedi_driver driver_a2150 = { - driver_name:"ni_at_a2150", - module:THIS_MODULE, - attach:a2150_attach, - detach:a2150_detach, + .driver_name = "ni_at_a2150", + .module = THIS_MODULE, + .attach = a2150_attach, + .detach = a2150_detach, }; -static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG); -static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, +static irqreturn_t a2150_interrupt(int irq, void *d); +static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int a2150_get_timing(struct comedi_device *dev, unsigned int *period, int flags); -static int a2150_probe(struct comedi_device * dev); -static int a2150_set_chanlist(struct comedi_device * dev, unsigned int start_channel, +static int a2150_probe(struct comedi_device *dev); +static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel, unsigned int num_channels); /* * A convenient macro that defines init_module() and cleanup_module(), @@ -199,17 +200,17 @@ COMEDI_INITCLEANUP(driver_a2150); #ifdef A2150_DEBUG -static void ni_dump_regs(struct comedi_device * dev) +static void ni_dump_regs(struct comedi_device *dev) { - rt_printk("config bits 0x%x\n", devpriv->config_bits); - rt_printk("irq dma bits 0x%x\n", devpriv->irq_dma_bits); - rt_printk("status bits 0x%x\n", inw(dev->iobase + STATUS_REG)); + printk("config bits 0x%x\n", devpriv->config_bits); + printk("irq dma bits 0x%x\n", devpriv->irq_dma_bits); + printk("status bits 0x%x\n", inw(dev->iobase + STATUS_REG)); } #endif /* interrupt service routine */ -static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t a2150_interrupt(int irq, void *d) { int i; int status; @@ -226,7 +227,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) comedi_error(dev, "premature interrupt"); return IRQ_HANDLED; } - // initialize async here to make sure s is not NULL + /* initialize async here to make sure s is not NULL */ async = s->async; async->events = 0; cmd = &async->cmd; @@ -258,7 +259,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) * count and address get set correctly */ clear_dma_ff(devpriv->dma); - // figure out how many points to read + /* figure out how many points to read */ max_points = devpriv->dma_transfer_size / sample_size; /* residue is the number of points left to be done on the dma * transfer. It should always be zero at this point unless @@ -269,7 +270,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT) num_points = devpriv->count; - // figure out how many points will be stored next time + /* figure out how many points will be stored next time */ leftover = 0; if (cmd->stop_src == TRIG_NONE) { leftover = devpriv->dma_transfer_size / sample_size; @@ -288,7 +289,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) for (i = 0; i < num_points; i++) { /* write data point to comedi buffer */ dpnt = devpriv->dma_buffer[i]; - // convert from 2's complement to unsigned coding + /* convert from 2's complement to unsigned coding */ dpnt ^= 0x8000; cfc_write_to_buffer(s, dpnt); if (cmd->stop_src == TRIG_COUNT) { @@ -299,7 +300,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) } } } - // re-enable dma + /* re-enable dma */ if (leftover) { set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); set_dma_count(devpriv->dma, leftover * sample_size); @@ -317,14 +318,14 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -// probes board type, returns offset -static int a2150_probe(struct comedi_device * dev) +/* probes board type, returns offset */ +static int a2150_probe(struct comedi_device *dev) { int status = inw(dev->iobase + STATUS_REG); return ID_BITS(status); } -static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = it->options[0]; @@ -365,12 +366,12 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it /* grab our IRQ */ if (irq) { - // check that irq is supported + /* check that irq is supported */ if (irq < 3 || irq == 8 || irq == 13 || irq > 15) { printk(" invalid irq line %u\n", irq); return -EINVAL; } - if (comedi_request_irq(irq, a2150_interrupt, 0, + if (request_irq(irq, a2150_interrupt, 0, driver_a2150.driver_name, dev)) { printk("unable to allocate irq %u\n", irq); return -EINVAL; @@ -378,7 +379,7 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it devpriv->irq_dma_bits |= IRQ_LVL_BITS(irq); dev->irq = irq; } - // initialize dma + /* initialize dma */ if (dma) { if (dma == 4 || dma > 7) { printk(" invalid dma channel %u\n", dma); @@ -424,20 +425,20 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it * prevent hardware count from stopping aquisition */ outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG); - // set card's irq and dma levels + /* set card's irq and dma levels */ outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); - // reset and sync adc clock circuitry + /* reset and sync adc clock circuitry */ outw_p(DPD_BIT | APD_BIT, dev->iobase + CONFIG_REG); outw_p(DPD_BIT, dev->iobase + CONFIG_REG); - // initialize configuration register + /* initialize configuration register */ devpriv->config_bits = 0; outw(devpriv->config_bits, dev->iobase + CONFIG_REG); - // wait until offset calibration is done, then enable analog inputs + /* wait until offset calibration is done, then enable analog inputs */ for (i = 0; i < timeout; i++) { if ((DCAL_BIT & inw(dev->iobase + STATUS_REG)) == 0) break; - comedi_udelay(1000); + udelay(1000); } if (i == timeout) { printk(" timed out waiting for offset calibration to complete\n"); @@ -449,19 +450,19 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it return 0; }; -static int a2150_detach(struct comedi_device * dev) +static int a2150_detach(struct comedi_device *dev) { printk("comedi%d: %s: remove\n", dev->minor, driver_a2150.driver_name); /* only free stuff if it has been allocated by _attach */ if (dev->iobase) { - // put board in power-down mode + /* put board in power-down mode */ outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG); release_region(dev->iobase, A2150_SIZE); } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv) { if (devpriv->dma) free_dma(devpriv->dma); @@ -472,23 +473,23 @@ static int a2150_detach(struct comedi_device * dev) return 0; }; -static int a2150_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - // disable dma on card + /* disable dma on card */ devpriv->irq_dma_bits &= ~DMA_INTR_EN_BIT & ~DMA_EN_BIT; outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); - // disable computer's dma + /* disable computer's dma */ disable_dma(devpriv->dma); - // clear fifo and reset triggering circuitry + /* clear fifo and reset triggering circuitry */ outw(0, dev->iobase + FIFO_RESET_REG); return 0; } -static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -582,7 +583,7 @@ static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (err) return 4; - // check channel/gain list against card's limitations + /* check channel/gain list against card's limitations */ if (cmd->chanlist) { startChan = CR_CHAN(cmd->chanlist[0]); for (i = 1; i < cmd->chanlist_len; i++) { @@ -617,7 +618,7 @@ static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -635,7 +636,7 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) " dma incompatible with hard real-time interrupt (TRIG_RT), aborting"); return -1; } - // clear fifo and reset triggering circuitry + /* clear fifo and reset triggering circuitry */ outw(0, dev->iobase + FIFO_RESET_REG); /* setup chanlist */ @@ -643,7 +644,7 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) cmd->chanlist_len) < 0) return -1; - // setup ac/dc coupling + /* setup ac/dc coupling */ if (CR_AREF(cmd->chanlist[0]) == AREF_OTHER) devpriv->config_bits |= AC0_BIT; else @@ -653,23 +654,23 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) else devpriv->config_bits &= ~AC1_BIT; - // setup timing + /* setup timing */ a2150_get_timing(dev, &cmd->scan_begin_arg, cmd->flags); - // send timing, channel, config bits + /* send timing, channel, config bits */ outw(devpriv->config_bits, dev->iobase + CONFIG_REG); - // initialize number of samples remaining + /* initialize number of samples remaining */ devpriv->count = cmd->stop_arg * cmd->chanlist_len; - // enable computer's dma + /* enable computer's dma */ lock_flags = claim_dma_lock(); disable_dma(devpriv->dma); /* clear flip-flop to make sure 2-byte registers for * count and address get set correctly */ clear_dma_ff(devpriv->dma); set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); - // set size of transfer to fill in 1/3 second + /* set size of transfer to fill in 1/3 second */ #define ONE_THIRD_SECOND 333333333 devpriv->dma_transfer_size = sizeof(devpriv->dma_buffer[0]) * cmd->chanlist_len * @@ -688,36 +689,36 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) * one spurious interrupt that has been happening */ outw(0x00, dev->iobase + DMA_TC_CLEAR_REG); - // enable dma on card + /* enable dma on card */ devpriv->irq_dma_bits |= DMA_INTR_EN_BIT | DMA_EN_BIT; outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); - // may need to wait 72 sampling periods if timing was changed + /* may need to wait 72 sampling periods if timing was changed */ i8254_load(dev->iobase + I8253_BASE_REG, 0, 2, 72, 0); - // setup start triggering + /* setup start triggering */ trigger_bits = 0; - // decide if we need to wait 72 periods for valid data + /* decide if we need to wait 72 periods for valid data */ if (cmd->start_src == TRIG_NOW && (old_config_bits & CLOCK_MASK) != (devpriv->config_bits & CLOCK_MASK)) { - // set trigger source to delay trigger + /* set trigger source to delay trigger */ trigger_bits |= DELAY_TRIGGER_BITS; } else { - // otherwise no delay + /* otherwise no delay */ trigger_bits |= POST_TRIGGER_BITS; } - // enable external hardware trigger + /* enable external hardware trigger */ if (cmd->start_src == TRIG_EXT) { trigger_bits |= HW_TRIG_EN; } else if (cmd->start_src == TRIG_OTHER) { - // XXX add support for level/slope start trigger using TRIG_OTHER + /* XXX add support for level/slope start trigger using TRIG_OTHER */ comedi_error(dev, "you shouldn't see this?"); } - // send trigger config bits + /* send trigger config bits */ outw(trigger_bits, dev->iobase + TRIGGER_REG); - // start aquisition for soft trigger + /* start aquisition for soft trigger */ if (cmd->start_src == TRIG_NOW) { outw(0, dev->iobase + FIFO_START_REG); } @@ -728,35 +729,35 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int i, n; static const int timeout = 100000; static const int filter_delay = 36; - // clear fifo and reset triggering circuitry + /* clear fifo and reset triggering circuitry */ outw(0, dev->iobase + FIFO_RESET_REG); /* setup chanlist */ if (a2150_set_chanlist(dev, CR_CHAN(insn->chanspec), 1) < 0) return -1; - // set dc coupling + /* set dc coupling */ devpriv->config_bits &= ~AC0_BIT; devpriv->config_bits &= ~AC1_BIT; - // send timing, channel, config bits + /* send timing, channel, config bits */ outw(devpriv->config_bits, dev->iobase + CONFIG_REG); - // disable dma on card + /* disable dma on card */ devpriv->irq_dma_bits &= ~DMA_INTR_EN_BIT & ~DMA_EN_BIT; outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); - // setup start triggering + /* setup start triggering */ outw(0, dev->iobase + TRIGGER_REG); - // start aquisition for soft trigger + /* start aquisition for soft trigger */ outw(0, dev->iobase + FIFO_START_REG); /* there is a 35.6 sample delay for data to get through the antialias filter */ @@ -764,7 +765,7 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * for (i = 0; i < timeout; i++) { if (inw(dev->iobase + STATUS_REG) & FNE_BIT) break; - comedi_udelay(1); + udelay(1); } if (i == timeout) { comedi_error(dev, "timeout"); @@ -773,12 +774,12 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * inw(dev->iobase + FIFO_DATA_REG); } - // read data + /* read data */ for (n = 0; n < insn->n; n++) { for (i = 0; i < timeout; i++) { if (inw(dev->iobase + STATUS_REG) & FNE_BIT) break; - comedi_udelay(1); + udelay(1); } if (i == timeout) { comedi_error(dev, "timeout"); @@ -789,12 +790,12 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * #endif data[n] = inw(dev->iobase + FIFO_DATA_REG); #ifdef A2150_DEBUG - rt_printk(" data is %i\n", data[n]); + printk(" data is %i\n", data[n]); #endif data[n] ^= 0x8000; } - // clear fifo and reset triggering circuitry + /* clear fifo and reset triggering circuitry */ outw(0, dev->iobase + FIFO_RESET_REG); return n; @@ -802,14 +803,14 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * /* sets bits in devpriv->clock_bits to nearest approximation of requested period, * adjusts requested period to actual timing. */ -static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, +static int a2150_get_timing(struct comedi_device *dev, unsigned int *period, int flags) { int lub, glb, temp; int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index; int i, j; - // initialize greatest lower and least upper bounds + /* initialize greatest lower and least upper bounds */ lub_divisor_shift = 3; lub_index = 0; lub = thisboard->clock[lub_index] * (1 << lub_divisor_shift); @@ -817,19 +818,19 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, glb_index = thisboard->num_clocks - 1; glb = thisboard->clock[glb_index] * (1 << glb_divisor_shift); - // make sure period is in available range + /* make sure period is in available range */ if (*period < glb) *period = glb; if (*period > lub) *period = lub; - // we can multiply period by 1, 2, 4, or 8, using (1 << i) + /* we can multiply period by 1, 2, 4, or 8, using (1 << i) */ for (i = 0; i < 4; i++) { - // there are a maximum of 4 master clocks + /* there are a maximum of 4 master clocks */ for (j = 0; j < thisboard->num_clocks; j++) { - // temp is the period in nanosec we are evaluating + /* temp is the period in nanosec we are evaluating */ temp = thisboard->clock[j] * (1 << i); - // if it is the best match yet + /* if it is the best match yet */ if (temp < lub && temp >= *period) { lub_divisor_shift = i; lub_index = j; @@ -846,7 +847,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, switch (flags) { case TRIG_ROUND_NEAREST: default: - // if least upper bound is better approximation + /* if least upper bound is better approximation */ if (lub - *period < *period - glb) { *period = lub; } else { @@ -861,7 +862,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, break; } - // set clock bits for config register appropriately + /* set clock bits for config register appropriately */ devpriv->config_bits &= ~CLOCK_MASK; if (*period == lub) { devpriv->config_bits |= @@ -876,7 +877,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period, return 0; } -static int a2150_set_chanlist(struct comedi_device * dev, unsigned int start_channel, +static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel, unsigned int num_channels) { if (start_channel + num_channels > 4) diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 2cc46b672588..4e8bf9ed167c 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -158,12 +158,12 @@ struct atao_board { static const struct atao_board atao_boards[] = { { - name: "ai-ao-6", - n_ao_chans:6, + .name = "ai-ao-6", + .n_ao_chans = 6, }, { - name: "ai-ao-10", - n_ao_chans:10, + .name = "ai-ao-10", + .n_ao_chans = 10, }, }; @@ -181,36 +181,36 @@ struct atao_private { #define devpriv ((struct atao_private *)dev->private) -static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int atao_detach(struct comedi_device * dev); +static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int atao_detach(struct comedi_device *dev); static struct comedi_driver driver_atao = { - driver_name:"ni_at_ao", - module:THIS_MODULE, - attach:atao_attach, - detach:atao_detach, - board_name:&atao_boards[0].name, - offset:sizeof(struct atao_board), - num_names:sizeof(atao_boards) / sizeof(struct atao_board), + .driver_name = "ni_at_ao", + .module = THIS_MODULE, + .attach = atao_attach, + .detach = atao_detach, + .board_name = &atao_boards[0].name, + .offset = sizeof(struct atao_board), + .num_names = ARRAY_SIZE(atao_boards), }; COMEDI_INITCLEANUP(driver_atao); -static void atao_reset(struct comedi_device * dev); - -static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int atao_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); - -static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static void atao_reset(struct comedi_device *dev); + +static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -229,7 +229,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it) } dev->iobase = iobase; - //dev->board_ptr = atao_probe(dev); + /* dev->board_ptr = atao_probe(dev); */ dev->board_name = thisboard->name; @@ -273,7 +273,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it) s = dev->subdevices + 3; /* eeprom subdevice */ - //s->type=COMEDI_SUBD_EEPROM; + /* s->type=COMEDI_SUBD_EEPROM; */ s->type = COMEDI_SUBD_UNUSED; atao_reset(dev); @@ -283,7 +283,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it) return 0; } -static int atao_detach(struct comedi_device * dev) +static int atao_detach(struct comedi_device *dev) { printk("comedi%d: atao: remove\n", dev->minor); @@ -293,7 +293,7 @@ static int atao_detach(struct comedi_device * dev) return 0; } -static void atao_reset(struct comedi_device * dev) +static void atao_reset(struct comedi_device *dev) { /* This is the reset sequence described in the manual */ @@ -323,8 +323,8 @@ static void atao_reset(struct comedi_device * dev) outw(devpriv->cfg1, dev->iobase + ATAO_CFG1); } -static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -347,8 +347,8 @@ static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s return i; } -static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -359,8 +359,8 @@ static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s return i; } -static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -376,8 +376,8 @@ static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic return 2; } -static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); unsigned int mask, bit; @@ -421,8 +421,8 @@ static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdev * DACs. It is not explicitly stated in the manual how to access * the caldacs, but we can guess. */ -static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; for (i = 0; i < insn->n; i++) { @@ -431,8 +431,8 @@ static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdev return insn->n; } -static int atao_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int bitstring, bit; unsigned int chan = CR_CHAN(insn->chanspec); diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index fcc38535afc5..8839447538f2 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -93,6 +93,7 @@ are not supported. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -114,156 +115,156 @@ are not supported. #define MAX_N_CALDACS 32 -static const ni_board ni_boards[] = { - {device_id:44, - isapnp_id:0x0000,/* XXX unknown */ - name: "at-mio-16e-1", - n_adchan:16, - adbits: 12, - ai_fifo_depth:8192, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:800, - n_aochan:2, - aobits: 12, - ao_fifo_depth:2048, +static const struct ni_board_struct ni_boards[] = { + {.device_id = 44, + .isapnp_id = 0x0000,/* XXX unknown */ + .name = "at-mio-16e-1", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 8192, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 800, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:1000, - has_8255:0, + .ao_unipolar = 1, + .ao_speed = 1000, + .has_8255 = 0, .num_p0_dio_channels = 8, - caldac: {mb88341}, + .caldac = {mb88341}, }, - {device_id:25, - isapnp_id:0x1900, - name: "at-mio-16e-2", - n_adchan:16, - adbits: 12, - ai_fifo_depth:2048, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:2000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:2048, + {.device_id = 25, + .isapnp_id = 0x1900, + .name = "at-mio-16e-2", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 2048, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 2000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:1000, - has_8255:0, + .ao_unipolar = 1, + .ao_speed = 1000, + .has_8255 = 0, .num_p0_dio_channels = 8, - caldac: {mb88341}, + .caldac = {mb88341}, }, - {device_id:36, - isapnp_id:0x2400, - name: "at-mio-16e-10", - n_adchan:16, - adbits: 12, - ai_fifo_depth:512, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:10000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:0, + {.device_id = 36, + .isapnp_id = 0x2400, + .name = "at-mio-16e-10", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 512, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 10000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 0, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:10000, + .ao_unipolar = 1, + .ao_speed = 10000, .num_p0_dio_channels = 8, - caldac: {ad8804_debug}, - has_8255:0, + .caldac = {ad8804_debug}, + .has_8255 = 0, }, - {device_id:37, - isapnp_id:0x2500, - name: "at-mio-16de-10", - n_adchan:16, - adbits: 12, - ai_fifo_depth:512, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:10000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:0, + {.device_id = 37, + .isapnp_id = 0x2500, + .name = "at-mio-16de-10", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 512, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 10000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 0, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:10000, + .ao_unipolar = 1, + .ao_speed = 10000, .num_p0_dio_channels = 8, - caldac: {ad8804_debug}, - has_8255:1, + .caldac = {ad8804_debug}, + .has_8255 = 1, }, - {device_id:38, - isapnp_id:0x2600, - name: "at-mio-64e-3", - n_adchan:64, - adbits: 12, - ai_fifo_depth:2048, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:2000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:2048, + {.device_id = 38, + .isapnp_id = 0x2600, + .name = "at-mio-64e-3", + .n_adchan = 64, + .adbits = 12, + .ai_fifo_depth = 2048, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 2000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:1000, - has_8255:0, + .ao_unipolar = 1, + .ao_speed = 1000, + .has_8255 = 0, .num_p0_dio_channels = 8, - caldac: {ad8804_debug}, + .caldac = {ad8804_debug}, }, - {device_id:39, - isapnp_id:0x2700, - name: "at-mio-16xe-50", - n_adchan:16, - adbits: 16, - ai_fifo_depth:512, - alwaysdither:1, - gainlkup:ai_gain_8, - ai_speed:50000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:0, + {.device_id = 39, + .isapnp_id = 0x2700, + .name = "at-mio-16xe-50", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 512, + .alwaysdither = 1, + .gainlkup = ai_gain_8, + .ai_speed = 50000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 0, .ao_range_table = &range_bipolar10, - ao_unipolar:0, - ao_speed:50000, + .ao_unipolar = 0, + .ao_speed = 50000, .num_p0_dio_channels = 8, - caldac: {dac8800, dac8043}, - has_8255:0, + .caldac = {dac8800, dac8043}, + .has_8255 = 0, }, - {device_id:50, - isapnp_id:0x0000,/* XXX unknown */ - name: "at-mio-16xe-10", - n_adchan:16, - adbits: 16, - ai_fifo_depth:512, - alwaysdither:1, - gainlkup:ai_gain_14, - ai_speed:10000, - n_aochan:2, - aobits: 16, - ao_fifo_depth:2048, + {.device_id = 50, + .isapnp_id = 0x0000,/* XXX unknown */ + .name = "at-mio-16xe-10", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 512, + .alwaysdither = 1, + .gainlkup = ai_gain_14, + .ai_speed = 10000, + .n_aochan = 2, + .aobits = 16, + .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - ao_unipolar:1, - ao_speed:1000, + .ao_unipolar = 1, + .ao_speed = 1000, .num_p0_dio_channels = 8, - caldac: {dac8800, dac8043, ad8522}, - has_8255:0, + .caldac = {dac8800, dac8043, ad8522}, + .has_8255 = 0, }, - {device_id:51, - isapnp_id:0x0000,/* XXX unknown */ - name: "at-ai-16xe-10", - n_adchan:16, - adbits: 16, - ai_fifo_depth:512, - alwaysdither:1, /* unknown */ - gainlkup:ai_gain_14, - ai_speed:10000, - n_aochan:0, - aobits: 0, - ao_fifo_depth:0, - ao_unipolar:0, + {.device_id = 51, + .isapnp_id = 0x0000,/* XXX unknown */ + .name = "at-ai-16xe-10", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 512, + .alwaysdither = 1, /* unknown */ + .gainlkup = ai_gain_14, + .ai_speed = 10000, + .n_aochan = 0, + .aobits = 0, + .ao_fifo_depth = 0, + .ao_unipolar = 0, .num_p0_dio_channels = 8, - caldac: {dac8800, dac8043, ad8522}, - has_8255:0, + .caldac = {dac8800, dac8043, ad8522}, + .has_8255 = 0, } }; @@ -276,18 +277,19 @@ static const int ni_irqpin[] = #define NI_E_IRQ_FLAGS 0 -typedef struct { +struct ni_private { struct pnp_dev *isapnp_dev; - NI_PRIVATE_COMMON} ni_private; -#define devpriv ((ni_private *)dev->private) + NI_PRIVATE_COMMON +}; +#define devpriv ((struct ni_private *)dev->private) /* How we access registers */ -#define ni_writel(a,b) (outl((a),(b)+dev->iobase)) +#define ni_writel(a, b) (outl((a), (b)+dev->iobase)) #define ni_readl(a) (inl((a)+dev->iobase)) -#define ni_writew(a,b) (outw((a),(b)+dev->iobase)) +#define ni_writew(a, b) (outw((a), (b)+dev->iobase)) #define ni_readw(a) (inw((a)+dev->iobase)) -#define ni_writeb(a,b) (outb((a),(b)+dev->iobase)) +#define ni_writeb(a, b) (outb((a), (b)+dev->iobase)) #define ni_readb(a) (inb((a)+dev->iobase)) /* How we access windowed registers */ @@ -296,72 +298,72 @@ typedef struct { * read/written directly in the I/O space of the board. The * AT-MIO devices map the low 8 STC registers to iobase+addr*2. */ -static void ni_atmio_win_out(struct comedi_device * dev, uint16_t data, int addr) +static void ni_atmio_win_out(struct comedi_device *dev, uint16_t data, int addr) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); if ((addr) < 8) { ni_writew(data, addr * 2); } else { ni_writew(addr, Window_Address); ni_writew(data, Window_Data); } - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); } -static uint16_t ni_atmio_win_in(struct comedi_device * dev, int addr) +static uint16_t ni_atmio_win_in(struct comedi_device *dev, int addr) { unsigned long flags; uint16_t ret; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); if (addr < 8) { ret = ni_readw(addr * 2); } else { ni_writew(addr, Window_Address); ret = ni_readw(Window_Data); } - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); return ret; } static struct pnp_device_id device_ids[] = { - {.id = "NIC1900",.driver_data = 0}, - {.id = "NIC2400",.driver_data = 0}, - {.id = "NIC2500",.driver_data = 0}, - {.id = "NIC2600",.driver_data = 0}, - {.id = "NIC2700",.driver_data = 0}, + {.id = "NIC1900", .driver_data = 0}, + {.id = "NIC2400", .driver_data = 0}, + {.id = "NIC2500", .driver_data = 0}, + {.id = "NIC2600", .driver_data = 0}, + {.id = "NIC2700", .driver_data = 0}, {.id = ""} }; MODULE_DEVICE_TABLE(pnp, device_ids); -static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int ni_atmio_detach(struct comedi_device * dev); +static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int ni_atmio_detach(struct comedi_device *dev); static struct comedi_driver driver_atmio = { - driver_name:"ni_atmio", - module:THIS_MODULE, - attach:ni_atmio_attach, - detach:ni_atmio_detach, + .driver_name = "ni_atmio", + .module = THIS_MODULE, + .attach = ni_atmio_attach, + .detach = ni_atmio_detach, }; COMEDI_INITCLEANUP(driver_atmio); #include "ni_mio_common.c" -static int ni_getboardtype(struct comedi_device * dev); +static int ni_getboardtype(struct comedi_device *dev); /* clean up allocated resources */ -static int ni_atmio_detach(struct comedi_device * dev) +static int ni_atmio_detach(struct comedi_device *dev) { mio_common_detach(dev); if (dev->iobase) release_region(dev->iobase, NI_SIZE); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (devpriv->isapnp_dev) pnp_device_detach(devpriv->isapnp_dev); @@ -404,7 +406,7 @@ static int ni_isapnp_find_board(struct pnp_dev **dev) return 0; } -static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pnp_dev *isapnp_dev; int ret; @@ -413,8 +415,10 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * unsigned int irq; /* allocate private area */ - if ((ret = ni_alloc_private(dev)) < 0) + ret = ni_alloc_private(dev); + if (ret < 0) return ret; + devpriv->stc_writew = &ni_atmio_win_out; devpriv->stc_readw = &ni_atmio_win_in; devpriv->stc_writel = &win_out2; @@ -475,8 +479,10 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * return -EINVAL; } printk(" ( irq = %u )", irq); - if ((ret = comedi_request_irq(irq, ni_E_interrupt, - NI_E_IRQ_FLAGS, "ni_atmio", dev)) < 0) { + ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS, + "ni_atmio", dev); + + if (ret < 0) { printk(" irq not available\n"); return -EINVAL; } @@ -485,14 +491,15 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * /* generic E series stuff in ni_mio_common.c */ - if ((ret = ni_E_init(dev, it)) < 0) { + ret = ni_E_init(dev, it); + if (ret < 0) { return ret; } return 0; } -static int ni_getboardtype(struct comedi_device * dev) +static int ni_getboardtype(struct comedi_device *dev) { int device_id = ni_read_eeprom(dev, 511); int i; diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 35fcd172af2e..1a8c2ab20d3d 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -35,6 +35,7 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d) * */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -111,12 +112,12 @@ struct atmio16_board_t { static const struct atmio16_board_t atmio16_boards[] = { { - name: "atmio16", - has_8255:0, + .name = "atmio16", + .has_8255 = 0, }, { - name: "atmio16d", - has_8255:1, + .name = "atmio16d", + .has_8255 = 1, }, }; @@ -125,25 +126,25 @@ static const struct atmio16_board_t atmio16_boards[] = { #define boardtype ((const struct atmio16_board_t *)dev->board_ptr) /* function prototypes */ -static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int atmio16d_detach(struct comedi_device * dev); -static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG); -static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void reset_counters(struct comedi_device * dev); -static void reset_atmio16d(struct comedi_device * dev); +static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int atmio16d_detach(struct comedi_device *dev); +static irqreturn_t atmio16d_interrupt(int irq, void *d); +static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void reset_counters(struct comedi_device *dev); +static void reset_atmio16d(struct comedi_device *dev); /* main driver struct */ static struct comedi_driver driver_atmio16d = { - driver_name:"atmio16", - module:THIS_MODULE, - attach:atmio16d_attach, - detach:atmio16d_detach, - board_name:&atmio16_boards[0].name, - num_names:n_atmio16_boards, - offset:sizeof(struct atmio16_board_t), + .driver_name = "atmio16", + .module = THIS_MODULE, + .attach = atmio16d_attach, + .detach = atmio16d_detach, + .board_name = &atmio16_boards[0].name, + .num_names = n_atmio16_boards, + .offset = sizeof(struct atmio16_board_t), }; COMEDI_INITCLEANUP(driver_atmio16d); @@ -187,7 +188,7 @@ struct atmio16d_private { unsigned int com_reg_2_state; /* current state of command register 2 */ }; -static void reset_counters(struct comedi_device * dev) +static void reset_counters(struct comedi_device *dev) { /* Counter 2 */ outw(0xFFC2, dev->iobase + AM9513A_COM_REG); @@ -225,7 +226,7 @@ static void reset_counters(struct comedi_device * dev) outw(0, dev->iobase + AD_CLEAR_REG); } -static void reset_atmio16d(struct comedi_device * dev) +static void reset_atmio16d(struct comedi_device *dev) { int i; @@ -257,12 +258,12 @@ static void reset_atmio16d(struct comedi_device * dev) outw(2048, dev->iobase + DAC1_REG); } -static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t atmio16d_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 0; -// printk("atmio16d_interrupt!\n"); +/* printk("atmio16d_interrupt!\n"); */ comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG)); @@ -270,8 +271,8 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0, tmp; #ifdef DEBUG1 @@ -371,7 +372,7 @@ static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int timer, base_clock; @@ -417,10 +418,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } else if (cmd->convert_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->convert_arg / 10000; - } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->convert_arg / 100000; - } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->convert_arg / 1000000; } @@ -449,11 +450,13 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * outw(devpriv->com_reg_1_state, dev->iobase + COM_REG_1); } else { /* Counter 4 and 5 are needed */ - if ((tmp = sample_count & 0xFFFF)) { + + tmp = sample_count & 0xFFFF; + if (tmp) outw(tmp - 1, dev->iobase + AM9513A_DATA_REG); - } else { + else outw(0xFFFF, dev->iobase + AM9513A_DATA_REG); - } + outw(0xFF48, dev->iobase + AM9513A_COM_REG); outw(0, dev->iobase + AM9513A_DATA_REG); outw(0xFF28, dev->iobase + AM9513A_COM_REG); @@ -483,10 +486,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } else if (cmd->scan_begin_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->scan_begin_arg / 10000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->scan_begin_arg / 100000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->scan_begin_arg / 1000000; } @@ -519,7 +522,7 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } /* This will cancel a running acquisition operation */ -static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { reset_atmio16d(dev); @@ -527,8 +530,8 @@ static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevic } /* Mode 0 is used to get a single conversion on demand */ -static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, t; int chan; @@ -542,9 +545,9 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde gain = CR_RANGE(insn->chanspec); /* reset the Analog input circuitry */ - //outw( 0, dev->iobase+AD_CLEAR_REG ); + /* outw( 0, dev->iobase+AD_CLEAR_REG ); */ /* reset the Analog Input MUX Counter to 0 */ - //outw( 0, dev->iobase+MUX_CNTR_REG ); + /* outw( 0, dev->iobase+MUX_CNTR_REG ); */ /* set the Input MUX gain */ outw(chan | (gain << 6), dev->iobase + MUX_GAIN_REG); @@ -577,7 +580,7 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde } /* end waiting, now check if it timed out */ if (t == ATMIO16D_TIMEOUT) { - rt_printk("atmio16d: timeout\n"); + printk("atmio16d: timeout\n"); return -ETIME; } @@ -586,8 +589,8 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde return i; } -static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; #ifdef DEBUG1 @@ -601,8 +604,8 @@ static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subde return i; } -static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -636,8 +639,8 @@ static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subd return i; } -static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -652,8 +655,8 @@ static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subd return 2; } -static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int mask; @@ -706,7 +709,7 @@ static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_su options[12] - dac1 coding */ -static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned int irq; unsigned long iobase; @@ -726,9 +729,12 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * /* board name */ dev->board_name = boardtype->name; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct atmio16d_private))) < 0) + + ret = alloc_private(dev, sizeof(struct atmio16d_private)); + if (ret < 0) return ret; /* reset the atmio16d hardware */ @@ -737,8 +743,9 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * /* check if our interrupt is available and get it */ irq = it->options[1]; if (irq) { - if ((ret = comedi_request_irq(irq, atmio16d_interrupt, - 0, "atmio16d", dev)) < 0) { + + ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev); + if (ret < 0) { printk("failed to allocate irq %u\n", irq); return ret; } @@ -841,7 +848,7 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int atmio16d_detach(struct comedi_device * dev) +static int atmio16d_detach(struct comedi_device *dev) { printk("comedi%d: atmio16d: remove\n", dev->minor); @@ -849,7 +856,7 @@ static int atmio16d_detach(struct comedi_device * dev) subdev_8255_cleanup(dev, dev->subdevices + 3); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); reset_atmio16d(dev); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 61a31ad2d030..e34948205320 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -41,6 +41,7 @@ emu as port A output, port B input, port C N/A). IRQ is assigned but not used. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -53,36 +54,36 @@ IRQ is assigned but not used. static struct pcmcia_device *pcmcia_cur_dev = NULL; -#define DIO700_SIZE 8 // size of io region used by board +#define DIO700_SIZE 8 /* size of io region used by board */ -static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dio700_detach(struct comedi_device * dev); +static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dio700_detach(struct comedi_device *dev); enum dio700_bustype { pcmcia_bustype }; struct dio700_board { const char *name; - int device_id; // device id for pcmcia board - enum dio700_bustype bustype; // PCMCIA - int have_dio; // have daqcard-700 dio - // function pointers so we can use inb/outb or readb/writeb - // as appropriate + int device_id; /* device id for pcmcia board */ + enum dio700_bustype bustype; /* PCMCIA */ + int have_dio; /* have daqcard-700 dio */ + /* function pointers so we can use inb/outb or readb/writeb */ + /* as appropriate */ unsigned int (*read_byte) (unsigned int address); void (*write_byte) (unsigned int byte, unsigned int address); }; static const struct dio700_board dio700_boards[] = { { - name: "daqcard-700", - device_id:0x4743,// 0x10b is manufacturer id, 0x4743 is device id - bustype: pcmcia_bustype, - have_dio:1, + .name = "daqcard-700", + .device_id = 0x4743,/* 0x10b is manufacturer id, 0x4743 is device id */ + .bustype = pcmcia_bustype, + .have_dio = 1, }, { - name: "ni_daq_700", - device_id:0x4743,// 0x10b is manufacturer id, 0x4743 is device id - bustype: pcmcia_bustype, - have_dio:1, + .name = "ni_daq_700", + .device_id = 0x4743,/* 0x10b is manufacturer id, 0x4743 is device id */ + .bustype = pcmcia_bustype, + .have_dio = 1, }, }; @@ -100,13 +101,13 @@ struct dio700_private { #define devpriv ((struct dio700_private *)dev->private) static struct comedi_driver driver_dio700 = { - driver_name:"ni_daq_700", - module:THIS_MODULE, - attach:dio700_attach, - detach:dio700_detach, - num_names:sizeof(dio700_boards) / sizeof(struct dio700_board), - board_name:&dio700_boards[0].name, - offset:sizeof(struct dio700_board), + .driver_name = "ni_daq_700", + .module = THIS_MODULE, + .attach = dio700_attach, + .detach = dio700_detach, + .num_names = ARRAY_SIZE(dio700_boards), + .board_name = &dio700_boards[0].name, + .offset = sizeof(struct dio700_board), }; /* the real driver routines */ @@ -128,9 +129,9 @@ struct subdev_700_struct { #define CALLBACK_FUNC (((struct subdev_700_struct *)s->private)->cb_func) #define subdevpriv ((struct subdev_700_struct *)s->private) -static void do_config(struct comedi_device * dev, struct comedi_subdevice * s); +static void do_config(struct comedi_device *dev, struct comedi_subdevice *s); -void subdev_700_interrupt(struct comedi_device * dev, struct comedi_subdevice * s) +void subdev_700_interrupt(struct comedi_device *dev, struct comedi_subdevice *s) { short d; @@ -155,8 +156,8 @@ static int subdev_700_cb(int dir, int port, int data, unsigned long arg) } } -static int subdev_700_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int subdev_700_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -173,8 +174,8 @@ static int subdev_700_insn(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int subdev_700_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int subdev_700_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { @@ -196,13 +197,13 @@ static int subdev_700_insn_config(struct comedi_device * dev, struct comedi_subd return 1; } -static void do_config(struct comedi_device * dev, struct comedi_subdevice * s) +static void do_config(struct comedi_device *dev, struct comedi_subdevice *s) { /* use powerup defaults */ return; } -static int subdev_700_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int subdev_700_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -276,21 +277,21 @@ static int subdev_700_cmdtest(struct comedi_device * dev, struct comedi_subdevic return 0; } -static int subdev_700_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int subdev_700_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { /* FIXME */ return 0; } -static int subdev_700_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int subdev_700_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { /* FIXME */ return 0; } -int subdev_700_init(struct comedi_device * dev, struct comedi_subdevice * s, int (*cb) (int, +int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), unsigned long arg) { s->type = COMEDI_SUBD_DIO; @@ -319,7 +320,7 @@ int subdev_700_init(struct comedi_device * dev, struct comedi_subdevice * s, int return 0; } -int subdev_700_init_irq(struct comedi_device * dev, struct comedi_subdevice * s, +int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), unsigned long arg) { int ret; @@ -337,7 +338,7 @@ int subdev_700_init_irq(struct comedi_device * dev, struct comedi_subdevice * s, return 0; } -void subdev_700_cleanup(struct comedi_device * dev, struct comedi_subdevice * s) +void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { if (s->private) { if (subdevpriv->have_irq) { @@ -352,7 +353,7 @@ EXPORT_SYMBOL(subdev_700_init_irq); EXPORT_SYMBOL(subdev_700_cleanup); EXPORT_SYMBOL(subdev_700_interrupt); -static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = 0; @@ -365,7 +366,7 @@ static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * i if (alloc_private(dev, sizeof(struct dio700_private)) < 0) return -ENOMEM; - // get base address, irq etc. based on bustype + /* get base address, irq etc. based on bustype */ switch (thisboard->bustype) { case pcmcia_bustype: link = pcmcia_cur_dev; /* XXX hack */ @@ -415,7 +416,7 @@ static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; }; -static int dio700_detach(struct comedi_device * dev) +static int dio700_detach(struct comedi_device *dev) { printk("comedi%d: ni_daq_700: cs-remove\n", dev->minor); @@ -425,12 +426,12 @@ static int dio700_detach(struct comedi_device * dev) if (thisboard->bustype != pcmcia_bustype && dev->iobase) release_region(dev->iobase, DIO700_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; }; -// PCMCIA crap +/* PCMCIA crap */ /* All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If @@ -594,15 +595,21 @@ static void dio700_config(struct pcmcia_device *link) tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) { + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) { + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) { cs_error(link, GetTupleData, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) { + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) { cs_error(link, ParseTuple, last_ret); goto cs_failed; } @@ -622,7 +629,8 @@ static void dio700_config(struct pcmcia_device *link) will only use the CIS to fill in implementation-defined details. */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) { + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret != 0) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } @@ -692,7 +700,9 @@ static void dio700_config(struct pcmcia_device *link) break; next_entry: - if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) { + + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetNextTuple, last_ret); goto cs_failed; } @@ -703,18 +713,21 @@ static void dio700_config(struct pcmcia_device *link) handler to the interrupt, unless the 'Handler' member of the irq structure is initialized. */ - if (link->conf.Attributes & CONF_ENABLE_IRQ) - if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) { + if (link->conf.Attributes & CONF_ENABLE_IRQ) { + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) { cs_error(link, RequestIRQ, last_ret); goto cs_failed; } + } /* This actually configures the PCMCIA socket -- setting up the I/O windows and the interrupt mapping, and putting the card and host interface into "Memory and IO" mode. */ - if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) { + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret != 0) { cs_error(link, RequestConfiguration, last_ret); goto cs_failed; } diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index daec5c4b4c95..a8ac02febc66 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -37,9 +37,10 @@ This is just a wrapper around the 8255.o driver to properly handle the PCMCIA interface. */ -//#define LABPC_DEBUG // enable debugging messages +/* #define LABPC_DEBUG */ /* enable debugging messages */ #undef LABPC_DEBUG +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -54,42 +55,42 @@ the PCMCIA interface. static struct pcmcia_device *pcmcia_cur_dev = NULL; -#define DIO24_SIZE 4 // size of io region used by board +#define DIO24_SIZE 4 /* size of io region used by board */ -static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dio24_detach(struct comedi_device * dev); +static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dio24_detach(struct comedi_device *dev); enum dio24_bustype { pcmcia_bustype }; -typedef struct dio24_board_struct { +struct dio24_board_struct { const char *name; - int device_id; // device id for pcmcia board - enum dio24_bustype bustype; // PCMCIA - int have_dio; // have 8255 chip - // function pointers so we can use inb/outb or readb/writeb as appropriate + int device_id; /* device id for pcmcia board */ + enum dio24_bustype bustype; /* PCMCIA */ + int have_dio; /* have 8255 chip */ + /* function pointers so we can use inb/outb or readb/writeb as appropriate */ unsigned int (*read_byte) (unsigned int address); void (*write_byte) (unsigned int byte, unsigned int address); -} dio24_board; +}; -static const dio24_board dio24_boards[] = { +static const struct dio24_board_struct dio24_boards[] = { { - name: "daqcard-dio24", - device_id:0x475c,// 0x10b is manufacturer id, 0x475c is device id - bustype: pcmcia_bustype, - have_dio:1, + .name = "daqcard-dio24", + .device_id = 0x475c,/* 0x10b is manufacturer id, 0x475c is device id */ + .bustype = pcmcia_bustype, + .have_dio = 1, }, { - name: "ni_daq_dio24", - device_id:0x475c,// 0x10b is manufacturer id, 0x475c is device id - bustype: pcmcia_bustype, - have_dio:1, + .name = "ni_daq_dio24", + .device_id = 0x475c,/* 0x10b is manufacturer id, 0x475c is device id */ + .bustype = pcmcia_bustype, + .have_dio = 1, }, }; /* * Useful for shorthand access to the particular board structure */ -#define thisboard ((const dio24_board *)dev->board_ptr) +#define thisboard ((const struct dio24_board_struct *)dev->board_ptr) struct dio24_private { @@ -100,16 +101,16 @@ struct dio24_private { #define devpriv ((struct dio24_private *)dev->private) static struct comedi_driver driver_dio24 = { - driver_name:"ni_daq_dio24", - module:THIS_MODULE, - attach:dio24_attach, - detach:dio24_detach, - num_names:sizeof(dio24_boards) / sizeof(dio24_board), - board_name:&dio24_boards[0].name, - offset:sizeof(dio24_board), + .driver_name = "ni_daq_dio24", + .module = THIS_MODULE, + .attach = dio24_attach, + .detach = dio24_detach, + .num_names = ARRAY_SIZE(dio24_boards), + .board_name = &dio24_boards[0].name, + .offset = sizeof(struct dio24_board_struct), }; -static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase = 0; @@ -122,7 +123,7 @@ static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it if (alloc_private(dev, sizeof(struct dio24_private)) < 0) return -ENOMEM; - // get base address, irq etc. based on bustype + /* get base address, irq etc. based on bustype */ switch (thisboard->bustype) { case pcmcia_bustype: link = pcmcia_cur_dev; /* XXX hack */ @@ -172,7 +173,7 @@ static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it return 0; }; -static int dio24_detach(struct comedi_device * dev) +static int dio24_detach(struct comedi_device *dev) { printk("comedi%d: ni_daq_dio24: remove\n", dev->minor); @@ -182,12 +183,12 @@ static int dio24_detach(struct comedi_device * dev) if (thisboard->bustype != pcmcia_bustype && dev->iobase) release_region(dev->iobase, DIO24_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; }; -// PCMCIA crap +/* PCMCIA crap */ /* All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If @@ -236,12 +237,12 @@ static void dio24_cs_detach(struct pcmcia_device *); static const dev_info_t dev_info = "ni_daq_dio24"; -typedef struct local_info_t { +struct local_info_t { struct pcmcia_device *link; dev_node_t node; int stop; struct bus_operations *bus; -} local_info_t; +}; /*====================================================================== @@ -257,14 +258,14 @@ typedef struct local_info_t { static int dio24_cs_attach(struct pcmcia_device *link) { - local_info_t *local; + struct local_info_t *local; printk(KERN_INFO "ni_daq_dio24: HOLA SOY YO - CS-attach!\n"); DEBUG(0, "dio24_cs_attach()\n"); /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(local_info_t), GFP_KERNEL); + local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL); if (!local) return -ENOMEM; local->link = link; @@ -309,7 +310,7 @@ static void dio24_cs_detach(struct pcmcia_device *link) DEBUG(0, "dio24_cs_detach(0x%p)\n", link); if (link->dev_node) { - ((local_info_t *) link->priv)->stop = 1; + ((struct local_info_t *) link->priv)->stop = 1; dio24_release(link); } @@ -329,7 +330,7 @@ static void dio24_cs_detach(struct pcmcia_device *link) static void dio24_config(struct pcmcia_device *link) { - local_info_t *dev = link->priv; + struct local_info_t *dev = link->priv; tuple_t tuple; cisparse_t parse; int last_ret; @@ -351,15 +352,21 @@ static void dio24_config(struct pcmcia_device *link) tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) { + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) { + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) { cs_error(link, GetTupleData, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) { + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) { cs_error(link, ParseTuple, last_ret); goto cs_failed; } @@ -379,7 +386,9 @@ static void dio24_config(struct pcmcia_device *link) will only use the CIS to fill in implementation-defined details. */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) { + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } @@ -449,7 +458,9 @@ static void dio24_config(struct pcmcia_device *link) break; next_entry: - if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) { + + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetNextTuple, last_ret); goto cs_failed; } @@ -460,18 +471,21 @@ static void dio24_config(struct pcmcia_device *link) handler to the interrupt, unless the 'Handler' member of the irq structure is initialized. */ - if (link->conf.Attributes & CONF_ENABLE_IRQ) - if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) { + if (link->conf.Attributes & CONF_ENABLE_IRQ) { + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) { cs_error(link, RequestIRQ, last_ret); goto cs_failed; } + } /* This actually configures the PCMCIA socket -- setting up the I/O windows and the interrupt mapping, and putting the card and host interface into "Memory and IO" mode. */ - if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) { + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret) { cs_error(link, RequestConfiguration, last_ret); goto cs_failed; } @@ -529,7 +543,7 @@ static void dio24_release(struct pcmcia_device *link) static int dio24_cs_suspend(struct pcmcia_device *link) { - local_info_t *local = link->priv; + struct local_info_t *local = link->priv; /* Mark the device as stopped, to block IO until later */ local->stop = 1; @@ -538,7 +552,7 @@ static int dio24_cs_suspend(struct pcmcia_device *link) static int dio24_cs_resume(struct pcmcia_device *link) { - local_info_t *local = link->priv; + struct local_info_t *local = link->priv; local->stop = 0; return 0; diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 37898d8474cd..30e11f46a640 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -74,8 +74,9 @@ NI manuals: */ #undef LABPC_DEBUG -//#define LABPC_DEBUG // enable debugging messages +/* #define LABPC_DEBUG enable debugging messages */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -89,120 +90,120 @@ NI manuals: #define DRV_NAME "ni_labpc" -#define LABPC_SIZE 32 // size of io region used by board -#define LABPC_TIMER_BASE 500 // 2 MHz master clock +#define LABPC_SIZE 32 /* size of io region used by board */ +#define LABPC_TIMER_BASE 500 /* 2 MHz master clock */ /* Registers for the lab-pc+ */ -//write-only registers +/* write-only registers */ #define COMMAND1_REG 0x0 #define ADC_GAIN_MASK (0x7 << 4) #define ADC_CHAN_BITS(x) ((x) & 0x7) -#define ADC_SCAN_EN_BIT 0x80 // enables multi channel scans +#define ADC_SCAN_EN_BIT 0x80 /* enables multi channel scans */ #define COMMAND2_REG 0x1 -#define PRETRIG_BIT 0x1 // enable pretriggering (used in conjunction with SWTRIG) -#define HWTRIG_BIT 0x2 // enable paced conversions on external trigger -#define SWTRIG_BIT 0x4 // enable paced conversions -#define CASCADE_BIT 0x8 // use two cascaded counters for pacing +#define PRETRIG_BIT 0x1 /* enable pretriggering (used in conjunction with SWTRIG) */ +#define HWTRIG_BIT 0x2 /* enable paced conversions on external trigger */ +#define SWTRIG_BIT 0x4 /* enable paced conversions */ +#define CASCADE_BIT 0x8 /* use two cascaded counters for pacing */ #define DAC_PACED_BIT(channel) (0x40 << ((channel) & 0x1)) #define COMMAND3_REG 0x2 -#define DMA_EN_BIT 0x1 // enable dma transfers -#define DIO_INTR_EN_BIT 0x2 // enable interrupts for 8255 -#define DMATC_INTR_EN_BIT 0x4 // enable dma terminal count interrupt -#define TIMER_INTR_EN_BIT 0x8 // enable timer interrupt -#define ERR_INTR_EN_BIT 0x10 // enable error interrupt -#define ADC_FNE_INTR_EN_BIT 0x20 // enable fifo not empty interrupt +#define DMA_EN_BIT 0x1 /* enable dma transfers */ +#define DIO_INTR_EN_BIT 0x2 /* enable interrupts for 8255 */ +#define DMATC_INTR_EN_BIT 0x4 /* enable dma terminal count interrupt */ +#define TIMER_INTR_EN_BIT 0x8 /* enable timer interrupt */ +#define ERR_INTR_EN_BIT 0x10 /* enable error interrupt */ +#define ADC_FNE_INTR_EN_BIT 0x20 /* enable fifo not empty interrupt */ #define ADC_CONVERT_REG 0x3 #define DAC_LSB_REG(channel) (0x4 + 2 * ((channel) & 0x1)) #define DAC_MSB_REG(channel) (0x5 + 2 * ((channel) & 0x1)) #define ADC_CLEAR_REG 0x8 #define DMATC_CLEAR_REG 0xa #define TIMER_CLEAR_REG 0xc -#define COMMAND6_REG 0xe // 1200 boards only -#define ADC_COMMON_BIT 0x1 // select ground or common-mode reference -#define ADC_UNIP_BIT 0x2 // adc unipolar -#define DAC_UNIP_BIT(channel) (0x4 << ((channel) & 0x1)) // dac unipolar -#define ADC_FHF_INTR_EN_BIT 0x20 // enable fifo half full interrupt -#define A1_INTR_EN_BIT 0x40 // enable interrupt on end of hardware count -#define ADC_SCAN_UP_BIT 0x80 // scan up from channel zero instead of down to zero +#define COMMAND6_REG 0xe /* 1200 boards only */ +#define ADC_COMMON_BIT 0x1 /* select ground or common-mode reference */ +#define ADC_UNIP_BIT 0x2 /* adc unipolar */ +#define DAC_UNIP_BIT(channel) (0x4 << ((channel) & 0x1)) /* dac unipolar */ +#define ADC_FHF_INTR_EN_BIT 0x20 /* enable fifo half full interrupt */ +#define A1_INTR_EN_BIT 0x40 /* enable interrupt on end of hardware count */ +#define ADC_SCAN_UP_BIT 0x80 /* scan up from channel zero instead of down to zero */ #define COMMAND4_REG 0xf -#define INTERVAL_SCAN_EN_BIT 0x1 // enables 'interval' scanning -#define EXT_SCAN_EN_BIT 0x2 // enables external signal on counter b1 output to trigger scan -#define EXT_CONVERT_OUT_BIT 0x4 // chooses direction (output or input) for EXTCONV* line -#define ADC_DIFF_BIT 0x8 // chooses differential inputs for adc (in conjunction with board jumper) +#define INTERVAL_SCAN_EN_BIT 0x1 /* enables 'interval' scanning */ +#define EXT_SCAN_EN_BIT 0x2 /* enables external signal on counter b1 output to trigger scan */ +#define EXT_CONVERT_OUT_BIT 0x4 /* chooses direction (output or input) for EXTCONV* line */ +#define ADC_DIFF_BIT 0x8 /* chooses differential inputs for adc (in conjunction with board jumper) */ #define EXT_CONVERT_DISABLE_BIT 0x10 -#define COMMAND5_REG 0x1c // 1200 boards only, calibration stuff -#define EEPROM_WRITE_UNPROTECT_BIT 0x4 // enable eeprom for write -#define DITHER_EN_BIT 0x8 // enable dithering -#define CALDAC_LOAD_BIT 0x10 // load calibration dac -#define SCLOCK_BIT 0x20 // serial clock - rising edge writes, falling edge reads -#define SDATA_BIT 0x40 // serial data bit for writing to eeprom or calibration dacs -#define EEPROM_EN_BIT 0x80 // enable eeprom for read/write +#define COMMAND5_REG 0x1c /* 1200 boards only, calibration stuff */ +#define EEPROM_WRITE_UNPROTECT_BIT 0x4 /* enable eeprom for write */ +#define DITHER_EN_BIT 0x8 /* enable dithering */ +#define CALDAC_LOAD_BIT 0x10 /* load calibration dac */ +#define SCLOCK_BIT 0x20 /* serial clock - rising edge writes, falling edge reads */ +#define SDATA_BIT 0x40 /* serial data bit for writing to eeprom or calibration dacs */ +#define EEPROM_EN_BIT 0x80 /* enable eeprom for read/write */ #define INTERVAL_COUNT_REG 0x1e #define INTERVAL_LOAD_REG 0x1f #define INTERVAL_LOAD_BITS 0x1 -// read-only registers +/* read-only registers */ #define STATUS1_REG 0x0 -#define DATA_AVAIL_BIT 0x1 // data is available in fifo -#define OVERRUN_BIT 0x2 // overrun has occurred -#define OVERFLOW_BIT 0x4 // fifo overflow -#define TIMER_BIT 0x8 // timer interrupt has occured -#define DMATC_BIT 0x10 // dma terminal count has occured -#define EXT_TRIG_BIT 0x40 // external trigger has occured -#define STATUS2_REG 0x1d // 1200 boards only -#define EEPROM_OUT_BIT 0x1 // programmable eeprom serial output -#define A1_TC_BIT 0x2 // counter A1 terminal count -#define FNHF_BIT 0x4 // fifo not half full +#define DATA_AVAIL_BIT 0x1 /* data is available in fifo */ +#define OVERRUN_BIT 0x2 /* overrun has occurred */ +#define OVERFLOW_BIT 0x4 /* fifo overflow */ +#define TIMER_BIT 0x8 /* timer interrupt has occured */ +#define DMATC_BIT 0x10 /* dma terminal count has occured */ +#define EXT_TRIG_BIT 0x40 /* external trigger has occured */ +#define STATUS2_REG 0x1d /* 1200 boards only */ +#define EEPROM_OUT_BIT 0x1 /* programmable eeprom serial output */ +#define A1_TC_BIT 0x2 /* counter A1 terminal count */ +#define FNHF_BIT 0x4 /* fifo not half full */ #define ADC_FIFO_REG 0xa #define DIO_BASE_REG 0x10 #define COUNTER_A_BASE_REG 0x14 #define COUNTER_A_CONTROL_REG (COUNTER_A_BASE_REG + 0x3) -#define INIT_A0_BITS 0x14 // check modes put conversion pacer output in harmless state (a0 mode 2) -#define INIT_A1_BITS 0x70 // put hardware conversion counter output in harmless state (a1 mode 0) +#define INIT_A0_BITS 0x14 /* check modes put conversion pacer output in harmless state (a0 mode 2) */ +#define INIT_A1_BITS 0x70 /* put hardware conversion counter output in harmless state (a1 mode 0) */ #define COUNTER_B_BASE_REG 0x18 -static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG); -static int labpc_drain_fifo(struct comedi_device * dev); -static void labpc_drain_dma(struct comedi_device * dev); -static void handle_isa_dma(struct comedi_device * dev); -static void labpc_drain_dregs(struct comedi_device * dev); -static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static irqreturn_t labpc_interrupt(int irq, void *d); +static int labpc_drain_fifo(struct comedi_device *dev); +static void labpc_drain_dma(struct comedi_device *dev); +static void handle_isa_dma(struct comedi_device *dev); +static void labpc_drain_dregs(struct comedi_device *dev); +static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int labpc_eeprom_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd); -static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd); +static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd); #ifdef CONFIG_COMEDI_PCI static int labpc_find_device(struct comedi_device *dev, int bus, int slot); #endif static int labpc_dio_mem_callback(int dir, int port, int data, unsigned long arg); -static void labpc_serial_out(struct comedi_device * dev, unsigned int value, +static void labpc_serial_out(struct comedi_device *dev, unsigned int value, unsigned int num_bits); -static unsigned int labpc_serial_in(struct comedi_device * dev); -static unsigned int labpc_eeprom_read(struct comedi_device * dev, +static unsigned int labpc_serial_in(struct comedi_device *dev); +static unsigned int labpc_eeprom_read(struct comedi_device *dev, unsigned int address); -static unsigned int labpc_eeprom_read_status(struct comedi_device * dev); -static unsigned int labpc_eeprom_write(struct comedi_device * dev, +static unsigned int labpc_eeprom_read_status(struct comedi_device *dev); +static unsigned int labpc_eeprom_write(struct comedi_device *dev, unsigned int address, unsigned int value); -static void write_caldac(struct comedi_device * dev, unsigned int channel, +static void write_caldac(struct comedi_device *dev, unsigned int channel, unsigned int value); enum scan_mode { @@ -212,9 +213,9 @@ enum scan_mode { MODE_MULT_CHAN_DOWN, }; -//analog input ranges +/* analog input ranges */ #define NUM_LABPC_PLUS_AI_RANGES 16 -// indicates unipolar ranges +/* indicates unipolar ranges */ static const int labpc_plus_is_unipolar[NUM_LABPC_PLUS_AI_RANGES] = { 0, 0, @@ -234,7 +235,7 @@ static const int labpc_plus_is_unipolar[NUM_LABPC_PLUS_AI_RANGES] = { 1, }; -// map range index to gain bits +/* map range index to gain bits */ static const int labpc_plus_ai_gain_bits[NUM_LABPC_PLUS_AI_RANGES] = { 0x00, 0x10, @@ -276,7 +277,7 @@ static const struct comedi_lrange range_labpc_plus_ai = { }; #define NUM_LABPC_1200_AI_RANGES 14 -// indicates unipolar ranges +/* indicates unipolar ranges */ const int labpc_1200_is_unipolar[NUM_LABPC_1200_AI_RANGES] = { 0, 0, @@ -294,7 +295,7 @@ const int labpc_1200_is_unipolar[NUM_LABPC_1200_AI_RANGES] = { 1, }; -// map range index to gain bits +/* map range index to gain bits */ const int labpc_1200_ai_gain_bits[NUM_LABPC_1200_AI_RANGES] = { 0x00, 0x20, @@ -331,7 +332,7 @@ const struct comedi_lrange range_labpc_1200_ai = { } }; -//analog output ranges +/* analog output ranges */ #define AO_RANGE_IS_UNIPOLAR 0x1 static const struct comedi_lrange range_labpc_ao = { 2, @@ -360,58 +361,58 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address) writeb(byte, (void *)address); } -static const labpc_board labpc_boards[] = { +static const struct labpc_board_struct labpc_boards[] = { { - name: "lab-pc-1200", - ai_speed:10000, - bustype: isa_bustype, - register_layout:labpc_1200_layout, - has_ao: 1, - ai_range_table:&range_labpc_1200_ai, - ai_range_code:labpc_1200_ai_gain_bits, - ai_range_is_unipolar:labpc_1200_is_unipolar, - ai_scan_up:1, - memory_mapped_io:0, + .name = "lab-pc-1200", + .ai_speed = 10000, + .bustype = isa_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + .ai_scan_up = 1, + .memory_mapped_io = 0, }, { - name: "lab-pc-1200ai", - ai_speed:10000, - bustype: isa_bustype, - register_layout:labpc_1200_layout, - has_ao: 0, - ai_range_table:&range_labpc_1200_ai, - ai_range_code:labpc_1200_ai_gain_bits, - ai_range_is_unipolar:labpc_1200_is_unipolar, - ai_scan_up:1, - memory_mapped_io:0, + .name = "lab-pc-1200ai", + .ai_speed = 10000, + .bustype = isa_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 0, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + .ai_scan_up = 1, + .memory_mapped_io = 0, }, { - name: "lab-pc+", - ai_speed:12000, - bustype: isa_bustype, - register_layout:labpc_plus_layout, - has_ao: 1, - ai_range_table:&range_labpc_plus_ai, - ai_range_code:labpc_plus_ai_gain_bits, - ai_range_is_unipolar:labpc_plus_is_unipolar, - ai_scan_up:0, - memory_mapped_io:0, + .name = "lab-pc+", + .ai_speed = 12000, + .bustype = isa_bustype, + .register_layout = labpc_plus_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_plus_ai, + .ai_range_code = labpc_plus_ai_gain_bits, + .ai_range_is_unipolar = labpc_plus_is_unipolar, + .ai_scan_up = 0, + .memory_mapped_io = 0, }, #ifdef CONFIG_COMEDI_PCI { - name: "pci-1200", - device_id:0x161, - ai_speed:10000, - bustype: pci_bustype, - register_layout:labpc_1200_layout, - has_ao: 1, - ai_range_table:&range_labpc_1200_ai, - ai_range_code:labpc_1200_ai_gain_bits, - ai_range_is_unipolar:labpc_1200_is_unipolar, - ai_scan_up:1, - memory_mapped_io:1, + .name = "pci-1200", + .device_id = 0x161, + .ai_speed = 10000, + .bustype = pci_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + .ai_scan_up = 1, + .memory_mapped_io = 1, }, - // dummy entry so pci board works when comedi_config is passed driver name + /* dummy entry so pci board works when comedi_config is passed driver name */ { .name = DRV_NAME, .bustype = pci_bustype, @@ -422,21 +423,21 @@ static const labpc_board labpc_boards[] = { /* * Useful for shorthand access to the particular board structure */ -#define thisboard ((labpc_board *)dev->board_ptr) +#define thisboard ((struct labpc_board_struct *)dev->board_ptr) -static const int dma_buffer_size = 0xff00; // size in bytes of dma buffer -static const int sample_size = 2; // 2 bytes per sample +static const int dma_buffer_size = 0xff00; /* size in bytes of dma buffer */ +static const int sample_size = 2; /* 2 bytes per sample */ -#define devpriv ((labpc_private *)dev->private) +#define devpriv ((struct labpc_private *)dev->private) static struct comedi_driver driver_labpc = { .driver_name = DRV_NAME, .module = THIS_MODULE, .attach = labpc_attach, .detach = labpc_common_detach, - .num_names = sizeof(labpc_boards) / sizeof(labpc_board), + .num_names = ARRAY_SIZE(labpc_boards), .board_name = &labpc_boards[0].name, - .offset = sizeof(labpc_board), + .offset = sizeof(struct labpc_board_struct), }; #ifdef CONFIG_COMEDI_PCI @@ -448,7 +449,7 @@ static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = { MODULE_DEVICE_TABLE(pci, labpc_pci_table); #endif /* CONFIG_COMEDI_PCI */ -static inline int labpc_counter_load(struct comedi_device * dev, +static inline int labpc_counter_load(struct comedi_device *dev, unsigned long base_address, unsigned int counter_number, unsigned int count, unsigned int mode) { @@ -459,7 +460,7 @@ static inline int labpc_counter_load(struct comedi_device * dev, return i8254_load(base_address, 0, counter_number, count, mode); } -int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, +int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, unsigned int irq, unsigned int dma_chan) { struct comedi_subdevice *s; @@ -481,7 +482,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, printk("io base address is zero!\n"); return -EINVAL; } - // request io regions for isa boards + /* request io regions for isa boards */ if (thisboard->bustype == isa_bustype) { /* check if io addresses are available */ if (!request_region(iobase, LABPC_SIZE, @@ -499,7 +500,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, devpriv->read_byte = labpc_inb; devpriv->write_byte = labpc_outb; } - // initialize board's command registers + /* initialize board's command registers */ devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG); devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); @@ -516,7 +517,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, isr_flags = 0; if (thisboard->bustype == pci_bustype) isr_flags |= IRQF_SHARED; - if (comedi_request_irq(irq, labpc_interrupt, isr_flags, + if (request_irq(irq, labpc_interrupt, isr_flags, driver_labpc.driver_name, dev)) { printk("unable to allocate irq %u\n", irq); return -EINVAL; @@ -524,12 +525,12 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, } dev->irq = irq; - // grab dma channel + /* grab dma channel */ if (dma_chan > 3) { printk(" invalid dma channel %u\n", dma_chan); return -EINVAL; } else if (dma_chan) { - // allocate dma buffer + /* allocate dma buffer */ devpriv->dma_buffer = kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA); if (devpriv->dma_buffer == NULL) { @@ -562,7 +563,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, SDF_CMD_READ; s->n_chan = 8; s->len_chanlist = 8; - s->maxdata = (1 << 12) - 1; // 12 bit resolution + s->maxdata = (1 << 12) - 1; /* 12 bit resolution */ s->range_table = thisboard->ai_range_table; s->do_cmd = labpc_ai_cmd; s->do_cmdtest = labpc_ai_cmdtest; @@ -577,7 +578,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; s->n_chan = NUM_AO_CHAN; - s->maxdata = (1 << 12) - 1; // 12 bit resolution + s->maxdata = (1 << 12) - 1; /* 12 bit resolution */ s->range_table = &range_labpc_ao; s->insn_read = labpc_ao_rinsn; s->insn_write = labpc_ao_winsn; @@ -595,14 +596,14 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, /* 8255 dio */ s = dev->subdevices + 2; - // if board uses io memory we have to give a custom callback function to the 8255 driver + /* if board uses io memory we have to give a custom callback function to the 8255 driver */ if (thisboard->memory_mapped_io) subdev_8255_init(dev, s, labpc_dio_mem_callback, (unsigned long)(dev->iobase + DIO_BASE_REG)); else subdev_8255_init(dev, s, NULL, dev->iobase + DIO_BASE_REG); - // calibration subdevices for boards that have one + /* calibration subdevices for boards that have one */ s = dev->subdevices + 3; if (thisboard->register_layout == labpc_1200_layout) { s->type = COMEDI_SUBD_CALIB; @@ -643,7 +644,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, return 0; } -static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned long iobase = 0; unsigned int irq = 0; @@ -653,10 +654,10 @@ static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it #endif /* allocate and initialize dev->private */ - if (alloc_private(dev, sizeof(labpc_private)) < 0) + if (alloc_private(dev, sizeof(struct labpc_private)) < 0) return -ENOMEM; - // get base address, irq etc. based on bustype + /* get base address, irq etc. based on bustype */ switch (thisboard->bustype) { case isa_bustype: iobase = it->options[0]; @@ -692,7 +693,7 @@ static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it return labpc_common_attach(dev, iobase, irq, dma_chan); } -// adapted from ni_pcimio for finding mite based boards (pc-1200) +/* adapted from ni_pcimio for finding mite based boards (pc-1200) */ #ifdef CONFIG_COMEDI_PCI static int labpc_find_device(struct comedi_device *dev, int bus, int slot) { @@ -701,7 +702,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) for (mite = mite_devices; mite; mite = mite->next) { if (mite->used) continue; - // if bus/slot are specified then make sure we have the right bus/slot + /* if bus/slot are specified then make sure we have the right bus/slot */ if (bus || slot) { if (bus != mite->pcidev->bus->number || slot != PCI_SLOT(mite->pcidev->devfn)) @@ -712,7 +713,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) continue; if (mite_device_id(mite) == labpc_boards[i].device_id) { devpriv->mite = mite; - // fixup board pointer, in case we were using the dummy "ni_labpc" entry + /* fixup board pointer, in case we were using the dummy "ni_labpc" entry */ dev->board_ptr = &labpc_boards[i]; return 0; } @@ -724,7 +725,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) } #endif -int labpc_common_detach(struct comedi_device * dev) +int labpc_common_detach(struct comedi_device *dev) { printk("comedi%d: ni_labpc: detach\n", dev->minor); @@ -737,7 +738,7 @@ int labpc_common_detach(struct comedi_device * dev) if (devpriv->dma_chan) free_dma(devpriv->dma_chan); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (thisboard->bustype == isa_bustype && dev->iobase) release_region(dev->iobase, LABPC_SIZE); #ifdef CONFIG_COMEDI_PCI @@ -748,21 +749,21 @@ int labpc_common_detach(struct comedi_device * dev) return 0; }; -static void labpc_clear_adc_fifo(const struct comedi_device * dev) +static void labpc_clear_adc_fifo(const struct comedi_device *dev) { devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG); devpriv->read_byte(dev->iobase + ADC_FIFO_REG); devpriv->read_byte(dev->iobase + ADC_FIFO_REG); } -static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); devpriv->command3_bits = 0; devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); @@ -770,7 +771,7 @@ static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd * cmd) +static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd) { if (cmd->chanlist_len == 1) return MODE_SINGLE_CHAN; @@ -788,13 +789,13 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd * cmd) if (CR_CHAN(cmd->chanlist[0]) > CR_CHAN(cmd->chanlist[1])) return MODE_MULT_CHAN_DOWN; - rt_printk("ni_labpc: bug! this should never happen\n"); + printk("ni_labpc: bug! this should never happen\n"); return 0; } -static int labpc_ai_chanlist_invalid(const struct comedi_device * dev, - const struct comedi_cmd * cmd) +static int labpc_ai_chanlist_invalid(const struct comedi_device *dev, + const struct comedi_cmd *cmd) { int mode, channel, range, aref, i; @@ -844,7 +845,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device * dev, } break; default: - rt_printk("ni_labpc: bug! in chanlist check\n"); + printk("ni_labpc: bug! in chanlist check\n"); return 1; break; } @@ -865,7 +866,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device * dev, return 0; } -static int labpc_use_continuous_mode(const struct comedi_cmd * cmd) +static int labpc_use_continuous_mode(const struct comedi_cmd *cmd) { if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN) return 1; @@ -876,7 +877,7 @@ static int labpc_use_continuous_mode(const struct comedi_cmd * cmd) return 0; } -static unsigned int labpc_ai_convert_period(const struct comedi_cmd * cmd) +static unsigned int labpc_ai_convert_period(const struct comedi_cmd *cmd) { if (cmd->convert_src != TRIG_TIMER) return 0; @@ -888,7 +889,7 @@ static unsigned int labpc_ai_convert_period(const struct comedi_cmd * cmd) return cmd->convert_arg; } -static void labpc_set_ai_convert_period(struct comedi_cmd * cmd, unsigned int ns) +static void labpc_set_ai_convert_period(struct comedi_cmd *cmd, unsigned int ns) { if (cmd->convert_src != TRIG_TIMER) return; @@ -902,7 +903,7 @@ static void labpc_set_ai_convert_period(struct comedi_cmd * cmd, unsigned int ns cmd->convert_arg = ns; } -static unsigned int labpc_ai_scan_period(const struct comedi_cmd * cmd) +static unsigned int labpc_ai_scan_period(const struct comedi_cmd *cmd) { if (cmd->scan_begin_src != TRIG_TIMER) return 0; @@ -914,7 +915,7 @@ static unsigned int labpc_ai_scan_period(const struct comedi_cmd * cmd) return cmd->scan_begin_arg; } -static void labpc_set_ai_scan_period(struct comedi_cmd * cmd, unsigned int ns) +static void labpc_set_ai_scan_period(struct comedi_cmd *cmd, unsigned int ns) { if (cmd->scan_begin_src != TRIG_TIMER) return; @@ -926,8 +927,8 @@ static void labpc_set_ai_scan_period(struct comedi_cmd * cmd, unsigned int ns) cmd->scan_begin_arg = ns; } -static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, tmp2; @@ -980,7 +981,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE) err++; - // can't have external stop and start triggers at once + /* can't have external stop and start triggers at once */ if (cmd->start_src == TRIG_EXT && cmd->stop_src == TRIG_EXT) err++; @@ -1008,7 +1009,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice err++; } } - // make sure scan timing is not too fast + /* make sure scan timing is not too fast */ if (cmd->scan_begin_src == TRIG_TIMER) { if (cmd->convert_src == TRIG_TIMER && cmd->scan_begin_arg < @@ -1024,7 +1025,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice err++; } } - // stop source + /* stop source */ switch (cmd->stop_src) { case TRIG_COUNT: if (!cmd->stop_arg) { @@ -1038,7 +1039,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice err++; } break; - // TRIG_EXT doesn't care since it doesn't trigger off a numbered channel + /* TRIG_EXT doesn't care since it doesn't trigger off a numbered channel */ default: break; } @@ -1063,7 +1064,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int channel, range, aref; unsigned long irq_flags; @@ -1081,77 +1082,77 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) range = CR_RANGE(cmd->chanlist[0]); aref = CR_AREF(cmd->chanlist[0]); - // make sure board is disabled before setting up aquisition - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* make sure board is disabled before setting up aquisition */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); devpriv->command3_bits = 0; devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); - // initialize software conversion count + /* initialize software conversion count */ if (cmd->stop_src == TRIG_COUNT) { devpriv->count = cmd->stop_arg * cmd->chanlist_len; } - // setup hardware conversion counter + /* setup hardware conversion counter */ if (cmd->stop_src == TRIG_EXT) { - // load counter a1 with count of 3 (pc+ manual says this is minimum allowed) using mode 0 + /* load counter a1 with count of 3 (pc+ manual says this is minimum allowed) using mode 0 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, 1, 3, 0); if (ret < 0) { comedi_error(dev, "error loading counter a1"); return -1; } - } else // otherwise, just put a1 in mode 0 with no count to set its output low + } else /* otherwise, just put a1 in mode 0 with no count to set its output low */ devpriv->write_byte(INIT_A1_BITS, dev->iobase + COUNTER_A_CONTROL_REG); - // figure out what method we will use to transfer data - if (devpriv->dma_chan && // need a dma channel allocated - // dma unsafe at RT priority, and too much setup time for TRIG_WAKE_EOS for + /* figure out what method we will use to transfer data */ + if (devpriv->dma_chan && /* need a dma channel allocated */ + /* dma unsafe at RT priority, and too much setup time for TRIG_WAKE_EOS for */ (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) == 0 && - // only available on the isa boards + /* only available on the isa boards */ thisboard->bustype == isa_bustype) { xfer = isa_dma_transfer; - } else if (thisboard->register_layout == labpc_1200_layout && // pc-plus has no fifo-half full interrupt - // wake-end-of-scan should interrupt on fifo not empty + } else if (thisboard->register_layout == labpc_1200_layout && /* pc-plus has no fifo-half full interrupt */ + /* wake-end-of-scan should interrupt on fifo not empty */ (cmd->flags & TRIG_WAKE_EOS) == 0 && - // make sure we are taking more than just a few points + /* make sure we are taking more than just a few points */ (cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) { xfer = fifo_half_full_transfer; } else xfer = fifo_not_empty_transfer; devpriv->current_transfer = xfer; - // setup command6 register for 1200 boards + /* setup command6 register for 1200 boards */ if (thisboard->register_layout == labpc_1200_layout) { - // reference inputs to ground or common? + /* reference inputs to ground or common? */ if (aref != AREF_GROUND) devpriv->command6_bits |= ADC_COMMON_BIT; else devpriv->command6_bits &= ~ADC_COMMON_BIT; - // bipolar or unipolar range? + /* bipolar or unipolar range? */ if (thisboard->ai_range_is_unipolar[range]) devpriv->command6_bits |= ADC_UNIP_BIT; else devpriv->command6_bits &= ~ADC_UNIP_BIT; - // interrupt on fifo half full? + /* interrupt on fifo half full? */ if (xfer == fifo_half_full_transfer) devpriv->command6_bits |= ADC_FHF_INTR_EN_BIT; else devpriv->command6_bits &= ~ADC_FHF_INTR_EN_BIT; - // enable interrupt on counter a1 terminal count? + /* enable interrupt on counter a1 terminal count? */ if (cmd->stop_src == TRIG_EXT) devpriv->command6_bits |= A1_INTR_EN_BIT; else devpriv->command6_bits &= ~A1_INTR_EN_BIT; - // are we scanning up or down through channels? + /* are we scanning up or down through channels? */ if (labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_UP) devpriv->command6_bits |= ADC_SCAN_UP_BIT; else devpriv->command6_bits &= ~ADC_SCAN_UP_BIT; - // write to register + /* write to register */ devpriv->write_byte(devpriv->command6_bits, dev->iobase + COMMAND6_REG); } @@ -1162,23 +1163,23 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) channel = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]); else channel = CR_CHAN(cmd->chanlist[0]); - // munge channel bits for differential / scan disabled mode + /* munge channel bits for differential / scan disabled mode */ if (labpc_ai_scan_mode(cmd) != MODE_SINGLE_CHAN && aref == AREF_DIFF) channel *= 2; devpriv->command1_bits |= ADC_CHAN_BITS(channel); devpriv->command1_bits |= thisboard->ai_range_code[range]; devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG); - // manual says to set scan enable bit on second pass + /* manual says to set scan enable bit on second pass */ if (labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_UP || labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_DOWN) { devpriv->command1_bits |= ADC_SCAN_EN_BIT; /* need a brief delay before enabling scan, or scan list will get screwed when you switch * between scan up to scan down mode - dunno why */ - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG); } - // setup any external triggering/pacing (command4 register) + /* setup any external triggering/pacing (command4 register) */ devpriv->command4_bits = 0; if (cmd->convert_src != TRIG_EXT) devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT; @@ -1189,21 +1190,21 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) if (cmd->scan_begin_src == TRIG_EXT) devpriv->command4_bits |= EXT_SCAN_EN_BIT; } - // single-ended/differential + /* single-ended/differential */ if (aref == AREF_DIFF) devpriv->command4_bits |= ADC_DIFF_BIT; devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG); devpriv->write_byte(cmd->chanlist_len, dev->iobase + INTERVAL_COUNT_REG); - // load count + /* load count */ devpriv->write_byte(INTERVAL_LOAD_BITS, dev->iobase + INTERVAL_LOAD_REG); if (cmd->convert_src == TRIG_TIMER || cmd->scan_begin_src == TRIG_TIMER) { - // set up pacing + /* set up pacing */ labpc_adc_timing(dev, cmd); - // load counter b0 in mode 3 + /* load counter b0 in mode 3 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, 0, devpriv->divisor_b0, 3); if (ret < 0) { @@ -1211,9 +1212,9 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return -1; } } - // set up conversion pacing + /* set up conversion pacing */ if (labpc_ai_convert_period(cmd)) { - // load counter a0 in mode 2 + /* load counter a0 in mode 2 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, 0, devpriv->divisor_a0, 2); if (ret < 0) { @@ -1224,9 +1225,9 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) devpriv->write_byte(INIT_A0_BITS, dev->iobase + COUNTER_A_CONTROL_REG); - // set up scan pacing + /* set up scan pacing */ if (labpc_ai_scan_period(cmd)) { - // load counter b1 in mode 2 + /* load counter b1 in mode 2 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, 1, devpriv->divisor_b1, 2); if (ret < 0) { @@ -1237,7 +1238,7 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) labpc_clear_adc_fifo(dev); - // set up dma transfer + /* set up dma transfer */ if (xfer == isa_dma_transfer) { irq_flags = claim_dma_lock(); disable_dma(devpriv->dma_chan); @@ -1246,7 +1247,7 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) clear_dma_ff(devpriv->dma_chan); set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer)); - // set appropriate size of transfer + /* set appropriate size of transfer */ devpriv->dma_transfer_size = labpc_suggest_transfer_size(*cmd); if (cmd->stop_src == TRIG_COUNT && devpriv->count * sample_size < @@ -1257,25 +1258,25 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); enable_dma(devpriv->dma_chan); release_dma_lock(irq_flags); - // enable board's dma + /* enable board's dma */ devpriv->command3_bits |= DMA_EN_BIT | DMATC_INTR_EN_BIT; } else devpriv->command3_bits &= ~DMA_EN_BIT & ~DMATC_INTR_EN_BIT; - // enable error interrupts + /* enable error interrupts */ devpriv->command3_bits |= ERR_INTR_EN_BIT; - // enable fifo not empty interrupt? + /* enable fifo not empty interrupt? */ if (xfer == fifo_not_empty_transfer) devpriv->command3_bits |= ADC_FNE_INTR_EN_BIT; else devpriv->command3_bits &= ~ADC_FNE_INTR_EN_BIT; devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); - // startup aquisition + /* startup aquisition */ - // command2 reg - // use 2 cascaded counters for pacing - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* command2 reg */ + /* use 2 cascaded counters for pacing */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->command2_bits |= CASCADE_BIT; switch (cmd->start_src) { case TRIG_EXT: @@ -1303,13 +1304,13 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return -1; } devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } /* interrupt service routine */ -static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t labpc_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; @@ -1325,7 +1326,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) cmd = &async->cmd; async->events = 0; - // read board status + /* read board status */ devpriv->status1_bits = devpriv->read_byte(dev->iobase + STATUS1_REG); if (thisboard->register_layout == labpc_1200_layout) devpriv->status2_bits = @@ -1339,7 +1340,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) } if (devpriv->status1_bits & OVERRUN_BIT) { - // clear error interrupt + /* clear error interrupt */ devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; comedi_event(dev, s); @@ -1348,7 +1349,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) } if (devpriv->current_transfer == isa_dma_transfer) { - // if a dma terminal count of external stop trigger has occurred + /* if a dma terminal count of external stop trigger has occurred */ if (devpriv->status1_bits & DMATC_BIT || (thisboard->register_layout == labpc_1200_layout && devpriv->status2_bits & A1_TC_BIT)) { @@ -1359,19 +1360,19 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) if (devpriv->status1_bits & TIMER_BIT) { comedi_error(dev, "handled timer interrupt?"); - // clear it + /* clear it */ devpriv->write_byte(0x1, dev->iobase + TIMER_CLEAR_REG); } if (devpriv->status1_bits & OVERFLOW_BIT) { - // clear error interrupt + /* clear error interrupt */ devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; comedi_event(dev, s); comedi_error(dev, "overflow"); return IRQ_HANDLED; } - // handle external stop trigger + /* handle external stop trigger */ if (cmd->stop_src == TRIG_EXT) { if (devpriv->status2_bits & A1_TC_BIT) { labpc_drain_dregs(dev); @@ -1392,8 +1393,8 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -// read all available samples from ai fifo -static int labpc_drain_fifo(struct comedi_device * dev) +/* read all available samples from ai fifo */ +static int labpc_drain_fifo(struct comedi_device *dev) { unsigned int lsb, msb; short data; @@ -1405,7 +1406,7 @@ static int labpc_drain_fifo(struct comedi_device * dev) for (i = 0; (devpriv->status1_bits & DATA_AVAIL_BIT) && i < timeout; i++) { - // quit if we have all the data we want + /* quit if we have all the data we want */ if (async->cmd.stop_src == TRIG_COUNT) { if (devpriv->count == 0) break; @@ -1427,7 +1428,7 @@ static int labpc_drain_fifo(struct comedi_device * dev) return 0; } -static void labpc_drain_dma(struct comedi_device * dev) +static void labpc_drain_dma(struct comedi_device *dev) { struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; @@ -1444,7 +1445,7 @@ static void labpc_drain_dma(struct comedi_device * dev) * count and address get set correctly */ clear_dma_ff(devpriv->dma_chan); - // figure out how many points to read + /* figure out how many points to read */ max_points = devpriv->dma_transfer_size / sample_size; /* residue is the number of points left to be done on the dma * transfer. It should always be zero at this point unless @@ -1455,7 +1456,7 @@ static void labpc_drain_dma(struct comedi_device * dev) if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT) num_points = devpriv->count; - // figure out how many points will be stored next time + /* figure out how many points will be stored next time */ leftover = 0; if (async->cmd.stop_src != TRIG_COUNT) { leftover = devpriv->dma_transfer_size / sample_size; @@ -1472,7 +1473,7 @@ static void labpc_drain_dma(struct comedi_device * dev) if (async->cmd.stop_src == TRIG_COUNT) devpriv->count -= num_points; - // set address and count for next transfer + /* set address and count for next transfer */ set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer)); set_dma_count(devpriv->dma_chan, leftover * sample_size); release_dma_lock(flags); @@ -1480,19 +1481,19 @@ static void labpc_drain_dma(struct comedi_device * dev) async->events |= COMEDI_CB_BLOCK; } -static void handle_isa_dma(struct comedi_device * dev) +static void handle_isa_dma(struct comedi_device *dev) { labpc_drain_dma(dev); enable_dma(devpriv->dma_chan); - // clear dma tc interrupt + /* clear dma tc interrupt */ devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG); } /* makes sure all data aquired by board is transfered to comedi (used * when aquisition is terminated by stop_src == TRIG_EXT). */ -static void labpc_drain_dregs(struct comedi_device * dev) +static void labpc_drain_dregs(struct comedi_device *dev) { if (devpriv->current_transfer == isa_dma_transfer) labpc_drain_dma(dev); @@ -1500,8 +1501,8 @@ static void labpc_drain_dregs(struct comedi_device * dev) labpc_drain_fifo(dev); } -static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int chan, range; @@ -1509,13 +1510,13 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * int timeout = 1000; unsigned long flags; - // disable timed conversions - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* disable timed conversions */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // disable interrupt generation and dma + /* disable interrupt generation and dma */ devpriv->command3_bits = 0; devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); @@ -1524,41 +1525,41 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * chan = CR_CHAN(insn->chanspec); range = CR_RANGE(insn->chanspec); devpriv->command1_bits |= thisboard->ai_range_code[range]; - // munge channel bits for differential/scan disabled mode + /* munge channel bits for differential/scan disabled mode */ if (CR_AREF(insn->chanspec) == AREF_DIFF) chan *= 2; devpriv->command1_bits |= ADC_CHAN_BITS(chan); devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG); - // setup command6 register for 1200 boards + /* setup command6 register for 1200 boards */ if (thisboard->register_layout == labpc_1200_layout) { - // reference inputs to ground or common? + /* reference inputs to ground or common? */ if (CR_AREF(insn->chanspec) != AREF_GROUND) devpriv->command6_bits |= ADC_COMMON_BIT; else devpriv->command6_bits &= ~ADC_COMMON_BIT; - // bipolar or unipolar range? + /* bipolar or unipolar range? */ if (thisboard->ai_range_is_unipolar[range]) devpriv->command6_bits |= ADC_UNIP_BIT; else devpriv->command6_bits &= ~ADC_UNIP_BIT; - // don't interrupt on fifo half full + /* don't interrupt on fifo half full */ devpriv->command6_bits &= ~ADC_FHF_INTR_EN_BIT; - // don't enable interrupt on counter a1 terminal count? + /* don't enable interrupt on counter a1 terminal count? */ devpriv->command6_bits &= ~A1_INTR_EN_BIT; - // write to register + /* write to register */ devpriv->write_byte(devpriv->command6_bits, dev->iobase + COMMAND6_REG); } - // setup command4 register + /* setup command4 register */ devpriv->command4_bits = 0; devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT; - // single-ended/differential + /* single-ended/differential */ if (CR_AREF(insn->chanspec) == AREF_DIFF) devpriv->command4_bits |= ADC_DIFF_BIT; devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG); - // initialize pacer counter output to make sure it doesn't cause any problems + /* initialize pacer counter output to make sure it doesn't cause any problems */ devpriv->write_byte(INIT_A0_BITS, dev->iobase + COUNTER_A_CONTROL_REG); labpc_clear_adc_fifo(dev); @@ -1571,7 +1572,7 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * if (devpriv->read_byte(dev->iobase + STATUS1_REG) & DATA_AVAIL_BIT) break; - comedi_udelay(1); + udelay(1); } if (i == timeout) { comedi_error(dev, "timeout"); @@ -1585,9 +1586,9 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * return n; } -// analog output insn -static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* analog output insn */ +static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel, range; unsigned long flags; @@ -1595,56 +1596,56 @@ static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * channel = CR_CHAN(insn->chanspec); - // turn off pacing of analog output channel + /* turn off pacing of analog output channel */ /* note: hardware bug in daqcard-1200 means pacing cannot * be independently enabled/disabled for its the two channels */ - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); devpriv->command2_bits &= ~DAC_PACED_BIT(channel); devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - // set range + /* set range */ if (thisboard->register_layout == labpc_1200_layout) { range = CR_RANGE(insn->chanspec); if (range & AO_RANGE_IS_UNIPOLAR) devpriv->command6_bits |= DAC_UNIP_BIT(channel); else devpriv->command6_bits &= ~DAC_UNIP_BIT(channel); - // write to register + /* write to register */ devpriv->write_byte(devpriv->command6_bits, dev->iobase + COMMAND6_REG); } - // send data + /* send data */ lsb = data[0] & 0xff; msb = (data[0] >> 8) & 0xff; devpriv->write_byte(lsb, dev->iobase + DAC_LSB_REG(channel)); devpriv->write_byte(msb, dev->iobase + DAC_MSB_REG(channel)); - // remember value for readback + /* remember value for readback */ devpriv->ao_value[channel] = data[0]; return 1; } -// analog output readback insn -static int labpc_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +/* analog output readback insn */ +static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; return 1; } -static int labpc_calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int labpc_calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->caldac[CR_CHAN(insn->chanspec)]; return 1; } -static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int labpc_calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel = CR_CHAN(insn->chanspec); @@ -1652,21 +1653,21 @@ static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subd return 1; } -static int labpc_eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int labpc_eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->eeprom_data[CR_CHAN(insn->chanspec)]; return 1; } -static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int labpc_eeprom_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int channel = CR_CHAN(insn->chanspec); int ret; - // only allow writes to user area of eeprom + /* only allow writes to user area of eeprom */ if (channel < 16 || channel > 127) { printk("eeprom writes are only allowed to channels 16 through 127 (the pointer and user areas)"); return -EINVAL; @@ -1679,7 +1680,7 @@ static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_sub return 1; } -// utility function that suggests a dma transfer size in bytes +/* utility function that suggests a dma transfer size in bytes */ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd) { unsigned int size; @@ -1687,14 +1688,14 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd) if (cmd.convert_src == TRIG_TIMER) freq = 1000000000 / cmd.convert_arg; - // return some default value + /* return some default value */ else freq = 0xffffffff; - // make buffer fill in no more than 1/3 second + /* make buffer fill in no more than 1/3 second */ size = (freq / 3) * sample_size; - // set a minimum and maximum size allowed + /* set a minimum and maximum size allowed */ if (size > dma_buffer_size) size = dma_buffer_size - dma_buffer_size % sample_size; else if (size < sample_size) @@ -1703,16 +1704,16 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd) return size; } -// figures out what counter values to use based on command -static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd) +/* figures out what counter values to use based on command */ +static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) { - const int max_counter_value = 0x10000; // max value for 16 bit counter in mode 2 - const int min_counter_value = 2; // min value for 16 bit counter in mode 2 + const int max_counter_value = 0x10000; /* max value for 16 bit counter in mode 2 */ + const int min_counter_value = 2; /* min value for 16 bit counter in mode 2 */ unsigned int base_period; - // if both convert and scan triggers are TRIG_TIMER, then they both rely on counter b0 + /* if both convert and scan triggers are TRIG_TIMER, then they both rely on counter b0 */ if (labpc_ai_convert_period(cmd) && labpc_ai_scan_period(cmd)) { - // pick the lowest b0 divisor value we can (for maximum input clock speed on convert and scan counters) + /* pick the lowest b0 divisor value we can (for maximum input clock speed on convert and scan counters) */ devpriv->divisor_b0 = (labpc_ai_scan_period(cmd) - 1) / (LABPC_TIMER_BASE * max_counter_value) + 1; if (devpriv->divisor_b0 < min_counter_value) @@ -1722,7 +1723,7 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd base_period = LABPC_TIMER_BASE * devpriv->divisor_b0; - // set a0 for conversion frequency and b1 for scan frequency + /* set a0 for conversion frequency and b1 for scan frequency */ switch (cmd->flags & TRIG_ROUND_MASK) { default: case TRIG_ROUND_NEAREST: @@ -1748,7 +1749,7 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd labpc_ai_scan_period(cmd) / base_period; break; } - // make sure a0 and b1 values are acceptable + /* make sure a0 and b1 values are acceptable */ if (devpriv->divisor_a0 < min_counter_value) devpriv->divisor_a0 = min_counter_value; if (devpriv->divisor_a0 > max_counter_value) @@ -1757,12 +1758,12 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd devpriv->divisor_b1 = min_counter_value; if (devpriv->divisor_b1 > max_counter_value) devpriv->divisor_b1 = max_counter_value; - // write corrected timings to command + /* write corrected timings to command */ labpc_set_ai_convert_period(cmd, base_period * devpriv->divisor_a0); labpc_set_ai_scan_period(cmd, base_period * devpriv->divisor_b1); - // if only one TRIG_TIMER is used, we can employ the generic cascaded timing functions + /* if only one TRIG_TIMER is used, we can employ the generic cascaded timing functions */ } else if (labpc_ai_scan_period(cmd)) { unsigned int scan_period; @@ -1795,51 +1796,51 @@ static int labpc_dio_mem_callback(int dir, int port, int data, } } -// lowlevel write to eeprom/dac -static void labpc_serial_out(struct comedi_device * dev, unsigned int value, +/* lowlevel write to eeprom/dac */ +static void labpc_serial_out(struct comedi_device *dev, unsigned int value, unsigned int value_width) { int i; for (i = 1; i <= value_width; i++) { - // clear serial clock + /* clear serial clock */ devpriv->command5_bits &= ~SCLOCK_BIT; - // send bits most significant bit first + /* send bits most significant bit first */ if (value & (1 << (value_width - i))) devpriv->command5_bits |= SDATA_BIT; else devpriv->command5_bits &= ~SDATA_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // set clock to load bit + /* set clock to load bit */ devpriv->command5_bits |= SCLOCK_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); } } -// lowlevel read from eeprom -static unsigned int labpc_serial_in(struct comedi_device * dev) +/* lowlevel read from eeprom */ +static unsigned int labpc_serial_in(struct comedi_device *dev) { unsigned int value = 0; int i; - const int value_width = 8; // number of bits wide values are + const int value_width = 8; /* number of bits wide values are */ for (i = 1; i <= value_width; i++) { - // set serial clock + /* set serial clock */ devpriv->command5_bits |= SCLOCK_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // clear clock bit + /* clear clock bit */ devpriv->command5_bits &= ~SCLOCK_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // read bits most significant bit first - comedi_udelay(1); + /* read bits most significant bit first */ + udelay(1); devpriv->status2_bits = devpriv->read_byte(dev->iobase + STATUS2_REG); if (devpriv->status2_bits & EEPROM_OUT_BIT) { @@ -1850,46 +1851,46 @@ static unsigned int labpc_serial_in(struct comedi_device * dev) return value; } -static unsigned int labpc_eeprom_read(struct comedi_device * dev, unsigned int address) +static unsigned int labpc_eeprom_read(struct comedi_device *dev, unsigned int address) { unsigned int value; - const int read_instruction = 0x3; // bits to tell eeprom to expect a read - const int write_length = 8; // 8 bit write lengths to eeprom + const int read_instruction = 0x3; /* bits to tell eeprom to expect a read */ + const int write_length = 8; /* 8 bit write lengths to eeprom */ - // enable read/write to eeprom + /* enable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // send read instruction + /* send read instruction */ labpc_serial_out(dev, read_instruction, write_length); - // send 8 bit address to read from + /* send 8 bit address to read from */ labpc_serial_out(dev, address, write_length); - // read result + /* read result */ value = labpc_serial_in(dev); - // disable read/write to eeprom + /* disable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); return value; } -static unsigned int labpc_eeprom_write(struct comedi_device * dev, +static unsigned int labpc_eeprom_write(struct comedi_device *dev, unsigned int address, unsigned int value) { const int write_enable_instruction = 0x6; const int write_instruction = 0x2; - const int write_length = 8; // 8 bit write lengths to eeprom + const int write_length = 8; /* 8 bit write lengths to eeprom */ const int write_in_progress_bit = 0x1; const int timeout = 10000; int i; - // make sure there isn't already a write in progress + /* make sure there isn't already a write in progress */ for (i = 0; i < timeout; i++) { if ((labpc_eeprom_read_status(dev) & write_in_progress_bit) == 0) @@ -1899,96 +1900,96 @@ static unsigned int labpc_eeprom_write(struct comedi_device * dev, comedi_error(dev, "eeprom write timed out"); return -ETIME; } - // update software copy of eeprom + /* update software copy of eeprom */ devpriv->eeprom_data[address] = value; - // enable read/write to eeprom + /* enable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // send write_enable instruction + /* send write_enable instruction */ labpc_serial_out(dev, write_enable_instruction, write_length); devpriv->command5_bits &= ~EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // send write instruction + /* send write instruction */ devpriv->command5_bits |= EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); labpc_serial_out(dev, write_instruction, write_length); - // send 8 bit address to write to + /* send 8 bit address to write to */ labpc_serial_out(dev, address, write_length); - // write value + /* write value */ labpc_serial_out(dev, value, write_length); devpriv->command5_bits &= ~EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // disable read/write to eeprom + /* disable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); return 0; } -static unsigned int labpc_eeprom_read_status(struct comedi_device * dev) +static unsigned int labpc_eeprom_read_status(struct comedi_device *dev) { unsigned int value; const int read_status_instruction = 0x5; - const int write_length = 8; // 8 bit write lengths to eeprom + const int write_length = 8; /* 8 bit write lengths to eeprom */ - // enable read/write to eeprom + /* enable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // send read status instruction + /* send read status instruction */ labpc_serial_out(dev, read_status_instruction, write_length); - // read result + /* read result */ value = labpc_serial_in(dev); - // disable read/write to eeprom + /* disable read/write to eeprom */ devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); return value; } -// writes to 8 bit calibration dacs -static void write_caldac(struct comedi_device * dev, unsigned int channel, +/* writes to 8 bit calibration dacs */ +static void write_caldac(struct comedi_device *dev, unsigned int channel, unsigned int value) { if (value == devpriv->caldac[channel]) return; devpriv->caldac[channel] = value; - // clear caldac load bit and make sure we don't write to eeprom + /* clear caldac load bit and make sure we don't write to eeprom */ devpriv->command5_bits &= ~CALDAC_LOAD_BIT & ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); - // write 4 bit channel + /* write 4 bit channel */ labpc_serial_out(dev, channel, 4); - // write 8 bit caldac value + /* write 8 bit caldac value */ labpc_serial_out(dev, value, 8); - // set and clear caldac bit to load caldac value + /* set and clear caldac bit to load caldac value */ devpriv->command5_bits |= CALDAC_LOAD_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); devpriv->command5_bits &= ~CALDAC_LOAD_BIT; - comedi_udelay(1); + udelay(1); devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG); } diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index b44b0d3d02f1..c5d2d212612c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -24,59 +24,59 @@ #ifndef _NI_LABPC_H #define _NI_LABPC_H -#define EEPROM_SIZE 256 // 256 byte eeprom -#define NUM_AO_CHAN 2 // boards have two analog output channels +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define NUM_AO_CHAN 2 /* boards have two analog output channels */ enum labpc_bustype { isa_bustype, pci_bustype, pcmcia_bustype }; enum labpc_register_layout { labpc_plus_layout, labpc_1200_layout }; enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer, isa_dma_transfer }; -typedef struct labpc_board_struct { +struct labpc_board_struct { const char *name; - int device_id; // device id for pci and pcmcia boards - int ai_speed; // maximum input speed in nanoseconds - enum labpc_bustype bustype; // ISA/PCI/etc. - enum labpc_register_layout register_layout; // 1200 has extra registers compared to pc+ - int has_ao; // has analog output true/false + int device_id; /* device id for pci and pcmcia boards */ + int ai_speed; /* maximum input speed in nanoseconds */ + enum labpc_bustype bustype; /* ISA/PCI/etc. */ + enum labpc_register_layout register_layout; /* 1200 has extra registers compared to pc+ */ + int has_ao; /* has analog output true/false */ const struct comedi_lrange *ai_range_table; const int *ai_range_code; const int *ai_range_is_unipolar; - unsigned ai_scan_up:1; // board can auto scan up in ai channels, not just down + unsigned ai_scan_up:1; /* board can auto scan up in ai channels, not just down */ unsigned memory_mapped_io:1; /* uses memory mapped io instead of ioports */ -} labpc_board; +}; -typedef struct { - struct mite_struct *mite; // for mite chip on pci-1200 +struct labpc_private { + struct mite_struct *mite; /* for mite chip on pci-1200 */ volatile unsigned long long count; /* number of data points left to be taken */ - unsigned int ao_value[NUM_AO_CHAN]; // software copy of analog output values - // software copys of bits written to command registers + unsigned int ao_value[NUM_AO_CHAN]; /* software copy of analog output values */ + /* software copys of bits written to command registers */ volatile unsigned int command1_bits; volatile unsigned int command2_bits; volatile unsigned int command3_bits; volatile unsigned int command4_bits; volatile unsigned int command5_bits; volatile unsigned int command6_bits; - // store last read of board status registers + /* store last read of board status registers */ volatile unsigned int status1_bits; volatile unsigned int status2_bits; unsigned int divisor_a0; /* value to load into board's counter a0 (conversion pacing) for timed conversions */ unsigned int divisor_b0; /* value to load into board's counter b0 (master) for timed conversions */ unsigned int divisor_b1; /* value to load into board's counter b1 (scan pacing) for timed conversions */ - unsigned int dma_chan; // dma channel to use - u16 *dma_buffer; // buffer ai will dma into - unsigned int dma_transfer_size; // transfer size in bytes for current transfer - enum transfer_type current_transfer; // we are using dma/fifo-half-full/etc. - unsigned int eeprom_data[EEPROM_SIZE]; // stores contents of board's eeprom - unsigned int caldac[16]; // stores settings of calibration dacs - // function pointers so we can use inb/outb or readb/writeb as appropriate + unsigned int dma_chan; /* dma channel to use */ + u16 *dma_buffer; /* buffer ai will dma into */ + unsigned int dma_transfer_size; /* transfer size in bytes for current transfer */ + enum transfer_type current_transfer; /* we are using dma/fifo-half-full/etc. */ + unsigned int eeprom_data[EEPROM_SIZE]; /* stores contents of board's eeprom */ + unsigned int caldac[16]; /* stores settings of calibration dacs */ + /* function pointers so we can use inb/outb or readb/writeb as appropriate */ unsigned int (*read_byte) (unsigned long address); void (*write_byte) (unsigned int byte, unsigned long address); -} labpc_private; +}; -int labpc_common_attach(struct comedi_device * dev, unsigned long iobase, +int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, unsigned int irq, unsigned int dma); -int labpc_common_detach(struct comedi_device * dev); +int labpc_common_detach(struct comedi_device *dev); extern const int labpc_1200_is_unipolar[]; extern const int labpc_1200_ai_gain_bits[]; diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index ac0ce2f58f5f..fb56c03a1b9f 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -60,7 +60,7 @@ NI manuals: */ #undef LABPC_DEBUG -//#define LABPC_DEBUG // enable debugging messages +/* #define LABPC_DEBUG */ /* enable debugging messages */ #include "../comedidev.h" @@ -79,64 +79,64 @@ NI manuals: static struct pcmcia_device *pcmcia_cur_dev = NULL; -static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it); +static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it); -static const labpc_board labpc_cs_boards[] = { +static const struct labpc_board_struct labpc_cs_boards[] = { { - name: "daqcard-1200", - device_id:0x103, // 0x10b is manufacturer id, 0x103 is device id - ai_speed:10000, - bustype: pcmcia_bustype, - register_layout:labpc_1200_layout, - has_ao: 1, - ai_range_table:&range_labpc_1200_ai, - ai_range_code:labpc_1200_ai_gain_bits, - ai_range_is_unipolar:labpc_1200_is_unipolar, - ai_scan_up:0, - memory_mapped_io:0, + .name = "daqcard-1200", + .device_id = 0x103, /* 0x10b is manufacturer id, 0x103 is device id */ + .ai_speed = 10000, + .bustype = pcmcia_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + .ai_scan_up = 0, + .memory_mapped_io = 0, }, /* duplicate entry, to support using alternate name */ { - name: "ni_labpc_cs", - device_id:0x103, - ai_speed:10000, - bustype: pcmcia_bustype, - register_layout:labpc_1200_layout, - has_ao: 1, - ai_range_table:&range_labpc_1200_ai, - ai_range_code:labpc_1200_ai_gain_bits, - ai_range_is_unipolar:labpc_1200_is_unipolar, - ai_scan_up:0, - memory_mapped_io:0, + .name = "ni_labpc_cs", + .device_id = 0x103, + .ai_speed = 10000, + .bustype = pcmcia_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + .ai_scan_up = 0, + .memory_mapped_io = 0, }, }; /* * Useful for shorthand access to the particular board structure */ -#define thisboard ((const labpc_board *)dev->board_ptr) +#define thisboard ((const struct labpc_board_struct *)dev->board_ptr) static struct comedi_driver driver_labpc_cs = { .driver_name = "ni_labpc_cs", .module = THIS_MODULE, .attach = &labpc_attach, .detach = &labpc_common_detach, - .num_names = sizeof(labpc_cs_boards) / sizeof(labpc_board), + .num_names = ARRAY_SIZE(labpc_cs_boards), .board_name = &labpc_cs_boards[0].name, - .offset = sizeof(labpc_board), + .offset = sizeof(struct labpc_board_struct), }; -static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned long iobase = 0; unsigned int irq = 0; struct pcmcia_device *link; /* allocate and initialize dev->private */ - if (alloc_private(dev, sizeof(labpc_private)) < 0) + if (alloc_private(dev, sizeof(struct labpc_private)) < 0) return -ENOMEM; - // get base address, irq etc. based on bustype + /* get base address, irq etc. based on bustype */ switch (thisboard->bustype) { case pcmcia_bustype: link = pcmcia_cur_dev; /* XXX hack */ @@ -213,12 +213,12 @@ static void labpc_cs_detach(struct pcmcia_device *); static const dev_info_t dev_info = "daqcard-1200"; -typedef struct local_info_t { +struct local_info_t { struct pcmcia_device *link; dev_node_t node; int stop; struct bus_operations *bus; -} local_info_t; +}; /*====================================================================== @@ -234,12 +234,12 @@ typedef struct local_info_t { static int labpc_cs_attach(struct pcmcia_device *link) { - local_info_t *local; + struct local_info_t *local; DEBUG(0, "labpc_cs_attach()\n"); /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(local_info_t), GFP_KERNEL); + local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL); if (!local) return -ENOMEM; local->link = link; @@ -287,7 +287,7 @@ static void labpc_cs_detach(struct pcmcia_device *link) detach(). */ if (link->dev_node) { - ((local_info_t *) link->priv)->stop = 1; + ((struct local_info_t *) link->priv)->stop = 1; labpc_release(link); } @@ -307,7 +307,7 @@ static void labpc_cs_detach(struct pcmcia_device *link) static void labpc_config(struct pcmcia_device *link) { - local_info_t *dev = link->priv; + struct local_info_t *dev = link->priv; tuple_t tuple; cisparse_t parse; int last_ret; @@ -327,15 +327,21 @@ static void labpc_config(struct pcmcia_device *link) tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) { + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) { + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) { cs_error(link, GetTupleData, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) { + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) { cs_error(link, ParseTuple, last_ret); goto cs_failed; } @@ -355,7 +361,8 @@ static void labpc_config(struct pcmcia_device *link) will only use the CIS to fill in implementation-defined details. */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) { + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } @@ -422,7 +429,8 @@ static void labpc_config(struct pcmcia_device *link) break; next_entry: - if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) { + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetNextTuple, last_ret); goto cs_failed; } @@ -433,18 +441,21 @@ static void labpc_config(struct pcmcia_device *link) handler to the interrupt, unless the 'Handler' member of the irq structure is initialized. */ - if (link->conf.Attributes & CONF_ENABLE_IRQ) - if ((last_ret = pcmcia_request_irq(link, &link->irq))) { + if (link->conf.Attributes & CONF_ENABLE_IRQ) { + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) { cs_error(link, RequestIRQ, last_ret); goto cs_failed; } + } /* This actually configures the PCMCIA socket -- setting up the I/O windows and the interrupt mapping, and putting the card and host interface into "Memory and IO" mode. */ - if ((last_ret = pcmcia_request_configuration(link, &link->conf))) { + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret) { cs_error(link, RequestConfiguration, last_ret); goto cs_failed; } @@ -501,7 +512,7 @@ static void labpc_release(struct pcmcia_device *link) static int labpc_cs_suspend(struct pcmcia_device *link) { - local_info_t *local = link->priv; + struct local_info_t *local = link->priv; /* Mark the device as stopped, to block IO until later */ local->stop = 1; @@ -510,7 +521,7 @@ static int labpc_cs_suspend(struct pcmcia_device *link) static int labpc_cs_resume(struct pcmcia_device *link) { - local_info_t *local = link->priv; + struct local_info_t *local = link->priv; local->stop = 0; return 0; diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 542bd0dcd44d..d727d7533fc8 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -57,16 +57,17 @@ fully tested as yet. Terry Barnaby, BEAM Ltd. */ -//#define DEBUG_INTERRUPT -//#define DEBUG_STATUS_A -//#define DEBUG_STATUS_B +/* #define DEBUG_INTERRUPT */ +/* #define DEBUG_STATUS_A */ +/* #define DEBUG_STATUS_B */ +#include <linux/interrupt.h> #include "8255.h" #include "mite.h" #include "comedi_fc.h" #ifndef MDPRINTK -#define MDPRINTK(format,args...) +#define MDPRINTK(format, args...) #endif /* A timeout count */ @@ -193,49 +194,49 @@ static const struct comedi_lrange *const ni_range_lkup[] = { [ai_gain_6143] = &range_ni_S_ai_6143 }; -static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int ni_cdio_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void handle_cdio_interrupt(struct comedi_device * dev); -static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void handle_cdio_interrupt(struct comedi_device *dev); +static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum); -static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s, unsigned char data_out, unsigned char *data_in); -static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_serial_sw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s, unsigned char data_out, unsigned char *data_in); -static int ni_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ni_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_m_series_eeprom_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int ni_eeprom_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_m_series_eeprom_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan); +static int ni_pfi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_pfi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static unsigned ni_old_get_pfi_routing(struct comedi_device *dev, unsigned chan); -static void ni_rtsi_init(struct comedi_device * dev); -static int ni_rtsi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static void ni_rtsi_init(struct comedi_device *dev); +static int ni_rtsi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_rtsi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s); -static int ni_read_eeprom(struct comedi_device * dev, int addr); +static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s); +static int ni_read_eeprom(struct comedi_device *dev, int addr); #ifdef DEBUG_STATUS_A static void ni_mio_print_status_a(int status); @@ -248,58 +249,58 @@ static void ni_mio_print_status_b(int status); #define ni_mio_print_status_b(a) #endif -static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s); +static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s); #ifndef PCIDMA -static void ni_handle_fifo_half_full(struct comedi_device * dev); -static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subdevice * s); +static void ni_handle_fifo_half_full(struct comedi_device *dev); +static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdevice *s); #endif -static void ni_handle_fifo_dregs(struct comedi_device * dev); -static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static void ni_handle_fifo_dregs(struct comedi_device *dev); +static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum); -static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_chan, +static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan, unsigned int *list); -static void shutdown_ai_command(struct comedi_device * dev); +static void shutdown_ai_command(struct comedi_device *dev); -static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum); -static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s); +static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s); static int ni_8255_callback(int dir, int port, int data, unsigned long arg); -static int ni_gpct_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_gpct_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void handle_gpct_interrupt(struct comedi_device * dev, +static int ni_gpct_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_gpct_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int ni_gpct_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void handle_gpct_interrupt(struct comedi_device *dev, unsigned short counter_index); -static int init_cs5529(struct comedi_device * dev); -static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data); -static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int init_cs5529(struct comedi_device *dev); +static int cs5529_do_conversion(struct comedi_device *dev, unsigned short *data); +static int cs5529_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); #ifdef NI_CS5529_DEBUG -static unsigned int cs5529_config_read(struct comedi_device * dev, +static unsigned int cs5529_config_read(struct comedi_device *dev, unsigned int reg_select_bits); #endif -static void cs5529_config_write(struct comedi_device * dev, unsigned int value, +static void cs5529_config_write(struct comedi_device *dev, unsigned int value, unsigned int reg_select_bits); -static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int ni_set_master_clock(struct comedi_device * dev, unsigned source, +static int ni_set_master_clock(struct comedi_device *dev, unsigned source, unsigned period_ns); -static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status); -static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status); +static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status); +static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status); enum aimodes { AIMODE_NONE = 0, @@ -353,19 +354,19 @@ enum timebase_nanoseconds { static const int num_adc_stages_611x = 3; -static void handle_a_interrupt(struct comedi_device * dev, unsigned short status, +static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, unsigned ai_mite_status); -static void handle_b_interrupt(struct comedi_device * dev, unsigned short status, +static void handle_b_interrupt(struct comedi_device *dev, unsigned short status, unsigned ao_mite_status); -static void get_last_sample_611x(struct comedi_device * dev); -static void get_last_sample_6143(struct comedi_device * dev); +static void get_last_sample_611x(struct comedi_device *dev); +static void get_last_sample_6143(struct comedi_device *dev); -static inline void ni_set_bitfield(struct comedi_device * dev, int reg, +static inline void ni_set_bitfield(struct comedi_device *dev, int reg, unsigned bit_mask, unsigned bit_values) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); + spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); switch (reg) { case Interrupt_A_Enable_Register: devpriv->int_a_enable_reg &= ~bit_mask; @@ -396,22 +397,22 @@ static inline void ni_set_bitfield(struct comedi_device * dev, int reg, ni_writeb(devpriv->g0_g1_select_reg, G0_G1_Select); break; default: - rt_printk("Warning %s() called with invalid register\n", - __FUNCTION__); - rt_printk("reg is %d\n", reg); + printk("Warning %s() called with invalid register\n", + __func__); + printk("reg is %d\n", reg); break; } mmiowb(); - comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); + spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); } #ifdef PCIDMA -static int ni_ai_drain_dma(struct comedi_device * dev); +static int ni_ai_drain_dma(struct comedi_device *dev); /* DMA channel setup */ -// negative channel means no channel -static inline void ni_set_ai_dma_channel(struct comedi_device * dev, int channel) +/* negative channel means no channel */ +static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) { unsigned bitfield; @@ -425,8 +426,8 @@ static inline void ni_set_ai_dma_channel(struct comedi_device * dev, int channel ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield); } -// negative channel means no channel -static inline void ni_set_ao_dma_channel(struct comedi_device * dev, int channel) +/* negative channel means no channel */ +static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) { unsigned bitfield; @@ -440,8 +441,8 @@ static inline void ni_set_ao_dma_channel(struct comedi_device * dev, int channel ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield); } -// negative mite_channel means no channel -static inline void ni_set_gpct_dma_channel(struct comedi_device * dev, +/* negative mite_channel means no channel */ +static inline void ni_set_gpct_dma_channel(struct comedi_device *dev, unsigned gpct_index, int mite_channel) { unsigned bitfield; @@ -455,12 +456,12 @@ static inline void ni_set_gpct_dma_channel(struct comedi_device * dev, bitfield); } -// negative mite_channel means no channel -static inline void ni_set_cdo_dma_channel(struct comedi_device * dev, int mite_channel) +/* negative mite_channel means no channel */ +static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, int mite_channel) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); + spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); devpriv->cdio_dma_select_reg &= ~CDO_DMA_Select_Mask; if (mite_channel >= 0) { /*XXX just guessing ni_stc_dma_channel_select_bitfield() returns the right bits, @@ -472,19 +473,19 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device * dev, int mite_c } ni_writeb(devpriv->cdio_dma_select_reg, M_Offset_CDIO_DMA_Select); mmiowb(); - comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); + spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); } -static int ni_request_ai_mite_channel(struct comedi_device * dev) +static int ni_request_ai_mite_channel(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->ai_mite_chan); devpriv->ai_mite_chan = mite_request_channel(devpriv->mite, devpriv->ai_mite_ring); if (devpriv->ai_mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel for analog input."); @@ -492,20 +493,20 @@ static int ni_request_ai_mite_channel(struct comedi_device * dev) } devpriv->ai_mite_chan->dir = COMEDI_INPUT; ni_set_ai_dma_channel(dev, devpriv->ai_mite_chan->channel); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return 0; } -static int ni_request_ao_mite_channel(struct comedi_device * dev) +static int ni_request_ao_mite_channel(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->ao_mite_chan); devpriv->ao_mite_chan = mite_request_channel(devpriv->mite, devpriv->ao_mite_ring); if (devpriv->ao_mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel for analog outut."); @@ -513,24 +514,24 @@ static int ni_request_ao_mite_channel(struct comedi_device * dev) } devpriv->ao_mite_chan->dir = COMEDI_OUTPUT; ni_set_ao_dma_channel(dev, devpriv->ao_mite_chan->channel); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return 0; } -static int ni_request_gpct_mite_channel(struct comedi_device * dev, +static int ni_request_gpct_mite_channel(struct comedi_device *dev, unsigned gpct_index, enum comedi_io_direction direction) { unsigned long flags; struct mite_channel *mite_chan; BUG_ON(gpct_index >= NUM_GPCT); - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->counter_dev->counters[gpct_index].mite_chan); mite_chan = mite_request_channel(devpriv->mite, devpriv->gpct_mite_ring[gpct_index]); if (mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel for counter."); @@ -540,23 +541,23 @@ static int ni_request_gpct_mite_channel(struct comedi_device * dev, ni_tio_set_mite_channel(&devpriv->counter_dev->counters[gpct_index], mite_chan); ni_set_gpct_dma_channel(dev, gpct_index, mite_chan->channel); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return 0; } -#endif // PCIDMA +#endif /* PCIDMA */ -static int ni_request_cdo_mite_channel(struct comedi_device * dev) +static int ni_request_cdo_mite_channel(struct comedi_device *dev) { #ifdef PCIDMA unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->cdo_mite_chan); devpriv->cdo_mite_chan = mite_request_channel(devpriv->mite, devpriv->cdo_mite_ring); if (devpriv->cdo_mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel for correlated digital outut."); @@ -564,48 +565,48 @@ static int ni_request_cdo_mite_channel(struct comedi_device * dev) } devpriv->cdo_mite_chan->dir = COMEDI_OUTPUT; ni_set_cdo_dma_channel(dev, devpriv->cdo_mite_chan->channel); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); -#endif // PCIDMA + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); +#endif /* PCIDMA */ return 0; } -static void ni_release_ai_mite_channel(struct comedi_device * dev) +static void ni_release_ai_mite_channel(struct comedi_device *dev) { #ifdef PCIDMA unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan) { ni_set_ai_dma_channel(dev, -1); mite_release_channel(devpriv->ai_mite_chan); devpriv->ai_mite_chan = NULL; } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); -#endif // PCIDMA + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); +#endif /* PCIDMA */ } -static void ni_release_ao_mite_channel(struct comedi_device * dev) +static void ni_release_ao_mite_channel(struct comedi_device *dev) { #ifdef PCIDMA unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { ni_set_ao_dma_channel(dev, -1); mite_release_channel(devpriv->ao_mite_chan); devpriv->ao_mite_chan = NULL; } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); -#endif // PCIDMA + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); +#endif /* PCIDMA */ } -void ni_release_gpct_mite_channel(struct comedi_device * dev, unsigned gpct_index) +void ni_release_gpct_mite_channel(struct comedi_device *dev, unsigned gpct_index) { #ifdef PCIDMA unsigned long flags; BUG_ON(gpct_index >= NUM_GPCT); - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->counter_dev->counters[gpct_index].mite_chan) { struct mite_channel *mite_chan = devpriv->counter_dev->counters[gpct_index].mite_chan; @@ -615,28 +616,28 @@ void ni_release_gpct_mite_channel(struct comedi_device * dev, unsigned gpct_inde counters[gpct_index], NULL); mite_release_channel(mite_chan); } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); -#endif // PCIDMA + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); +#endif /* PCIDMA */ } -static void ni_release_cdo_mite_channel(struct comedi_device * dev) +static void ni_release_cdo_mite_channel(struct comedi_device *dev) { #ifdef PCIDMA unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->cdo_mite_chan) { ni_set_cdo_dma_channel(dev, -1); mite_release_channel(devpriv->cdo_mite_chan); devpriv->cdo_mite_chan = NULL; } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); -#endif // PCIDMA + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); +#endif /* PCIDMA */ } -// e-series boards use the second irq signals to generate dma requests for their counters +/* e-series boards use the second irq signals to generate dma requests for their counters */ #ifdef PCIDMA -static void ni_e_series_enable_second_irq(struct comedi_device * dev, +static void ni_e_series_enable_second_irq(struct comedi_device *dev, unsigned gpct_index, short enable) { if (boardtype.reg_type & ni_reg_m_series_mask) @@ -665,15 +666,15 @@ static void ni_e_series_enable_second_irq(struct comedi_device * dev, break; } } -#endif // PCIDMA +#endif /* PCIDMA */ -static void ni_clear_ai_fifo(struct comedi_device * dev) +static void ni_clear_ai_fifo(struct comedi_device *dev) { if (boardtype.reg_type == ni_reg_6143) { - // Flush the 6143 data FIFO - ni_writel(0x10, AIFIFO_Control_6143); // Flush fifo - ni_writel(0x00, AIFIFO_Control_6143); // Flush fifo - while (ni_readl(AIFIFO_Status_6143) & 0x10) ; // Wait for complete + /* Flush the 6143 data FIFO */ + ni_writel(0x10, AIFIFO_Control_6143); /* Flush fifo */ + ni_writel(0x00, AIFIFO_Control_6143); /* Flush fifo */ + while (ni_readl(AIFIFO_Status_6143) & 0x10) ; /* Wait for complete */ } else { devpriv->stc_writew(dev, 1, ADC_FIFO_Clear); if (boardtype.reg_type == ni_reg_625x) { @@ -693,13 +694,13 @@ static void ni_clear_ai_fifo(struct comedi_device * dev) } } -static void win_out2(struct comedi_device * dev, uint32_t data, int reg) +static void win_out2(struct comedi_device *dev, uint32_t data, int reg) { devpriv->stc_writew(dev, data >> 16, reg); devpriv->stc_writew(dev, data & 0xffff, reg + 1); } -static uint32_t win_in2(struct comedi_device * dev, int reg) +static uint32_t win_in2(struct comedi_device *dev, int reg) { uint32_t bits; bits = devpriv->stc_readw(dev, reg) << 16; @@ -707,36 +708,36 @@ static uint32_t win_in2(struct comedi_device * dev, int reg) return bits; } -#define ao_win_out(data,addr) ni_ao_win_outw(dev,data,addr) -static inline void ni_ao_win_outw(struct comedi_device * dev, uint16_t data, int addr) +#define ao_win_out(data, addr) ni_ao_win_outw(dev, data, addr) +static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data, int addr) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); ni_writew(addr, AO_Window_Address_611x); ni_writew(data, AO_Window_Data_611x); - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); } -static inline void ni_ao_win_outl(struct comedi_device * dev, uint32_t data, int addr) +static inline void ni_ao_win_outl(struct comedi_device *dev, uint32_t data, int addr) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); ni_writew(addr, AO_Window_Address_611x); ni_writel(data, AO_Window_Data_611x); - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); } -static inline unsigned short ni_ao_win_inw(struct comedi_device * dev, int addr) +static inline unsigned short ni_ao_win_inw(struct comedi_device *dev, int addr) { unsigned long flags; unsigned short data; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); ni_writew(addr, AO_Window_Address_611x); data = ni_readw(AO_Window_Data_611x); - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); return data; } @@ -750,7 +751,7 @@ static inline unsigned short ni_ao_win_inw(struct comedi_device * dev, int addr) * * value should only be 1 or 0. */ -static inline void ni_set_bits(struct comedi_device * dev, int reg, unsigned bits, +static inline void ni_set_bits(struct comedi_device *dev, int reg, unsigned bits, unsigned value) { unsigned bit_values; @@ -762,7 +763,7 @@ static inline void ni_set_bits(struct comedi_device * dev, int reg, unsigned bit ni_set_bitfield(dev, reg, bits, bit_values); } -static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t ni_E_interrupt(int irq, void *d) { struct comedi_device *dev = d; unsigned short a_status; @@ -776,18 +777,17 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG) if (dev->attached == 0) return IRQ_NONE; - smp_mb(); // make sure dev->attached is checked before handler does anything else. + smp_mb(); /* make sure dev->attached is checked before handler does anything else. */ - // lock to avoid race with comedi_poll - comedi_spin_lock_irqsave(&dev->spinlock, flags); + /* lock to avoid race with comedi_poll */ + spin_lock_irqsave(&dev->spinlock, flags); a_status = devpriv->stc_readw(dev, AI_Status_1_Register); b_status = devpriv->stc_readw(dev, AO_Status_1_Register); #ifdef PCIDMA if (mite) { unsigned long flags_too; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, - flags_too); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags_too); if (devpriv->ai_mite_chan) { ai_mite_status = mite_get_status(devpriv->ai_mite_chan); if (ai_mite_status & CHSR_LINKC) @@ -804,8 +804,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG) MITE_CHOR(devpriv->ao_mite_chan-> channel)); } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, - flags_too); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags_too); } #endif ack_a_interrupt(dev, a_status); @@ -818,20 +817,20 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG) handle_gpct_interrupt(dev, 1); handle_cdio_interrupt(dev); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return IRQ_HANDLED; } #ifdef PCIDMA -static void ni_sync_ai_dma(struct comedi_device * dev) +static void ni_sync_ai_dma(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan) mite_sync_input_dma(devpriv->ai_mite_chan, s->async); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); } static void mite_handle_b_linkc(struct mite_struct *mite, struct comedi_device * dev) @@ -839,14 +838,14 @@ static void mite_handle_b_linkc(struct mite_struct *mite, struct comedi_device * struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV; unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { mite_sync_output_dma(devpriv->ao_mite_chan, s->async); } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); } -static int ni_ao_wait_for_dma_load(struct comedi_device * dev) +static int ni_ao_wait_for_dma_load(struct comedi_device *dev) { static const int timeout = 10000; int i; @@ -858,7 +857,7 @@ static int ni_ao_wait_for_dma_load(struct comedi_device * dev) break; /* if we poll too often, the pci bus activity seems to slow the dma transfer down */ - comedi_udelay(10); + udelay(10); } if (i == timeout) { comedi_error(dev, "timed out waiting for dma load"); @@ -867,8 +866,8 @@ static int ni_ao_wait_for_dma_load(struct comedi_device * dev) return 0; } -#endif //PCIDMA -static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice * s) +#endif /* PCIDMA */ +static void ni_handle_eos(struct comedi_device *dev, struct comedi_subdevice *s) { if (devpriv->aimode == AIMODE_SCAN) { #ifdef PCIDMA @@ -879,7 +878,7 @@ static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice * ni_sync_ai_dma(dev); if ((s->async->events & COMEDI_CB_EOS)) break; - comedi_udelay(1); + udelay(1); } #else ni_handle_fifo_dregs(dev); @@ -892,7 +891,7 @@ static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice * } } -static void shutdown_ai_command(struct comedi_device * dev) +static void shutdown_ai_command(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; @@ -906,7 +905,7 @@ static void shutdown_ai_command(struct comedi_device * dev) s->async->events |= COMEDI_CB_EOA; } -static void ni_event(struct comedi_device * dev, struct comedi_subdevice * s) +static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s) { if (s->async-> events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW | COMEDI_CB_EOA)) @@ -932,7 +931,7 @@ static void ni_event(struct comedi_device * dev, struct comedi_subdevice * s) comedi_event(dev, s); } -static void handle_gpct_interrupt(struct comedi_device * dev, +static void handle_gpct_interrupt(struct comedi_device *dev, unsigned short counter_index) { #ifdef PCIDMA @@ -945,7 +944,7 @@ static void handle_gpct_interrupt(struct comedi_device * dev, #endif } -static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status) +static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status) { unsigned short ack = 0; @@ -966,17 +965,17 @@ static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status) devpriv->stc_writew(dev, ack, Interrupt_A_Ack_Register); } -static void handle_a_interrupt(struct comedi_device * dev, unsigned short status, +static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, unsigned ai_mite_status) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; - //67xx boards don't have ai subdevice, but their gpct0 might generate an a interrupt + /* 67xx boards don't have ai subdevice, but their gpct0 might generate an a interrupt */ if (s->type == COMEDI_SUBD_UNUSED) return; #ifdef DEBUG_INTERRUPT - rt_printk + printk ("ni_mio_common: interrupt: a_status=%04x ai_mite_status=%08x\n", status, ai_mite_status); ni_mio_print_status_a(status); @@ -989,12 +988,12 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status if (ai_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY | CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR | CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) { - rt_printk + printk ("unknown mite interrupt, ack! (ai_mite_status=%08x)\n", ai_mite_status); - //mite_print_chsr(ai_mite_status); + /* mite_print_chsr(ai_mite_status); */ s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - //disable_irq(dev->irq); + /* disable_irq(dev->irq); */ } #endif @@ -1002,7 +1001,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St | AI_SC_TC_St | AI_START1_St)) { if (status == 0xffff) { - rt_printk + printk ("ni_mio_common: a_status=0xffff. Card removed?\n"); /* we probably aren't even running a command now, * so it's a good idea to be careful. */ @@ -1015,7 +1014,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status } if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St)) { - rt_printk("ni_mio_common: ai error a_status=%04x\n", + printk("ni_mio_common: ai error a_status=%04x\n", status); ni_mio_print_status_a(status); @@ -1031,7 +1030,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status } if (status & AI_SC_TC_St) { #ifdef DEBUG_INTERRUPT - rt_printk("ni_mio_common: SC_TC interrupt\n"); + printk("ni_mio_common: SC_TC interrupt\n"); #endif if (!devpriv->ai_continuous) { shutdown_ai_command(dev); @@ -1052,7 +1051,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status break; } } -#endif // !PCIDMA +#endif /* !PCIDMA */ if ((status & AI_STOP_St)) { ni_handle_eos(dev, s); @@ -1063,14 +1062,14 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status #ifdef DEBUG_INTERRUPT status = devpriv->stc_readw(dev, AI_Status_1_Register); if (status & Interrupt_A_St) { - rt_printk + printk ("handle_a_interrupt: didn't clear interrupt? status=0x%x\n", status); } #endif } -static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status) +static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status) { unsigned short ack = 0; if (b_status & AO_BC_TC_St) { @@ -1098,13 +1097,13 @@ static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status) devpriv->stc_writew(dev, ack, Interrupt_B_Ack_Register); } -static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_status, +static void handle_b_interrupt(struct comedi_device *dev, unsigned short b_status, unsigned ao_mite_status) { struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV; - //unsigned short ack=0; + /* unsigned short ack=0; */ #ifdef DEBUG_INTERRUPT - rt_printk("ni_mio_common: interrupt: b_status=%04x m1_status=%08x\n", + printk("ni_mio_common: interrupt: b_status=%04x m1_status=%08x\n", b_status, ao_mite_status); ni_mio_print_status_b(b_status); #endif @@ -1118,10 +1117,10 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat if (ao_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY | CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR | CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) { - rt_printk + printk ("unknown mite interrupt, ack! (ao_mite_status=%08x)\n", ao_mite_status); - //mite_print_chsr(ao_mite_status); + /* mite_print_chsr(ao_mite_status); */ s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; } #endif @@ -1129,7 +1128,7 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat if (b_status == 0xffff) return; if (b_status & AO_Overrun_St) { - rt_printk + printk ("ni_mio_common: AO FIFO underrun status=0x%04x status2=0x%04x\n", b_status, devpriv->stc_readw(dev, AO_Status_2_Register)); @@ -1146,7 +1145,7 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat ret = ni_ao_fifo_half_empty(dev, s); if (!ret) { - rt_printk("ni_mio_common: AO buffer underrun\n"); + printk("ni_mio_common: AO buffer underrun\n"); ni_set_bits(dev, Interrupt_B_Enable_Register, AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0); @@ -1170,13 +1169,13 @@ static void ni_mio_print_status_a(int status) { int i; - rt_printk("A status:"); + printk("A status:"); for (i = 15; i >= 0; i--) { if (status & (1 << i)) { - rt_printk(" %s", status_a_strings[i]); + printk(" %s", status_a_strings[i]); } } - rt_printk("\n"); + printk("\n"); } #endif @@ -1192,19 +1191,19 @@ static void ni_mio_print_status_b(int status) { int i; - rt_printk("B status:"); + printk("B status:"); for (i = 15; i >= 0; i--) { if (status & (1 << i)) { - rt_printk(" %s", status_b_strings[i]); + printk(" %s", status_b_strings[i]); } } - rt_printk("\n"); + printk("\n"); } #endif #ifndef PCIDMA -static void ni_ao_fifo_load(struct comedi_device * dev, struct comedi_subdevice * s, int n) +static void ni_ao_fifo_load(struct comedi_device *dev, struct comedi_subdevice *s, int n) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -1263,7 +1262,7 @@ static void ni_ao_fifo_load(struct comedi_device * dev, struct comedi_subdevice * RT code, as RT code might purposely be running close to the * metal. Needs to be fixed eventually. */ -static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdevice *s) { int n; @@ -1284,7 +1283,7 @@ static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subde return 1; } -static int ni_ao_prep_fifo(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ao_prep_fifo(struct comedi_device *dev, struct comedi_subdevice *s) { int n; @@ -1307,7 +1306,7 @@ static int ni_ao_prep_fifo(struct comedi_device * dev, struct comedi_subdevice * return n; } -static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice * s, int n) +static void ni_ai_fifo_read(struct comedi_device *dev, struct comedi_subdevice *s, int n) { struct comedi_async *async = s->async; int i; @@ -1333,7 +1332,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice short data[2]; u32 dl; - // This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed + /* This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */ for (i = 0; i < n / 2; i++) { dl = ni_readl(AIFIFO_Data_6143); @@ -1343,7 +1342,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice } if (n % 2) { /* Assume there is a single sample stuck in the FIFO */ - ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO + ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */ dl = ni_readl(AIFIFO_Data_6143); data[0] = (dl >> 16) & 0xffff; cfc_write_to_buffer(s, data[0]); @@ -1364,7 +1363,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice } } -static void ni_handle_fifo_half_full(struct comedi_device * dev) +static void ni_handle_fifo_half_full(struct comedi_device *dev) { int n; struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; @@ -1376,14 +1375,14 @@ static void ni_handle_fifo_half_full(struct comedi_device * dev) #endif #ifdef PCIDMA -static int ni_ai_drain_dma(struct comedi_device * dev) +static int ni_ai_drain_dma(struct comedi_device *dev) { int i; static const int timeout = 10000; unsigned long flags; int retval = 0; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan) { for (i = 0; i < timeout; i++) { if ((devpriv->stc_readw(dev, @@ -1392,19 +1391,19 @@ static int ni_ai_drain_dma(struct comedi_device * dev) && mite_bytes_in_transit(devpriv-> ai_mite_chan) == 0) break; - comedi_udelay(5); + udelay(5); } if (i == timeout) { - rt_printk + printk ("ni_mio_common: wait for dma drain timed out\n"); - rt_printk + printk ("mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n", mite_bytes_in_transit(devpriv->ai_mite_chan), devpriv->stc_readw(dev, AI_Status_1_Register)); retval = -1; } } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); ni_sync_ai_dma(dev); @@ -1414,7 +1413,7 @@ static int ni_ai_drain_dma(struct comedi_device * dev) /* Empties the AI fifo */ -static void ni_handle_fifo_dregs(struct comedi_device * dev) +static void ni_handle_fifo_dregs(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; short data[2]; @@ -1444,9 +1443,9 @@ static void ni_handle_fifo_dregs(struct comedi_device * dev) cfc_write_array_to_buffer(s, data, sizeof(data)); i += 2; } - // Check if stranded sample is present + /* Check if stranded sample is present */ if (ni_readl(AIFIFO_Status_6143) & 0x01) { - ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO + ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */ dl = ni_readl(AIFIFO_Data_6143); data[0] = (dl >> 16) & 0xffff; cfc_write_to_buffer(s, data[0]); @@ -1476,7 +1475,7 @@ static void ni_handle_fifo_dregs(struct comedi_device * dev) } } -static void get_last_sample_611x(struct comedi_device * dev) +static void get_last_sample_611x(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; short data; @@ -1493,7 +1492,7 @@ static void get_last_sample_611x(struct comedi_device * dev) } } -static void get_last_sample_6143(struct comedi_device * dev) +static void get_last_sample_6143(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; short data; @@ -1504,7 +1503,7 @@ static void get_last_sample_6143(struct comedi_device * dev) /* Check if there's a single sample stuck in the FIFO */ if (ni_readl(AIFIFO_Status_6143) & 0x01) { - ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO + ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */ dl = ni_readl(AIFIFO_Data_6143); /* This may get the hi/lo data in the wrong order */ @@ -1513,7 +1512,7 @@ static void get_last_sample_6143(struct comedi_device * dev) } } -static void ni_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int chan_index) { struct comedi_async *async = s->async; @@ -1539,7 +1538,7 @@ static void ni_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s, #ifdef PCIDMA -static int ni_ai_setup_MITE_dma(struct comedi_device * dev) +static int ni_ai_setup_MITE_dma(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV; int retval; @@ -1548,15 +1547,14 @@ static int ni_ai_setup_MITE_dma(struct comedi_device * dev) retval = ni_request_ai_mite_channel(dev); if (retval) return retval; -// rt_printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); +/* printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); */ /* write alloc the entire buffer */ comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); - if(devpriv->ai_mite_chan == NULL) - { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + if (devpriv->ai_mite_chan == NULL) { + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return -EIO; } @@ -1574,12 +1572,12 @@ static int ni_ai_setup_MITE_dma(struct comedi_device * dev) }; /*start the MITE */ mite_dma_arm(devpriv->ai_mite_chan); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return 0; } -static int ni_ao_setup_MITE_dma(struct comedi_device * dev) +static int ni_ao_setup_MITE_dma(struct comedi_device *dev) { struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV; int retval; @@ -1592,7 +1590,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev) /* read alloc the entire buffer */ comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz); - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { if (boardtype.reg_type & (ni_reg_611x | ni_reg_6713)) { mite_prep_dma(devpriv->ao_mite_chan, 32, 32); @@ -1604,12 +1602,12 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev) mite_dma_arm(devpriv->ao_mite_chan); } else retval = -EIO; - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return retval; } -#endif // PCIDMA +#endif /* PCIDMA */ /* used for both cancel ioctl and board initialization @@ -1617,7 +1615,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev) this is pretty harsh for a cancel, but it works... */ -static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) { ni_release_ai_mite_channel(dev); /* ai configuration */ @@ -1698,14 +1696,14 @@ static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ni_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags = 0; int count; - // lock to avoid race with interrupt handler + /* lock to avoid race with interrupt handler */ if (in_interrupt() == 0) - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); #ifndef PCIDMA ni_handle_fifo_dregs(dev); #else @@ -1713,13 +1711,13 @@ static int ni_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s) #endif count = s->async->buf_write_count - s->async->buf_read_count; if (in_interrupt() == 0) - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return count; } -static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; const unsigned int mask = (1 << boardtype.adbits) - 1; @@ -1736,7 +1734,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * for (n = 0; n < num_adc_stages_611x; n++) { devpriv->stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register); - comedi_udelay(1); + udelay(1); } for (n = 0; n < insn->n; n++) { devpriv->stc_writew(dev, AI_CONVERT_Pulse, @@ -1758,7 +1756,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * } } if (i == NI_TIMEOUT) { - rt_printk + printk ("ni_mio_common: timeout in 611x ni_ai_insn_read\n"); return -ETIME; } @@ -1774,13 +1772,13 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * dl = 0; for (i = 0; i < NI_TIMEOUT; i++) { if (ni_readl(AIFIFO_Status_6143) & 0x01) { - ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO + ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */ dl = ni_readl(AIFIFO_Data_6143); break; } } if (i == NI_TIMEOUT) { - rt_printk + printk ("ni_mio_common: timeout in 6143 ni_ai_insn_read\n"); return -ETIME; } @@ -1797,7 +1795,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * break; } if (i == NI_TIMEOUT) { - rt_printk + printk ("ni_mio_common: timeout in ni_ai_insn_read\n"); return -ETIME; } @@ -1814,7 +1812,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * return insn->n; } -void ni_prime_channelgain_list(struct comedi_device * dev) +void ni_prime_channelgain_list(struct comedi_device *dev) { int i; devpriv->stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register); @@ -1825,12 +1823,12 @@ void ni_prime_channelgain_list(struct comedi_device * dev) devpriv->stc_writew(dev, 1, ADC_FIFO_Clear); return; } - comedi_udelay(1); + udelay(1); } - rt_printk("ni_mio_common: timeout loading channel/gain list\n"); + printk("ni_mio_common: timeout loading channel/gain list\n"); } -static void ni_m_series_load_channelgain_list(struct comedi_device * dev, +static void ni_m_series_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan, unsigned int *list) { unsigned int chan, range, aref; @@ -1841,7 +1839,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev, devpriv->stc_writew(dev, 1, Configuration_Memory_Clear); -// offset = 1 << (boardtype.adbits - 1); +/* offset = 1 << (boardtype.adbits - 1); */ if ((list[0] & CR_ALT_SOURCE)) { unsigned bypass_bits; chan = CR_CHAN(list[0]); @@ -1859,7 +1857,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev, bypass_bits |= MSeries_AI_Bypass_Gain_Bits(range_code); if (dither) bypass_bits |= MSeries_AI_Bypass_Dither_Bit; - // don't use 2's complement encoding + /* don't use 2's complement encoding */ bypass_bits |= MSeries_AI_Bypass_Polarity_Bit; ni_writel(bypass_bits, M_Offset_AI_Config_FIFO_Bypass); } else { @@ -1899,7 +1897,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev, config_bits |= MSeries_AI_Config_Last_Channel_Bit; if (dither) config_bits |= MSeries_AI_Config_Dither_Bit; - // don't use 2's complement encoding + /* don't use 2's complement encoding */ config_bits |= MSeries_AI_Config_Polarity_Bit; ni_writew(config_bits, M_Offset_AI_Config_FIFO_Data); } @@ -1935,7 +1933,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev, * bits 0-2: channel * valid channels are 0-3 */ -static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_chan, +static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan, unsigned int *list) { unsigned int chan, range, aref; @@ -1952,7 +1950,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_ && (boardtype.reg_type != ni_reg_6143)) { if (devpriv->changain_state && devpriv->changain_spec == list[0]) { - // ready to go. + /* ready to go. */ return; } devpriv->changain_state = 1; @@ -1963,11 +1961,11 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_ devpriv->stc_writew(dev, 1, Configuration_Memory_Clear); - // Set up Calibration mode if required + /* Set up Calibration mode if required */ if (boardtype.reg_type == ni_reg_6143) { if ((list[0] & CR_ALT_SOURCE) && !devpriv->ai_calib_source_enabled) { - // Strobe Relay enable bit + /* Strobe Relay enable bit */ ni_writew(devpriv-> ai_calib_source | Calibration_Channel_6143_RelayOn, @@ -1975,10 +1973,10 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_ ni_writew(devpriv->ai_calib_source, Calibration_Channel_6143); devpriv->ai_calib_source_enabled = 1; - msleep_interruptible(100); // Allow relays to change + msleep_interruptible(100); /* Allow relays to change */ } else if (!(list[0] & CR_ALT_SOURCE) && devpriv->ai_calib_source_enabled) { - // Strobe Relay disable bit + /* Strobe Relay disable bit */ ni_writew(devpriv-> ai_calib_source | Calibration_Channel_6143_RelayOff, @@ -1986,7 +1984,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_ ni_writew(devpriv->ai_calib_source, Calibration_Channel_6143); devpriv->ai_calib_source_enabled = 0; - msleep_interruptible(100); // Allow relays to change + msleep_interruptible(100); /* Allow relays to change */ } } @@ -2055,7 +2053,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_ } } -static int ni_ns_to_timer(const struct comedi_device * dev, unsigned nanosec, +static int ni_ns_to_timer(const struct comedi_device *dev, unsigned nanosec, int round_mode) { int divider; @@ -2074,29 +2072,29 @@ static int ni_ns_to_timer(const struct comedi_device * dev, unsigned nanosec, return divider - 1; } -static unsigned ni_timer_to_ns(const struct comedi_device * dev, int timer) +static unsigned ni_timer_to_ns(const struct comedi_device *dev, int timer) { return devpriv->clock_ns * (timer + 1); } -static unsigned ni_min_ai_scan_period_ns(struct comedi_device * dev, +static unsigned ni_min_ai_scan_period_ns(struct comedi_device *dev, unsigned num_channels) { switch (boardtype.reg_type) { case ni_reg_611x: case ni_reg_6143: - // simultaneously-sampled inputs + /* simultaneously-sampled inputs */ return boardtype.ai_speed; break; default: - // multiplexed inputs + /* multiplexed inputs */ break; }; return boardtype.ai_speed * num_channels; } -static int ni_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -2308,7 +2306,7 @@ static int ni_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct comedi_cmd *cmd = &s->async->cmd; int timer; @@ -2367,10 +2365,10 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) if (cmd->chanlist_len == 1 || (boardtype.reg_type == ni_reg_611x) || (boardtype.reg_type == ni_reg_6143)) { start_stop_select |= AI_STOP_Polarity; - start_stop_select |= AI_STOP_Select(31); // logic low + start_stop_select |= AI_STOP_Select(31); /* logic low */ start_stop_select |= AI_STOP_Sync; } else { - start_stop_select |= AI_STOP_Select(19); // ai configuration memory + start_stop_select |= AI_STOP_Select(19); /* ai configuration memory */ } devpriv->stc_writew(dev, start_stop_select, AI_START_STOP_Select_Register); @@ -2381,7 +2379,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) stop_count = cmd->stop_arg - 1; if (boardtype.reg_type == ni_reg_611x) { - // have to take 3 stage adc pipeline into account + /* have to take 3 stage adc pipeline into account */ stop_count += num_adc_stages_611x; } /* stage number of scans */ @@ -2396,7 +2394,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) if (stop_count == 0) { devpriv->ai_cmd2 |= AI_End_On_End_Of_Scan; interrupt_a_enable |= AI_STOP_Interrupt_Enable; - // this is required to get the last sample for chanlist_len > 1, not sure why + /* this is required to get the last sample for chanlist_len > 1, not sure why */ if (cmd->chanlist_len > 1) start_stop_select |= AI_STOP_Polarity | AI_STOP_Edge; @@ -2440,7 +2438,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) mode2 |= AI_SI_Reload_Mode(0); /* AI_SI_Initial_Load_Source=A */ mode2 &= ~AI_SI_Initial_Load_Source; - //mode2 |= AI_SC_Reload_Mode; + /* mode2 |= AI_SC_Reload_Mode; */ devpriv->stc_writew(dev, mode2, AI_Mode_2_Register); /* load SI */ @@ -2486,8 +2484,8 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) /* AI_SI2_Load */ devpriv->stc_writew(dev, AI_SI2_Load, AI_Command_1_Register); - mode2 |= AI_SI2_Reload_Mode; // alternate - mode2 |= AI_SI2_Initial_Load_Source; // B + mode2 |= AI_SI2_Reload_Mode; /* alternate */ + mode2 |= AI_SI2_Initial_Load_Source; /* B */ devpriv->stc_writew(dev, mode2, AI_Mode_2_Register); break; @@ -2589,7 +2587,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) if (retval) return retval; } - //mite_dump_regs(devpriv->mite); + /* mite_dump_regs(devpriv->mite); */ #endif switch (cmd->start_src) { @@ -2612,7 +2610,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { if (trignum != 0) @@ -2625,11 +2623,11 @@ static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s return 1; } -static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static int ni_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -2679,8 +2677,8 @@ static int ni_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice return -EINVAL; } -static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int a, b, modebits; int err = 0; @@ -2777,7 +2775,7 @@ static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_su } /* munge data from unsigned to 2's complement for analog output bipolar modes */ -static void ni_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, +static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int chan_index) { struct comedi_async *async = s->async; @@ -2800,8 +2798,8 @@ static void ni_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, } } -static int ni_m_series_ao_config_chanlist(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int chanspec[], unsigned int n_chans, +static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int chanspec[], unsigned int n_chans, int timed) { unsigned int range; @@ -2810,7 +2808,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev, int i; int invert = 0; - if(timed) { + if (timed) { for (i = 0; i < boardtype.n_aochan; ++i) { devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit; ni_writeb(devpriv->ao_conf[i], M_Offset_AO_Config_Bank(i)); @@ -2844,8 +2842,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev, M_Offset_AO_Reference_Attenuation(chan)); break; default: - rt_printk("%s: bug! unhandled ao reference voltage\n", - __FUNCTION__); + printk("%s: bug! unhandled ao reference voltage\n", + __func__); break; } switch (krange->max + krange->min) { @@ -2856,8 +2854,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev, conf |= MSeries_AO_DAC_Offset_5V_Bits; break; default: - rt_printk("%s: bug! unhandled ao offset voltage\n", - __FUNCTION__); + printk("%s: bug! unhandled ao offset voltage\n", + __func__); break; } if (timed) @@ -2869,7 +2867,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev, return invert; } -static int ni_old_ao_config_chanlist(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_old_ao_config_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chanspec[], unsigned int n_chans) { unsigned int range; @@ -2912,7 +2910,7 @@ static int ni_old_ao_config_chanlist(struct comedi_device * dev, struct comedi_s return invert; } -static int ni_ao_config_chanlist(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_ao_config_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chanspec[], unsigned int n_chans, int timed) { if (boardtype.reg_type & ni_reg_m_series_mask) @@ -2921,16 +2919,16 @@ static int ni_ao_config_chanlist(struct comedi_device * dev, struct comedi_subde else return ni_old_ao_config_chanlist(dev, s, chanspec, n_chans); } -static int ni_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->ao[CR_CHAN(insn->chanspec)]; return 1; } -static int ni_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int invert; @@ -2948,8 +2946,8 @@ static int ni_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice return 1; } -static int ni_ao_insn_write_671x(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ao_insn_write_671x(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int invert; @@ -2965,16 +2963,16 @@ static int ni_ao_insn_write_671x(struct comedi_device * dev, struct comedi_subde return 1; } -static int ni_ao_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_ao_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { case INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: - switch(data[1]) + switch (data[1]) { case COMEDI_OUTPUT: data[2] = 1 + boardtype.ao_fifo_depth * sizeof(short); - if(devpriv->mite) data[2] += devpriv->mite->fifo_size; + if (devpriv->mite) data[2] += devpriv->mite->fifo_size; break; case COMEDI_INPUT: data[2] = 0; @@ -2991,7 +2989,7 @@ static int ni_ao_insn_config(struct comedi_device * dev, struct comedi_subdevice return -EINVAL; } -static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { int ret; @@ -3033,7 +3031,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s devpriv->stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); /* wait for DACs to be loaded */ for (i = 0; i < timeout; i++) { - comedi_udelay(1); + udelay(1); if ((devpriv->stc_readw(dev, Joint_Status_2_Register) & AO_TMRDACWRs_In_Progress_St) == 0) @@ -3044,7 +3042,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s "timed out waiting for AO_TMRDACWRs_In_Progress_St to clear"); return -EIO; } - // stc manual says we are need to clear error interrupt after AO_TMRDACWRs_In_Progress_St clears + /* stc manual says we are need to clear error interrupt after AO_TMRDACWRs_In_Progress_St clears */ devpriv->stc_writew(dev, AO_Error_Interrupt_Ack, Interrupt_B_Ack_Register); @@ -3062,7 +3060,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct comedi_cmd *cmd = &s->async->cmd; int bits; @@ -3114,9 +3112,9 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) case TRIG_EXT: devpriv->ao_trigger_select = AO_START1_Select(CR_CHAN(cmd->start_arg)+1); if (cmd->start_arg & CR_INVERT) - devpriv->ao_trigger_select |= AO_START1_Polarity; // 0=active high, 1=active low. see daq-stc 3-24 (p186) + devpriv->ao_trigger_select |= AO_START1_Polarity; /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */ if (cmd->start_arg & CR_EDGE) - devpriv->ao_trigger_select |= AO_START1_Edge; // 0=edge detection disabled, 1=enabled + devpriv->ao_trigger_select |= AO_START1_Edge; /* 0=edge detection disabled, 1=enabled */ devpriv->stc_writew(dev, devpriv->ao_trigger_select, AO_Trigger_Select_Register); break; default: @@ -3139,9 +3137,9 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); switch (cmd->stop_src) { case TRIG_COUNT: - if(boardtype.reg_type & ni_reg_m_series_mask) + if (boardtype.reg_type & ni_reg_m_series_mask) { - // this is how the NI example code does it for m-series boards, verified correct with 6259 + /* this is how the NI example code does it for m-series boards, verified correct with 6259 */ devpriv->stc_writel(dev, cmd->stop_arg - 1, AO_UC_Load_A_Register); devpriv->stc_writew(dev, AO_UC_Load, AO_Command_1_Register); }else @@ -3244,7 +3242,7 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) bits |= AO_Number_Of_DAC_Packages; #endif devpriv->stc_writew(dev, bits, AO_Personal_Register); - // enable sending of ao dma requests + /* enable sending of ao dma requests */ devpriv->stc_writew(dev, AO_AOFREQ_Enable, AO_Start_Select_Register); devpriv->stc_writew(dev, AO_Configuration_End, Joint_Reset_Register); @@ -3261,8 +3259,8 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ni_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -3384,13 +3382,13 @@ static int ni_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) { - //devpriv->ao0p=0x0000; - //ni_writew(devpriv->ao0p,AO_Configuration); + /* devpriv->ao0p=0x0000; */ + /* ni_writew(devpriv->ao0p,AO_Configuration); */ - //devpriv->ao1p=AO_Channel(1); - //ni_writew(devpriv->ao1p,AO_Configuration); + /* devpriv->ao1p=AO_Channel(1); */ + /* ni_writew(devpriv->ao1p,AO_Configuration); */ ni_release_ao_mite_channel(dev); @@ -3422,7 +3420,7 @@ static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s) if (boardtype.reg_type & ni_reg_6xxx_mask) { unsigned immediate_bits = 0; unsigned i; - for(i = 0; i < s->n_chan; ++i) + for (i = 0; i < s->n_chan; ++i) { immediate_bits |= 1 << i; } @@ -3434,13 +3432,13 @@ static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -// digital io +/* digital io */ -static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { #ifdef DEBUG_DIO - rt_printk("ni_dio_insn_config() chan=%d io=%d\n", + printk("ni_dio_insn_config() chan=%d io=%d\n", CR_CHAN(insn->chanspec), data[0]); #endif switch (data[0]) { @@ -3468,11 +3466,11 @@ static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevic return 1; } -static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { #ifdef DEBUG_DIO - rt_printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]); + printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]); #endif if (insn->n != 2) return -EINVAL; @@ -3495,11 +3493,11 @@ static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int ni_m_series_dio_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_m_series_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { #ifdef DEBUG_DIO - rt_printk("ni_m_series_dio_insn_config() chan=%d io=%d\n", + printk("ni_m_series_dio_insn_config() chan=%d io=%d\n", CR_CHAN(insn->chanspec), data[0]); #endif switch (data[0]) { @@ -3525,11 +3523,11 @@ static int ni_m_series_dio_insn_config(struct comedi_device * dev, return 1; } -static int ni_m_series_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_m_series_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { #ifdef DEBUG_DIO - rt_printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], + printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]); #endif if (insn->n != 2) @@ -3544,8 +3542,8 @@ static int ni_m_series_dio_insn_bits(struct comedi_device * dev, struct comedi_s return 2; } -static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -3653,7 +3651,7 @@ static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct comedi_cmd *cmd = &s->async->cmd; unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit; @@ -3690,7 +3688,7 @@ static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { #ifdef PCIDMA @@ -3706,7 +3704,7 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz); #ifdef PCIDMA - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->cdo_mite_chan) { mite_prep_dma(devpriv->cdo_mite_chan, 32, 32); mite_dma_arm(devpriv->cdo_mite_chan); @@ -3714,17 +3712,19 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * comedi_error(dev, "BUG: no cdo mite channel?"); retval = -EIO; } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); if (retval < 0) return retval; #endif -// XXX not sure what interrupt C group does -// ni_writeb(Interrupt_Group_C_Enable_Bit, M_Offset_Interrupt_C_Enable); - //wait for dma to fill output fifo +/* +* XXX not sure what interrupt C group does +* ni_writeb(Interrupt_Group_C_Enable_Bit, +* M_Offset_Interrupt_C_Enable); wait for dma to fill output fifo +*/ for (i = 0; i < timeout; ++i) { if (ni_readl(M_Offset_CDIO_Status) & CDO_FIFO_Full_Bit) break; - comedi_udelay(10); + udelay(10); } if (i == timeout) { comedi_error(dev, "dma failed to fill cdo fifo!"); @@ -3736,20 +3736,22 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * return retval; } -static int ni_cdio_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { ni_writel(CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit | CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit | CDO_FIFO_Request_Interrupt_Enable_Clear_Bit, M_Offset_CDIO_Command); -// XXX not sure what interrupt C group does -// ni_writeb(0, M_Offset_Interrupt_C_Enable); +/* +* XXX not sure what interrupt C group does ni_writeb(0, +* M_Offset_Interrupt_C_Enable); +*/ ni_writel(0, M_Offset_CDO_Mask_Enable); ni_release_cdo_mite_channel(dev); return 0; } -static void handle_cdio_interrupt(struct comedi_device * dev) +static void handle_cdio_interrupt(struct comedi_device *dev) { unsigned cdio_status; struct comedi_subdevice *s = dev->subdevices + NI_DIO_SUBDEV; @@ -3761,7 +3763,7 @@ static void handle_cdio_interrupt(struct comedi_device * dev) return; } #ifdef PCIDMA - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->cdo_mite_chan) { unsigned cdo_mite_status = mite_get_status(devpriv->cdo_mite_chan); @@ -3772,26 +3774,26 @@ static void handle_cdio_interrupt(struct comedi_device * dev) } mite_sync_output_dma(devpriv->cdo_mite_chan, s->async); } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); #endif cdio_status = ni_readl(M_Offset_CDIO_Status); if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) { -// rt_printk("cdio error: statux=0x%x\n", cdio_status); - ni_writel(CDO_Error_Interrupt_Confirm_Bit, M_Offset_CDIO_Command); // XXX just guessing this is needed and does something useful +/* printk("cdio error: statux=0x%x\n", cdio_status); */ + ni_writel(CDO_Error_Interrupt_Confirm_Bit, M_Offset_CDIO_Command); /* XXX just guessing this is needed and does something useful */ s->async->events |= COMEDI_CB_OVERFLOW; } if (cdio_status & CDO_FIFO_Empty_Bit) { -// rt_printk("cdio fifo empty\n"); +/* printk("cdio fifo empty\n"); */ ni_writel(CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit, M_Offset_CDIO_Command); -// s->async->events |= COMEDI_CB_EOA; +/* s->async->events |= COMEDI_CB_EOA; */ } ni_event(dev, s); } -static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int err = insn->n; unsigned char byte_out, byte_in = 0; @@ -3803,7 +3805,7 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde case INSN_CONFIG_SERIAL_CLOCK: #ifdef DEBUG_DIO - rt_printk("SPI serial clock Config cd\n", data[1]); + printk("SPI serial clock Config cd\n", data[1]); #endif devpriv->serial_hw_mode = 1; devpriv->dio_control |= DIO_HW_Serial_Enable; @@ -3869,7 +3871,7 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde err = ni_serial_sw_readwrite8(dev, s, byte_out, &byte_in); } else { - rt_printk("ni_serial_insn_config: serial disabled!\n"); + printk("ni_serial_insn_config: serial disabled!\n"); return -EINVAL; } if (err < 0) @@ -3884,14 +3886,14 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde } -static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s, unsigned char data_out, unsigned char *data_in) { unsigned int status1; int err = 0, count = 20; #ifdef DEBUG_DIO - rt_printk("ni_serial_hw_readwrite8: outputting 0x%x\n", data_out); + printk("ni_serial_hw_readwrite8: outputting 0x%x\n", data_out); #endif devpriv->dio_output &= ~DIO_Serial_Data_Mask; @@ -3914,9 +3916,9 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub Joint_Status_1_Register)) & DIO_Serial_IO_In_Progress_St) { /* Delay one bit per loop */ - comedi_udelay((devpriv->serial_interval_ns + 999) / 1000); + udelay((devpriv->serial_interval_ns + 999) / 1000); if (--count < 0) { - rt_printk + printk ("ni_serial_hw_readwrite8: SPI serial I/O didn't finish in time!\n"); err = -ETIME; goto Error; @@ -3925,12 +3927,12 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub /* Delay for last bit. This delay is absolutely necessary, because DIO_Serial_IO_In_Progress_St goes high one bit too early. */ - comedi_udelay((devpriv->serial_interval_ns + 999) / 1000); + udelay((devpriv->serial_interval_ns + 999) / 1000); if (data_in != NULL) { *data_in = devpriv->stc_readw(dev, DIO_Serial_Input_Register); #ifdef DEBUG_DIO - rt_printk("ni_serial_hw_readwrite8: inputted 0x%x\n", *data_in); + printk("ni_serial_hw_readwrite8: inputted 0x%x\n", *data_in); #endif } @@ -3940,17 +3942,17 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub return err; } -static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_serial_sw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s, unsigned char data_out, unsigned char *data_in) { unsigned char mask, input = 0; #ifdef DEBUG_DIO - rt_printk("ni_serial_sw_readwrite8: outputting 0x%x\n", data_out); + printk("ni_serial_sw_readwrite8: outputting 0x%x\n", data_out); #endif /* Wait for one bit before transfer */ - comedi_udelay((devpriv->serial_interval_ns + 999) / 1000); + udelay((devpriv->serial_interval_ns + 999) / 1000); for (mask = 0x80; mask; mask >>= 1) { /* Output current bit; note that we cannot touch s->state @@ -3969,23 +3971,23 @@ static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_sub devpriv->stc_writew(dev, devpriv->dio_control, DIO_Control_Register); - comedi_udelay((devpriv->serial_interval_ns + 999) / 2000); + udelay((devpriv->serial_interval_ns + 999) / 2000); devpriv->dio_control &= ~DIO_Software_Serial_Control; devpriv->stc_writew(dev, devpriv->dio_control, DIO_Control_Register); - comedi_udelay((devpriv->serial_interval_ns + 999) / 2000); + udelay((devpriv->serial_interval_ns + 999) / 2000); /* Input current bit */ if (devpriv->stc_readw(dev, DIO_Parallel_Input_Register) & DIO_SDIN) { -/* rt_printk("DIO_P_I_R: 0x%x\n", devpriv->stc_readw(dev, DIO_Parallel_Input_Register)); */ +/* printk("DIO_P_I_R: 0x%x\n", devpriv->stc_readw(dev, DIO_Parallel_Input_Register)); */ input |= mask; } } #ifdef DEBUG_DIO - rt_printk("ni_serial_sw_readwrite8: inputted 0x%x\n", input); + printk("ni_serial_sw_readwrite8: inputted 0x%x\n", input); #endif if (data_in) *data_in = input; @@ -3993,7 +3995,7 @@ static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_sub return 0; } -static void mio_common_detach(struct comedi_device * dev) +static void mio_common_detach(struct comedi_device *dev) { if (dev->private) { if (devpriv->counter_dev) { @@ -4004,7 +4006,7 @@ static void mio_common_detach(struct comedi_device * dev) subdev_8255_cleanup(dev, dev->subdevices + NI_8255_DIO_SUBDEV); } -static void init_ao_67xx(struct comedi_device * dev, struct comedi_subdevice * s) +static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) { int i; @@ -4099,8 +4101,8 @@ static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg) stc_register = Interrupt_B_Enable_Register; break; default: - rt_printk("%s: unhandled register 0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: unhandled register 0x%x in switch.\n", + __func__, reg); BUG(); return 0; break; @@ -4208,15 +4210,15 @@ static unsigned ni_gpct_read_register(struct ni_gpct *counter, return 0; } -static int ni_freq_out_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_freq_out_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->clock_and_fout & FOUT_Divider_mask; return 1; } -static int ni_freq_out_insn_write(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_freq_out_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { devpriv->clock_and_fout &= ~FOUT_Enable; devpriv->stc_writew(dev, devpriv->clock_and_fout, @@ -4229,7 +4231,7 @@ static int ni_freq_out_insn_write(struct comedi_device * dev, return insn->n; } -static int ni_set_freq_out_clock(struct comedi_device * dev, unsigned int clock_source) +static int ni_set_freq_out_clock(struct comedi_device *dev, unsigned int clock_source) { switch (clock_source) { case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC: @@ -4246,8 +4248,8 @@ static int ni_set_freq_out_clock(struct comedi_device * dev, unsigned int clock_ return 3; } -static void ni_get_freq_out_clock(struct comedi_device * dev, unsigned int * clock_source, - unsigned int * clock_period_ns) +static void ni_get_freq_out_clock(struct comedi_device *dev, unsigned int *clock_source, + unsigned int *clock_period_ns) { if (devpriv->clock_and_fout & FOUT_Timebase_Select) { *clock_source = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC; @@ -4258,8 +4260,8 @@ static void ni_get_freq_out_clock(struct comedi_device * dev, unsigned int * clo } } -static int ni_freq_out_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_freq_out_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { case INSN_CONFIG_SET_CLOCK_SRC: @@ -4274,11 +4276,11 @@ static int ni_freq_out_insn_config(struct comedi_device * dev, struct comedi_sub return -EINVAL; } -static int ni_alloc_private(struct comedi_device * dev) +static int ni_alloc_private(struct comedi_device *dev) { int ret; - ret = alloc_private(dev, sizeof(ni_private)); + ret = alloc_private(dev, sizeof(struct ni_private)); if (ret < 0) return ret; @@ -4289,7 +4291,7 @@ static int ni_alloc_private(struct comedi_device * dev) return 0; }; -static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it) +static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned j; @@ -4419,14 +4421,14 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it) s = dev->subdevices + NI_CALIBRATION_SUBDEV; s->type = COMEDI_SUBD_CALIB; if (boardtype.reg_type & ni_reg_m_series_mask) { - // internal PWM analog output used for AI nonlinearity calibration + /* internal PWM analog output used for AI nonlinearity calibration */ s->subdev_flags = SDF_INTERNAL; s->insn_config = &ni_m_series_pwm_config; s->n_chan = 1; s->maxdata = 0; ni_writel(0x0, M_Offset_Cal_PWM); } else if (boardtype.reg_type == ni_reg_6143) { - // internal PWM analog output used for AI nonlinearity calibration + /* internal PWM analog output used for AI nonlinearity calibration */ s->subdev_flags = SDF_INTERNAL; s->insn_config = &ni_6143_pwm_config; s->n_chan = 1; @@ -4478,7 +4480,7 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it) if (boardtype.reg_type & ni_reg_67xx_mask) { s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_INTERNAL; - // one channel for each analog output channel + /* one channel for each analog output channel */ s->n_chan = boardtype.n_aochan; s->maxdata = (1 << 16) - 1; s->range_table = &range_unknown; /* XXX */ @@ -4557,7 +4559,7 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it) /* ai configuration */ ni_ai_reset(dev, dev->subdevices + NI_AI_SUBDEV); if ((boardtype.reg_type & ni_reg_6xxx_mask) == 0) { - // BEAM is this needed for PCI-6143 ?? + /* BEAM is this needed for PCI-6143 ?? */ devpriv->clock_and_fout = Slow_Internal_Time_Divide_By_2 | Slow_Internal_Timebase | @@ -4623,8 +4625,8 @@ static int ni_8255_callback(int dir, int port, int data, unsigned long arg) presents the EEPROM as a subdevice */ -static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_eeprom_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = ni_read_eeprom(dev, CR_CHAN(insn->chanspec)); @@ -4635,7 +4637,7 @@ static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevi reads bytes out of eeprom */ -static int ni_read_eeprom(struct comedi_device * dev, int addr) +static int ni_read_eeprom(struct comedi_device *dev, int addr) { int bit; int bitstring; @@ -4659,23 +4661,23 @@ static int ni_read_eeprom(struct comedi_device * dev, int addr) return bitstring; } -static int ni_m_series_eeprom_insn_read(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int ni_m_series_eeprom_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->eeprom_buffer[CR_CHAN(insn->chanspec)]; return 1; } -static int ni_get_pwm_config(struct comedi_device * dev, unsigned int * data) +static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data) { data[1] = devpriv->pwm_up_count * devpriv->clock_ns; data[2] = devpriv->pwm_down_count * devpriv->clock_ns; return 3; } -static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned up_count, down_count; switch (data[0]) { @@ -4739,8 +4741,8 @@ static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subd return 0; } -static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned up_count, down_count; switch (data[0]) { @@ -4802,20 +4804,20 @@ static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevic return 0; } -static void ni_write_caldac(struct comedi_device * dev, int addr, int val); +static void ni_write_caldac(struct comedi_device *dev, int addr, int val); /* calibration subdevice */ -static int ni_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { ni_write_caldac(dev, CR_CHAN(insn->chanspec), data[0]); return 1; } -static int ni_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = devpriv->caldacs[CR_CHAN(insn->chanspec)]; @@ -4845,7 +4847,7 @@ static struct caldac_struct caldacs[] = { [ad8804_debug] = {16, 8, pack_ad8804}, }; -static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s) +static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s) { int i, j; int n_dacs; @@ -4898,13 +4900,13 @@ static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s } } -static void ni_write_caldac(struct comedi_device * dev, int addr, int val) +static void ni_write_caldac(struct comedi_device *dev, int addr, int val) { unsigned int loadbit = 0, bits = 0, bit, bitstring = 0; int i; int type; - //printk("ni_write_caldac: chan=%d val=%d\n",addr,val); + /* printk("ni_write_caldac: chan=%d val=%d\n",addr,val); */ if (devpriv->caldacs[addr] == val) return; devpriv->caldacs[addr] = val; @@ -4916,7 +4918,7 @@ static void ni_write_caldac(struct comedi_device * dev, int addr, int val) if (addr < caldacs[type].n_chans) { bits = caldacs[type].packbits(addr, val, &bitstring); loadbit = SerDacLd(i); - //printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring); + /* printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring); */ break; } addr -= caldacs[type].n_chans; @@ -4924,12 +4926,12 @@ static void ni_write_caldac(struct comedi_device * dev, int addr, int val) for (bit = 1 << (bits - 1); bit; bit >>= 1) { ni_writeb(((bit & bitstring) ? 0x02 : 0), Serial_Command); - comedi_udelay(1); + udelay(1); ni_writeb(1 | ((bit & bitstring) ? 0x02 : 0), Serial_Command); - comedi_udelay(1); + udelay(1); } ni_writeb(loadbit, Serial_Command); - comedi_udelay(1); + udelay(1); ni_writeb(0, Serial_Command); } @@ -4985,7 +4987,7 @@ static int pack_ad8842(int addr, int val, int *bitstring) /* * Read the GPCTs current value. */ -static int GPCT_G_Watch(struct comedi_device * dev, int chan) +static int GPCT_G_Watch(struct comedi_device *dev, int chan) { unsigned int hi1, hi2, lo; @@ -5008,11 +5010,11 @@ static int GPCT_G_Watch(struct comedi_device * dev, int chan) return (hi1 << 16) | lo; } -static void GPCT_Reset(struct comedi_device * dev, int chan) +static void GPCT_Reset(struct comedi_device *dev, int chan) { int temp_ack_reg = 0; - //printk("GPCT_Reset..."); + /* printk("GPCT_Reset..."); */ devpriv->gpct_cur_operation[chan] = GPCT_RESET; switch (chan) { @@ -5029,7 +5031,7 @@ static void GPCT_Reset(struct comedi_device * dev, int chan) devpriv->stc_writew(dev, temp_ack_reg, Interrupt_A_Ack_Register); - //problem...this interferes with the other ctr... + /* problem...this interferes with the other ctr... */ devpriv->an_trig_etc_reg |= GPFO_0_Output_Enable; devpriv->stc_writew(dev, devpriv->an_trig_etc_reg, Analog_Trigger_Etc_Register); @@ -5065,38 +5067,38 @@ static void GPCT_Reset(struct comedi_device * dev, int chan) G_Input_Select_Register(chan)); devpriv->stc_writew(dev, 0, G_Autoincrement_Register(chan)); - //printk("exit GPCT_Reset\n"); + /* printk("exit GPCT_Reset\n"); */ } #endif -static int ni_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct ni_gpct *counter = s->private; return ni_tio_insn_config(counter, insn, data); } -static int ni_gpct_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_gpct_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct ni_gpct *counter = s->private; return ni_tio_rinsn(counter, insn, data); } -static int ni_gpct_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_gpct_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct ni_gpct *counter = s->private; return ni_tio_winsn(counter, insn, data); } -static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int retval; #ifdef PCIDMA struct ni_gpct *counter = s->private; -// const struct comedi_cmd *cmd = &s->async->cmd; +/* const struct comedi_cmd *cmd = &s->async->cmd; */ retval = ni_request_gpct_mite_channel(dev, counter->counter_index, COMEDI_INPUT); @@ -5114,8 +5116,8 @@ static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return retval; } -static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ni_gpct_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { #ifdef PCIDMA struct ni_gpct *counter = s->private; @@ -5126,7 +5128,7 @@ static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice * #endif } -static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { #ifdef PCIDMA struct ni_gpct *counter = s->private; @@ -5147,7 +5149,7 @@ static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice * * */ -static int ni_m_series_set_pfi_routing(struct comedi_device * dev, unsigned chan, +static int ni_m_series_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { unsigned pfi_reg_index; @@ -5165,16 +5167,16 @@ static int ni_m_series_set_pfi_routing(struct comedi_device * dev, unsigned chan return 2; } -static int ni_old_set_pfi_routing(struct comedi_device * dev, unsigned chan, +static int ni_old_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { - // pre-m-series boards have fixed signals on pfi pins + /* pre-m-series boards have fixed signals on pfi pins */ if (source != ni_old_get_pfi_routing(dev, chan)) return -EINVAL; return 2; } -static int ni_set_pfi_routing(struct comedi_device * dev, unsigned chan, +static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { if (boardtype.reg_type & ni_reg_m_series_mask) @@ -5183,16 +5185,16 @@ static int ni_set_pfi_routing(struct comedi_device * dev, unsigned chan, return ni_old_set_pfi_routing(dev, chan, source); } -static unsigned ni_m_series_get_pfi_routing(struct comedi_device * dev, unsigned chan) +static unsigned ni_m_series_get_pfi_routing(struct comedi_device *dev, unsigned chan) { const unsigned array_offset = chan / 3; return MSeries_PFI_Output_Select_Source(chan, devpriv->pfi_output_select_reg[array_offset]); } -static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan) +static unsigned ni_old_get_pfi_routing(struct comedi_device *dev, unsigned chan) { - // pre-m-series boards have fixed signals on pfi pins + /* pre-m-series boards have fixed signals on pfi pins */ switch (chan) { case 0: return NI_PFI_OUTPUT_AI_START1; @@ -5225,13 +5227,13 @@ static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan return NI_PFI_OUTPUT_G_GATE0; break; default: - rt_printk("%s: bug, unhandled case in switch.\n", __FUNCTION__); + printk("%s: bug, unhandled case in switch.\n", __func__); break; } return 0; } -static unsigned ni_get_pfi_routing(struct comedi_device * dev, unsigned chan) +static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan) { if (boardtype.reg_type & ni_reg_m_series_mask) return ni_m_series_get_pfi_routing(dev, chan); @@ -5239,7 +5241,7 @@ static unsigned ni_get_pfi_routing(struct comedi_device * dev, unsigned chan) return ni_old_get_pfi_routing(dev, chan); } -static int ni_config_filter(struct comedi_device * dev, unsigned pfi_channel, +static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel, enum ni_pfi_filter_select filter) { unsigned bits; @@ -5253,8 +5255,8 @@ static int ni_config_filter(struct comedi_device * dev, unsigned pfi_channel, return 0; } -static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_pfi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if ((boardtype.reg_type & ni_reg_m_series_mask) == 0) { return -ENOTSUPP; @@ -5268,8 +5270,8 @@ static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_pfi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int chan; @@ -5312,16 +5314,16 @@ static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevic * NI RTSI Bus Functions * */ -static void ni_rtsi_init(struct comedi_device * dev) +static void ni_rtsi_init(struct comedi_device *dev) { - // Initialises the RTSI bus signal switch to a default state + /* Initialises the RTSI bus signal switch to a default state */ - // Set clock mode to internal + /* Set clock mode to internal */ devpriv->clock_and_fout2 = MSeries_RTSI_10MHz_Bit; if (ni_set_master_clock(dev, NI_MIO_INTERNAL_CLOCK, 0) < 0) { - rt_printk("ni_set_master_clock failed, bug?"); + printk("ni_set_master_clock failed, bug?"); } - // default internal lines routing to RTSI bus lines + /* default internal lines routing to RTSI bus lines */ devpriv->rtsi_trig_a_output_reg = RTSI_Trig_Output_Bits(0, NI_RTSI_OUTPUT_ADR_START1) | RTSI_Trig_Output_Bits(1, @@ -5341,12 +5343,14 @@ static void ni_rtsi_init(struct comedi_device * dev) devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg, RTSI_Trig_B_Output_Register); - // Sets the source and direction of the 4 on board lines -// devpriv->stc_writew(dev, 0x0000, RTSI_Board_Register); +/* +* Sets the source and direction of the 4 on board lines +* devpriv->stc_writew(dev, 0x0000, RTSI_Board_Register); +*/ } -static int ni_rtsi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_rtsi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -5389,8 +5393,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns, } } if (best_period_picosec == 0) { - rt_printk("%s: bug, failed to find pll parameters\n", - __FUNCTION__); + printk("%s: bug, failed to find pll parameters\n", + __func__); return -EIO; } *freq_divider = best_div; @@ -5401,7 +5405,7 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns, return 0; } -static inline unsigned num_configurable_rtsi_channels(struct comedi_device * dev) +static inline unsigned num_configurable_rtsi_channels(struct comedi_device *dev) { if (boardtype.reg_type & ni_reg_m_series_mask) return 8; @@ -5409,7 +5413,7 @@ static inline unsigned num_configurable_rtsi_channels(struct comedi_device * dev return 7; } -static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned source, +static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned source, unsigned period_ns) { static const unsigned min_period_ns = 50; @@ -5422,11 +5426,11 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned int retval; if (source == NI_MIO_PLL_PXI10_CLOCK) period_ns = 100; - // these limits are somewhat arbitrary, but NI advertises 1 to 20MHz range so we'll use that + /* these limits are somewhat arbitrary, but NI advertises 1 to 20MHz range so we'll use that */ if (period_ns < min_period_ns || period_ns > max_period_ns) { - rt_printk + printk ("%s: you must specify an input clock frequency between %i and %i nanosec " - "for the phased-lock loop.\n", __FUNCTION__, + "for the phased-lock loop.\n", __func__, min_period_ns, max_period_ns); return -EINVAL; } @@ -5484,8 +5488,10 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned pll_control_bits |= MSeries_PLL_Divisor_Bits(freq_divider) | MSeries_PLL_Multiplier_Bits(freq_multiplier); -// rt_printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n", freq_divider, freq_multiplier, pll_control_bits); -// rt_printk("clock_ns=%d\n", devpriv->clock_ns); + + /* printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n", + * freq_divider, freq_multiplier, pll_control_bits); */ + /* printk("clock_ns=%d\n", devpriv->clock_ns); */ ni_writew(pll_control_bits, M_Offset_PLL_Control); devpriv->clock_source = source; /* it seems to typically take a few hundred microseconds for PLL to lock */ @@ -5496,15 +5502,15 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned udelay(1); } if (i == timeout) { - rt_printk + printk ("%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns.\n", - __FUNCTION__, source, period_ns); + __func__, source, period_ns); return -ETIMEDOUT; } return 3; } -static int ni_set_master_clock(struct comedi_device * dev, unsigned source, +static int ni_set_master_clock(struct comedi_device *dev, unsigned source, unsigned period_ns) { if (source == NI_MIO_INTERNAL_CLOCK) { @@ -5533,9 +5539,9 @@ static int ni_set_master_clock(struct comedi_device * dev, unsigned source, devpriv->rtsi_trig_direction_reg, RTSI_Trig_Direction_Register); if (period_ns == 0) { - rt_printk + printk ("%s: we don't handle an unspecified clock period correctly yet, returning error.\n", - __FUNCTION__); + __func__); return -EINVAL; } else { devpriv->clock_ns = period_ns; @@ -5548,7 +5554,7 @@ static int ni_set_master_clock(struct comedi_device * dev, unsigned source, return 3; } -static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan, +static int ni_valid_rtsi_output_source(struct comedi_device *dev, unsigned chan, unsigned source) { if (chan >= num_configurable_rtsi_channels(dev)) { @@ -5556,9 +5562,9 @@ static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan if (source == NI_RTSI_OUTPUT_RTSI_OSC) return 1; else { - rt_printk + printk ("%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards.\n", - __FUNCTION__, chan, + __func__, chan, old_RTSI_clock_channel); return 0; } @@ -5589,7 +5595,7 @@ static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan } } -static int ni_set_rtsi_routing(struct comedi_device * dev, unsigned chan, +static int ni_set_rtsi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { if (ni_valid_rtsi_output_source(dev, chan, source) == 0) @@ -5610,7 +5616,7 @@ static int ni_set_rtsi_routing(struct comedi_device * dev, unsigned chan, return 2; } -static unsigned ni_get_rtsi_routing(struct comedi_device * dev, unsigned chan) +static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan) { if (chan < 4) { return RTSI_Trig_Output_Source(chan, @@ -5621,13 +5627,13 @@ static unsigned ni_get_rtsi_routing(struct comedi_device * dev, unsigned chan) } else { if (chan == old_RTSI_clock_channel) return NI_RTSI_OUTPUT_RTSI_OSC; - rt_printk("%s: bug! should never get here?\n", __FUNCTION__); + printk("%s: bug! should never get here?\n", __func__); return 0; } } -static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ni_rtsi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); switch (data[0]) { @@ -5698,7 +5704,7 @@ static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevi return 1; } -static int cs5529_wait_for_idle(struct comedi_device * dev) +static int cs5529_wait_for_idle(struct comedi_device *dev) { unsigned short status; const int timeout = HZ; @@ -5714,15 +5720,15 @@ static int cs5529_wait_for_idle(struct comedi_device * dev) return -EIO; } } -//printk("looped %i times waiting for idle\n", i); +/* printk("looped %i times waiting for idle\n", i); */ if (i == timeout) { - rt_printk("%s: %s: timeout\n", __FILE__, __FUNCTION__); + printk("%s: %s: timeout\n", __FILE__, __func__); return -ETIME; } return 0; } -static void cs5529_command(struct comedi_device * dev, unsigned short value) +static void cs5529_command(struct comedi_device *dev, unsigned short value) { static const int timeout = 100; int i; @@ -5735,16 +5741,16 @@ static void cs5529_command(struct comedi_device * dev, unsigned short value) for (i = 0; i < timeout; i++) { if ((ni_ao_win_inw(dev, CAL_ADC_Status_67xx) & CSS_ADC_BUSY)) break; - comedi_udelay(1); + udelay(1); } -//printk("looped %i times writing command to cs5529\n", i); +/* printk("looped %i times writing command to cs5529\n", i); */ if (i == timeout) { comedi_error(dev, "possible problem - never saw adc go busy?"); } } /* write to cs5529 register */ -static void cs5529_config_write(struct comedi_device * dev, unsigned int value, +static void cs5529_config_write(struct comedi_device *dev, unsigned int value, unsigned int reg_select_bits) { ni_ao_win_outw(dev, ((value >> 16) & 0xff), @@ -5759,7 +5765,7 @@ static void cs5529_config_write(struct comedi_device * dev, unsigned int value, #ifdef NI_CS5529_DEBUG /* read from cs5529 register */ -static unsigned int cs5529_config_read(struct comedi_device * dev, +static unsigned int cs5529_config_read(struct comedi_device *dev, unsigned int reg_select_bits) { unsigned int value; @@ -5775,7 +5781,7 @@ static unsigned int cs5529_config_read(struct comedi_device * dev, } #endif -static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data) +static int cs5529_do_conversion(struct comedi_device *dev, unsigned short *data) { int retval; unsigned short status; @@ -5789,12 +5795,12 @@ static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data } status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx); if (status & CSS_OSC_DETECT) { - rt_printk + printk ("ni_mio_common: cs5529 conversion error, status CSS_OSC_DETECT\n"); return -EIO; } if (status & CSS_OVERRANGE) { - rt_printk + printk ("ni_mio_common: cs5529 conversion error, overrange (ignoring)\n"); } if (data) { @@ -5805,8 +5811,8 @@ static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data return 0; } -static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int cs5529_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, retval; unsigned short sample; @@ -5831,7 +5837,7 @@ static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi return insn->n; } -static int init_cs5529(struct comedi_device * dev) +static int init_cs5529(struct comedi_device *dev) { unsigned int config_bits = CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES; @@ -5851,11 +5857,11 @@ static int init_cs5529(struct comedi_device * dev) comedi_error(dev, "timeout or signal in init_cs5529()\n"); #endif #ifdef NI_CS5529_DEBUG - rt_printk("config: 0x%x\n", cs5529_config_read(dev, + printk("config: 0x%x\n", cs5529_config_read(dev, CSCMD_CONFIG_REGISTER)); - rt_printk("gain: 0x%x\n", cs5529_config_read(dev, + printk("gain: 0x%x\n", cs5529_config_read(dev, CSCMD_GAIN_REGISTER)); - rt_printk("offset: 0x%x\n", cs5529_config_read(dev, + printk("offset: 0x%x\n", cs5529_config_read(dev, CSCMD_OFFSET_REGISTER)); #endif return 0; diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c index d6357c25aca5..4d408d410c24 100644 --- a/drivers/staging/comedi/drivers/ni_mio_cs.c +++ b/drivers/staging/comedi/drivers/ni_mio_cs.c @@ -66,103 +66,103 @@ See the notes in the ni_atmio.o driver. #define MAX_N_CALDACS 32 -static const ni_board ni_boards[] = { - {device_id:0x010d, - name: "DAQCard-ai-16xe-50", - n_adchan:16, - adbits: 16, - ai_fifo_depth:1024, - alwaysdither:0, - gainlkup:ai_gain_8, - ai_speed:5000, - n_aochan:0, - aobits: 0, - ao_fifo_depth:0, - ao_unipolar:0, - num_p0_dio_channels:8, - has_8255:0, - caldac: {dac8800, dac8043}, - }, - {device_id:0x010c, - name: "DAQCard-ai-16e-4", - n_adchan:16, - adbits: 12, - ai_fifo_depth:1024, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:4000, - n_aochan:0, - aobits: 0, - ao_fifo_depth:0, - ao_unipolar:0, - num_p0_dio_channels:8, - has_8255:0, - caldac: {mb88341}, /* verified */ - }, - {device_id:0x02c4, - name: "DAQCard-6062E", - n_adchan:16, - adbits: 12, - ai_fifo_depth:8192, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:2000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:2048, - ao_range_table:&range_bipolar10, - ao_unipolar:0, - ao_speed:1176, - num_p0_dio_channels:8, - has_8255:0, - caldac: {ad8804_debug}, /* verified */ - }, - {device_id:0x075e, - name: "DAQCard-6024E", /* specs incorrect! */ - n_adchan:16, - adbits: 12, - ai_fifo_depth:1024, - alwaysdither:0, - gainlkup:ai_gain_16, - ai_speed:5000, - n_aochan:2, - aobits: 12, - ao_fifo_depth:0, - ao_range_table:&range_bipolar10, - ao_unipolar:0, - ao_speed:1000000, - num_p0_dio_channels:8, - has_8255:0, - caldac: {ad8804_debug}, - }, - {device_id:0x0245, - name: "DAQCard-6036E", /* specs incorrect! */ - n_adchan:16, - adbits: 16, - ai_fifo_depth:1024, - alwaysdither:1, - gainlkup:ai_gain_4, - ai_speed:5000, - n_aochan:2, - aobits: 16, - ao_fifo_depth:0, - ao_range_table:&range_bipolar10, - ao_unipolar:0, - ao_speed:1000000, - num_p0_dio_channels:8, - has_8255:0, - caldac: {ad8804_debug}, - }, +static const struct ni_board_struct ni_boards[] = { + {.device_id = 0x010d, + .name = "DAQCard-ai-16xe-50", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 1024, + .alwaysdither = 0, + .gainlkup = ai_gain_8, + .ai_speed = 5000, + .n_aochan = 0, + .aobits = 0, + .ao_fifo_depth = 0, + .ao_unipolar = 0, + .num_p0_dio_channels = 8, + .has_8255 = 0, + .caldac = {dac8800, dac8043}, + }, + {.device_id = 0x010c, + .name = "DAQCard-ai-16e-4", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 1024, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 4000, + .n_aochan = 0, + .aobits = 0, + .ao_fifo_depth = 0, + .ao_unipolar = 0, + .num_p0_dio_channels = 8, + .has_8255 = 0, + .caldac = {mb88341}, /* verified */ + }, + {.device_id = 0x02c4, + .name = "DAQCard-6062E", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 8192, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 2000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 2048, + .ao_range_table = &range_bipolar10, + .ao_unipolar = 0, + .ao_speed = 1176, + .num_p0_dio_channels = 8, + .has_8255 = 0, + .caldac = {ad8804_debug}, /* verified */ + }, + {.device_id = 0x075e, + .name = "DAQCard-6024E", /* specs incorrect! */ + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 1024, + .alwaysdither = 0, + .gainlkup = ai_gain_16, + .ai_speed = 5000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 0, + .ao_range_table = &range_bipolar10, + .ao_unipolar = 0, + .ao_speed = 1000000, + .num_p0_dio_channels = 8, + .has_8255 = 0, + .caldac = {ad8804_debug}, + }, + {.device_id = 0x0245, + .name = "DAQCard-6036E", /* specs incorrect! */ + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 1024, + .alwaysdither = 1, + .gainlkup = ai_gain_4, + .ai_speed = 5000, + .n_aochan = 2, + .aobits = 16, + .ao_fifo_depth = 0, + .ao_range_table = &range_bipolar10, + .ao_unipolar = 0, + .ao_speed = 1000000, + .num_p0_dio_channels = 8, + .has_8255 = 0, + .caldac = {ad8804_debug}, + }, #if 0 - {device_id:0x0000, /* unknown */ - name: "DAQCard-6715", - n_adchan:0, - n_aochan:8, - aobits: 12, - ao_671x: 8192, - num_p0_dio_channels:8, - caldac: {mb88341, mb88341}, - }, + {.device_id = 0x0000, /* unknown */ + .name = "DAQCard-6715", + .n_adchan = 0, + .n_aochan = 8, + .aobits = 12, + .ao_671x = 8192, + .num_p0_dio_channels = 8, + .caldac = {mb88341, mb88341}, + }, #endif /* N.B. Update ni_mio_cs_ids[] when entries added above. */ }; @@ -183,11 +183,11 @@ struct ni_private { /* How we access registers */ -#define ni_writel(a,b) (outl((a),(b)+dev->iobase)) +#define ni_writel(a, b) (outl((a), (b)+dev->iobase)) #define ni_readl(a) (inl((a)+dev->iobase)) -#define ni_writew(a,b) (outw((a),(b)+dev->iobase)) +#define ni_writew(a, b) (outw((a), (b)+dev->iobase)) #define ni_readw(a) (inw((a)+dev->iobase)) -#define ni_writeb(a,b) (outb((a),(b)+dev->iobase)) +#define ni_writeb(a, b) (outb((a), (b)+dev->iobase)) #define ni_readb(a) (inb((a)+dev->iobase)) /* How we access windowed registers */ @@ -196,60 +196,60 @@ struct ni_private { * read/written directly in the I/O space of the board. The * DAQCard devices map the low 8 STC registers to iobase+addr*2. */ -static void mio_cs_win_out(struct comedi_device * dev, uint16_t data, int addr) +static void mio_cs_win_out(struct comedi_device *dev, uint16_t data, int addr) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); if (addr < 8) { ni_writew(data, addr * 2); } else { ni_writew(addr, Window_Address); ni_writew(data, Window_Data); } - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); } -static uint16_t mio_cs_win_in(struct comedi_device * dev, int addr) +static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr) { unsigned long flags; uint16_t ret; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); if (addr < 8) { ret = ni_readw(addr * 2); } else { ni_writew(addr, Window_Address); ret = ni_readw(Window_Data); } - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); return ret; } -static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int mio_cs_detach(struct comedi_device * dev); +static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int mio_cs_detach(struct comedi_device *dev); static struct comedi_driver driver_ni_mio_cs = { - driver_name:"ni_mio_cs", - module:THIS_MODULE, - attach:mio_cs_attach, - detach:mio_cs_detach, + .driver_name = "ni_mio_cs", + .module = THIS_MODULE, + .attach = mio_cs_attach, + .detach = mio_cs_detach, }; #include "ni_mio_common.c" -static int ni_getboardtype(struct comedi_device * dev, struct pcmcia_device *link); +static int ni_getboardtype(struct comedi_device *dev, struct pcmcia_device *link); /* clean up allocated resources */ /* called when driver is removed */ -static int mio_cs_detach(struct comedi_device * dev) +static int mio_cs_detach(struct comedi_device *dev) { mio_common_detach(dev); /* PCMCIA layer frees the IO region */ if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } return 0; @@ -344,7 +344,7 @@ static void mio_cs_config(struct pcmcia_device *link) manfid = le16_to_cpu(buf[0]); prodid = le16_to_cpu(buf[1]); } - //printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid); + /* printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid); */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; tuple.Attributes = 0; @@ -381,7 +381,7 @@ static void mio_cs_config(struct pcmcia_device *link) for (base = 0x000; base < 0x400; base += 0x20) { link->io.BasePort1 = base; ret = pcmcia_request_io(link, &link->io); - //printk("RequestIO 0x%02x\n",ret); + /* printk("RequestIO 0x%02x\n",ret); */ if (!ret) break; } @@ -393,17 +393,17 @@ static void mio_cs_config(struct pcmcia_device *link) if (ret) { printk("pcmcia_request_irq() returned error: %i\n", ret); } - //printk("RequestIRQ 0x%02x\n",ret); + /* printk("RequestIRQ 0x%02x\n",ret); */ link->conf.ConfigIndex = 1; ret = pcmcia_request_configuration(link, &link->conf); - //printk("RequestConfiguration %d\n",ret); + /* printk("RequestConfiguration %d\n",ret); */ link->dev_node = &dev_node; } -static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pcmcia_device *link; unsigned int irq; @@ -446,29 +446,33 @@ static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * i printk(" %s", boardtype.name); dev->board_name = boardtype.name; - if ((ret = comedi_request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS, - "ni_mio_cs", dev)) < 0) { + ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS, + "ni_mio_cs", dev); + if (ret < 0) { printk(" irq not available\n"); return -EINVAL; } dev->irq = irq; /* allocate private area */ - if ((ret = ni_alloc_private(dev)) < 0) + ret = ni_alloc_private(dev); + if (ret < 0) return ret; + devpriv->stc_writew = &mio_cs_win_out; devpriv->stc_readw = &mio_cs_win_in; devpriv->stc_writel = &win_out2; devpriv->stc_readl = &win_in2; - if ((ret = ni_E_init(dev, it)) < 0) { + ret = ni_E_init(dev, it); + + if (ret < 0) return ret; - } return 0; } -static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link) +static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link) { tuple_t tuple; u_short buf[128]; @@ -487,7 +491,7 @@ static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link) return prodid; } -static int ni_getboardtype(struct comedi_device * dev, struct pcmcia_device *link) +static int ni_getboardtype(struct comedi_device *dev, struct pcmcia_device *link) { int id; int i; diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 87def2cc9a29..6b86a39aac5e 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -66,9 +66,10 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org */ #define USE_DMA -//#define DEBUG 1 -//#define DEBUG_FLAGS +/* #define DEBUG 1 */ +/* #define DEBUG_FLAGS */ +#include <linux/interrupt.h> #include "../comedidev.h" #include "mite.h" @@ -117,9 +118,9 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org #define Waited (1<<5) #define PrimaryTC (1<<6) #define SecondaryTC (1<<7) - //#define SerialRose - //#define ReqRose - //#define Paused + /* #define SerialRose */ + /* #define ReqRose */ + /* #define Paused */ #define Group_1_First_Clear 6 /* W */ #define Group_2_First_Clear 7 /* W */ @@ -206,7 +207,7 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org #define DMA_Line_Control_Group1 76 #define DMA_Line_Control_Group2 108 -// channel zero is none +/* channel zero is none */ static inline unsigned primary_DMAChannel_bits(unsigned channel) { return channel & 0x3; @@ -287,15 +288,15 @@ enum FPGA_Control_Bits { #define IntEn (TransferReady|CountExpired|Waited|PrimaryTC|SecondaryTC) #endif -static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int nidio_detach(struct comedi_device * dev); -static int ni_pcidio_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int nidio_detach(struct comedi_device *dev); +static int ni_pcidio_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static struct comedi_driver driver_pcidio = { - driver_name:"ni_pcidio", - module:THIS_MODULE, - attach:nidio_attach, - detach:nidio_detach, + .driver_name = "ni_pcidio", + .module = THIS_MODULE, + .attach = nidio_attach, + .detach = nidio_detach, }; struct nidio_board { @@ -309,65 +310,65 @@ struct nidio_board { static const struct nidio_board nidio_boards[] = { { - dev_id: 0x1150, - name: "pci-dio-32hs", - n_8255: 0, - is_diodaq:1, + .dev_id = 0x1150, + .name = "pci-dio-32hs", + .n_8255 = 0, + .is_diodaq = 1, }, { - dev_id: 0x1320, - name: "pxi-6533", - n_8255: 0, - is_diodaq:1, + .dev_id = 0x1320, + .name = "pxi-6533", + .n_8255 = 0, + .is_diodaq = 1, }, { - dev_id: 0x12b0, - name: "pci-6534", - n_8255: 0, - is_diodaq:1, - uses_firmware:1, + .dev_id = 0x12b0, + .name = "pci-6534", + .n_8255 = 0, + .is_diodaq = 1, + .uses_firmware = 1, }, { - dev_id: 0x0160, - name: "pci-dio-96", - n_8255: 4, - is_diodaq:0, + .dev_id = 0x0160, + .name = "pci-dio-96", + .n_8255 = 4, + .is_diodaq = 0, }, { - dev_id: 0x1630, - name: "pci-dio-96b", - n_8255: 4, - is_diodaq:0, + .dev_id = 0x1630, + .name = "pci-dio-96b", + .n_8255 = 4, + .is_diodaq = 0, }, { - dev_id: 0x13c0, - name: "pxi-6508", - n_8255: 4, - is_diodaq:0, + .dev_id = 0x13c0, + .name = "pxi-6508", + .n_8255 = 4, + .is_diodaq = 0, }, { - dev_id: 0x0400, - name: "pci-6503", - n_8255: 1, - is_diodaq:0, + .dev_id = 0x0400, + .name = "pci-6503", + .n_8255 = 1, + .is_diodaq = 0, }, { - dev_id: 0x1250, - name: "pci-6503b", - n_8255: 1, - is_diodaq:0, + .dev_id = 0x1250, + .name = "pci-6503b", + .n_8255 = 1, + .is_diodaq = 0, }, { - dev_id: 0x17d0, - name: "pci-6503x", - n_8255: 1, - is_diodaq:0, + .dev_id = 0x17d0, + .name = "pci-6503x", + .n_8255 = 1, + .is_diodaq = 0, }, { - dev_id: 0x1800, - name: "pxi-6503", - n_8255: 1, - is_diodaq:0, + .dev_id = 0x1800, + .name = "pxi-6503", + .n_8255 = 1, + .is_diodaq = 0, }, }; @@ -401,14 +402,14 @@ struct nidio96_private { }; #define devpriv ((struct nidio96_private *)dev->private) -static int ni_pcidio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int ni_pcidio_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_pcidio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int ni_pcidio_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum); -static int nidio_find_device(struct comedi_device * dev, int bus, int slot); +static int nidio_find_device(struct comedi_device *dev, int bus, int slot); static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode); -static int setup_mite_dma(struct comedi_device * dev, struct comedi_subdevice * s); +static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s); #ifdef DEBUG_FLAGS static void ni_pcidio_print_flags(unsigned int flags); @@ -418,18 +419,17 @@ static void ni_pcidio_print_status(unsigned int status); #define ni_pcidio_print_status(x) #endif -static int ni_pcidio_request_di_mite_channel(struct comedi_device * dev) +static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->di_mite_chan); devpriv->di_mite_chan = mite_request_channel_in_range(devpriv->mite, devpriv->di_mite_ring, 1, 2); if (devpriv->di_mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, - flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); comedi_error(dev, "failed to reserve mite dma channel."); return -EBUSY; } @@ -437,15 +437,15 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device * dev) secondary_DMAChannel_bits(devpriv->di_mite_chan->channel), devpriv->mite->daq_io_addr + DMA_Line_Control_Group1); mmiowb(); - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return 0; } -static void ni_pcidio_release_di_mite_channel(struct comedi_device * dev) +static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->di_mite_chan) { mite_dma_disarm(devpriv->di_mite_chan); mite_dma_reset(devpriv->di_mite_chan); @@ -456,7 +456,7 @@ static void ni_pcidio_release_di_mite_channel(struct comedi_device * dev) devpriv->mite->daq_io_addr + DMA_Line_Control_Group1); mmiowb(); } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); } static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase) @@ -469,7 +469,7 @@ static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase) } } -void ni_pcidio_event(struct comedi_device * dev, struct comedi_subdevice * s) +void ni_pcidio_event(struct comedi_device *dev, struct comedi_subdevice *s) { if (s->async-> events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) @@ -479,14 +479,14 @@ void ni_pcidio_event(struct comedi_device * dev, struct comedi_subdevice * s) comedi_event(dev, s); } -static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t nidio_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices; struct comedi_async *async = s->async; struct mite_struct *mite = devpriv->mite; - //int i, j; + /* int i, j; */ long int AuxData = 0; short data1 = 0; short data2 = 0; @@ -496,9 +496,9 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) unsigned int m_status = 0; unsigned long irq_flags; - //interrupcions parasites + /* interrupcions parasites */ if (dev->attached == 0) { - // assume it's from another card + /* assume it's from another card */ return IRQ_NONE; } @@ -511,17 +511,17 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) ni_pcidio_print_flags(flags); ni_pcidio_print_status(status); - //printk("buf[0]=%08x\n",*(unsigned int *)async->prealloc_buf); - //printk("buf[4096]=%08x\n",*(unsigned int *)(async->prealloc_buf+4096)); + /* printk("buf[0]=%08x\n",*(unsigned int *)async->prealloc_buf); */ + /* printk("buf[4096]=%08x\n",*(unsigned int *)(async->prealloc_buf+4096)); */ - comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, irq_flags); + spin_lock_irqsave(&devpriv->mite_channel_lock, irq_flags); if (devpriv->di_mite_chan) m_status = mite_get_status(devpriv->di_mite_chan); #ifdef MITE_DEBUG mite_print_chsr(m_status); #endif - //printk("mite_bytes_transferred: %d\n",mite_bytes_transferred(mite,DI_DMA_CHAN)); - //mite_dump_regs(mite); + /* printk("mite_bytes_transferred: %d\n",mite_bytes_transferred(mite,DI_DMA_CHAN)); */ + /* mite_dump_regs(mite); */ if (m_status & CHSR_INT) { if (m_status & CHSR_LINKC) { writel(CHOR_CLRLC, @@ -537,7 +537,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) disable_irq(dev->irq); } } - comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, irq_flags); + spin_unlock_irqrestore(&devpriv->mite_channel_lock, irq_flags); while (status & DataLeft) { work++; @@ -552,7 +552,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) flags &= IntEn; if (flags & TransferReady) { - //DPRINTK("TransferReady\n"); + /* DPRINTK("TransferReady\n"); */ while (flags & TransferReady) { work++; if (work > 100) { @@ -569,14 +569,14 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) data2 = (AuxData & 0xffff0000) >> 16; comedi_buf_put(async, data1); comedi_buf_put(async, data2); - //DPRINTK("read:%d, %d\n",data1,data2); + /* DPRINTK("read:%d, %d\n",data1,data2); */ flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags); } - //DPRINTK("buf_int_count: %d\n",async->buf_int_count); - //DPRINTK("1) IntEn=%d,flags=%d,status=%d\n",IntEn,flags,status); - //ni_pcidio_print_flags(flags); - //ni_pcidio_print_status(status); + /* DPRINTK("buf_int_count: %d\n",async->buf_int_count); */ + /* DPRINTK("1) IntEn=%d,flags=%d,status=%d\n",IntEn,flags,status); */ + /* ni_pcidio_print_flags(flags); */ + /* ni_pcidio_print_status(status); */ async->events |= COMEDI_CB_BLOCK; } @@ -621,10 +621,10 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags); status = readb(devpriv->mite->daq_io_addr + Interrupt_And_Window_Status); - //DPRINTK("loop end: IntEn=0x%02x,flags=0x%02x,status=0x%02x\n", - // IntEn,flags,status); - //ni_pcidio_print_flags(flags); - //ni_pcidio_print_status(status); + /* DPRINTK("loop end: IntEn=0x%02x,flags=0x%02x,status=0x%02x\n", */ + /* IntEn,flags,status); */ + /* ni_pcidio_print_flags(flags); */ + /* ni_pcidio_print_status(status); */ } out: @@ -963,7 +963,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s /* clear and enable interrupts */ writeb(0xff, devpriv->mite->daq_io_addr + Group_1_First_Clear); - //writeb(ClearExpired,devpriv->mite->daq_io_addr+Group_1_Second_Clear); + /* writeb(ClearExpired,devpriv->mite->daq_io_addr+Group_1_Second_Clear); */ writeb(IntEn, devpriv->mite->daq_io_addr + Interrupt_Control); writeb(0x03, @@ -971,7 +971,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s if (cmd->stop_src == TRIG_NONE) { devpriv->OpModeBits = DataLatching(0) | RunMode(7); - } else { // TRIG_TIMER + } else { /* TRIG_TIMER */ devpriv->OpModeBits = Numbered | RunMode(7); } if (cmd->start_src == TRIG_NOW) { @@ -1235,8 +1235,8 @@ static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control); - ret = comedi_request_irq(irq, nidio_interrupt, IRQF_SHARED, - "ni_pcidio", dev); + ret = request_irq(irq, nidio_interrupt, IRQF_SHARED, + "ni_pcidio", dev); if (ret < 0) { printk(" irq not available"); } @@ -1259,7 +1259,7 @@ static int nidio_detach(struct comedi_device * dev) } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv) { if (devpriv->di_mite_ring) { diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 3a2aba7c8dd3..1d04b75dec22 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -101,7 +101,7 @@ Bugs: need to slow down DAC loading. I don't trust NI's claim that two writes to the PCI bus slows IO enough. I would prefer to - use comedi_udelay(). Timing specs: (clock) + use udelay(). Timing specs: (clock) AD8522 30ns DAC8043 120ns DAC8800 60ns @@ -117,7 +117,7 @@ Bugs: #include "ni_stc.h" #include "mite.h" -//#define PCI_DEBUG +/* #define PCI_DEBUG */ #define PCIDMA @@ -216,9 +216,9 @@ static const struct comedi_lrange range_ni_M_622x_ao = { 1, { } }; -static const ni_board ni_boards[] = { +static const struct ni_board_struct ni_boards[] = { { - .device_id = 0x0162, // NI also says 0x1620. typo? + .device_id = 0x0162, /* NI also says 0x1620. typo? */ .name = "pci-mio-16xe-50", .n_adchan = 16, .adbits = 16, @@ -238,7 +238,7 @@ static const ni_board ni_boards[] = { }, { .device_id = 0x1170, - .name = "pci-mio-16xe-10", // aka pci-6030E + .name = "pci-mio-16xe-10", /* aka pci-6030E */ .n_adchan = 16, .adbits = 16, .ai_fifo_depth = 512, @@ -320,7 +320,7 @@ static const ni_board ni_boards[] = { .ai_fifo_depth = 512, .alwaysdither = 0, .gainlkup = ai_gain_16, - /* Note: there have been reported problems with full speed + /* .Note = there have been reported problems with full speed * on this board */ .ai_speed = 2000, .n_aochan = 2, @@ -330,7 +330,7 @@ static const ni_board ni_boards[] = { .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, - .caldac = {ad8804_debug}, // doc says mb88341 + .caldac = {ad8804_debug}, /* doc says mb88341 */ .has_8255 = 0, }, { @@ -846,7 +846,7 @@ static const ni_board ni_boards[] = { .n_adchan = 16, .adbits = 16, .ai_fifo_depth = 512, - //FIXME: guess + /* .FIXME = guess */ .gainlkup = ai_gain_622x, .ai_speed = 4000, .n_aochan = 0, @@ -1207,28 +1207,29 @@ static const ni_board ni_boards[] = { #define n_pcimio_boards ((sizeof(ni_boards)/sizeof(ni_boards[0]))) -static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcimio_detach(struct comedi_device * dev); +static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcimio_detach(struct comedi_device *dev); static struct comedi_driver driver_pcimio = { - driver_name: DRV_NAME, - module:THIS_MODULE, - attach:pcimio_attach, - detach:pcimio_detach, + .driver_name = DRV_NAME, + .module = THIS_MODULE, + .attach = pcimio_attach, + .detach = pcimio_detach, }; COMEDI_PCI_INITCLEANUP(driver_pcimio, ni_pci_table) -typedef struct { -NI_PRIVATE_COMMON} ni_private; -#define devpriv ((ni_private *)dev->private) +struct ni_private { + NI_PRIVATE_COMMON +}; +#define devpriv ((struct ni_private *)dev->private) /* How we access registers */ -#define ni_writel(a,b) (writel((a), devpriv->mite->daq_io_addr + (b))) +#define ni_writel(a, b) (writel((a), devpriv->mite->daq_io_addr + (b))) #define ni_readl(a) (readl(devpriv->mite->daq_io_addr + (a))) -#define ni_writew(a,b) (writew((a), devpriv->mite->daq_io_addr + (b))) +#define ni_writew(a, b) (writew((a), devpriv->mite->daq_io_addr + (b))) #define ni_readw(a) (readw(devpriv->mite->daq_io_addr + (a))) -#define ni_writeb(a,b) (writeb((a), devpriv->mite->daq_io_addr + (b))) +#define ni_writeb(a, b) (writeb((a), devpriv->mite->daq_io_addr + (b))) #define ni_readb(a) (readb(devpriv->mite->daq_io_addr + (a))) /* How we access STC registers */ @@ -1241,30 +1242,30 @@ NI_PRIVATE_COMMON} ni_private; /* However, the 611x boards still aren't working, so I'm disabling * non-windowed STC access temporarily */ -static void e_series_win_out(struct comedi_device * dev, uint16_t data, int reg) +static void e_series_win_out(struct comedi_device *dev, uint16_t data, int reg) { unsigned long flags; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); ni_writew(reg, Window_Address); ni_writew(data, Window_Data); - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); } -static uint16_t e_series_win_in(struct comedi_device * dev, int reg) +static uint16_t e_series_win_in(struct comedi_device *dev, int reg) { unsigned long flags; uint16_t ret; - comedi_spin_lock_irqsave(&devpriv->window_lock, flags); + spin_lock_irqsave(&devpriv->window_lock, flags); ni_writew(reg, Window_Address); ret = ni_readw(Window_Data); - comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags); + spin_unlock_irqrestore(&devpriv->window_lock, flags); return ret; } -static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int reg) +static void m_series_stc_writew(struct comedi_device *dev, uint16_t data, int reg) { unsigned offset; switch (reg) { @@ -1293,12 +1294,12 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r offset = M_Offset_AI_Personal; break; case AI_SI2_Load_A_Register: - // this is actually a 32 bit register on m series boards + /* this is actually a 32 bit register on m series boards */ ni_writel(data, M_Offset_AI_SI2_Load_A); return; break; case AI_SI2_Load_B_Register: - // this is actually a 32 bit register on m series boards + /* this is actually a 32 bit register on m series boards */ ni_writel(data, M_Offset_AI_SI2_Load_B); return; break; @@ -1348,9 +1349,9 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r offset = M_Offset_AO_FIFO_Clear; break; case DIO_Control_Register: - rt_printk + printk ("%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n", - __FUNCTION__, reg); + __func__, reg); return; break; case G_Autoincrement_Register(0): @@ -1410,8 +1411,8 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r /* FIXME: DIO_Output_Register (16 bit reg) is replaced by M_Offset_Static_Digital_Output (32 bit) and M_Offset_SCXI_Serial_Data_Out (8 bit) */ default: - rt_printk("%s: bug! unhandled register=0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: bug! unhandled register=0x%x in switch.\n", + __func__, reg); BUG(); return; break; @@ -1419,7 +1420,7 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r ni_writew(data, offset); } -static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg) +static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg) { unsigned offset; switch (reg) { @@ -1445,8 +1446,8 @@ static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg) offset = M_Offset_G01_Status; break; default: - rt_printk("%s: bug! unhandled register=0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: bug! unhandled register=0x%x in switch.\n", + __func__, reg); BUG(); return 0; break; @@ -1454,7 +1455,7 @@ static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg) return ni_readw(offset); } -static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int reg) +static void m_series_stc_writel(struct comedi_device *dev, uint32_t data, int reg) { unsigned offset; switch (reg) { @@ -1486,8 +1487,8 @@ static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int r offset = M_Offset_G1_Load_B; break; default: - rt_printk("%s: bug! unhandled register=0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: bug! unhandled register=0x%x in switch.\n", + __func__, reg); BUG(); return; break; @@ -1495,7 +1496,7 @@ static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int r ni_writel(data, offset); } -static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg) +static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg) { unsigned offset; switch (reg) { @@ -1512,8 +1513,8 @@ static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg) offset = M_Offset_G1_Save; break; default: - rt_printk("%s: bug! unhandled register=0x%x in switch.\n", - __FUNCTION__, reg); + printk("%s: bug! unhandled register=0x%x in switch.\n", + __func__, reg); BUG(); return 0; break; @@ -1528,19 +1529,19 @@ static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg) #include "ni_mio_common.c" -static int pcimio_find_device(struct comedi_device * dev, int bus, int slot); -static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_find_device(struct comedi_device *dev, int bus, int slot); +static int pcimio_ai_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_ao_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_gpct0_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_gpct1_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -static int pcimio_dio_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_dio_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -static void m_series_init_eeprom_buffer(struct comedi_device * dev) +static void m_series_init_eeprom_buffer(struct comedi_device *dev) { static const int Start_Cal_EEPROM = 0x400; static const unsigned window_size = 10; @@ -1577,19 +1578,19 @@ static void m_series_init_eeprom_buffer(struct comedi_device * dev) writel(0x0, devpriv->mite->mite_io_addr + 0x30); } -static void init_6143(struct comedi_device * dev) +static void init_6143(struct comedi_device *dev) { - // Disable interrupts + /* Disable interrupts */ devpriv->stc_writew(dev, 0, Interrupt_Control_Register); - // Initialise 6143 AI specific bits - ni_writeb(0x00, Magic_6143); // Set G0,G1 DMA mode to E series version - ni_writeb(0x80, PipelineDelay_6143); // Set EOCMode, ADCMode and pipelinedelay - ni_writeb(0x00, EOC_Set_6143); // Set EOC Delay + /* Initialise 6143 AI specific bits */ + ni_writeb(0x00, Magic_6143); /* Set G0,G1 DMA mode to E series version */ + ni_writeb(0x80, PipelineDelay_6143); /* Set EOCMode, ADCMode and pipelinedelay */ + ni_writeb(0x00, EOC_Set_6143); /* Set EOC Delay */ - ni_writel(boardtype.ai_fifo_depth / 2, AIFIFO_Flag_6143); // Set the FIFO half full level + ni_writel(boardtype.ai_fifo_depth / 2, AIFIFO_Flag_6143); /* Set the FIFO half full level */ - // Strobe Relay disable bit + /* Strobe Relay disable bit */ devpriv->ai_calib_source_enabled = 0; ni_writew(devpriv->ai_calib_source | Calibration_Channel_6143_RelayOff, Calibration_Channel_6143); @@ -1597,11 +1598,11 @@ static void init_6143(struct comedi_device * dev) } /* cleans up allocated resources */ -static int pcimio_detach(struct comedi_device * dev) +static int pcimio_detach(struct comedi_device *dev) { mio_common_detach(dev); if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } if (dev->private) { mite_free_ring(devpriv->ai_mite_ring); @@ -1616,7 +1617,7 @@ static int pcimio_detach(struct comedi_device * dev) return 0; } -static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; @@ -1678,9 +1679,9 @@ static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * i printk(" unknown irq (bad)\n"); } else { printk(" ( irq = %u )", dev->irq); - if ((ret = comedi_request_irq(dev->irq, ni_E_interrupt, - NI_E_IRQ_FLAGS, DRV_NAME, - dev)) < 0) { + ret = request_irq(dev->irq, ni_E_interrupt, NI_E_IRQ_FLAGS, + DRV_NAME, dev); + if (ret < 0) { printk(" irq not available\n"); dev->irq = 0; } @@ -1699,7 +1700,7 @@ static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * i return ret; } -static int pcimio_find_device(struct comedi_device * dev, int bus, int slot) +static int pcimio_find_device(struct comedi_device *dev, int bus, int slot) { struct mite_struct *mite; int i; @@ -1727,7 +1728,7 @@ static int pcimio_find_device(struct comedi_device * dev, int bus, int slot) return -EIO; } -static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_ai_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; @@ -1739,7 +1740,7 @@ static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_ao_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; @@ -1751,7 +1752,7 @@ static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_gpct0_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; @@ -1763,7 +1764,7 @@ static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_gpct1_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; @@ -1775,7 +1776,7 @@ static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int pcimio_dio_change(struct comedi_device * dev, struct comedi_subdevice * s, +static int pcimio_dio_change(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size) { int ret; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 1ebf521ab773..fcaedb346c44 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -262,7 +262,7 @@ enum Joint_Status_2_Bits { #define AO_Trigger_Once _bit0 #define AO_Mode_2_Register 39 -#define AO_FIFO_Mode_Mask ( 0x3 << 14 ) +#define AO_FIFO_Mode_Mask (0x3 << 14) enum AO_FIFO_Mode_Bits { AO_FIFO_Mode_HF_to_F = (3 << 14), AO_FIFO_Mode_F = (2 << 14), @@ -318,7 +318,7 @@ enum Clock_and_FOUT_bits { }; static inline unsigned FOUT_Divider(unsigned divider) { - return (divider & FOUT_Divider_mask); + return divider & FOUT_Divider_mask; } #define IO_Bidirection_Pin_Register 57 @@ -339,7 +339,7 @@ static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries) max_channel = 6; } if (channel > max_channel) { - rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__, + printk("%s: bug, invalid RTSI_channel=%i\n", __func__, channel); return 0; } @@ -521,13 +521,13 @@ enum AO_Personal_Bits { AO_FIFO_Flags_Polarity = 1 << 11, /* M Series: reserved */ AO_TMRDACWR_Pulse_Width = 1 << 12, AO_Fast_CPU = 1 << 13, /* M Series: reserved */ - AO_Number_Of_DAC_Packages = 1 << 14, // 1 for "single" mode, 0 for "dual" - AO_Multiple_DACS_Per_Package = 1 << 15 // m-series only + AO_Number_Of_DAC_Packages = 1 << 14, /* 1 for "single" mode, 0 for "dual" */ + AO_Multiple_DACS_Per_Package = 1 << 15 /* m-series only */ }; #define RTSI_Trig_A_Output_Register 79 #define RTSI_Trig_B_Output_Register 80 enum RTSI_Trig_B_Output_Bits { - RTSI_Sub_Selection_1_Bit = 0x8000 // not for m-series + RTSI_Sub_Selection_1_Bit = 0x8000 /* not for m-series */ }; static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel, unsigned source) @@ -539,7 +539,7 @@ static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel) return 0xf << ((rtsi_channel % 4) * 4); }; -// inverse to RTSI_Trig_Output_Bits() +/* inverse to RTSI_Trig_Output_Bits() */ static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel, unsigned bits) { @@ -759,7 +759,7 @@ enum Configuration_Memory_High_Bits { }; static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel) { - return (channel & 0x3f); + return channel & 0x3f; } #define ADC_FIFO_Data_Register 0x1c @@ -920,42 +920,42 @@ enum ni_reg_type { static const struct comedi_lrange range_ni_E_ao_ext; enum m_series_register_offsets { - M_Offset_CDIO_DMA_Select = 0x7, // write - M_Offset_SCXI_Status = 0x7, // read - M_Offset_AI_AO_Select = 0x9, // write, same offset as e-series - M_Offset_SCXI_Serial_Data_In = 0x9, // read - M_Offset_G0_G1_Select = 0xb, // write, same offset as e-series + M_Offset_CDIO_DMA_Select = 0x7, /* write */ + M_Offset_SCXI_Status = 0x7, /* read */ + M_Offset_AI_AO_Select = 0x9, /* write, same offset as e-series */ + M_Offset_SCXI_Serial_Data_In = 0x9, /* read */ + M_Offset_G0_G1_Select = 0xb, /* write, same offset as e-series */ M_Offset_Misc_Command = 0xf, M_Offset_SCXI_Serial_Data_Out = 0x11, M_Offset_SCXI_Control = 0x13, M_Offset_SCXI_Output_Enable = 0x15, M_Offset_AI_FIFO_Data = 0x1c, - M_Offset_Static_Digital_Output = 0x24, // write - M_Offset_Static_Digital_Input = 0x24, // read + M_Offset_Static_Digital_Output = 0x24, /* write */ + M_Offset_Static_Digital_Input = 0x24, /* read */ M_Offset_DIO_Direction = 0x28, M_Offset_Cal_PWM = 0x40, M_Offset_AI_Config_FIFO_Data = 0x5e, - M_Offset_Interrupt_C_Enable = 0x88, // write - M_Offset_Interrupt_C_Status = 0x88, // read + M_Offset_Interrupt_C_Enable = 0x88, /* write */ + M_Offset_Interrupt_C_Status = 0x88, /* read */ M_Offset_Analog_Trigger_Control = 0x8c, M_Offset_AO_Serial_Interrupt_Enable = 0xa0, - M_Offset_AO_Serial_Interrupt_Ack = 0xa1, // write - M_Offset_AO_Serial_Interrupt_Status = 0xa1, // read + M_Offset_AO_Serial_Interrupt_Ack = 0xa1, /* write */ + M_Offset_AO_Serial_Interrupt_Status = 0xa1, /* read */ M_Offset_AO_Calibration = 0xa3, M_Offset_AO_FIFO_Data = 0xa4, M_Offset_PFI_Filter = 0xb0, M_Offset_RTSI_Filter = 0xb4, M_Offset_SCXI_Legacy_Compatibility = 0xbc, - M_Offset_Interrupt_A_Ack = 0x104, // write - M_Offset_AI_Status_1 = 0x104, // read - M_Offset_Interrupt_B_Ack = 0x106, // write - M_Offset_AO_Status_1 = 0x106, // read - M_Offset_AI_Command_2 = 0x108, // write - M_Offset_G01_Status = 0x108, // read + M_Offset_Interrupt_A_Ack = 0x104, /* write */ + M_Offset_AI_Status_1 = 0x104, /* read */ + M_Offset_Interrupt_B_Ack = 0x106, /* write */ + M_Offset_AO_Status_1 = 0x106, /* read */ + M_Offset_AI_Command_2 = 0x108, /* write */ + M_Offset_G01_Status = 0x108, /* read */ M_Offset_AO_Command_2 = 0x10a, - M_Offset_AO_Status_2 = 0x10c, // read - M_Offset_G0_Command = 0x10c, // write - M_Offset_G1_Command = 0x10e, // write + M_Offset_AO_Status_2 = 0x10c, /* read */ + M_Offset_G0_Command = 0x10c, /* write */ + M_Offset_G1_Command = 0x10e, /* write */ M_Offset_G0_HW_Save = 0x110, M_Offset_G0_HW_Save_High = 0x110, M_Offset_AI_Command_1 = 0x110, @@ -973,17 +973,17 @@ enum m_series_register_offsets { M_Offset_G1_Save = 0x11c, M_Offset_G1_Save_High = 0x11c, M_Offset_G1_Save_Low = 0x11e, - M_Offset_AI_SI_Load_B = 0x120, // write - M_Offset_AO_UI_Save = 0x120, // read - M_Offset_AI_SC_Load_A = 0x124, // write - M_Offset_AO_BC_Save = 0x124, // read - M_Offset_AI_SC_Load_B = 0x128, // write - M_Offset_AO_UC_Save = 0x128, //read + M_Offset_AI_SI_Load_B = 0x120, /* write */ + M_Offset_AO_UI_Save = 0x120, /* read */ + M_Offset_AI_SC_Load_A = 0x124, /* write */ + M_Offset_AO_BC_Save = 0x124, /* read */ + M_Offset_AI_SC_Load_B = 0x128, /* write */ + M_Offset_AO_UC_Save = 0x128, /* read */ M_Offset_AI_SI2_Load_A = 0x12c, M_Offset_AI_SI2_Load_B = 0x130, M_Offset_G0_Mode = 0x134, - M_Offset_G1_Mode = 0x136, // write - M_Offset_Joint_Status_1 = 0x136, // read + M_Offset_G1_Mode = 0x136, /* write */ + M_Offset_Joint_Status_1 = 0x136, /* read */ M_Offset_G0_Load_A = 0x138, M_Offset_Joint_Status_2 = 0x13a, M_Offset_G0_Load_B = 0x13c, @@ -1007,10 +1007,10 @@ enum m_series_register_offsets { M_Offset_Analog_Trigger_Etc = 0x17a, M_Offset_AI_START_STOP_Select = 0x17c, M_Offset_AI_Trigger_Select = 0x17e, - M_Offset_AI_SI_Save = 0x180, // read - M_Offset_AI_DIV_Load_A = 0x180, // write - M_Offset_AI_SC_Save = 0x184, // read - M_Offset_AO_Start_Select = 0x184, // write + M_Offset_AI_SI_Save = 0x180, /* read */ + M_Offset_AI_DIV_Load_A = 0x180, /* write */ + M_Offset_AI_SC_Save = 0x184, /* read */ + M_Offset_AO_Start_Select = 0x184, /* write */ M_Offset_AO_Trigger_Select = 0x186, M_Offset_AO_Mode_3 = 0x18c, M_Offset_G0_Autoincrement = 0x188, @@ -1032,10 +1032,10 @@ enum m_series_register_offsets { M_Offset_G1_Counting_Mode = 0x1b2, M_Offset_G0_Second_Gate = 0x1b4, M_Offset_G1_Second_Gate = 0x1b6, - M_Offset_G0_DMA_Config = 0x1b8, // write - M_Offset_G0_DMA_Status = 0x1b8, // read - M_Offset_G1_DMA_Config = 0x1ba, // write - M_Offset_G1_DMA_Status = 0x1ba, // read + M_Offset_G0_DMA_Config = 0x1b8, /* write */ + M_Offset_G0_DMA_Status = 0x1b8, /* read */ + M_Offset_G1_DMA_Config = 0x1ba, /* write */ + M_Offset_G1_DMA_Status = 0x1ba, /* read */ M_Offset_G0_MSeries_ABZ = 0x1c0, M_Offset_G1_MSeries_ABZ = 0x1c2, M_Offset_Clock_and_Fout2 = 0x1c4, @@ -1051,10 +1051,10 @@ enum m_series_register_offsets { M_Offset_PFI_DO = 0x1de, M_Offset_AI_Config_FIFO_Bypass = 0x218, M_Offset_SCXI_DIO_Enable = 0x21c, - M_Offset_CDI_FIFO_Data = 0x220, // read - M_Offset_CDO_FIFO_Data = 0x220, // write - M_Offset_CDIO_Status = 0x224, // read - M_Offset_CDIO_Command = 0x224, // write + M_Offset_CDI_FIFO_Data = 0x220, /* read */ + M_Offset_CDO_FIFO_Data = 0x220, /* write */ + M_Offset_CDIO_Status = 0x224, /* read */ + M_Offset_CDIO_Command = 0x224, /* write */ M_Offset_CDI_Mode = 0x228, M_Offset_CDO_Mode = 0x22c, M_Offset_CDI_Mask_Enable = 0x230, @@ -1084,8 +1084,8 @@ static inline int M_Offset_Static_AI_Control(int i) 0x262, 0x263, }; - if (((unsigned)i) >= sizeof(offset) / sizeof(offset[0])) { - rt_printk("%s: invalid channel=%i\n", __FUNCTION__, i); + if (((unsigned)i) >= ARRAY_SIZE(offset)) { + printk("%s: invalid channel=%i\n", __func__, i); return offset[0]; } return offset[i]; @@ -1098,8 +1098,8 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel) 0x266, 0x267 }; - if (((unsigned)channel) >= sizeof(offset) / sizeof(offset[0])) { - rt_printk("%s: invalid channel=%i\n", __FUNCTION__, channel); + if (((unsigned)channel) >= ARRAY_SIZE(offset)) { + printk("%s: invalid channel=%i\n", __func__, channel); return offset[0]; } return offset[channel]; @@ -1107,8 +1107,8 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel) static inline unsigned M_Offset_PFI_Output_Select(unsigned n) { if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) { - rt_printk("%s: invalid pfi output select register=%i\n", - __FUNCTION__, n); + printk("%s: invalid pfi output select register=%i\n", + __func__, n); return M_Offset_PFI_Output_Select_1; } return M_Offset_PFI_Output_Select_1 + (n - 1) * 2; @@ -1122,7 +1122,7 @@ enum MSeries_AI_Config_FIFO_Data_Bits { MSeries_AI_Config_Channel_Type_Ground_Ref_Bits = 0x3 << 6, MSeries_AI_Config_Channel_Type_Aux_Bits = 0x5 << 6, MSeries_AI_Config_Channel_Type_Ghost_Bits = 0x7 << 6, - MSeries_AI_Config_Polarity_Bit = 0x1000, // 0 for 2's complement encoding + MSeries_AI_Config_Polarity_Bit = 0x1000, /* 0 for 2's complement encoding */ MSeries_AI_Config_Dither_Bit = 0x2000, MSeries_AI_Config_Last_Channel_Bit = 0x4000, }; @@ -1151,8 +1151,8 @@ enum MSeries_Clock_and_Fout2_Bits { MSeries_PLL_In_Source_Select_RTSI7_Bits = 0x1b, MSeries_PLL_In_Source_Select_PXI_Clock10 = 0x1d, MSeries_PLL_In_Source_Select_Mask = 0x1f, - MSeries_Timebase1_Select_Bit = 0x20, // use PLL for timebase 1 - MSeries_Timebase3_Select_Bit = 0x40, // use PLL for timebase 3 + MSeries_Timebase1_Select_Bit = 0x20, /* use PLL for timebase 1 */ + MSeries_Timebase3_Select_Bit = 0x40, /* use PLL for timebase 3 */ /* use 10MHz instead of 20MHz for RTSI clock frequency. Appears to have no effect, at least on pxi-6281, which always uses 20MHz rtsi clock frequency */ @@ -1162,7 +1162,7 @@ static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned RTSI_channel) { if (RTSI_channel > 7) { - rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__, + printk("%s: bug, invalid RTSI_channel=%i\n", __func__, RTSI_channel); return 0; } @@ -1183,7 +1183,7 @@ static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor) { static const unsigned max_divisor = 0x10; if (divisor < 1 || divisor > max_divisor) { - rt_printk("%s: bug, invalid divisor=%i\n", __FUNCTION__, + printk("%s: bug, invalid divisor=%i\n", __func__, divisor); return 0; } @@ -1193,7 +1193,7 @@ static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier) { static const unsigned max_multiplier = 0x100; if (multiplier < 1 || multiplier > max_multiplier) { - rt_printk("%s: bug, invalid multiplier=%i\n", __FUNCTION__, + printk("%s: bug, invalid multiplier=%i\n", __func__, multiplier); return 0; } @@ -1213,7 +1213,7 @@ enum MSeries_AI_Config_FIFO_Bypass_Bits { MSeries_AO_Bypass_AO_Cal_Sel_Mask = 0x38000, MSeries_AI_Bypass_Gain_Mask = 0x1c0000, MSeries_AI_Bypass_Dither_Bit = 0x200000, - MSeries_AI_Bypass_Polarity_Bit = 0x400000, // 0 for 2's complement encoding + MSeries_AI_Bypass_Polarity_Bit = 0x400000, /* 0 for 2's complement encoding */ MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000 }; static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int @@ -1239,7 +1239,7 @@ enum MSeries_AO_Config_Bank_Bits { MSeries_AO_DAC_Reference_10V_Internal_Bits = 0x0, MSeries_AO_DAC_Reference_5V_Internal_Bits = 0x8, MSeries_AO_Update_Timed_Bit = 0x40, - MSeries_AO_Bipolar_Bit = 0x80 // turns on 2's complement encoding + MSeries_AO_Bipolar_Bit = 0x80 /* turns on 2's complement encoding */ }; enum MSeries_AO_Reference_Attenuation_Bits { @@ -1266,7 +1266,7 @@ static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel, return (source & 0x1f) << ((channel % 3) * 5); }; -// inverse to MSeries_PFI_Output_Select_Bits +/* inverse to MSeries_PFI_Output_Select_Bits */ static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel, unsigned bits) { @@ -1338,9 +1338,9 @@ enum CDIO_Command_Bits { enum CDI_Mode_Bits { CDI_Sample_Source_Select_Mask = 0x3f, CDI_Halt_On_Error_Bit = 0x200, - CDI_Polarity_Bit = 0x400, // sample clock on falling edge - CDI_FIFO_Mode_Bit = 0x800, // set for half full mode, clear for not empty mode - CDI_Data_Lane_Mask = 0x3000, // data lanes specify which dio channels map to byte or word accesses to the dio fifos + CDI_Polarity_Bit = 0x400, /* sample clock on falling edge */ + CDI_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not empty mode */ + CDI_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */ CDI_Data_Lane_0_15_Bits = 0x0, CDI_Data_Lane_16_31_Bits = 0x1000, CDI_Data_Lane_0_7_Bits = 0x0, @@ -1353,9 +1353,9 @@ enum CDO_Mode_Bits { CDO_Sample_Source_Select_Mask = 0x3f, CDO_Retransmit_Bit = 0x100, CDO_Halt_On_Error_Bit = 0x200, - CDO_Polarity_Bit = 0x400, // sample clock on falling edge - CDO_FIFO_Mode_Bit = 0x800, // set for half full mode, clear for not full mode - CDO_Data_Lane_Mask = 0x3000, // data lanes specify which dio channels map to byte or word accesses to the dio fifos + CDO_Polarity_Bit = 0x400, /* sample clock on falling edge */ + CDO_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not full mode */ + CDO_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */ CDO_Data_Lane_0_15_Bits = 0x0, CDO_Data_Lane_16_31_Bits = 0x1000, CDO_Data_Lane_0_7_Bits = 0x0, @@ -1374,7 +1374,7 @@ enum Interrupt_C_Status_Bits { #define M_SERIES_EEPROM_SIZE 1024 -typedef struct ni_board_struct { +struct ni_board_struct { int device_id; int isapnp_id; char *name; @@ -1401,11 +1401,11 @@ typedef struct ni_board_struct { unsigned int has_analog_trig:1; enum caldac_enum caldac[3]; -} ni_board; +}; -#define n_ni_boards (sizeof(ni_boards)/sizeof(ni_board)) +#define n_ni_boards (sizeof(ni_boards)/sizeof(struct ni_board_struct)) -#define boardtype (*(ni_board *)dev->board_ptr) +#define boardtype (*(struct ni_board_struct *)dev->board_ptr) #define MAX_N_AO_CHAN 8 #define NUM_GPCT 2 @@ -1418,7 +1418,7 @@ typedef struct ni_board_struct { \ unsigned short dio_output; \ unsigned short dio_control; \ - int ao0p,ao1p; \ + int ao0p, ao1p; \ int lastchan; \ int last_do; \ int rt_irq; \ diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 05a957540398..785553d0cc9d 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -149,13 +149,13 @@ static const unsigned ni_660x_max_rtsi_channel = 6; static inline unsigned NI_660x_RTSI_Clock(unsigned n) { BUG_ON(n > ni_660x_max_rtsi_channel); - return (0xb + n); + return 0xb + n; } static const unsigned ni_660x_max_source_pin = 7; static inline unsigned NI_660x_Source_Pin_Clock(unsigned n) { BUG_ON(n > ni_660x_max_source_pin); - return (0x2 + n); + return 0x2 + n; } /* clock sources for ni e and m series boards, get bits with Gi_Source_Select_Bits() */ @@ -279,9 +279,9 @@ static void __exit ni_tio_cleanup_module(void) module_exit(ni_tio_cleanup_module); struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev, - void (*write_register) (struct ni_gpct * counter, unsigned bits, + void (*write_register) (struct ni_gpct *counter, unsigned bits, enum ni_gpct_register reg), - unsigned (*read_register) (struct ni_gpct * counter, + unsigned (*read_register) (struct ni_gpct *counter, enum ni_gpct_register reg), enum ni_gpct_variant variant, unsigned num_counters) { @@ -669,7 +669,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source) } if (i <= ni_m_series_max_pfi_channel) break; - rt_printk("invalid clock source 0x%lx\n", + printk("invalid clock source 0x%lx\n", (unsigned long)clock_source); BUG(); ni_m_series_clock = 0; @@ -965,7 +965,7 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, } static void ni_tio_get_clock_src(struct ni_gpct *counter, - unsigned int * clock_source, unsigned int * period_ns) + unsigned int *clock_source, unsigned int *period_ns) { static const unsigned pico_per_nano = 1000; uint64_t temp64; @@ -1273,7 +1273,7 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index, counter_dev->regs[abz_reg] &= ~mask; counter_dev->regs[abz_reg] |= (source << shift) & mask; write_register(counter, counter_dev->regs[abz_reg], abz_reg); -// rt_printk("%s %x %d %d\n", __FUNCTION__, counter_dev->regs[abz_reg], index, source); +/* printk("%s %x %d %d\n", __func__, counter_dev->regs[abz_reg], index, source); */ return 0; } return -EINVAL; @@ -1442,7 +1442,7 @@ static unsigned ni_m_series_second_gate_to_generic_gate_source(unsigned }; static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index, - unsigned int * gate_source) + unsigned int *gate_source) { struct ni_gpct_device *counter_dev = counter->counter_dev; const unsigned mode_bits = ni_tio_get_soft_copy(counter, @@ -1534,7 +1534,7 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index, } int ni_tio_insn_config(struct ni_gpct *counter, - struct comedi_insn * insn, unsigned int * data) + struct comedi_insn *insn, unsigned int *data) { switch (data[0]) { case INSN_CONFIG_SET_COUNTER_MODE: diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 0729d60b01cc..3aacfe2f2420 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -25,7 +25,7 @@ #include "../comedidev.h" -// forward declarations +/* forward declarations */ struct mite_struct; struct ni_gpct_device; @@ -120,9 +120,9 @@ struct ni_gpct { struct ni_gpct_device { struct comedi_device *dev; - void (*write_register) (struct ni_gpct * counter, unsigned bits, + void (*write_register) (struct ni_gpct *counter, unsigned bits, enum ni_gpct_register reg); - unsigned (*read_register) (struct ni_gpct * counter, + unsigned (*read_register) (struct ni_gpct *counter, enum ni_gpct_register reg); enum ni_gpct_variant variant; struct ni_gpct *counters; @@ -132,24 +132,24 @@ struct ni_gpct_device { }; extern struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev, - void (*write_register) (struct ni_gpct * counter, unsigned bits, + void (*write_register) (struct ni_gpct *counter, unsigned bits, enum ni_gpct_register reg), - unsigned (*read_register) (struct ni_gpct * counter, + unsigned (*read_register) (struct ni_gpct *counter, enum ni_gpct_register reg), enum ni_gpct_variant variant, unsigned num_counters); extern void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev); extern void ni_tio_init_counter(struct ni_gpct *counter); extern int ni_tio_rinsn(struct ni_gpct *counter, - struct comedi_insn * insn, unsigned int * data); + struct comedi_insn *insn, unsigned int *data); extern int ni_tio_insn_config(struct ni_gpct *counter, - struct comedi_insn * insn, unsigned int * data); + struct comedi_insn *insn, unsigned int *data); extern int ni_tio_winsn(struct ni_gpct *counter, - struct comedi_insn * insn, unsigned int * data); + struct comedi_insn *insn, unsigned int *data); extern int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async); extern int ni_tio_cmdtest(struct ni_gpct *counter, struct comedi_cmd * cmd); extern int ni_tio_cancel(struct ni_gpct *counter); extern void ni_tio_handle_interrupt(struct ni_gpct *counter, - struct comedi_subdevice * s); + struct comedi_subdevice *s); extern void ni_tio_set_mite_channel(struct ni_gpct *counter, struct mite_channel *mite_chan); extern void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index ac5b171cbe18..920dd221da0d 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -487,8 +487,8 @@ enum Gi_Counting_Mode_Reg_Bits { #define Gi_Source_Select_Shift 2 #define Gi_Gate_Select_Shift 7 enum Gi_Input_Select_Bits { - Gi_Read_Acknowledges_Irq = 0x1, // not present on 660x - Gi_Write_Acknowledges_Irq = 0x2, // not present on 660x + Gi_Read_Acknowledges_Irq = 0x1, /* not present on 660x */ + Gi_Write_Acknowledges_Irq = 0x2, /* not present on 660x */ Gi_Source_Select_Mask = 0x7c, Gi_Gate_Select_Mask = 0x1f << Gi_Gate_Select_Shift, Gi_Gate_Select_Load_Source_Bit = 0x1000, @@ -656,7 +656,7 @@ static inline unsigned Gi_TC_Error_Confirm_Bit(unsigned counter_index) return G0_TC_Error_Confirm_Bit; } -// bits that are the same in G0/G2 and G1/G3 interrupt acknowledge registers +/* bits that are the same in G0/G2 and G1/G3 interrupt acknowledge registers */ enum Gxx_Interrupt_Acknowledge_Bits { Gi_TC_Interrupt_Ack_Bit = 0x4000, Gi_Gate_Interrupt_Ack_Bit = 0x8000 @@ -728,14 +728,14 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter, unsigned long flags; BUG_ON(register_index >= NITIO_Num_Registers); - comedi_spin_lock_irqsave(&counter_dev->regs_lock, flags); + spin_lock_irqsave(&counter_dev->regs_lock, flags); counter_dev->regs[register_index] &= ~bit_mask; counter_dev->regs[register_index] |= (bit_values & bit_mask); write_register(counter, counter_dev->regs[register_index] | transient_bit_values, register_index); mmiowb(); - comedi_spin_unlock_irqrestore(&counter_dev->regs_lock, flags); + spin_unlock_irqrestore(&counter_dev->regs_lock, flags); } /* ni_tio_set_bits( ) is for safely writing to registers whose bits may be @@ -761,9 +761,9 @@ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter, unsigned value; BUG_ON(register_index >= NITIO_Num_Registers); - comedi_spin_lock_irqsave(&counter_dev->regs_lock, flags); + spin_lock_irqsave(&counter_dev->regs_lock, flags); value = counter_dev->regs[register_index]; - comedi_spin_unlock_irqrestore(&counter_dev->regs_lock, flags); + spin_unlock_irqrestore(&counter_dev->regs_lock, flags); return value; } diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 16a26e73c994..5be1e1a62c0a 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -96,7 +96,7 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable, } } -static int ni_tio_input_inttrig(struct comedi_device * dev, struct comedi_subdevice * s, +static int ni_tio_input_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { unsigned long flags; @@ -107,12 +107,12 @@ static int ni_tio_input_inttrig(struct comedi_device * dev, struct comedi_subdev if (trignum != 0) return -EINVAL; - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); if (counter->mite_chan) mite_dma_arm(counter->mite_chan); else retval = -EIO; - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); if (retval < 0) return retval; retval = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE); @@ -171,7 +171,7 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) static int ni_tio_output_cmd(struct ni_gpct *counter, struct comedi_async *async) { - rt_printk("ni_tio: output commands not yet implemented.\n"); + printk("ni_tio: output commands not yet implemented.\n"); return -ENOTSUPP; counter->mite_chan->dir = COMEDI_OUTPUT; @@ -213,9 +213,9 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async) int retval = 0; unsigned long flags; - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); if (counter->mite_chan == NULL) { - rt_printk + printk ("ni_tio: commands only supported with DMA. Interrupt-driven commands not yet implemented.\n"); retval = -EIO; } else { @@ -228,7 +228,7 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async) } } } - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); return retval; } @@ -342,11 +342,11 @@ int ni_tio_cancel(struct ni_gpct *counter) unsigned long flags; ni_tio_arm(counter, 0, 0); - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); if (counter->mite_chan) { mite_dma_disarm(counter->mite_chan); } - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); ni_tio_configure_dma(counter, 0, 0); ni_tio_set_bits(counter, @@ -365,11 +365,11 @@ static int should_ack_gate(struct ni_gpct *counter) switch (counter->counter_dev->variant) { case ni_gpct_variant_m_series: - case ni_gpct_variant_660x: // not sure if 660x really supports gate interrupts (the bits are not listed in register-level manual) + case ni_gpct_variant_660x: /* not sure if 660x really supports gate interrupts (the bits are not listed in register-level manual) */ return 1; break; case ni_gpct_variant_e_series: - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); { if (counter->mite_chan == NULL || counter->mite_chan->dir != COMEDI_INPUT || @@ -377,7 +377,7 @@ static int should_ack_gate(struct ni_gpct *counter) retval = 1; } } - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); break; } return retval; @@ -439,7 +439,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error, NITIO_Gxx_Joint_Status2_Reg(counter-> counter_index)) & Gi_Permanent_Stale_Bit(counter->counter_index)) { - rt_printk("%s: Gi_Permanent_Stale_Data detected.\n", + printk("%s: Gi_Permanent_Stale_Data detected.\n", __FUNCTION__); if (perm_stale_data) *perm_stale_data = 1; @@ -458,7 +458,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice * ni_tio_acknowledge_and_confirm(counter, &gate_error, &tc_error, &perm_stale_data, NULL); if (gate_error) { - rt_printk("%s: Gi_Gate_Error detected.\n", __FUNCTION__); + printk("%s: Gi_Gate_Error detected.\n", __FUNCTION__); s->async->events |= COMEDI_CB_OVERFLOW; } if (perm_stale_data) { @@ -470,16 +470,16 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice * if (read_register(counter, NITIO_Gi_DMA_Status_Reg(counter-> counter_index)) & Gi_DRQ_Error_Bit) { - rt_printk("%s: Gi_DRQ_Error detected.\n", __FUNCTION__); + printk("%s: Gi_DRQ_Error detected.\n", __FUNCTION__); s->async->events |= COMEDI_CB_OVERFLOW; } break; case ni_gpct_variant_e_series: break; } - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); if (counter->mite_chan == NULL) { - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); return; } gpct_mite_status = mite_get_status(counter->mite_chan); @@ -489,7 +489,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice * MITE_CHOR(counter->mite_chan->channel)); } mite_sync_input_dma(counter->mite_chan, s->async); - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); } void ni_tio_set_mite_channel(struct ni_gpct *counter, @@ -497,9 +497,9 @@ void ni_tio_set_mite_channel(struct ni_gpct *counter, { unsigned long flags; - comedi_spin_lock_irqsave(&counter->lock, flags); + spin_lock_irqsave(&counter->lock, flags); counter->mite_chan = mite_chan; - comedi_spin_unlock_irqrestore(&counter->lock, flags); + spin_unlock_irqrestore(&counter->lock, flags); } static int __init ni_tiocmd_init_module(void) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index ce42506d47b5..7b72b7af75c8 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -58,6 +58,7 @@ supported. */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -156,16 +157,16 @@ static const struct pcl711_board boardtypes[] = { #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl711_board)) #define this_board ((const struct pcl711_board *)dev->board_ptr) -static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl711_detach(struct comedi_device * dev); +static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl711_detach(struct comedi_device *dev); static struct comedi_driver driver_pcl711 = { - driver_name:"pcl711", - module:THIS_MODULE, - attach:pcl711_attach, - detach:pcl711_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl711_board), + .driver_name = "pcl711", + .module = THIS_MODULE, + .attach = pcl711_attach, + .detach = pcl711_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl711_board), }; COMEDI_INITCLEANUP(driver_pcl711); @@ -185,7 +186,7 @@ struct pcl711_private { #define devpriv ((struct pcl711_private *)dev->private) -static irqreturn_t pcl711_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t pcl711_interrupt(int irq, void *d) { int lo, hi; int data; @@ -217,7 +218,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static void pcl711_set_changain(struct comedi_device * dev, int chan) +static void pcl711_set_changain(struct comedi_device *dev, int chan) { int chan_register; @@ -244,8 +245,8 @@ static void pcl711_set_changain(struct comedi_device * dev, int chan) } } -static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, n; int hi, lo; @@ -269,9 +270,9 @@ static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice * hi = inb(dev->iobase + PCL711_AD_HI); if (!(hi & PCL711_DRDY)) goto ok; - comedi_udelay(1); + udelay(1); } - rt_printk("comedi%d: pcl711: A/D timeout\n", dev->minor); + printk("comedi%d: pcl711: A/D timeout\n", dev->minor); return -ETIME; ok: @@ -283,8 +284,8 @@ static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int pcl711_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int tmp; int err = 0; @@ -385,7 +386,7 @@ static int pcl711_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcl711_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { int timer1, timer2; struct comedi_cmd *cmd = &s->async->cmd; @@ -431,8 +432,8 @@ static int pcl711_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s /* analog output */ -static int pcl711_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl711_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -449,8 +450,8 @@ static int pcl711_ao_insn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int pcl711_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl711_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -464,8 +465,8 @@ static int pcl711_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi } /* Digital port read - Untested on 8112 */ -static int pcl711_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl711_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -477,8 +478,8 @@ static int pcl711_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi } /* Digital port write - Untested on 8112 */ -static int pcl711_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl711_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -498,12 +499,12 @@ static int pcl711_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi } /* Free any resources that we have claimed */ -static int pcl711_detach(struct comedi_device * dev) +static int pcl711_detach(struct comedi_device *dev) { printk("comedi%d: pcl711: remove\n", dev->minor); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, PCL711_SIZE); @@ -512,7 +513,7 @@ static int pcl711_detach(struct comedi_device * dev) } /* Initialization */ -static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; unsigned long iobase; @@ -541,7 +542,7 @@ static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * i return -EINVAL; } if (irq) { - if (comedi_request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) { + if (request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) { printk("unable to allocate irq %u\n", irq); return -EINVAL; } else { @@ -550,9 +551,12 @@ static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * i } dev->irq = irq; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct pcl711_private))) < 0) + + ret = alloc_private(dev, sizeof(struct pcl711_private)); + if (ret < 0) return ret; s = dev->subdevices + 0; diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index cd1e784f25f9..699daff3035a 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -54,18 +54,18 @@ See the source for configuration details. #define SIZE_8255 4 -// #define PCL724_IRQ 1 /* no IRQ support now */ +/* #define PCL724_IRQ 1 no IRQ support now */ -static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl724_detach(struct comedi_device * dev); +static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl724_detach(struct comedi_device *dev); struct pcl724_board { - const char *name; // board name - int dio; // num of DIO - int numofports; // num of 8255 subdevices - unsigned int IRQbits; // allowed interrupts - unsigned int io_range; // len of IO space + const char *name; /* board name */ + int dio; /* num of DIO */ + int numofports; /* num of 8255 subdevices */ + unsigned int IRQbits; /* allowed interrupts */ + unsigned int io_range; /* len of IO space */ char can_have96; char is_pet48; }; @@ -84,13 +84,13 @@ static const struct pcl724_board boardtypes[] = { #define this_board ((const struct pcl724_board *)dev->board_ptr) static struct comedi_driver driver_pcl724 = { - driver_name:"pcl724", - module:THIS_MODULE, - attach:pcl724_attach, - detach:pcl724_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl724_board), + .driver_name = "pcl724", + .module = THIS_MODULE, + .attach = pcl724_attach, + .detach = pcl724_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl724_board), }; COMEDI_INITCLEANUP(driver_pcl724); @@ -124,7 +124,7 @@ static int subdev_8255mapped_cb(int dir, int port, int data, } } -static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned long iobase; unsigned int iorange; @@ -137,7 +137,7 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i iorange = this_board->io_range; if ((this_board->can_have96) && ((it->options[1] == 1) || (it->options[1] == 96))) - iorange = PCL722_96_SIZE; // PCL-724 in 96 DIO configuration + iorange = PCL722_96_SIZE; /* PCL-724 in 96 DIO configuration */ printk("comedi%d: pcl724: board=%s, 0x%03lx ", dev->minor, this_board->name, iobase); if (!request_region(iobase, iorange, "pcl724")) { @@ -155,19 +155,18 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i irq = it->options[1]; if (irq) { /* we want to use IRQ */ if (((1 << irq) & this_board->IRQbits) == 0) { - rt_printk + printk (", IRQ %u is out of allowed range, DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { - if (comedi_request_irq(irq, interrupt_pcl724, 0, - "pcl724", dev)) { - rt_printk + if (request_irq(irq, interrupt_pcl724, 0, "pcl724", dev)) { + printk (", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%u", irq); + printk(", irq=%u", irq); } } } @@ -181,9 +180,10 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i n_subdevices = this_board->numofports; if ((this_board->can_have96) && ((it->options[1] == 1) || (it->options[1] == 96))) - n_subdevices = 4; // PCL-724 in 96 DIO configuration + n_subdevices = 4; /* PCL-724 in 96 DIO configuration */ - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) return ret; for (i = 0; i < dev->n_subdevices; i++) { @@ -200,11 +200,11 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int pcl724_detach(struct comedi_device * dev) +static int pcl724_detach(struct comedi_device *dev) { int i; -// printk("comedi%d: pcl724: remove\n",dev->minor); +/* printk("comedi%d: pcl724: remove\n",dev->minor); */ for (i = 0; i < dev->n_subdevices; i++) { subdev_8255_cleanup(dev, dev->subdevices + i); @@ -212,7 +212,7 @@ static int pcl724_detach(struct comedi_device * dev) #ifdef PCL724_IRQ if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } #endif diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c index 0766ba02bd03..1347624d0519 100644 --- a/drivers/staging/comedi/drivers/pcl725.c +++ b/drivers/staging/comedi/drivers/pcl725.c @@ -20,19 +20,19 @@ Devices: [Advantech] PCL-725 (pcl725) #define PCL725_DO 0 #define PCL725_DI 1 -static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl725_detach(struct comedi_device * dev); +static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl725_detach(struct comedi_device *dev); static struct comedi_driver driver_pcl725 = { - driver_name:"pcl725", - module:THIS_MODULE, - attach:pcl725_attach, - detach:pcl725_detach, + .driver_name = "pcl725", + .module = THIS_MODULE, + .attach = pcl725_attach, + .detach = pcl725_detach, }; COMEDI_INITCLEANUP(driver_pcl725); -static int pcl725_do_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -48,8 +48,8 @@ static int pcl725_do_insn(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int pcl725_di_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl725_di_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -59,7 +59,7 @@ static int pcl725_di_insn(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -100,7 +100,7 @@ static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int pcl725_detach(struct comedi_device * dev) +static int pcl725_detach(struct comedi_device *dev) { printk("comedi%d: pcl725: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 6dbd33d7907b..149e75f0e09c 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -111,22 +111,22 @@ static const struct comedi_lrange *const rangelist_728[] = { &range_4_20mA, &range_0_20mA }; -static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl726_detach(struct comedi_device * dev); +static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl726_detach(struct comedi_device *dev); struct pcl726_board { - const char *name; // driver name - int n_aochan; // num of D/A chans - int num_of_ranges; // num of ranges - unsigned int IRQbits; // allowed interrupts - unsigned int io_range; // len of IO space - char have_dio; // 1=card have DI/DO ports - int di_hi; // ports for DI/DO operations + const char *name; /* driver name */ + int n_aochan; /* num of D/A chans */ + int num_of_ranges; /* num of ranges */ + unsigned int IRQbits; /* allowed interrupts */ + unsigned int io_range; /* len of IO space */ + char have_dio; /* 1=card have DI/DO ports */ + int di_hi; /* ports for DI/DO operations */ int di_lo; int do_hi; int do_lo; - const struct comedi_lrange *const *range_type_list; // list of supported ranges + const struct comedi_lrange *const *range_type_list; /* list of supported ranges */ }; @@ -152,13 +152,13 @@ static const struct pcl726_board boardtypes[] = { #define this_board ((const struct pcl726_board *)dev->board_ptr) static struct comedi_driver driver_pcl726 = { - driver_name:"pcl726", - module:THIS_MODULE, - attach:pcl726_attach, - detach:pcl726_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl726_board), + .driver_name = "pcl726", + .module = THIS_MODULE, + .attach = pcl726_attach, + .detach = pcl726_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl726_board), }; COMEDI_INITCLEANUP(driver_pcl726); @@ -172,8 +172,8 @@ struct pcl726_private { #define devpriv ((struct pcl726_private *)dev->private) -static int pcl726_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl726_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int hi, lo; int n; @@ -197,8 +197,8 @@ static int pcl726_ao_insn(struct comedi_device * dev, struct comedi_subdevice * return n; } -static int pcl726_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl726_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int n; @@ -209,8 +209,8 @@ static int pcl726_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return n; } -static int pcl726_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl726_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -221,8 +221,8 @@ static int pcl726_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int pcl726_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl726_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -241,7 +241,7 @@ static int pcl726_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -264,7 +264,8 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->board_name = this_board->name; - if ((ret = alloc_private(dev, sizeof(struct pcl726_private))) < 0) + ret = alloc_private(dev, sizeof(struct pcl726_private)); + if (ret < 0) return -ENOMEM; for (i = 0; i < 12; i++) { @@ -279,19 +280,19 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->first_chan = 2; if (irq) { /* we want to use IRQ */ if (((1 << irq) & boardtypes[board].IRQbits) == 0) { - rt_printk + printk (", IRQ %d is out of allowed range, DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { - if (comedi_request_irq(irq, interrupt_pcl818, 0, + if (request_irq(irq, interrupt_pcl818, 0, "pcl726", dev)) { - rt_printk + printk (", unable to allocate IRQ %d, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%d", irq); + printk(", irq=%d", irq); } } } @@ -302,7 +303,8 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i printk("\n"); - if ((ret = alloc_subdevices(dev, 3)) < 0) + ret = alloc_subdevices(dev, 3); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -360,13 +362,13 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int pcl726_detach(struct comedi_device * dev) +static int pcl726_detach(struct comedi_device *dev) { -// printk("comedi%d: pcl726: remove\n",dev->minor); +/* printk("comedi%d: pcl726: remove\n",dev->minor); */ #ifdef ACL6126_IRQ if (dev->irq) { - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } #endif diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index f2c6d7c5693c..408cbffae418 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -26,13 +26,13 @@ The ACL-7130 card have an 8254 timer/counter not supported by this driver. #define PCL730_DIO_LO 2 /* TTL Digital I/O low byte (D0-D7) */ #define PCL730_DIO_HI 3 /* TTL Digital I/O high byte (D8-D15) */ -static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl730_detach(struct comedi_device * dev); +static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl730_detach(struct comedi_device *dev); struct pcl730_board { - const char *name; // board name - unsigned int io_range; // len of I/O space + const char *name; /* board name */ + unsigned int io_range; /* len of I/O space */ }; @@ -46,19 +46,19 @@ static const struct pcl730_board boardtypes[] = { #define this_board ((const struct pcl730_board *)dev->board_ptr) static struct comedi_driver driver_pcl730 = { - driver_name:"pcl730", - module:THIS_MODULE, - attach:pcl730_attach, - detach:pcl730_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl730_board), + .driver_name = "pcl730", + .module = THIS_MODULE, + .attach = pcl730_attach, + .detach = pcl730_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl730_board), }; COMEDI_INITCLEANUP(driver_pcl730); -static int pcl730_do_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -79,8 +79,8 @@ static int pcl730_do_insn(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int pcl730_di_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl730_di_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -91,7 +91,7 @@ static int pcl730_di_insn(struct comedi_device * dev, struct comedi_subdevice * return 2; } -static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -157,7 +157,7 @@ static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int pcl730_detach(struct comedi_device * dev) +static int pcl730_detach(struct comedi_device *dev) { printk("comedi%d: pcl730: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 11dfd230e565..dd91fe9f5f51 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -107,6 +107,7 @@ Options for ACL-8113, ISO-813: 3= 20V unipolar inputs */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/delay.h> @@ -117,7 +118,7 @@ Options for ACL-8113, ISO-813: #undef PCL812_EXTDEBUG /* if this is defined then a lot of messages is printed */ -// hardware types of the cards +/* hardware types of the cards */ #define boardPCL812PG 0 /* and ACL-8112PG */ #define boardPCL813B 1 #define boardPCL812 2 @@ -292,27 +293,27 @@ static const struct comedi_lrange range_a821pgh_ai = { 4, { } }; -static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl812_detach(struct comedi_device * dev); +static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl812_detach(struct comedi_device *dev); struct pcl812_board { - const char *name; // board name - int board_type; // type of this board - int n_aichan; // num of AI chans in S.E. - int n_aichan_diff; // DIFF num of chans - int n_aochan; // num of DA chans - int n_dichan; // DI and DO chans + const char *name; /* board name */ + int board_type; /* type of this board */ + int n_aichan; /* num of AI chans in S.E. */ + int n_aichan_diff; /* DIFF num of chans */ + int n_aochan; /* num of DA chans */ + int n_dichan; /* DI and DO chans */ int n_dochan; - int ai_maxdata; // AI resolution - unsigned int ai_ns_min; // max sample speed of card v ns - unsigned int i8254_osc_base; // clock base - const struct comedi_lrange *rangelist_ai; // rangelist for A/D - const struct comedi_lrange *rangelist_ao; // rangelist for D/A - unsigned int IRQbits; // allowed IRQ - unsigned char DMAbits; // allowed DMA chans - unsigned char io_range; // iorange for this board - unsigned char haveMPC508; // 1=board use MPC508A multiplexor + int ai_maxdata; /* AI resolution */ + unsigned int ai_ns_min; /* max sample speed of card v ns */ + unsigned int i8254_osc_base; /* clock base */ + const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ + unsigned int IRQbits; /* allowed IRQ */ + unsigned char DMAbits; /* allowed DMA chans */ + unsigned char io_range; /* iorange for this board */ + unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */ }; @@ -377,50 +378,50 @@ static const struct pcl812_board boardtypes[] = { #define this_board ((const struct pcl812_board *)dev->board_ptr) static struct comedi_driver driver_pcl812 = { - driver_name:"pcl812", - module:THIS_MODULE, - attach:pcl812_attach, - detach:pcl812_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl812_board), + .driver_name = "pcl812", + .module = THIS_MODULE, + .attach = pcl812_attach, + .detach = pcl812_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl812_board), }; COMEDI_INITCLEANUP(driver_pcl812); struct pcl812_private { - unsigned char valid; // =1 device is OK - unsigned char dma; // >0 use dma ( usedDMA channel) - unsigned char use_diff; // =1 diff inputs - unsigned char use_MPC; // 1=board uses MPC508A multiplexor - unsigned char use_ext_trg; // 1=board uses external trigger - unsigned char range_correction; // =1 we must add 1 to range number - unsigned char old_chan_reg; // lastly used chan/gain pair + unsigned char valid; /* =1 device is OK */ + unsigned char dma; /* >0 use dma ( usedDMA channel) */ + unsigned char use_diff; /* =1 diff inputs */ + unsigned char use_MPC; /* 1=board uses MPC508A multiplexor */ + unsigned char use_ext_trg; /* 1=board uses external trigger */ + unsigned char range_correction; /* =1 we must add 1 to range number */ + unsigned char old_chan_reg; /* lastly used chan/gain pair */ unsigned char old_gain_reg; - unsigned char mode_reg_int; // there is stored INT number for some card - unsigned char ai_neverending; // =1 we do unlimited AI - unsigned char ai_eos; // 1=EOS wake up - unsigned char ai_dma; // =1 we use DMA - unsigned int ai_poll_ptr; // how many sampes transfer poll - unsigned int ai_scans; // len of scanlist - unsigned int ai_act_scan; // how many scans we finished - unsigned int ai_chanlist[MAX_CHANLIST_LEN]; // our copy of channel/range list - unsigned int ai_n_chan; // how many channels is measured - unsigned int ai_flags; // flaglist - unsigned int ai_data_len; // len of data buffer - short *ai_data; // data buffer - unsigned int ai_is16b; // =1 we have 16 bit card - unsigned long dmabuf[2]; // PTR to DMA buf - unsigned int dmapages[2]; // how many pages we have allocated - unsigned int hwdmaptr[2]; // HW PTR to DMA buf - unsigned int hwdmasize[2]; // DMA buf size in bytes - unsigned int dmabytestomove[2]; // how many bytes DMA transfer - int next_dma_buf; // which buffer is next to use - unsigned int dma_runs_to_end; // how many times we must switch DMA buffers - unsigned int last_dma_run; // how many bytes to transfer on last DMA buffer - unsigned int max_812_ai_mode0_rangewait; // setling time for gain - unsigned int ao_readback[2]; // data for AO readback + unsigned char mode_reg_int; /* there is stored INT number for some card */ + unsigned char ai_neverending; /* =1 we do unlimited AI */ + unsigned char ai_eos; /* 1=EOS wake up */ + unsigned char ai_dma; /* =1 we use DMA */ + unsigned int ai_poll_ptr; /* how many sampes transfer poll */ + unsigned int ai_scans; /* len of scanlist */ + unsigned int ai_act_scan; /* how many scans we finished */ + unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ + unsigned int ai_n_chan; /* how many channels is measured */ + unsigned int ai_flags; /* flaglist */ + unsigned int ai_data_len; /* len of data buffer */ + short *ai_data; /* data buffer */ + unsigned int ai_is16b; /* =1 we have 16 bit card */ + unsigned long dmabuf[2]; /* PTR to DMA buf */ + unsigned int dmapages[2]; /* how many pages we have allocated */ + unsigned int hwdmaptr[2]; /* HW PTR to DMA buf */ + unsigned int hwdmasize[2]; /* DMA buf size in bytes */ + unsigned int dmabytestomove[2]; /* how many bytes DMA transfer */ + int next_dma_buf; /* which buffer is next to use */ + unsigned int dma_runs_to_end; /* how many times we must switch DMA buffers */ + unsigned int last_dma_run; /* how many bytes to transfer on last DMA buffer */ + unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */ + unsigned int ao_readback[2]; /* data for AO readback */ }; @@ -429,33 +430,33 @@ struct pcl812_private { /* ============================================================================== */ -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); -static void setup_range_channel(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int rangechan, char wait); -static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); +static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); /* ============================================================================== */ -static int pcl812_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl812_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int timeout, hi; outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); /* select software trigger */ - setup_range_channel(dev, s, insn->chanspec, 1); // select channel and renge + setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */ for (n = 0; n < insn->n; n++) { outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */ - comedi_udelay(5); + udelay(5); timeout = 50; /* wait max 50us, it must finish under 33us */ while (timeout--) { hi = inb(dev->iobase + PCL812_AD_HI); if (!(hi & PCL812_DRDY)) goto conv_finish; - comedi_udelay(1); + udelay(1); } - rt_printk + printk ("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n", dev->minor, dev->board_name, dev->iobase); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); @@ -471,24 +472,24 @@ static int pcl812_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi /* ============================================================================== */ -static int acl8216_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int acl8216_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int timeout; outb(1, dev->iobase + PCL812_MODE); /* select software trigger */ - setup_range_channel(dev, s, insn->chanspec, 1); // select channel and renge + setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */ for (n = 0; n < insn->n; n++) { outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */ - comedi_udelay(5); + udelay(5); timeout = 50; /* wait max 50us, it must finish under 33us */ while (timeout--) { if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY)) goto conv_finish; - comedi_udelay(1); + udelay(1); } - rt_printk + printk ("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n", dev->minor, dev->board_name, dev->iobase); outb(0, dev->iobase + PCL812_MODE); @@ -507,8 +508,8 @@ static int acl8216_ai_insn_read(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pcl812_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl812_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int i; @@ -527,8 +528,8 @@ static int pcl812_ao_insn_write(struct comedi_device * dev, struct comedi_subdev /* ============================================================================== */ -static int pcl812_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl812_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int i; @@ -543,8 +544,8 @@ static int pcl812_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi /* ============================================================================== */ -static int pcl812_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl812_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -558,8 +559,8 @@ static int pcl812_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi /* ============================================================================== */ -static int pcl812_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl812_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -579,15 +580,15 @@ static int pcl812_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi /* ============================================================================== */ -static void pcl812_cmdtest_out(int e, struct comedi_cmd * cmd) +static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd) { - rt_printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, + printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, cmd->start_src, cmd->scan_begin_src, cmd->convert_src); - rt_printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e, + printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e, cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); - rt_printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, + printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, cmd->scan_end_src); - rt_printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, + printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); } #endif @@ -595,14 +596,14 @@ static void pcl812_cmdtest_out(int e, struct comedi_cmd * cmd) /* ============================================================================== */ -static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...)\n"); + printk("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...)\n"); pcl812_cmdtest_out(-1, cmd); #endif /* step 1: make sure trigger sources are trivially valid */ @@ -639,7 +640,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (err) { #ifdef PCL812_EXTDEBUG pcl812_cmdtest_out(1, cmd); - rt_printk + printk ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=1\n", err); #endif @@ -681,7 +682,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (err) { #ifdef PCL812_EXTDEBUG pcl812_cmdtest_out(2, cmd); - rt_printk + printk ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=2\n", err); #endif @@ -739,7 +740,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (err) { #ifdef PCL812_EXTDEBUG pcl812_cmdtest_out(3, cmd); - rt_printk + printk ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=3\n", err); #endif @@ -761,7 +762,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (err) { #ifdef PCL812_EXTDEBUG - rt_printk + printk ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=4\n", err); #endif @@ -774,13 +775,13 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice /* ============================================================================== */ -static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes; struct comedi_cmd *cmd = &s->async->cmd; #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n"); + printk("pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n"); #endif if (cmd->start_src != TRIG_NOW) @@ -809,18 +810,18 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s cmd->flags & TRIG_ROUND_MASK); } - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ devpriv->ai_n_chan = cmd->chanlist_len; memcpy(devpriv->ai_chanlist, cmd->chanlist, sizeof(unsigned int) * cmd->scan_end_arg); - setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); // select first channel and range + setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); /* select first channel and range */ - if (devpriv->dma) { // check if we can use DMA transfer + if (devpriv->dma) { /* check if we can use DMA transfer */ devpriv->ai_dma = 1; for (i = 1; i < devpriv->ai_n_chan; i++) if (devpriv->ai_chanlist[0] != devpriv->ai_chanlist[i]) { - devpriv->ai_dma = 0; // we cann't use DMA :-( + devpriv->ai_dma = 0; /* we cann't use DMA :-( */ break; } } else @@ -841,14 +842,14 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s devpriv->ai_poll_ptr = 0; s->async->cur_chan = 0; - if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan? + if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */ devpriv->ai_eos = 1; if (devpriv->ai_n_chan == 1) - devpriv->ai_dma = 0; // DMA is useless for this situation + devpriv->ai_dma = 0; /* DMA is useless for this situation */ } if (devpriv->ai_dma) { - if (devpriv->ai_eos) { // we use EOS, so adapt DMA buffer to one scan + if (devpriv->ai_eos) { /* we use EOS, so adapt DMA buffer to one scan */ devpriv->dmabytestomove[0] = devpriv->ai_n_chan * sizeof(short); devpriv->dmabytestomove[1] = @@ -866,9 +867,9 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s if (devpriv->ai_neverending) { devpriv->dma_runs_to_end = 1; } else { - bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); // how many samples we must transfer? - devpriv->dma_runs_to_end = bytes / devpriv->dmabytestomove[0]; // how many DMA pages we must fill - devpriv->last_dma_run = bytes % devpriv->dmabytestomove[0]; //on last dma transfer must be moved + bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many samples we must transfer? */ + devpriv->dma_runs_to_end = bytes / devpriv->dmabytestomove[0]; /* how many DMA pages we must fill */ + devpriv->last_dma_run = bytes % devpriv->dmabytestomove[0]; /* on last dma transfer must be moved */ if (devpriv->dma_runs_to_end == 0) devpriv->dmabytestomove[0] = devpriv->last_dma_run; @@ -892,7 +893,7 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s release_dma_lock(dma_flags); enable_dma(devpriv->dma); #ifdef PCL812_EXTDEBUG - rt_printk + printk ("pcl812 EDBG: DMA %d PTR 0x%0x/0x%0x LEN %u/%u EOS %d\n", devpriv->dma, devpriv->hwdmaptr[0], devpriv->hwdmaptr[1], devpriv->dmabytestomove[0], @@ -907,13 +908,13 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s } if (devpriv->ai_dma) { - outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); // let's go! + outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); /* let's go! */ } else { - outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); // let's go! + outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); /* let's go! */ } #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: END: pcl812_ai_cmd(...)\n"); + printk("pcl812 EDBG: END: pcl812_ai_cmd(...)\n"); #endif return 0; @@ -939,7 +940,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) err = 0; break; } - comedi_udelay(1); + udelay(1); } } else { mask = 0x0fff; @@ -948,12 +949,12 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) err = 0; break; } - comedi_udelay(1); + udelay(1); } } if (err) { - rt_printk + printk ("comedi%d: pcl812: (%s at 0x%lx) A/D cmd IRQ without DRDY!\n", dev->minor, dev->board_name, dev->iobase); pcl812_ai_cancel(dev, s); @@ -984,14 +985,14 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) /* ============================================================================== */ -static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subdevice * s, - short * ptr, unsigned int bufptr, unsigned int len) +static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s, + short *ptr, unsigned int bufptr, unsigned int len) { unsigned int i; s->async->events = 0; for (i = len; i; i--) { - comedi_buf_put(s->async, ptr[bufptr++]); // get one sample + comedi_buf_put(s->async, ptr[bufptr++]); /* get one sample */ if (s->async->cur_chan == 0) { devpriv->ai_act_scan++; @@ -1019,7 +1020,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) short *ptr; #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n"); + printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n"); #endif ptr = (short *) devpriv->dmabuf[devpriv->next_dma_buf]; len = (devpriv->dmabytestomove[devpriv->next_dma_buf] >> 1) - @@ -1053,7 +1054,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) transfer_from_dma_buf(dev, s, ptr, bufptr, len); #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n"); + printk("pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n"); #endif return IRQ_HANDLED; } @@ -1061,7 +1062,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) /* ============================================================================== */ -static irqreturn_t interrupt_pcl812(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pcl812(int irq, void *d) { struct comedi_device *dev = d; @@ -1079,33 +1080,33 @@ static irqreturn_t interrupt_pcl812(int irq, void *d PT_REGS_ARG) /* ============================================================================== */ -static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; unsigned int top1, top2, i; if (!devpriv->ai_dma) - return 0; // poll is valid only for DMA transfer + return 0; /* poll is valid only for DMA transfer */ - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); for (i = 0; i < 10; i++) { - top1 = get_dma_residue(devpriv->ai_dma); // where is now DMA + top1 = get_dma_residue(devpriv->ai_dma); /* where is now DMA */ top2 = get_dma_residue(devpriv->ai_dma); if (top1 == top2) break; } if (top1 != top2) { - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } - top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; // where is now DMA in buffer - top1 >>= 1; // sample position + top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; /* where is now DMA in buffer */ + top1 >>= 1; /* sample position */ top2 = top1 - devpriv->ai_poll_ptr; - if (top2 < 1) { // no new samples - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + if (top2 < 1) { /* no new samples */ + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } @@ -1113,9 +1114,9 @@ static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice * (void *)devpriv->dmabuf[1 - devpriv->next_dma_buf], devpriv->ai_poll_ptr, top2); - devpriv->ai_poll_ptr = top1; // new buffer position + devpriv->ai_poll_ptr = top1; /* new buffer position */ - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return s->async->buf_write_count - s->async->buf_read_count; } @@ -1123,27 +1124,27 @@ static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice * /* ============================================================================== */ -static void setup_range_channel(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int rangechan, char wait) { - unsigned char chan_reg = CR_CHAN(rangechan); // normal board - unsigned char gain_reg = CR_RANGE(rangechan) + devpriv->range_correction; // gain index + unsigned char chan_reg = CR_CHAN(rangechan); /* normal board */ + unsigned char gain_reg = CR_RANGE(rangechan) + devpriv->range_correction; /* gain index */ if ((chan_reg == devpriv->old_chan_reg) && (gain_reg == devpriv->old_gain_reg)) - return; // we can return, no change + return; /* we can return, no change */ devpriv->old_chan_reg = chan_reg; devpriv->old_gain_reg = gain_reg; if (devpriv->use_MPC) { if (devpriv->use_diff) { - chan_reg = chan_reg | 0x30; // DIFF inputs + chan_reg = chan_reg | 0x30; /* DIFF inputs */ } else { if (chan_reg & 0x80) { - chan_reg = chan_reg | 0x20; // SE inputs 8-15 + chan_reg = chan_reg | 0x20; /* SE inputs 8-15 */ } else { - chan_reg = chan_reg | 0x10; // SE inputs 0-7 + chan_reg = chan_reg | 0x10; /* SE inputs 0-7 */ } } } @@ -1152,23 +1153,23 @@ static void setup_range_channel(struct comedi_device * dev, struct comedi_subdev outb(gain_reg, dev->iobase + PCL812_GAIN); /* select gain */ if (wait) { - comedi_udelay(devpriv->max_812_ai_mode0_rangewait); // XXX this depends on selected range and can be very long for some high gain ranges! + udelay(devpriv->max_812_ai_mode0_rangewait); /* XXX this depends on selected range and can be very long for some high gain ranges! */ } } /* ============================================================================== */ -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1, + printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1, divisor2); #endif outb(0xb4, dev->iobase + PCL812_CTRCTL); outb(0x74, dev->iobase + PCL812_CTRCTL); - comedi_udelay(1); + udelay(1); if (mode == 1) { outb(divisor2 & 0xff, dev->iobase + PCL812_CTR2); @@ -1177,14 +1178,14 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis outb((divisor1 >> 8) & 0xff, dev->iobase + PCL812_CTR1); } #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: END: start_pacer(...)\n"); + printk("pcl812 EDBG: END: start_pacer(...)\n"); #endif } /* ============================================================================== */ -static void free_resources(struct comedi_device * dev) +static void free_resources(struct comedi_device *dev) { if (dev->private) { @@ -1196,7 +1197,7 @@ static void free_resources(struct comedi_device * dev) free_dma(devpriv->dma); } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, this_board->io_range); } @@ -1204,19 +1205,19 @@ static void free_resources(struct comedi_device * dev) /* ============================================================================== */ -static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n"); + printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n"); #endif if (devpriv->ai_dma) disable_dma(devpriv->dma); outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); /* Stop A/D */ - start_pacer(dev, -1, 0, 0); // stop 8254 + start_pacer(dev, -1, 0, 0); /* stop 8254 */ outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: END: pcl812_ai_cancel(...)\n"); + printk("pcl812 EDBG: END: pcl812_ai_cancel(...)\n"); #endif return 0; } @@ -1224,14 +1225,14 @@ static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice /* ============================================================================== */ -static void pcl812_reset(struct comedi_device * dev) +static void pcl812_reset(struct comedi_device *dev) { #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: BGN: pcl812_reset(...)\n"); + printk("pcl812 EDBG: BGN: pcl812_reset(...)\n"); #endif outb(0, dev->iobase + PCL812_MUX); outb(0 + devpriv->range_correction, dev->iobase + PCL812_GAIN); - devpriv->old_chan_reg = -1; // invalidate chain/gain memory + devpriv->old_chan_reg = -1; /* invalidate chain/gain memory */ devpriv->old_gain_reg = -1; switch (this_board->board_type) { @@ -1244,7 +1245,7 @@ static void pcl812_reset(struct comedi_device * dev) case boardA821: outb(0, dev->iobase + PCL812_DA1_LO); outb(0, dev->iobase + PCL812_DA1_HI); - start_pacer(dev, -1, 0, 0); // stop 8254 + start_pacer(dev, -1, 0, 0); /* stop 8254 */ outb(0, dev->iobase + PCL812_DO_HI); outb(0, dev->iobase + PCL812_DO_LO); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); @@ -1254,19 +1255,19 @@ static void pcl812_reset(struct comedi_device * dev) case boardPCL813: case boardISO813: case boardACL8113: - comedi_udelay(5); + udelay(5); break; } - comedi_udelay(5); + udelay(5); #ifdef PCL812_EXTDEBUG - rt_printk("pcl812 EDBG: END: pcl812_reset(...)\n"); + printk("pcl812 EDBG: END: pcl812_reset(...)\n"); #endif } /* ============================================================================== */ -static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret, subdev; unsigned long iobase; @@ -1286,7 +1287,8 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i } dev->iobase = iobase; - if ((ret = alloc_private(dev, sizeof(struct pcl812_private))) < 0) { + ret = alloc_private(dev, sizeof(struct pcl812_private)); + if (ret < 0) { free_resources(dev); return ret; /* Can't alloc mem */ } @@ -1301,8 +1303,7 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i printk(", IRQ %u is out of allowed range, DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { - if (comedi_request_irq(irq, interrupt_pcl812, 0, - "pcl812", dev)) { + if (request_irq(irq, interrupt_pcl812, 0, "pcl812", dev)) { printk(", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { @@ -1364,7 +1365,8 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i if (this_board->n_dochan > 0) n_subdevices++; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) { + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) { free_resources(dev); return ret; } @@ -1570,7 +1572,7 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i case boardACL8112: devpriv->max_812_ai_mode0_rangewait = 1; if (it->options[3] > 0) - devpriv->use_ext_trg = 1; // we use external trigger + devpriv->use_ext_trg = 1; /* we use external trigger */ case boardA821: devpriv->max_812_ai_mode0_rangewait = 1; devpriv->mode_reg_int = (irq << 4) & 0xf0; @@ -1594,11 +1596,11 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i /* ============================================================================== */ -static int pcl812_detach(struct comedi_device * dev) +static int pcl812_detach(struct comedi_device *dev) { #ifdef PCL812_EXTDEBUG - rt_printk("comedi%d: pcl812: remove\n", dev->minor); + printk("comedi%d: pcl812: remove\n", dev->minor); #endif free_resources(dev); return 0; diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 515ba74cc7fe..19465c1b53c3 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -43,38 +43,38 @@ Configuration Options: #define DEBUG(x) x -// boards constants -// IO space len +/* boards constants */ +/* IO space len */ #define PCLx1x_RANGE 16 -//#define outb(x,y) printk("OUTB(%x, 200+%d)\n", x,y-0x200); outb(x,y) +/* #define outb(x,y) printk("OUTB(%x, 200+%d)\n", x,y-0x200); outb(x,y) */ -// INTEL 8254 counters +/* INTEL 8254 counters */ #define PCL816_CTR0 4 #define PCL816_CTR1 5 #define PCL816_CTR2 6 -// R: counter read-back register W: counter control +/* R: counter read-back register W: counter control */ #define PCL816_CTRCTL 7 -// R: A/D high byte W: A/D range control +/* R: A/D high byte W: A/D range control */ #define PCL816_RANGE 9 -// W: clear INT request +/* W: clear INT request */ #define PCL816_CLRINT 10 -// R: next mux scan channel W: mux scan channel & range control pointer +/* R: next mux scan channel W: mux scan channel & range control pointer */ #define PCL816_MUX 11 -// R/W: operation control register +/* R/W: operation control register */ #define PCL816_CONTROL 12 -// R: return status byte W: set DMA/IRQ +/* R: return status byte W: set DMA/IRQ */ #define PCL816_STATUS 13 #define PCL816_STATUS_DRDY_MASK 0x80 -// R: low byte of A/D W: soft A/D trigger +/* R: low byte of A/D W: soft A/D trigger */ #define PCL816_AD_LO 8 -// R: high byte of A/D W: A/D range control +/* R: high byte of A/D W: A/D range control */ #define PCL816_AD_HI 9 -// type of interrupt handler +/* type of interrupt handler */ #define INT_TYPE_AI1_INT 1 #define INT_TYPE_AI1_DMA 2 #define INT_TYPE_AI3_INT 4 @@ -83,7 +83,7 @@ Configuration Options: #define INT_TYPE_AI1_DMA_RTC 9 #define INT_TYPE_AI3_DMA_RTC 10 -// RTC stuff... +/* RTC stuff... */ #define RTC_IRQ 8 #define RTC_IO_EXTENT 0x10 #endif @@ -103,35 +103,35 @@ static const struct comedi_lrange range_pcl816 = { 8, { }; struct pcl816_board { - const char *name; // board name - int n_ranges; // len of range list - int n_aichan; // num of A/D chans in diferencial mode - unsigned int ai_ns_min; // minimal alllowed delay between samples (in ns) - int n_aochan; // num of D/A chans - int n_dichan; // num of DI chans - int n_dochan; // num of DO chans - const struct comedi_lrange *ai_range_type; // default A/D rangelist - const struct comedi_lrange *ao_range_type; // dafault D/A rangelist - unsigned int io_range; // len of IO space - unsigned int IRQbits; // allowed interrupts - unsigned int DMAbits; // allowed DMA chans - int ai_maxdata; // maxdata for A/D - int ao_maxdata; // maxdata for D/A - int ai_chanlist; // allowed len of channel list A/D - int ao_chanlist; // allowed len of channel list D/A - int i8254_osc_base; // 1/frequency of on board oscilator in ns + const char *name; /* board name */ + int n_ranges; /* len of range list */ + int n_aichan; /* num of A/D chans in diferencial mode */ + unsigned int ai_ns_min; /* minimal alllowed delay between samples (in ns) */ + int n_aochan; /* num of D/A chans */ + int n_dichan; /* num of DI chans */ + int n_dochan; /* num of DO chans */ + const struct comedi_lrange *ai_range_type; /* default A/D rangelist */ + const struct comedi_lrange *ao_range_type; /* dafault D/A rangelist */ + unsigned int io_range; /* len of IO space */ + unsigned int IRQbits; /* allowed interrupts */ + unsigned int DMAbits; /* allowed DMA chans */ + int ai_maxdata; /* maxdata for A/D */ + int ao_maxdata; /* maxdata for D/A */ + int ai_chanlist; /* allowed len of channel list A/D */ + int ao_chanlist; /* allowed len of channel list D/A */ + int i8254_osc_base; /* 1/frequency of on board oscilator in ns */ }; static const struct pcl816_board boardtypes[] = { {"pcl816", 8, 16, 10000, 1, 16, 16, &range_pcl816, &range_pcl816, PCLx1x_RANGE, - 0x00fc, // IRQ mask - 0x0a, // DMA mask - 0xffff, // 16-bit card - 0xffff, // D/A maxdata + 0x00fc, /* IRQ mask */ + 0x0a, /* DMA mask */ + 0xffff, /* 16-bit card */ + 0xffff, /* D/A maxdata */ 1024, - 1, // ao chan list + 1, /* ao chan list */ 100}, {"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816, &range_pcl816, PCLx1x_RANGE, @@ -148,8 +148,8 @@ static const struct pcl816_board boardtypes[] = { #define devpriv ((struct pcl816_private *)dev->private) #define this_board ((const struct pcl816_board *)dev->board_ptr) -static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl816_detach(struct comedi_device * dev); +static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl816_detach(struct comedi_device *dev); #ifdef unused static int RTC_lock = 0; /* RTC lock */ @@ -157,55 +157,55 @@ static int RTC_timer_lock = 0; /* RTC int lock */ #endif static struct comedi_driver driver_pcl816 = { - driver_name:"pcl816", - module:THIS_MODULE, - attach:pcl816_attach, - detach:pcl816_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl816_board), + .driver_name = "pcl816", + .module = THIS_MODULE, + .attach = pcl816_attach, + .detach = pcl816_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl816_board), }; COMEDI_INITCLEANUP(driver_pcl816); struct pcl816_private { - unsigned int dma; // used DMA, 0=don't use DMA - int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc + unsigned int dma; /* used DMA, 0=don't use DMA */ + int dma_rtc; /* 1=RTC used with DMA, 0=no RTC alloc */ #ifdef unused - unsigned long rtc_iobase; // RTC port region + unsigned long rtc_iobase; /* RTC port region */ unsigned int rtc_iosize; unsigned int rtc_irq; #endif - unsigned long dmabuf[2]; // pointers to begin of DMA buffers - unsigned int dmapages[2]; // len of DMA buffers in PAGE_SIZEs - unsigned int hwdmaptr[2]; // hardware address of DMA buffers - unsigned int hwdmasize[2]; // len of DMA buffers in Bytes - unsigned int dmasamplsize; // size in samples hwdmasize[0]/2 - unsigned int last_top_dma; // DMA pointer in last RTC int - int next_dma_buf; // which DMA buffer will be used next round - long dma_runs_to_end; // how many we must permorm DMA transfer to end of record - unsigned long last_dma_run; // how many bytes we must transfer on last DMA page - - unsigned int ai_scans; // len of scanlist - unsigned char ai_neverending; // if=1, then we do neverending record (you must use cancel()) - int irq_free; // 1=have allocated IRQ - int irq_blocked; // 1=IRQ now uses any subdev + unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */ + unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */ + unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */ + unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */ + unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */ + unsigned int last_top_dma; /* DMA pointer in last RTC int */ + int next_dma_buf; /* which DMA buffer will be used next round */ + long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ + unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ + + unsigned int ai_scans; /* len of scanlist */ + unsigned char ai_neverending; /* if=1, then we do neverending record (you must use cancel()) */ + int irq_free; /* 1=have allocated IRQ */ + int irq_blocked; /* 1=IRQ now uses any subdev */ #ifdef unused - int rtc_irq_blocked; // 1=we now do AI with DMA&RTC + int rtc_irq_blocked; /* 1=we now do AI with DMA&RTC */ #endif - int irq_was_now_closed; // when IRQ finish, there's stored int816_mode for last interrupt - int int816_mode; // who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma - struct comedi_subdevice *last_int_sub; // ptr to subdevice which now finish - int ai_act_scan; // how many scans we finished - unsigned int ai_act_chanlist[16]; // MUX setting for actual AI operations - unsigned int ai_act_chanlist_len; // how long is actual MUX list - unsigned int ai_act_chanlist_pos; // actual position in MUX list - unsigned int ai_poll_ptr; // how many sampes transfer poll - struct comedi_subdevice *sub_ai; // ptr to AI subdevice + int irq_was_now_closed; /* when IRQ finish, there's stored int816_mode for last interrupt */ + int int816_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ + struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */ + int ai_act_scan; /* how many scans we finished */ + unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */ + unsigned int ai_act_chanlist_len; /* how long is actual MUX list */ + unsigned int ai_act_chanlist_pos; /* actual position in MUX list */ + unsigned int ai_poll_ptr; /* how many sampes transfer poll */ + struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */ #ifdef unused - struct timer_list rtc_irq_timer; // timer for RTC sanity check - unsigned long rtc_freq; // RTC int freq + struct timer_list rtc_irq_timer; /* timer for RTC sanity check */ + unsigned long rtc_freq; /* RTC int freq */ #endif }; @@ -213,36 +213,36 @@ struct pcl816_private { /* ============================================================================== */ -static int check_and_setup_channel_list(struct comedi_device * dev, - struct comedi_subdevice * s, unsigned int *chanlist, int chanlen); -static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static int check_and_setup_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int *chanlist, int chanlen); +static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); #ifdef unused static int set_rtc_irq_bit(unsigned char bit); #endif -static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); +static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); /* ============================================================================== ANALOG INPUT MODE0, 816 cards, slow version */ -static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl816_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int timeout; DPRINTK("mode 0 analog input\n"); - // software trigger, DMA and INT off + /* software trigger, DMA and INT off */ outb(0, dev->iobase + PCL816_CONTROL); - // clear INT (conversion end) flag + /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL816_CLRINT); - // Set the input channel + /* Set the input channel */ outb(CR_CHAN(insn->chanspec) & 0xf, dev->iobase + PCL816_MUX); outb(CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); /* select gain */ @@ -254,7 +254,7 @@ static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi while (timeout--) { if (!(inb(dev->iobase + PCL816_STATUS) & PCL816_STATUS_DRDY_MASK)) { - // return read value + /* return read value */ data[n] = ((inb(dev->iobase + PCL816_AD_HI) << 8) | @@ -263,9 +263,9 @@ static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi outb(0, dev->iobase + PCL816_CLRINT); /* clear INT (conversion end) flag */ break; } - comedi_udelay(1); + udelay(1); } - // Return timeout error + /* Return timeout error */ if (!timeout) { comedi_error(dev, "A/D insn timeout\n"); data[0] = 0; @@ -293,9 +293,9 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) if (!(inb(dev->iobase + PCL816_STATUS) & PCL816_STATUS_DRDY_MASK)) break; - comedi_udelay(1); + udelay(1); } - if (!timeout) { // timeout, bail error + if (!timeout) { /* timeout, bail error */ outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ comedi_error(dev, "A/D mode1/3 IRQ without DRDY!"); pcl816_ai_cancel(dev, s); @@ -305,7 +305,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) } - // get the sample + /* get the sample */ low = inb(dev->iobase + PCL816_AD_LO); hi = inb(dev->iobase + PCL816_AD_HI); @@ -334,8 +334,8 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) ============================================================================== analog input dma mode 1 & 3, 816 cards */ -static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subdevice * s, - short * ptr, unsigned int bufptr, unsigned int len) +static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s, + short *ptr, unsigned int bufptr, unsigned int len) { int i; @@ -352,7 +352,7 @@ static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subd } if (!devpriv->ai_neverending) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { // all data sampled + if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ pcl816_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_BLOCK; @@ -374,12 +374,12 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) disable_dma(devpriv->dma); this_dma_buf = devpriv->next_dma_buf; - if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { // switch dma bufs + if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { /* switch dma bufs */ devpriv->next_dma_buf = 1 - devpriv->next_dma_buf; set_dma_mode(devpriv->dma, DMA_MODE_READ); dma_flags = claim_dma_lock(); -// clear_dma_ff (devpriv->dma); +/* clear_dma_ff (devpriv->dma); */ set_dma_addr(devpriv->dma, devpriv->hwdmaptr[devpriv->next_dma_buf]); if (devpriv->dma_runs_to_end) { @@ -409,7 +409,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) ============================================================================== INT procedure */ -static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pcl816(int irq, void *d) { struct comedi_device *dev = d; DPRINTK("<I>"); @@ -433,7 +433,7 @@ static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG) (!devpriv->int816_mode)) { if (devpriv->irq_was_now_closed) { devpriv->irq_was_now_closed = 0; - // comedi_error(dev,"last IRQ.."); + /* comedi_error(dev,"last IRQ.."); */ return IRQ_HANDLED; } comedi_error(dev, "bad IRQ!"); @@ -447,28 +447,28 @@ static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG) ============================================================================== COMMAND MODE */ -static void pcl816_cmdtest_out(int e, struct comedi_cmd * cmd) +static void pcl816_cmdtest_out(int e, struct comedi_cmd *cmd) { - rt_printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, + printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, cmd->start_src, cmd->scan_begin_src, cmd->convert_src); - rt_printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e, + printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e, cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); - rt_printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, + printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, cmd->scan_end_src); - rt_printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, + printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); } /* ============================================================================== */ -static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; - DEBUG(rt_printk("pcl816 pcl812_ai_cmdtest\n"); + DEBUG(printk("pcl816 pcl812_ai_cmdtest\n"); pcl816_cmdtest_out(-1, cmd);); /* step 1: make sure trigger sources are trivially valid */ @@ -482,7 +482,7 @@ static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) err++; - if (!cmd->convert_src & (TRIG_EXT | TRIG_TIMER)) + if (!(cmd->convert_src & (TRIG_EXT | TRIG_TIMER))) err++; tmp = cmd->scan_end_src; @@ -597,7 +597,7 @@ static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq; struct comedi_cmd *cmd = &s->async->cmd; @@ -610,7 +610,7 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s return -EINVAL; if (cmd->scan_end_arg != cmd->chanlist_len) return -EINVAL; -// if(cmd->chanlist_len>MAX_CHANLIST_LEN) return -EINVAL; +/* if(cmd->chanlist_len>MAX_CHANLIST_LEN) return -EINVAL; */ if (devpriv->irq_blocked) return -EBUSY; @@ -621,7 +621,7 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); - if (divisor1 == 1) { // PCL816 crash if any divisor is set to 1 + if (divisor1 == 1) { /* PCL816 crash if any divisor is set to 1 */ divisor1 = 2; divisor2 /= 2; } @@ -631,12 +631,12 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s } } - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ if (!check_and_setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len)) return -EINVAL; - comedi_udelay(1); + udelay(1); devpriv->ai_act_scan = 0; s->async->cur_chan = 0; @@ -652,19 +652,19 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s devpriv->ai_neverending = 1; } - if ((cmd->flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan? + if ((cmd->flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */ printk("pl816: You wankt WAKE_EOS but I dont want handle it"); - // devpriv->ai_eos=1; - //if (devpriv->ai_n_chan==1) - // devpriv->dma=0; // DMA is useless for this situation + /* devpriv->ai_eos=1; */ + /* if (devpriv->ai_n_chan==1) */ + /* devpriv->dma=0; // DMA is useless for this situation */ } if (devpriv->dma) { bytes = devpriv->hwdmasize[0]; if (!devpriv->ai_neverending) { - bytes = s->async->cmd.chanlist_len * s->async->cmd.chanlist_len * sizeof(short); // how many - devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; // how many DMA pages we must fill - devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; //on last dma transfer must be moved + bytes = s->async->cmd.chanlist_len * s->async->cmd.chanlist_len * sizeof(short); /* how many */ + devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fill */ + devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ devpriv->dma_runs_to_end--; if (devpriv->dma_runs_to_end >= 0) bytes = devpriv->hwdmasize[0]; @@ -687,14 +687,14 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s switch (cmd->convert_src) { case TRIG_TIMER: devpriv->int816_mode = INT_TYPE_AI1_DMA; - outb(0x32, dev->iobase + PCL816_CONTROL); // Pacer+IRQ+DMA - outb(dmairq, dev->iobase + PCL816_STATUS); // write irq and DMA to card + outb(0x32, dev->iobase + PCL816_CONTROL); /* Pacer+IRQ+DMA */ + outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq and DMA to card */ break; default: devpriv->int816_mode = INT_TYPE_AI3_DMA; - outb(0x34, dev->iobase + PCL816_CONTROL); // Ext trig+IRQ+DMA - outb(dmairq, dev->iobase + PCL816_STATUS); // write irq to card + outb(0x34, dev->iobase + PCL816_CONTROL); /* Ext trig+IRQ+DMA */ + outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq to card */ break; } @@ -702,32 +702,32 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s return 0; } -static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; unsigned int top1, top2, i; if (!devpriv->dma) - return 0; // poll is valid only for DMA transfer + return 0; /* poll is valid only for DMA transfer */ - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); for (i = 0; i < 20; i++) { - top1 = get_dma_residue(devpriv->dma); // where is now DMA + top1 = get_dma_residue(devpriv->dma); /* where is now DMA */ top2 = get_dma_residue(devpriv->dma); if (top1 == top2) break; } if (top1 != top2) { - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } - top1 = devpriv->hwdmasize[0] - top1; // where is now DMA in buffer - top1 >>= 1; // sample position + top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */ + top1 >>= 1; /* sample position */ top2 = top1 - devpriv->ai_poll_ptr; - if (top2 < 1) { // no new samples - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + if (top2 < 1) { /* no new samples */ + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } @@ -735,8 +735,8 @@ static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice * (short *) devpriv->dmabuf[devpriv->next_dma_buf], devpriv->ai_poll_ptr, top2); - devpriv->ai_poll_ptr = top1; // new buffer position - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + devpriv->ai_poll_ptr = top1; /* new buffer position */ + spin_unlock_irqrestore(&dev->spinlock, flags); return s->async->buf_write_count - s->async->buf_read_count; } @@ -745,16 +745,16 @@ static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice * ============================================================================== cancel any mode 1-4 AI */ -static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { -// DEBUG(rt_printk("pcl816_ai_cancel()\n");) +/* DEBUG(printk("pcl816_ai_cancel()\n");) */ if (devpriv->irq_blocked > 0) { switch (devpriv->int816_mode) { #ifdef unused case INT_TYPE_AI1_DMA_RTC: case INT_TYPE_AI3_DMA_RTC: - set_rtc_irq_bit(0); // stop RTC + set_rtc_irq_bit(0); /* stop RTC */ del_timer(&devpriv->rtc_irq_timer); #endif case INT_TYPE_AI1_DMA: @@ -763,7 +763,7 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice case INT_TYPE_AI1_INT: case INT_TYPE_AI3_INT: outb(inb(dev->iobase + PCL816_CONTROL) & 0x73, dev->iobase + PCL816_CONTROL); /* Stop A/D */ - comedi_udelay(1); + udelay(1); outb(0, dev->iobase + PCL816_CONTROL); /* Stop A/D */ outb(0xb0, dev->iobase + PCL816_CTRCTL); /* Stop pacer */ outb(0x70, dev->iobase + PCL816_CTRCTL); @@ -776,12 +776,12 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice devpriv->irq_was_now_closed = devpriv->int816_mode; devpriv->int816_mode = 0; devpriv->last_int_sub = s; -// s->busy = 0; +/* s->busy = 0; */ break; } } - DEBUG(rt_printk("comedi: pcl816_ai_cancel() successful\n"); + DEBUG(printk("comedi: pcl816_ai_cancel() successful\n"); ) return 0; } @@ -793,34 +793,34 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice static int pcl816_check(unsigned long iobase) { outb(0x00, iobase + PCL816_MUX); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL816_MUX) != 0x00) - return 1; //there isn't card + return 1; /* there isn't card */ outb(0x55, iobase + PCL816_MUX); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL816_MUX) != 0x55) - return 1; //there isn't card + return 1; /* there isn't card */ outb(0x00, iobase + PCL816_MUX); - comedi_udelay(1); + udelay(1); outb(0x18, iobase + PCL816_CONTROL); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL816_CONTROL) != 0x18) - return 1; //there isn't card - return 0; // ok, card exist + return 1; /* there isn't card */ + return 0; /* ok, card exist */ } /* ============================================================================== reset whole PCL-816 cards */ -static void pcl816_reset(struct comedi_device * dev) +static void pcl816_reset(struct comedi_device *dev) { -// outb (0, dev->iobase + PCL818_DA_LO); // DAC=0V -// outb (0, dev->iobase + PCL818_DA_HI); -// comedi_udelay (1); -// outb (0, dev->iobase + PCL818_DO_HI); // DO=$0000 -// outb (0, dev->iobase + PCL818_DO_LO); -// comedi_udelay (1); +/* outb (0, dev->iobase + PCL818_DA_LO); DAC=0V */ +/* outb (0, dev->iobase + PCL818_DA_HI); */ +/* udelay (1); */ +/* outb (0, dev->iobase + PCL818_DO_HI); DO=$0000 */ +/* outb (0, dev->iobase + PCL818_DO_LO); */ +/* udelay (1); */ outb(0, dev->iobase + PCL816_CONTROL); outb(0, dev->iobase + PCL816_MUX); outb(0, dev->iobase + PCL816_CLRINT); @@ -835,16 +835,16 @@ static void pcl816_reset(struct comedi_device * dev) Start/stop pacer onboard pacer */ static void -start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { outb(0x32, dev->iobase + PCL816_CTRCTL); outb(0xff, dev->iobase + PCL816_CTR0); outb(0x00, dev->iobase + PCL816_CTR0); - comedi_udelay(1); - outb(0xb4, dev->iobase + PCL816_CTRCTL); // set counter 2 as mode 3 - outb(0x74, dev->iobase + PCL816_CTRCTL); // set counter 1 as mode 3 - comedi_udelay(1); + udelay(1); + outb(0xb4, dev->iobase + PCL816_CTRCTL); /* set counter 2 as mode 3 */ + outb(0x74, dev->iobase + PCL816_CTRCTL); /* set counter 1 as mode 3 */ + udelay(1); if (mode == 1) { DPRINTK("mode %d, divisor1 %d, divisor2 %d\n", mode, divisor1, @@ -856,7 +856,7 @@ start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, } /* clear pending interrupts (just in case) */ -// outb(0, dev->iobase + PCL816_CLRINT); +/* outb(0, dev->iobase + PCL816_CLRINT); */ } /* @@ -865,49 +865,49 @@ start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, If it's ok, then program scan/gain logic */ static int -check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +check_and_setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, int chanlen) { unsigned int chansegment[16]; unsigned int i, nowmustbechan, seglen, segpos; - // correct channel and range number check itself comedi/range.c + /* correct channel and range number check itself comedi/range.c */ if (chanlen < 1) { comedi_error(dev, "range/channel list is empty!"); return 0; } if (chanlen > 1) { - chansegment[0] = chanlist[0]; // first channel is everytime ok + chansegment[0] = chanlist[0]; /* first channel is everytime ok */ for (i = 1, seglen = 1; i < chanlen; i++, seglen++) { - // build part of chanlist - DEBUG(rt_printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]), + /* build part of chanlist */ + DEBUG(printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]), CR_RANGE(chanlist[i])); ) if (chanlist[0] == chanlist[i]) - break; // we detect loop, this must by finish + break; /* we detect loop, this must by finish */ nowmustbechan = (CR_CHAN(chansegment[i - 1]) + 1) % chanlen; if (nowmustbechan != CR_CHAN(chanlist[i])) { - // channel list isn't continous :-( - rt_printk + /* channel list isn't continous :-( */ + printk ("comedi%d: pcl816: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", dev->minor, i, CR_CHAN(chanlist[i]), nowmustbechan, CR_CHAN(chanlist[0])); return 0; } - chansegment[i] = chanlist[i]; // well, this is next correct channel in list + chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */ } - for (i = 0, segpos = 0; i < chanlen; i++) { // check whole chanlist - DEBUG(rt_printk("%d %d=%d %d\n", + for (i = 0, segpos = 0; i < chanlen; i++) { /* check whole chanlist */ + DEBUG(printk("%d %d=%d %d\n", CR_CHAN(chansegment[i % seglen]), CR_RANGE(chansegment[i % seglen]), CR_CHAN(chanlist[i]), CR_RANGE(chanlist[i])); ) if (chanlist[i] != chansegment[i % seglen]) { - rt_printk + printk ("comedi%d: pcl816: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", dev->minor, i, CR_CHAN(chansegment[i]), CR_RANGE(chansegment[i]), @@ -915,7 +915,7 @@ check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice CR_CHAN(chanlist[i % seglen]), CR_RANGE(chanlist[i % seglen]), CR_AREF(chansegment[i % seglen])); - return 0; // chan/gain list is strange + return 0; /* chan/gain list is strange */ } } } else { @@ -925,17 +925,17 @@ check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice devpriv->ai_act_chanlist_len = seglen; devpriv->ai_act_chanlist_pos = 0; - for (i = 0; i < seglen; i++) { // store range list to card + for (i = 0; i < seglen; i++) { /* store range list to card */ devpriv->ai_act_chanlist[i] = CR_CHAN(chanlist[i]); outb(CR_CHAN(chanlist[0]) & 0xf, dev->iobase + PCL816_MUX); outb(CR_RANGE(chanlist[0]), dev->iobase + PCL816_RANGE); /* select gain */ } - comedi_udelay(1); + udelay(1); outb(devpriv->ai_act_chanlist[0] | (devpriv->ai_act_chanlist[seglen - 1] << 4), dev->iobase + PCL816_MUX); /* select channel interval to scan */ - return 1; // we can serve this with MUX logic + return 1; /* we can serve this with MUX logic */ } #ifdef unused @@ -979,9 +979,9 @@ static int set_rtc_irq_bit(unsigned char bit) ============================================================================== Free any resources that we have claimed */ -static void free_resources(struct comedi_device * dev) +static void free_resources(struct comedi_device *dev) { - //rt_printk("free_resource()\n"); + /* printk("free_resource()\n"); */ if (dev->private) { pcl816_ai_cancel(dev, devpriv->sub_ai); pcl816_reset(dev); @@ -993,7 +993,7 @@ static void free_resources(struct comedi_device * dev) free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]); #ifdef unused if (devpriv->rtc_irq) - comedi_free_irq(devpriv->rtc_irq, dev); + free_irq(devpriv->rtc_irq, dev); if ((devpriv->dma_rtc) && (RTC_lock == 1)) { if (devpriv->rtc_iobase) release_region(devpriv->rtc_iobase, @@ -1006,7 +1006,7 @@ static void free_resources(struct comedi_device * dev) free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, this_board->io_range); - //rt_printk("free_resource() end\n"); + /* printk("free_resource() end\n"); */ } /* @@ -1015,13 +1015,13 @@ static void free_resources(struct comedi_device * dev) Initialization */ -static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; unsigned long iobase; unsigned int irq, dma; unsigned long pages; - //int i; + /* int i; */ struct comedi_subdevice *s; /* claim our I/O space */ @@ -1030,18 +1030,19 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i this_board->name, iobase); if (!request_region(iobase, this_board->io_range, "pcl816")) { - rt_printk("I/O port conflict\n"); + printk("I/O port conflict\n"); return -EIO; } dev->iobase = iobase; if (pcl816_check(iobase)) { - rt_printk(", I cann't detect board. FAIL!\n"); + printk(", I cann't detect board. FAIL!\n"); return -EIO; } - if ((ret = alloc_private(dev, sizeof(struct pcl816_private))) < 0) + ret = alloc_private(dev, sizeof(struct pcl816_private)); + if (ret < 0) return ret; /* Can't alloc mem */ /* set up some name stuff */ @@ -1053,19 +1054,18 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i irq = it->options[1]; if (irq) { /* we want to use IRQ */ if (((1 << irq) & this_board->IRQbits) == 0) { - rt_printk + printk (", IRQ %u is out of allowed range, DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { - if (comedi_request_irq(irq, interrupt_pcl816, 0, - "pcl816", dev)) { - rt_printk + if (request_irq(irq, interrupt_pcl816, 0, "pcl816", dev)) { + printk (", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%u", irq); + printk(", irq=%u", irq); } } } @@ -1084,7 +1084,7 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i #ifdef unused /* grab RTC for DMA operations */ devpriv->dma_rtc = 0; - if (it->options[2] > 0) { // we want to use DMA + if (it->options[2] > 0) { /* we want to use DMA */ if (RTC_lock == 0) { if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "pcl816 (RTC)")) @@ -1094,12 +1094,11 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->rtc_iosize = RTC_IO_EXTENT; RTC_lock++; #ifdef UNTESTED_CODE - if (!comedi_request_irq(RTC_IRQ, - interrupt_pcl816_ai_mode13_dma_rtc, 0, + if (!request_irq(RTC_IRQ, interrupt_pcl816_ai_mode13_dma_rtc, 0, "pcl816 DMA (RTC)", dev)) { devpriv->dma_rtc = 1; devpriv->rtc_irq = RTC_IRQ; - rt_printk(", dma_irq=%u", devpriv->rtc_irq); + printk(", dma_irq=%u", devpriv->rtc_irq); } else { RTC_lock--; if (RTC_lock == 0) { @@ -1130,34 +1129,34 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i goto no_dma; /* DMA disabled */ if (((1 << dma) & this_board->DMAbits) == 0) { - rt_printk(", DMA is out of allowed range, FAIL!\n"); + printk(", DMA is out of allowed range, FAIL!\n"); return -EINVAL; /* Bad DMA */ } ret = request_dma(dma, "pcl816"); if (ret) { - rt_printk(", unable to allocate DMA %u, FAIL!\n", dma); + printk(", unable to allocate DMA %u, FAIL!\n", dma); return -EBUSY; /* DMA isn't free */ } devpriv->dma = dma; - rt_printk(", dma=%u", dma); + printk(", dma=%u", dma); pages = 2; /* we need 16KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) { - rt_printk(", unable to allocate DMA buffer, FAIL!\n"); + printk(", unable to allocate DMA buffer, FAIL!\n"); /* maybe experiment with try_to_free_pages() will help .... */ return -EBUSY; /* no buffer :-( */ } devpriv->dmapages[0] = pages; devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]); devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE; - //rt_printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); + /* printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); */ - if (devpriv->dma_rtc == 0) { // we must do duble buff :-( + if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */ devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[1]) { - rt_printk + printk (", unable to allocate DMA buffer, FAIL!\n"); return -EBUSY; } @@ -1177,7 +1176,9 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i if (this_board->n_dochan > 0) subdevs[3] = COMEDI_SUBD_DO; */ - if ((ret = alloc_subdevices(dev, 1)) < 0) + + ret = alloc_subdevices(dev, 1); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -1188,7 +1189,7 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i s->subdev_flags = SDF_READABLE | SDF_CMD_READ; s->n_chan = this_board->n_aichan; s->subdev_flags |= SDF_DIFF; - //printk (", %dchans DIFF DAC - %d", s->n_chan, i); + /* printk (", %dchans DIFF DAC - %d", s->n_chan, i); */ s->maxdata = this_board->ai_maxdata; s->len_chanlist = this_board->ai_chanlist; s->range_table = this_board->ai_range_type; @@ -1229,7 +1230,7 @@ case COMEDI_SUBD_DO: pcl816_reset(dev); - rt_printk("\n"); + printk("\n"); return 0; } @@ -1238,9 +1239,9 @@ case COMEDI_SUBD_DO: ============================================================================== Removes device */ -static int pcl816_detach(struct comedi_device * dev) +static int pcl816_detach(struct comedi_device *dev) { - DEBUG(rt_printk("comedi%d: pcl816: remove\n", dev->minor); + DEBUG(printk("comedi%d: pcl816: remove\n", dev->minor); ) free_resources(dev); #ifdef unused diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 43a9d56c6a43..039a77a66451 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -107,9 +107,9 @@ A word or two about DMA. Driver support DMA operations at two ways: #include "8253.h" -// #define PCL818_MODE13_AO 1 +/* #define PCL818_MODE13_AO 1 */ -// boards constants +/* boards constants */ #define boardPCL818L 0 #define boardPCL818H 1 @@ -118,60 +118,60 @@ A word or two about DMA. Driver support DMA operations at two ways: #define boardPCL818 4 #define boardPCL718 5 -// IO space len +/* IO space len */ #define PCLx1x_RANGE 16 -// IO space len if we use FIFO +/* IO space len if we use FIFO */ #define PCLx1xFIFO_RANGE 32 -// W: clear INT request +/* W: clear INT request */ #define PCL818_CLRINT 8 -// R: return status byte +/* R: return status byte */ #define PCL818_STATUS 8 -// R: A/D high byte W: A/D range control +/* R: A/D high byte W: A/D range control */ #define PCL818_RANGE 1 -// R: next mux scan channel W: mux scan channel & range control pointer +/* R: next mux scan channel W: mux scan channel & range control pointer */ #define PCL818_MUX 2 -// R/W: operation control register +/* R/W: operation control register */ #define PCL818_CONTROL 9 -// W: counter enable +/* W: counter enable */ #define PCL818_CNTENABLE 10 -// R: low byte of A/D W: soft A/D trigger +/* R: low byte of A/D W: soft A/D trigger */ #define PCL818_AD_LO 0 -// R: high byte of A/D W: A/D range control +/* R: high byte of A/D W: A/D range control */ #define PCL818_AD_HI 1 -// W: D/A low&high byte +/* W: D/A low&high byte */ #define PCL818_DA_LO 4 #define PCL818_DA_HI 5 -// R: low&high byte of DI +/* R: low&high byte of DI */ #define PCL818_DI_LO 3 #define PCL818_DI_HI 11 -// W: low&high byte of DO +/* W: low&high byte of DO */ #define PCL818_DO_LO 3 #define PCL818_DO_HI 11 -// W: PCL718 second D/A +/* W: PCL718 second D/A */ #define PCL718_DA2_LO 6 #define PCL718_DA2_HI 7 -// counters +/* counters */ #define PCL818_CTR0 12 #define PCL818_CTR1 13 #define PCL818_CTR2 14 -// W: counter control +/* W: counter control */ #define PCL818_CTRCTL 15 -// W: fifo enable/disable +/* W: fifo enable/disable */ #define PCL818_FI_ENABLE 6 -// W: fifo interrupt clear +/* W: fifo interrupt clear */ #define PCL818_FI_INTCLR 20 -// W: fifo interrupt clear +/* W: fifo interrupt clear */ #define PCL818_FI_FLUSH 25 -// R: fifo status +/* R: fifo status */ #define PCL818_FI_STATUS 25 -// R: one record from FIFO +/* R: one record from FIFO */ #define PCL818_FI_DATALO 23 #define PCL818_FI_DATAHI 23 -// type of interrupt handler +/* type of interrupt handler */ #define INT_TYPE_AI1_INT 1 #define INT_TYPE_AI1_DMA 2 #define INT_TYPE_AI1_FIFO 3 @@ -184,7 +184,7 @@ A word or two about DMA. Driver support DMA operations at two ways: #endif #ifdef unused -// RTC stuff... +/* RTC stuff... */ #define INT_TYPE_AI1_DMA_RTC 9 #define INT_TYPE_AI3_DMA_RTC 10 @@ -244,8 +244,8 @@ static const struct comedi_lrange range718_bipolar0_5 = { 1, {BIP_RANGE(0.5),} } static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} }; static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} }; -static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcl818_detach(struct comedi_device * dev); +static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcl818_detach(struct comedi_device *dev); #ifdef unused static int RTC_lock = 0; /* RTC lock */ @@ -254,22 +254,22 @@ static int RTC_timer_lock = 0; /* RTC int lock */ struct pcl818_board { - const char *name; // driver name - int n_ranges; // len of range list - int n_aichan_se; // num of A/D chans in single ended mode - int n_aichan_diff; // num of A/D chans in diferencial mode - unsigned int ns_min; // minimal alllowed delay between samples (in ns) - int n_aochan; // num of D/A chans - int n_dichan; // num of DI chans - int n_dochan; // num of DO chans - const struct comedi_lrange *ai_range_type; // default A/D rangelist - const struct comedi_lrange *ao_range_type; // default D/A rangelist - unsigned int io_range; // len of IO space - unsigned int IRQbits; // allowed interrupts - unsigned int DMAbits; // allowed DMA chans - int ai_maxdata; // maxdata for A/D - int ao_maxdata; // maxdata for D/A - unsigned char fifo; // 1=board has FIFO + const char *name; /* driver name */ + int n_ranges; /* len of range list */ + int n_aichan_se; /* num of A/D chans in single ended mode */ + int n_aichan_diff; /* num of A/D chans in diferencial mode */ + unsigned int ns_min; /* minimal alllowed delay between samples (in ns) */ + int n_aochan; /* num of D/A chans */ + int n_dichan; /* num of DI chans */ + int n_dochan; /* num of DO chans */ + const struct comedi_lrange *ai_range_type; /* default A/D rangelist */ + const struct comedi_lrange *ao_range_type; /* default D/A rangelist */ + unsigned int io_range; /* len of IO space */ + unsigned int IRQbits; /* allowed interrupts */ + unsigned int DMAbits; /* allowed DMA chans */ + int ai_maxdata; /* maxdata for A/D */ + int ao_maxdata; /* maxdata for D/A */ + unsigned char fifo; /* 1=board has FIFO */ int is_818; }; @@ -302,67 +302,67 @@ static const struct pcl818_board boardtypes[] = { #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board)) static struct comedi_driver driver_pcl818 = { - driver_name:"pcl818", - module:THIS_MODULE, - attach:pcl818_attach, - detach:pcl818_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcl818_board), + .driver_name = "pcl818", + .module = THIS_MODULE, + .attach = pcl818_attach, + .detach = pcl818_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcl818_board), }; COMEDI_INITCLEANUP(driver_pcl818); struct pcl818_private { - unsigned int dma; // used DMA, 0=don't use DMA - int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc + unsigned int dma; /* used DMA, 0=don't use DMA */ + int dma_rtc; /* 1=RTC used with DMA, 0=no RTC alloc */ unsigned int io_range; #ifdef unused - unsigned long rtc_iobase; // RTC port region + unsigned long rtc_iobase; /* RTC port region */ unsigned int rtc_iosize; unsigned int rtc_irq; - struct timer_list rtc_irq_timer; // timer for RTC sanity check - unsigned long rtc_freq; // RTC int freq - int rtc_irq_blocked; // 1=we now do AI with DMA&RTC + struct timer_list rtc_irq_timer; /* timer for RTC sanity check */ + unsigned long rtc_freq; /* RTC int freq */ + int rtc_irq_blocked; /* 1=we now do AI with DMA&RTC */ #endif - unsigned long dmabuf[2]; // pointers to begin of DMA buffers - unsigned int dmapages[2]; // len of DMA buffers in PAGE_SIZEs - unsigned int hwdmaptr[2]; // hardware address of DMA buffers - unsigned int hwdmasize[2]; // len of DMA buffers in Bytes - unsigned int dmasamplsize; // size in samples hwdmasize[0]/2 - unsigned int last_top_dma; // DMA pointer in last RTC int - int next_dma_buf; // which DMA buffer will be used next round - long dma_runs_to_end; // how many we must permorm DMA transfer to end of record - unsigned long last_dma_run; // how many bytes we must transfer on last DMA page - unsigned char neverending_ai; // if=1, then we do neverending record (you must use cancel()) - unsigned int ns_min; // manimal alllowed delay between samples (in us) for actual card - int i8253_osc_base; // 1/frequency of on board oscilator in ns - int irq_free; // 1=have allocated IRQ - int irq_blocked; // 1=IRQ now uses any subdev - int irq_was_now_closed; // when IRQ finish, there's stored int818_mode for last interrupt - int ai_mode; // who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma - struct comedi_subdevice *last_int_sub; // ptr to subdevice which now finish - int ai_act_scan; // how many scans we finished - int ai_act_chan; // actual position in actual scan - unsigned int act_chanlist[16]; // MUX setting for actual AI operations - unsigned int act_chanlist_len; // how long is actual MUX list - unsigned int act_chanlist_pos; // actual position in MUX list - unsigned int ai_scans; // len of scanlist - unsigned int ai_n_chan; // how many channels is measured - unsigned int *ai_chanlist; // actaul chanlist - unsigned int ai_flags; // flaglist - unsigned int ai_data_len; // len of data buffer - short *ai_data; // data buffer - unsigned int ai_timer1; // timers + unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */ + unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */ + unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */ + unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */ + unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */ + unsigned int last_top_dma; /* DMA pointer in last RTC int */ + int next_dma_buf; /* which DMA buffer will be used next round */ + long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ + unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ + unsigned char neverending_ai; /* if=1, then we do neverending record (you must use cancel()) */ + unsigned int ns_min; /* manimal alllowed delay between samples (in us) for actual card */ + int i8253_osc_base; /* 1/frequency of on board oscilator in ns */ + int irq_free; /* 1=have allocated IRQ */ + int irq_blocked; /* 1=IRQ now uses any subdev */ + int irq_was_now_closed; /* when IRQ finish, there's stored int818_mode for last interrupt */ + int ai_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ + struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */ + int ai_act_scan; /* how many scans we finished */ + int ai_act_chan; /* actual position in actual scan */ + unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */ + unsigned int act_chanlist_len; /* how long is actual MUX list */ + unsigned int act_chanlist_pos; /* actual position in MUX list */ + unsigned int ai_scans; /* len of scanlist */ + unsigned int ai_n_chan; /* how many channels is measured */ + unsigned int *ai_chanlist; /* actaul chanlist */ + unsigned int ai_flags; /* flaglist */ + unsigned int ai_data_len; /* len of data buffer */ + short *ai_data; /* data buffer */ + unsigned int ai_timer1; /* timers */ unsigned int ai_timer2; - struct comedi_subdevice *sub_ai; // ptr to AI subdevice - unsigned char usefifo; // 1=use fifo + struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */ + unsigned char usefifo; /* 1=use fifo */ unsigned int ao_readback[2]; }; -static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // used for gain list programming +static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, /* used for gain list programming */ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; @@ -372,13 +372,13 @@ static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0 /* ============================================================================== */ -static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan, unsigned int seglen); -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan); -static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); #ifdef unused @@ -391,8 +391,8 @@ static int rtc_setfreq_irq(int freq); ============================================================================== ANALOG INPUT MODE0, 818 cards, slow version */ -static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int timeout; @@ -418,7 +418,7 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi while (timeout--) { if (inb(dev->iobase + PCL818_STATUS) & 0x10) goto conv_finish; - comedi_udelay(1); + udelay(1); } comedi_error(dev, "A/D insn timeout"); /* clear INT (conversion end) flag */ @@ -438,8 +438,8 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi ANALOG OUTPUT MODE0, 818 cards only one sample per call is supported */ -static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl818_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -451,8 +451,8 @@ static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return n; } -static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl818_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -460,9 +460,9 @@ static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdev for (n = 0; n < insn->n; n++) { devpriv->ao_readback[chan] = data[n]; outb((data[n] & 0x000f) << 4, dev->iobase + - (chan) ? PCL718_DA2_LO : PCL818_DA_LO); + (chan ? PCL718_DA2_LO : PCL818_DA_LO)); outb((data[n] & 0x0ff0) >> 4, dev->iobase + - (chan) ? PCL718_DA2_HI : PCL818_DA_HI); + (chan ? PCL718_DA2_HI : PCL818_DA_HI)); } return n; @@ -474,8 +474,8 @@ static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdev only one sample per call is supported */ -static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl818_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -492,8 +492,8 @@ static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi only one sample per call is supported */ -static int pcl818_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl818_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -524,7 +524,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) while (timeout--) { if (inb(dev->iobase + PCL818_STATUS) & 0x10) goto conv_finish; - comedi_udelay(1); + udelay(1); } outb(0, dev->iobase + PCL818_STATUS); /* clear INT request */ comedi_error(dev, "A/D mode1/3 IRQ without DRDY!"); @@ -535,11 +535,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) conv_finish: low = inb(dev->iobase + PCL818_AD_LO); - comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); // get one sample + comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); /* get one sample */ outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ - if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout! - rt_printk + if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */ + printk ("comedi: A/D mode1/3 IRQ - channel dropout %x!=%x !\n", (low & 0xf), devpriv->act_chanlist[devpriv->act_chanlist_pos]); @@ -549,7 +549,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) return IRQ_HANDLED; } if (s->async->cur_chan == 0) { - // rt_printk("E"); + /* printk("E"); */ devpriv->ai_act_scan--; } @@ -577,7 +577,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) disable_dma(devpriv->dma); devpriv->next_dma_buf = 1 - devpriv->next_dma_buf; - if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { // switch dma bufs + if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { /* switch dma bufs */ set_dma_mode(devpriv->dma, DMA_MODE_READ); flags = claim_dma_lock(); set_dma_addr(devpriv->dma, @@ -591,7 +591,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) release_dma_lock(flags); enable_dma(devpriv->dma); } - rt_printk("comedi: A/D mode1/3 IRQ \n"); + printk("comedi: A/D mode1/3 IRQ \n"); devpriv->dma_runs_to_end--; outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ @@ -601,8 +601,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) bufptr = 0; for (i = 0; i < len; i++) { - if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout! - rt_printk + if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */ + printk ("comedi: A/D mode1/3 DMA - channel dropout %d(card)!=%d(chanlist) at %d !\n", (ptr[bufptr] & 0xf), devpriv->act_chanlist[devpriv-> @@ -614,7 +614,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) return IRQ_HANDLED; } - comedi_buf_put(s->async, ptr[bufptr++] >> 4); // get one sample + comedi_buf_put(s->async, ptr[bufptr++] >> 4); /* get one sample */ devpriv->act_chanlist_pos++; if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) { @@ -627,7 +627,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) pcl818_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); - // printk("done int ai13 dma\n"); + /* printk("done int ai13 dma\n"); */ return IRQ_HANDLED; } } @@ -651,7 +651,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d) long ofs_dats; short *dmabuf = (short *) devpriv->dmabuf[0]; - //outb(2,0x378); + /* outb(2,0x378); */ switch (devpriv->ai_mode) { case INT_TYPE_AI1_DMA_RTC: case INT_TYPE_AI3_DMA_RTC: @@ -668,32 +668,32 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d) if (top1 != top2) return IRQ_HANDLED; - top1 = devpriv->hwdmasize[0] - top1; // where is now DMA in buffer + top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */ top1 >>= 1; - ofs_dats = top1 - devpriv->last_top_dma; // new samples from last call + ofs_dats = top1 - devpriv->last_top_dma; /* new samples from last call */ if (ofs_dats < 0) ofs_dats = (devpriv->dmasamplsize) + ofs_dats; if (!ofs_dats) - return IRQ_HANDLED; // exit=no new samples from last call - // obsluz data + return IRQ_HANDLED; /* exit=no new samples from last call */ + /* obsluz data */ i = devpriv->last_top_dma - 1; i &= (devpriv->dmasamplsize - 1); - if (dmabuf[i] != MAGIC_DMA_WORD) { // DMA overflow! + if (dmabuf[i] != MAGIC_DMA_WORD) { /* DMA overflow! */ comedi_error(dev, "A/D mode1/3 DMA buffer overflow!"); - //rt_printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize); + /* printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize); */ pcl818_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; } - //rt_printk("r %ld ",ofs_dats); + /* printk("r %ld ",ofs_dats); */ bufptr = devpriv->last_top_dma; for (i = 0; i < ofs_dats; i++) { - if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout! - rt_printk + if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */ + printk ("comedi: A/D mode1/3 DMA - channel dropout %d!=%d !\n", (dmabuf[bufptr] & 0xf), devpriv->act_chanlist[devpriv-> @@ -705,7 +705,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d) return IRQ_HANDLED; } - comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); // get one sample + comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); /* get one sample */ bufptr &= (devpriv->dmasamplsize - 1); if (s->async->cur_chan == 0) { @@ -717,7 +717,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d) pcl818_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); - //printk("done int ai13 dma\n"); + /* printk("done int ai13 dma\n"); */ return IRQ_HANDLED; } } @@ -727,11 +727,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d) bufptr &= (devpriv->dmasamplsize - 1); dmabuf[bufptr] = MAGIC_DMA_WORD; comedi_event(dev, s); - //outb(0,0x378); + /* outb(0,0x378); */ return IRQ_HANDLED; } - //outb(0,0x378); + /* outb(0,0x378); */ return IRQ_HANDLED; } #endif @@ -746,7 +746,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) struct comedi_subdevice *s = dev->subdevices + 0; int i, len, lo; - outb(0, dev->iobase + PCL818_FI_INTCLR); // clear fifo int request + outb(0, dev->iobase + PCL818_FI_INTCLR); /* clear fifo int request */ lo = inb(dev->iobase + PCL818_FI_STATUS); @@ -774,8 +774,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) for (i = 0; i < len; i++) { lo = inb(dev->iobase + PCL818_FI_DATALO); - if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout! - rt_printk + if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */ + printk ("comedi: A/D mode1/3 FIFO - channel dropout %d!=%d !\n", (lo & 0xf), devpriv->act_chanlist[devpriv-> @@ -786,7 +786,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) return IRQ_HANDLED; } - comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); // get one sample + comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); /* get one sample */ if (s->async->cur_chan == 0) { devpriv->ai_act_scan--; @@ -810,7 +810,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) ============================================================================== INT procedure */ -static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pcl818(int irq, void *d) { struct comedi_device *dev = d; @@ -818,7 +818,28 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG) comedi_error(dev, "premature interrupt"); return IRQ_HANDLED; } - //rt_printk("I\n"); + /* printk("I\n"); */ + + if (devpriv->irq_blocked && devpriv->irq_was_now_closed) { + if ((devpriv->neverending_ai || (!devpriv->neverending_ai && + devpriv->ai_act_scan > 0)) && + (devpriv->ai_mode == INT_TYPE_AI1_DMA || + devpriv->ai_mode == INT_TYPE_AI3_DMA)) { + /* The cleanup from ai_cancel() has been delayed + until now because the card doesn't seem to like + being reprogrammed while a DMA transfer is in + progress. + */ + struct comedi_subdevice *s = dev->subdevices + 0; + devpriv->ai_act_scan = 0; + devpriv->neverending_ai = 0; + pcl818_ai_cancel(dev, s); + } + + outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ + + return IRQ_HANDLED; + } switch (devpriv->ai_mode) { case INT_TYPE_AI1_DMA: @@ -843,25 +864,6 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG) if ((!dev->irq) || (!devpriv->irq_free) || (!devpriv->irq_blocked) || (!devpriv->ai_mode)) { - if (devpriv->irq_was_now_closed) { - if (devpriv->neverending_ai && - (devpriv->ai_mode == INT_TYPE_AI1_DMA - || devpriv->ai_mode == - INT_TYPE_AI3_DMA)) { - /* we had neverending ai but ai_cancel() has been called - the cleanup from ai_cancel() has been delayed until know - because the card doesn't seem to like being reprogrammed - while a DMA transfer is in progress - */ - struct comedi_subdevice *s = dev->subdevices + 0; - devpriv->ai_mode = devpriv->irq_was_now_closed; - devpriv->irq_was_now_closed = 0; - devpriv->neverending_ai = 0; - pcl818_ai_cancel(dev, s); - } - devpriv->irq_was_now_closed = 0; - return IRQ_HANDLED; - } comedi_error(dev, "bad IRQ!"); return IRQ_NONE; } @@ -874,19 +876,19 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG) ============================================================================== ANALOG INPUT MODE 1 or 3 DMA , 818 cards */ -static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev, - struct comedi_subdevice * s) +static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned int flags; unsigned int bytes; - rt_printk("mode13dma_int, mode: %d\n", mode); - disable_dma(devpriv->dma); // disable dma + printk("mode13dma_int, mode: %d\n", mode); + disable_dma(devpriv->dma); /* disable dma */ bytes = devpriv->hwdmasize[0]; if (!devpriv->neverending_ai) { - bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); // how many - devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; // how many DMA pages we must fiil - devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; //on last dma transfer must be moved + bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many */ + devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */ + devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ devpriv->dma_runs_to_end--; if (devpriv->dma_runs_to_end >= 0) bytes = devpriv->hwdmasize[0]; @@ -915,8 +917,8 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev, ============================================================================== ANALOG INPUT MODE 1 or 3 DMA rtc, 818 cards */ -static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev, - struct comedi_subdevice * s) +static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned int flags; short *pole; @@ -928,7 +930,7 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev, set_dma_count(devpriv->dma, devpriv->hwdmasize[0]); release_dma_lock(flags); enable_dma(devpriv->dma); - devpriv->last_top_dma = 0; //devpriv->hwdmasize[0]; + devpriv->last_top_dma = 0; /* devpriv->hwdmasize[0]; */ pole = (short *) devpriv->dmabuf[0]; devpriv->dmasamplsize = devpriv->hwdmasize[0] / 2; pole[devpriv->dmasamplsize - 1] = MAGIC_DMA_WORD; @@ -956,14 +958,14 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev, ============================================================================== ANALOG INPUT MODE 1 or 3, 818 cards */ -static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, - struct comedi_subdevice * s) +static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int divisor1, divisor2; unsigned int seglen; - rt_printk("pcl818_ai_cmd_mode()\n"); + printk("pcl818_ai_cmd_mode()\n"); if ((!dev->irq) && (!devpriv->dma_rtc)) { comedi_error(dev, "IRQ not defined!"); return -EINVAL; @@ -972,7 +974,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, if (devpriv->irq_blocked) return -EBUSY; - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ seglen = check_channel_list(dev, s, devpriv->ai_chanlist, devpriv->ai_n_chan); @@ -981,7 +983,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, setup_channel_list(dev, s, devpriv->ai_chanlist, devpriv->ai_n_chan, seglen); - comedi_udelay(1); + udelay(1); devpriv->ai_act_scan = devpriv->ai_scans; devpriv->ai_act_chan = 0; @@ -992,7 +994,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, devpriv->dma_runs_to_end = 0; if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) - devpriv->neverending_ai = 1; //well, user want neverending + devpriv->neverending_ai = 1; /* well, user want neverending */ if (mode == 1) { i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1, @@ -1010,7 +1012,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, outb(0, dev->iobase + PCL818_CNTENABLE); /* enable pacer */ switch (devpriv->dma) { - case 1: // DMA + case 1: /* DMA */ case 3: if (devpriv->dma_rtc == 0) { pcl818_ai_mode13dma_int(mode, dev, s); @@ -1025,26 +1027,32 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, } #endif break; - case 0: // IRQ - // rt_printk("IRQ\n"); - if (mode == 1) { - devpriv->ai_mode = INT_TYPE_AI1_INT; - outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Pacer+IRQ */ - } else { - devpriv->ai_mode = INT_TYPE_AI3_INT; - outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Ext trig+IRQ */ - }; - break; - case -1: // FIFO - outb(1, dev->iobase + PCL818_FI_ENABLE); // enable FIFO - if (mode == 1) { - devpriv->ai_mode = INT_TYPE_AI1_FIFO; - outb(0x03, dev->iobase + PCL818_CONTROL); /* Pacer */ + case 0: + if (!devpriv->usefifo) { + /* IRQ */ + /* printk("IRQ\n"); */ + if (mode == 1) { + devpriv->ai_mode = INT_TYPE_AI1_INT; + /* Pacer+IRQ */ + outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); + } else { + devpriv->ai_mode = INT_TYPE_AI3_INT; + /* Ext trig+IRQ */ + outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); + } } else { - devpriv->ai_mode = INT_TYPE_AI3_FIFO; - outb(0x02, dev->iobase + PCL818_CONTROL); - }; /* Ext trig */ - break; + /* FIFO */ + /* enable FIFO */ + outb(1, dev->iobase + PCL818_FI_ENABLE); + if (mode == 1) { + devpriv->ai_mode = INT_TYPE_AI1_FIFO; + /* Pacer */ + outb(0x03, dev->iobase + PCL818_CONTROL); + } else { + devpriv->ai_mode = INT_TYPE_AI3_FIFO; + outb(0x02, dev->iobase + PCL818_CONTROL); + } + } } start_pacer(dev, mode, divisor1, divisor2); @@ -1057,7 +1065,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, break; } #endif - rt_printk("pcl818_ai_cmd_mode() end\n"); + printk("pcl818_ai_cmd_mode() end\n"); return 0; } @@ -1067,8 +1075,8 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev, ANALOG OUTPUT MODE 1 or 3, 818 cards */ #ifdef PCL818_MODE13_AO -static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_subdevice * s, - comedi_trig * it) +static int pcl818_ao_mode13(int mode, struct comedi_device *dev, struct comedi_subdevice *s, + comedi_trig *it) { int divisor1, divisor2; @@ -1080,7 +1088,7 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_ if (devpriv->irq_blocked) return -EBUSY; - start_pacer(dev, -1, 0, 0); // stop pacer + start_pacer(dev, -1, 0, 0); /* stop pacer */ devpriv->int13_act_scan = it->n; devpriv->int13_act_chan = 0; @@ -1120,8 +1128,8 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_ ============================================================================== ANALOG OUTPUT MODE 1, 818 cards */ -static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice * s, - comedi_trig * it) +static int pcl818_ao_mode1(struct comedi_device *dev, struct comedi_subdevice *s, + comedi_trig *it) { return pcl818_ao_mode13(1, dev, s, it); } @@ -1130,8 +1138,8 @@ static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice * ============================================================================== ANALOG OUTPUT MODE 3, 818 cards */ -static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice * s, - comedi_trig * it) +static int pcl818_ao_mode3(struct comedi_device *dev, struct comedi_subdevice *s, + comedi_trig *it) { return pcl818_ao_mode13(3, dev, s, it); } @@ -1142,12 +1150,12 @@ static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice * ============================================================================== Start/stop pacer onboard pacer */ -static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1, +static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { outb(0xb4, dev->iobase + PCL818_CTRCTL); outb(0x74, dev->iobase + PCL818_CTRCTL); - comedi_udelay(1); + udelay(1); if (mode == 1) { outb(divisor2 & 0xff, dev->iobase + PCL818_CTR2); @@ -1162,7 +1170,7 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis Check if channel list from user is builded correctly If it's ok, then program scan/gain logic */ -static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan) { unsigned int chansegment[16]; @@ -1175,32 +1183,36 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic } if (n_chan > 1) { - // first channel is everytime ok + /* first channel is everytime ok */ chansegment[0] = chanlist[0]; - // build part of chanlist + /* build part of chanlist */ for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { - // rt_printk("%d. %d %d\n",i,CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i])); - // we detect loop, this must by finish + + /* printk("%d. %d * %d\n",i, + * CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));*/ + + /* we detect loop, this must by finish */ + if (chanlist[0] == chanlist[i]) break; nowmustbechan = (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan; - if (nowmustbechan != CR_CHAN(chanlist[i])) { // channel list isn't continous :-( - rt_printk + if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */ + printk ("comedi%d: pcl818: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", dev->minor, i, CR_CHAN(chanlist[i]), nowmustbechan, CR_CHAN(chanlist[0])); return 0; } - // well, this is next correct channel in list + /* well, this is next correct channel in list */ chansegment[i] = chanlist[i]; } - // check whole chanlist + /* check whole chanlist */ for (i = 0, segpos = 0; i < n_chan; i++) { - //rt_printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i])); + /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i])); */ if (chanlist[i] != chansegment[i % seglen]) { - rt_printk + printk ("comedi%d: pcl818: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", dev->minor, i, CR_CHAN(chansegment[i]), CR_RANGE(chansegment[i]), @@ -1208,17 +1220,17 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic CR_CHAN(chanlist[i % seglen]), CR_RANGE(chanlist[i % seglen]), CR_AREF(chansegment[i % seglen])); - return 0; // chan/gain list is strange + return 0; /* chan/gain list is strange */ } } } else { seglen = 1; } - rt_printk("check_channel_list: seglen %d\n", seglen); + printk("check_channel_list: seglen %d\n", seglen); return seglen; } -static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s, +static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan, unsigned int seglen) { int i; @@ -1226,13 +1238,13 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi devpriv->act_chanlist_len = seglen; devpriv->act_chanlist_pos = 0; - for (i = 0; i < seglen; i++) { // store range list to card + for (i = 0; i < seglen; i++) { /* store range list to card */ devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]); outb(muxonechan[CR_CHAN(chanlist[i])], dev->iobase + PCL818_MUX); /* select channel */ outb(CR_RANGE(chanlist[i]), dev->iobase + PCL818_RANGE); /* select gain */ } - comedi_udelay(1); + udelay(1); /* select channel interval to scan */ outb(devpriv->act_chanlist[0] | (devpriv->act_chanlist[seglen - @@ -1255,8 +1267,8 @@ static int check_single_ended(unsigned int port) /* ============================================================================== */ -static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; @@ -1391,7 +1403,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, if (cmd->chanlist) { if (!check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len)) - return 5; // incorrect channels list + return 5; /* incorrect channels list */ } return 0; @@ -1400,12 +1412,12 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, /* ============================================================================== */ -static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; int retval; - rt_printk("pcl818_ai_cmd()\n"); + printk("pcl818_ai_cmd()\n"); devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_flags = cmd->flags; @@ -1420,14 +1432,14 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) devpriv->ai_scans = 0; } - if (cmd->scan_begin_src == TRIG_FOLLOW) { // mode 1, 3 - if (cmd->convert_src == TRIG_TIMER) { // mode 1 + if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 3 */ + if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */ devpriv->ai_timer1 = cmd->convert_arg; retval = pcl818_ai_cmd_mode(1, dev, s); - rt_printk("pcl818_ai_cmd() end\n"); + printk("pcl818_ai_cmd() end\n"); return retval; } - if (cmd->convert_src == TRIG_EXT) { // mode 3 + if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ return pcl818_ai_cmd_mode(3, dev, s); } } @@ -1439,23 +1451,24 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) ============================================================================== cancel any mode 1-4 AI */ -static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { if (devpriv->irq_blocked > 0) { - rt_printk("pcl818_ai_cancel()\n"); - devpriv->irq_was_now_closed = devpriv->ai_mode; - devpriv->ai_mode = 0; + printk("pcl818_ai_cancel()\n"); + devpriv->irq_was_now_closed = 1; - switch (devpriv->irq_was_now_closed) { + switch (devpriv->ai_mode) { #ifdef unused case INT_TYPE_AI1_DMA_RTC: case INT_TYPE_AI3_DMA_RTC: - set_rtc_irq_bit(0); // stop RTC + set_rtc_irq_bit(0); /* stop RTC */ del_timer(&devpriv->rtc_irq_timer); #endif case INT_TYPE_AI1_DMA: case INT_TYPE_AI3_DMA: - if (devpriv->neverending_ai) { + if (devpriv->neverending_ai || + (!devpriv->neverending_ai && + devpriv->ai_act_scan > 0)) { /* wait for running dma transfer to end, do cleanup in interrupt */ goto end; } @@ -1469,14 +1482,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice case INT_TYPE_AO3_INT: #endif outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */ - comedi_udelay(1); + udelay(1); start_pacer(dev, -1, 0, 0); outb(0, dev->iobase + PCL818_AD_LO); inb(dev->iobase + PCL818_AD_LO); inb(dev->iobase + PCL818_AD_HI); outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ outb(0, dev->iobase + PCL818_CONTROL); /* Stop A/D */ - if (devpriv->usefifo) { // FIFO shutdown + if (devpriv->usefifo) { /* FIFO shutdown */ outb(0, dev->iobase + PCL818_FI_INTCLR); outb(0, dev->iobase + PCL818_FI_FLUSH); outb(0, dev->iobase + PCL818_FI_ENABLE); @@ -1484,12 +1497,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice devpriv->irq_blocked = 0; devpriv->last_int_sub = s; devpriv->neverending_ai = 0; + devpriv->ai_mode = 0; + devpriv->irq_was_now_closed = 0; break; } } end: - rt_printk("pcl818_ai_cancel() end\n"); + printk("pcl818_ai_cancel() end\n"); return 0; } @@ -1500,39 +1515,39 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice static int pcl818_check(unsigned long iobase) { outb(0x00, iobase + PCL818_MUX); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL818_MUX) != 0x00) - return 1; //there isn't card + return 1; /* there isn't card */ outb(0x55, iobase + PCL818_MUX); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL818_MUX) != 0x55) - return 1; //there isn't card + return 1; /* there isn't card */ outb(0x00, iobase + PCL818_MUX); - comedi_udelay(1); + udelay(1); outb(0x18, iobase + PCL818_CONTROL); - comedi_udelay(1); + udelay(1); if (inb(iobase + PCL818_CONTROL) != 0x18) - return 1; //there isn't card - return 0; // ok, card exist + return 1; /* there isn't card */ + return 0; /* ok, card exist */ } /* ============================================================================== reset whole PCL-818 cards */ -static void pcl818_reset(struct comedi_device * dev) +static void pcl818_reset(struct comedi_device *dev) { - if (devpriv->usefifo) { // FIFO shutdown + if (devpriv->usefifo) { /* FIFO shutdown */ outb(0, dev->iobase + PCL818_FI_INTCLR); outb(0, dev->iobase + PCL818_FI_FLUSH); outb(0, dev->iobase + PCL818_FI_ENABLE); } - outb(0, dev->iobase + PCL818_DA_LO); // DAC=0V + outb(0, dev->iobase + PCL818_DA_LO); /* DAC=0V */ outb(0, dev->iobase + PCL818_DA_HI); - comedi_udelay(1); - outb(0, dev->iobase + PCL818_DO_HI); // DO=$0000 + udelay(1); + outb(0, dev->iobase + PCL818_DO_HI); /* DO=$0000 */ outb(0, dev->iobase + PCL818_DO_LO); - comedi_udelay(1); + udelay(1); outb(0, dev->iobase + PCL818_CONTROL); outb(0, dev->iobase + PCL818_CNTENABLE); outb(0, dev->iobase + PCL818_MUX); @@ -1641,9 +1656,9 @@ static int rtc_setfreq_irq(int freq) ============================================================================== Free any resources that we have claimed */ -static void free_resources(struct comedi_device * dev) +static void free_resources(struct comedi_device *dev) { - //rt_printk("free_resource()\n"); + /* printk("free_resource()\n"); */ if (dev->private) { pcl818_ai_cancel(dev, devpriv->sub_ai); pcl818_reset(dev); @@ -1655,7 +1670,7 @@ static void free_resources(struct comedi_device * dev) free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]); #ifdef unused if (devpriv->rtc_irq) - comedi_free_irq(devpriv->rtc_irq, dev); + free_irq(devpriv->rtc_irq, dev); if ((devpriv->dma_rtc) && (RTC_lock == 1)) { if (devpriv->rtc_iobase) release_region(devpriv->rtc_iobase, @@ -1670,7 +1685,7 @@ static void free_resources(struct comedi_device * dev) free_irq(dev->irq, dev); if (dev->iobase) release_region(dev->iobase, devpriv->io_range); - //rt_printk("free_resource() end\n"); + /* printk("free_resource() end\n"); */ } /* @@ -1679,15 +1694,17 @@ static void free_resources(struct comedi_device * dev) Initialization */ -static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; unsigned long iobase; - unsigned int irq, dma; + unsigned int irq; + int dma; unsigned long pages; struct comedi_subdevice *s; - if ((ret = alloc_private(dev, sizeof(struct pcl818_private))) < 0) + ret = alloc_private(dev, sizeof(struct pcl818_private)); + if (ret < 0) return ret; /* Can't alloc mem */ /* claim our I/O space */ @@ -1695,19 +1712,19 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i printk("comedi%d: pcl818: board=%s, ioport=0x%03lx", dev->minor, this_board->name, iobase); devpriv->io_range = this_board->io_range; - if ((this_board->fifo) && (it->options[2] == -1)) { // we've board with FIFO and we want to use FIFO + if ((this_board->fifo) && (it->options[2] == -1)) { /* we've board with FIFO and we want to use FIFO */ devpriv->io_range = PCLx1xFIFO_RANGE; devpriv->usefifo = 1; } if (!request_region(iobase, devpriv->io_range, "pcl818")) { - rt_printk("I/O port conflict\n"); + printk("I/O port conflict\n"); return -EIO; } dev->iobase = iobase; if (pcl818_check(iobase)) { - rt_printk(", I can't detect board. FAIL!\n"); + printk(", I can't detect board. FAIL!\n"); return -EIO; } @@ -1719,19 +1736,18 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i irq = it->options[1]; if (irq) { /* we want to use IRQ */ if (((1 << irq) & this_board->IRQbits) == 0) { - rt_printk + printk (", IRQ %u is out of allowed range, DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { - if (comedi_request_irq(irq, interrupt_pcl818, 0, - "pcl818", dev)) { - rt_printk + if (request_irq(irq, interrupt_pcl818, 0, "pcl818", dev)) { + printk (", unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - rt_printk(", irq=%u", irq); + printk(", irq=%u", irq); } } } @@ -1750,7 +1766,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i #ifdef unused /* grab RTC for DMA operations */ devpriv->dma_rtc = 0; - if (it->options[2] > 0) { // we want to use DMA + if (it->options[2] > 0) { /* we want to use DMA */ if (RTC_lock == 0) { if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "pcl818 (RTC)")) @@ -1759,12 +1775,11 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->rtc_iobase = RTC_PORT(0); devpriv->rtc_iosize = RTC_IO_EXTENT; RTC_lock++; - if (!comedi_request_irq(RTC_IRQ, - interrupt_pcl818_ai_mode13_dma_rtc, 0, + if (!request_irq(RTC_IRQ, interrupt_pcl818_ai_mode13_dma_rtc, 0, "pcl818 DMA (RTC)", dev)) { devpriv->dma_rtc = 1; devpriv->rtc_irq = RTC_IRQ; - rt_printk(", dma_irq=%u", devpriv->rtc_irq); + printk(", dma_irq=%u", devpriv->rtc_irq); } else { RTC_lock--; if (RTC_lock == 0) { @@ -1789,31 +1804,31 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i if (dma < 1) goto no_dma; /* DMA disabled */ if (((1 << dma) & this_board->DMAbits) == 0) { - rt_printk(", DMA is out of allowed range, FAIL!\n"); + printk(", DMA is out of allowed range, FAIL!\n"); return -EINVAL; /* Bad DMA */ } ret = request_dma(dma, "pcl818"); if (ret) { - rt_printk(", unable to allocate DMA %u, FAIL!\n", dma); + printk(", unable to allocate DMA %u, FAIL!\n", dma); return -EBUSY; /* DMA isn't free */ } devpriv->dma = dma; - rt_printk(", dma=%u", dma); + printk(", dma=%u", dma); pages = 2; /* we need 16KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) { - rt_printk(", unable to allocate DMA buffer, FAIL!\n"); + printk(", unable to allocate DMA buffer, FAIL!\n"); /* maybe experiment with try_to_free_pages() will help .... */ return -EBUSY; /* no buffer :-( */ } devpriv->dmapages[0] = pages; devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]); devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE; - //rt_printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); - if (devpriv->dma_rtc == 0) { // we must do duble buff :-( + /* printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); */ + if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */ devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[1]) { - rt_printk + printk (", unable to allocate DMA buffer, FAIL!\n"); return -EBUSY; } @@ -1826,7 +1841,8 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i no_dma: - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; s = dev->subdevices + 0; @@ -1858,7 +1874,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i } if (this_board->is_818) { if ((it->options[4] == 1) || (it->options[4] == 10)) - s->range_table = &range_pcl818l_h_ai; // secondary range list jumper selectable + s->range_table = &range_pcl818l_h_ai; /* secondary range list jumper selectable */ } else { switch (it->options[4]) { case 0: @@ -1971,7 +1987,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i pcl818_reset(dev); - rt_printk("\n"); + printk("\n"); return 0; } @@ -1980,9 +1996,9 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i ============================================================================== Removes device */ -static int pcl818_detach(struct comedi_device * dev) +static int pcl818_detach(struct comedi_device *dev) { - // rt_printk("comedi%d: pcl818: remove\n", dev->minor); + /* printk("comedi%d: pcl818: remove\n", dev->minor); */ free_resources(dev); return 0; } diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index a3ed3a0e855a..a5d6b1d9a1aa 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -62,18 +62,18 @@ Copy/pasted/hacked from pcm724.c #define CR_A_MODE(a) ((a)<<5) #define CR_CW 0x80 -static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcm3724_detach(struct comedi_device * dev); +static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcm3724_detach(struct comedi_device *dev); struct pcm3724_board { - const char *name; // driver name - int dio; // num of DIO - int numofports; // num of 8255 subdevices - unsigned int IRQbits; // allowed interrupts - unsigned int io_range; // len of IO space + const char *name; /* driver name */ + int dio; /* num of DIO */ + int numofports; /* num of 8255 subdevices */ + unsigned int IRQbits; /* allowed interrupts */ + unsigned int io_range; /* len of IO space */ }; -//used to track configured dios +/* used to track configured dios */ struct priv_pcm3724 { int dio_1; int dio_2; @@ -87,36 +87,36 @@ static const struct pcm3724_board boardtypes[] = { #define this_board ((const struct pcm3724_board *)dev->board_ptr) static struct comedi_driver driver_pcm3724 = { - driver_name:"pcm3724", - module:THIS_MODULE, - attach:pcm3724_attach, - detach:pcm3724_detach, - board_name:&boardtypes[0].name, - num_names:n_boardtypes, - offset:sizeof(struct pcm3724_board), + .driver_name = "pcm3724", + .module = THIS_MODULE, + .attach = pcm3724_attach, + .detach = pcm3724_detach, + .board_name = &boardtypes[0].name, + .num_names = n_boardtypes, + .offset = sizeof(struct pcm3724_board), }; COMEDI_INITCLEANUP(driver_pcm3724); -// (setq c-basic-offset 8) +/* (setq c-basic-offset 8) */ static int subdev_8255_cb(int dir, int port, int data, unsigned long arg) { unsigned long iobase = arg; unsigned char inbres; - //printk("8255cb %d %d %d %lx\n", dir,port,data,arg); + /* printk("8255cb %d %d %d %lx\n", dir,port,data,arg); */ if (dir) { - //printk("8255 cb outb(%x, %lx)\n", data, iobase+port); + /* printk("8255 cb outb(%x, %lx)\n", data, iobase+port); */ outb(data, iobase + port); return 0; } else { inbres = inb(iobase + port); - //printk("8255 cb inb(%lx) = %x\n", iobase+port, inbres); + /* printk("8255 cb inb(%lx) = %x\n", iobase+port, inbres); */ return inbres; } } -static int compute_buffer(int config, int devno, struct comedi_subdevice * s) +static int compute_buffer(int config, int devno, struct comedi_subdevice *s) { /* 1 in io_bits indicates output */ if (s->io_bits & 0x0000ff) { @@ -143,7 +143,7 @@ static int compute_buffer(int config, int devno, struct comedi_subdevice * s) return config; } -static void do_3724_config(struct comedi_device * dev, struct comedi_subdevice * s, +static void do_3724_config(struct comedi_device *dev, struct comedi_subdevice *s, int chanspec) { int config; @@ -173,11 +173,11 @@ static void do_3724_config(struct comedi_device * dev, struct comedi_subdevice * port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR; } outb(buffer_config, dev->iobase + 8); /* update buffer register */ - //printk("pcm3724 buffer_config (%lx) %d, %x\n", dev->iobase + _8255_CR, chanspec, buffer_config); + /* printk("pcm3724 buffer_config (%lx) %d, %x\n", dev->iobase + _8255_CR, chanspec, buffer_config); */ outb(config, port_8255_cfg); } -static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s, int chanspec) +static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, int chanspec) { unsigned int mask; int gatecfg; @@ -187,9 +187,9 @@ static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s, priv = (struct priv_pcm3724 *) (dev->private); mask = 1 << CR_CHAN(chanspec); - if (s == dev->subdevices) { // subdev 0 + if (s == dev->subdevices) { /* subdev 0 */ priv->dio_1 |= mask; - } else { //subdev 1 + } else { /* subdev 1 */ priv->dio_2 |= mask; } if (priv->dio_1 & 0xff0000) { @@ -210,13 +210,13 @@ static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s, if (priv->dio_2 & 0xff) { gatecfg |= GATE_A1; } - // printk("gate control %x\n", gatecfg); + /* printk("gate control %x\n", gatecfg); */ outb(gatecfg, dev->iobase + 9); } /* overriding the 8255 insn config */ -static int subdev_3724_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; unsigned int bits; @@ -252,7 +252,7 @@ static int subdev_3724_insn_config(struct comedi_device * dev, struct comedi_sub return 1; } -static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned long iobase; unsigned int iorange; @@ -260,7 +260,9 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * iobase = it->options[0]; iorange = this_board->io_range; - if ((ret = alloc_private(dev, sizeof(struct priv_pcm3724))) < 0) + + ret = alloc_private(dev, sizeof(struct priv_pcm3724)); + if (ret < 0) return -ENOMEM; ((struct priv_pcm3724 *) (dev->private))->dio_1 = 0; @@ -279,7 +281,8 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * n_subdevices = this_board->numofports; - if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) + ret = alloc_subdevices(dev, n_subdevices); + if (ret < 0) return ret; for (i = 0; i < dev->n_subdevices; i++) { @@ -290,7 +293,7 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int pcm3724_detach(struct comedi_device * dev) +static int pcm3724_detach(struct comedi_device *dev) { int i; diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c index 1de555fe645c..ae90ea4ae3c9 100644 --- a/drivers/staging/comedi/drivers/pcm3730.c +++ b/drivers/staging/comedi/drivers/pcm3730.c @@ -19,28 +19,28 @@ Configuration options: #include <linux/ioport.h> -#define PCM3730_SIZE 4 // consecutive io port addresses +#define PCM3730_SIZE 4 /* consecutive io port addresses */ -#define PCM3730_DOA 0 // offsets for each port +#define PCM3730_DOA 0 /* offsets for each port */ #define PCM3730_DOB 2 #define PCM3730_DOC 3 #define PCM3730_DIA 0 #define PCM3730_DIB 2 #define PCM3730_DIC 3 -static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcm3730_detach(struct comedi_device * dev); +static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcm3730_detach(struct comedi_device *dev); static struct comedi_driver driver_pcm3730 = { - driver_name:"pcm3730", - module:THIS_MODULE, - attach:pcm3730_attach, - detach:pcm3730_detach, + .driver_name = "pcm3730", + .module = THIS_MODULE, + .attach = pcm3730_attach, + .detach = pcm3730_detach, }; COMEDI_INITCLEANUP(driver_pcm3730); -static int pcm3730_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcm3730_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -54,8 +54,8 @@ static int pcm3730_do_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int pcm3730_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcm3730_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -63,7 +63,7 @@ static int pcm3730_di_insn_bits(struct comedi_device * dev, struct comedi_subdev return 2; } -static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -141,7 +141,7 @@ static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int pcm3730_detach(struct comedi_device * dev) +static int pcm3730_detach(struct comedi_device *dev) { printk("comedi%d: pcm3730: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/pcm_common.c b/drivers/staging/comedi/drivers/pcm_common.c new file mode 100644 index 000000000000..ebd9838232af --- /dev/null +++ b/drivers/staging/comedi/drivers/pcm_common.c @@ -0,0 +1,111 @@ +#include "../comedidev.h" +#include "pcm_common.h" + +/* + * 'do_cmdtest' function for an 'INTERRUPT' subdevice. This is for + * the PCM drivers. + */ +int comedi_pcm_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) +{ + int err = 0; + unsigned int tmp; + + /* step 1: make sure trigger sources are trivially valid */ + + tmp = cmd->start_src; + cmd->start_src &= (TRIG_NOW | TRIG_INT); + if (!cmd->start_src || tmp != cmd->start_src) + err++; + + tmp = cmd->scan_begin_src; + cmd->scan_begin_src &= TRIG_EXT; + if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) + err++; + + tmp = cmd->convert_src; + cmd->convert_src &= TRIG_NOW; + if (!cmd->convert_src || tmp != cmd->convert_src) + err++; + + tmp = cmd->scan_end_src; + cmd->scan_end_src &= TRIG_COUNT; + if (!cmd->scan_end_src || tmp != cmd->scan_end_src) + err++; + + tmp = cmd->stop_src; + cmd->stop_src &= (TRIG_COUNT | TRIG_NONE); + if (!cmd->stop_src || tmp != cmd->stop_src) + err++; + + if (err) + return 1; + + /* step 2: make sure trigger sources are unique and mutually compatible */ + + /* these tests are true if more than one _src bit is set */ + if ((cmd->start_src & (cmd->start_src - 1)) != 0) + err++; + if ((cmd->scan_begin_src & (cmd->scan_begin_src - 1)) != 0) + err++; + if ((cmd->convert_src & (cmd->convert_src - 1)) != 0) + err++; + if ((cmd->scan_end_src & (cmd->scan_end_src - 1)) != 0) + err++; + if ((cmd->stop_src & (cmd->stop_src - 1)) != 0) + err++; + + if (err) + return 2; + + /* step 3: make sure arguments are trivially compatible */ + + /* cmd->start_src == TRIG_NOW || cmd->start_src == TRIG_INT */ + if (cmd->start_arg != 0) { + cmd->start_arg = 0; + err++; + } + + /* cmd->scan_begin_src == TRIG_EXT */ + if (cmd->scan_begin_arg != 0) { + cmd->scan_begin_arg = 0; + err++; + } + + /* cmd->convert_src == TRIG_NOW */ + if (cmd->convert_arg != 0) { + cmd->convert_arg = 0; + err++; + } + + /* cmd->scan_end_src == TRIG_COUNT */ + if (cmd->scan_end_arg != cmd->chanlist_len) { + cmd->scan_end_arg = cmd->chanlist_len; + err++; + } + + switch (cmd->stop_src) { + case TRIG_COUNT: + /* any count allowed */ + break; + case TRIG_NONE: + if (cmd->stop_arg != 0) { + cmd->stop_arg = 0; + err++; + } + break; + default: + break; + } + + if (err) + return 3; + + /* step 4: fix up any arguments */ + + /* if (err) return 4; */ + + return 0; +} + +EXPORT_SYMBOL(comedi_pcm_cmdtest); diff --git a/drivers/staging/comedi/drivers/pcm_common.h b/drivers/staging/comedi/drivers/pcm_common.h new file mode 100644 index 000000000000..cd4840c11444 --- /dev/null +++ b/drivers/staging/comedi/drivers/pcm_common.h @@ -0,0 +1,8 @@ +#ifndef _comedi_common_H +#define _comedi_common_H + +extern int comedi_pcm_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd); + +#endif diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index fc2a73d97c24..9bb26699f47e 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -41,6 +41,7 @@ Configuration options: 1 = two's complement */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -58,12 +59,12 @@ struct pcmad_board_struct { }; static const struct pcmad_board_struct pcmad_boards[] = { { - name: "pcmad12", - n_ai_bits:12, + .name = "pcmad12", + .n_ai_bits = 12, }, { - name: "pcmad16", - n_ai_bits:16, + .name = "pcmad16", + .n_ai_bits = 16, }, }; @@ -76,24 +77,24 @@ struct pcmad_priv_struct { }; #define devpriv ((struct pcmad_priv_struct *)dev->private) -static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcmad_detach(struct comedi_device * dev); +static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcmad_detach(struct comedi_device *dev); static struct comedi_driver driver_pcmad = { - driver_name:"pcmad", - module:THIS_MODULE, - attach:pcmad_attach, - detach:pcmad_detach, - board_name:&pcmad_boards[0].name, - num_names:n_pcmad_boards, - offset:sizeof(pcmad_boards[0]), + .driver_name = "pcmad", + .module = THIS_MODULE, + .attach = pcmad_attach, + .detach = pcmad_detach, + .board_name = &pcmad_boards[0].name, + .num_names = n_pcmad_boards, + .offset = sizeof(pcmad_boards[0]), }; COMEDI_INITCLEANUP(driver_pcmad); #define TIMEOUT 100 -static int pcmad_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcmad_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -126,7 +127,7 @@ static int pcmad_ai_insn_read(struct comedi_device * dev, struct comedi_subdevic * 2 0=single ended 1=differential * 3 0=straight binary 1=two's comp */ -static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; struct comedi_subdevice *s; @@ -140,9 +141,12 @@ static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it } dev->iobase = iobase; - if ((ret = alloc_subdevices(dev, 1)) < 0) + ret = alloc_subdevices(dev, 1); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct pcmad_priv_struct))) < 0) + + ret = alloc_private(dev, sizeof(struct pcmad_priv_struct)); + if (ret < 0) return ret; dev->board_name = this_board->name; @@ -159,7 +163,7 @@ static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it return 0; } -static int pcmad_detach(struct comedi_device * dev) +static int pcmad_detach(struct comedi_device *dev) { printk("comedi%d: pcmad: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 2a1ff465602a..6e172a6b1cb2 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -55,7 +55,6 @@ Configuration Options: #include <linux/pci.h> /* for PCI devices */ -#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) ) #define SDEV_NO ((int)(s - dev->subdevices)) #define CHANS 8 #define IOSIZE 16 @@ -83,7 +82,7 @@ static const struct comedi_lrange pcmda12_ranges = { static const struct pcmda12_board pcmda12_boards[] = { { - name: "pcmda12", + .name = "pcmda12", }, }; @@ -107,16 +106,16 @@ struct pcmda12_private { * the board, and also about the kernel module that contains * the device code. */ -static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcmda12_detach(struct comedi_device * dev); +static int pcmda12_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcmda12_detach(struct comedi_device *dev); -static void zero_chans(struct comedi_device * dev); +static void zero_chans(struct comedi_device *dev); static struct comedi_driver driver = { - driver_name:"pcmda12", - module:THIS_MODULE, - attach:pcmda12_attach, - detach:pcmda12_detach, + .driver_name = "pcmda12", + .module = THIS_MODULE, + .attach = pcmda12_attach, + .detach = pcmda12_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -135,15 +134,15 @@ static struct comedi_driver driver = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&pcmda12_boards[0].name, - offset:sizeof(struct pcmda12_board), - num_names:sizeof(pcmda12_boards) / sizeof(struct pcmda12_board), + .board_name = &pcmda12_boards[0].name, + .offset = sizeof(struct pcmda12_board), + .num_names = ARRAY_SIZE(pcmda12_boards), }; -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * Attach is called by the Comedi core to configure the driver @@ -151,7 +150,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, * in the driver structure, dev->board_ptr contains that * address. */ -static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcmda12_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -220,7 +219,7 @@ static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig * * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pcmda12_detach(struct comedi_device * dev) +static int pcmda12_detach(struct comedi_device *dev) { printk("comedi%d: %s: remove\n", dev->minor, driver.driver_name); if (dev->iobase) @@ -228,7 +227,7 @@ static int pcmda12_detach(struct comedi_device * dev) return 0; } -static void zero_chans(struct comedi_device * dev) +static void zero_chans(struct comedi_device *dev) { /* sets up an ASIC chip to defaults */ int i; @@ -241,8 +240,8 @@ static void zero_chans(struct comedi_device * dev) inb(LSB_PORT(0)); /* update chans. */ } -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -283,8 +282,8 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, DAC outputs, which makes all AO channels update simultaneously. This is useful for some control applications, I would imagine. */ -static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 01e40f1b5628..cdf501afa14e 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -73,11 +73,11 @@ Configuration Options: [1] - IRQ (optional -- for edge-detect interrupt support only, leave out if you don't need this feature) */ +#include <linux/interrupt.h> #include "../comedidev.h" +#include "pcm_common.h" #include <linux/pci.h> /* for PCI devices */ -#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) ) - /* This stuff is all from pcmuio.c -- it refers to the DIO subdevices only */ #define CHANS_PER_PORT 8 #define PORTS_PER_ASIC 6 @@ -179,19 +179,19 @@ static const struct comedi_lrange ranges_ao = static const struct pcmmio_board pcmmio_boards[] = { { - name: "pcmmio", - dio_num_asics:1, - dio_num_ports:6, - total_iosize:32, - ai_bits: 16, - ao_bits: 16, - n_ai_chans:16, - n_ao_chans:8, - ai_range_table:&ranges_ai, - ao_range_table:&ranges_ao, - ai_rinsn:ai_rinsn, - ao_rinsn:ao_rinsn, - ao_winsn:ao_winsn}, + .name = "pcmmio", + .dio_num_asics = 1, + .dio_num_ports = 6, + .total_iosize = 32, + .ai_bits = 16, + .ao_bits = 16, + .n_ai_chans = 16, + .n_ao_chans = 8, + .ai_range_table = &ranges_ai, + .ao_range_table = &ranges_ao, + .ai_rinsn = ai_rinsn, + .ao_rinsn = ao_rinsn, + .ao_winsn = ao_winsn}, }; /* @@ -264,14 +264,14 @@ struct pcmmio_private { * the board, and also about the kernel module that contains * the device code. */ -static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcmmio_detach(struct comedi_device * dev); +static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcmmio_detach(struct comedi_device *dev); static struct comedi_driver driver = { - driver_name:"pcmmio", - module:THIS_MODULE, - attach:pcmmio_attach, - detach:pcmmio_detach, + .driver_name = "pcmmio", + .module = THIS_MODULE, + .attach = pcmmio_attach, + .detach = pcmmio_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -290,29 +290,29 @@ static struct comedi_driver driver = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&pcmmio_boards[0].name, - offset:sizeof(struct pcmmio_board), - num_names:sizeof(pcmmio_boards) / sizeof(struct pcmmio_board), + .board_name = &pcmmio_boards[0].name, + .offset = sizeof(struct pcmmio_board), + .num_names = ARRAY_SIZE(pcmmio_boards), }; -static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG); +static irqreturn_t interrupt_pcmmio(int irq, void *d); static void pcmmio_stop_intr(struct comedi_device *, struct comedi_subdevice *); -static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int pcmmio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); +static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); /* some helper functions to deal with specifics of this device's registers */ -static void init_asics(struct comedi_device * dev); /* sets up/clears ASIC chips to defaults */ -static void switch_page(struct comedi_device * dev, int asic, int page); +static void init_asics(struct comedi_device *dev); /* sets up/clears ASIC chips to defaults */ +static void switch_page(struct comedi_device *dev, int asic, int page); #ifdef notused -static void lock_port(struct comedi_device * dev, int asic, int port); -static void unlock_port(struct comedi_device * dev, int asic, int port); +static void lock_port(struct comedi_device *dev, int asic, int port); +static void unlock_port(struct comedi_device *dev, int asic, int port); #endif /* @@ -321,7 +321,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port); * in the driver structure, dev->board_ptr contains that * address. */ -static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int sdev_no, chans_left, n_dio_subdevs, n_subdevs, port, asic, @@ -364,7 +364,7 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->iobase + 16 + asic * ASIC_IOSIZE; devpriv->asics[asic].irq = 0; /* this gets actually set at the end of this function when we - comedi_request_irqs */ + request_irqs */ spin_lock_init(&devpriv->asics[asic].spinlock); } @@ -435,7 +435,7 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i s->type = COMEDI_SUBD_DIO; s->insn_bits = pcmmio_dio_insn_bits; s->insn_config = pcmmio_dio_insn_config; - s->n_chan = MIN(chans_left, MAX_CHANS_PER_SUBDEV); + s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV); subpriv->dio.intr.asic = -1; subpriv->dio.intr.first_chan = -1; subpriv->dio.intr.asic_chan = -1; @@ -489,12 +489,12 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) { if (irq[asic] - && comedi_request_irq(irq[asic], interrupt_pcmmio, + && request_irq(irq[asic], interrupt_pcmmio, IRQF_SHARED, thisboard->name, dev)) { int i; /* unroll the allocated irqs.. */ for (i = asic - 1; i >= 0; --i) { - comedi_free_irq(irq[i], dev); + free_irq(irq[i], dev); devpriv->asics[i].irq = irq[i] = 0; } irq[asic] = 0; @@ -526,7 +526,7 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pcmmio_detach(struct comedi_device * dev) +static int pcmmio_detach(struct comedi_device *dev) { int i; @@ -536,7 +536,7 @@ static int pcmmio_detach(struct comedi_device * dev) for (i = 0; i < MAX_ASICS; ++i) { if (devpriv && devpriv->asics[i].irq) - comedi_free_irq(devpriv->asics[i].irq, dev); + free_irq(devpriv->asics[i].irq, dev); } if (devpriv && devpriv->sprivs) @@ -550,8 +550,8 @@ static int pcmmio_detach(struct comedi_device * dev) * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int byte_no; if (insn->n != 2) @@ -624,8 +624,8 @@ static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ -static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no = chan % 8; @@ -685,7 +685,7 @@ static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subd return insn->n; } -static void init_asics(struct comedi_device * dev) +static void init_asics(struct comedi_device *dev) { /* sets up an ASIC chip to defaults */ int asic; @@ -722,7 +722,7 @@ static void init_asics(struct comedi_device * dev) } } -static void switch_page(struct comedi_device * dev, int asic, int page) +static void switch_page(struct comedi_device *dev, int asic, int page) { if (asic < 0 || asic >= thisboard->dio_num_asics) return; /* paranoia */ @@ -738,7 +738,7 @@ static void switch_page(struct comedi_device * dev, int asic, int page) } #ifdef notused -static void lock_port(struct comedi_device * dev, int asic, int port) +static void lock_port(struct comedi_device *dev, int asic, int port) { if (asic < 0 || asic >= thisboard->dio_num_asics) return; /* paranoia */ @@ -752,7 +752,7 @@ static void lock_port(struct comedi_device * dev, int asic, int port) return; } -static void unlock_port(struct comedi_device * dev, int asic, int port) +static void unlock_port(struct comedi_device *dev, int asic, int port) { if (asic < 0 || asic >= thisboard->dio_num_asics) return; /* paranoia */ @@ -765,7 +765,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port) } #endif /* notused */ -static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pcmmio(int irq, void *d) { int asic, got1 = 0; struct comedi_device *dev = (struct comedi_device *) d; @@ -778,8 +778,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) /* it is an interrupt for ASIC #asic */ unsigned char int_pend; - comedi_spin_lock_irqsave(&devpriv->asics[asic].spinlock, - flags); + spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags); int_pend = inb(iobase + REG_INT_PENDING) & 0x07; @@ -811,8 +810,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) ++got1; } - comedi_spin_unlock_irqrestore(&devpriv->asics[asic]. - spinlock, flags); + spin_unlock_irqrestore(&devpriv->asics[asic]. spinlock, flags); if (triggered) { struct comedi_subdevice *s; @@ -825,9 +823,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) unsigned long flags; unsigned oldevents; - comedi_spin_lock_irqsave - (&subpriv->dio.intr. - spinlock, flags); + spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); oldevents = s->async->events; @@ -859,10 +855,10 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) } } /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, ((short *) & val)[0]) + if (comedi_buf_put(s->async, ((short *) &val)[0]) && comedi_buf_put - (s->async, ((short *) & val)[1])) { + (s->async, ((short *) &val)[1])) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Overflow! Stop acquisition!! */ @@ -896,9 +892,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) } } - comedi_spin_unlock_irqrestore - (&subpriv->dio.intr. - spinlock, flags); + spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); if (oldevents != s->async->events) { @@ -917,11 +911,12 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static void pcmmio_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static void pcmmio_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s) { int nports, firstport, asic, port; - if ((asic = subpriv->dio.intr.asic) < 0) + asic = subpriv->dio.intr.asic; + if (asic < 0) return; /* not an interrupt subdev */ subpriv->dio.intr.enabled_mask = 0; @@ -936,7 +931,7 @@ static void pcmmio_stop_intr(struct comedi_device * dev, struct comedi_subdevice } } -static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmmio_start_intr(struct comedi_device *dev, struct comedi_subdevice *s) { if (!subpriv->dio.intr.continuous && subpriv->dio.intr.stop_count == 0) { /* An empty acquisition! */ @@ -948,7 +943,8 @@ static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice int nports, firstport, asic, port; struct comedi_cmd *cmd = &s->async->cmd; - if ((asic = subpriv->dio.intr.asic) < 0) + asic = subpriv->dio.intr.asic; + if (asic < 0) return 1; /* not an interrupt subdev */ subpriv->dio.intr.enabled_mask = 0; @@ -995,14 +991,14 @@ static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); + spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); if (subpriv->dio.intr.active) pcmmio_stop_intr(dev, s); - comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); return 0; } @@ -1011,7 +1007,7 @@ static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. */ static int -pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s, +pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { unsigned long flags; @@ -1020,12 +1016,12 @@ pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * if (trignum != 0) return -EINVAL; - comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); + spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); s->async->inttrig = 0; if (subpriv->dio.intr.active) { event = pcmmio_start_intr(dev, s); } - comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); if (event) { comedi_event(dev, s); @@ -1037,13 +1033,13 @@ pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * /* * 'do_cmd' function for an 'INTERRUPT' subdevice. */ -static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; int event = 0; - comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); + spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); subpriv->dio.intr.active = 1; /* Set up end of acquisition. */ @@ -1069,7 +1065,7 @@ static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) event = pcmmio_start_intr(dev, s); break; } - comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); if (event) { comedi_event(dev, s); @@ -1078,110 +1074,10 @@ static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -/* - * 'do_cmdtest' function for an 'INTERRUPT' subdevice. - */ static int -pcmmio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd) +pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - int err = 0; - unsigned int tmp; - - /* step 1: make sure trigger sources are trivially valid */ - - tmp = cmd->start_src; - cmd->start_src &= (TRIG_NOW | TRIG_INT); - if (!cmd->start_src || tmp != cmd->start_src) - err++; - - tmp = cmd->scan_begin_src; - cmd->scan_begin_src &= TRIG_EXT; - if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) - err++; - - tmp = cmd->convert_src; - cmd->convert_src &= TRIG_NOW; - if (!cmd->convert_src || tmp != cmd->convert_src) - err++; - - tmp = cmd->scan_end_src; - cmd->scan_end_src &= TRIG_COUNT; - if (!cmd->scan_end_src || tmp != cmd->scan_end_src) - err++; - - tmp = cmd->stop_src; - cmd->stop_src &= (TRIG_COUNT | TRIG_NONE); - if (!cmd->stop_src || tmp != cmd->stop_src) - err++; - - if (err) - return 1; - - /* step 2: make sure trigger sources are unique and mutually compatible */ - - /* these tests are true if more than one _src bit is set */ - if ((cmd->start_src & (cmd->start_src - 1)) != 0) - err++; - if ((cmd->scan_begin_src & (cmd->scan_begin_src - 1)) != 0) - err++; - if ((cmd->convert_src & (cmd->convert_src - 1)) != 0) - err++; - if ((cmd->scan_end_src & (cmd->scan_end_src - 1)) != 0) - err++; - if ((cmd->stop_src & (cmd->stop_src - 1)) != 0) - err++; - - if (err) - return 2; - - /* step 3: make sure arguments are trivially compatible */ - - /* cmd->start_src == TRIG_NOW || cmd->start_src == TRIG_INT */ - if (cmd->start_arg != 0) { - cmd->start_arg = 0; - err++; - } - - /* cmd->scan_begin_src == TRIG_EXT */ - if (cmd->scan_begin_arg != 0) { - cmd->scan_begin_arg = 0; - err++; - } - - /* cmd->convert_src == TRIG_NOW */ - if (cmd->convert_arg != 0) { - cmd->convert_arg = 0; - err++; - } - - /* cmd->scan_end_src == TRIG_COUNT */ - if (cmd->scan_end_arg != cmd->chanlist_len) { - cmd->scan_end_arg = cmd->chanlist_len; - err++; - } - - switch (cmd->stop_src) { - case TRIG_COUNT: - /* any count allowed */ - break; - case TRIG_NONE: - if (cmd->stop_arg != 0) { - cmd->stop_arg = 0; - err++; - } - break; - default: - break; - } - - if (err) - return 3; - - /* step 4: fix up any arguments */ - - /* if (err) return 4; */ - - return 0; + return comedi_pcm_cmdtest(dev, s, cmd); } static int adc_wait_ready(unsigned long iobase) @@ -1194,8 +1090,8 @@ static int adc_wait_ready(unsigned long iobase) } /* All this is for AI and AO */ -static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; unsigned long iobase = subpriv->iobase; @@ -1258,8 +1154,8 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, return n; } -static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; for (n = 0; n < insn->n; n++) { @@ -1288,8 +1184,8 @@ static int wait_dac_ready(unsigned long iobase) return 1; } -static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; unsigned iobase = subpriv->iobase, iooffset = 0; diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 4e7d8b6327fd..81ee7cdc0caf 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -75,11 +75,12 @@ Configuration Options: [2] - IRQ for second ASIC (pcmuio96 only - IRQ for chans 48-72 .. can be the same as first irq!) */ +#include <linux/interrupt.h> #include "../comedidev.h" +#include "pcm_common.h" #include <linux/pci.h> /* for PCI devices */ -#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) ) #define CHANS_PER_PORT 8 #define PORTS_PER_ASIC 6 #define INTR_PORTS_PER_ASIC 3 @@ -155,14 +156,14 @@ struct pcmuio_board { static const struct pcmuio_board pcmuio_boards[] = { { - name: "pcmuio48", - num_asics:1, - num_ports:6, + .name = "pcmuio48", + .num_asics = 1, + .num_ports = 6, }, { - name: "pcmuio96", - num_asics:2, - num_ports:12, + .name = "pcmuio96", + .num_asics = 2, + .num_ports = 12, }, }; @@ -222,14 +223,14 @@ struct pcmuio_private { * the board, and also about the kernel module that contains * the device code. */ -static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int pcmuio_detach(struct comedi_device * dev); +static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pcmuio_detach(struct comedi_device *dev); static struct comedi_driver driver = { - driver_name:"pcmuio", - module:THIS_MODULE, - attach:pcmuio_attach, - detach:pcmuio_detach, + .driver_name = "pcmuio", + .module = THIS_MODULE, + .attach = pcmuio_attach, + .detach = pcmuio_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -248,29 +249,29 @@ static struct comedi_driver driver = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&pcmuio_boards[0].name, - offset:sizeof(struct pcmuio_board), - num_names:sizeof(pcmuio_boards) / sizeof(struct pcmuio_board), + .board_name = &pcmuio_boards[0].name, + .offset = sizeof(struct pcmuio_board), + .num_names = ARRAY_SIZE(pcmuio_boards), }; -static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); -static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG); +static irqreturn_t interrupt_pcmuio(int irq, void *d); static void pcmuio_stop_intr(struct comedi_device *, struct comedi_subdevice *); -static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int pcmuio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); +static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); /* some helper functions to deal with specifics of this device's registers */ -static void init_asics(struct comedi_device * dev); /* sets up/clears ASIC chips to defaults */ -static void switch_page(struct comedi_device * dev, int asic, int page); +static void init_asics(struct comedi_device *dev); /* sets up/clears ASIC chips to defaults */ +static void switch_page(struct comedi_device *dev, int asic, int page); #ifdef notused -static void lock_port(struct comedi_device * dev, int asic, int port); -static void unlock_port(struct comedi_device * dev, int asic, int port); +static void lock_port(struct comedi_device *dev, int asic, int port); +static void unlock_port(struct comedi_device *dev, int asic, int port); #endif /* @@ -279,7 +280,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port); * in the driver structure, dev->board_ptr contains that * address. */ -static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0; @@ -322,7 +323,7 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i devpriv->asics[asic].iobase = dev->iobase + asic * ASIC_IOSIZE; devpriv->asics[asic].irq = 0; /* this gets actually set at the end of this function when we - comedi_request_irqs */ + request_irqs */ spin_lock_init(&devpriv->asics[asic].spinlock); } @@ -359,7 +360,7 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i s->type = COMEDI_SUBD_DIO; s->insn_bits = pcmuio_dio_insn_bits; s->insn_config = pcmuio_dio_insn_config; - s->n_chan = MIN(chans_left, MAX_CHANS_PER_SUBDEV); + s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV); subpriv->intr.asic = -1; subpriv->intr.first_chan = -1; subpriv->intr.asic_chan = -1; @@ -413,12 +414,12 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) { if (irq[asic] - && comedi_request_irq(irq[asic], interrupt_pcmuio, + && request_irq(irq[asic], interrupt_pcmuio, IRQF_SHARED, thisboard->name, dev)) { int i; /* unroll the allocated irqs.. */ for (i = asic - 1; i >= 0; --i) { - comedi_free_irq(irq[i], dev); + free_irq(irq[i], dev); devpriv->asics[i].irq = irq[i] = 0; } irq[asic] = 0; @@ -450,7 +451,7 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int pcmuio_detach(struct comedi_device * dev) +static int pcmuio_detach(struct comedi_device *dev) { int i; @@ -460,7 +461,7 @@ static int pcmuio_detach(struct comedi_device * dev) for (i = 0; i < MAX_ASICS; ++i) { if (devpriv->asics[i].irq) - comedi_free_irq(devpriv->asics[i].irq, dev); + free_irq(devpriv->asics[i].irq, dev); } if (devpriv && devpriv->sprivs) @@ -474,8 +475,8 @@ static int pcmuio_detach(struct comedi_device * dev) * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int byte_no; if (insn->n != 2) @@ -548,8 +549,8 @@ static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ -static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no = chan % 8; @@ -609,7 +610,7 @@ static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subd return insn->n; } -static void init_asics(struct comedi_device * dev) +static void init_asics(struct comedi_device *dev) { /* sets up an ASIC chip to defaults */ int asic; @@ -646,7 +647,7 @@ static void init_asics(struct comedi_device * dev) } } -static void switch_page(struct comedi_device * dev, int asic, int page) +static void switch_page(struct comedi_device *dev, int asic, int page) { if (asic < 0 || asic >= thisboard->num_asics) return; /* paranoia */ @@ -662,7 +663,7 @@ static void switch_page(struct comedi_device * dev, int asic, int page) } #ifdef notused -static void lock_port(struct comedi_device * dev, int asic, int port) +static void lock_port(struct comedi_device *dev, int asic, int port) { if (asic < 0 || asic >= thisboard->num_asics) return; /* paranoia */ @@ -675,7 +676,7 @@ static void lock_port(struct comedi_device * dev, int asic, int port) dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK); } -static void unlock_port(struct comedi_device * dev, int asic, int port) +static void unlock_port(struct comedi_device *dev, int asic, int port) { if (asic < 0 || asic >= thisboard->num_asics) return; /* paranoia */ @@ -688,7 +689,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port) } #endif /* notused */ -static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) +static irqreturn_t interrupt_pcmuio(int irq, void *d) { int asic, got1 = 0; struct comedi_device *dev = (struct comedi_device *) d; @@ -701,8 +702,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) /* it is an interrupt for ASIC #asic */ unsigned char int_pend; - comedi_spin_lock_irqsave(&devpriv->asics[asic].spinlock, - flags); + spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags); int_pend = inb(iobase + REG_INT_PENDING) & 0x07; @@ -734,8 +734,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) ++got1; } - comedi_spin_unlock_irqrestore(&devpriv->asics[asic]. - spinlock, flags); + spin_unlock_irqrestore(&devpriv->asics[asic].spinlock, flags); if (triggered) { struct comedi_subdevice *s; @@ -748,9 +747,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) unsigned long flags; unsigned oldevents; - comedi_spin_lock_irqsave - (&subpriv->intr. - spinlock, flags); + spin_lock_irqsave (&subpriv->intr.spinlock, flags); oldevents = s->async->events; @@ -781,10 +778,10 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) } } /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, ((short *) & val)[0]) + if (comedi_buf_put(s->async, ((short *) &val)[0]) && comedi_buf_put - (s->async, ((short *) & val)[1])) { + (s->async, ((short *) &val)[1])) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Overflow! Stop acquisition!! */ @@ -816,9 +813,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) } } - comedi_spin_unlock_irqrestore - (&subpriv->intr. - spinlock, flags); + spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); if (oldevents != s->async->events) { @@ -837,11 +832,12 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static void pcmuio_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static void pcmuio_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s) { int nports, firstport, asic, port; - if ((asic = subpriv->intr.asic) < 0) + asic = subpriv->intr.asic; + if (asic < 0) return; /* not an interrupt subdev */ subpriv->intr.enabled_mask = 0; @@ -856,7 +852,7 @@ static void pcmuio_stop_intr(struct comedi_device * dev, struct comedi_subdevice } } -static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmuio_start_intr(struct comedi_device *dev, struct comedi_subdevice *s) { if (!subpriv->intr.continuous && subpriv->intr.stop_count == 0) { /* An empty acquisition! */ @@ -868,7 +864,8 @@ static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice int nports, firstport, asic, port; struct comedi_cmd *cmd = &s->async->cmd; - if ((asic = subpriv->intr.asic) < 0) + asic = subpriv->intr.asic; + if (asic < 0) return 1; /* not an interrupt subdev */ subpriv->intr.enabled_mask = 0; @@ -905,14 +902,14 @@ static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice return 0; } -static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { unsigned long flags; - comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags); + spin_lock_irqsave(&subpriv->intr.spinlock, flags); if (subpriv->intr.active) pcmuio_stop_intr(dev, s); - comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); return 0; } @@ -921,7 +918,7 @@ static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. */ static int -pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s, +pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { unsigned long flags; @@ -930,12 +927,12 @@ pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * if (trignum != 0) return -EINVAL; - comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags); + spin_lock_irqsave(&subpriv->intr.spinlock, flags); s->async->inttrig = 0; if (subpriv->intr.active) { event = pcmuio_start_intr(dev, s); } - comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); if (event) { comedi_event(dev, s); @@ -947,13 +944,13 @@ pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * /* * 'do_cmd' function for an 'INTERRUPT' subdevice. */ -static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; int event = 0; - comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags); + spin_lock_irqsave(&subpriv->intr.spinlock, flags); subpriv->intr.active = 1; /* Set up end of acquisition. */ @@ -979,7 +976,7 @@ static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) event = pcmuio_start_intr(dev, s); break; } - comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); + spin_unlock_irqrestore(&subpriv->intr.spinlock, flags); if (event) { comedi_event(dev, s); @@ -988,110 +985,10 @@ static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s) return 0; } -/* - * 'do_cmdtest' function for an 'INTERRUPT' subdevice. - */ static int -pcmuio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd) +pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - int err = 0; - unsigned int tmp; - - /* step 1: make sure trigger sources are trivially valid */ - - tmp = cmd->start_src; - cmd->start_src &= (TRIG_NOW | TRIG_INT); - if (!cmd->start_src || tmp != cmd->start_src) - err++; - - tmp = cmd->scan_begin_src; - cmd->scan_begin_src &= TRIG_EXT; - if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) - err++; - - tmp = cmd->convert_src; - cmd->convert_src &= TRIG_NOW; - if (!cmd->convert_src || tmp != cmd->convert_src) - err++; - - tmp = cmd->scan_end_src; - cmd->scan_end_src &= TRIG_COUNT; - if (!cmd->scan_end_src || tmp != cmd->scan_end_src) - err++; - - tmp = cmd->stop_src; - cmd->stop_src &= (TRIG_COUNT | TRIG_NONE); - if (!cmd->stop_src || tmp != cmd->stop_src) - err++; - - if (err) - return 1; - - /* step 2: make sure trigger sources are unique and mutually compatible */ - - /* these tests are true if more than one _src bit is set */ - if ((cmd->start_src & (cmd->start_src - 1)) != 0) - err++; - if ((cmd->scan_begin_src & (cmd->scan_begin_src - 1)) != 0) - err++; - if ((cmd->convert_src & (cmd->convert_src - 1)) != 0) - err++; - if ((cmd->scan_end_src & (cmd->scan_end_src - 1)) != 0) - err++; - if ((cmd->stop_src & (cmd->stop_src - 1)) != 0) - err++; - - if (err) - return 2; - - /* step 3: make sure arguments are trivially compatible */ - - /* cmd->start_src == TRIG_NOW || cmd->start_src == TRIG_INT */ - if (cmd->start_arg != 0) { - cmd->start_arg = 0; - err++; - } - - /* cmd->scan_begin_src == TRIG_EXT */ - if (cmd->scan_begin_arg != 0) { - cmd->scan_begin_arg = 0; - err++; - } - - /* cmd->convert_src == TRIG_NOW */ - if (cmd->convert_arg != 0) { - cmd->convert_arg = 0; - err++; - } - - /* cmd->scan_end_src == TRIG_COUNT */ - if (cmd->scan_end_arg != cmd->chanlist_len) { - cmd->scan_end_arg = cmd->chanlist_len; - err++; - } - - switch (cmd->stop_src) { - case TRIG_COUNT: - /* any count allowed */ - break; - case TRIG_NONE: - if (cmd->stop_arg != 0) { - cmd->stop_arg = 0; - err++; - } - break; - default: - break; - } - - if (err) - return 3; - - /* step 4: fix up any arguments */ - - /* if (err) return 4; */ - - return 0; + return comedi_pcm_cmdtest(dev, s, cmd); } /* diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 9231ba802030..e4bbd5dc9a61 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -399,11 +399,11 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel) /* wait to make sure done bit is zero */ for (i = 0; (dma_status & PLX_DMA_DONE_BIT) && i < timeout; i++) { - comedi_udelay(1); + udelay(1); dma_status = readb(dma_cs_addr); } if (i == timeout) { - rt_printk + printk ("plx9080: cancel() timed out waiting for dma %i done clear\n", channel); return -ETIMEDOUT; @@ -413,11 +413,11 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel) /* wait for dma done bit */ dma_status = readb(dma_cs_addr); for (i = 0; (dma_status & PLX_DMA_DONE_BIT) == 0 && i < timeout; i++) { - comedi_udelay(1); + udelay(1); dma_status = readb(dma_cs_addr); } if (i == timeout) { - rt_printk + printk ("plx9080: cancel() timed out waiting for dma %i done set\n", channel); return -ETIMEDOUT; diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 8a0bf6854939..47850bd15484 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -41,17 +41,17 @@ Configuration options: #include <linux/ioport.h> -static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int poc_detach(struct comedi_device * dev); -static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); - -static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int pcl734_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int poc_detach(struct comedi_device *dev); +static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); + +static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pcl733_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pcl734_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); struct boarddef_struct { const char *name; @@ -70,33 +70,33 @@ struct boarddef_struct { }; static const struct boarddef_struct boards[] = { { - name: "dac02", - iosize: 8, - //setup: dac02_setup, - type: COMEDI_SUBD_AO, - n_chan: 2, - n_bits: 12, - winsn: dac02_ao_winsn, - rinsn: readback_insn, - range: &range_unknown, + .name = "dac02", + .iosize = 8, + /* .setup = dac02_setup, */ + .type = COMEDI_SUBD_AO, + .n_chan = 2, + .n_bits = 12, + .winsn = dac02_ao_winsn, + .rinsn = readback_insn, + .range = &range_unknown, }, { - name: "pcl733", - iosize: 4, - type: COMEDI_SUBD_DI, - n_chan: 32, - n_bits: 1, - insnbits:pcl733_insn_bits, - range: &range_digital, + .name = "pcl733", + .iosize = 4, + .type = COMEDI_SUBD_DI, + .n_chan = 32, + .n_bits = 1, + .insnbits = pcl733_insn_bits, + .range = &range_digital, }, { - name: "pcl734", - iosize: 4, - type: COMEDI_SUBD_DO, - n_chan: 32, - n_bits: 1, - insnbits:pcl734_insn_bits, - range: &range_digital, + .name = "pcl734", + .iosize = 4, + .type = COMEDI_SUBD_DO, + .n_chan = 32, + .n_bits = 1, + .insnbits = pcl734_insn_bits, + .range = &range_digital, }, }; @@ -104,16 +104,16 @@ static const struct boarddef_struct boards[] = { #define this_board ((const struct boarddef_struct *)dev->board_ptr) static struct comedi_driver driver_poc = { - driver_name:"poc", - module:THIS_MODULE, - attach:poc_attach, - detach:poc_detach, - board_name:&boards[0].name, - num_names:n_boards, - offset:sizeof(boards[0]), + .driver_name = "poc", + .module = THIS_MODULE, + .attach = poc_attach, + .detach = poc_detach, + .board_name = &boards[0].name, + .num_names = n_boards, + .offset = sizeof(boards[0]), }; -static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; unsigned long iobase; @@ -159,7 +159,7 @@ static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it) return 0; } -static int poc_detach(struct comedi_device * dev) +static int poc_detach(struct comedi_device *dev) { /* only free stuff if it has been allocated by _attach */ if (dev->iobase) @@ -170,8 +170,8 @@ static int poc_detach(struct comedi_device * dev) return 0; } -static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan; @@ -185,8 +185,8 @@ static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s #define DAC02_LSB(a) (2 * a) #define DAC02_MSB(a) (2 * a + 1) -static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int temp; int chan; @@ -196,7 +196,7 @@ static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * ((unsigned int *) dev->private)[chan] = data[0]; output = data[0]; #ifdef wrong - // convert to complementary binary if range is bipolar + /* convert to complementary binary if range is bipolar */ if ((CR_RANGE(insn->chanspec) & 0x2) == 0) output = ~output; #endif @@ -208,8 +208,8 @@ static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * return 1; } -static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl733_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -222,8 +222,8 @@ static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice return 2; } -static int pcl734_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int pcl734_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 795c4522867f..85b53c93e135 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -179,8 +179,8 @@ static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ }; #define DAQP_AUX_FIFO_EMPTY 0x01 /* These range structures tell COMEDI how the sample values map to - * voltages. The A/D converter has four ranges: +/- 10V through - * +/- 1.25V, and the D/A converter has only one: +/- 5V. + * voltages. The A/D converter has four .ranges = +/- 10V through + * +/- 1.25V, and the D/A converter has only .one = +/- 5V. */ static const struct comedi_lrange range_daqp_ai = { 4, { @@ -197,18 +197,18 @@ static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} }; /* comedi interface code */ -static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int daqp_detach(struct comedi_device * dev); +static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int daqp_detach(struct comedi_device *dev); static struct comedi_driver driver_daqp = { - driver_name:"quatech_daqp_cs", - module:THIS_MODULE, - attach:daqp_attach, - detach:daqp_detach, + .driver_name = "quatech_daqp_cs", + .module = THIS_MODULE, + .attach = daqp_attach, + .detach = daqp_detach, }; #ifdef DAQP_DEBUG -static void daqp_dump(struct comedi_device * dev) +static void daqp_dump(struct comedi_device *dev) { printk("DAQP: status %02x; aux status %02x\n", inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX)); @@ -234,7 +234,7 @@ static void hex_dump(char *str, void *ptr, int len) /* Cancel a running acquisition */ -static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct local_info_t *local = (struct local_info_t *) s->private; @@ -262,7 +262,7 @@ static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * * which run pretty quick. */ -static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG) +static void daqp_interrupt(int irq, void *dev_id) { struct local_info_t *local = (struct local_info_t *) dev_id; struct comedi_device *dev; @@ -361,8 +361,8 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG) /* One-shot analog data acquisition routine */ -static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct local_info_t *local = (struct local_info_t *) s->private; int i; @@ -467,8 +467,8 @@ static int daqp_ns_to_timer(unsigned int *ns, int round) * the command passes. */ -static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -593,7 +593,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * return 0; } -static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct local_info_t *local = (struct local_info_t *) s->private; struct comedi_cmd *cmd = &s->async->cmd; @@ -793,8 +793,8 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) /* Single-shot analog output routine */ -static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqp_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct local_info_t *local = (struct local_info_t *) s->private; int d; @@ -820,8 +820,8 @@ static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevic /* Digital input routine */ -static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqp_di_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct local_info_t *local = (struct local_info_t *) s->private; @@ -836,8 +836,8 @@ static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice /* Digital output routine */ -static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int daqp_do_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct local_info_t *local = (struct local_info_t *) s->private; @@ -856,7 +856,7 @@ static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevic * when it is inserted. */ -static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int ret; struct local_info_t *local = dev_table[it->options[0]]; @@ -908,7 +908,8 @@ static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it) dev->iobase = local->link->io.BasePort1; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; printk("comedi%d: attaching daqp%d (io 0x%04lx)\n", @@ -962,7 +963,7 @@ static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it) * card is removed, daqp_cs_detach() is called by the pcmcia subsystem. */ -static int daqp_detach(struct comedi_device * dev) +static int daqp_detach(struct comedi_device *dev) { printk("comedi%d: detaching daqp\n", dev->minor); @@ -1149,15 +1150,21 @@ static void daqp_cs_config(struct pcmcia_device *link) tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) { + + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) { + + last_ret = pcmcia_get_tuple_data(link, &tuple); + if (last_ret) { cs_error(link, GetTupleData, last_ret); goto cs_failed; } - if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) { + + last_ret = pcmcia_parse_tuple(&tuple, &parse); + if (last_ret) { cs_error(link, ParseTuple, last_ret); goto cs_failed; } @@ -1177,10 +1184,12 @@ static void daqp_cs_config(struct pcmcia_device *link) will only use the CIS to fill in implementation-defined details. */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) { + last_ret = pcmcia_get_first_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetFirstTuple, last_ret); goto cs_failed; } + while (1) { cistpl_cftable_entry_t dflt = { 0 }; cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); @@ -1226,7 +1235,8 @@ static void daqp_cs_config(struct pcmcia_device *link) break; next_entry: - if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) { + last_ret = pcmcia_get_next_tuple(link, &tuple); + if (last_ret) { cs_error(link, GetNextTuple, last_ret); goto cs_failed; } @@ -1237,18 +1247,21 @@ static void daqp_cs_config(struct pcmcia_device *link) handler to the interrupt, unless the 'Handler' member of the irq structure is initialized. */ - if (link->conf.Attributes & CONF_ENABLE_IRQ) - if ((last_ret = pcmcia_request_irq(link, &link->irq))) { + if (link->conf.Attributes & CONF_ENABLE_IRQ) { + last_ret = pcmcia_request_irq(link, &link->irq); + if (last_ret) { cs_error(link, RequestIRQ, last_ret); goto cs_failed; } + } /* This actually configures the PCMCIA socket -- setting up the I/O windows and the interrupt mapping, and putting the card and host interface into "Memory and IO" mode. */ - if ((last_ret = pcmcia_request_configuration(link, &link->conf))) { + last_ret = pcmcia_request_configuration(link, &link->conf); + if (last_ret) { cs_error(link, RequestConfiguration, last_ret); goto cs_failed; } diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index ca347f21d140..243ee76c836d 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -101,6 +101,7 @@ Configuration options: */ +#include <linux/interrupt.h> #include <linux/delay.h> #include "../comedidev.h" @@ -135,7 +136,7 @@ Configuration options: #define RTD_DMA_TIMEOUT 33000 /* 1 msec */ #else /* by delaying, power and electrical noise are reduced somewhat */ -#define WAIT_QUIETLY comedi_udelay (1) +#define WAIT_QUIETLY udelay (1) #define RTD_ADC_TIMEOUT 2000 /* in usec */ #define RTD_DAC_TIMEOUT 2000 /* in usec */ #define RTD_DMA_TIMEOUT 1000 /* in usec */ @@ -278,22 +279,22 @@ struct rtdBoard { static const struct rtdBoard rtd520Boards[] = { { - name: "DM7520", - device_id : 0x7520, - aiChans: 16, - aiBits: 12, - aiMaxGain:32, - range10Start:6, - rangeUniStart:12, + .name = "DM7520", + .device_id = 0x7520, + .aiChans = 16, + .aiBits = 12, + .aiMaxGain = 32, + .range10Start = 6, + .rangeUniStart = 12, }, { - name: "PCI4520", - device_id : 0x4520, - aiChans: 16, - aiBits: 12, - aiMaxGain:128, - range10Start:8, - rangeUniStart:16, + .name = "PCI4520", + .device_id = 0x4520, + .aiChans = 16, + .aiBits = 12, + .aiMaxGain = 128, + .range10Start = 8, + .rangeUniStart = 16, }, }; @@ -684,10 +685,10 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int rtd_detach(struct comedi_device *dev); static struct comedi_driver rtd520Driver = { - driver_name: DRV_NAME, - module : THIS_MODULE, - attach : rtd_attach, - detach : rtd_detach, + .driver_name = DRV_NAME, + .module = THIS_MODULE, + .attach = rtd_attach, + .detach = rtd_detach, }; static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, @@ -706,7 +707,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); /* static int rtd_ai_poll (struct comedi_device *dev,struct comedi_subdevice *s); */ static int rtd_ns_to_timer(unsigned int *ns, int roundMode); -static irqreturn_t rtd_interrupt(int irq, void *d PT_REGS_ARG); +static irqreturn_t rtd_interrupt(int irq, void *d); static int rtd520_probe_fifo_depth(struct comedi_device *dev); /* @@ -757,15 +758,15 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) continue; } } - for(i = 0; i < sizeof(rtd520Boards) / sizeof(rtd520Boards[0]); ++i) + for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i) { - if(pcidev->device == rtd520Boards[i].device_id) + if (pcidev->device == rtd520Boards[i].device_id) { dev->board_ptr = &rtd520Boards[i]; break; } } - if(dev->board_ptr) break; /* found one */ + if (dev->board_ptr) break; /* found one */ } if (!pcidev) { if (it->options[0] && it->options[1]) { @@ -900,7 +901,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* initialize board, per RTD spec */ /* also, initialize shadow registers */ RtdResetBoard(dev); - comedi_udelay(100); /* needed? */ + udelay(100); /* needed? */ RtdPlxInterruptWrite(dev, 0); RtdInterruptMask(dev, 0); /* and sets shadow */ RtdInterruptClearMask(dev, ~0); /* and sets shadow */ @@ -919,7 +920,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* TODO: set user out source ??? */ /* check if our interrupt is available and get it */ - ret = comedi_request_irq(devpriv->pci_dev->irq, rtd_interrupt, + ret = request_irq(devpriv->pci_dev->irq, rtd_interrupt, IRQF_SHARED, DRV_NAME, dev); if (ret < 0) { @@ -931,7 +932,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) printk("( irq=%u )", dev->irq); ret = rtd520_probe_fifo_depth(dev); - if(ret < 0) { + if (ret < 0) { return ret; } devpriv->fifoLen = ret; @@ -1032,7 +1033,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* disable interrupt controller */ RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev) & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E)); - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } /* release all regions that were allocated */ @@ -1111,7 +1112,7 @@ static int rtd_detach(struct comedi_device *dev) /* disable interrupt controller */ RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev) & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E)); - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); } /* release all regions that were allocated */ @@ -1224,22 +1225,22 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev) unsigned fifo_status; /* trigger conversion */ RtdAdcStart(dev); - comedi_udelay(1); + udelay(1); fifo_status = RtdFifoStatus(dev); - if((fifo_status & FS_ADC_HEMPTY) == 0) { + if ((fifo_status & FS_ADC_HEMPTY) == 0) { fifo_size = 2 * i; break; } } - if(i == limit) + if (i == limit) { - rt_printk("\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME); + printk("\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME); return -EIO; } RtdAdcClearFifo(dev); - if(fifo_size != 0x400 && fifo_size != 0x2000) + if (fifo_size != 0x400 && fifo_size != 0x2000) { - rt_printk("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n", + printk("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n", DRV_NAME, fifo_size); return -EIO; } @@ -1386,7 +1387,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel) + ((channel == 0) ? LCFG_DMACSR0 : LCFG_DMACSR1); /* spinlock for plx dma control/status reg */ - /* comedi_spin_lock_irqsave( &dev->spinlock, flags ); */ + /* spin_lock_irqsave( &dev->spinlock, flags ); */ /* abort dma transfer if necessary */ status = readb(dma_cs_addr); @@ -1409,7 +1410,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel) /* disable channel (required) */ writeb(0, dma_cs_addr); - comedi_udelay(1); /* needed?? */ + udelay(1); /* needed?? */ /* set abort bit for channel */ writeb(PLX_DMA_ABORT_BIT, dma_cs_addr); @@ -1427,7 +1428,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel) } abortDmaExit: - /* comedi_spin_unlock_irqrestore( &dev->spinlock, flags ); */ + /* spin_unlock_irqrestore( &dev->spinlock, flags ); */ } /* @@ -1494,8 +1495,7 @@ static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s) The data conversion may someday happen in a "bottom half". */ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */ - void *d /* our data */ - PT_REGS_ARG) + void *d) /* our data */ { /* cpu context (ignored) */ struct comedi_device *dev = d; /* must be called "dev" for devpriv */ u16 status; diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 334ac5773a13..f1b7e0252f13 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -52,6 +52,7 @@ Configuration options: [8] - DAC 1 encoding (same as DAC 0) */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -89,8 +90,8 @@ Configuration options: #define Am9513_8BITBUS -#define Am9513_output_control(a) outb(a,dev->iobase+RTI800_9513A_CNTRL) -#define Am9513_output_data(a) outb(a,dev->iobase+RTI800_9513A_DATA) +#define Am9513_output_control(a) outb(a, dev->iobase+RTI800_9513A_CNTRL) +#define Am9513_output_data(a) outb(a, dev->iobase+RTI800_9513A_DATA) #define Am9513_input_data() inb(dev->iobase+RTI800_9513A_DATA) #define Am9513_input_status() inb(dev->iobase+RTI800_9513A_STATUS) @@ -131,21 +132,21 @@ static const struct rti800_board boardtypes[] = { #define this_board ((const struct rti800_board *)dev->board_ptr) -static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int rti800_detach(struct comedi_device * dev); +static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int rti800_detach(struct comedi_device *dev); static struct comedi_driver driver_rti800 = { - driver_name:"rti800", - module:THIS_MODULE, - attach:rti800_attach, - detach:rti800_detach, - num_names:sizeof(boardtypes) / sizeof(struct rti800_board), - board_name:&boardtypes[0].name, - offset:sizeof(struct rti800_board), + .driver_name = "rti800", + .module = THIS_MODULE, + .attach = rti800_attach, + .detach = rti800_detach, + .num_names = ARRAY_SIZE(boardtypes), + .board_name = &boardtypes[0].name, + .offset = sizeof(struct rti800_board), }; COMEDI_INITCLEANUP(driver_rti800); -static irqreturn_t rti800_interrupt(int irq, void *dev PT_REGS_ARG); +static irqreturn_t rti800_interrupt(int irq, void *dev); struct rti800_private { enum { @@ -172,16 +173,16 @@ struct rti800_private { #define RTI800_TIMEOUT 100 -static irqreturn_t rti800_interrupt(int irq, void *dev PT_REGS_ARG) +static irqreturn_t rti800_interrupt(int irq, void *dev) { return IRQ_HANDLED; } -// settling delay times in usec for different gains +/* settling delay times in usec for different gains */ static const int gaindelay[] = { 10, 20, 40, 80 }; -static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti800_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, t; int status; @@ -199,9 +200,8 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi /* without a delay here, the RTI_OVERRUN bit * gets set, and you will have an error. */ if (insn->n > 0) { - BUG_ON(gain >= - sizeof(gaindelay) / sizeof(gaindelay[0])); - comedi_udelay(gaindelay[gain]); + BUG_ON(gain >= ARRAY_SIZE(gaindelay)); + udelay(gaindelay[gain]); } } @@ -210,16 +210,16 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi for (t = RTI800_TIMEOUT; t; t--) { status = inb(dev->iobase + RTI800_CSR); if (status & RTI800_OVERRUN) { - rt_printk("rti800: a/d overrun\n"); + printk("rti800: a/d overrun\n"); outb(0, dev->iobase + RTI800_CLRFLAGS); return -EIO; } if (status & RTI800_DONE) break; - comedi_udelay(1); + udelay(1); } if (t == 0) { - rt_printk("rti800: timeout\n"); + printk("rti800: timeout\n"); return -ETIME; } data[i] = inb(dev->iobase + RTI800_ADCLO); @@ -233,8 +233,8 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int rti800_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti800_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -245,8 +245,8 @@ static int rti800_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int rti800_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti800_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int d; @@ -265,8 +265,8 @@ static int rti800_ao_insn_write(struct comedi_device * dev, struct comedi_subdev return i; } -static int rti800_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti800_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -274,8 +274,8 @@ static int rti800_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi return 2; } -static int rti800_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti800_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -309,7 +309,7 @@ static int rti800_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi options[8] - dac1 coding */ -static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned int irq; unsigned long iobase; @@ -339,8 +339,8 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i irq = it->options[1]; if (irq) { printk("( irq = %u )", irq); - if ((ret = comedi_request_irq(irq, rti800_interrupt, 0, - "rti800", dev)) < 0) { + ret = request_irq(irq, rti800_interrupt, 0, "rti800", dev); + if (ret < 0) { printk(" Failed to allocate IRQ\n"); return ret; } @@ -351,9 +351,12 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i dev->board_name = this_board->name; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct rti800_private))) < 0) + + ret = alloc_private(dev, sizeof(struct rti800_private)); + if (ret < 0) return ret; devpriv->adc_mux = it->options[2]; @@ -444,7 +447,7 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int rti800_detach(struct comedi_device * dev) +static int rti800_detach(struct comedi_device *dev) { printk("comedi%d: rti800: remove\n", dev->minor); @@ -452,7 +455,7 @@ static int rti800_detach(struct comedi_device * dev) release_region(dev->iobase, RTI800_SIZE); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); return 0; } diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index cc2c385db0b0..fffde45a352b 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -47,13 +47,13 @@ Configuration Options: #define RTI802_DATALOW 1 #define RTI802_DATAHIGH 2 -static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int rti802_detach(struct comedi_device * dev); +static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int rti802_detach(struct comedi_device *dev); static struct comedi_driver driver_rti802 = { - driver_name:"rti802", - module:THIS_MODULE, - attach:rti802_attach, - detach:rti802_detach, + .driver_name = "rti802", + .module = THIS_MODULE, + .attach = rti802_attach, + .detach = rti802_detach, }; COMEDI_INITCLEANUP(driver_rti802); @@ -68,8 +68,8 @@ struct rti802_private { #define devpriv ((struct rti802_private *)dev->private) -static int rti802_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti802_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; @@ -79,8 +79,8 @@ static int rti802_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi return i; } -static int rti802_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int rti802_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, d; int chan = CR_CHAN(insn->chanspec); @@ -96,7 +96,7 @@ static int rti802_ao_insn_write(struct comedi_device * dev, struct comedi_subdev return i; } -static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int i; @@ -140,7 +140,7 @@ static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * i return 0; } -static int rti802_detach(struct comedi_device * dev) +static int rti802_detach(struct comedi_device *dev) { printk("comedi%d: rti802: remove\n", dev->minor); diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index a7b6f711afca..d9509d7a3283 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -169,14 +169,14 @@ struct s526_board { static const struct s526_board s526_boards[] = { { - name: "s526", - gpct_chans:4, - gpct_bits:24, - ad_chans:8, - ad_bits: 16, - da_chans:4, - da_bits: 16, - have_dio:1, + .name = "s526", + .gpct_chans = 4, + .gpct_bits = 24, + .ad_chans = 8, + .ad_bits = 16, + .da_chans = 4, + .da_bits = 16, + .have_dio = 1, } }; @@ -217,13 +217,13 @@ struct s526_private { * the board, and also about the kernel module that contains * the device code. */ -static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int s526_detach(struct comedi_device * dev); +static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int s526_detach(struct comedi_device *dev); static struct comedi_driver driver_s526 = { - driver_name:"s526", - module:THIS_MODULE, - attach:s526_attach, - detach:s526_detach, + .driver_name = "s526", + .module = THIS_MODULE, + .attach = s526_attach, + .detach = s526_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -242,29 +242,29 @@ static struct comedi_driver driver_s526 = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&s526_boards[0].name, - offset:sizeof(struct s526_board), - num_names:sizeof(s526_boards) / sizeof(struct s526_board), + .board_name = &s526_boards[0].name, + .offset = sizeof(struct s526_board), + .num_names = ARRAY_SIZE(s526_boards), }; -static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * Attach is called by the Comedi core to configure the driver @@ -272,13 +272,13 @@ static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdev * in the driver structure, dev->board_ptr contains that * address. */ -static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; int iobase; int i, n; -// short value; -// int subdev_channel = 0; +/* short value; */ +/* int subdev_channel = 0; */ printk("comedi%d: s526: ", dev->minor); @@ -334,12 +334,12 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) /* Command are not implemented yet, however they are necessary to allocate the necessary memory for the comedi_async struct (used to trigger the GPCT in case of pulsegenerator function */ - //s->do_cmd = s526_gpct_cmd; - //s->do_cmdtest = s526_gpct_cmdtest; - //s->cancel = s526_gpct_cancel; + /* s->do_cmd = s526_gpct_cmd; */ + /* s->do_cmdtest = s526_gpct_cmdtest; */ + /* s->cancel = s526_gpct_cancel; */ s = dev->subdevices + 1; - //dev->read_subdev=s; + /* dev->read_subdev=s; */ /* analog input subdevice */ s->type = COMEDI_SUBD_AI; /* we support differential */ @@ -383,18 +383,18 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) return 1; #if 0 - // Example of Counter Application - //One-shot (software trigger) - cmReg.reg.coutSource = 0; // out RCAP - cmReg.reg.coutPolarity = 1; // Polarity inverted - cmReg.reg.autoLoadResetRcap = 1; // Auto load 0:disabled, 1:enabled - cmReg.reg.hwCtEnableSource = 3; // NOT RCAP - cmReg.reg.ctEnableCtrl = 2; // Hardware - cmReg.reg.clockSource = 2; // Internal - cmReg.reg.countDir = 1; // Down - cmReg.reg.countDirCtrl = 1; // Software - cmReg.reg.outputRegLatchCtrl = 0; // latch on read - cmReg.reg.preloadRegSel = 0; // PR0 + /* Example of Counter Application */ + /* One-shot (software trigger) */ + cmReg.reg.coutSource = 0; /* out RCAP */ + cmReg.reg.coutPolarity = 1; /* Polarity inverted */ + cmReg.reg.autoLoadResetRcap = 1; /* Auto load 0:disabled, 1:enabled */ + cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */ + cmReg.reg.ctEnableCtrl = 2; /* Hardware */ + cmReg.reg.clockSource = 2; /* Internal */ + cmReg.reg.countDir = 1; /* Down */ + cmReg.reg.countDirCtrl = 1; /* Software */ + cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */ + cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.reserved = 0; outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); @@ -402,24 +402,24 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel)); outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter - outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0 + outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */ + outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */ - outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset RCAP (fires one-shot) + outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset RCAP (fires one-shot) */ #else - // Set Counter Mode Register - cmReg.reg.coutSource = 0; // out RCAP - cmReg.reg.coutPolarity = 0; // Polarity inverted - cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled - cmReg.reg.hwCtEnableSource = 2; // NOT RCAP - cmReg.reg.ctEnableCtrl = 1; // 1: Software, >1 : Hardware - cmReg.reg.clockSource = 3; // x4 - cmReg.reg.countDir = 0; // up - cmReg.reg.countDirCtrl = 0; // quadrature - cmReg.reg.outputRegLatchCtrl = 0; // latch on read - cmReg.reg.preloadRegSel = 0; // PR0 + /* Set Counter Mode Register */ + cmReg.reg.coutSource = 0; /* out RCAP */ + cmReg.reg.coutPolarity = 0; /* Polarity inverted */ + cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */ + cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */ + cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */ + cmReg.reg.clockSource = 3; /* x4 */ + cmReg.reg.countDir = 0; /* up */ + cmReg.reg.countDirCtrl = 0; /* quadrature */ + cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */ + cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.reserved = 0; n = 0; @@ -429,21 +429,21 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) udelay(1000); printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n))); - // Load the pre-laod register high word -// value = (short) (0x55); -// outw(value, ADDR_CHAN_REG(REG_C0H, n)); + /* Load the pre-laod register high word */ +/* value = (short) (0x55); */ +/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */ - // Load the pre-laod register low word -// value = (short)(0xaa55); -// outw(value, ADDR_CHAN_REG(REG_C0L, n)); + /* Load the pre-laod register low word */ +/* value = (short)(0xaa55); */ +/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */ - // Write the Counter Control Register -// outw(value, ADDR_CHAN_REG(REG_C0C, 0)); + /* Write the Counter Control Register */ +/* outw(value, ADDR_CHAN_REG(REG_C0C, 0)); */ - // Reset the counter if it is software preload + /* Reset the counter if it is software preload */ if (cmReg.reg.autoLoadResetRcap == 0) { - outw(0x8000, ADDR_CHAN_REG(REG_C0C, n)); // Reset the counter - outw(0x4000, ADDR_CHAN_REG(REG_C0C, n)); // Load the counter from PR0 + outw(0x8000, ADDR_CHAN_REG(REG_C0C, n)); /* Reset the counter */ + outw(0x4000, ADDR_CHAN_REG(REG_C0C, n)); /* Load the counter from PR0 */ } outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n)); @@ -468,7 +468,7 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it) * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int s526_detach(struct comedi_device * dev) +static int s526_detach(struct comedi_device *dev) { printk("comedi%d: s526: remove\n", dev->minor); @@ -478,47 +478,47 @@ static int s526_detach(struct comedi_device * dev) return 0; } -static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int i; // counts the Data + int i; /* counts the Data */ int counter_channel = CR_CHAN(insn->chanspec); unsigned short datalow; unsigned short datahigh; - // Check if (n > 0) + /* Check if (n > 0) */ if (insn->n <= 0) { printk("s526: INSN_READ: n should be > 0\n"); return -EINVAL; } - // Read the low word first + /* Read the low word first */ for (i = 0; i < insn->n; i++) { datalow = inw(ADDR_CHAN_REG(REG_C0L, counter_channel)); datahigh = inw(ADDR_CHAN_REG(REG_C0H, counter_channel)); data[i] = (int)(datahigh & 0x00FF); data[i] = (data[i] << 16) | (datalow & 0xFFFF); -// printk("s526 GPCT[%d]: %x(0x%04x, 0x%04x)\n", counter_channel, data[i], datahigh, datalow); +/* printk("s526 GPCT[%d]: %x(0x%04x, 0x%04x)\n", counter_channel, data[i], datahigh, datalow); */ } return i; } -static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec + int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */ int i; short value; -// printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel); +/* printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel); */ for (i = 0; i < MAX_GPCT_CONFIG_DATA; i++) { devpriv->s526_gpct_config[subdev_channel].data[i] = insn->data[i]; -// printk("data[%d]=%x\n", i, insn->data[i]); +/* printk("data[%d]=%x\n", i, insn->data[i]); */ } - // Check what type of Counter the user requested, data[0] contains - // the Application type + /* Check what type of Counter the user requested, data[0] contains */ + /* the Application type */ switch (insn->data[0]) { case INSN_CONFIG_GPCT_QUADRATURE_ENCODER: /* @@ -531,19 +531,19 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde devpriv->s526_gpct_config[subdev_channel].app = PositionMeasurement; -/* - // Example of Counter Application - //One-shot (software trigger) - cmReg.reg.coutSource = 0; // out RCAP - cmReg.reg.coutPolarity = 1; // Polarity inverted - cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled - cmReg.reg.hwCtEnableSource = 3; // NOT RCAP - cmReg.reg.ctEnableCtrl = 2; // Hardware - cmReg.reg.clockSource = 2; // Internal - cmReg.reg.countDir = 1; // Down - cmReg.reg.countDirCtrl = 1; // Software - cmReg.reg.outputRegLatchCtrl = 0; // latch on read - cmReg.reg.preloadRegSel = 0; // PR0 +#if 0 + /* Example of Counter Application */ + /* One-shot (software trigger) */ + cmReg.reg.coutSource = 0; /* out RCAP */ + cmReg.reg.coutPolarity = 1; /* Polarity inverted */ + cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */ + cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */ + cmReg.reg.ctEnableCtrl = 2; /* Hardware */ + cmReg.reg.clockSource = 2; /* Internal */ + cmReg.reg.countDir = 1; /* Down */ + cmReg.reg.countDirCtrl = 1; /* Software */ + cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */ + cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.reserved = 0; outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); @@ -551,40 +551,40 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel)); outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter - outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0 + outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */ + outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */ - outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset RCAP (fires one-shot) + outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset RCAP (fires one-shot) */ -*/ +#endif #if 1 - // Set Counter Mode Register - cmReg.reg.coutSource = 0; // out RCAP - cmReg.reg.coutPolarity = 0; // Polarity inverted - cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled - cmReg.reg.hwCtEnableSource = 2; // NOT RCAP - cmReg.reg.ctEnableCtrl = 1; // 1: Software, >1 : Hardware - cmReg.reg.clockSource = 3; // x4 - cmReg.reg.countDir = 0; // up - cmReg.reg.countDirCtrl = 0; // quadrature - cmReg.reg.outputRegLatchCtrl = 0; // latch on read - cmReg.reg.preloadRegSel = 0; // PR0 + /* Set Counter Mode Register */ + cmReg.reg.coutSource = 0; /* out RCAP */ + cmReg.reg.coutPolarity = 0; /* Polarity inverted */ + cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */ + cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */ + cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */ + cmReg.reg.clockSource = 3; /* x4 */ + cmReg.reg.countDir = 0; /* up */ + cmReg.reg.countDirCtrl = 0; /* quadrature */ + cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */ + cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.reserved = 0; - // Set Counter Mode Register -// printk("s526: Counter Mode register=%x\n", cmReg.value); + /* Set Counter Mode Register */ +/* printk("s526: Counter Mode register=%x\n", cmReg.value); */ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Reset the counter if it is software preload + /* Reset the counter if it is software preload */ if (cmReg.reg.autoLoadResetRcap == 0) { - outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter -// outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0 + outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */ +/* outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); Load the counter from PR0 */ } #else - cmReg.reg.countDirCtrl = 0; // 0 quadrature, 1 software control + cmReg.reg.countDirCtrl = 0; /* 0 quadrature, 1 software control */ - // data[1] contains GPCT_X1, GPCT_X2 or GPCT_X4 + /* data[1] contains GPCT_X1, GPCT_X2 or GPCT_X4 */ if (insn->data[1] == GPCT_X2) { cmReg.reg.clockSource = 1; } else if (insn->data[1] == GPCT_X4) { @@ -593,37 +593,37 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde cmReg.reg.clockSource = 0; } - // When to take into account the indexpulse: + /* When to take into account the indexpulse: */ if (insn->data[2] == GPCT_IndexPhaseLowLow) { } else if (insn->data[2] == GPCT_IndexPhaseLowHigh) { } else if (insn->data[2] == GPCT_IndexPhaseHighLow) { } else if (insn->data[2] == GPCT_IndexPhaseHighHigh) { } - // Take into account the index pulse? + /* Take into account the index pulse? */ if (insn->data[3] == GPCT_RESET_COUNTER_ON_INDEX) - cmReg.reg.autoLoadResetRcap = 4; // Auto load with INDEX^ + cmReg.reg.autoLoadResetRcap = 4; /* Auto load with INDEX^ */ - // Set Counter Mode Register + /* Set Counter Mode Register */ cmReg.value = (short) (insn->data[1] & 0xFFFF); outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Load the pre-laod register high word + /* Load the pre-laod register high word */ value = (short) ((insn->data[2] >> 16) & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); - // Load the pre-laod register low word + /* Load the pre-laod register low word */ value = (short) (insn->data[2] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - // Write the Counter Control Register + /* Write the Counter Control Register */ if (insn->data[3] != 0) { value = (short) (insn->data[3] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel)); } - // Reset the counter if it is software preload + /* Reset the counter if it is software preload */ if (cmReg.reg.autoLoadResetRcap == 0) { - outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter - outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0 + outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */ + outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */ } #endif break; @@ -640,33 +640,33 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde devpriv->s526_gpct_config[subdev_channel].app = SinglePulseGeneration; - // Set Counter Mode Register + /* Set Counter Mode Register */ cmReg.value = (short) (insn->data[1] & 0xFFFF); - cmReg.reg.preloadRegSel = 0; // PR0 + cmReg.reg.preloadRegSel = 0; /* PR0 */ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Load the pre-laod register 0 high word + /* Load the pre-laod register 0 high word */ value = (short) ((insn->data[2] >> 16) & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); - // Load the pre-laod register 0 low word + /* Load the pre-laod register 0 low word */ value = (short) (insn->data[2] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - // Set Counter Mode Register + /* Set Counter Mode Register */ cmReg.value = (short) (insn->data[1] & 0xFFFF); - cmReg.reg.preloadRegSel = 1; // PR1 + cmReg.reg.preloadRegSel = 1; /* PR1 */ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Load the pre-laod register 1 high word + /* Load the pre-laod register 1 high word */ value = (short) ((insn->data[3] >> 16) & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); - // Load the pre-laod register 1 low word + /* Load the pre-laod register 1 low word */ value = (short) (insn->data[3] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - // Write the Counter Control Register + /* Write the Counter Control Register */ if (insn->data[3] != 0) { value = (short) (insn->data[3] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel)); @@ -685,33 +685,33 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde devpriv->s526_gpct_config[subdev_channel].app = PulseTrainGeneration; - // Set Counter Mode Register + /* Set Counter Mode Register */ cmReg.value = (short) (insn->data[1] & 0xFFFF); - cmReg.reg.preloadRegSel = 0; // PR0 + cmReg.reg.preloadRegSel = 0; /* PR0 */ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Load the pre-laod register 0 high word + /* Load the pre-laod register 0 high word */ value = (short) ((insn->data[2] >> 16) & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); - // Load the pre-laod register 0 low word + /* Load the pre-laod register 0 low word */ value = (short) (insn->data[2] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - // Set Counter Mode Register + /* Set Counter Mode Register */ cmReg.value = (short) (insn->data[1] & 0xFFFF); - cmReg.reg.preloadRegSel = 1; // PR1 + cmReg.reg.preloadRegSel = 1; /* PR1 */ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel)); - // Load the pre-laod register 1 high word + /* Load the pre-laod register 1 high word */ value = (short) ((insn->data[3] >> 16) & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel)); - // Load the pre-laod register 1 low word + /* Load the pre-laod register 1 low word */ value = (short) (insn->data[3] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); - // Write the Counter Control Register + /* Write the Counter Control Register */ if (insn->data[3] != 0) { value = (short) (insn->data[3] & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel)); @@ -727,16 +727,16 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde return insn->n; } -static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec + int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */ short value; printk("s526: GPCT_INSN_WRITE on channel %d\n", subdev_channel); cmReg.value = inw(ADDR_CHAN_REG(REG_C0M, subdev_channel)); printk("s526: Counter Mode Register: %x\n", cmReg.value); - // Check what Application of Counter this channel is configured for + /* Check what Application of Counter this channel is configured for */ switch (devpriv->s526_gpct_config[subdev_channel].app) { case PositionMeasurement: printk("S526: INSN_WRITE: PM\n"); @@ -776,18 +776,18 @@ static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * value = (short) (*data & 0xFFFF); outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel)); break; - default: // Impossible + default: /* Impossible */ printk("s526: INSN_WRITE: Functionality %d not implemented yet\n", devpriv->s526_gpct_config[subdev_channel].app); return -EINVAL; break; } - // return the number of samples written + /* return the number of samples written */ return insn->n; } #define ISR_ADC_DONE 0x4 -static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int result = -EINVAL; @@ -803,14 +803,14 @@ static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevi * enable channels here. The channel should be enabled in the * INSN_READ handler. */ - // Enable ADC interrupt + /* Enable ADC interrupt */ outw(ISR_ADC_DONE, ADDR_REG(REG_IER)); -// printk("s526: ADC current value: 0x%04x\n", inw(ADDR_REG(REG_ADC))); +/* printk("s526: ADC current value: 0x%04x\n", inw(ADDR_REG(REG_ADC))); */ devpriv->s526_ai_config = (data[0] & 0x3FF) << 5; if (data[1] > 0) - devpriv->s526_ai_config |= 0x8000; //set the delay + devpriv->s526_ai_config |= 0x8000; /* set the delay */ - devpriv->s526_ai_config |= 0x0001; // ADC start bit. + devpriv->s526_ai_config |= 0x0001; /* ADC start bit. */ return result; } @@ -819,8 +819,8 @@ static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevi * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; int chan = CR_CHAN(insn->chanspec); @@ -837,8 +837,8 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s for (n = 0; n < insn->n; n++) { /* trigger conversion */ outw(value, ADDR_REG(REG_ADC)); -// printk("s526: Wrote 0x%04x to ADC\n", value); -// printk("s526: ADC reg=0x%04x\n", inw(ADDR_REG(REG_ADC))); +/* printk("s526: Wrote 0x%04x to ADC\n", value); */ +/* printk("s526: ADC reg=0x%04x\n", inw(ADDR_REG(REG_ADC))); */ #define TIMEOUT 100 /* wait for conversion to end */ @@ -850,16 +850,16 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s } } if (i == TIMEOUT) { - /* rt_printk() should be used instead of printk() + /* printk() should be used instead of printk() * whenever the code can be called from real-time. */ - rt_printk("s526: ADC(0x%04x) timeout\n", + printk("s526: ADC(0x%04x) timeout\n", inw(ADDR_REG(REG_ISR))); return -ETIMEDOUT; } /* read data */ d = inw(ADDR_REG(REG_ADD)); -// printk("AI[%d]=0x%04x\n", n, (unsigned short)(d & 0xFFFF)); +/* printk("AI[%d]=0x%04x\n", n, (unsigned short)(d & 0xFFFF)); */ /* munge data */ data[n] = d ^ 0x8000; @@ -869,27 +869,27 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s return n; } -static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); unsigned short val; -// printk("s526_ao_winsn\n"); +/* printk("s526_ao_winsn\n"); */ val = chan << 1; -// outw(val, dev->iobase + REG_DAC); +/* outw(val, dev->iobase + REG_DAC); */ outw(val, ADDR_REG(REG_DAC)); /* Writing a list of values to an AO channel is probably not * very useful, but that's how the interface is defined. */ for (i = 0; i < insn->n; i++) { /* a typical programming sequence */ -// outw(data[i], dev->iobase + REG_ADD); // write the data to preload register - outw(data[i], ADDR_REG(REG_ADD)); // write the data to preload register +/* outw(data[i], dev->iobase + REG_ADD); write the data to preload register */ + outw(data[i], ADDR_REG(REG_ADD)); /* write the data to preload register */ devpriv->ao_readback[chan] = data[i]; -// outw(val + 1, dev->iobase + REG_DAC); // starts the D/A conversion. - outw(val + 1, ADDR_REG(REG_DAC)); // starts the D/A conversion. +/* outw(val + 1, dev->iobase + REG_DAC); starts the D/A conversion. */ + outw(val + 1, ADDR_REG(REG_DAC)); /* starts the D/A conversion. */ } /* return the number of samples read/written */ @@ -898,8 +898,8 @@ static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -915,8 +915,8 @@ static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -932,16 +932,16 @@ static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic /* on return, data[1] contains the value of the digital * input and output lines. */ - data[1] = inw(ADDR_REG(REG_DIO)) & 0xFF; // low 8 bits are the data + data[1] = inw(ADDR_REG(REG_DIO)) & 0xFF; /* low 8 bits are the data */ /* or we could just return the software copy of the output values if * it was a purely digital output subdevice */ - //data[1]=s->state; + /* data[1]=s->state; */ return 2; } -static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); short value; @@ -959,10 +959,10 @@ static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdev * value COMEDI_INPUT or COMEDI_OUTPUT. */ if (data[0] == COMEDI_OUTPUT) { - value |= 1 << (chan + 10); // bit 10/11 set the group 1/2's mode + value |= 1 << (chan + 10); /* bit 10/11 set the group 1/2's mode */ s->io_bits |= (0xF << chan); } else { - value &= ~(1 << (chan + 10)); // 1 is output, 0 is input. + value &= ~(1 << (chan + 10)); /* 1 is output, 0 is input. */ s->io_bits &= ~(0xF << chan); } outw(value, ADDR_REG(REG_DIO)); diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 30dec9dab19b..5d9bab352c1d 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -68,6 +68,7 @@ INSN_CONFIG instructions: comedi_do_insn(cf,&insn); //executing configuration */ +#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/types.h> @@ -95,14 +96,14 @@ struct s626_board { static const struct s626_board s626_boards[] = { { - name: "s626", - ai_chans : S626_ADC_CHANNELS, - ai_bits: 14, - ao_chans : S626_DAC_CHANNELS, - ao_bits: 13, - dio_chans : S626_DIO_CHANNELS, - dio_banks : S626_DIO_BANKS, - enc_chans : S626_ENCODER_CHANNELS, + .name = "s626", + .ai_chans = S626_ADC_CHANNELS, + .ai_bits = 14, + .ao_chans = S626_DAC_CHANNELS, + .ao_bits = 13, + .dio_chans = S626_DIO_CHANNELS, + .dio_banks = S626_DIO_BANKS, + .enc_chans = S626_ENCODER_CHANNELS, } }; @@ -110,9 +111,13 @@ static const struct s626_board s626_boards[] = { #define PCI_VENDOR_ID_S626 0x1131 #define PCI_DEVICE_ID_S626 0x7146 +/* + * For devices with vendor:device id == 0x1131:0x7146 you must specify + * also subvendor:subdevice ids, because otherwise it will conflict with + * Philips SAA7146 media/dvb based cards. + */ static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = { - {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, PCI_ANY_ID, PCI_ANY_ID, 0, 0, - 0}, + {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0}, {0} }; @@ -122,10 +127,10 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int s626_detach(struct comedi_device *dev); static struct comedi_driver driver_s626 = { - driver_name:"s626", - module : THIS_MODULE, - attach : s626_attach, - detach : s626_detach, + .driver_name = "s626", + .module = THIS_MODULE, + .attach = s626_attach, + .detach = s626_detach, }; struct s626_private { @@ -173,39 +178,39 @@ struct dio_private { }; static struct dio_private dio_private_A = { - RDDIn:LP_RDDINA, - WRDOut : LP_WRDOUTA, - RDEdgSel : LP_RDEDGSELA, - WREdgSel : LP_WREDGSELA, - RDCapSel : LP_RDCAPSELA, - WRCapSel : LP_WRCAPSELA, - RDCapFlg : LP_RDCAPFLGA, - RDIntSel : LP_RDINTSELA, - WRIntSel : LP_WRINTSELA, + .RDDIn = LP_RDDINA, + .WRDOut = LP_WRDOUTA, + .RDEdgSel = LP_RDEDGSELA, + .WREdgSel = LP_WREDGSELA, + .RDCapSel = LP_RDCAPSELA, + .WRCapSel = LP_WRCAPSELA, + .RDCapFlg = LP_RDCAPFLGA, + .RDIntSel = LP_RDINTSELA, + .WRIntSel = LP_WRINTSELA, }; static struct dio_private dio_private_B = { - RDDIn:LP_RDDINB, - WRDOut : LP_WRDOUTB, - RDEdgSel : LP_RDEDGSELB, - WREdgSel : LP_WREDGSELB, - RDCapSel : LP_RDCAPSELB, - WRCapSel : LP_WRCAPSELB, - RDCapFlg : LP_RDCAPFLGB, - RDIntSel : LP_RDINTSELB, - WRIntSel : LP_WRINTSELB, + .RDDIn = LP_RDDINB, + .WRDOut = LP_WRDOUTB, + .RDEdgSel = LP_RDEDGSELB, + .WREdgSel = LP_WREDGSELB, + .RDCapSel = LP_RDCAPSELB, + .WRCapSel = LP_WRCAPSELB, + .RDCapFlg = LP_RDCAPFLGB, + .RDIntSel = LP_RDINTSELB, + .WRIntSel = LP_WRINTSELB, }; static struct dio_private dio_private_C = { - RDDIn:LP_RDDINC, - WRDOut : LP_WRDOUTC, - RDEdgSel : LP_RDEDGSELC, - WREdgSel : LP_WREDGSELC, - RDCapSel : LP_RDCAPSELC, - WRCapSel : LP_WRCAPSELC, - RDCapFlg : LP_RDCAPFLGC, - RDIntSel : LP_RDINTSELC, - WRIntSel : LP_WRINTSELC, + .RDDIn = LP_RDDINC, + .WRDOut = LP_WRDOUTC, + .RDEdgSel = LP_RDEDGSELC, + .WREdgSel = LP_WREDGSELC, + .RDCapSel = LP_RDCAPSELC, + .WRCapSel = LP_WRCAPSELC, + .RDCapFlg = LP_RDCAPFLGC, + .RDIntSel = LP_RDINTSELC, + .WRIntSel = LP_WRINTSELC, }; /* to group dio devices (48 bits mask and data are not allowed ???) @@ -253,7 +258,7 @@ static int s626_ns_to_timer(int *nanosec, int round_mode); static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd); static int s626_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum); -static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG); +static irqreturn_t s626_irq_handler(int irq, void *d); static unsigned int s626_ai_reg_to_uint(int data); /* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data); */ @@ -355,100 +360,100 @@ static void CountersInit(struct comedi_device *dev); /* struct enc_private; */ static struct enc_private enc_private_data[] = { { - GetEnable:GetEnable_A, - GetIntSrc : GetIntSrc_A, - GetLoadTrig : GetLoadTrig_A, - GetMode : GetMode_A, - PulseIndex : PulseIndex_A, - SetEnable : SetEnable_A, - SetIntSrc : SetIntSrc_A, - SetLoadTrig : SetLoadTrig_A, - SetMode : SetMode_A, - ResetCapFlags : ResetCapFlags_A, - MyCRA : LP_CR0A, - MyCRB : LP_CR0B, - MyLatchLsw : LP_CNTR0ALSW, - MyEventBits : EVBITS(0), + .GetEnable = GetEnable_A, + .GetIntSrc = GetIntSrc_A, + .GetLoadTrig = GetLoadTrig_A, + .GetMode = GetMode_A, + .PulseIndex = PulseIndex_A, + .SetEnable = SetEnable_A, + .SetIntSrc = SetIntSrc_A, + .SetLoadTrig = SetLoadTrig_A, + .SetMode = SetMode_A, + .ResetCapFlags = ResetCapFlags_A, + .MyCRA = LP_CR0A, + .MyCRB = LP_CR0B, + .MyLatchLsw = LP_CNTR0ALSW, + .MyEventBits = EVBITS(0), }, { - GetEnable:GetEnable_A, - GetIntSrc : GetIntSrc_A, - GetLoadTrig : GetLoadTrig_A, - GetMode : GetMode_A, - PulseIndex : PulseIndex_A, - SetEnable : SetEnable_A, - SetIntSrc : SetIntSrc_A, - SetLoadTrig : SetLoadTrig_A, - SetMode : SetMode_A, - ResetCapFlags : ResetCapFlags_A, - MyCRA : LP_CR1A, - MyCRB : LP_CR1B, - MyLatchLsw : LP_CNTR1ALSW, - MyEventBits : EVBITS(1), + .GetEnable = GetEnable_A, + .GetIntSrc = GetIntSrc_A, + .GetLoadTrig = GetLoadTrig_A, + .GetMode = GetMode_A, + .PulseIndex = PulseIndex_A, + .SetEnable = SetEnable_A, + .SetIntSrc = SetIntSrc_A, + .SetLoadTrig = SetLoadTrig_A, + .SetMode = SetMode_A, + .ResetCapFlags = ResetCapFlags_A, + .MyCRA = LP_CR1A, + .MyCRB = LP_CR1B, + .MyLatchLsw = LP_CNTR1ALSW, + .MyEventBits = EVBITS(1), }, { - GetEnable:GetEnable_A, - GetIntSrc : GetIntSrc_A, - GetLoadTrig : GetLoadTrig_A, - GetMode : GetMode_A, - PulseIndex : PulseIndex_A, - SetEnable : SetEnable_A, - SetIntSrc : SetIntSrc_A, - SetLoadTrig : SetLoadTrig_A, - SetMode : SetMode_A, - ResetCapFlags : ResetCapFlags_A, - MyCRA : LP_CR2A, - MyCRB : LP_CR2B, - MyLatchLsw : LP_CNTR2ALSW, - MyEventBits : EVBITS(2), + .GetEnable = GetEnable_A, + .GetIntSrc = GetIntSrc_A, + .GetLoadTrig = GetLoadTrig_A, + .GetMode = GetMode_A, + .PulseIndex = PulseIndex_A, + .SetEnable = SetEnable_A, + .SetIntSrc = SetIntSrc_A, + .SetLoadTrig = SetLoadTrig_A, + .SetMode = SetMode_A, + .ResetCapFlags = ResetCapFlags_A, + .MyCRA = LP_CR2A, + .MyCRB = LP_CR2B, + .MyLatchLsw = LP_CNTR2ALSW, + .MyEventBits = EVBITS(2), }, { - GetEnable:GetEnable_B, - GetIntSrc : GetIntSrc_B, - GetLoadTrig : GetLoadTrig_B, - GetMode : GetMode_B, - PulseIndex : PulseIndex_B, - SetEnable : SetEnable_B, - SetIntSrc : SetIntSrc_B, - SetLoadTrig : SetLoadTrig_B, - SetMode : SetMode_B, - ResetCapFlags : ResetCapFlags_B, - MyCRA : LP_CR0A, - MyCRB : LP_CR0B, - MyLatchLsw : LP_CNTR0BLSW, - MyEventBits : EVBITS(3), + .GetEnable = GetEnable_B, + .GetIntSrc = GetIntSrc_B, + .GetLoadTrig = GetLoadTrig_B, + .GetMode = GetMode_B, + .PulseIndex = PulseIndex_B, + .SetEnable = SetEnable_B, + .SetIntSrc = SetIntSrc_B, + .SetLoadTrig = SetLoadTrig_B, + .SetMode = SetMode_B, + .ResetCapFlags = ResetCapFlags_B, + .MyCRA = LP_CR0A, + .MyCRB = LP_CR0B, + .MyLatchLsw = LP_CNTR0BLSW, + .MyEventBits = EVBITS(3), }, { - GetEnable:GetEnable_B, - GetIntSrc : GetIntSrc_B, - GetLoadTrig : GetLoadTrig_B, - GetMode : GetMode_B, - PulseIndex : PulseIndex_B, - SetEnable : SetEnable_B, - SetIntSrc : SetIntSrc_B, - SetLoadTrig : SetLoadTrig_B, - SetMode : SetMode_B, - ResetCapFlags : ResetCapFlags_B, - MyCRA : LP_CR1A, - MyCRB : LP_CR1B, - MyLatchLsw : LP_CNTR1BLSW, - MyEventBits : EVBITS(4), + .GetEnable = GetEnable_B, + .GetIntSrc = GetIntSrc_B, + .GetLoadTrig = GetLoadTrig_B, + .GetMode = GetMode_B, + .PulseIndex = PulseIndex_B, + .SetEnable = SetEnable_B, + .SetIntSrc = SetIntSrc_B, + .SetLoadTrig = SetLoadTrig_B, + .SetMode = SetMode_B, + .ResetCapFlags = ResetCapFlags_B, + .MyCRA = LP_CR1A, + .MyCRB = LP_CR1B, + .MyLatchLsw = LP_CNTR1BLSW, + .MyEventBits = EVBITS(4), }, { - GetEnable:GetEnable_B, - GetIntSrc : GetIntSrc_B, - GetLoadTrig : GetLoadTrig_B, - GetMode : GetMode_B, - PulseIndex : PulseIndex_B, - SetEnable : SetEnable_B, - SetIntSrc : SetIntSrc_B, - SetLoadTrig : SetLoadTrig_B, - SetMode : SetMode_B, - ResetCapFlags : ResetCapFlags_B, - MyCRA : LP_CR2A, - MyCRB : LP_CR2B, - MyLatchLsw : LP_CNTR2BLSW, - MyEventBits : EVBITS(5), + .GetEnable = GetEnable_B, + .GetIntSrc = GetIntSrc_B, + .GetLoadTrig = GetLoadTrig_B, + .GetMode = GetMode_B, + .PulseIndex = PulseIndex_B, + .SetEnable = SetEnable_B, + .SetIntSrc = SetIntSrc_B, + .SetLoadTrig = SetLoadTrig_B, + .SetMode = SetMode_B, + .ResetCapFlags = ResetCapFlags_B, + .MyCRA = LP_CR2A, + .MyCRB = LP_CR2B, + .MyLatchLsw = LP_CNTR2BLSW, + .MyEventBits = EVBITS(5), }, }; @@ -498,25 +503,26 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) resource_size_t resourceStart; dma_addr_t appdma; struct comedi_subdevice *s; - struct pci_dev *pdev; + const struct pci_device_id *ids; + struct pci_dev *pdev = NULL; if (alloc_private(dev, sizeof(struct s626_private)) < 0) return -ENOMEM; - for (pdev = pci_get_device(PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, - NULL); pdev != NULL; - pdev = pci_get_device(PCI_VENDOR_ID_S626, - PCI_DEVICE_ID_S626, pdev)) { - if (it->options[0] || it->options[1]) { - if (pdev->bus->number == it->options[0] && - PCI_SLOT(pdev->devfn) == it->options[1]) { + for (i = 0; i < (ARRAY_SIZE(s626_pci_table) - 1) && !pdev; i++) { + ids = &s626_pci_table[i]; + do { + pdev = pci_get_subsys(ids->vendor, ids->device, ids->subvendor, + ids->subdevice, pdev); + + if ((it->options[0] || it->options[1]) && pdev) { /* matches requested bus/slot */ + if (pdev->bus->number == it->options[0] && + PCI_SLOT(pdev->devfn) == it->options[1]) + break; + } else break; - } - } else { - /* no bus/slot specified */ - break; - } + } while (1); } devpriv->pdev = pdev; @@ -596,8 +602,8 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (dev->irq == 0) { printk(" unknown irq (bad)\n"); } else { - ret = comedi_request_irq(dev->irq, s626_irq_handler, - IRQF_SHARED, "s626", dev); + ret = request_irq(dev->irq, s626_irq_handler, IRQF_SHARED, + "s626", dev); if (ret < 0) { printk(" irq not available\n"); @@ -968,7 +974,7 @@ static unsigned int s626_ai_reg_to_uint(int data) /* return 0; */ /* } */ -static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG) +static irqreturn_t s626_irq_handler(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s; @@ -987,7 +993,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG) if (dev->attached == 0) return IRQ_NONE; /* lock to avoid race with comedi_poll */ - comedi_spin_lock_irqsave(&dev->spinlock, flags); + spin_lock_irqsave(&dev->spinlock, flags); /* save interrupt enable register state */ irqstatus = readl(devpriv->base_addr + P_IER); @@ -1264,7 +1270,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG) DEBUG("s626_irq_handler: exit interrupt service routine.\n"); - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); + spin_unlock_irqrestore(&dev->spinlock, flags); return IRQ_HANDLED; } @@ -1291,7 +1297,7 @@ static int s626_detach(struct comedi_device *dev) } if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); if (devpriv->base_addr) iounmap(devpriv->base_addr); @@ -1574,7 +1580,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice for (n = 0; n < insn->n; n++) { /* Delay 10 microseconds for analog input settling. */ - comedi_udelay(10); + udelay(10); /* Start ADC by pulsing GPIO1 low. */ GpioImage = RR7146(P_GPIO); @@ -1606,7 +1612,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice * data value is sometimes set to the previous * conversion's data value. */ - comedi_udelay(4); + udelay(4); } /* Start a dummy conversion to cause the data from the @@ -1886,31 +1892,16 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } - if (cmd->start_src == TRIG_EXT && cmd->start_arg < 0) { - cmd->start_arg = 0; - err++; - } - if (cmd->start_src == TRIG_EXT && cmd->start_arg > 39) { cmd->start_arg = 39; err++; } - if (cmd->scan_begin_src == TRIG_EXT && cmd->scan_begin_arg < 0) { - cmd->scan_begin_arg = 0; - err++; - } - if (cmd->scan_begin_src == TRIG_EXT && cmd->scan_begin_arg > 39) { cmd->scan_begin_arg = 39; err++; } - if (cmd->convert_src == TRIG_EXT && cmd->convert_arg < 0) { - cmd->convert_arg = 0; - err++; - } - if (cmd->convert_src == TRIG_EXT && cmd->convert_arg > 39) { cmd->convert_arg = 39; err++; @@ -2373,7 +2364,7 @@ static void LoadTrimDACs(struct comedi_device *dev) register uint8_t i; /* Copy TrimDac setpoint values from EEPROM to TrimDacs. */ - for (i = 0; i < (sizeof(trimchan) / sizeof(trimchan[0])); i++) + for (i = 0; i < ARRAY_SIZE(trimchan); i++) WriteTrimDAC(dev, i, I2Cread(dev, trimadrs[i])); } diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h index 891126f25099..27ae02be5300 100644 --- a/drivers/staging/comedi/drivers/s626.h +++ b/drivers/staging/comedi/drivers/s626.h @@ -63,7 +63,7 @@ */ #ifdef _DEBUG_ -#define DEBUG(...); rt_printk(__VA_ARGS__); +#define DEBUG(...); printk(__VA_ARGS__); #else #define DEBUG(...) #endif diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 844fd5e2e3a9..db18b11b9d30 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -52,7 +52,7 @@ struct serial2002_board { static const struct serial2002_board serial2002_boards[] = { { - name: "serial2002"} + .name = "serial2002"} }; /* @@ -62,7 +62,7 @@ static const struct serial2002_board serial2002_boards[] = { struct serial2002_range_table_t { - // HACK... + /* HACK... */ int length; struct comedi_krange range; }; @@ -70,8 +70,8 @@ struct serial2002_range_table_t { struct serial2002_private { - int port; // /dev/ttyS<port> - int speed; // baudrate + int port; /* /dev/ttyS<port> */ + int speed; /* baudrate */ struct file *tty; unsigned int ao_readback[32]; unsigned char digital_in_mapping[32]; @@ -89,28 +89,28 @@ struct serial2002_private { */ #define devpriv ((struct serial2002_private *)dev->private) -static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int serial2002_detach(struct comedi_device * dev); +static int serial2002_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int serial2002_detach(struct comedi_device *dev); struct comedi_driver driver_serial2002 = { - driver_name:"serial2002", - module:THIS_MODULE, - attach:serial2002_attach, - detach:serial2002_detach, - board_name:&serial2002_boards[0].name, - offset:sizeof(struct serial2002_board), - num_names:sizeof(serial2002_boards) / sizeof(struct serial2002_board), + .driver_name = "serial2002", + .module = THIS_MODULE, + .attach = serial2002_attach, + .detach = serial2002_detach, + .board_name = &serial2002_boards[0].name, + .offset = sizeof(struct serial2002_board), + .num_names = ARRAY_SIZE(serial2002_boards), }; -static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); +static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int serial2002_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int serial2002_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int serial2002_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int serial2002_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); struct serial_data { enum { is_invalid, is_digital, is_channel } kind; @@ -121,12 +121,12 @@ struct serial_data { static long tty_ioctl(struct file *f, unsigned op, unsigned long param) { #ifdef HAVE_UNLOCKED_IOCTL - if (f->f_op->unlocked_ioctl) { + if (f->f_op->unlocked_ioctl) { return f->f_op->unlocked_ioctl(f, op, param); } #endif if (f->f_op->ioctl) { - return f->f_op->ioctl(f->f_dentry->d_inode, f, op, param); + return f->f_op->ioctl(f->f_dentry->d_inode, f, op, param); } return -ENOSYS; } @@ -211,7 +211,7 @@ static int tty_read(struct file *f, int timeout) /* Device does not support poll, busy wait */ int retries = 0; while (1) { - unsigned char ch; + unsigned char ch; retries++; if (retries >= timeout) { @@ -220,10 +220,10 @@ static int tty_read(struct file *f, int timeout) f->f_pos = 0; if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) { - result = ch; + result = ch; break; } - comedi_udelay(100); + udelay(100); } } set_fs(oldfs); @@ -238,11 +238,11 @@ static void tty_setspeed(struct file *f, int speed) oldfs = get_fs(); set_fs(KERNEL_DS); { - // Set speed + /* Set speed */ struct termios settings; tty_ioctl(f, TCGETS, (unsigned long)&settings); -// printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); +/* printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); */ settings.c_iflag = 0; settings.c_oflag = 0; settings.c_lflag = 0; @@ -284,10 +284,10 @@ static void tty_setspeed(struct file *f, int speed) break; } tty_ioctl(f, TCSETS, (unsigned long)&settings); -// printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); +/* printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); */ } { - // Set low latency + /* Set low latency */ struct serial_struct settings; tty_ioctl(f, TIOCGSERIAL, (unsigned long)&settings); @@ -393,7 +393,7 @@ static void serial_write(struct file *f, struct serial_data data) } } -static void serial_2002_open(struct comedi_device * dev) +static void serial_2002_open(struct comedi_device *dev) { char port[20]; @@ -437,7 +437,7 @@ static void serial_2002_open(struct comedi_device * dev) } tty_setspeed(devpriv->tty, devpriv->speed); - poll_channel(devpriv->tty, 31); // Start reading configuration + poll_channel(devpriv->tty, 31); /* Start reading configuration */ while (1) { struct serial_data data; @@ -557,7 +557,7 @@ static void serial_2002_open(struct comedi_device * dev) } } for (i = 0; i <= 4; i++) { - // Fill in subdev data + /* Fill in subdev data */ struct config_t *c; unsigned char *mapping = 0; struct serial2002_range_table_t *range = 0; @@ -659,15 +659,15 @@ static void serial_2002_open(struct comedi_device * dev) } } -static void serial_2002_close(struct comedi_device * dev) +static void serial_2002_close(struct comedi_device *dev) { if (!IS_ERR(devpriv->tty) && (devpriv->tty != 0)) { filp_close(devpriv->tty, 0); } } -static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan; @@ -688,8 +688,8 @@ static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan; @@ -706,8 +706,8 @@ static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan; @@ -728,8 +728,8 @@ static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan; @@ -747,8 +747,8 @@ static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan = CR_CHAN(insn->chanspec); @@ -760,8 +760,8 @@ static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_ei_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int serial2002_ei_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; int chan; @@ -782,7 +782,7 @@ static int serial2002_ei_rinsn(struct comedi_device * dev, struct comedi_subdevi return n; } -static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int serial2002_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; @@ -849,7 +849,7 @@ static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig return 1; } -static int serial2002_detach(struct comedi_device * dev) +static int serial2002_detach(struct comedi_device *dev) { struct comedi_subdevice *s; int i; diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index c7700d134cc1..07f580a48206 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -97,16 +97,16 @@ struct skel_board { static const struct skel_board skel_boards[] = { { - name: "skel-100", - ai_chans:16, - ai_bits: 12, - have_dio:1, + .name = "skel-100", + .ai_chans = 16, + .ai_bits = 12, + .have_dio = 1, }, { - name: "skel-200", - ai_chans:8, - ai_bits: 16, - have_dio:0, + .name = "skel-200", + .ai_chans = 8, + .ai_bits = 16, + .have_dio = 0, }, }; @@ -154,13 +154,13 @@ struct skel_private { * the board, and also about the kernel module that contains * the device code. */ -static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int skel_detach(struct comedi_device * dev); +static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int skel_detach(struct comedi_device *dev); static struct comedi_driver driver_skel = { - driver_name:"dummy", - module:THIS_MODULE, - attach:skel_attach, - detach:skel_detach, + .driver_name = "dummy", + .module = THIS_MODULE, + .attach = skel_attach, + .detach = skel_detach, /* It is not necessary to implement the following members if you are * writing a driver for a ISA PnP or PCI card */ /* Most drivers will support multiple types of boards by @@ -179,23 +179,23 @@ static struct comedi_driver driver_skel = { * the type of board in software. ISA PnP, PCI, and PCMCIA * devices are such boards. */ - board_name:&skel_boards[0].name, - offset:sizeof(struct skel_board), - num_names:sizeof(skel_boards) / sizeof(struct skel_board), + .board_name = &skel_boards[0].name, + .offset = sizeof(struct skel_board), + .num_names = ARRAY_SIZE(skel_boards), }; -static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int skel_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data); -static int skel_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); +static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int skel_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); static int skel_ns_to_timer(unsigned int *ns, int round); /* @@ -204,7 +204,7 @@ static int skel_ns_to_timer(unsigned int *ns, int round); * in the driver structure, dev->board_ptr contains that * address. */ -static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; @@ -292,7 +292,7 @@ static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it) * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int skel_detach(struct comedi_device * dev) +static int skel_detach(struct comedi_device *dev) { printk("comedi%d: skel: remove\n", dev->minor); @@ -303,8 +303,8 @@ static int skel_detach(struct comedi_device * dev) * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, i; unsigned int d; @@ -331,9 +331,9 @@ static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s break; } if (i == TIMEOUT) { - /* rt_printk() should be used instead of printk() + /* printk() should be used instead of printk() * whenever the code can be called from real-time. */ - rt_printk("timeout\n"); + printk("timeout\n"); return -ETIMEDOUT; } @@ -351,8 +351,8 @@ static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s return n; } -static int skel_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -520,8 +520,8 @@ static int skel_ns_to_timer(unsigned int *ns, int round) return *ns; } -static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -541,8 +541,8 @@ static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -558,8 +558,8 @@ static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int skel_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -583,8 +583,8 @@ static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic return 2; } -static int skel_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 1628d216cdd4..13c29bb99100 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -61,10 +61,10 @@ struct dnp_board { static const struct dnp_board dnp_boards[] = { /* we only support one DNP 'board' */ { /* variant at the moment */ - name: "dnp-1486", - ai_chans:16, - ai_bits: 12, - have_dio:1, + .name = "dnp-1486", + .ai_chans = 16, + .ai_bits = 12, + .have_dio = 1, }, }; @@ -74,7 +74,6 @@ static const struct dnp_board dnp_boards[] = { /* we only support one DNP 'board /* This structure is for data unique to the DNP driver --------------------- */ struct dnp_private_data { - // }; @@ -89,27 +88,27 @@ struct dnp_private_data { /* In the following section we define the API of this driver. */ /* ------------------------------------------------------------------------- */ -static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int dnp_detach(struct comedi_device * dev); +static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dnp_detach(struct comedi_device *dev); static struct comedi_driver driver_dnp = { - driver_name:"ssv_dnp", - module:THIS_MODULE, - attach:dnp_attach, - detach:dnp_detach, - board_name:&dnp_boards[0].name, + .driver_name = "ssv_dnp", + .module = THIS_MODULE, + .attach = dnp_attach, + .detach = dnp_detach, + .board_name = &dnp_boards[0].name, /* only necessary for non-PnP devs */ - offset:sizeof(struct dnp_board),/* like ISA-PnP, PCI or PCMCIA. */ - num_names:sizeof(dnp_boards) / sizeof(struct dnp_board), + .offset = sizeof(struct dnp_board),/* like ISA-PnP, PCI or PCMCIA. */ + .num_names = ARRAY_SIZE(dnp_boards), }; COMEDI_INITCLEANUP(driver_dnp); -static int dnp_dio_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int dnp_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int dnp_dio_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data); +static int dnp_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* ------------------------------------------------------------------------- */ /* Attach is called by comedi core to configure the driver for a particular */ @@ -117,7 +116,7 @@ static int dnp_dio_insn_config(struct comedi_device * dev, /* dev->board_ptr contains that address. */ /* ------------------------------------------------------------------------- */ -static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; @@ -126,7 +125,7 @@ static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it) /* Autoprobing: this should find out which board we have. Currently only */ /* the 1486 board is supported and autoprobing is not implemented :-) */ - //dev->board_ptr = dnp_probe(dev); + /* dev->board_ptr = dnp_probe(dev); */ /* Initialize the name of the board. We can use the "thisboard" macro now. */ dev->board_name = thisboard->name; @@ -178,7 +177,7 @@ static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it) /* deallocated automatically by the core. */ /* ------------------------------------------------------------------------- */ -static int dnp_detach(struct comedi_device * dev) +static int dnp_detach(struct comedi_device *dev) { /* configure all ports as input (default) */ @@ -202,8 +201,8 @@ static int dnp_detach(struct comedi_device * dev) /* are able to use these instructions as well. */ /* ------------------------------------------------------------------------- */ -static int dnp_dio_insn_bits(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int dnp_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) @@ -252,8 +251,8 @@ static int dnp_dio_insn_bits(struct comedi_device * dev, /* COMEDI_INPUT or COMEDI_OUTPUT. */ /* ------------------------------------------------------------------------- */ -static int dnp_dio_insn_config(struct comedi_device * dev, - struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data) +static int dnp_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { u8 register_buffer; diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index dd3b1119319b..96bb15ccccb1 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -80,38 +80,38 @@ struct unioxx5_subd_priv { unsigned char usp_prev_cn_val[3]; /* previous channel value */ }; -static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data); -static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data); -static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data); -static int unioxx5_detach(struct comedi_device * dev); -static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_iobase, +static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int unioxx5_subdev_write(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data); +static int unioxx5_subdev_read(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data); +static int unioxx5_insn_config(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data); +static int unioxx5_detach(struct comedi_device *dev); +static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iobase, int minor); -static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor); -static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor); -//static void __unioxx5_digital_config(struct unioxx5_subd_priv* usp, int mode); -static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * data, +/* static void __unioxx5_digital_config(struct unioxx5_subd_priv* usp, int mode); */ +static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor); -static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor); static int __unioxx5_define_chan_offset(int chan_num); -static void __unioxx5_analog_config(struct unioxx5_subd_priv * usp, int channel); +static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel); static struct comedi_driver unioxx5_driver = { - driver_name:DRIVER_NAME, - module:THIS_MODULE, - attach:unioxx5_attach, - detach:unioxx5_detach + .driver_name = DRIVER_NAME, + .module = THIS_MODULE, + .attach = unioxx5_attach, + .detach = unioxx5_detach }; COMEDI_INITCLEANUP(unioxx5_driver); -static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it) { int iobase, i, n_subd; int id, num, ba; @@ -156,8 +156,8 @@ static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data) +static int unioxx5_subdev_read(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data) { struct unioxx5_subd_priv *usp = subdev->private; int channel, type; @@ -176,8 +176,8 @@ static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevi return 1; } -static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data) +static int unioxx5_subdev_write(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data) { struct unioxx5_subd_priv *usp = subdev->private; int channel, type; @@ -197,8 +197,8 @@ static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdev } /* for digital modules only */ -static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevice * subdev, - struct comedi_insn * insn, unsigned int * data) +static int unioxx5_insn_config(struct comedi_device *dev, struct comedi_subdevice *subdev, + struct comedi_insn *insn, unsigned int *data) { int channel_offset, flags, channel = CR_CHAN(insn->chanspec), type; struct unioxx5_subd_priv *usp = subdev->private; @@ -213,7 +213,8 @@ static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevi return -1; } - if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) { + channel_offset = __unioxx5_define_chan_offset(channel); + if (channel_offset < 0) { printk(KERN_ERR "comedi%d: undefined channel %d. channel range is 0 .. 23\n", dev->minor, channel); @@ -247,7 +248,7 @@ static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int unioxx5_detach(struct comedi_device * dev) +static int unioxx5_detach(struct comedi_device *dev) { int i; struct comedi_subdevice *subdev; @@ -264,7 +265,7 @@ static int unioxx5_detach(struct comedi_device * dev) } /* initializing subdevice with given address */ -static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_iobase, +static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iobase, int minor) { struct unioxx5_subd_priv *usp; @@ -275,8 +276,9 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io return -EIO; } - if ((usp = (struct unioxx5_subd_priv *) kzalloc(sizeof(*usp), - GFP_KERNEL)) == NULL) { + usp = (struct unioxx5_subd_priv *) kzalloc(sizeof(*usp), GFP_KERNEL); + + if (usp == NULL) { printk(KERN_ERR "comedi%d: erorr! --> out of memory!\n", minor); return -1; } @@ -309,7 +311,7 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io usp->usp_module_type[i] = inb(subdev_iobase + 6); printk(" [%d] 0x%02x |", i, usp->usp_module_type[i]); - comedi_udelay(1); + udelay(1); } printk("\n"); @@ -330,13 +332,14 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io return 0; } -static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor) { int channel_offset, val; int mask = 1 << (channel & 0x07); - if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) { + channel_offset = __unioxx5_define_chan_offset(channel); + if (channel_offset < 0) { printk(KERN_ERR "comedi%d: undefined channel %d. channel range is 0 .. 23\n", minor, channel); @@ -357,12 +360,13 @@ static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int } /* function for digital reading */ -static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor) { int channel_offset, mask = 1 << (channel & 0x07); - if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) { + channel_offset = __unioxx5_define_chan_offset(channel); + if (channel_offset < 0) { printk(KERN_ERR "comedi%d: undefined channel %d. channel range is 0 .. 23\n", minor, channel); @@ -380,7 +384,7 @@ static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int * } #if 0 /* not used? */ -static void __unioxx5_digital_config(struct unioxx5_subd_priv * usp, int mode) +static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp, int mode) { int i, mask; @@ -396,7 +400,7 @@ static void __unioxx5_digital_config(struct unioxx5_subd_priv * usp, int mode) } #endif -static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor) { int module, i; @@ -418,7 +422,7 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * /* saving major byte */ usp->usp_extra_data[module][i] = (unsigned char)((*data & 0xFF00) >> 8); - //while(!((inb(usp->usp_iobase + 0)) & TxBE)); + /* while(!((inb(usp->usp_iobase + 0)) & TxBE)); */ outb(module + 1, usp->usp_iobase + 5); /* sending module number to card(1 .. 12) */ outb('W', usp->usp_iobase + 6); /* sends (W)rite command to module */ @@ -431,7 +435,7 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * return 1; } -static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int * data, +static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *data, int channel, int minor) { int module_no, read_ch; @@ -471,7 +475,7 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int * } /* configure channels for analog i/o (even to output, odd to input) */ -static void __unioxx5_analog_config(struct unioxx5_subd_priv * usp, int channel) +static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel) { int chan_a, chan_b, conf, channel_offset; diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index d0b59e98314b..171a6f2ff74f 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -509,14 +509,19 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb) for (i = 0; i < n; i++) { /* transfer data */ if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { - comedi_buf_put + err = comedi_buf_put (s->async, - le16_to_cpu(this_usbduxsub-> - inBuffer[i]) ^ 0x800); + le16_to_cpu(this_usbduxsub-> + inBuffer[i]) ^ 0x800); } else { - comedi_buf_put + err = comedi_buf_put (s->async, - le16_to_cpu(this_usbduxsub->inBuffer[i])); + le16_to_cpu(this_usbduxsub->inBuffer[i])); + } + if (unlikely(err == 0)) { + /* buffer overflow */ + usbdux_ai_stop(this_usbduxsub, 0); + return; } } /* tell comedi that data is there */ @@ -809,32 +814,56 @@ static int usbduxsub_upload(struct usbduxsub *usbduxsub, return 0; } -static int firmwareUpload(struct usbduxsub *usbduxsub, uint8_t *firmwareBinary, +#define FIRMWARE_MAX_LEN 0x2000 + +static int firmwareUpload(struct usbduxsub *usbduxsub, + const u8 *firmwareBinary, int sizeFirmware) { int ret; + uint8_t *fwBuf; if (!firmwareBinary) return 0; + if (sizeFirmware>FIRMWARE_MAX_LEN) { + dev_err(&usbduxsub->interface->dev, + "comedi_: usbdux firmware binary it too large for FX2.\n"); + return -ENOMEM; + } + + /* we generate a local buffer for the firmware */ + fwBuf = kzalloc(sizeFirmware, GFP_KERNEL); + if (!fwBuf) { + dev_err(&usbduxsub->interface->dev, + "comedi_: mem alloc for firmware failed\n"); + return -ENOMEM; + } + memcpy(fwBuf,firmwareBinary,sizeFirmware); + ret = usbduxsub_stop(usbduxsub); if (ret < 0) { dev_err(&usbduxsub->interface->dev, "comedi_: can not stop firmware\n"); + kfree(fwBuf); return ret; } - ret = usbduxsub_upload(usbduxsub, firmwareBinary, 0, sizeFirmware); + + ret = usbduxsub_upload(usbduxsub, fwBuf, 0, sizeFirmware); if (ret < 0) { dev_err(&usbduxsub->interface->dev, "comedi_: firmware upload failed\n"); + kfree(fwBuf); return ret; } ret = usbduxsub_start(usbduxsub); if (ret < 0) { dev_err(&usbduxsub->interface->dev, "comedi_: can not start firmware\n"); + kfree(fwBuf); return ret; } + kfree(fwBuf); return 0; } @@ -2260,134 +2289,6 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp) usbduxsub_tmp->pwm_cmd_running = 0; } -static unsigned hex2unsigned(char *h) -{ - unsigned hi, lo; - - if (h[0] > '9') - hi = h[0] - 'A' + 0x0a; - else - hi = h[0] - '0'; - - if (h[1] > '9') - lo = h[1] - 'A' + 0x0a; - else - lo = h[1] - '0'; - - return hi * 0x10 + lo; -} - -/* for FX2 */ -#define FIRMWARE_MAX_LEN 0x2000 - -/* taken from David Brownell's fxload and adjusted for this driver */ -static int read_firmware(struct usbduxsub *usbduxsub, const void *firmwarePtr, - long size) -{ - struct device *dev = &usbduxsub->interface->dev; - int i = 0; - unsigned char *fp = (char *)firmwarePtr; - unsigned char *firmwareBinary; - int res = 0; - int maxAddr = 0; - - firmwareBinary = kzalloc(FIRMWARE_MAX_LEN, GFP_KERNEL); - if (!firmwareBinary) { - dev_err(dev, "comedi_: mem alloc for firmware failed\n"); - return -ENOMEM; - } - - for (;;) { - char buf[256], *cp; - char type; - int len; - int idx, off; - int j = 0; - - /* get one line */ - while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) { - buf[j] = fp[i]; - i++; - j++; - if (j >= sizeof(buf)) { - dev_err(dev, "comedi_: bogus firmware file!\n"); - kfree(firmwareBinary); - return -1; - } - } - /* get rid of LF/CR/... */ - while ((i < size) && ((fp[i] == 13) || (fp[i] == 10) - || (fp[i] == 0))) { - i++; - } - - buf[j] = 0; - /* dev_dbg(dev, "comedi_: buf=%s\n", buf); */ - - /* - * EXTENSION: - * "# comment-till-end-of-line", for copyrights etc - */ - if (buf[0] == '#') - continue; - - if (buf[0] != ':') { - dev_err(dev, "comedi_: upload: not an ihex record: %s", - buf); - kfree(firmwareBinary); - return -EFAULT; - } - - /* Read the length field (up to 16 bytes) */ - len = hex2unsigned(buf + 1); - - /* Read the target offset */ - off = (hex2unsigned(buf + 3) * 0x0100) + hex2unsigned(buf + 5); - - if ((off + len) > maxAddr) - maxAddr = off + len; - - - if (maxAddr >= FIRMWARE_MAX_LEN) { - dev_err(dev, "comedi_: firmware upload goes " - "beyond FX2 RAM boundaries.\n"); - kfree(firmwareBinary); - return -EFAULT; - } - /* dev_dbg(dev, "comedi_: off=%x, len=%x:\n", off, len); */ - - /* Read the record type */ - type = hex2unsigned(buf + 7); - - /* If this is an EOF record, then make it so. */ - if (type == 1) - break; - - - if (type != 0) { - dev_err(dev, "comedi_: unsupported record type: %u\n", - type); - kfree(firmwareBinary); - return -EFAULT; - } - - for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) { - firmwareBinary[idx + off] = hex2unsigned(cp); - /*printk("%02x ",firmwareBinary[idx+off]); */ - } - /*printk("\n"); */ - - if (i >= size) { - dev_err(dev, "comedi_: unexpected end of hex file\n"); - break; - } - - } - res = firmwareUpload(usbduxsub, firmwareBinary, maxAddr + 1); - kfree(firmwareBinary); - return res; -} - static void usbdux_firmware_request_complete_handler(const struct firmware *fw, void *context) { @@ -2405,7 +2306,7 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw, * we need to upload the firmware here because fw will be * freed once we've left this function */ - ret = read_firmware(usbduxsub_tmp, fw->data, fw->size); + ret = firmwareUpload(usbduxsub_tmp, fw->data, fw->size); if (ret) { dev_err(&usbdev->dev, @@ -2662,11 +2563,13 @@ static int usbduxsub_probe(struct usb_interface *uinterf, ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - "usbdux_firmware.hex", + "usbdux_firmware.bin", &udev->dev, usbduxsub + index, usbdux_firmware_request_complete_handler); + + if (ret) { dev_err(dev, "Could not load firmware (err=%d)\n", ret); return ret; @@ -2739,8 +2642,8 @@ static int usbdux_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* trying to upload the firmware into the chip */ if (comedi_aux_data(it->options, 0) && it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { - read_firmware(udev, comedi_aux_data(it->options, 0), - it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]); + firmwareUpload(udev, comedi_aux_data(it->options, 0), + it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]); } dev->board_name = BOARDNAME; diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 2fb64de3f86b..939b53fa569c 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -314,7 +314,7 @@ static int usbduxfast_ai_cancel(struct comedi_device *dev, struct comedi_subdevi * analogue IN * interrupt service routine */ -static void usbduxfastsub_ai_Irq(struct urb *urb PT_REGS_ARG) +static void usbduxfastsub_ai_Irq(struct urb *urb) { int n, err; struct usbduxfastsub_s *udfs; @@ -406,7 +406,7 @@ static void usbduxfastsub_ai_Irq(struct urb *urb PT_REGS_ARG) udfs->ai_sample_count * sizeof(uint16_t)); usbduxfast_ai_stop(udfs, 0); - /* say comedi that the acquistion is over */ + /* tell comedi that the acquistion is over */ s->async->events |= COMEDI_CB_EOA; comedi_event(udfs->comedidev, s); return; @@ -414,8 +414,13 @@ static void usbduxfastsub_ai_Irq(struct urb *urb PT_REGS_ARG) udfs->ai_sample_count -= n; } /* write the full buffer to comedi */ - cfc_write_array_to_buffer(s, urb->transfer_buffer, - urb->actual_length); + err = cfc_write_array_to_buffer(s, urb->transfer_buffer, + urb->actual_length); + if (unlikely(err == 0)) { + /* buffer overflow */ + usbduxfast_ai_stop(udfs, 0); + return; + } /* tell comedi that data is there */ comedi_event(udfs->comedidev, s); @@ -524,33 +529,6 @@ static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs, return 0; } -int firmwareUpload(struct usbduxfastsub_s *udfs, unsigned char *firmwareBinary, - int sizeFirmware) -{ - int ret; - - if (!firmwareBinary) - return 0; - - ret = usbduxfastsub_stop(udfs); - if (ret < 0) { - printk(KERN_ERR "comedi_: usbduxfast: can not stop firmware\n"); - return ret; - } - ret = usbduxfastsub_upload(udfs, firmwareBinary, 0, sizeFirmware); - if (ret < 0) { - printk(KERN_ERR "comedi_: usbduxfast: firmware upload failed\n"); - return ret; - } - ret = usbduxfastsub_start(udfs); - if (ret < 0) { - printk(KERN_ERR "comedi_: usbduxfast: can not start firmware\n"); - return ret; - } - - return 0; -} - int usbduxfastsub_submit_InURBs(struct usbduxfastsub_s *udfs) { int ret; @@ -1365,136 +1343,61 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev, return i; } -static unsigned hex2unsigned(char *h) -{ - unsigned hi, lo; - - if (h[0] > '9') - hi = h[0] - 'A' + 0x0a; - else - hi = h[0] - '0'; - - if (h[1] > '9') - lo = h[1] - 'A' + 0x0a; - else - lo = h[1] - '0'; - - return hi * 0x10 + lo; -} - -/* for FX2 */ #define FIRMWARE_MAX_LEN 0x2000 -/* - * taken from David Brownell's fxload and adjusted for this driver - */ -static int read_firmware(struct usbduxfastsub_s *udfs, const void *firmwarePtr, - long size) +static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub, + const u8 *firmwareBinary, + int sizeFirmware) { - int i = 0; - unsigned char *fp = (char *)firmwarePtr; - unsigned char *firmwareBinary; - int res = 0; - int maxAddr = 0; - - firmwareBinary = kmalloc(FIRMWARE_MAX_LEN, GFP_KERNEL); - if (!firmwareBinary) { - printk(KERN_ERR "comedi_: usbduxfast: mem alloc for firmware " - " failed\n"); - return -ENOMEM; - } - - for (;;) { - char buf[256], *cp; - char type; - int len; - int idx, off; - int j = 0; - - /* get one line */ - while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) { - buf[j] = fp[i]; - i++; - j++; - if (j >= sizeof(buf)) { - printk(KERN_ERR "comedi_: usbduxfast: bogus " - "firmware file!\n"); - kfree(firmwareBinary); - return -1; - } - } - /* get rid of LF/CR/... */ - while ((i < size) && ((fp[i] == 13) || (fp[i] == 10) - || (fp[i] == 0))) - i++; - - buf[j] = 0; - /* printk("comedi_: buf=%s\n",buf); */ - - /* - * EXTENSION: "# comment-till-end-of-line", - * for copyrights etc - */ - if (buf[0] == '#') - continue; - - if (buf[0] != ':') { - printk(KERN_ERR "comedi_: usbduxfast: upload: not an " - "ihex record: %s", buf); - kfree(firmwareBinary); - return -EFAULT; - } - - /* Read the length field (up to 16 bytes) */ - len = hex2unsigned(buf + 1); - - /* Read the target offset */ - off = (hex2unsigned(buf + 3) * 0x0100) + hex2unsigned(buf + 5); - - if ((off + len) > maxAddr) - maxAddr = off + len; - - if (maxAddr >= FIRMWARE_MAX_LEN) { - printk(KERN_ERR "comedi_: usbduxfast: firmware upload " - "goes beyond FX2 RAM boundaries."); - kfree(firmwareBinary); - return -EFAULT; - } - /* printk("comedi_: usbduxfast: off=%x, len=%x:",off,len); */ - - /* Read the record type */ - type = hex2unsigned(buf + 7); - - /* If this is an EOF record, then make it so. */ - if (type == 1) - break; + int ret; + uint8_t *fwBuf; - if (type != 0) { - printk(KERN_ERR "comedi_: usbduxfast: unsupported " - "record type: %u\n", type); - kfree(firmwareBinary); - return -EFAULT; - } + if (!firmwareBinary) + return 0; - for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) { - firmwareBinary[idx + off] = hex2unsigned(cp); - /* printk("%02x ",firmwareBinary[idx+off]); */ - } + if (sizeFirmware>FIRMWARE_MAX_LEN) { + dev_err(&usbduxfastsub->interface->dev, + "comedi_: usbduxfast firmware binary it too large for FX2.\n"); + return -ENOMEM; + } - /* printk("\n"); */ + /* we generate a local buffer for the firmware */ + fwBuf = kzalloc(sizeFirmware, GFP_KERNEL); + if (!fwBuf) { + dev_err(&usbduxfastsub->interface->dev, + "comedi_: mem alloc for firmware failed\n"); + return -ENOMEM; + } + memcpy(fwBuf,firmwareBinary,sizeFirmware); - if (i >= size) { - printk(KERN_ERR "comedi_: usbduxfast: unexpected end " - "of hex file\n"); - break; - } + ret = usbduxfastsub_stop(usbduxfastsub); + if (ret < 0) { + dev_err(&usbduxfastsub->interface->dev, + "comedi_: can not stop firmware\n"); + kfree(fwBuf); + return ret; + } + ret = usbduxfastsub_upload(usbduxfastsub, fwBuf, 0, sizeFirmware); + if (ret < 0) { + dev_err(&usbduxfastsub->interface->dev, + "comedi_: firmware upload failed\n"); + kfree(fwBuf); + return ret; } - res = firmwareUpload(udfs, firmwareBinary, maxAddr + 1); - kfree(firmwareBinary); - return res; + ret = usbduxfastsub_start(usbduxfastsub); + if (ret < 0) { + dev_err(&usbduxfastsub->interface->dev, + "comedi_: can not start firmware\n"); + kfree(fwBuf); + return ret; + } + kfree(fwBuf); + return 0; } + + static void tidy_up(struct usbduxfastsub_s *udfs) { #ifdef CONFIG_COMEDI_DEBUG @@ -1544,7 +1447,7 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware * * we need to upload the firmware here because fw will be * freed once we've left this function */ - ret = read_firmware(usbduxfastsub_tmp, fw->data, fw->size); + ret = firmwareUpload(usbduxfastsub_tmp, fw->data, fw->size); if (ret) { dev_err(&usbdev->dev, @@ -1666,7 +1569,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf, ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - "usbduxfast_firmware.hex", + "usbduxfast_firmware.bin", &udev->dev, usbduxfastsub + index, usbduxfast_firmware_request_complete_handler); @@ -1751,9 +1654,9 @@ static int usbduxfast_attach(struct comedi_device *dev, struct comedi_devconfig /* trying to upload the firmware into the chip */ if (comedi_aux_data(it->options, 0) && it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { - read_firmware(&usbduxfastsub[index], - comedi_aux_data(it->options, 0), - it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]); + firmwareUpload(&usbduxfastsub[index], + comedi_aux_data(it->options, 0), + it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]); } dev->board_name = BOARDNAME; diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c new file mode 100644 index 000000000000..9de43b5310d7 --- /dev/null +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -0,0 +1,1399 @@ +/* + comedi/drivers/vmk80xx.c + Velleman USB Board Low-Level Driver + + Copyright (C) 2009 Manuel Gebele <forensixs@gmx.de>, Germany + + COMEDI - Linux Control and Measurement Device Interface + Copyright (C) 2000 David A. Schleef <ds@schleef.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +/* +Driver: vmk80xx +Description: Velleman USB Board Low-Level Driver +Devices: K8055/K8061 aka VM110/VM140 +Author: Manuel Gebele <forensixs@gmx.de> +Updated: Sun, 10 May 2009 11:14:59 +0200 +Status: works + +Supports: + - analog input + - analog output + - digital input + - digital output + - counter + - pwm +*/ +/* +Changelog: + +0.8.81 -3- code completely rewritten (adjust driver logic) +0.8.81 -2- full support for K8061 +0.8.81 -1- fix some mistaken among others the number of + supported boards and I/O handling + +0.7.76 -4- renamed to vmk80xx +0.7.76 -3- detect K8061 (only theoretically supported) +0.7.76 -2- code completely rewritten (adjust driver logic) +0.7.76 -1- support for digital and counter subdevice +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/errno.h> +#include <linux/input.h> +#include <linux/slab.h> +#include <linux/poll.h> +#include <linux/usb.h> +#include <linux/uaccess.h> + +#include "../comedidev.h" + +MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>"); +MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver"); +MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140"); +MODULE_VERSION("0.8.01"); +MODULE_LICENSE("GPL"); + +enum { + DEVICE_VMK8055, + DEVICE_VMK8061 +}; + +static struct usb_device_id vmk80xx_id_table[] = { + { USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055 }, + { USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055 }, + { USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055 }, + { USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055 }, + { USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061 }, + { USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061 }, + { } /* terminating entry */ +}; + +MODULE_DEVICE_TABLE(usb, vmk80xx_id_table); + +#define VMK8055_DI_REG 0x00 +#define VMK8055_DO_REG 0x01 +#define VMK8055_AO1_REG 0x02 +#define VMK8055_AO2_REG 0x03 +#define VMK8055_AI1_REG 0x02 +#define VMK8055_AI2_REG 0x03 +#define VMK8055_CNT1_REG 0x04 +#define VMK8055_CNT2_REG 0x06 + +#define VMK8061_CH_REG 0x01 +#define VMK8061_DI_REG 0x01 +#define VMK8061_DO_REG 0x01 +#define VMK8061_PWM_REG1 0x01 +#define VMK8061_PWM_REG2 0x02 +#define VMK8061_CNT_REG 0x02 +#define VMK8061_AO_REG 0x02 +#define VMK8061_AI_REG1 0x02 +#define VMK8061_AI_REG2 0x03 + +#define VMK8055_CMD_RST 0x00 +#define VMK8055_CMD_DEB1_TIME 0x01 +#define VMK8055_CMD_DEB2_TIME 0x02 +#define VMK8055_CMD_RST_CNT1 0x03 +#define VMK8055_CMD_RST_CNT2 0x04 +#define VMK8055_CMD_WRT_AD 0x05 + +#define VMK8061_CMD_RD_AI 0x00 +#define VMK8061_CMR_RD_ALL_AI 0x01 /* !non-active! */ +#define VMK8061_CMD_SET_AO 0x02 +#define VMK8061_CMD_SET_ALL_AO 0x03 /* !non-active! */ +#define VMK8061_CMD_OUT_PWM 0x04 +#define VMK8061_CMD_RD_DI 0x05 +#define VMK8061_CMD_DO 0x06 /* !non-active! */ +#define VMK8061_CMD_CLR_DO 0x07 +#define VMK8061_CMD_SET_DO 0x08 +#define VMK8061_CMD_RD_CNT 0x09 /* TODO: completely pointless? */ +#define VMK8061_CMD_RST_CNT 0x0a /* TODO: completely pointless? */ +#define VMK8061_CMD_RD_VERSION 0x0b /* internal usage */ +#define VMK8061_CMD_RD_JMP_STAT 0x0c /* TODO: not implemented yet */ +#define VMK8061_CMD_RD_PWR_STAT 0x0d /* internal usage */ +#define VMK8061_CMD_RD_DO 0x0e +#define VMK8061_CMD_RD_AO 0x0f +#define VMK8061_CMD_RD_PWM 0x10 + +#define VMK80XX_MAX_BOARDS COMEDI_NUM_BOARD_MINORS + +#define TRANS_OUT_BUSY 1 +#define TRANS_IN_BUSY 2 +#define TRANS_IN_RUNNING 3 + +#define IC3_VERSION (1 << 0) +#define IC6_VERSION (1 << 1) + +#define URB_RCV_FLAG (1 << 0) +#define URB_SND_FLAG (1 << 1) + +#define CONFIG_VMK80XX_DEBUG +#undef CONFIG_VMK80XX_DEBUG + +#ifdef CONFIG_VMK80XX_DEBUG + static int dbgvm = 1; +#else + static int dbgvm; +#endif + +#ifdef CONFIG_COMEDI_DEBUG + static int dbgcm = 1; +#else + static int dbgcm; +#endif + +#define dbgvm(fmt, arg...) \ +do { \ + if (dbgvm) \ + printk(KERN_DEBUG fmt, ##arg); \ +} while (0) + +#define dbgcm(fmt, arg...) \ +do { \ + if (dbgcm) \ + printk(KERN_DEBUG fmt, ##arg); \ +} while (0) + +enum vmk80xx_model { + VMK8055_MODEL, + VMK8061_MODEL +}; + +struct firmware_version { + unsigned char ic3_vers[32]; /* USB-Controller */ + unsigned char ic6_vers[32]; /* CPU */ +}; + +static const struct comedi_lrange vmk8055_range = { + 1, { UNI_RANGE(5) } +}; + +static const struct comedi_lrange vmk8061_range = { + 2, { UNI_RANGE(5), UNI_RANGE(10) } +}; + +struct vmk80xx_board { + const char *name; + enum vmk80xx_model model; + const struct comedi_lrange *range; + __u8 ai_chans; + __le16 ai_bits; + __u8 ao_chans; + __le16 ao_bits; + __u8 di_chans; + __le16 di_bits; + __u8 do_chans; + __le16 do_bits; + __u8 cnt_chans; + __le16 cnt_bits; + __u8 pwm_chans; + __le16 pwm_bits; +}; + +enum { + VMK80XX_SUBD_AI, + VMK80XX_SUBD_AO, + VMK80XX_SUBD_DI, + VMK80XX_SUBD_DO, + VMK80XX_SUBD_CNT, + VMK80XX_SUBD_PWM, +}; + +struct vmk80xx_usb { + struct usb_device *udev; + struct usb_interface *intf; + struct usb_endpoint_descriptor *ep_rx; + struct usb_endpoint_descriptor *ep_tx; + struct usb_anchor rx_anchor; + struct usb_anchor tx_anchor; + struct vmk80xx_board board; + struct firmware_version fw; + struct semaphore limit_sem; + wait_queue_head_t read_wait; + wait_queue_head_t write_wait; + unsigned char *usb_rx_buf; + unsigned char *usb_tx_buf; + unsigned long flags; + int probed; + int attached; + int count; +}; + +static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS]; + +static DEFINE_MUTEX(glb_mutex); + +static void vmk80xx_tx_callback(struct urb *urb) +{ + struct vmk80xx_usb *dev = urb->context; + int stat = urb->status; + + dbgvm("vmk80xx: %s\n", __func__); + + if (stat && !(stat == -ENOENT + || stat == -ECONNRESET + || stat == -ESHUTDOWN)) + dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n", + __func__, stat); + + if (!test_bit(TRANS_OUT_BUSY, &dev->flags)) + return; + + clear_bit(TRANS_OUT_BUSY, &dev->flags); + + wake_up_interruptible(&dev->write_wait); +} + +static void vmk80xx_rx_callback(struct urb *urb) +{ + struct vmk80xx_usb *dev = urb->context; + int stat = urb->status; + + dbgvm("vmk80xx: %s\n", __func__); + + switch (stat) { + case 0: + break; + case -ENOENT: + case -ECONNRESET: + case -ESHUTDOWN: + break; + default: + dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n", + __func__, stat); + goto resubmit; + } + + goto exit; +resubmit: + if (test_bit(TRANS_IN_RUNNING, &dev->flags) && dev->intf) { + usb_anchor_urb(urb, &dev->rx_anchor); + + if (!usb_submit_urb(urb, GFP_KERNEL)) + goto exit; + + err("comedi#: vmk80xx: %s - submit urb failed\n", __func__); + + usb_unanchor_urb(urb); + } +exit: + clear_bit(TRANS_IN_BUSY, &dev->flags); + + wake_up_interruptible(&dev->read_wait); +} + +static int vmk80xx_check_data_link(struct vmk80xx_usb *dev) +{ + unsigned int tx_pipe, rx_pipe; + unsigned char tx[1], rx[2]; + + dbgvm("vmk80xx: %s\n", __func__); + + tx_pipe = usb_sndbulkpipe(dev->udev, 0x01); + rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81); + + tx[0] = VMK8061_CMD_RD_PWR_STAT; + + /* Check that IC6 (PIC16F871) is powered and + * running and the data link between IC3 and + * IC6 is working properly */ + usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, + dev->ep_tx->bInterval); + usb_bulk_msg(dev->udev, rx_pipe, rx, 2, NULL, + HZ * 10); + + return (int)rx[1]; +} + +static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag) +{ + unsigned int tx_pipe, rx_pipe; + unsigned char tx[1], rx[64]; + int cnt; + + dbgvm("vmk80xx: %s\n", __func__); + + tx_pipe = usb_sndbulkpipe(dev->udev, 0x01); + rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81); + + tx[0] = VMK8061_CMD_RD_VERSION; + + /* Read the firmware version info of IC3 and + * IC6 from the internal EEPROM of the IC */ + usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, + dev->ep_tx->bInterval); + usb_bulk_msg(dev->udev, rx_pipe, rx, 64, &cnt, + HZ * 10); + + rx[cnt] = '\0'; + + if (flag & IC3_VERSION) + strncpy(dev->fw.ic3_vers, rx + 1, 24); + else /* IC6_VERSION */ + strncpy(dev->fw.ic6_vers, rx + 25, 24); +} + +static int vmk80xx_reset_device(struct vmk80xx_usb *dev) +{ + struct urb *urb; + unsigned int tx_pipe; + int ival; + size_t size; + + dbgvm("vmk80xx: %s\n", __func__); + + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) + return -ENOMEM; + + tx_pipe = usb_sndintpipe(dev->udev, 0x01); + + ival = dev->ep_tx->bInterval; + size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); + + dev->usb_tx_buf[0] = VMK8055_CMD_RST; + dev->usb_tx_buf[1] = 0x00; + dev->usb_tx_buf[2] = 0x00; + dev->usb_tx_buf[3] = 0x00; + dev->usb_tx_buf[4] = 0x00; + dev->usb_tx_buf[5] = 0x00; + dev->usb_tx_buf[6] = 0x00; + dev->usb_tx_buf[7] = 0x00; + + usb_fill_int_urb(urb, dev->udev, tx_pipe, dev->usb_tx_buf, + size, vmk80xx_tx_callback, dev, ival); + + usb_anchor_urb(urb, &dev->tx_anchor); + + return usb_submit_urb(urb, GFP_KERNEL); +} + +static void vmk80xx_build_int_urb(struct urb *urb, int flag) +{ + struct vmk80xx_usb *dev = urb->context; + __u8 rx_addr, tx_addr; + unsigned int pipe; + unsigned char *buf; + size_t size; + void (*callback)(struct urb *); + int ival; + + dbgvm("vmk80xx: %s\n", __func__); + + if (flag & URB_RCV_FLAG) { + rx_addr = dev->ep_rx->bEndpointAddress; + pipe = usb_rcvintpipe(dev->udev, rx_addr); + buf = dev->usb_rx_buf; + size = le16_to_cpu(dev->ep_rx->wMaxPacketSize); + callback = vmk80xx_rx_callback; + ival = dev->ep_rx->bInterval; + } else { /* URB_SND_FLAG */ + tx_addr = dev->ep_tx->bEndpointAddress; + pipe = usb_sndintpipe(dev->udev, tx_addr); + buf = dev->usb_tx_buf; + size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); + callback = vmk80xx_tx_callback; + ival = dev->ep_tx->bInterval; + } + + usb_fill_int_urb(urb, dev->udev, pipe, buf, + size, callback, dev, ival); +} + +static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev) +{ + __u8 tx_addr, rx_addr; + unsigned int tx_pipe, rx_pipe; + size_t size; + + dbgvm("vmk80xx: %s\n", __func__); + + set_bit(TRANS_IN_BUSY, &dev->flags); + set_bit(TRANS_OUT_BUSY, &dev->flags); + + tx_addr = dev->ep_tx->bEndpointAddress; + rx_addr = dev->ep_rx->bEndpointAddress; + tx_pipe = usb_sndbulkpipe(dev->udev, tx_addr); + rx_pipe = usb_rcvbulkpipe(dev->udev, rx_addr); + + /* The max packet size attributes of the K8061 + * input/output endpoints are identical */ + size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); + + usb_bulk_msg(dev->udev, tx_pipe, dev->usb_tx_buf, + size, NULL, dev->ep_tx->bInterval); + usb_bulk_msg(dev->udev, rx_pipe, dev->usb_rx_buf, + size, NULL, HZ * 10); + + clear_bit(TRANS_OUT_BUSY, &dev->flags); + clear_bit(TRANS_IN_BUSY, &dev->flags); +} + +static int vmk80xx_read_packet(struct vmk80xx_usb *dev) +{ + struct urb *urb; + int retval; + + dbgvm("vmk80xx: %s\n", __func__); + + if (!dev->intf) + return -ENODEV; + + /* Only useful for interrupt transfers */ + if (test_bit(TRANS_IN_BUSY, &dev->flags)) + if (wait_event_interruptible(dev->read_wait, + !test_bit(TRANS_IN_BUSY, &dev->flags))) + return -ERESTART; + + if (dev->board.model == VMK8061_MODEL) { + vmk80xx_do_bulk_msg(dev); + + return 0; + } + + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) + return -ENOMEM; + + urb->context = dev; + vmk80xx_build_int_urb(urb, URB_RCV_FLAG); + + set_bit(TRANS_IN_RUNNING, &dev->flags); + set_bit(TRANS_IN_BUSY, &dev->flags); + + usb_anchor_urb(urb, &dev->rx_anchor); + + retval = usb_submit_urb(urb, GFP_KERNEL); + if (!retval) + goto exit; + + clear_bit(TRANS_IN_RUNNING, &dev->flags); + usb_unanchor_urb(urb); + +exit: + usb_free_urb(urb); + + return retval; +} + +static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd) +{ + struct urb *urb; + int retval; + + dbgvm("vmk80xx: %s\n", __func__); + + if (!dev->intf) + return -ENODEV; + + if (test_bit(TRANS_OUT_BUSY, &dev->flags)) + if (wait_event_interruptible(dev->write_wait, + !test_bit(TRANS_OUT_BUSY, &dev->flags))) + return -ERESTART; + + if (dev->board.model == VMK8061_MODEL) { + dev->usb_tx_buf[0] = cmd; + vmk80xx_do_bulk_msg(dev); + + return 0; + } + + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) + return -ENOMEM; + + urb->context = dev; + vmk80xx_build_int_urb(urb, URB_SND_FLAG); + + set_bit(TRANS_OUT_BUSY, &dev->flags); + + usb_anchor_urb(urb, &dev->tx_anchor); + + dev->usb_tx_buf[0] = cmd; + + retval = usb_submit_urb(urb, GFP_KERNEL); + if (!retval) + goto exit; + + clear_bit(TRANS_OUT_BUSY, &dev->flags); + usb_unanchor_urb(urb); + +exit: + usb_free_urb(urb); + + return retval; +} + +#define DIR_IN 1 +#define DIR_OUT 2 + +#define rudimentary_check(dir) \ +do { \ + if (!dev) \ + return -EFAULT; \ + if (!dev->probed) \ + return -ENODEV; \ + if (!dev->attached) \ + return -ENODEV; \ + if ((dir) & DIR_IN) { \ + if (test_bit(TRANS_IN_BUSY, &dev->flags)) \ + return -EBUSY; \ + } else { /* DIR_OUT */ \ + if (test_bit(TRANS_OUT_BUSY, &dev->flags)) \ + return -EBUSY; \ + } \ +} while (0) + +static int vmk80xx_ai_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan, reg[2]; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + switch (dev->board.model) { + case VMK8055_MODEL: + if (!chan) + reg[0] = VMK8055_AI1_REG; + else + reg[0] = VMK8055_AI2_REG; + break; + case VMK8061_MODEL: + reg[0] = VMK8061_AI_REG1; + reg[1] = VMK8061_AI_REG2; + dev->usb_tx_buf[0] = VMK8061_CMD_RD_AI; + dev->usb_tx_buf[VMK8061_CH_REG] = chan; + break; + } + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + if (dev->board.model == VMK8055_MODEL) { + data[n] = dev->usb_rx_buf[reg[0]]; + continue; + } + + /* VMK8061_MODEL */ + data[n] = dev->usb_rx_buf[reg[0]] + 256 * + dev->usb_rx_buf[reg[1]]; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_ao_winsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan, cmd, reg; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_OUT); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + switch (dev->board.model) { + case VMK8055_MODEL: + cmd = VMK8055_CMD_WRT_AD; + if (!chan) + reg = VMK8055_AO1_REG; + else + reg = VMK8055_AO2_REG; + break; + default: /* NOTE: avoid compiler warnings */ + cmd = VMK8061_CMD_SET_AO; + reg = VMK8061_AO_REG; + dev->usb_tx_buf[VMK8061_CH_REG] = chan; + break; + } + + for (n = 0; n < insn->n; n++) { + dev->usb_tx_buf[reg] = data[n]; + + if (vmk80xx_write_packet(dev, cmd)) + break; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_ao_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan, reg; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + reg = VMK8061_AO_REG - 1; + + dev->usb_tx_buf[0] = VMK8061_CMD_RD_AO; + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + data[n] = dev->usb_rx_buf[reg+chan]; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_di_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan; + unsigned char *rx_buf; + int reg, inp; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + rx_buf = dev->usb_rx_buf; + + if (dev->board.model == VMK8061_MODEL) { + reg = VMK8061_DI_REG; + dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI; + } else + reg = VMK8055_DI_REG; + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + if (dev->board.model == VMK8055_MODEL) + inp = (((rx_buf[reg] >> 4) & 0x03) | + ((rx_buf[reg] << 2) & 0x04) | + ((rx_buf[reg] >> 3) & 0x18)); + else + inp = rx_buf[reg]; + + data[n] = ((inp & (1 << chan)) > 0); + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_do_winsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + + struct vmk80xx_usb *dev = cdev->private; + int chan; + unsigned char *tx_buf; + int reg, cmd; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_OUT); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + tx_buf = dev->usb_tx_buf; + + for (n = 0; n < insn->n; n++) { + if (dev->board.model == VMK8055_MODEL) { + reg = VMK8055_DO_REG; + cmd = VMK8055_CMD_WRT_AD; + if (data[n] == 1) + tx_buf[reg] |= (1 << chan); + else + tx_buf[reg] ^= (1 << chan); + + goto write_packet; + } + + /* VMK8061_MODEL */ + reg = VMK8061_DO_REG; + if (data[n] == 1) { + cmd = VMK8061_CMD_SET_DO; + tx_buf[reg] = 1 << chan; + } else { + cmd = VMK8061_CMD_CLR_DO; + tx_buf[reg] = 0xff - (1 << chan); + } + +write_packet: + if (vmk80xx_write_packet(dev, cmd)) + break; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_do_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan, reg, mask; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + reg = VMK8061_DO_REG; + mask = 1 << chan; + + dev->usb_tx_buf[0] = VMK8061_CMD_RD_DO; + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + data[n] = (dev->usb_rx_buf[reg] & mask) >> chan; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_cnt_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int chan, reg[2]; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + switch (dev->board.model) { + case VMK8055_MODEL: + if (!chan) + reg[0] = VMK8055_CNT1_REG; + else + reg[0] = VMK8055_CNT2_REG; + break; + case VMK8061_MODEL: + reg[0] = VMK8061_CNT_REG; + reg[1] = VMK8061_CNT_REG; + dev->usb_tx_buf[0] = VMK8061_CMD_RD_CNT; + break; + } + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + if (dev->board.model == VMK8055_MODEL) { + data[n] = dev->usb_rx_buf[reg[0]]; + continue; + } + + /* VMK8061_MODEL */ + data[n] = dev->usb_rx_buf[reg[0]*(chan+1)+1] + + 256 * dev->usb_rx_buf[reg[1]*2+2]; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_cnt_cinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + unsigned int insn_cmd; + int chan, cmd, reg; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_OUT); + + down(&dev->limit_sem); + + insn_cmd = data[0]; + if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET) + return -EINVAL; + + chan = CR_CHAN(insn->chanspec); + + if (dev->board.model == VMK8055_MODEL) { + if (!chan) { + cmd = VMK8055_CMD_RST_CNT1; + reg = VMK8055_CNT1_REG; + } else { + cmd = VMK8055_CMD_RST_CNT2; + reg = VMK8055_CNT2_REG; + } + + dev->usb_tx_buf[reg] = 0x00; + } else + cmd = VMK8061_CMD_RST_CNT; + + for (n = 0; n < insn->n; n++) + if (vmk80xx_write_packet(dev, cmd)) + break; + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_cnt_winsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + unsigned long debtime, val; + int chan, cmd; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_OUT); + + down(&dev->limit_sem); + chan = CR_CHAN(insn->chanspec); + + if (!chan) + cmd = VMK8055_CMD_DEB1_TIME; + else + cmd = VMK8055_CMD_DEB2_TIME; + + for (n = 0; n < insn->n; n++) { + debtime = data[n]; + if (debtime == 0) + debtime = 1; + + /* TODO: Prevent overflows */ + if (debtime > 7450) + debtime = 7450; + + val = int_sqrt(debtime * 1000 / 115); + if (((val + 1) * val) < debtime * 1000 / 115) + val += 1; + + dev->usb_tx_buf[6+chan] = val; + + if (vmk80xx_write_packet(dev, cmd)) + break; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_pwm_rinsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + int reg[2]; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_IN); + + down(&dev->limit_sem); + + reg[0] = VMK8061_PWM_REG1; + reg[1] = VMK8061_PWM_REG2; + + dev->usb_tx_buf[0] = VMK8061_CMD_RD_PWM; + + for (n = 0; n < insn->n; n++) { + if (vmk80xx_read_packet(dev)) + break; + + data[n] = dev->usb_rx_buf[reg[0]] + 4 * + dev->usb_rx_buf[reg[1]]; + } + + up(&dev->limit_sem); + + return n; +} + +static int vmk80xx_pwm_winsn(struct comedi_device *cdev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct vmk80xx_usb *dev = cdev->private; + unsigned char *tx_buf; + int reg[2], cmd; + int n; + + dbgvm("vmk80xx: %s\n", __func__); + + rudimentary_check(DIR_OUT); + + down(&dev->limit_sem); + + tx_buf = dev->usb_tx_buf; + + reg[0] = VMK8061_PWM_REG1; + reg[1] = VMK8061_PWM_REG2; + + cmd = VMK8061_CMD_OUT_PWM; + + /* + * The followin piece of code was translated from the inline + * assembler code in the DLL source code. + * + * asm + * mov eax, k ; k is the value (data[n]) + * and al, 03h ; al are the lower 8 bits of eax + * mov lo, al ; lo is the low part (tx_buf[reg[0]]) + * mov eax, k + * shr eax, 2 ; right shift eax register by 2 + * mov hi, al ; hi is the high part (tx_buf[reg[1]]) + * end; + */ + for (n = 0; n < insn->n; n++) { + tx_buf[reg[0]] = (unsigned char)(data[n] & 0x03); + tx_buf[reg[1]] = (unsigned char)(data[n] >> 2) & 0xff; + + if (vmk80xx_write_packet(dev, cmd)) + break; + } + + up(&dev->limit_sem); + + return n; +} + +static int +vmk80xx_attach(struct comedi_device *cdev, struct comedi_devconfig *it) +{ + int i; + struct vmk80xx_usb *dev; + int n_subd; + struct comedi_subdevice *s; + int minor; + + dbgvm("vmk80xx: %s\n", __func__); + + mutex_lock(&glb_mutex); + + for (i = 0; i < VMK80XX_MAX_BOARDS; i++) + if (vmb[i].probed && !vmb[i].attached) + break; + + if (i == VMK80XX_MAX_BOARDS) { + mutex_unlock(&glb_mutex); + return -ENODEV; + } + + dev = &vmb[i]; + + down(&dev->limit_sem); + + cdev->board_name = dev->board.name; + cdev->private = dev; + + if (dev->board.model == VMK8055_MODEL) + n_subd = 5; + else + n_subd = 6; + + if (alloc_subdevices(cdev, n_subd) < 0) { + up(&dev->limit_sem); + mutex_unlock(&glb_mutex); + return -ENOMEM; + } + + /* Analog input subdevice */ + s = cdev->subdevices + VMK80XX_SUBD_AI; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND; + s->n_chan = dev->board.ai_chans; + s->maxdata = (1 << dev->board.ai_bits) - 1; + s->range_table = dev->board.range; + s->insn_read = vmk80xx_ai_rinsn; + + /* Analog output subdevice */ + s = cdev->subdevices + VMK80XX_SUBD_AO; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; + s->n_chan = dev->board.ao_chans; + s->maxdata = (1 << dev->board.ao_bits) - 1; + s->range_table = dev->board.range; + s->insn_write = vmk80xx_ao_winsn; + + if (dev->board.model == VMK8061_MODEL) { + s->subdev_flags |= SDF_READABLE; + s->insn_read = vmk80xx_ao_rinsn; + } + + /* Digital input subdevice */ + s = cdev->subdevices + VMK80XX_SUBD_DI; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND; + s->n_chan = dev->board.di_chans; + s->maxdata = (1 << dev->board.di_bits) - 1; + s->insn_read = vmk80xx_di_rinsn; + + /* Digital output subdevice */ + s = cdev->subdevices + VMK80XX_SUBD_DO; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; + s->n_chan = dev->board.do_chans; + s->maxdata = (1 << dev->board.do_bits) - 1; + s->insn_write = vmk80xx_do_winsn; + + if (dev->board.model == VMK8061_MODEL) { + s->subdev_flags |= SDF_READABLE; + s->insn_read = vmk80xx_do_rinsn; + } + + /* Counter subdevice */ + s = cdev->subdevices + VMK80XX_SUBD_CNT; + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_READABLE; + s->n_chan = dev->board.cnt_chans; + s->insn_read = vmk80xx_cnt_rinsn; + s->insn_config = vmk80xx_cnt_cinsn; + + if (dev->board.model == VMK8055_MODEL) { + s->subdev_flags |= SDF_WRITEABLE; + s->maxdata = (1 << dev->board.cnt_bits) - 1; + s->insn_write = vmk80xx_cnt_winsn; + } + + /* PWM subdevice */ + if (dev->board.model == VMK8061_MODEL) { + s = cdev->subdevices + VMK80XX_SUBD_PWM; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; + s->n_chan = dev->board.pwm_chans; + s->maxdata = (1 << dev->board.pwm_bits) - 1; + s->insn_read = vmk80xx_pwm_rinsn; + s->insn_write = vmk80xx_pwm_winsn; + } + + dev->attached = 1; + + minor = cdev->minor; + + printk(KERN_INFO + "comedi%d: vmk80xx: board #%d [%s] attached to comedi\n", + minor, dev->count, dev->board.name); + + up(&dev->limit_sem); + mutex_unlock(&glb_mutex); + + return 0; +} + +static int vmk80xx_detach(struct comedi_device *cdev) +{ + struct vmk80xx_usb *dev; + int minor; + + dbgvm("vmk80xx: %s\n", __func__); + + if (!cdev) + return -EFAULT; + + dev = cdev->private; + if (!dev) + return -EFAULT; + + down(&dev->limit_sem); + + cdev->private = NULL; + dev->attached = 0; + + minor = cdev->minor; + + printk(KERN_INFO + "comedi%d: vmk80xx: board #%d [%s] detached from comedi\n", + minor, dev->count, dev->board.name); + + up(&dev->limit_sem); + + return 0; +} + +static int +vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + int i; + struct vmk80xx_usb *dev; + struct usb_host_interface *iface_desc; + struct usb_endpoint_descriptor *ep_desc; + size_t size; + + dbgvm("vmk80xx: %s\n", __func__); + + mutex_lock(&glb_mutex); + + for (i = 0; i < VMK80XX_MAX_BOARDS; i++) + if (!vmb[i].probed) + break; + + if (i == VMK80XX_MAX_BOARDS) { + mutex_unlock(&glb_mutex); + return -EMFILE; + } + + dev = &vmb[i]; + + memset(dev, 0x00, sizeof(struct vmk80xx_usb)); + dev->count = i; + + iface_desc = intf->cur_altsetting; + if (iface_desc->desc.bNumEndpoints != 2) + goto error; + + for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { + ep_desc = &iface_desc->endpoint[i].desc; + + if (usb_endpoint_is_int_in(ep_desc)) { + dev->ep_rx = ep_desc; + continue; + } + + if (usb_endpoint_is_int_out(ep_desc)) { + dev->ep_tx = ep_desc; + continue; + } + + if (usb_endpoint_is_bulk_in(ep_desc)) { + dev->ep_rx = ep_desc; + continue; + } + + if (usb_endpoint_is_bulk_out(ep_desc)) { + dev->ep_tx = ep_desc; + continue; + } + } + + if (!dev->ep_rx || !dev->ep_tx) + goto error; + + size = le16_to_cpu(dev->ep_rx->wMaxPacketSize); + dev->usb_rx_buf = kmalloc(size, GFP_KERNEL); + if (!dev->usb_rx_buf) { + mutex_unlock(&glb_mutex); + return -ENOMEM; + } + + size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); + dev->usb_tx_buf = kmalloc(size, GFP_KERNEL); + if (!dev->usb_tx_buf) { + kfree(dev->usb_rx_buf); + mutex_unlock(&glb_mutex); + return -ENOMEM; + } + + dev->udev = interface_to_usbdev(intf); + dev->intf = intf; + + sema_init(&dev->limit_sem, 8); + init_waitqueue_head(&dev->read_wait); + init_waitqueue_head(&dev->write_wait); + + init_usb_anchor(&dev->rx_anchor); + init_usb_anchor(&dev->tx_anchor); + + usb_set_intfdata(intf, dev); + + switch (id->driver_info) { + case DEVICE_VMK8055: + dev->board.name = "K8055 (VM110)"; + dev->board.model = VMK8055_MODEL; + dev->board.range = &vmk8055_range; + dev->board.ai_chans = 2; + dev->board.ai_bits = 8; + dev->board.ao_chans = 2; + dev->board.ao_bits = 8; + dev->board.di_chans = 5; + dev->board.di_bits = 1; + dev->board.do_chans = 8; + dev->board.do_bits = 1; + dev->board.cnt_chans = 2; + dev->board.cnt_bits = 16; + dev->board.pwm_chans = 0; + dev->board.pwm_bits = 0; + break; + case DEVICE_VMK8061: + dev->board.name = "K8061 (VM140)"; + dev->board.model = VMK8061_MODEL; + dev->board.range = &vmk8061_range; + dev->board.ai_chans = 8; + dev->board.ai_bits = 10; + dev->board.ao_chans = 8; + dev->board.ao_bits = 8; + dev->board.di_chans = 8; + dev->board.di_bits = 1; + dev->board.do_chans = 8; + dev->board.do_bits = 1; + dev->board.cnt_chans = 2; + dev->board.cnt_bits = 0; + dev->board.pwm_chans = 1; + dev->board.pwm_bits = 10; + break; + } + + if (dev->board.model == VMK8061_MODEL) { + vmk80xx_read_eeprom(dev, IC3_VERSION); + printk(KERN_INFO "comedi#: vmk80xx: %s\n", + dev->fw.ic3_vers); + + if (vmk80xx_check_data_link(dev)) { + vmk80xx_read_eeprom(dev, IC6_VERSION); + printk(KERN_INFO "comedi#: vmk80xx: %s\n", + dev->fw.ic6_vers); + } else + dbgcm("comedi#: vmk80xx: no conn. to CPU\n"); + } + + if (dev->board.model == VMK8055_MODEL) + vmk80xx_reset_device(dev); + + dev->probed = 1; + + printk(KERN_INFO "comedi#: vmk80xx: board #%d [%s] now attached\n", + dev->count, dev->board.name); + + mutex_unlock(&glb_mutex); + + return 0; +error: + mutex_unlock(&glb_mutex); + + return -ENODEV; +} + +static void vmk80xx_disconnect(struct usb_interface *intf) +{ + struct vmk80xx_usb *dev = usb_get_intfdata(intf); + + dbgvm("vmk80xx: %s\n", __func__); + + if (!dev) + return; + + mutex_lock(&glb_mutex); + down(&dev->limit_sem); + + dev->probed = 0; + usb_set_intfdata(dev->intf, NULL); + + usb_kill_anchored_urbs(&dev->rx_anchor); + usb_kill_anchored_urbs(&dev->tx_anchor); + + kfree(dev->usb_rx_buf); + kfree(dev->usb_tx_buf); + + printk(KERN_INFO "comedi#: vmk80xx: board #%d [%s] now detached\n", + dev->count, dev->board.name); + + up(&dev->limit_sem); + mutex_unlock(&glb_mutex); +} + +/* TODO: Add support for suspend, resume, pre_reset, + * post_reset and flush */ +static struct usb_driver vmk80xx_driver = { + .name = "vmk80xx", + .probe = vmk80xx_probe, + .disconnect = vmk80xx_disconnect, + .id_table = vmk80xx_id_table +}; + +static struct comedi_driver driver_vmk80xx = { + .module = THIS_MODULE, + .driver_name = "vmk80xx", + .attach = vmk80xx_attach, + .detach = vmk80xx_detach +}; + +static int __init vmk80xx_init(void) +{ + printk(KERN_INFO "vmk80xx: version 0.8.01 " + "Manuel Gebele <forensixs@gmx.de>\n"); + usb_register(&vmk80xx_driver); + return comedi_driver_register(&driver_vmk80xx); +} + +static void __exit vmk80xx_exit(void) +{ + comedi_driver_unregister(&driver_vmk80xx); + usb_deregister(&vmk80xx_driver); +} + +module_init(vmk80xx_init); +module_exit(vmk80xx_exit); diff --git a/drivers/staging/comedi/interrupt.h b/drivers/staging/comedi/interrupt.h deleted file mode 100644 index d1f09892da2e..000000000000 --- a/drivers/staging/comedi/interrupt.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - linux/interrupt.h compatibility header - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __COMPAT_LINUX_INTERRUPT_H_ -#define __COMPAT_LINUX_INTERRUPT_H_ - -#include <linux/interrupt.h> - -#ifndef IRQF_DISABLED -#define IRQF_DISABLED SA_INTERRUPT -#define IRQF_SAMPLE_RANDOM SA_SAMPLE_RANDOM -#define IRQF_SHARED SA_SHIRQ -#define IRQF_PROBE_SHARED SA_PROBEIRQ -#define IRQF_PERCPU SA_PERCPU -#ifdef SA_TRIGGER_MASK -#define IRQF_TRIGGER_NONE 0 -#define IRQF_TRIGGER_LOW SA_TRIGGER_LOW -#define IRQF_TRIGGER_HIGH SA_TRIGGER_HIGH -#define IRQF_TRIGGER_FALLING SA_TRIGGER_FALLING -#define IRQF_TRIGGER_RISING SA_TRIGGER_RISING -#define IRQF_TRIGGER_MASK SA_TRIGGER_MASK -#else -#define IRQF_TRIGGER_NONE 0 -#define IRQF_TRIGGER_LOW 0 -#define IRQF_TRIGGER_HIGH 0 -#define IRQF_TRIGGER_FALLING 0 -#define IRQF_TRIGGER_RISING 0 -#define IRQF_TRIGGER_MASK 0 -#endif -#endif - -#define PT_REGS_ARG -#define PT_REGS_CALL -#define PT_REGS_NULL - -#endif diff --git a/drivers/staging/comedi/kcomedilib/data.c b/drivers/staging/comedi/kcomedilib/data.c index 9797e13e3774..d808556460aa 100644 --- a/drivers/staging/comedi/kcomedilib/data.c +++ b/drivers/staging/comedi/kcomedilib/data.c @@ -23,9 +23,10 @@ #include "../comedi.h" #include "../comedilib.h" -#include "../comedidev.h" /* for comedi_udelay() */ +#include "../comedidev.h" #include <linux/string.h> +#include <linux/delay.h> int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, unsigned int range, unsigned int aref, unsigned int data) @@ -83,7 +84,7 @@ int comedi_data_read_delayed(void *dev, unsigned int subdev, if (retval < 0) return retval; - comedi_udelay((nano_sec + 999) / 1000); + udelay((nano_sec + 999) / 1000); return comedi_data_read(dev, subdev, chan, range, aref, data); } diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index a4fa9571c58f..b39ea7c50b87 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -105,7 +105,7 @@ int comedi_loglevel(int newlevel) void comedi_perror(const char *message) { - rt_printk("%s: unknown error\n", message); + printk("%s: unknown error\n", message); } char *comedi_strerror(int err) @@ -150,10 +150,6 @@ int comedi_command(void *d, struct comedi_cmd *cmd) runflags = SRF_RUNNING; -#ifdef CONFIG_COMEDI_RT - if (comedi_switch_to_rt(dev) == 0) - runflags |= SRF_RT; -#endif comedi_set_subdevice_runflags(s, ~0, runflags); comedi_reset_async_buf(async); @@ -208,7 +204,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) ret = -EINVAL; break; } - comedi_udelay(insn->data[0]); + udelay(insn->data[0]); ret = 1; break; case INSN_INTTRIG: @@ -217,19 +213,19 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) break; } if (insn->subdev >= dev->n_subdevices) { - rt_printk("%d not usable subdevice\n", + printk("%d not usable subdevice\n", insn->subdev); ret = -EINVAL; break; } s = dev->subdevices + insn->subdev; if (!s->async) { - rt_printk("no async\n"); + printk("no async\n"); ret = -EINVAL; break; } if (!s->async->inttrig) { - rt_printk("no inttrig\n"); + printk("no inttrig\n"); ret = -EAGAIN; break; } @@ -249,7 +245,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) s = dev->subdevices + insn->subdev; if (s->type == COMEDI_SUBD_UNUSED) { - rt_printk("%d not useable subdevice\n", insn->subdev); + printk("%d not useable subdevice\n", insn->subdev); ret = -EIO; goto error; } @@ -258,7 +254,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) ret = check_chanlist(s, 1, &insn->chanspec); if (ret < 0) { - rt_printk("bad chanspec\n"); + printk("bad chanspec\n"); ret = -EINVAL; goto error; } @@ -295,7 +291,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) #if 0 /* XXX do we want this? -- abbotti #if'ed it out for now. */ if (ret != insn->n) { - rt_printk("BUG: result of insn != insn.n\n"); + printk("BUG: result of insn != insn.n\n"); ret = -EINVAL; goto error; } @@ -336,7 +332,7 @@ int comedi_lock(void *d, unsigned int subdevice) s = dev->subdevices + subdevice; - comedi_spin_lock_irqsave(&s->spin_lock, flags); + spin_lock_irqsave(&s->spin_lock, flags); if (s->busy) { ret = -EBUSY; @@ -348,7 +344,7 @@ int comedi_lock(void *d, unsigned int subdevice) } } - comedi_spin_unlock_irqrestore(&s->spin_lock, flags); + spin_unlock_irqrestore(&s->spin_lock, flags); return ret; } @@ -382,7 +378,7 @@ int comedi_unlock(void *d, unsigned int subdevice) async = s->async; - comedi_spin_lock_irqsave(&s->spin_lock, flags); + spin_lock_irqsave(&s->spin_lock, flags); if (s->busy) { ret = -EBUSY; @@ -400,7 +396,7 @@ int comedi_unlock(void *d, unsigned int subdevice) ret = 0; } - comedi_spin_unlock_irqrestore(&s->spin_lock, flags); + spin_unlock_irqrestore(&s->spin_lock, flags); return ret; } @@ -449,11 +445,6 @@ int comedi_cancel(void *d, unsigned int subdevice) if (ret) return ret; -#ifdef CONFIG_COMEDI_RT - if (comedi_get_subdevice_runflags(s) & SRF_RT) - comedi_switch_to_non_rt(dev); - -#endif comedi_set_subdevice_runflags(s, SRF_RUNNING | SRF_RT, 0); s->async->inttrig = NULL; s->busy = NULL; diff --git a/drivers/staging/comedi/kcomedilib/ksyms.c b/drivers/staging/comedi/kcomedilib/ksyms.c index 3db86dabf878..314765db51fe 100644 --- a/drivers/staging/comedi/kcomedilib/ksyms.c +++ b/drivers/staging/comedi/kcomedilib/ksyms.c @@ -59,7 +59,7 @@ EXPORT_SYMBOL(comedi_close); EXPORT_SYMBOL(comedi_loglevel); EXPORT_SYMBOL(comedi_perror); EXPORT_SYMBOL(comedi_strerror); -//EXPORT_SYMBOL(comedi_errno); +/* EXPORT_SYMBOL(comedi_errno); */ EXPORT_SYMBOL(comedi_fileno); /* device queries */ @@ -73,8 +73,10 @@ EXPORT_SYMBOL(comedi_get_subdevice_type); EXPORT_SYMBOL(comedi_find_subdevice_by_type); EXPORT_SYMBOL(comedi_get_subdevice_flags); EXPORT_SYMBOL(comedi_get_n_channels); -//EXPORT_SYMBOL(comedi_range_is_chan_specific); -//EXPORT_SYMBOL(comedi_maxdata_is_chan_specific); +/* +* EXPORT_SYMBOL(comedi_range_is_chan_specific); +* EXPORT_SYMBOL(comedi_maxdata_is_chan_specific); +*/ /* channel queries */ EXPORT_SYMBOL(comedi_get_maxdata); @@ -82,25 +84,29 @@ EXPORT_SYMBOL(comedi_get_maxdata); EXPORT_SYMBOL(comedi_get_rangetype); #endif EXPORT_SYMBOL(comedi_get_n_ranges); -//EXPORT_SYMBOL(comedi_find_range); +/* EXPORT_SYMBOL(comedi_find_range); */ /* buffer queries */ EXPORT_SYMBOL(comedi_get_buffer_size); -//EXPORT_SYMBOL(comedi_get_max_buffer_size); -//EXPORT_SYMBOL(comedi_set_buffer_size); +/* +* EXPORT_SYMBOL(comedi_get_max_buffer_size); +* EXPORT_SYMBOL(comedi_set_buffer_size); +*/ EXPORT_SYMBOL(comedi_get_buffer_contents); EXPORT_SYMBOL(comedi_get_buffer_offset); /* low-level stuff */ -//EXPORT_SYMBOL(comedi_trigger); -//EXPORT_SYMBOL(comedi_do_insnlist); +/* +* EXPORT_SYMBOL(comedi_trigger); EXPORT_SYMBOL(comedi_do_insnlist); +*/ EXPORT_SYMBOL(comedi_do_insn); EXPORT_SYMBOL(comedi_lock); EXPORT_SYMBOL(comedi_unlock); /* physical units */ -//EXPORT_SYMBOL(comedi_to_phys); -//EXPORT_SYMBOL(comedi_from_phys); +/* +* EXPORT_SYMBOL(comedi_to_phys); EXPORT_SYMBOL(comedi_from_phys); +*/ /* synchronous stuff */ EXPORT_SYMBOL(comedi_data_read); @@ -113,13 +119,16 @@ EXPORT_SYMBOL(comedi_dio_write); EXPORT_SYMBOL(comedi_dio_bitfield); /* slowly varying stuff */ -//EXPORT_SYMBOL(comedi_sv_init); -//EXPORT_SYMBOL(comedi_sv_update); -//EXPORT_SYMBOL(comedi_sv_measure); +/* +* EXPORT_SYMBOL(comedi_sv_init); EXPORT_SYMBOL(comedi_sv_update); +* EXPORT_SYMBOL(comedi_sv_measure); +*/ /* commands */ -//EXPORT_SYMBOL(comedi_get_cmd_src_mask); -//EXPORT_SYMBOL(comedi_get_cmd_generic_timed); +/* +* EXPORT_SYMBOL(comedi_get_cmd_src_mask); +* EXPORT_SYMBOL(comedi_get_cmd_generic_timed); +*/ EXPORT_SYMBOL(comedi_cancel); EXPORT_SYMBOL(comedi_command); EXPORT_SYMBOL(comedi_command_test); @@ -129,12 +138,14 @@ EXPORT_SYMBOL(comedi_poll); EXPORT_SYMBOL(comedi_mark_buffer_read); EXPORT_SYMBOL(comedi_mark_buffer_written); -//EXPORT_SYMBOL(comedi_get_range); +/* EXPORT_SYMBOL(comedi_get_range); */ EXPORT_SYMBOL(comedi_get_len_chanlist); /* deprecated */ -//EXPORT_SYMBOL(comedi_get_timer); -//EXPORT_SYMBOL(comedi_timed_1chan); +/* +* EXPORT_SYMBOL(comedi_get_timer); +* EXPORT_SYMBOL(comedi_timed_1chan); +*/ /* alpha */ -//EXPORT_SYMBOL(comedi_set_global_oor_behavior); +/* EXPORT_SYMBOL(comedi_set_global_oor_behavior); */ diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c index ac200d929f35..445909e6f334 100644 --- a/drivers/staging/comedi/range.c +++ b/drivers/staging/comedi/range.c @@ -32,7 +32,7 @@ const struct comedi_lrange range_unipolar5 = { 1, {UNI_RANGE(5)} }; const struct comedi_lrange range_unknown = { 1, {{0, 1000000, UNIT_none}} }; /* - COMEDI_RANGEINFO + COMEDI_RANGEINFO range information ioctl arg: @@ -130,8 +130,7 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) if (CR_CHAN(chanlist[i]) >= s->n_chan || CR_RANGE(chanlist[i]) >= s->range_table->length || aref_invalid(s, chanlist[i])) { - rt_printk - ("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n", + printk("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n", i, chanlist[i], s->n_chan, s->range_table->length); #if 0 @@ -147,13 +146,13 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) CR_RANGE(chanlist[i]) >= s->range_table_list[chan]->length || aref_invalid(s, chanlist[i])) { - rt_printk("bad chanlist[%d]=0x%08x\n", i, + printk("bad chanlist[%d]=0x%08x\n", i, chanlist[i]); return -EINVAL; } } } else { - rt_printk("comedi: (bug) no range type list!\n"); + printk("comedi: (bug) no range type list!\n"); return -EINVAL; } return 0; diff --git a/drivers/staging/comedi/rt.c b/drivers/staging/comedi/rt.c deleted file mode 100644 index e9f5777595ab..000000000000 --- a/drivers/staging/comedi/rt.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - comedi/rt.c - comedi kernel module - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#undef DEBUG - -#define __NO_VERSION__ -#include <linux/comedidev.h> - -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/fcntl.h> -#include <linux/delay.h> -#include <linux/ioport.h> -#include <linux/mm.h> -#include <linux/slab.h> -#include <asm/io.h> - -#include "rt_pend_tq.h" - -#ifdef CONFIG_COMEDI_RTAI -#include <rtai.h> -#endif - -#ifdef CONFIG_COMEDI_FUSION -#include <nucleus/asm/hal.h> -#endif - -#ifdef CONFIG_COMEDI_RTL -#include <rtl_core.h> -#include <rtl_sync.h> -#endif - -struct comedi_irq_struct { - int rt; - int irq; - irqreturn_t(*handler) (int irq, void *dev_id PT_REGS_ARG); - unsigned long flags; - const char *device; - struct comedi_device *dev_id; -}; - -static int comedi_rt_get_irq(struct comedi_irq_struct *it); -static int comedi_rt_release_irq(struct comedi_irq_struct *it); - -static struct comedi_irq_struct *comedi_irqs[NR_IRQS]; - -int comedi_request_irq(unsigned irq, irqreturn_t(*handler) (int, - void *PT_REGS_ARG), unsigned long flags, const char *device, - struct comedi_device *dev_id) -{ - struct comedi_irq_struct *it; - int ret; - /* null shared interrupt flag, since rt interrupt handlers do not - * support it, and this version of comedi_request_irq() is only - * called for kernels with rt support */ - unsigned long unshared_flags = flags & ~IRQF_SHARED; - - ret = request_irq(irq, handler, unshared_flags, device, dev_id); - if (ret < 0) { - /* we failed, so fall back on allowing shared interrupt (which we won't ever make RT) */ - if (flags & IRQF_SHARED) { - rt_printk - ("comedi: cannot get unshared interrupt, will not use RT interrupts.\n"); - ret = request_irq(irq, handler, flags, device, dev_id); - } - if (ret < 0) - return ret; - - } else { - it = kzalloc(sizeof(struct comedi_irq_struct), GFP_KERNEL); - if (!it) - return -ENOMEM; - - it->handler = handler; - it->irq = irq; - it->dev_id = dev_id; - it->device = device; - it->flags = unshared_flags; - comedi_irqs[irq] = it; - } - return 0; -} - -void comedi_free_irq(unsigned int irq, struct comedi_device *dev_id) -{ - struct comedi_irq_struct *it; - - free_irq(irq, dev_id); - - it = comedi_irqs[irq]; - if (it == NULL) - return; - - if (it->rt) { - printk("real-time IRQ allocated at board removal (ignore)\n"); - comedi_rt_release_irq(it); - } - - kfree(it); - comedi_irqs[irq] = NULL; -} - -int comedi_switch_to_rt(struct comedi_device *dev) -{ - struct comedi_irq_struct *it; - unsigned long flags; - - it = comedi_irqs[dev->irq]; - /* drivers might not be using an interrupt for commands, - or we might not have been able to get an unshared irq */ - if (it == NULL) - return -1; - - comedi_spin_lock_irqsave(&dev->spinlock, flags); - - if (!dev->rt) - comedi_rt_get_irq(it); - - dev->rt++; - it->rt = 1; - - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); - - return 0; -} - -void comedi_switch_to_non_rt(struct comedi_device *dev) -{ - struct comedi_irq_struct *it; - unsigned long flags; - - it = comedi_irqs[dev->irq]; - if (it == NULL) - return; - - comedi_spin_lock_irqsave(&dev->spinlock, flags); - - dev->rt--; - if (!dev->rt) - comedi_rt_release_irq(it); - - it->rt = 0; - - comedi_spin_unlock_irqrestore(&dev->spinlock, flags); -} - -void wake_up_int_handler(int arg1, void *arg2) -{ - wake_up_interruptible((wait_queue_head_t *) arg2); -} - -void comedi_rt_pend_wakeup(wait_queue_head_t *q) -{ - rt_pend_call(wake_up_int_handler, 0, q); -} - -/* RTAI section */ -#ifdef CONFIG_COMEDI_RTAI - -#ifndef HAVE_RT_REQUEST_IRQ_WITH_ARG -#define DECLARE_VOID_IRQ(irq) \ -static void handle_void_irq_ ## irq (void){ handle_void_irq(irq); } - -static void handle_void_irq(int irq) -{ - struct comedi_irq_struct *it; - - it = comedi_irqs[irq]; - if (it == NULL) { - rt_printk("comedi: null irq struct?\n"); - return; - } - it->handler(irq, it->dev_id PT_REGS_NULL); - rt_enable_irq(irq); /* needed by rtai-adeos, seems like it shouldn't hurt earlier versions */ -} - -DECLARE_VOID_IRQ(0); -DECLARE_VOID_IRQ(1); -DECLARE_VOID_IRQ(2); -DECLARE_VOID_IRQ(3); -DECLARE_VOID_IRQ(4); -DECLARE_VOID_IRQ(5); -DECLARE_VOID_IRQ(6); -DECLARE_VOID_IRQ(7); -DECLARE_VOID_IRQ(8); -DECLARE_VOID_IRQ(9); -DECLARE_VOID_IRQ(10); -DECLARE_VOID_IRQ(11); -DECLARE_VOID_IRQ(12); -DECLARE_VOID_IRQ(13); -DECLARE_VOID_IRQ(14); -DECLARE_VOID_IRQ(15); -DECLARE_VOID_IRQ(16); -DECLARE_VOID_IRQ(17); -DECLARE_VOID_IRQ(18); -DECLARE_VOID_IRQ(19); -DECLARE_VOID_IRQ(20); -DECLARE_VOID_IRQ(21); -DECLARE_VOID_IRQ(22); -DECLARE_VOID_IRQ(23); - -static void handle_void_irq_ptrs[] = { - handle_void_irq_0, - handle_void_irq_1, - handle_void_irq_2, - handle_void_irq_3, - handle_void_irq_4, - handle_void_irq_5, - handle_void_irq_6, - handle_void_irq_7, - handle_void_irq_8, - handle_void_irq_9, - handle_void_irq_10, - handle_void_irq_11, - handle_void_irq_12, - handle_void_irq_13, - handle_void_irq_14, - handle_void_irq_15, - handle_void_irq_16, - handle_void_irq_17, - handle_void_irq_18, - handle_void_irq_19, - handle_void_irq_20, - handle_void_irq_21, - handle_void_irq_22, - handle_void_irq_23, -}; - -static int comedi_rt_get_irq(struct comedi_irq_struct *it) -{ - rt_request_global_irq(it->irq, handle_void_irq_ptrs[it->irq]); - rt_startup_irq(it->irq); - - return 0; -} - -static int comedi_rt_release_irq(struct comedi_irq_struct *it) -{ - rt_shutdown_irq(it->irq); - rt_free_global_irq(it->irq); - return 0; -} -#else - -static int comedi_rt_get_irq(struct comedi_irq_struct *it) -{ - int ret; - - ret = rt_request_global_irq_arg(it->irq, it->handler, it->flags, - it->device, it->dev_id); - if (ret < 0) { - rt_printk("rt_request_global_irq_arg() returned %d\n", ret); - return ret; - } - rt_startup_irq(it->irq); - - return 0; -} - -static int comedi_rt_release_irq(struct comedi_irq_struct *it) -{ - rt_shutdown_irq(it->irq); - rt_free_global_irq(it->irq); - return 0; -} -#endif - -void comedi_rt_init(void) -{ - rt_mount_rtai(); - rt_pend_tq_init(); -} - -void comedi_rt_cleanup(void) -{ - rt_umount_rtai(); - rt_pend_tq_cleanup(); -} - -#endif - -/* Fusion section */ -#ifdef CONFIG_COMEDI_FUSION - -static void fusion_handle_irq(unsigned int irq, void *cookie) -{ - struct comedi_irq_struct *it = cookie; - - it->handler(irq, it->dev_id PT_REGS_NULL); - rthal_irq_enable(irq); -} - -static int comedi_rt_get_irq(struct comedi_irq_struct *it) -{ - rthal_irq_request(it->irq, fusion_handle_irq, it); - rthal_irq_enable(it->irq); - return 0; -} - -static int comedi_rt_release_irq(struct comedi_irq_struct *it) -{ - rthal_irq_disable(it->irq); - rthal_irq_release(it->irq); - return 0; -} - -void comedi_rt_init(void) -{ - rt_pend_tq_init(); -} - -void comedi_rt_cleanup(void) -{ - rt_pend_tq_cleanup(); -} - -#endif /*CONFIG_COMEDI_FUSION */ - -/* RTLinux section */ -#ifdef CONFIG_COMEDI_RTL - -static unsigned int handle_rtl_irq(unsigned int irq PT_REGS_ARG) -{ - struct comedi_irq_struct *it; - - it = comedi_irqs[irq]; - if (it == NULL) - return 0; - it->handler(irq, it->dev_id PT_REGS_NULL); - rtl_hard_enable_irq(irq); - return 0; -} - -static int comedi_rt_get_irq(struct comedi_irq_struct *it) -{ - rtl_request_global_irq(it->irq, handle_rtl_irq); - return 0; -} - -static int comedi_rt_release_irq(struct comedi_irq_struct *it) -{ - rtl_free_global_irq(it->irq); - return 0; -} - -void comedi_rt_init(void) -{ - rt_pend_tq_init(); -} - -void comedi_rt_cleanup(void) -{ - rt_pend_tq_cleanup(); -} - -#endif - -#ifdef CONFIG_COMEDI_PIRQ -static int comedi_rt_get_irq(struct comedi_irq_struct *it) -{ - int ret; - - free_irq(it->irq, it->dev_id); - ret = request_irq(it->irq, it->handler, it->flags | SA_PRIORITY, - it->device, it->dev_id); - - return ret; -} - -static int comedi_rt_release_irq(struct comedi_irq_struct *it) -{ - int ret; - - free_irq(it->irq, it->dev_id); - ret = request_irq(it->irq, it->handler, it->flags, - it->device, it->dev_id); - - return ret; -} - -void comedi_rt_init(void) -{ - /* rt_pend_tq_init(); */ -} - -void comedi_rt_cleanup(void) -{ - /* rt_pend_tq_cleanup(); */ -} -#endif diff --git a/drivers/staging/comedi/rt_pend_tq.c b/drivers/staging/comedi/rt_pend_tq.c deleted file mode 100644 index f9dfd9d40cd3..000000000000 --- a/drivers/staging/comedi/rt_pend_tq.c +++ /dev/null @@ -1,113 +0,0 @@ -#define __NO_VERSION__ -/* rt_pend_tq.c */ -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/sched.h> -#include "comedidev.h" /* for rt spinlocks */ -#include "rt_pend_tq.h" -#ifdef CONFIG_COMEDI_RTAI -#include <rtai.h> -#endif -#ifdef CONFIG_COMEDI_FUSION -#include <nucleus/asm/hal.h> -#endif -#ifdef CONFIG_COMEDI_RTL -#include <rtl_core.h> -#endif - -#ifdef standalone -#include <linux/module.h> -#define rt_pend_tq_init init_module -#define rt_pend_tq_cleanup cleanup_module -#endif - -volatile static struct rt_pend_tq rt_pend_tq[RT_PEND_TQ_SIZE]; -volatile static struct rt_pend_tq *volatile rt_pend_head = rt_pend_tq, - *volatile rt_pend_tail = rt_pend_tq; -int rt_pend_tq_irq = 0; -DEFINE_SPINLOCK(rt_pend_tq_lock); - -/* WARNING: following code not checked against race conditions yet. */ -#define INC_CIRCULAR_PTR(ptr,begin,size) do {if(++(ptr)>=(begin)+(size)) (ptr)=(begin); } while(0) -#define DEC_CIRCULAR_PTR(ptr,begin,size) do {if(--(ptr)<(begin)) (ptr)=(begin)+(size)-1; } while(0) - -int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1, void *arg2) -{ - unsigned long flags; - - if (func == NULL) - return -EINVAL; - if (rt_pend_tq_irq <= 0) - return -ENODEV; - comedi_spin_lock_irqsave(&rt_pend_tq_lock, flags); - INC_CIRCULAR_PTR(rt_pend_head, rt_pend_tq, RT_PEND_TQ_SIZE); - if (rt_pend_head == rt_pend_tail) { - /* overflow, we just refuse to take this request */ - DEC_CIRCULAR_PTR(rt_pend_head, rt_pend_tq, RT_PEND_TQ_SIZE); - comedi_spin_unlock_irqrestore(&rt_pend_tq_lock, flags); - return -EAGAIN; - } - rt_pend_head->func = func; - rt_pend_head->arg1 = arg1; - rt_pend_head->arg2 = arg2; - comedi_spin_unlock_irqrestore(&rt_pend_tq_lock, flags); -#ifdef CONFIG_COMEDI_RTAI - rt_pend_linux_srq(rt_pend_tq_irq); -#endif -#ifdef CONFIG_COMEDI_FUSION - rthal_apc_schedule(rt_pend_tq_irq); -#endif -#ifdef CONFIG_COMEDI_RTL - rtl_global_pend_irq(rt_pend_tq_irq); - -#endif - return 0; -} - -#ifdef CONFIG_COMEDI_RTAI -void rt_pend_irq_handler(void) -#elif defined(CONFIG_COMEDI_FUSION) -void rt_pend_irq_handler(void *cookie) -#elif defined(CONFIG_COMEDI_RTL) -void rt_pend_irq_handler(int irq, void *dev PT_REGS_ARG) -#endif -{ - while (rt_pend_head != rt_pend_tail) { - INC_CIRCULAR_PTR(rt_pend_tail, rt_pend_tq, RT_PEND_TQ_SIZE); - rt_pend_tail->func(rt_pend_tail->arg1, rt_pend_tail->arg2); - } -} - -int rt_pend_tq_init(void) -{ - rt_pend_head = rt_pend_tail = rt_pend_tq; -#ifdef CONFIG_COMEDI_RTAI - rt_pend_tq_irq = rt_request_srq(0, rt_pend_irq_handler, NULL); -#endif -#ifdef CONFIG_COMEDI_FUSION - rt_pend_tq_irq = - rthal_apc_alloc("comedi APC", rt_pend_irq_handler, NULL); -#endif -#ifdef CONFIG_COMEDI_RTL - rt_pend_tq_irq = rtl_get_soft_irq(rt_pend_irq_handler, "rt_pend_irq"); -#endif - if (rt_pend_tq_irq > 0) - printk("rt_pend_tq: RT bottom half scheduler initialized OK\n"); - else - printk("rt_pend_tq: rtl_get_soft_irq failed\n"); - return 0; -} - -void rt_pend_tq_cleanup(void) -{ - printk("rt_pend_tq: unloading\n"); -#ifdef CONFIG_COMEDI_RTAI - rt_free_srq(rt_pend_tq_irq); -#endif -#ifdef CONFIG_COMEDI_FUSION - rthal_apc_free(rt_pend_tq_irq); -#endif -#ifdef CONFIG_COMEDI_RTL - free_irq(rt_pend_tq_irq, NULL); -#endif -} diff --git a/drivers/staging/comedi/rt_pend_tq.h b/drivers/staging/comedi/rt_pend_tq.h deleted file mode 100644 index 01ed71bf409d..000000000000 --- a/drivers/staging/comedi/rt_pend_tq.h +++ /dev/null @@ -1,10 +0,0 @@ -#define RT_PEND_TQ_SIZE 16 -struct rt_pend_tq { - void (*func) (int arg1, void *arg2); - int arg1; - void *arg2; -}; -extern int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1, - void *arg2); -extern int rt_pend_tq_init(void); -extern void rt_pend_tq_cleanup(void); |