diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-06-30 00:36:09 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-06 22:46:05 (GMT) |
commit | 944a2f111f5cb82c46b75a4990aa3afa4b243b35 (patch) | |
tree | 20232cf048978a346514b4e506af726b0e4b1189 /drivers/staging | |
parent | 6f37e28821c38ea1981cef26ca6187cf307ea612 (diff) | |
download | linux-fsl-qoriq-944a2f111f5cb82c46b75a4990aa3afa4b243b35.tar.xz |
staging: comedi: ni_670x: remove forward declarations
Move the attach and detach functions to remove the need for the
forward declarations.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_670x.c | 182 |
1 files changed, 83 insertions, 99 deletions
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index cea43de..e9270af 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -103,105 +103,6 @@ struct ni_670x_private { 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_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) -{ - struct comedi_subdevice *s; - int ret; - int i; - - printk(KERN_INFO "comedi%d: ni_670x: ", dev->minor); - - 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]); - if (ret < 0) - return ret; - - ret = mite_setup(devpriv->mite); - if (ret < 0) { - printk(KERN_WARNING "error setting up mite\n"); - return ret; - } - dev->board_name = thisboard->name; - dev->irq = mite_irq(devpriv->mite); - printk(KERN_INFO " %s", dev->board_name); - - ret = comedi_alloc_subdevices(dev, 2); - if (ret) - return ret; - - s = dev->subdevices + 0; - /* analog output subdevice */ - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = thisboard->ao_chans; - s->maxdata = 0xffff; - if (s->n_chan == 32) { - const struct comedi_lrange **range_table_list; - - range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32, - GFP_KERNEL); - if (!range_table_list) - return -ENOMEM; - s->range_table_list = range_table_list; - for (i = 0; i < 16; i++) { - range_table_list[i] = &range_bipolar10; - range_table_list[16 + i] = &range_0_20mA; - } - } else { - s->range_table = &range_bipolar10; - } - s->insn_write = &ni_670x_ao_winsn; - s->insn_read = &ni_670x_ao_rinsn; - - s = dev->subdevices + 1; - /* digital i/o subdevice */ - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 8; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = ni_670x_dio_insn_bits; - s->insn_config = ni_670x_dio_insn_config; - - /* Config of misc registers */ - writel(0x10, devpriv->mite->daq_io_addr + MISC_CONTROL_OFFSET); - /* Config of ao registers */ - writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET); - - printk(KERN_INFO "attached\n"); - - return 1; -} - -static void ni_670x_detach(struct comedi_device *dev) -{ - kfree(dev->subdevices[0].range_table_list); - if (dev->private && devpriv->mite) - mite_unsetup(devpriv->mite); - if (dev->irq) - free_irq(dev->irq, dev); -} - static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -320,6 +221,89 @@ static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot) return -EIO; } +static int ni_670x_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + struct comedi_subdevice *s; + int ret; + int i; + + printk(KERN_INFO "comedi%d: ni_670x: ", dev->minor); + + 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]); + if (ret < 0) + return ret; + + ret = mite_setup(devpriv->mite); + if (ret < 0) { + printk(KERN_WARNING "error setting up mite\n"); + return ret; + } + dev->board_name = thisboard->name; + dev->irq = mite_irq(devpriv->mite); + printk(KERN_INFO " %s", dev->board_name); + + ret = comedi_alloc_subdevices(dev, 2); + if (ret) + return ret; + + s = dev->subdevices + 0; + /* analog output subdevice */ + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = thisboard->ao_chans; + s->maxdata = 0xffff; + if (s->n_chan == 32) { + const struct comedi_lrange **range_table_list; + + range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32, + GFP_KERNEL); + if (!range_table_list) + return -ENOMEM; + s->range_table_list = range_table_list; + for (i = 0; i < 16; i++) { + range_table_list[i] = &range_bipolar10; + range_table_list[16 + i] = &range_0_20mA; + } + } else { + s->range_table = &range_bipolar10; + } + s->insn_write = &ni_670x_ao_winsn; + s->insn_read = &ni_670x_ao_rinsn; + + s = dev->subdevices + 1; + /* digital i/o subdevice */ + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = ni_670x_dio_insn_bits; + s->insn_config = ni_670x_dio_insn_config; + + /* Config of misc registers */ + writel(0x10, devpriv->mite->daq_io_addr + MISC_CONTROL_OFFSET); + /* Config of ao registers */ + writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET); + + printk(KERN_INFO "attached\n"); + + return 1; +} + +static void ni_670x_detach(struct comedi_device *dev) +{ + kfree(dev->subdevices[0].range_table_list); + if (dev->private && devpriv->mite) + mite_unsetup(devpriv->mite); + if (dev->irq) + free_irq(dev->irq, dev); +} + static struct comedi_driver ni_670x_driver = { .driver_name = "ni_670x", .module = THIS_MODULE, |