From: H Hartley Sweeten Date: Fri, 20 Jun 2014 20:12:34 +0000 (-0700) Subject: staging: comedi: dt282x: remove forward declarations X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=935f0e8c2b127d0aaec12184718c7b3fc73b7787;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: dt282x: remove forward declarations Move some of the functions to remove the need for the forward declarations. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index c2a66dcf99fe..424eebb06a41 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -248,16 +248,101 @@ struct dt282x_private { */ #define chan_to_DAC(a) ((a)&1) -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 int prep_ai_dma(struct comedi_device *dev, int dma_index, int n) +{ + struct dt282x_private *devpriv = dev->private; + int dma_chan; + unsigned long dma_ptr; + unsigned long flags; + + if (!devpriv->ntrig) + return 0; + + if (n == 0) + n = devpriv->dma_maxsize; + if (n > devpriv->ntrig * 2) + n = devpriv->ntrig * 2; + devpriv->ntrig -= n / 2; + + devpriv->dma[dma_index].size = n; + dma_chan = devpriv->dma[dma_index].chan; + dma_ptr = virt_to_bus(devpriv->dma[dma_index].buf); + + set_dma_mode(dma_chan, DMA_MODE_READ); + flags = claim_dma_lock(); + clear_dma_ff(dma_chan); + set_dma_addr(dma_chan, dma_ptr); + set_dma_count(dma_chan, n); + release_dma_lock(flags); + + enable_dma(dma_chan); + + return n; +} + +static int prep_ao_dma(struct comedi_device *dev, int dma_index, int n) +{ + struct dt282x_private *devpriv = dev->private; + int dma_chan; + unsigned long dma_ptr; + unsigned long flags; + + devpriv->dma[dma_index].size = n; + dma_chan = devpriv->dma[dma_index].chan; + dma_ptr = virt_to_bus(devpriv->dma[dma_index].buf); + + set_dma_mode(dma_chan, DMA_MODE_WRITE); + flags = claim_dma_lock(); + clear_dma_ff(dma_chan); + set_dma_addr(dma_chan, dma_ptr); + set_dma_count(dma_chan, n); + release_dma_lock(flags); + + enable_dma(dma_chan); + + return n; +} + +static void dt282x_disable_dma(struct comedi_device *dev) +{ + struct dt282x_private *devpriv = dev->private; -static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2); + if (devpriv->usedma) { + disable_dma(devpriv->dma[0].chan); + disable_dma(devpriv->dma[1].chan); + } +} + +static int dt282x_ns_to_timer(int *nanosec, int round_mode) +{ + int prescale, base, divider; + + for (prescale = 0; prescale < 16; prescale++) { + if (prescale == 1) + continue; + base = 250 * (1 << prescale); + switch (round_mode) { + case TRIG_ROUND_NEAREST: + default: + divider = (*nanosec + base / 2) / base; + break; + case TRIG_ROUND_DOWN: + divider = (*nanosec) / base; + break; + case TRIG_ROUND_UP: + divider = (*nanosec + base - 1) / base; + break; + } + if (divider < 256) { + *nanosec = divider * base; + return (prescale << 8) | (255 - divider); + } + } + base = 250 * (1 << 15); + divider = 255; + *nanosec = divider * base; + return (15 << 8) | (255 - divider); +} static void dt282x_munge(struct comedi_device *dev, unsigned short *buf, unsigned int nbytes) @@ -365,61 +450,6 @@ 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) -{ - struct dt282x_private *devpriv = dev->private; - int dma_chan; - unsigned long dma_ptr; - unsigned long flags; - - if (!devpriv->ntrig) - return 0; - - if (n == 0) - n = devpriv->dma_maxsize; - if (n > devpriv->ntrig * 2) - n = devpriv->ntrig * 2; - devpriv->ntrig -= n / 2; - - devpriv->dma[dma_index].size = n; - dma_chan = devpriv->dma[dma_index].chan; - dma_ptr = virt_to_bus(devpriv->dma[dma_index].buf); - - set_dma_mode(dma_chan, DMA_MODE_READ); - flags = claim_dma_lock(); - clear_dma_ff(dma_chan); - set_dma_addr(dma_chan, dma_ptr); - set_dma_count(dma_chan, n); - release_dma_lock(flags); - - enable_dma(dma_chan); - - return n; -} - -static int prep_ao_dma(struct comedi_device *dev, int dma_index, int n) -{ - struct dt282x_private *devpriv = dev->private; - int dma_chan; - unsigned long dma_ptr; - unsigned long flags; - - devpriv->dma[dma_index].size = n; - dma_chan = devpriv->dma[dma_index].chan; - dma_ptr = virt_to_bus(devpriv->dma[dma_index].buf); - - set_dma_mode(dma_chan, DMA_MODE_WRITE); - flags = claim_dma_lock(); - clear_dma_ff(dma_chan); - set_dma_addr(dma_chan, dma_ptr); - set_dma_count(dma_chan, n); - release_dma_lock(flags); - - enable_dma(dma_chan); - - return n; -} - static irqreturn_t dt282x_interrupt(int irq, void *d) { struct comedi_device *dev = d; @@ -710,16 +740,6 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -static void dt282x_disable_dma(struct comedi_device *dev) -{ - struct dt282x_private *devpriv = dev->private; - - if (devpriv->usedma) { - disable_dma(devpriv->dma[0].chan); - disable_dma(devpriv->dma[1].chan); - } -} - static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -736,37 +756,6 @@ static int dt282x_ai_cancel(struct comedi_device *dev, return 0; } -static int dt282x_ns_to_timer(int *nanosec, int round_mode) -{ - int prescale, base, divider; - - for (prescale = 0; prescale < 16; prescale++) { - if (prescale == 1) - continue; - base = 250 * (1 << prescale); - switch (round_mode) { - case TRIG_ROUND_NEAREST: - default: - divider = (*nanosec + base / 2) / base; - break; - case TRIG_ROUND_DOWN: - divider = (*nanosec) / base; - break; - case TRIG_ROUND_UP: - divider = (*nanosec + base - 1) / base; - break; - } - if (divider < 256) { - *nanosec = divider * base; - return (prescale << 8) | (255 - divider); - } - } - base = 250 * (1 << 15); - divider = 255; - *nanosec = divider * base; - return (15 << 8) | (255 - divider); -} - /* * Analog output routine. Selects single channel conversion, * selects correct channel, converts from 2's compliment to