diff options
Diffstat (limited to 'drivers/staging/comedi/drivers/rtd520.c')
-rw-r--r-- | drivers/staging/comedi/drivers/rtd520.c | 277 |
1 files changed, 140 insertions, 137 deletions
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 65d5242a2585..ca347f21d140 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -196,7 +196,7 @@ Configuration options: /* The board has 3 input modes and the gains of 1,2,4,...32 (, 64, 128) */ -static const comedi_lrange rtd_ai_7520_range = { 18, { +static const struct comedi_lrange rtd_ai_7520_range = { 18, { /* +-5V input range gain steps */ BIP_RANGE(5.0), BIP_RANGE(5.0 / 2), @@ -223,7 +223,7 @@ static const comedi_lrange rtd_ai_7520_range = { 18, { }; /* PCI4520 has two more gains (6 more entries) */ -static const comedi_lrange rtd_ai_4520_range = { 24, { +static const struct comedi_lrange rtd_ai_4520_range = { 24, { /* +-5V input range gain steps */ BIP_RANGE(5.0), BIP_RANGE(5.0 / 2), @@ -255,7 +255,7 @@ static const comedi_lrange rtd_ai_4520_range = { 24, { }; /* Table order matches range values */ -static const comedi_lrange rtd_ao_range = { 4, { +static const struct comedi_lrange rtd_ao_range = { 4, { RANGE(0, 5), RANGE(0, 10), RANGE(-5, 5), @@ -266,7 +266,7 @@ static const comedi_lrange rtd_ao_range = { 4, { /* Board descriptions */ -typedef struct rtdBoard_struct { +struct rtdBoard { const char *name; /* must be first */ int device_id; int aiChans; @@ -274,12 +274,12 @@ typedef struct rtdBoard_struct { int aiMaxGain; int range10Start; /* start of +-10V range */ int rangeUniStart; /* start of +10V range */ -} rtdBoard; +}; -static const rtdBoard rtd520Boards[] = { +static const struct rtdBoard rtd520Boards[] = { { name: "DM7520", - device_id:0x7520, + device_id : 0x7520, aiChans: 16, aiBits: 12, aiMaxGain:32, @@ -288,7 +288,7 @@ static const rtdBoard rtd520Boards[] = { }, { name: "PCI4520", - device_id:0x4520, + device_id : 0x4520, aiChans: 16, aiBits: 12, aiMaxGain:128, @@ -308,13 +308,13 @@ MODULE_DEVICE_TABLE(pci, rtd520_pci_table); /* * Useful for shorthand access to the particular board structure */ -#define thisboard ((const rtdBoard *)dev->board_ptr) +#define thisboard ((const struct rtdBoard *)dev->board_ptr) /* This structure is for data unique to this hardware driver. This is also unique for each board in the system. */ -typedef struct { +struct rtdPrivate { /* memory mapped board structures */ void *las0; void *las1; @@ -334,7 +334,7 @@ typedef struct { unsigned char chanBipolar[RTD_MAX_CHANLIST / 8]; /* bit array */ /* read back data */ - lsampl_t aoValue[2]; /* Used for AO read back */ + unsigned int aoValue[2]; /* Used for AO read back */ /* timer gate (when enabled) */ u8 utcGate[4]; /* 1 extra allows simple range check */ @@ -358,7 +358,7 @@ typedef struct { u8 dma1Control; #endif /* USE_DMA */ unsigned fifoLen; -} rtdPrivate; +}; /* bit defines for "flags" */ #define SEND_EOS 0x01 /* send End Of Scan events */ @@ -366,18 +366,18 @@ typedef struct { #define DMA1_ACTIVE 0x04 /* DMA1 is active */ /* Macros for accessing channel list bit array */ -#define CHAN_ARRAY_TEST(array,index) \ +#define CHAN_ARRAY_TEST(array, index) \ (((array)[(index)/8] >> ((index) & 0x7)) & 0x1) -#define CHAN_ARRAY_SET(array,index) \ +#define CHAN_ARRAY_SET(array, index) \ (((array)[(index)/8] |= 1 << ((index) & 0x7))) -#define CHAN_ARRAY_CLEAR(array,index) \ +#define CHAN_ARRAY_CLEAR(array, index) \ (((array)[(index)/8] &= ~(1 << ((index) & 0x7)))) /* * most drivers define the following macro to make it easy to * access the private structure. */ -#define devpriv ((rtdPrivate *)dev->private) +#define devpriv ((struct rtdPrivate *)dev->private) /* Macros to access registers */ @@ -394,15 +394,15 @@ typedef struct { writel (0, devpriv->las0+LAS0_CGT_CLEAR) /* Reset channel gain table read and write pointers */ -#define RtdEnableCGT(dev,v) \ +#define RtdEnableCGT(dev, v) \ writel ((v > 0) ? 1 : 0, devpriv->las0+LAS0_CGT_ENABLE) /* Write channel gain table entry */ -#define RtdWriteCGTable(dev,v) \ +#define RtdWriteCGTable(dev, v) \ writel (v, devpriv->las0+LAS0_CGT_WRITE) /* Write Channel Gain Latch */ -#define RtdWriteCGLatch(dev,v) \ +#define RtdWriteCGLatch(dev, v) \ writel (v, devpriv->las0+LAS0_CGL_WRITE) /* Reset ADC FIFO */ @@ -410,39 +410,39 @@ typedef struct { writel (0, devpriv->las0+LAS0_ADC_FIFO_CLEAR) /* Set ADC start conversion source select (write only) */ -#define RtdAdcConversionSource(dev,v) \ +#define RtdAdcConversionSource(dev, v) \ writel (v, devpriv->las0+LAS0_ADC_CONVERSION) /* Set burst start source select (write only) */ -#define RtdBurstStartSource(dev,v) \ +#define RtdBurstStartSource(dev, v) \ writel (v, devpriv->las0+LAS0_BURST_START) /* Set Pacer start source select (write only) */ -#define RtdPacerStartSource(dev,v) \ +#define RtdPacerStartSource(dev, v) \ writel (v, devpriv->las0+LAS0_PACER_START) /* Set Pacer stop source select (write only) */ -#define RtdPacerStopSource(dev,v) \ +#define RtdPacerStopSource(dev, v) \ writel (v, devpriv->las0+LAS0_PACER_STOP) /* Set Pacer clock source select (write only) 0=external 1=internal */ -#define RtdPacerClockSource(dev,v) \ +#define RtdPacerClockSource(dev, v) \ writel ((v > 0) ? 1 : 0, devpriv->las0+LAS0_PACER_SELECT) /* Set sample counter source select (write only) */ -#define RtdAdcSampleCounterSource(dev,v) \ +#define RtdAdcSampleCounterSource(dev, v) \ writel (v, devpriv->las0+LAS0_ADC_SCNT_SRC) /* Set Pacer trigger mode select (write only) 0=single cycle, 1=repeat */ -#define RtdPacerTriggerMode(dev,v) \ +#define RtdPacerTriggerMode(dev, v) \ writel ((v > 0) ? 1 : 0, devpriv->las0+LAS0_PACER_REPEAT) /* Set About counter stop enable (write only) */ -#define RtdAboutStopEnable(dev,v) \ +#define RtdAboutStopEnable(dev, v) \ writel ((v > 0) ? 1 : 0, devpriv->las0+LAS0_ACNT_STOP_ENABLE) /* Set external trigger polarity (write only) 0=positive edge, 1=negative */ -#define RtdTriggerPolarity(dev,v) \ +#define RtdTriggerPolarity(dev, v) \ writel ((v > 0) ? 1 : 0, devpriv->las0+LAS0_ETRG_POLARITY) /* Start single ADC conversion */ @@ -473,15 +473,15 @@ typedef struct { readw (devpriv->las0+LAS0_IT) /* Interrupt mask */ -#define RtdInterruptMask(dev,v) \ - writew ((devpriv->intMask = (v)),devpriv->las0+LAS0_IT) +#define RtdInterruptMask(dev, v) \ + writew ((devpriv->intMask = (v)), devpriv->las0+LAS0_IT) /* Interrupt status clear (only bits set in mask) */ #define RtdInterruptClear(dev) \ readw (devpriv->las0+LAS0_CLEAR) /* Interrupt clear mask */ -#define RtdInterruptClearMask(dev,v) \ +#define RtdInterruptClearMask(dev, v) \ writew ((devpriv->intClearMask = (v)), devpriv->las0+LAS0_CLEAR) /* Interrupt overrun status */ @@ -495,92 +495,92 @@ typedef struct { /* Pacer counter, 24bit */ #define RtdPacerCount(dev) \ readl (devpriv->las0+LAS0_PCLK) -#define RtdPacerCounter(dev,v) \ - writel ((v) & 0xffffff,devpriv->las0+LAS0_PCLK) +#define RtdPacerCounter(dev, v) \ + writel ((v) & 0xffffff, devpriv->las0+LAS0_PCLK) /* Burst counter, 10bit */ #define RtdBurstCount(dev) \ readl (devpriv->las0+LAS0_BCLK) -#define RtdBurstCounter(dev,v) \ - writel ((v) & 0x3ff,devpriv->las0+LAS0_BCLK) +#define RtdBurstCounter(dev, v) \ + writel ((v) & 0x3ff, devpriv->las0+LAS0_BCLK) /* Delay counter, 16bit */ #define RtdDelayCount(dev) \ readl (devpriv->las0+LAS0_DCLK) -#define RtdDelayCounter(dev,v) \ +#define RtdDelayCounter(dev, v) \ writel ((v) & 0xffff, devpriv->las0+LAS0_DCLK) /* About counter, 16bit */ #define RtdAboutCount(dev) \ readl (devpriv->las0+LAS0_ACNT) -#define RtdAboutCounter(dev,v) \ +#define RtdAboutCounter(dev, v) \ writel ((v) & 0xffff, devpriv->las0+LAS0_ACNT) /* ADC sample counter, 10bit */ #define RtdAdcSampleCount(dev) \ readl (devpriv->las0+LAS0_ADC_SCNT) -#define RtdAdcSampleCounter(dev,v) \ +#define RtdAdcSampleCounter(dev, v) \ writel ((v) & 0x3ff, devpriv->las0+LAS0_ADC_SCNT) /* User Timer/Counter (8254) */ -#define RtdUtcCounterGet(dev,n) \ +#define RtdUtcCounterGet(dev, n) \ readb (devpriv->las0 \ + ((n <= 0) ? LAS0_UTC0 : ((1 == n) ? LAS0_UTC1 : LAS0_UTC2))) -#define RtdUtcCounterPut(dev,n,v) \ +#define RtdUtcCounterPut(dev, n, v) \ writeb ((v) & 0xff, devpriv->las0 \ + ((n <= 0) ? LAS0_UTC0 : ((1 == n) ? LAS0_UTC1 : LAS0_UTC2))) /* Set UTC (8254) control byte */ -#define RtdUtcCtrlPut(dev,n,v) \ +#define RtdUtcCtrlPut(dev, n, v) \ writeb (devpriv->utcCtrl[(n) & 3] = (((n) & 3) << 6) | ((v) & 0x3f), \ devpriv->las0 + LAS0_UTC_CTRL) /* Set UTCn clock source (write only) */ -#define RtdUtcClockSource(dev,n,v) \ +#define RtdUtcClockSource(dev, n, v) \ writew (v, devpriv->las0 \ + ((n <= 0) ? LAS0_UTC0_CLOCK : \ ((1 == n) ? LAS0_UTC1_CLOCK : LAS0_UTC2_CLOCK))) /* Set UTCn gate source (write only) */ -#define RtdUtcGateSource(dev,n,v) \ +#define RtdUtcGateSource(dev, n, v) \ writew (v, devpriv->las0 \ + ((n <= 0) ? LAS0_UTC0_GATE : \ ((1 == n) ? LAS0_UTC1_GATE : LAS0_UTC2_GATE))) /* User output N source select (write only) */ -#define RtdUsrOutSource(dev,n,v) \ - writel (v,devpriv->las0+((n <= 0) ? LAS0_UOUT0_SELECT : LAS0_UOUT1_SELECT)) +#define RtdUsrOutSource(dev, n, v) \ + writel (v, devpriv->las0+((n <= 0) ? LAS0_UOUT0_SELECT : LAS0_UOUT1_SELECT)) /* Digital IO */ #define RtdDio0Read(dev) \ (readw (devpriv->las0+LAS0_DIO0) & 0xff) -#define RtdDio0Write(dev,v) \ +#define RtdDio0Write(dev, v) \ writew ((v) & 0xff, devpriv->las0+LAS0_DIO0) #define RtdDio1Read(dev) \ (readw (devpriv->las0+LAS0_DIO1) & 0xff) -#define RtdDio1Write(dev,v) \ +#define RtdDio1Write(dev, v) \ writew ((v) & 0xff, devpriv->las0+LAS0_DIO1) #define RtdDioStatusRead(dev) \ (readw (devpriv->las0+LAS0_DIO_STATUS) & 0xff) -#define RtdDioStatusWrite(dev,v) \ +#define RtdDioStatusWrite(dev, v) \ writew ((devpriv->dioStatus = (v)), devpriv->las0+LAS0_DIO_STATUS) #define RtdDio0CtrlRead(dev) \ (readw (devpriv->las0+LAS0_DIO0_CTRL) & 0xff) -#define RtdDio0CtrlWrite(dev,v) \ +#define RtdDio0CtrlWrite(dev, v) \ writew ((v) & 0xff, devpriv->las0+LAS0_DIO0_CTRL) /* Digital to Analog converter */ /* Write one data value (sign + 12bit + marker bits) */ /* Note: matches what DMA would put. Actual value << 3 */ -#define RtdDacFifoPut(dev,n,v) \ +#define RtdDacFifoPut(dev, n, v) \ writew ((v), devpriv->las1 +(((n) == 0) ? LAS1_DAC1_FIFO : LAS1_DAC2_FIFO)) /* Start single DAC conversion */ -#define RtdDacUpdate(dev,n) \ +#define RtdDacUpdate(dev, n) \ writew (0, devpriv->las0 +(((n) == 0) ? LAS0_DAC1 : LAS0_DAC2)) /* Start single DAC conversion on both DACs */ @@ -588,20 +588,20 @@ typedef struct { writew (0, devpriv->las0+LAS0_DAC) /* Set DAC output type and range */ -#define RtdDacRange(dev,n,v) \ +#define RtdDacRange(dev, n, v) \ writew ((v) & 7, devpriv->las0 \ +(((n) == 0) ? LAS0_DAC1_CTRL : LAS0_DAC2_CTRL)) /* Reset DAC FIFO */ -#define RtdDacClearFifo(dev,n) \ +#define RtdDacClearFifo(dev, n) \ writel (0, devpriv->las0+(((n) == 0) ? LAS0_DAC1_RESET : LAS0_DAC2_RESET)) /* Set source for DMA 0 (write only, shadow?) */ -#define RtdDma0Source(dev,n) \ +#define RtdDma0Source(dev, n) \ writel ((n) & 0xf, devpriv->las0+LAS0_DMA0_SRC) /* Set source for DMA 1 (write only, shadow?) */ -#define RtdDma1Source(dev,n) \ +#define RtdDma1Source(dev, n) \ writel ((n) & 0xf, devpriv->las0+LAS0_DMA1_SRC) /* Reset board state for DMA 0 */ @@ -615,51 +615,51 @@ typedef struct { /* PLX9080 interrupt mask and status */ #define RtdPlxInterruptRead(dev) \ readl (devpriv->lcfg+LCFG_ITCSR) -#define RtdPlxInterruptWrite(dev,v) \ +#define RtdPlxInterruptWrite(dev, v) \ writel (v, devpriv->lcfg+LCFG_ITCSR) /* Set mode for DMA 0 */ -#define RtdDma0Mode(dev,m) \ +#define RtdDma0Mode(dev, m) \ writel ((m), devpriv->lcfg+LCFG_DMAMODE0) /* Set PCI address for DMA 0 */ -#define RtdDma0PciAddr(dev,a) \ +#define RtdDma0PciAddr(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMAPADR0) /* Set local address for DMA 0 */ -#define RtdDma0LocalAddr(dev,a) \ +#define RtdDma0LocalAddr(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMALADR0) /* Set byte count for DMA 0 */ -#define RtdDma0Count(dev,c) \ +#define RtdDma0Count(dev, c) \ writel ((c), devpriv->lcfg+LCFG_DMASIZ0) /* Set next descriptor for DMA 0 */ -#define RtdDma0Next(dev,a) \ +#define RtdDma0Next(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMADPR0) /* Set mode for DMA 1 */ -#define RtdDma1Mode(dev,m) \ +#define RtdDma1Mode(dev, m) \ writel ((m), devpriv->lcfg+LCFG_DMAMODE1) /* Set PCI address for DMA 1 */ -#define RtdDma1PciAddr(dev,a) \ +#define RtdDma1PciAddr(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMAADR1) /* Set local address for DMA 1 */ -#define RtdDma1LocalAddr(dev,a) \ +#define RtdDma1LocalAddr(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMALADR1) /* Set byte count for DMA 1 */ -#define RtdDma1Count(dev,c) \ +#define RtdDma1Count(dev, c) \ writel ((c), devpriv->lcfg+LCFG_DMASIZ1) /* Set next descriptor for DMA 1 */ -#define RtdDma1Next(dev,a) \ +#define RtdDma1Next(dev, a) \ writel ((a), devpriv->lcfg+LCFG_DMADPR1) /* Set control for DMA 0 (write only, shadow?) */ -#define RtdDma0Control(dev,n) \ +#define RtdDma0Control(dev, n) \ writeb (devpriv->dma0Control = (n), devpriv->lcfg+LCFG_DMACSR0) /* Get status for DMA 0 */ @@ -667,7 +667,7 @@ typedef struct { readb (devpriv->lcfg+LCFG_DMACSR0) /* Set control for DMA 1 (write only, shadow?) */ -#define RtdDma1Control(dev,n) \ +#define RtdDma1Control(dev, n) \ writeb (devpriv->dma1Control = (n), devpriv->lcfg+LCFG_DMACSR1) /* Get status for DMA 1 */ @@ -675,39 +675,39 @@ typedef struct { readb (devpriv->lcfg+LCFG_DMACSR1) /* - * The comedi_driver structure tells the Comedi core module + * The struct comedi_driver structure tells the Comedi core module * which functions to call to configure/deconfigure (attac/detach) * the board, and also about the kernel module that contains * the device code. */ -static int rtd_attach(comedi_device * dev, comedi_devconfig * it); -static int rtd_detach(comedi_device * dev); +static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int rtd_detach(struct comedi_device *dev); -static comedi_driver rtd520Driver = { +static struct comedi_driver rtd520Driver = { driver_name: DRV_NAME, - module:THIS_MODULE, - attach:rtd_attach, - detach:rtd_detach, + module : THIS_MODULE, + attach : rtd_attach, + detach : rtd_detach, }; -static int rtd_ai_rinsn(comedi_device * dev, comedi_subdevice * s, - comedi_insn * insn, lsampl_t * data); -static int rtd_ao_winsn(comedi_device * dev, comedi_subdevice * s, - comedi_insn * insn, lsampl_t * data); -static int rtd_ao_rinsn(comedi_device * dev, comedi_subdevice * s, - comedi_insn * insn, lsampl_t * data); -static int rtd_dio_insn_bits(comedi_device * dev, comedi_subdevice * s, - comedi_insn * insn, lsampl_t * data); -static int rtd_dio_insn_config(comedi_device * dev, comedi_subdevice * s, - comedi_insn * insn, lsampl_t * data); -static int rtd_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, - comedi_cmd * cmd); -static int rtd_ai_cmd(comedi_device * dev, comedi_subdevice * s); -static int rtd_ai_cancel(comedi_device * dev, comedi_subdevice * s); -//static int rtd_ai_poll (comedi_device *dev,comedi_subdevice *s); +static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int rtd_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int rtd_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int rtd_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int rtd_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int rtd_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +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 int rtd520_probe_fifo_depth(comedi_device *dev); +static int rtd520_probe_fifo_depth(struct comedi_device *dev); /* * Attach is called by the Comedi core to configure the driver @@ -715,9 +715,9 @@ static int rtd520_probe_fifo_depth(comedi_device *dev); * in the driver structure, dev->board_ptr contains that * address. */ -static int rtd_attach(comedi_device * dev, comedi_devconfig * it) +static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) { /* board name and options flags */ - comedi_subdevice *s; + struct comedi_subdevice *s; struct pci_dev *pcidev; int ret; resource_size_t physLas0; /* configuation */ @@ -739,7 +739,7 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. */ - if (alloc_private(dev, sizeof(rtdPrivate)) < 0) + if (alloc_private(dev, sizeof(struct rtdPrivate)) < 0) return -ENOMEM; /* @@ -779,7 +779,8 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) devpriv->pci_dev = pcidev; dev->board_name = thisboard->name; - if ((ret = comedi_pci_enable(pcidev, DRV_NAME)) < 0) { + ret = comedi_pci_enable(pcidev, DRV_NAME); + if (ret < 0) { printk("Failed to enable PCI device and request regions.\n"); return ret; } @@ -866,7 +867,7 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) s->do_cmd = rtd_ai_cmd; s->do_cmdtest = rtd_ai_cmdtest; s->cancel = rtd_ai_cancel; - /*s->poll = rtd_ai_poll; *//* not ready yet */ + /* s->poll = rtd_ai_poll; */ /* not ready yet */ s = dev->subdevices + 1; /* analog output subdevice */ @@ -918,8 +919,10 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) /* TODO: set user out source ??? */ /* check if our interrupt is available and get it */ - if ((ret = comedi_request_irq(devpriv->pci_dev->irq, rtd_interrupt, - IRQF_SHARED, DRV_NAME, dev)) < 0) { + ret = comedi_request_irq(devpriv->pci_dev->irq, rtd_interrupt, + IRQF_SHARED, DRV_NAME, dev); + + if (ret < 0) { printk("Could not get interrupt! (%u)\n", devpriv->pci_dev->irq); return ret; @@ -1005,7 +1008,7 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) #if 0 /* hit an error, clean up memory and return ret */ -//rtd_attach_die_error: +/* rtd_attach_die_error: */ #ifdef USE_DMA for (index = 0; index < DMA_CHAIN_COUNT; index++) { if (NULL != devpriv->dma0Buff[index]) { /* free buffer memory */ @@ -1057,7 +1060,7 @@ static int rtd_attach(comedi_device * dev, comedi_devconfig * it) * allocated by _attach(). dev->private and dev->subdevices are * deallocated automatically by the core. */ -static int rtd_detach(comedi_device * dev) +static int rtd_detach(struct comedi_device *dev) { #ifdef USE_DMA int index; @@ -1137,7 +1140,7 @@ static int rtd_detach(comedi_device * dev) /* Convert a single comedi channel-gain entry to a RTD520 table entry */ -static unsigned short rtdConvertChanGain(comedi_device * dev, +static unsigned short rtdConvertChanGain(struct comedi_device *dev, unsigned int comediChan, int chanIndex) { /* index in channel list */ unsigned int chan, range, aref; @@ -1187,7 +1190,7 @@ static unsigned short rtdConvertChanGain(comedi_device * dev, /* Setup the channel-gain table from a comedi list */ -static void rtd_load_channelgain_list(comedi_device * dev, +static void rtd_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan, unsigned int *list) { if (n_chan > 1) { /* setup channel gain table */ @@ -1206,9 +1209,9 @@ static void rtd_load_channelgain_list(comedi_device * dev, /* determine fifo size by doing adc conversions until the fifo half empty status flag clears */ -static int rtd520_probe_fifo_depth(comedi_device *dev) +static int rtd520_probe_fifo_depth(struct comedi_device *dev) { - lsampl_t chanspec = CR_PACK(0, 0, AREF_GROUND); + unsigned int chanspec = CR_PACK(0, 0, AREF_GROUND); unsigned i; static const unsigned limit = 0x2000; unsigned fifo_size = 0; @@ -1234,7 +1237,7 @@ static int rtd520_probe_fifo_depth(comedi_device *dev) 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", DRV_NAME, fifo_size); @@ -1251,8 +1254,8 @@ static int rtd520_probe_fifo_depth(comedi_device *dev) Note, we don't do any settling delays. Use a instruction list to select, delay, then read. */ -static int rtd_ai_rinsn(comedi_device * dev, - comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) +static int rtd_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int n, ii; int stat; @@ -1304,12 +1307,12 @@ static int rtd_ai_rinsn(comedi_device * dev, The manual claims that we can do a lword read, but it doesn't work here. */ -static int ai_read_n(comedi_device * dev, comedi_subdevice * s, int count) +static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, int count) { int ii; for (ii = 0; ii < count; ii++) { - sampl_t sample; + short sample; s16 d; if (0 == devpriv->aiCount) { /* done */ @@ -1343,10 +1346,10 @@ static int ai_read_n(comedi_device * dev, comedi_subdevice * s, int count) /* unknown amout of data is waiting in fifo. */ -static int ai_read_dregs(comedi_device * dev, comedi_subdevice * s) +static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s) { while (RtdFifoStatus(dev) & FS_ADC_NOT_EMPTY) { /* 1 -> not empty */ - sampl_t sample; + short sample; s16 d = RtdAdcFifoGet(dev); /* get 2s comp value */ if (0 == devpriv->aiCount) { /* done */ @@ -1372,20 +1375,20 @@ static int ai_read_dregs(comedi_device * dev, comedi_subdevice * s) /* Terminate a DMA transfer and wait for everything to quiet down */ -void abort_dma(comedi_device * dev, unsigned int channel) +void abort_dma(struct comedi_device *dev, unsigned int channel) { /* DMA channel 0, 1 */ unsigned long dma_cs_addr; /* the control/status register */ uint8_t status; unsigned int ii; - //unsigned long flags; + /* unsigned long flags; */ dma_cs_addr = (unsigned long)devpriv->lcfg + ((channel == 0) ? LCFG_DMACSR0 : LCFG_DMACSR1); - // spinlock for plx dma control/status reg - //comedi_spin_lock_irqsave( &dev->spinlock, flags ); + /* spinlock for plx dma control/status reg */ + /* comedi_spin_lock_irqsave( &dev->spinlock, flags ); */ - // abort dma transfer if necessary + /* abort dma transfer if necessary */ status = readb(dma_cs_addr); if ((status & PLX_DMA_EN_BIT) == 0) { /* not enabled (Error?) */ DPRINTK("rtd520: AbortDma on non-active channel %d (0x%x)\n", @@ -1410,7 +1413,7 @@ void abort_dma(comedi_device * dev, unsigned int channel) /* set abort bit for channel */ writeb(PLX_DMA_ABORT_BIT, dma_cs_addr); - // wait for dma done bit to be set + /* wait for dma done bit to be set */ status = readb(dma_cs_addr); for (ii = 0; (status & PLX_DMA_DONE_BIT) == 0 && ii < RTD_DMA_TIMEOUT; @@ -1424,14 +1427,14 @@ void abort_dma(comedi_device * dev, unsigned int channel) } abortDmaExit: - //comedi_spin_unlock_irqrestore( &dev->spinlock, flags ); + /* comedi_spin_unlock_irqrestore( &dev->spinlock, flags ); */ } /* Process what is in the DMA transfer buffer and pass to comedi Note: this is not re-entrant */ -static int ai_process_dma(comedi_device * dev, comedi_subdevice * s) +static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s) { int ii, n; s16 *dp; @@ -1441,7 +1444,7 @@ static int ai_process_dma(comedi_device * dev, comedi_subdevice * s) dp = devpriv->dma0Buff[devpriv->dma0Offset]; for (ii = 0; ii < devpriv->fifoLen / 2;) { /* convert samples */ - sampl_t sample; + short sample; if (CHAN_ARRAY_TEST(devpriv->chanBipolar, s->async->cur_chan)) { sample = (*dp >> 3) + 2048; /* convert to comedi unsigned data */ @@ -1494,10 +1497,10 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */ void *d /* our data */ PT_REGS_ARG) { /* cpu context (ignored) */ - comedi_device *dev = d; /* must be called "dev" for devpriv */ + struct comedi_device *dev = d; /* must be called "dev" for devpriv */ u16 status; u16 fifoStatus; - comedi_subdevice *s = dev->subdevices + 0; /* analog in subdevice */ + struct comedi_subdevice *s = dev->subdevices + 0; /* analog in subdevice */ if (!dev->attached) { return IRQ_NONE; @@ -1645,7 +1648,7 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */ /* return the number of samples available */ -static int rtd_ai_poll(comedi_device * dev, comedi_subdevice * s) +static int rtd_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { /* TODO: This needs to mask interrupts, read_dregs, and then re-enable */ /* Not sure what to do if DMA is active */ @@ -1662,8 +1665,8 @@ static int rtd_ai_poll(comedi_device * dev, comedi_subdevice * s) the command passes. */ -static int rtd_ai_cmdtest(comedi_device * dev, - comedi_subdevice * s, comedi_cmd * cmd) +static int rtd_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -1867,9 +1870,9 @@ static int rtd_ai_cmdtest(comedi_device * dev, This is usually done by an interrupt handler. Userland gets to the data using read calls. */ -static int rtd_ai_cmd(comedi_device * dev, comedi_subdevice * s) +static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - comedi_cmd *cmd = &s->async->cmd; + struct comedi_cmd *cmd = &s->async->cmd; int timer; /* stop anything currently running */ @@ -2064,7 +2067,7 @@ static int rtd_ai_cmd(comedi_device * dev, comedi_subdevice * s) /* Stop a running data aquisition. */ -static int rtd_ai_cancel(comedi_device * dev, comedi_subdevice * s) +static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { u16 status; @@ -2132,8 +2135,8 @@ static int rtd_ns_to_timer(unsigned int *ns, int round_mode) /* Output one (or more) analog values to a single port as fast as possible. */ -static int rtd_ao_winsn(comedi_device * dev, - comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) +static int rtd_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); @@ -2152,7 +2155,7 @@ static int rtd_ao_winsn(comedi_device * dev, /* VERIFY: comedi range and offset conversions */ if ((range > 1) /* bipolar */ - &&(data[i] < 2048)) { + && (data[i] < 2048)) { /* offset and sign extend */ val = (((int)data[i]) - 2048) << 3; } else { /* unipolor */ @@ -2187,8 +2190,8 @@ static int rtd_ao_winsn(comedi_device * dev, /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int rtd_ao_rinsn(comedi_device * dev, - comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) +static int rtd_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); @@ -2210,8 +2213,8 @@ static int rtd_ao_rinsn(comedi_device * dev, * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int rtd_dio_insn_bits(comedi_device * dev, - comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) +static int rtd_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -2237,8 +2240,8 @@ static int rtd_dio_insn_bits(comedi_device * dev, /* Configure one bit on a IO port as Input or Output (hence the name :-). */ -static int rtd_dio_insn_config(comedi_device * dev, - comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) +static int rtd_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); |