[PATCH 075/108] staging: comedi: addi_apci_3120: remove private data 'b_ExttrigEnable'

2014-11-04 Thread H Hartley Sweeten
This member of the private data is not really needed. The devpriv-ctrl
value can be checked to determine if the external trigger is enabled.
Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++-
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  1 -
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 84600d4..b38bbd3 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -96,7 +96,6 @@ static int apci3120_reset(struct comedi_device *dev)
/*  variables used in timer subdevice */
devpriv-b_Timer2Mode = 0;
devpriv-b_Timer2Interrupt = 0;
-   devpriv-b_ExttrigEnable = 0;   /*  Disable ext trigger */
 
/* Disable all interrupts, watchdog for the anolog output */
devpriv-mode = 0;
@@ -378,12 +377,8 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
/* load chanlist for command scan */
apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
 
-   if (cmd-start_src == TRIG_EXT) {
-   devpriv-b_ExttrigEnable = 1;
+   if (cmd-start_src == TRIG_EXT)
apci3120_exttrig_enable(dev, true);
-   } else {
-   devpriv-b_ExttrigEnable = 0;
-   }
 
if (cmd-scan_begin_src == TRIG_TIMER) {
/*
@@ -591,10 +586,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
outl(int_amcc | 0x00ff, devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   if (devpriv-b_ExttrigEnable) {
+   if (devpriv-ctrl  APCI3120_CTRL_EXT_TRIG)
apci3120_exttrig_enable(dev, false);
-   devpriv-b_ExttrigEnable = 0;
-   }
 
apci3120_clr_timer2_interrupt(dev);
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index a6ae42f..3900a90 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -133,7 +133,6 @@ struct apci3120_private {
unsigned short ctrl;
unsigned char b_Timer2Mode;
unsigned char b_Timer2Interrupt;
-   unsigned char b_ExttrigEnable;
struct task_struct *tsk_Current;
 };
 
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 033/108] staging: comedi: addi_apci_3120: remove devpriv-mode '0xef' magic value

2014-11-04 Thread H Hartley Sweeten
This mask value is the same as APCI3120_DISABLE_TIMER_COUNTER. Use that
instead and remove the magic value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index c58d4a6..f351b50 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1095,7 +1095,8 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
apci3120_timer_enable(dev, 2, false);
 
/*  Disable TIMER Interrupt */
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT  0xef;
+   devpriv-mode = APCI3120_DISABLE_TIMER_INT 
+APCI3120_DISABLE_TIMER_COUNTER;
 
/*  Disable Eoc and Eos Interrupts */
devpriv-mode = APCI3120_DISABLE_EOC_INT  APCI3120_DISABLE_EOS_INT;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 035/108] staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_WATCHDOG

2014-11-04 Thread H Hartley Sweeten
For aesthetics, remove this define and just use ~APCI3120_ENABLE_WATCHDOG.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3eb53f1..f6812ea 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -113,7 +113,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_ENABLE_WATCHDOG   0x20
-#define APCI3120_DISABLE_WATCHDOG  (~APCI3120_ENABLE_WATCHDOG)
 #define APCI3120_ENABLE_TIMER_COUNTER  0x10
 #define APCI3120_FC_TIMER  0x1000
 
@@ -1195,7 +1194,7 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
devpriv-mode = ~APCI3120_ENABLE_TIMER_COUNTER;
} else {
/* Disable WatchDog */
-   devpriv-mode = APCI3120_DISABLE_WATCHDOG;
+   devpriv-mode = ~APCI3120_ENABLE_WATCHDOG;
}
/*  Disable timer interrupt */
devpriv-mode = APCI3120_DISABLE_TIMER_INT;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 030/108] staging: comedi: addi_apci_3120: properly disable interrupts in apci3120_cancel()

2014-11-04 Thread H Hartley Sweeten
The APCI3120_DISABLE_ALL_INTERRUPT define is a mask value used to clear bits
in devpriv-b_ModeSelectRegister to disable the interrupt sources. Writing this
value directly sets unintended bits.

Just set the devpriv-b_ModeSelectRegister to '0' and write that to the 
register.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 2dd8e66..84aff80 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -92,8 +92,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_DISABLE_EOS_INT   (~APCI3120_ENABLE_EOS_INT)
 #define APCI3120_ENABLE_EOC_INT0x1
 #define APCI3120_DISABLE_EOC_INT   (~APCI3120_ENABLE_EOC_INT)
-#define APCI3120_DISABLE_ALL_INTERRUPT \
-   (APCI3120_DISABLE_TIMER_INT  APCI3120_DISABLE_EOS_INT  
APCI3120_DISABLE_EOC_INT)
 
 /* status register bits */
 #define APCI3120_EOC   0x8000
@@ -424,8 +422,9 @@ static int apci3120_cancel(struct comedi_device *dev,
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
/* DISABLE_ALL_INTERRUPT */
-   outb(APCI3120_DISABLE_ALL_INTERRUPT,
-   dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   devpriv-b_ModeSelectRegister = 0;
+   outb(devpriv-b_ModeSelectRegister,
+dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_RD_STATUS);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 010/108] staging: comedi: addi_apci_3120: introduce apci3120_timer_set_mode()

2014-11-04 Thread H Hartley Sweeten
Introduce a helper function to set the operation mode of a timer.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 57 +++---
 drivers/staging/comedi/drivers/addi_apci_3120.c|  6 +++
 2 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index a876ada..dc6eb56 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -101,8 +101,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_10_GAIN   0x30
 #define APCI3120_SEQ_RAM_ADDRESS   0x06
 #define APCI3120_RESET_FIFO0x0c
-#define APCI3120_TIMER_0_MODE_20x01
-#define APCI3120_TIMER_0_MODE_40x2
 #define APCI3120_ENABLE_TIMER0 0x1000
 #define APCI3120_CLEAR_PR  0xf0ff
 #define APCI3120_CLEAR_PA  0xfff0
@@ -140,14 +138,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_ENABLE_TIMER_INT  0x04
 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
-#define APCI3120_TIMER_1_MODE_20x4
-
-/* $$ BIT FOR MODE IN nCsTimerCtr1 */
-#define APCI3120_TIMER_2_MODE_00x0
-#define APCI3120_TIMER_2_MODE_20x10
-#define APCI3120_TIMER_2_MODE_50x30
-
-#define APCI3120_TIMER_CRT10x0c
 
 #define APCI3120_TIMER_STATUS_REGISTER 0x0d
 #define APCI3120_RD_STATUS 0x02
@@ -224,6 +214,16 @@ static unsigned int apci3120_timer_read(struct 
comedi_device *dev,
return val;
 }
 
+static void apci3120_timer_set_mode(struct comedi_device *dev,
+   unsigned int timer, unsigned int mode)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(timer);
+   devpriv-timer_mode |= APCI3120_TIMER_MODE(timer, mode);
+   outb(devpriv-timer_mode, dev-iobase + APCI3120_TIMER_MODE_REG);
+}
+
 static int apci3120_ai_insn_config(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
@@ -373,10 +373,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
 
/* Initialize Timer 0 mode 4 */
-   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(0);
-   devpriv-timer_mode |= APCI3120_TIMER_0_MODE_4;
-   outb(devpriv-timer_mode,
-dev-iobase + APCI3120_TIMER_CRT1);
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
 
/*  Reset the scan bit and Disables the  EOS, DMA, EOC 
interrupt */
devpriv-b_ModeSelectRegister =
@@ -456,10 +453,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
 
/* Initialize Timer 0 mode 2 */
-   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(0);
-   devpriv-timer_mode |= APCI3120_TIMER_0_MODE_2;
-   outb(devpriv-timer_mode,
-dev-iobase + APCI3120_TIMER_CRT1);
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor);
@@ -755,9 +749,7 @@ static int apci3120_cyclic_ai(int mode,
switch (mode) {
case 1:
/*  init timer0 in mode 2 */
-   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(0);
-   devpriv-timer_mode |= APCI3120_TIMER_0_MODE_2;
-   outb(devpriv-timer_mode, dev-iobase + APCI3120_TIMER_CRT1);
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor0);
@@ -765,17 +757,13 @@ static int apci3120_cyclic_ai(int mode,
 
case 2:
/*  init timer1 in mode 2 */
-   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(1);
-   devpriv-timer_mode |= APCI3120_TIMER_1_MODE_2;
-   outb(devpriv-timer_mode, dev-iobase + APCI3120_TIMER_CRT1);
+   apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
 
/* Set the scan begin time */
apci3120_timer_write(dev, 1, divisor1);
 
/*  init timer0 in mode 2 */
-   devpriv-timer_mode = 

[PATCH 024/108] staging: comedi: addi_apci_3120: remove unnecessary reset of the scan sequence

2014-11-04 Thread H Hartley Sweeten
The scan sequence does not need to be reset when the driver is attached. Remove
the code in apci3120_reset() that does this.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 6f547ee..3ebf5ec 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -437,8 +437,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
-   unsigned int i;
-   unsigned short us_TmpValue;
 
devpriv-ai_running = 0;
devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
@@ -463,11 +461,6 @@ static int apci3120_reset(struct comedi_device *dev)
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 */
-   for (i = 0; i  16; i++) {
-   us_TmpValue = i  8;   /* select the location */
-   outw(us_TmpValue, dev-iobase + APCI3120_SEQ_RAM_ADDRESS);
-   }
return 0;
 }
 
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 025/108] staging: comedi: addi_apci_3120: tidy up scan chanlist programming

2014-11-04 Thread H Hartley Sweeten
Define the chanlist register and its bits and tidy up the programming
of the scan chanlist.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 38 +++---
 drivers/staging/comedi/drivers/addi_apci_3120.c|  5 +++
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3ebf5ec..dd7805b 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -71,11 +71,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 /* for transfer count enable bit */
 #define AGCSTS_TC_ENABLE   0x1000
 
-/* used for test on mixture of BIP/UNI ranges */
-#define APCI3120_BIPOLAR_RANGES4
-
-#define APCI3120_ADDRESS_RANGE 16
-
 #define APCI3120_DISABLE   0
 #define APCI3120_ENABLE1
 
@@ -89,14 +84,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
-/* ANALOG OUTPUT AND INPUT DEFINE */
-#define APCI3120_UNIPOLAR  0x80
-#define APCI3120_BIPOLAR   0x00
-#define APCI3120_1_GAIN0x00
-#define APCI3120_2_GAIN0x10
-#define APCI3120_5_GAIN0x20
-#define APCI3120_10_GAIN   0x30
-#define APCI3120_SEQ_RAM_ADDRESS   0x06
 #define APCI3120_RESET_FIFO0x0c
 
 /* nWrMode_Select */
@@ -214,9 +201,7 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
char check)
 {
struct apci3120_private *devpriv = dev-private;
-   unsigned int i;
-   unsigned int gain;
-   unsigned short us_TmpValue;
+   int i;
 
/* correct channel and range number check itself comedi/range.c */
if (n_chan  1) {
@@ -233,19 +218,20 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
+   /* set chanlist for scan */
for (i = 0; i  n_chan; i++) {
-   /*  store range list to card */
-   us_TmpValue = CR_CHAN(chanlist[i]); /*  get channel number 
*/
+   unsigned int chan = CR_CHAN(chanlist[i]);
+   unsigned int range = CR_RANGE(chanlist[i]);
+   unsigned int val;
 
-   if (CR_RANGE(chanlist[i])  APCI3120_BIPOLAR_RANGES)
-   us_TmpValue = ((~APCI3120_UNIPOLAR)  0xff);   /*  set 
bipolar */
-   else
-   us_TmpValue |= APCI3120_UNIPOLAR;   /*  enable 
unipolar */
+   val = APCI3120_CHANLIST_MUX(chan) |
+ APCI3120_CHANLIST_GAIN(range) |
+ APCI3120_CHANLIST_INDEX(i);
+
+   if (comedi_range_is_unipolar(s, range))
+   val |= APCI3120_CHANLIST_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 */
-   outw(us_TmpValue, dev-iobase + APCI3120_SEQ_RAM_ADDRESS);
+   outw(val, dev-iobase + APCI3120_CHANLIST_REG);
}
return 1;   /*  we can serve this with scan logic */
 }
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ce94f90..45add76 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -22,6 +22,11 @@
 #define APCI3120_CTRL_PA(x)(((x)  0xf)  0)
 #define APCI3120_STATUS_TO_VERSION(x)  (((x)  4)  0xf)
 #define APCI3120_TIMER_REG 0x04
+#define APCI3120_CHANLIST_REG  0x06
+#define APCI3120_CHANLIST_INDEX(x) (((x)  0xf)  8)
+#define APCI3120_CHANLIST_UNIPOLAR (1  7)
+#define APCI3120_CHANLIST_GAIN(x)  (((x)  0x3)  4)
+#define APCI3120_CHANLIST_MUX(x)   (((x)  0xf)  0)
 #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2))
 #define APCI3120_AO_MUX(x) (((x)  0x3)  14)
 #define APCI3120_AO_DATA(x)((x)  0)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 046/108] staging: comedi: addi_apci_3120: remove interrupt support from ai (*insn_read)

2014-11-04 Thread H Hartley Sweeten
(*insn_read) functions are supposed to do simple polled reads of a single
channel. This driver tries to be tricky and allow enabling interrupts in
the analog input (*insn_config) to allow the (*insn_read) to read samples
with the end-of-conversion interrupt.

The (*insn_config) doesn't follow the comedi API and this operation mode
is not part of the API.

Remove the interrupt support from the (*insn_read) as well as the support
code in the (*insn_config) and interrupt handler.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 74 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  1 -
 2 files changed, 17 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 9b18abf..40ff942 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -115,10 +115,6 @@ static int apci3120_ai_insn_config(struct comedi_device 
*dev,
return -1;
 
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-   if (data[1])
-   devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
-   else
-   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
 
return insn-n;
 }
@@ -198,11 +194,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
/* Initialize Timer 0 mode 4 */
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
 
-   if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-   devpriv-mode |= APCI3120_MODE_EOC_IRQ_ENA;
-   inw(dev-iobase + 0);
-   }
-
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
apci3120_timer_enable(dev, 0, true);
@@ -213,22 +204,17 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
us_TmpValue =
(unsigned short) inw(dev-iobase + 
APCI3120_RD_STATUS);
 
-   if (devpriv-b_EocEosInterrupt == APCI3120_DISABLE) {
-
-   do {
-   /*  Waiting for the end of conversion */
-   us_TmpValue = inw(dev-iobase +
- APCI3120_RD_STATUS);
-   } while ((us_TmpValue  APCI3120_EOC) ==
-   APCI3120_EOC);
-
-   /* Read the result in FIFO  and put it in insn 
data pointer */
-   us_TmpValue = inw(dev-iobase + 0);
-   *data = us_TmpValue;
+   do {
+   /*  Waiting for the end of conversion */
+   us_TmpValue = inw(dev-iobase +
+ APCI3120_RD_STATUS);
+   } while ((us_TmpValue  APCI3120_EOC) == APCI3120_EOC);
 
-   apci3120_ai_reset_fifo(dev);
-   }
+   /* Read the result in FIFO  and put it in insn data 
pointer */
+   us_TmpValue = inw(dev-iobase + 0);
+   *data = us_TmpValue;
 
+   apci3120_ai_reset_fifo(dev);
break;
default:
dev_err(dev-class_dev, inputs wrong\n);
@@ -245,7 +231,6 @@ static int apci3120_reset(struct comedi_device *dev)
struct apci3120_private *devpriv = dev-private;
 
devpriv-ai_running = 0;
-   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
 
/*  variables used in timer subdevice */
@@ -298,7 +283,6 @@ static int apci3120_cancel(struct comedi_device *dev,
 
devpriv-ai_running = 0;
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
 
return 0;
 }
@@ -448,7 +432,6 @@ static int apci3120_cyclic_ai(int mode,
if (devpriv-us_UseDma == APCI3120_DISABLE) {
/*  disable EOC and enable EOS */
devpriv-b_InterruptMode = APCI3120_EOS_MODE;
-   devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
 
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
@@ -816,9 +799,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
struct apci3120_private *devpriv = dev-private;
struct comedi_subdevice *s = dev-read_subdev;
unsigned short int_daq;
-   unsigned int int_amcc, ui_Check;
-
-   ui_Check = 1;
+   

[PATCH 071/108] staging: comedi: addi_apci_3120: set scan length/start after programming chanlist

2014-11-04 Thread H Hartley Sweeten
The APCI-3120 documentation says that the PR/PA bits should be set after the
chanlist sequence is programmed.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 77499b4..f258ceb 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -286,10 +286,6 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
struct apci3120_private *devpriv = dev-private;
int i;
 
-   /* set scan length (PR) and scan start (PA) */
-   devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
-
/* set chanlist for scan */
for (i = 0; i  n_chan; i++) {
unsigned int chan = CR_CHAN(chanlist[i]);
@@ -307,6 +303,10 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
}
 
apci3120_ai_reset_fifo(dev);
+
+   /* set scan length (PR) and scan start (PA) */
+   devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
 #include addi-data/hwdrv_apci3120.c
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 057/108] staging: comedi: addi_apci_3120: move apci3120_di_insn_bits() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function from the included hwdrv_apci31210.c source file to the main
driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 13 -
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 13 +
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index d577d37..a206d5e 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1018,19 +1018,6 @@ static int apci3120_read_insn_timer(struct comedi_device 
*dev,
return insn-n;
 }
 
-static int apci3120_di_insn_bits(struct comedi_device *dev,
-struct comedi_subdevice *s,
-struct comedi_insn *insn,
-unsigned int *data)
-{
-   unsigned int status;
-
-   status = inw(dev-iobase + APCI3120_STATUS_REG);
-   data[1] = APCI3120_STATUS_TO_DI_BITS(status);
-
-   return insn-n;
-}
-
 static int apci3120_ao_ready(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 22d17e2..7033b0b 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -281,6 +281,19 @@ static void apci3120_ai_reset_fifo(struct comedi_device 
*dev)
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_di_insn_bits(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_insn *insn,
+unsigned int *data)
+{
+   unsigned int status;
+
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
+   data[1] = APCI3120_STATUS_TO_DI_BITS(status);
+
+   return insn-n;
+}
+
 static int apci3120_do_insn_bits(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 012/108] staging: comedi: addi_apci_3120: rename private data 'us_OutputRegister'

2014-11-04 Thread H Hartley Sweeten
Rename this CamelCase member of the private data and tidy up the mask/set
of its bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 110 -
 drivers/staging/comedi/drivers/addi_apci_3120.c|   2 +-
 2 files changed, 42 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index d4d66e4..4231e99 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -247,10 +247,9 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
return 1;
 
/* 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);
+   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
+   devpriv-ctrl = ((n_chan - 1)  0xf)  8;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
for (i = 0; i  n_chan; i++) {
/*  store range list to card */
@@ -293,7 +292,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
/*  Clear software registers */
devpriv-timer_mode = 0;
devpriv-b_ModeSelectRegister = 0;
-   devpriv-us_OutputRegister = 0;
+   devpriv-ctrl = 0;
 
if (insn-unused[0] == 222) {   /*  second insn read */
for (i = 0; i  insn-n; i++)
@@ -348,12 +347,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/*  Sets gate 0 */
-   devpriv-us_OutputRegister =
-   (devpriv-
-   us_OutputRegister  APCI3120_CLEAR_PA_PR) |
-   APCI3120_ENABLE_TIMER0;
-   outw(devpriv-us_OutputRegister,
-dev-iobase + APCI3120_WR_ADDRESS);
+   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
+   devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor);
@@ -386,13 +382,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + APCI3120_RESET_FIFO);
/*  clear PA PR  and disable timer 0 */
 
-   devpriv-us_OutputRegister =
-   (devpriv-
-   us_OutputRegister  APCI3120_CLEAR_PA_PR) |
-   APCI3120_DISABLE_TIMER0;
-
-   outw(devpriv-us_OutputRegister,
-dev-iobase + APCI3120_WR_ADDRESS);
+   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
+   devpriv-ctrl |= APCI3120_DISABLE_TIMER0;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
if (!apci3120_setup_chan_list(dev, s,
devpriv-ui_AiNbrofChannels,
@@ -434,11 +426,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + APCI3120_RD_STATUS);
 
/* Sets gate 0 */
-   devpriv-us_OutputRegister =
-   devpriv-
-   us_OutputRegister | APCI3120_ENABLE_TIMER0;
-   outw(devpriv-us_OutputRegister,
-dev-iobase + APCI3120_WR_ADDRESS);
+   devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/* Start conversion */
outw(0, dev-iobase + APCI3120_START_CONVERSION);
@@ -496,8 +485,8 @@ static int apci3120_reset(struct comedi_device *dev)
dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/*  Disables all counters, ext trigger and clears PA, PR */
-   devpriv-us_OutputRegister = 0;
-   outw(devpriv-us_OutputRegister, dev-iobase + APCI3120_WR_ADDRESS);
+   devpriv-ctrl = 0;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
inw(dev-iobase + 0);   /* make a dummy read */
inb(dev-iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
@@ -515,8 +504,8 @@ static int apci3120_exttrig_enable(struct comedi_device 
*dev)
 {
struct apci3120_private *devpriv = dev-private;
 
-   devpriv-us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
-   

[PATCH 038/108] staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOS_INT

2014-11-04 Thread H Hartley Sweeten
For aesthetics, remove this define and just use ~APCI3120_ENABLE_EOS_INT.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 545bc90..a71b70f 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -89,7 +89,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_DISABLE_SCAN  (~APCI3120_ENABLE_SCAN)
 #define APCI3120_ENABLE_EOS_INT0x2
 
-#define APCI3120_DISABLE_EOS_INT   (~APCI3120_ENABLE_EOS_INT)
 #define APCI3120_ENABLE_EOC_INT0x1
 
 /* status register bits */
@@ -1000,7 +999,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
}
 
} else {
-   devpriv-mode = APCI3120_DISABLE_EOS_INT;
+   devpriv-mode = ~APCI3120_ENABLE_EOS_INT;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
devpriv-b_EocEosInterrupt = APCI3120_DISABLE;  /* 
Default settings */
@@ -1013,7 +1012,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
switch (devpriv-b_Timer2Mode) {
case APCI3120_COUNTER:
-   devpriv-mode = APCI3120_DISABLE_EOS_INT;
+   devpriv-mode = ~APCI3120_ENABLE_EOS_INT;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
@@ -1095,7 +1094,7 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
 ~APCI3120_ENABLE_TIMER_COUNTER;
 
/*  Disable Eoc and Eos Interrupts */
-   devpriv-mode = ~APCI3120_ENABLE_EOC_INT  APCI3120_DISABLE_EOS_INT;
+   devpriv-mode = ~APCI3120_ENABLE_EOC_INT  ~APCI3120_ENABLE_EOS_INT;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
if (data[0] == APCI3120_TIMER) {/* initialize timer */
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 043/108] staging: comedi: addi_apci_3120: rename APCI3120_WRITE_MODE_SELECT

2014-11-04 Thread H Hartley Sweeten
For aesthetics, rename this define used for the mode register offset.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 42 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  1 +
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index c0ae6d3..0e76b65 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -98,7 +98,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_WATCHDOG  2
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
-#define APCI3120_WRITE_MODE_SELECT 0x0e
 
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_FC_TIMER  0x1000
@@ -240,8 +239,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + 0);
}
 
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
apci3120_timer_enable(dev, 0, true);
 
@@ -285,8 +283,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
/* Set the scan bit */
devpriv-mode |= APCI3120_MODE_SCAN_ENA;
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
/* If Interrupt function is loaded */
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
@@ -294,8 +291,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + 0);
}
 
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
inw(dev-iobase + APCI3120_RD_STATUS);
 
@@ -351,7 +347,7 @@ static int apci3120_reset(struct comedi_device *dev)
 
/* Disable all interrupts, watchdog for the anolog output */
devpriv-mode = 0;
-   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
/* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
@@ -386,7 +382,7 @@ static int apci3120_cancel(struct comedi_device *dev,
 
/* DISABLE_ALL_INTERRUPT */
devpriv-mode = 0;
-   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_RD_STATUS);
@@ -538,7 +534,7 @@ static int apci3120_cyclic_ai(int mode,
 
}
 
-   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
/*  If DMA is disabled */
if (devpriv-us_UseDma == APCI3120_DISABLE) {
@@ -547,7 +543,7 @@ static int apci3120_cyclic_ai(int mode,
devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
 
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
if (cmd-stop_src == TRIG_COUNT) {
/* configure Timer2 For counting EOS */
@@ -563,8 +559,7 @@ static int apci3120_cyclic_ai(int mode,
devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
 APCI3120_MODE_TIMER2_CLK_EOS |
 APCI3120_MODE_TIMER2_IRQ_ENA;
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = APCI3120_ENABLE;
@@ -954,8 +949,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
} else {
/* Disable EOC Interrupt */
devpriv-mode = ~APCI3120_MODE_EOC_IRQ_ENA;
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
}
}
 
@@ -969,7 +963,7 @@ static irqreturn_t 

[PATCH 023/108] staging: comedi: addi_apci_3120: introduce apci3120_clr_timer2_interrupt()

2014-11-04 Thread H Hartley Sweeten
A dummy read of APCI3120_CTR0_REG clears the timer 2 interrupt. Introduce a
helper function to clarify this.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 30 --
 drivers/staging/comedi/drivers/addi_apci_3120.c|  6 +
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3683c9c..6f547ee 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -130,7 +130,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
 
-#define APCI3120_TIMER_STATUS_REGISTER 0x0d
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_ENABLE_WATCHDOG   0x20
 #define APCI3120_DISABLE_WATCHDOG  (~APCI3120_ENABLE_WATCHDOG)
@@ -691,8 +690,8 @@ static int apci3120_cyclic_ai(int mode,
/* Set the scan stop count (not sure about the -2) */
apci3120_timer_write(dev, 2, cmd-stop_arg - 2);
 
-   /* (2) Reset FC_TIMER BIT  Clearing timer status 
register */
-   inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
+   apci3120_clr_timer2_interrupt(dev);
+
/*  enable timer counter and disable watch dog */
devpriv-b_ModeSelectRegister =
(devpriv-
@@ -1067,7 +1066,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
unsigned short int_daq;
unsigned int int_amcc, ui_Check, i;
unsigned short us_TmpValue;
-   unsigned char b_DummyRead;
 
ui_Check = 1;
 
@@ -1087,8 +1085,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
apci3120_exttrig_enable(dev, false);
devpriv-b_ExttrigEnable = APCI3120_DISABLE;
}
-   /* clear the timer 2 interrupt */
-   inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
+
+   apci3120_clr_timer2_interrupt(dev);
 
if (int_amcc  MASTER_ABORT_INT)
dev_err(dev-class_dev, AMCC IRQ - MASTER DMA ABORT!\n);
@@ -1194,8 +1192,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
}
 
-   b_DummyRead = inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
-
+   apci3120_clr_timer2_interrupt(dev);
}
 
if ((int_daq  0x4)  (devpriv-b_InterruptMode == APCI3120_DMA_MODE)) 
{
@@ -1205,8 +1202,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
outl(APCI3120_CLEAR_WRITE_TC_INT,
 devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
-   /* Clears the timer status register */
-   inw(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
+   apci3120_clr_timer2_interrupt(dev);
+
/* do some data transfer */
apci3120_interrupt_dma(irq, d);
} else {
@@ -1318,9 +1315,8 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
 
switch (data[0]) {
case APCI3120_START:
+   apci3120_clr_timer2_interrupt(dev);
 
-   /*  Reset FC_TIMER BIT */
-   inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
if (devpriv-b_Timer2Mode == APCI3120_TIMER) {  /* start timer 
*/
/* Enable Timer */
devpriv-b_ModeSelectRegister =
@@ -1382,9 +1378,7 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
 
apci3120_timer_enable(dev, 2, false);
 
-   /*  Reset FC_TIMER BIT */
-   inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
-
+   apci3120_clr_timer2_interrupt(dev);
break;
 
case 2: /* write new value to Timer */
@@ -1434,10 +1428,8 @@ static int apci3120_read_insn_timer(struct comedi_device 
*dev,
us_StatusValue = inw(dev-iobase + APCI3120_RD_STATUS);
us_StatusValue =
((us_StatusValue  APCI3120_FC_TIMER)  12)  1;
-   if (us_StatusValue == 1) {
-   /*  RESET FC_TIMER BIT */
-   inb(dev-iobase + APCI3120_TIMER_STATUS_REGISTER);
-   }
+   if (us_StatusValue == 1)
+   apci3120_clr_timer2_interrupt(dev);
data[0] = us_StatusValue;   /*  when data[0] = 1 then the 
watch dog has rundown */
}
return insn-n;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 

[PATCH 018/108] staging: comedi: addi_apci_3120: introduce apci3120_timer_enable()

2014-11-04 Thread H Hartley Sweeten
Introduce a helper function to enable/disable a timer.

The disable of timers 0 and 1 in apci3120_interrupt() is probably not needed.
For now use the helper function to make sure the devpriv-ctrl bits are cleared
correctly to disable the timers.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 58 ++
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 30606c9..8da1db5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -156,6 +156,18 @@ static const struct comedi_lrange range_apci3120_ai = {
}
 };
 
+static void apci3120_timer_enable(struct comedi_device *dev,
+ unsigned int timer, bool enable)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   if (enable)
+   devpriv-ctrl |= APCI3120_CTRL_GATE(timer);
+   else
+   devpriv-ctrl = ~APCI3120_CTRL_GATE(timer);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+}
+
 static int apci3120_ai_insn_config(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
@@ -329,9 +341,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outb(devpriv-b_ModeSelectRegister,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
-   /*  Sets gate 0 */
-   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 0, true);
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor);
@@ -402,9 +412,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
inw(dev-iobase + APCI3120_RD_STATUS);
 
-   /* Sets gate 0 */
-   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 0, true);
 
/* Start conversion */
outw(0, dev-iobase + APCI3120_START_CONVERSION);
@@ -887,25 +895,17 @@ static int apci3120_cyclic_ai(int mode,
}
 
if (devpriv-us_UseDma == APCI3120_DISABLE 
-   cmd-stop_src == TRIG_COUNT) {
-   /*  set gate 2   to start conversion */
-   devpriv-ctrl |= APCI3120_CTRL_GATE(2);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
-   }
+   cmd-stop_src == TRIG_COUNT)
+   apci3120_timer_enable(dev, 2, true);
 
switch (mode) {
case 1:
-   /*  set gate 0   to start conversion */
-   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 0, true);
break;
case 2:
-   /*  set  gate 0 and gate 1 */
-   devpriv-ctrl |= APCI3120_CTRL_GATE(1) |
-APCI3120_CTRL_GATE(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 1, true);
+   apci3120_timer_enable(dev, 0, true);
break;
-
}
 
return 0;
@@ -1234,11 +1234,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
/* do some data transfer */
apci3120_interrupt_dma(irq, d);
} else {
-   /* Stops the Timer */
-   outw(devpriv-ctrl 
-~APCI3120_CTRL_GATE(0) 
-~APCI3120_CTRL_GATE(1),
-dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 0, false);
+   apci3120_timer_enable(dev, 1, false);
}
 
}
@@ -1270,9 +1267,7 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
 
divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN);
 
-   /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
-   devpriv-ctrl = ~APCI3120_CTRL_GATE(2);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   apci3120_timer_enable(dev, 2, false);
 
/*  Disable TIMER Interrupt */
devpriv-b_ModeSelectRegister =
@@ -1381,12 +1376,9 @@ static int apci3120_write_insn_timer(struct 
comedi_device *dev,
outb(devpriv-b_ModeSelectRegister,
  

[PATCH 054/108] staging: comedi: addi_apci_3120: define status register bits

2014-11-04 Thread H Hartley Sweeten
Define the bits in the status register and use them to clarify the code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 58 ++
 drivers/staging/comedi/drivers/addi_apci_3120.c|  9 
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 5deb1ff..83881a6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -83,10 +83,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_RD_FIFO   0x00
 
-/* status register bits */
-#define APCI3120_EOC   0x8000
-#define APCI3120_EOS   0x2000
-
 /* software trigger dummy register */
 #define APCI3120_START_CONVERSION  0x02
 
@@ -98,8 +94,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
 
-#define APCI3120_FC_TIMER  0x1000
-
 #define APCI3120_COUNTER   3
 
 static int apci3120_setup_chan_list(struct comedi_device *dev,
@@ -145,7 +139,7 @@ static int apci3120_ai_eoc(struct comedi_device *dev,
unsigned int status;
 
status = inw(dev-iobase + APCI3120_STATUS_REG);
-   if ((status  APCI3120_EOC) == 0)
+   if ((status  APCI3120_STATUS_EOC_INT) == 0)
return 0;
return -EBUSY;
 }
@@ -748,21 +742,20 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
struct apci3120_private *devpriv = dev-private;
struct comedi_subdevice *s = dev-read_subdev;
struct comedi_cmd *cmd = s-async-cmd;
-   unsigned short int_daq;
+   unsigned int status;
unsigned int int_amcc;
 
-   int_daq = inw(dev-iobase + APCI3120_STATUS_REG)  0xf000;
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
int_amcc = inl(devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   if ((!int_daq)  (!(int_amcc  ANY_S593X_INT))) {
+   if (!(status  APCI3120_STATUS_INT_MASK) 
+   !(int_amcc  ANY_S593X_INT)) {
dev_err(dev-class_dev, IRQ from unknown source\n);
return IRQ_NONE;
}
 
outl(int_amcc | 0x00ff, devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   int_daq = (int_daq  12)  0xF;
-
if (devpriv-b_ExttrigEnable == APCI3120_ENABLE) {
apci3120_exttrig_enable(dev, false);
devpriv-b_ExttrigEnable = APCI3120_DISABLE;
@@ -775,14 +768,13 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
if (int_amcc  TARGET_ABORT_INT)
dev_err(dev-class_dev, AMCC IRQ - TARGET DMA ABORT!\n);
 
-   /*  Ckeck if EOC interrupt */
-   if (((int_daq  0x8) == 0) 
-   (devpriv-b_InterruptMode == APCI3120_EOC_MODE)) {
+   if ((status  APCI3120_STATUS_EOC_INT) == 0 
+   devpriv-b_InterruptMode == APCI3120_EOC_MODE) {
/* nothing to do... EOC mode is not currently used */
}
 
-   /*  Check If EOS interrupt */
-   if ((int_daq  0x2)  (devpriv-b_InterruptMode == APCI3120_EOS_MODE)) 
{
+   if ((status  APCI3120_STATUS_EOS_INT) 
+   devpriv-b_InterruptMode == APCI3120_EOS_MODE) {
if (devpriv-ai_running) {
unsigned short val;
int i;
@@ -797,9 +789,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
}
}
 
-   /* Timer2 interrupt */
-   if (int_daq  0x1) {
-
+   if (status  APCI3120_STATUS_TIMER2_INT) {
switch (devpriv-b_Timer2Mode) {
case APCI3120_COUNTER:
devpriv-mode = ~APCI3120_MODE_EOS_IRQ_ENA;
@@ -829,7 +819,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
apci3120_clr_timer2_interrupt(dev);
}
 
-   if ((int_daq  0x4)  (devpriv-b_InterruptMode == APCI3120_DMA_MODE)) 
{
+   if ((status  APCI3120_STATUS_AMCC_INT) 
+   devpriv-b_InterruptMode == APCI3120_DMA_MODE) {
if (devpriv-ai_running) {
 
/* Clear Timer Write TC int */
@@ -1019,7 +1010,7 @@ static int apci3120_read_insn_timer(struct comedi_device 
*dev,
unsigned int *data)
 {
struct apci3120_private *devpriv = dev-private;
-   unsigned short us_StatusValue;
+   unsigned int status;
 
if ((devpriv-b_Timer2Mode != APCI3120_WATCHDOG)
 (devpriv-b_Timer2Mode != APCI3120_TIMER)) {
@@ -1027,13 +1018,15 @@ static int apci3120_read_insn_timer(struct 
comedi_device *dev,
}
if (devpriv-b_Timer2Mode == APCI3120_TIMER) {
data[0] = 

[PATCH 056/108] staging: comedi: addi_apci_3120: move apci3120_do_insn_bits() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function from the included hwdrv_apci31210.c source file to the main
driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c  | 18 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 18 ++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 7bd17c2..d577d37 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1031,24 +1031,6 @@ static int apci3120_di_insn_bits(struct comedi_device 
*dev,
return insn-n;
 }
 
-static int apci3120_do_insn_bits(struct comedi_device *dev,
-struct comedi_subdevice *s,
-struct comedi_insn *insn,
-unsigned int *data)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   if (comedi_dio_update_state(s, data)) {
-   devpriv-do_bits = s-state;
-   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits),
-dev-iobase + APCI3120_CTR0_REG);
-   }
-
-   data[1] = s-state;
-
-   return insn-n;
-}
-
 static int apci3120_ao_ready(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 98de447..22d17e2 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -281,6 +281,24 @@ static void apci3120_ai_reset_fifo(struct comedi_device 
*dev)
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_do_insn_bits(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_insn *insn,
+unsigned int *data)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   if (comedi_dio_update_state(s, data)) {
+   devpriv-do_bits = s-state;
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits),
+dev-iobase + APCI3120_CTR0_REG);
+   }
+
+   data[1] = s-state;
+
+   return insn-n;
+}
+
 static void apci3120_dma_alloc(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 050/108] staging: comedi: addi_apci_3120: absorb apci3120_interrupt_handle_eos()

2014-11-04 Thread H Hartley Sweeten
Absorb this simple function into apci3120_interrupt().

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 28 +++---
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 5fb8848..1913fd2 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -747,25 +747,6 @@ static void apci3120_interrupt_dma(int irq, void *d)
}
 }
 
-/*
- * This function handles EOS interrupt.
- * This function copies the acquired data(from FIFO) to Comedi buffer.
- */
-static int apci3120_interrupt_handle_eos(struct comedi_device *dev)
-{
-   struct apci3120_private *devpriv = dev-private;
-   struct comedi_subdevice *s = dev-read_subdev;
-   unsigned short val;
-   int i;
-
-   for (i = 0; i  devpriv-ui_AiNbrofChannels; i++) {
-   val = inw(dev-iobase + 0);
-   comedi_buf_write_samples(s, val, 1);
-   }
-
-   return 0;
-}
-
 static irqreturn_t apci3120_interrupt(int irq, void *d)
 {
struct comedi_device *dev = d;
@@ -807,7 +788,14 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
/*  Check If EOS interrupt */
if ((int_daq  0x2)  (devpriv-b_InterruptMode == APCI3120_EOS_MODE)) 
{
if (devpriv-ai_running) {
-   apci3120_interrupt_handle_eos(dev);
+   unsigned short val;
+   int i;
+
+   for (i = 0; i  devpriv-ui_AiNbrofChannels; i++) {
+   val = inw(dev-iobase + 0);
+   comedi_buf_write_samples(s, val, 1);
+   }
+
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
}
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 042/108] staging: comedi: addi_apci_3120: define the timer 2 clock select bits

2014-11-04 Thread H Hartley Sweeten
For aesthetics, redefine the bits in the mode register used to select the
clock for timer 2.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ---
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  5 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 87c82e4..c0ae6d3 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -103,7 +103,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_FC_TIMER  0x1000
 
-#define APCI3120_TIMER2_SELECT_EOS 0xc0
 #define APCI3120_COUNTER   3
 
 static int apci3120_ai_insn_config(struct comedi_device *dev,
@@ -561,14 +560,12 @@ static int apci3120_cyclic_ai(int mode,
 
apci3120_clr_timer2_interrupt(dev);
 
-   /*  enable timer counter and disable watch dog */
-   devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER;
-   /*  select EOS clock input for timer 2 */
-   devpriv-mode |= APCI3120_TIMER2_SELECT_EOS;
-   /*  Enable timer2  interrupt */
-   devpriv-mode |= APCI3120_MODE_TIMER2_IRQ_ENA;
+   devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
+APCI3120_MODE_TIMER2_CLK_EOS |
+APCI3120_MODE_TIMER2_IRQ_ENA;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
+
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = APCI3120_ENABLE;
}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ed51f41..10155e6 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -40,6 +40,11 @@
 #define APCI3120_CTR0_REG  0x0d
 #define APCI3120_CTR0_DO_BITS(x)   ((x)  4)
 #define APCI3120_CTR0_TIMER_SEL(x) ((x)  0)
+#define APCI3120_MODE_TIMER2_CLK_OSC   (0  6)
+#define APCI3120_MODE_TIMER2_CLK_OUT1  (1  6)
+#define APCI3120_MODE_TIMER2_CLK_EOC   (2  6)
+#define APCI3120_MODE_TIMER2_CLK_EOS   (3  6)
+#define APCI3120_MODE_TIMER2_CLK_MASK  (3  6)
 #define APCI3120_MODE_TIMER2_AS_TIMER  (0  4)
 #define APCI3120_MODE_TIMER2_AS_COUNTER(1  4)
 #define APCI3120_MODE_TIMER2_AS_WDOG   (2  4)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 015/108] staging: comedi: addi_apci_3120: tidy up APCI3120_ENABLE_TIMER[012]

2014-11-04 Thread H Hartley Sweeten
For aesthetics, replace these defines with a macro that returns the
correct bit needed to set the gate bit to enable a timer.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 25 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  1 +
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3575453..8e474a1 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -101,7 +101,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_10_GAIN   0x30
 #define APCI3120_SEQ_RAM_ADDRESS   0x06
 #define APCI3120_RESET_FIFO0x0c
-#define APCI3120_ENABLE_TIMER0 0x1000
 
 /* nWrMode_Select */
 #define APCI3120_ENABLE_SCAN   0x8
@@ -130,7 +129,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_WATCHDOG  2
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
-#define APCI3120_ENABLE_TIMER2 0x4000
 #define APCI3120_ENABLE_TIMER_INT  0x04
 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
@@ -143,9 +141,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_ENABLE_TIMER_COUNTER  0x10
 #define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER)
 #define APCI3120_FC_TIMER  0x1000
-#define APCI3120_ENABLE_TIMER0 0x1000
-#define APCI3120_ENABLE_TIMER1 0x2000
-#define APCI3120_ENABLE_TIMER2 0x4000
 
 #define APCI3120_TIMER2_SELECT_EOS 0xc0
 #define APCI3120_COUNTER   3
@@ -338,7 +333,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/*  Sets gate 0 */
-   devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
+   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/* Set the conversion time */
@@ -411,7 +406,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + APCI3120_RD_STATUS);
 
/* Sets gate 0 */
-   devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
+   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/* Start conversion */
@@ -903,20 +898,20 @@ static int apci3120_cyclic_ai(int mode,
if (devpriv-us_UseDma == APCI3120_DISABLE 
cmd-stop_src == TRIG_COUNT) {
/*  set gate 2   to start conversion */
-   devpriv-ctrl |= APCI3120_ENABLE_TIMER2;
+   devpriv-ctrl |= APCI3120_CTRL_GATE(2);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
}
 
switch (mode) {
case 1:
/*  set gate 0   to start conversion */
-   devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
+   devpriv-ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
break;
case 2:
/*  set  gate 0 and gate 1 */
-   devpriv-ctrl |= APCI3120_ENABLE_TIMER1 |
-APCI3120_ENABLE_TIMER0;
+   devpriv-ctrl |= APCI3120_CTRL_GATE(1) |
+APCI3120_CTRL_GATE(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
break;
 
@@ -1251,8 +1246,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
} else {
/* Stops the Timer */
outw(devpriv-ctrl 
-~APCI3120_ENABLE_TIMER0 
-~APCI3120_ENABLE_TIMER1,
+~APCI3120_CTRL_GATE(0) 
+~APCI3120_CTRL_GATE(1),
 dev-iobase + APCI3120_WR_ADDRESS);
}
 
@@ -1286,7 +1281,7 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN);
 
/* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
-   devpriv-ctrl = ~APCI3120_ENABLE_TIMER2;
+   devpriv-ctrl = ~APCI3120_CTRL_GATE(2);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/*  Disable TIMER Interrupt */
@@ -1398,7 +1393,7 @@ static int 

[PATCH 011/108] staging: comedi: addi_apci_3120: move timer helpers to main driver source

2014-11-04 Thread H Hartley Sweeten
Move the timer read/write and set mode helpers from the included source
file into the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 53 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 53 ++
 2 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index dc6eb56..d4d66e4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -171,59 +171,6 @@ static const struct comedi_lrange range_apci3120_ai = {
}
 };
 
-static void apci3120_timer_write(struct comedi_device *dev,
-unsigned int timer, unsigned int val)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   /* write 16-bit value to timer (lower 16-bits of timer 2) */
-   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
-APCI3120_CTR0_TIMER_SEL(timer),
-dev-iobase + APCI3120_CTR0_REG);
-   outw(val  0x, dev-iobase + APCI3120_TIMER_REG);
-
-   if (timer == 2) {
-   /* write upper 16-bits to timer 2 */
-   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
-APCI3120_CTR0_TIMER_SEL(timer + 1),
-dev-iobase + APCI3120_CTR0_REG);
-   outw((val  16)  0x, dev-iobase + APCI3120_TIMER_REG);
-   }
-}
-
-static unsigned int apci3120_timer_read(struct comedi_device *dev,
-   unsigned int timer)
-{
-   struct apci3120_private *devpriv = dev-private;
-   unsigned int val;
-
-   /* read 16-bit value from timer (lower 16-bits of timer 2) */
-   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
-APCI3120_CTR0_TIMER_SEL(timer),
-dev-iobase + APCI3120_CTR0_REG);
-   val = inw(dev-iobase + APCI3120_TIMER_REG);
-
-   if (timer == 2) {
-   /* read upper 16-bits from timer 2 */
-   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
-APCI3120_CTR0_TIMER_SEL(timer + 1),
-dev-iobase + APCI3120_CTR0_REG);
-   val |= (inw(dev-iobase + APCI3120_TIMER_REG)  16);
-   }
-
-   return val;
-}
-
-static void apci3120_timer_set_mode(struct comedi_device *dev,
-   unsigned int timer, unsigned int mode)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   devpriv-timer_mode = ~APCI3120_TIMER_MODE_MASK(timer);
-   devpriv-timer_mode |= APCI3120_TIMER_MODE(timer, mode);
-   outb(devpriv-timer_mode, dev-iobase + APCI3120_TIMER_MODE_REG);
-}
-
 static int apci3120_ai_insn_config(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 20babac..e5356119 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -150,6 +150,59 @@ static unsigned int apci3120_ns_to_timer(struct 
comedi_device *dev,
return divisor;
 }
 
+static void apci3120_timer_write(struct comedi_device *dev,
+unsigned int timer, unsigned int val)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* write 16-bit value to timer (lower 16-bits of timer 2) */
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
+APCI3120_CTR0_TIMER_SEL(timer),
+dev-iobase + APCI3120_CTR0_REG);
+   outw(val  0x, dev-iobase + APCI3120_TIMER_REG);
+
+   if (timer == 2) {
+   /* write upper 16-bits to timer 2 */
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
+APCI3120_CTR0_TIMER_SEL(timer + 1),
+dev-iobase + APCI3120_CTR0_REG);
+   outw((val  16)  0x, dev-iobase + APCI3120_TIMER_REG);
+   }
+}
+
+static unsigned int apci3120_timer_read(struct comedi_device *dev,
+   unsigned int timer)
+{
+   struct apci3120_private *devpriv = dev-private;
+   unsigned int val;
+
+   /* read 16-bit value from timer (lower 16-bits of timer 2) */
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
+APCI3120_CTR0_TIMER_SEL(timer),
+dev-iobase + APCI3120_CTR0_REG);
+   val = inw(dev-iobase + APCI3120_TIMER_REG);
+
+   if (timer == 2) {
+   /* read upper 16-bits from timer 2 */
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
+APCI3120_CTR0_TIMER_SEL(timer + 1),
+dev-iobase + 

[PATCH 028/108] staging: comedi: addi_apci_3120: move ai range table to driver source

2014-11-04 Thread H Hartley Sweeten
Move the analog input comedi_lrange table from the included hwdrv_apci3120.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 --
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 15 ++-
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0673e4f..cb2856d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -125,20 +125,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER2_SELECT_EOS 0xc0
 #define APCI3120_COUNTER   3
 
-/* ANALOG INPUT RANGE */
-static const struct comedi_lrange range_apci3120_ai = {
-   8, {
-   BIP_RANGE(10),
-   BIP_RANGE(5),
-   BIP_RANGE(2),
-   BIP_RANGE(1),
-   UNI_RANGE(10),
-   UNI_RANGE(5),
-   UNI_RANGE(2),
-   UNI_RANGE(1)
-   }
-};
-
 static int apci3120_ai_insn_config(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 8dfee45..6c7f452 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -53,6 +53,19 @@
 #define APCI3120_REVA_OSC_BASE 70  /* 70ns = 14.29MHz */
 #define APCI3120_REVB_OSC_BASE 50  /* 50ns = 20MHz */
 
+static const struct comedi_lrange apci3120_ai_range = {
+   8, {
+   BIP_RANGE(10),
+   BIP_RANGE(5),
+   BIP_RANGE(2),
+   BIP_RANGE(1),
+   UNI_RANGE(10),
+   UNI_RANGE(5),
+   UNI_RANGE(2),
+   UNI_RANGE(1)
+   }
+};
+
 enum apci3120_boardid {
BOARD_APCI3120,
BOARD_APCI3001,
@@ -355,7 +368,7 @@ static int apci3120_auto_attach(struct comedi_device *dev,
s-subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
s-n_chan   = 16;
s-maxdata  = this_board-ai_is_16bit ? 0x : 0x0fff;
-   s-range_table  = range_apci3120_ai;
+   s-range_table  = apci3120_ai_range;
s-insn_config  = apci3120_ai_insn_config;
s-insn_read= apci3120_ai_insn_read;
if (0 /* dev-irq */) {
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 041/108] staging: comedi: addi_apci_3120: define the timer 2 operation bits

2014-11-04 Thread H Hartley Sweeten
For aesthetics, redefine the bits in the mode register used to set the
operation mode of timer 2.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 23 --
 drivers/staging/comedi/drivers/addi_apci_3120.c|  4 
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 03ebe97..87c82e4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -101,8 +101,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_WRITE_MODE_SELECT 0x0e
 
 #define APCI3120_RD_STATUS 0x02
-#define APCI3120_ENABLE_WATCHDOG   0x20
-#define APCI3120_ENABLE_TIMER_COUNTER  0x10
 #define APCI3120_FC_TIMER  0x1000
 
 #define APCI3120_TIMER2_SELECT_EOS 0xc0
@@ -564,7 +562,7 @@ static int apci3120_cyclic_ai(int mode,
apci3120_clr_timer2_interrupt(dev);
 
/*  enable timer counter and disable watch dog */
-   devpriv-mode |= APCI3120_ENABLE_TIMER_COUNTER;
+   devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER;
/*  select EOS clock input for timer 2 */
devpriv-mode |= APCI3120_TIMER2_SELECT_EOS;
/*  Enable timer2  interrupt */
@@ -1081,9 +1079,9 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
 
apci3120_timer_enable(dev, 2, false);
 
-   /*  Disable TIMER Interrupt */
+   /* disable timer 2 interrupt and reset operation mode (timer) */
devpriv-mode = ~APCI3120_MODE_TIMER2_IRQ_ENA 
-~APCI3120_ENABLE_TIMER_COUNTER;
+~APCI3120_MODE_TIMER2_AS_MASK;
 
/*  Disable Eoc and Eos Interrupts */
devpriv-mode = ~APCI3120_MODE_EOC_IRQ_ENA 
@@ -1156,10 +1154,11 @@ static int apci3120_write_insn_timer(struct 
comedi_device *dev,
if (devpriv-b_Timer2Mode == APCI3120_TIMER) {  /* start timer 
*/
/* Enable Timer */
devpriv-mode = 0x0b;
+   devpriv-mode |= APCI3120_MODE_TIMER2_AS_TIMER;
} else {/* start watch dog */
/* Enable WatchDog */
devpriv-mode = 0x0b;
-   devpriv-mode |= APCI3120_ENABLE_WATCHDOG;
+   devpriv-mode |= APCI3120_MODE_TIMER2_AS_WDOG;
}
 
/* enable disable interrupt */
@@ -1179,15 +1178,9 @@ static int apci3120_write_insn_timer(struct 
comedi_device *dev,
break;
 
case APCI3120_STOP:
-   if (devpriv-b_Timer2Mode == APCI3120_TIMER) {
-   /* Disable timer */
-   devpriv-mode = ~APCI3120_ENABLE_TIMER_COUNTER;
-   } else {
-   /* Disable WatchDog */
-   devpriv-mode = ~APCI3120_ENABLE_WATCHDOG;
-   }
-   /*  Disable timer interrupt */
-   devpriv-mode = ~APCI3120_MODE_TIMER2_IRQ_ENA;
+   /* disable timer 2 interrupt and reset operation mode (timer) */
+   devpriv-mode = ~APCI3120_MODE_TIMER2_IRQ_ENA 
+~APCI3120_MODE_TIMER2_AS_MASK;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
apci3120_timer_enable(dev, 2, false);
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 603bebb..ed51f41 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -40,6 +40,10 @@
 #define APCI3120_CTR0_REG  0x0d
 #define APCI3120_CTR0_DO_BITS(x)   ((x)  4)
 #define APCI3120_CTR0_TIMER_SEL(x) ((x)  0)
+#define APCI3120_MODE_TIMER2_AS_TIMER  (0  4)
+#define APCI3120_MODE_TIMER2_AS_COUNTER(1  4)
+#define APCI3120_MODE_TIMER2_AS_WDOG   (2  4)
+#define APCI3120_MODE_TIMER2_AS_MASK   (3  4)  /* sets AS_TIMER */
 #define APCI3120_MODE_SCAN_ENA (1  3)
 #define APCI3120_MODE_TIMER2_IRQ_ENA   (1  2)
 #define APCI3120_MODE_EOS_IRQ_ENA  (1  1)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 001/108] staging: comedi: addi_apci_3120: introduce apci3120_ns_to_timer()

2014-11-04 Thread H Hartley Sweeten
The timer divisor calculations in this driver are over complicated.

There are three timers on the board. They all use the same base clock
with a fixed prescaler for each timer. The base clock used depends on
the board version and type:

  APCI-3120 Rev A boards OSC = 14.29MHz base clock (~70ns)
  APCI-3120 Rev B boards OSC = 20MHz base clock (50ns)
  APCI-3001 boards OSC = 20MHz base clock (50ns)

The prescalers for each timer are:

  Timer 0 CLK = OSC/10
  Timer 1 CLK = OSC/1000
  Timer 2 CLK = OSC/1000

Add a new member to the private data, 'osc_base', to hold the base clock
time. Set this member during the board attach.

Introduce a helper function to calculate the divisor needed to generate
a nanosecond time with a given timer.

Use the new helper function in the driver to clarify the code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 137 +
 drivers/staging/comedi/drivers/addi_apci_3120.c|  71 +++
 2 files changed, 100 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index c64799e..960002d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -309,14 +309,16 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
 unsigned int *data)
 {
struct apci3120_private *devpriv = dev-private;
-   unsigned short us_ConvertTiming, us_TmpValue, i;
+   unsigned int divisor;
+   unsigned int ns;
+   unsigned short us_TmpValue, i;
unsigned char b_Tmp;
 
/*  fix conversion time to 10 us */
if (!devpriv-ui_EocEosConversionTime)
-   us_ConvertTiming = 10;
+   ns = 1;
else
-   us_ConvertTiming = (unsigned short) 
(devpriv-ui_EocEosConversionTime / 1000);  /*  nano to useconds */
+   ns = devpriv-ui_EocEosConversionTime;
 
/*  Clear software registers */
devpriv-b_TimerSelectMode = 0;
@@ -329,20 +331,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
} 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
-*/
-   us_TmpValue = inw(dev-iobase + APCI3120_RD_STATUS);
-
-   /* EL250804: Testing if board APCI3120 have the new Quartz or 
if it is an APCI3001 */
-   if ((us_TmpValue  0x00B0) == 0x00B0
-   || !strcmp(dev-board_name, apci3001)) {
-   us_ConvertTiming = (us_ConvertTiming * 2) - 2;
-   } else {
-   us_ConvertTiming =
-   ((us_ConvertTiming * 12926) / 1) - 1;
-   }
+   divisor = apci3120_ns_to_timer(dev, 0, ns, CMDF_ROUND_NEAREST);
 
us_TmpValue = (unsigned short) devpriv-b_InterruptMode;
 
@@ -408,8 +397,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outb(b_Tmp, dev-iobase + APCI3120_TIMER_CRT0);
 
/* Set the conversion time */
-   outw(us_ConvertTiming,
-dev-iobase + APCI3120_TIMER_VALUE);
+   outw(divisor, dev-iobase + APCI3120_TIMER_VALUE);
 
us_TmpValue =
(unsigned short) inw(dev-iobase + 
APCI3120_RD_STATUS);
@@ -467,8 +455,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outb(b_Tmp, dev-iobase + APCI3120_TIMER_CRT0);
 
/* Set the conversion time */
-   outw(us_ConvertTiming,
-dev-iobase + APCI3120_TIMER_VALUE);
+   outw(divisor, dev-iobase + APCI3120_TIMER_VALUE);
 
/* Set the scan bit */
devpriv-b_ModeSelectRegister =
@@ -719,14 +706,11 @@ static int apci3120_cyclic_ai(int mode,
struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
unsigned char b_Tmp;
-   unsigned int ui_DelayTiming = 0;
-   unsigned int ui_TimerValue1 = 0;
+   unsigned int divisor1 = 0;
unsigned int dmalen0 = 0;
unsigned int dmalen1 = 0;
unsigned int ui_TimerValue2 = 0;
-   unsigned int ui_TimerValue0;
-   unsigned int ui_ConvertTiming;
-   unsigned short us_TmpValue;
+   unsigned int divisor0;
 
/* Resets the FIFO */
inb(dev-iobase + APCI3120_RESET_FIFO);
@@ -759,42 +743,17 @@ static int 

[PATCH 069/108] staging: comedi: addi_apci_3120: tidy up timer 2 programming in apci3120_ai_cmd()

2014-11-04 Thread H Hartley Sweeten
Tidy up the programming of timer 2.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c| 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3656f9d..54c8583 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -426,16 +426,20 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
if (cmd-stop_src == TRIG_COUNT) {
-   /* configure Timer2 For counting EOS */
-
-   /* (1) Init timer 2 in mode 0 and write timer value */
+   /*
+* Timer 2 is used in MODE0 (hardware retriggerable
+* one-shot) to count the number of scans.
+*
+* NOTE: not sure about the -2 value
+*/
apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0);
-
-   /* Set the scan stop count (not sure about the -2) */
apci3120_timer_write(dev, 2, cmd-stop_arg - 2);
 
apci3120_clr_timer2_interrupt(dev);
 
+   apci3120_timer_enable(dev, 2, true);
+
+   /* configure Timer 2 For counting EOS */
devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
 APCI3120_MODE_TIMER2_CLK_EOS |
 APCI3120_MODE_TIMER2_IRQ_ENA;
@@ -443,8 +447,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
 
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = 1;
-
-   apci3120_timer_enable(dev, 2, true);
}
}
 
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 016/108] staging: comedi: addi_apci_3120: rename APCI3120_ENABLE_EXT_TRIGGER

2014-11-04 Thread H Hartley Sweeten
For aesthetics, rename this define.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 ++-
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 1 +
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 8e474a1..7770468 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -89,9 +89,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
-/* Enable external trigger bit in nWrAddress */
-#define APCI3120_ENABLE_EXT_TRIGGER0x8000
-
 /* ANALOG OUTPUT AND INPUT DEFINE */
 #define APCI3120_UNIPOLAR  0x80
 #define APCI3120_BIPOLAR   0x00
@@ -484,7 +481,7 @@ static int apci3120_exttrig_enable(struct comedi_device 
*dev)
 {
struct apci3120_private *devpriv = dev-private;
 
-   devpriv-ctrl |= APCI3120_ENABLE_EXT_TRIGGER;
+   devpriv-ctrl |= APCI3120_CTRL_EXT_TRIG;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
return 0;
 }
@@ -493,7 +490,7 @@ static int apci3120_exttrig_disable(struct comedi_device 
*dev)
 {
struct apci3120_private *devpriv = dev-private;
 
-   devpriv-ctrl = ~APCI3120_ENABLE_EXT_TRIGGER;
+   devpriv-ctrl = ~APCI3120_CTRL_EXT_TRIG;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
return 0;
 }
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 58db0ab..087ff1a 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -15,6 +15,7 @@
 /*
  * PCI BAR 1 register map (dev-iobase)
  */
+#define APCI3120_CTRL_EXT_TRIG (1  15)
 #define APCI3120_CTRL_GATE(x)  (1  (12 + (x)))
 #define APCI3120_CTRL_PR(x)(((x)  0xf)  8)
 #define APCI3120_CTRL_PA(x)(((x)  0xf)  0)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 005/108] staging: comedi: addi_apci_3120: tidy up CTR0 register defines

2014-11-04 Thread H Hartley Sweeten
Define the CTR0 register in the main driver source file and remove all
the old defines in hwrdv_apci3120.c.

For aesthetics, save the raw digital output state (devpriv-do_bits) in
the digital output (*insn_bits) function and use a macro to set them when
reading/writing a timer.

Use the CTR0 register define in the digital output (*insn_bits) function
and remove the current register define.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 38 +++---
 drivers/staging/comedi/drivers/addi_apci_3120.c|  2 ++
 2 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 7335a64..93b1725 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -86,16 +86,9 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_EOS_MODE  2
 #define APCI3120_DMA_MODE  3
 
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI3120_DIGITAL_OUTPUT0x0d
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
-/* digital output insn_write ON /OFF selection */
-#defineAPCI3120_SET4DIGITALOUTPUTON1
-#define APCI3120_SET4DIGITALOUTPUTOFF  0
-
 /* Enable external trigger bit in nWrAddress */
 #define APCI3120_ENABLE_EXT_TRIGGER0x8000
 
@@ -110,7 +103,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RESET_FIFO0x0c
 #define APCI3120_TIMER_0_MODE_20x01
 #define APCI3120_TIMER_0_MODE_40x2
-#define APCI3120_SELECT_TIMER_0_WORD   0x00
 #define APCI3120_ENABLE_TIMER0 0x1000
 #define APCI3120_CLEAR_PR  0xf0ff
 #define APCI3120_CLEAR_PA  0xfff0
@@ -148,8 +140,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_ENABLE_TIMER_INT  0x04
 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
-#define APCI3120_SELECT_TIMER_0_WORD   0x00
-#define APCI3120_SELECT_TIMER_1_WORD   0x01
 #define APCI3120_TIMER_1_MODE_20x4
 
 /* $$ BIT FOR MODE IN nCsTimerCtr1 */
@@ -157,11 +147,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER_2_MODE_20x10
 #define APCI3120_TIMER_2_MODE_50x30
 
-/* $$ BIT FOR MODE IN nCsTimerCtr0 */
-#define APCI3120_SELECT_TIMER_2_LOW_WORD   0x02
-#define APCI3120_SELECT_TIMER_2_HIGH_WORD  0x03
-
-#define APCI3120_TIMER_CRT00x0d
 #define APCI3120_TIMER_CRT10x0c
 
 #define APCI3120_TIMER_VALUE   0x04
@@ -206,16 +191,16 @@ static void apci3120_timer_write(struct comedi_device 
*dev,
struct apci3120_private *devpriv = dev-private;
 
/* write 16-bit value to timer (lower 16-bits of timer 2) */
-   outb(((devpriv-do_bits)  0xF0) |
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
 APCI3120_CTR0_TIMER_SEL(timer),
-dev-iobase + APCI3120_TIMER_CRT0);
+dev-iobase + APCI3120_CTR0_REG);
outw(val  0x, dev-iobase + APCI3120_TIMER_VALUE);
 
if (timer == 2) {
/* write upper 16-bits to timer 2 */
-   outb(((devpriv-do_bits)  0xF0) |
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
 APCI3120_CTR0_TIMER_SEL(timer + 1),
-dev-iobase + APCI3120_TIMER_CRT0);
+dev-iobase + APCI3120_CTR0_REG);
outw((val  16)  0x, dev-iobase + APCI3120_TIMER_VALUE);
}
 }
@@ -227,16 +212,16 @@ static unsigned int apci3120_timer_read(struct 
comedi_device *dev,
unsigned int val;
 
/* read 16-bit value from timer (lower 16-bits of timer 2) */
-   outb(((devpriv-do_bits)  0xF0) |
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
 APCI3120_CTR0_TIMER_SEL(timer),
-dev-iobase + APCI3120_TIMER_CRT0);
+dev-iobase + APCI3120_CTR0_REG);
val = inw(dev-iobase + APCI3120_TIMER_VALUE);
 
if (timer == 2) {
/* read upper 16-bits from timer 2 */
-   outb(((devpriv-do_bits)  0xF0) |
+   outb(APCI3120_CTR0_DO_BITS(devpriv-do_bits) |
 APCI3120_CTR0_TIMER_SEL(timer + 1),
-dev-iobase + APCI3120_TIMER_CRT0);
+dev-iobase + APCI3120_CTR0_REG);
val |= (inw(dev-iobase + APCI3120_TIMER_VALUE)  16);
}
 
@@ -1693,10 +1678,9 @@ static int apci3120_do_insn_bits(struct comedi_device 
*dev,
struct apci3120_private 

[PATCH 059/108] staging: comedi: addi_apci_3120: move apci3120_ai_insn_read() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function, and its helper function, from the included hwdrv_apci31210.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 60 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 60 ++
 2 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 929ef0b..28c5792 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -131,66 +131,6 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
return 1;   /*  we can serve this with scan logic */
 }
 
-static int apci3120_ai_eoc(struct comedi_device *dev,
-  struct comedi_subdevice *s,
-  struct comedi_insn *insn,
-  unsigned long context)
-{
-   unsigned int status;
-
-   status = inw(dev-iobase + APCI3120_STATUS_REG);
-   if ((status  APCI3120_STATUS_EOC_INT) == 0)
-   return 0;
-   return -EBUSY;
-}
-
-static int apci3120_ai_insn_read(struct comedi_device *dev,
-struct comedi_subdevice *s,
-struct comedi_insn *insn,
-unsigned int *data)
-{
-   struct apci3120_private *devpriv = dev-private;
-   unsigned int divisor;
-   int ret;
-   int i;
-
-   /* set mode for A/D conversions by software trigger with timer 0 */
-   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
-   APCI3120_MODE_TIMER2_AS_TIMER;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   /* load chanlist for single channel scan */
-   if (!apci3120_setup_chan_list(dev, s, 1, insn-chanspec))
-   return -EINVAL;
-
-   /*
-* Timer 0 is used in MODE4 (software triggered strobe) to set the
-* conversion time for each acquisition. Each conversion is triggered
-* when the divisor is written to the timer, The conversion is done
-* when the EOC bit in the status register is '0'.
-*/
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
-   apci3120_timer_enable(dev, 0, true);
-
-   /* fixed conversion time of 10 us */
-   divisor = apci3120_ns_to_timer(dev, 0, 1, CMDF_ROUND_NEAREST);
-
-   apci3120_ai_reset_fifo(dev);
-
-   for (i = 0; i  insn-n; i++) {
-   /* trigger conversion */
-   apci3120_timer_write(dev, 0, divisor);
-
-   ret = comedi_timeout(dev, s, insn, apci3120_ai_eoc, 0);
-   if (ret)
-   return ret;
-
-   data[i] = inw(dev-iobase + 0);
-   }
-
-   return insn-n;
-}
-
 static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index c17a840..70363fa 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -281,6 +281,66 @@ static void apci3120_ai_reset_fifo(struct comedi_device 
*dev)
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_ai_eoc(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned long context)
+{
+   unsigned int status;
+
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
+   if ((status  APCI3120_STATUS_EOC_INT) == 0)
+   return 0;
+   return -EBUSY;
+}
+
+static int apci3120_ai_insn_read(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_insn *insn,
+unsigned int *data)
+{
+   struct apci3120_private *devpriv = dev-private;
+   unsigned int divisor;
+   int ret;
+   int i;
+
+   /* set mode for A/D conversions by software trigger with timer 0 */
+   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
+   APCI3120_MODE_TIMER2_AS_TIMER;
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+
+   /* load chanlist for single channel scan */
+   if (!apci3120_setup_chan_list(dev, s, 1, insn-chanspec))
+   return -EINVAL;
+
+   /*
+* Timer 0 is used in MODE4 (software triggered strobe) to set the
+* conversion time for each acquisition. Each conversion is triggered
+* when the divisor is written to the timer, The conversion is done
+* when the EOC bit in the status register is '0'.
+  

[PATCH 051/108] staging: comedi: addi_apci_3120: remove private data 'ui_AiNbrofChannels'

2014-11-04 Thread H Hartley Sweeten
This member of the private data is always the cmd-chanlist_len. Use that
instead and remove the member.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 8 +++-
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 1 -
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 1913fd2..004142e 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -361,7 +361,7 @@ static int apci3120_cyclic_ai(int mode,
devpriv-ui_DmaActualBuffer = 0;
 
/* Initializes the sequence array */
-   if (!apci3120_setup_chan_list(dev, s, devpriv-ui_AiNbrofChannels,
+   if (!apci3120_setup_chan_list(dev, s, cmd-chanlist_len,
cmd-chanlist))
return -EINVAL;
 
@@ -605,9 +605,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
 
-   /* loading private structure with cmd structure inputs */
-   devpriv-ui_AiNbrofChannels = cmd-chanlist_len;
-
if (cmd-start_src == TRIG_EXT)
devpriv-b_ExttrigEnable = APCI3120_ENABLE;
else
@@ -752,6 +749,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
struct comedi_device *dev = d;
struct apci3120_private *devpriv = dev-private;
struct comedi_subdevice *s = dev-read_subdev;
+   struct comedi_cmd *cmd = s-async-cmd;
unsigned short int_daq;
unsigned int int_amcc;
 
@@ -791,7 +789,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
unsigned short val;
int i;
 
-   for (i = 0; i  devpriv-ui_AiNbrofChannels; i++) {
+   for (i = 0; i  cmd-chanlist_len; i++) {
val = inw(dev-iobase + 0);
comedi_buf_write_samples(s, val, 1);
}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index dc05b2f..2eb7ab5 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -113,7 +113,6 @@ struct apci3120_private {
unsigned long amcc;
unsigned long addon;
unsigned int osc_base;
-   unsigned int ui_AiNbrofChannels;
unsigned int ui_AiChannelList[32];
unsigned short us_UseDma;
unsigned char b_DmaDoubleBuffer;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 058/108] staging: comedi: addi_apci_3120: move apci3120_ao_insn_write() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function, and its helper function, from the included hwdrv_apci31210.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 38 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 38 ++
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index a206d5e..929ef0b 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1017,41 +1017,3 @@ static int apci3120_read_insn_timer(struct comedi_device 
*dev,
}
return insn-n;
 }
-
-static int apci3120_ao_ready(struct comedi_device *dev,
-struct comedi_subdevice *s,
-struct comedi_insn *insn,
-unsigned long context)
-{
-   unsigned int status;
-
-   status = inw(dev-iobase + APCI3120_STATUS_REG);
-   if (status  APCI3120_STATUS_DA_READY)
-   return 0;
-   return -EBUSY;
-}
-
-static int apci3120_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);
-   int i;
-
-   for (i = 0; i  insn-n; i++) {
-   unsigned int val = data[i];
-   int ret;
-
-   ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0);
-   if (ret)
-   return ret;
-
-   outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val),
-dev-iobase + APCI3120_AO_REG(chan));
-
-   s-readback[chan] = val;
-   }
-
-   return insn-n;
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 7033b0b..c17a840 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -281,6 +281,44 @@ static void apci3120_ai_reset_fifo(struct comedi_device 
*dev)
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_ao_ready(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_insn *insn,
+unsigned long context)
+{
+   unsigned int status;
+
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
+   if (status  APCI3120_STATUS_DA_READY)
+   return 0;
+   return -EBUSY;
+}
+
+static int apci3120_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);
+   int i;
+
+   for (i = 0; i  insn-n; i++) {
+   unsigned int val = data[i];
+   int ret;
+
+   ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0);
+   if (ret)
+   return ret;
+
+   outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val),
+dev-iobase + APCI3120_AO_REG(chan));
+
+   s-readback[chan] = val;
+   }
+
+   return insn-n;
+}
+
 static int apci3120_di_insn_bits(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 014/108] staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER[012]

2014-11-04 Thread H Hartley Sweeten
For aesthetics, remove these defines and just use ~APCI3120_ENABLE_TIMER[012].

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 71fcaa4..3575453 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -131,7 +131,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
 #define APCI3120_ENABLE_TIMER2 0x4000
-#define APCI3120_DISABLE_TIMER2(~APCI3120_ENABLE_TIMER2)
 #define APCI3120_ENABLE_TIMER_INT  0x04
 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
@@ -147,9 +146,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_ENABLE_TIMER0 0x1000
 #define APCI3120_ENABLE_TIMER1 0x2000
 #define APCI3120_ENABLE_TIMER2 0x4000
-#define APCI3120_DISABLE_TIMER0(~APCI3120_ENABLE_TIMER0)
-#define APCI3120_DISABLE_TIMER1(~APCI3120_ENABLE_TIMER1)
-#define APCI3120_DISABLE_TIMER2(~APCI3120_ENABLE_TIMER2)
 
 #define APCI3120_TIMER2_SELECT_EOS 0xc0
 #define APCI3120_COUNTER   3
@@ -1254,10 +1250,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
apci3120_interrupt_dma(irq, d);
} else {
/* Stops the Timer */
-   outw(devpriv-
-   ctrl  APCI3120_DISABLE_TIMER0 
-   APCI3120_DISABLE_TIMER1,
-   dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl 
+~APCI3120_ENABLE_TIMER0 
+~APCI3120_ENABLE_TIMER1,
+dev-iobase + APCI3120_WR_ADDRESS);
}
 
}
@@ -1290,7 +1286,7 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN);
 
/* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
-   devpriv-ctrl = APCI3120_DISABLE_TIMER2;
+   devpriv-ctrl = ~APCI3120_ENABLE_TIMER2;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
/*  Disable TIMER Interrupt */
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 040/108] staging: comedi: addi_apci_3120: define the enable bits in the mode register

2014-11-04 Thread H Hartley Sweeten
For aesthetics, redefine the bits in the mode register that enable interrupts
and scanning.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 38 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  4 +++
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index d2d0ef4..03ebe97 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -84,12 +84,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
-/* nWrMode_Select */
-#define APCI3120_ENABLE_SCAN   0x8
-#define APCI3120_ENABLE_EOS_INT0x2
-
-#define APCI3120_ENABLE_EOC_INT0x1
-
 /* status register bits */
 #define APCI3120_EOC   0x8000
 #define APCI3120_EOS   0x2000
@@ -104,7 +98,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_WATCHDOG  2
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
-#define APCI3120_ENABLE_TIMER_INT  0x04
 #define APCI3120_WRITE_MODE_SELECT 0x0e
 
 #define APCI3120_RD_STATUS 0x02
@@ -246,7 +239,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
 
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-   devpriv-mode |= APCI3120_ENABLE_EOC_INT;
+   devpriv-mode |= APCI3120_MODE_EOC_IRQ_ENA;
inw(dev-iobase + 0);
}
 
@@ -294,13 +287,13 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
apci3120_timer_write(dev, 0, divisor);
 
/* Set the scan bit */
-   devpriv-mode |= APCI3120_ENABLE_SCAN;
+   devpriv-mode |= APCI3120_MODE_SCAN_ENA;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/* If Interrupt function is loaded */
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-   devpriv-mode |= APCI3120_ENABLE_EOS_INT;
+   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
inw(dev-iobase + 0);
}
 
@@ -556,7 +549,7 @@ static int apci3120_cyclic_ai(int mode,
devpriv-b_InterruptMode = APCI3120_EOS_MODE;
devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
 
-   devpriv-mode |= APCI3120_ENABLE_EOS_INT;
+   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
if (cmd-stop_src == TRIG_COUNT) {
@@ -575,7 +568,7 @@ static int apci3120_cyclic_ai(int mode,
/*  select EOS clock input for timer 2 */
devpriv-mode |= APCI3120_TIMER2_SELECT_EOS;
/*  Enable timer2  interrupt */
-   devpriv-mode |= APCI3120_ENABLE_TIMER_INT;
+   devpriv-mode |= APCI3120_MODE_TIMER2_IRQ_ENA;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
devpriv-b_Timer2Mode = APCI3120_COUNTER;
@@ -965,7 +958,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
send_sig(SIGIO, devpriv-tsk_Current, 0);   /*  
send signal to the sample */
} else {
/* Disable EOC Interrupt */
-   devpriv-mode = ~APCI3120_ENABLE_EOC_INT;
+   devpriv-mode = ~APCI3120_MODE_EOC_IRQ_ENA;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
}
@@ -979,7 +972,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
if (devpriv-ai_running) {
ui_Check = 0;
apci3120_interrupt_handle_eos(dev);
-   devpriv-mode |= APCI3120_ENABLE_EOS_INT;
+   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
} else {
@@ -998,7 +991,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)

[PATCH 061/108] staging: comedi: addi_apci_3120: move apci3120_set_chanlist() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function from the included hwdrv_apci31210.c source file to the
main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 28 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 28 ++
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3c17246..f7543f6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -96,34 +96,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_COUNTER   3
 
-static void apci3120_set_chanlist(struct comedi_device *dev,
- struct comedi_subdevice *s,
- int n_chan, unsigned int *chanlist)
-{
-   struct apci3120_private *devpriv = dev-private;
-   int i;
-
-   /* set scan length (PR) and scan start (PA) */
-   devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
-
-   /* set chanlist for scan */
-   for (i = 0; i  n_chan; i++) {
-   unsigned int chan = CR_CHAN(chanlist[i]);
-   unsigned int range = CR_RANGE(chanlist[i]);
-   unsigned int val;
-
-   val = APCI3120_CHANLIST_MUX(chan) |
- APCI3120_CHANLIST_GAIN(range) |
- APCI3120_CHANLIST_INDEX(i);
-
-   if (comedi_range_is_unipolar(s, range))
-   val |= APCI3120_CHANLIST_UNIPOLAR;
-
-   outw(val, dev-iobase + APCI3120_CHANLIST_REG);
-   }
-}
-
 static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index d40fdf2..044d2c4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -279,6 +279,34 @@ static void apci3120_ai_reset_fifo(struct comedi_device 
*dev)
inw(dev-iobase + APCI3120_TIMER_MODE_REG);
 }
 
+static void apci3120_set_chanlist(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ int n_chan, unsigned int *chanlist)
+{
+   struct apci3120_private *devpriv = dev-private;
+   int i;
+
+   /* set scan length (PR) and scan start (PA) */
+   devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
+
+   /* set chanlist for scan */
+   for (i = 0; i  n_chan; i++) {
+   unsigned int chan = CR_CHAN(chanlist[i]);
+   unsigned int range = CR_RANGE(chanlist[i]);
+   unsigned int val;
+
+   val = APCI3120_CHANLIST_MUX(chan) |
+ APCI3120_CHANLIST_GAIN(range) |
+ APCI3120_CHANLIST_INDEX(i);
+
+   if (comedi_range_is_unipolar(s, range))
+   val |= APCI3120_CHANLIST_UNIPOLAR;
+
+   outw(val, dev-iobase + APCI3120_CHANLIST_REG);
+   }
+}
+
 #include addi-data/hwdrv_apci3120.c
 
 static int apci3120_ai_eoc(struct comedi_device *dev,
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 020/108] staging: comedi: addi_apci_3120: rename APCI3120_WR_ADDRESS

2014-11-04 Thread H Hartley Sweeten
For aesthetics, rename this define.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 +--
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  1 +
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3aa4bbe..184bff4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -132,7 +132,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_TIMER_STATUS_REGISTER 0x0d
 #define APCI3120_RD_STATUS 0x02
-#define APCI3120_WR_ADDRESS0x00
 #define APCI3120_ENABLE_WATCHDOG   0x20
 #define APCI3120_DISABLE_WATCHDOG  (~APCI3120_ENABLE_WATCHDOG)
 #define APCI3120_ENABLE_TIMER_COUNTER  0x10
@@ -165,7 +164,7 @@ static void apci3120_timer_enable(struct comedi_device *dev,
devpriv-ctrl |= APCI3120_CTRL_GATE(timer);
else
devpriv-ctrl = ~APCI3120_CTRL_GATE(timer);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
 static int apci3120_ai_insn_config(struct comedi_device *dev,
@@ -245,7 +244,7 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
 
/* set scan length (PR) and scan start (PA) */
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
for (i = 0; i  n_chan; i++) {
/*  store range list to card */
@@ -471,7 +470,7 @@ static int apci3120_reset(struct comedi_device *dev)
 
/* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
inw(dev-iobase + 0);   /* make a dummy read */
inb(dev-iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
@@ -493,7 +492,7 @@ static void apci3120_exttrig_enable(struct comedi_device 
*dev, bool enable)
devpriv-ctrl |= APCI3120_CTRL_EXT_TRIG;
else
devpriv-ctrl = ~APCI3120_CTRL_EXT_TRIG;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
 static int apci3120_cancel(struct comedi_device *dev,
@@ -515,7 +514,7 @@ static int apci3120_cancel(struct comedi_device *dev,
 
/* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
/* DISABLE_ALL_INTERRUPT */
outb(APCI3120_DISABLE_ALL_INTERRUPT,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 087ff1a..014a014 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -15,6 +15,7 @@
 /*
  * PCI BAR 1 register map (dev-iobase)
  */
+#define APCI3120_CTRL_REG  0x00
 #define APCI3120_CTRL_EXT_TRIG (1  15)
 #define APCI3120_CTRL_GATE(x)  (1  (12 + (x)))
 #define APCI3120_CTRL_PR(x)(((x)  0xf)  8)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 048/108] staging: comedi: addi_apci_3120: remove private data 'ui_AiReadData'

2014-11-04 Thread H Hartley Sweeten
This member of the private data was used to return analog input samples that
were acquired for the (*insn_read) using interrupts. The interrupt support
code for the (*insn_read) has been removed. Remove this unused member from
the private data.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +---
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 1 -
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 5d15aca..51cdecb 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -147,7 +147,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
struct apci3120_private *devpriv = dev-private;
unsigned int divisor;
unsigned int ns;
-   unsigned short us_TmpValue, i;
+   unsigned short us_TmpValue;
 
/*  fix conversion time to 10 us */
ns = 1;
@@ -157,8 +157,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
devpriv-mode = 0;
 
if (insn-unused[0] == 222) {   /*  second insn read */
-   for (i = 0; i  insn-n; i++)
-   data[i] = devpriv-ui_AiReadData[i];
} else {
devpriv-tsk_Current = current; /*  Save the current process 
task structure */
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 572d545..dc05b2f 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -115,7 +115,6 @@ struct apci3120_private {
unsigned int osc_base;
unsigned int ui_AiNbrofChannels;
unsigned int ui_AiChannelList[32];
-   unsigned int ui_AiReadData[32];
unsigned short us_UseDma;
unsigned char b_DmaDoubleBuffer;
unsigned int ui_DmaActualBuffer;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 080/108] staging: comedi: addi_apci_3120: move APCI3120_FIFO_ADVANCE_ON_BYTE_2

2014-11-04 Thread H Hartley Sweeten
Move this define to the main driver source and convert it to a bit-shift.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 6 --
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 1 +
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0e31537..474b600 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -40,12 +40,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
   +--+---++
 */
 
-/*
- * ADDON RELATED ADDITIONS
- */
-/* Constant */
-#define APCI3120_FIFO_ADVANCE_ON_BYTE_20x2000L
-
 #define APCI3120_START 1
 #define APCI3120_STOP  0
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 699ba76..7ad7621 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -11,6 +11,7 @@
  * PCI BAR 0 register map (devpriv-amcc)
  * see amcc_s5933.h for register and bit defines
  */
+#define APCI3120_FIFO_ADVANCE_ON_BYTE_2(1  29)
 
 /*
  * PCI BAR 1 register map (dev-iobase)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 053/108] staging: comedi: addi_apci_3120: rename APCI3120_RD_STATUS

2014-11-04 Thread H Hartley Sweeten
For aesthetics, rename this define used for the status register offset.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c   | 17 +++--
 drivers/staging/comedi/drivers/addi_apci_3120.c |  3 ++-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 004142e..5deb1ff 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -81,7 +81,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_EOS_MODE  2
 #define APCI3120_DMA_MODE  3
 
-#define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
 /* status register bits */
@@ -99,7 +98,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
 
-#define APCI3120_RD_STATUS 0x02
 #define APCI3120_FC_TIMER  0x1000
 
 #define APCI3120_COUNTER   3
@@ -146,7 +144,7 @@ static int apci3120_ai_eoc(struct comedi_device *dev,
 {
unsigned int status;
 
-   status = inw(dev-iobase + APCI3120_RD_STATUS);
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
if ((status  APCI3120_EOC) == 0)
return 0;
return -EBUSY;
@@ -220,7 +218,7 @@ static int apci3120_reset(struct comedi_device *dev)
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
apci3120_ai_reset_fifo(dev);
-   inw(dev-iobase + APCI3120_RD_STATUS);  /*  flush A/D status register */
+   inw(dev-iobase + APCI3120_STATUS_REG);
 
return 0;
 }
@@ -251,7 +249,7 @@ static int apci3120_cancel(struct comedi_device *dev,
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
apci3120_ai_reset_fifo(dev);
-   inw(dev-iobase + APCI3120_RD_STATUS);
+   inw(dev-iobase + APCI3120_STATUS_REG);
devpriv-ui_DmaActualBuffer = 0;
 
devpriv-ai_running = 0;
@@ -753,7 +751,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
unsigned short int_daq;
unsigned int int_amcc;
 
-   int_daq = inw(dev-iobase + APCI3120_RD_STATUS)  0xf000;   /*  get 
IRQ reasons */
+   int_daq = inw(dev-iobase + APCI3120_STATUS_REG)  0xf000;
int_amcc = inl(devpriv-amcc + AMCC_OP_REG_INTCSR);
 
if ((!int_daq)  (!(int_amcc  ANY_S593X_INT))) {
@@ -1030,8 +1028,7 @@ static int apci3120_read_insn_timer(struct comedi_device 
*dev,
if (devpriv-b_Timer2Mode == APCI3120_TIMER) {
data[0] = apci3120_timer_read(dev, 2);
} else {/*  Read watch dog status */
-
-   us_StatusValue = inw(dev-iobase + APCI3120_RD_STATUS);
+   us_StatusValue = inw(dev-iobase + APCI3120_STATUS_REG);
us_StatusValue =
((us_StatusValue  APCI3120_FC_TIMER)  12)  1;
if (us_StatusValue == 1)
@@ -1049,7 +1046,7 @@ static int apci3120_di_insn_bits(struct comedi_device 
*dev,
unsigned int val;
 
/* the input channels are bits 11:8 of the status reg */
-   val = inw(dev-iobase + APCI3120_RD_STATUS);
+   val = inw(dev-iobase + APCI3120_STATUS_REG);
data[1] = (val  8)  0xf;
 
return insn-n;
@@ -1080,7 +1077,7 @@ static int apci3120_ao_ready(struct comedi_device *dev,
 {
unsigned int status;
 
-   status = inw(dev-iobase + APCI3120_RD_STATUS);
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
if (status  0x0001)/* waiting for DA_READY */
return 0;
return -EBUSY;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 9ff6580..d47b2e0 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -20,6 +20,7 @@
 #define APCI3120_CTRL_GATE(x)  (1  (12 + (x)))
 #define APCI3120_CTRL_PR(x)(((x)  0xf)  8)
 #define APCI3120_CTRL_PA(x)(((x)  0xf)  0)
+#define APCI3120_STATUS_REG0x02
 #define APCI3120_STATUS_TO_VERSION(x)  (((x)  4)  0xf)
 #define APCI3120_TIMER_REG 0x04
 #define APCI3120_CHANLIST_REG  0x06
@@ -360,7 +361,7 @@ static int apci3120_auto_attach(struct comedi_device *dev,
}
}
 
-   status = inw(dev-iobase + APCI3120_RD_STATUS);
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
if (APCI3120_STATUS_TO_VERSION(status) == APCI3120_REVB ||
context == BOARD_APCI3001)
devpriv-osc_base = 

[PATCH 003/108] staging: comedi: addi_apci_3120: introduce apci3120_timer_write()

2014-11-04 Thread H Hartley Sweeten
Introduce a helper function to select a timer and write a value to it.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 138 +
 drivers/staging/comedi/drivers/addi_apci_3120.c|   1 +
 2 files changed, 35 insertions(+), 104 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 9fca58c..ea825c7 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -200,6 +200,26 @@ static const struct comedi_lrange range_apci3120_ai = {
}
 };
 
+static void apci3120_timer_write(struct comedi_device *dev,
+unsigned int timer, unsigned int val)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* write 16-bit value to timer (lower 16-bits of timer 2) */
+   outb(((devpriv-do_bits)  0xF0) |
+APCI3120_CTR0_TIMER_SEL(timer),
+dev-iobase + APCI3120_TIMER_CRT0);
+   outw(val  0x, dev-iobase + APCI3120_TIMER_VALUE);
+
+   if (timer == 2) {
+   /* write upper 16-bits to timer 2 */
+   outb(((devpriv-do_bits)  0xF0) |
+APCI3120_CTR0_TIMER_SEL(timer + 1),
+dev-iobase + APCI3120_TIMER_CRT0);
+   outw((val  16)  0x, dev-iobase + APCI3120_TIMER_VALUE);
+   }
+}
+
 static int apci3120_ai_insn_config(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
@@ -312,7 +332,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
unsigned int divisor;
unsigned int ns;
unsigned short us_TmpValue, i;
-   unsigned char b_Tmp;
 
/*  fix conversion time to 10 us */
if (!devpriv-ui_EocEosConversionTime)
@@ -390,13 +409,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outw(devpriv-us_OutputRegister,
 dev-iobase + APCI3120_WR_ADDRESS);
 
-   /*  Select Timer 0 */
-   b_Tmp = ((devpriv-do_bits)  0xF0) |
-   APCI3120_SELECT_TIMER_0_WORD;
-   outb(b_Tmp, dev-iobase + APCI3120_TIMER_CRT0);
-
/* Set the conversion time */
-   outw(divisor, dev-iobase + APCI3120_TIMER_VALUE);
+   apci3120_timer_write(dev, 0, divisor);
 
us_TmpValue =
(unsigned short) inw(dev-iobase + 
APCI3120_RD_STATUS);
@@ -447,13 +461,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outb(devpriv-b_TimerSelectMode,
 dev-iobase + APCI3120_TIMER_CRT1);
 
-   /* Select Timer 0 */
-   b_Tmp = ((devpriv-do_bits)  0xF0) |
-   APCI3120_SELECT_TIMER_0_WORD;
-   outb(b_Tmp, dev-iobase + APCI3120_TIMER_CRT0);
-
/* Set the conversion time */
-   outw(divisor, dev-iobase + APCI3120_TIMER_VALUE);
+   apci3120_timer_write(dev, 0, divisor);
 
/* Set the scan bit */
devpriv-b_ModeSelectRegister =
@@ -703,11 +712,9 @@ static int apci3120_cyclic_ai(int mode,
 {
struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
-   unsigned char b_Tmp;
unsigned int divisor1 = 0;
unsigned int dmalen0 = 0;
unsigned int dmalen1 = 0;
-   unsigned int ui_TimerValue2 = 0;
unsigned int divisor0;
 
/* Resets the FIFO */
@@ -739,9 +746,6 @@ static int apci3120_cyclic_ai(int mode,
 
devpriv-ui_DmaActualBuffer = 0;
 
-   /* value for timer2  minus -2 has to be done */
-   ui_TimerValue2 = cmd-stop_arg - 2;
-
/* Initializes the sequence array */
if (!apci3120_setup_chan_list(dev, s, devpriv-ui_AiNbrofChannels,
cmd-chanlist, 0))
@@ -764,12 +768,8 @@ static int apci3120_cyclic_ai(int mode,
outb(devpriv-b_TimerSelectMode,
dev-iobase + APCI3120_TIMER_CRT1);
 
-   /* Select Timer 0 */
-   b_Tmp = ((devpriv-do_bits)  0xF0) |
-   APCI3120_SELECT_TIMER_0_WORD;
-   outb(b_Tmp, dev-iobase + APCI3120_TIMER_CRT0);
/* Set the conversion time */
-   outw(divisor0, dev-iobase + APCI3120_TIMER_VALUE);
+   apci3120_timer_write(dev, 0, divisor0);
break;
 
case 2:
@@ -780,12 +780,8 @@ static int apci3120_cyclic_ai(int mode,
   

[PATCH 044/108] staging: comedi: addi_apci_3120: remove scanning from ai (*insn_read)

2014-11-04 Thread H Hartley Sweeten
(*insn_read) functions are supposed to do simple polled reads of a single
channel. This driver tries to be tricky and allow passing a chanlist in
the analog input (*insn_config) to allow the (*insn_read) to do chanlist
scanning with or without interrupts.

The (*insn_config) doesn't follow the comedi API and this operation mode
is not part of the API.

Remove the scanning support from the (*insn_read) as well as the support
code in the (*insn_config) and interrupt handler.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 113 ++---
 1 file changed, 7 insertions(+), 106 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0e76b65..2656e53 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -110,43 +110,18 @@ static int apci3120_ai_insn_config(struct comedi_device 
*dev,
   unsigned int *data)
 {
struct apci3120_private *devpriv = dev-private;
-   unsigned int i;
 
-   if ((data[0] != APCI3120_EOC_MODE)  (data[0] != APCI3120_EOS_MODE))
+   if (data[0] != APCI3120_EOC_MODE)
return -1;
 
/*  Check for Conversion time to be added */
devpriv-ui_EocEosConversionTime = data[2];
 
-   if (data[0] == APCI3120_EOS_MODE) {
-
-   /* Test the number of the channel */
-   for (i = 0; i  data[3]; i++) {
-
-   if (CR_CHAN(data[4 + i]) = s-n_chan) {
-   dev_err(dev-class_dev, bad channel list\n);
-   return -2;
-   }
-   }
-
-   devpriv-b_InterruptMode = APCI3120_EOS_MODE;
-
-   if (data[1])
-   devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
-   else
-   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
-   /*  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 */
-   devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-   if (data[1])
-   devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
-   else
-   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
-   }
+   devpriv-b_InterruptMode = APCI3120_EOC_MODE;
+   if (data[1])
+   devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
+   else
+   devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
 
return insn-n;
 }
@@ -186,11 +161,6 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
return 1;   /*  we can serve this with scan logic */
 }
 
-/*
- * Reads analog input in synchronous mode EOC and EOS is selected
- * as per configured if no conversion time is set uses default
- * conversion time 10 microsec.
- */
 static int apci3120_ai_insn_read(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
@@ -266,60 +236,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
}
 
break;
-
-   case APCI3120_EOS_MODE:
-   apci3120_ai_reset_fifo(dev);
-
-   if (!apci3120_setup_chan_list(dev, s,
-   devpriv-ui_AiNbrofChannels,
-   devpriv-ui_AiChannelList))
-   return -EINVAL;
-
-   /* Initialize Timer 0 mode 2 */
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
-
-   /* Set the conversion time */
-   apci3120_timer_write(dev, 0, divisor);
-
-   /* Set the scan bit */
-   devpriv-mode |= APCI3120_MODE_SCAN_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   /* If Interrupt function is loaded */
-   if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-   inw(dev-iobase + 0);
-   }
-
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   inw(dev-iobase + APCI3120_RD_STATUS);
-
-   apci3120_timer_enable(dev, 0, true);
-
-   /* Start conversion */
-   outw(0, dev-iobase + 

[PATCH 070/108] staging: comedi: addi_apci_3120: reset fifo after programming chanlist

2014-11-04 Thread H Hartley Sweeten
The APCI-3120 documentation says that the FIFO should be reset after the
chanlist sequence is programmed.

Reset the FIFO after programming the chanlist and remove the extra FIFO
resets in the driver.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 4 ++--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 54c8583..95a1b7d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -112,7 +112,6 @@ static int apci3120_reset(struct comedi_device *dev)
devpriv-ctrl = 0;
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
-   apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_STATUS_REG);
 
return 0;
@@ -143,7 +142,6 @@ static int apci3120_cancel(struct comedi_device *dev,
devpriv-mode = 0;
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
-   apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_STATUS_REG);
devpriv-ui_DmaActualBuffer = 0;
 
@@ -382,8 +380,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
outl(APCI3120_CLEAR_WRITE_TC_INT,
 devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
-   apci3120_ai_reset_fifo(dev);
-
devpriv-ui_DmaActualBuffer = 0;
 
/* load chanlist for command scan */
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 044d2c4..77499b4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -305,6 +305,8 @@ static void apci3120_set_chanlist(struct comedi_device *dev,
 
outw(val, dev-iobase + APCI3120_CHANLIST_REG);
}
+
+   apci3120_ai_reset_fifo(dev);
 }
 
 #include addi-data/hwdrv_apci3120.c
@@ -352,8 +354,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
/* fixed conversion time of 10 us */
divisor = apci3120_ns_to_timer(dev, 0, 1, CMDF_ROUND_NEAREST);
 
-   apci3120_ai_reset_fifo(dev);
-
for (i = 0; i  insn-n; i++) {
/* trigger conversion */
apci3120_timer_write(dev, 0, divisor);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 060/108] staging: comedi: addi_apci_3120: remove check in apci3120_setup_chan_list()

2014-11-04 Thread H Hartley Sweeten
The n_chan check is not needed. This value will always be = 1. Remove
the unnecessary check.

For aesthetics, rename the function and change it's return type to void.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 19 +--
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  3 +--
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 28c5792..3c17246 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -96,19 +96,13 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_COUNTER   3
 
-static int apci3120_setup_chan_list(struct comedi_device *dev,
-   struct comedi_subdevice *s,
-   int n_chan, unsigned int *chanlist)
+static void apci3120_set_chanlist(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ int n_chan, unsigned int *chanlist)
 {
struct apci3120_private *devpriv = dev-private;
int i;
 
-   /* correct channel and range number check itself comedi/range.c */
-   if (n_chan  1) {
-   dev_err(dev-class_dev, range/channel list is empty!\n);
-   return 0;
-   }
-
/* set scan length (PR) and scan start (PA) */
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
@@ -128,7 +122,6 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
 
outw(val, dev-iobase + APCI3120_CHANLIST_REG);
}
-   return 1;   /*  we can serve this with scan logic */
 }
 
 static int apci3120_reset(struct comedi_device *dev)
@@ -288,10 +281,8 @@ static int apci3120_cyclic_ai(int mode,
 
devpriv-ui_DmaActualBuffer = 0;
 
-   /* Initializes the sequence array */
-   if (!apci3120_setup_chan_list(dev, s, cmd-chanlist_len,
-   cmd-chanlist))
-   return -EINVAL;
+   /* load chanlist for command scan */
+   apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
 
divisor0 = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
if (mode == 2) {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 70363fa..d40fdf2 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -310,8 +310,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
/* load chanlist for single channel scan */
-   if (!apci3120_setup_chan_list(dev, s, 1, insn-chanspec))
-   return -EINVAL;
+   apci3120_set_chanlist(dev, s, 1, insn-chanspec);
 
/*
 * Timer 0 is used in MODE4 (software triggered strobe) to set the
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 055/108] staging: comedi: addi_apci_3120: remove private data 'ai_running'

2014-11-04 Thread H Hartley Sweeten
This member of the private data was used to determine if the interrupt
routine was handling data for the (*insn_read) or an async command. Now
that the (*insn_read) does not use interrupts this member is not needed.

Remove the member and refactor the code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 41 --
 drivers/staging/comedi/drivers/addi_apci_3120.c|  1 -
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 83881a6..7bd17c2 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -195,7 +195,6 @@ static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
 
-   devpriv-ai_running = 0;
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
 
/*  variables used in timer subdevice */
@@ -246,7 +245,6 @@ static int apci3120_cancel(struct comedi_device *dev,
inw(dev-iobase + APCI3120_STATUS_REG);
devpriv-ui_DmaActualBuffer = 0;
 
-   devpriv-ai_running = 0;
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
 
return 0;
@@ -338,8 +336,6 @@ static int apci3120_cyclic_ai(int mode,
unsigned int dmalen1 = 0;
unsigned int divisor0;
 
-   devpriv-ai_running = 1;
-
/*  clear software  registers */
devpriv-timer_mode = 0;
devpriv-mode = 0;
@@ -775,18 +771,16 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
if ((status  APCI3120_STATUS_EOS_INT) 
devpriv-b_InterruptMode == APCI3120_EOS_MODE) {
-   if (devpriv-ai_running) {
-   unsigned short val;
-   int i;
-
-   for (i = 0; i  cmd-chanlist_len; i++) {
-   val = inw(dev-iobase + 0);
-   comedi_buf_write_samples(s, val, 1);
-   }
+   unsigned short val;
+   int i;
 
-   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+   for (i = 0; i  cmd-chanlist_len; i++) {
+   val = inw(dev-iobase + 0);
+   comedi_buf_write_samples(s, val, 1);
}
+
+   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
}
 
if (status  APCI3120_STATUS_TIMER2_INT) {
@@ -821,21 +815,14 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
if ((status  APCI3120_STATUS_AMCC_INT) 
devpriv-b_InterruptMode == APCI3120_DMA_MODE) {
-   if (devpriv-ai_running) {
+   /* Clear Timer Write TC int */
+   outl(APCI3120_CLEAR_WRITE_TC_INT,
+   devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
-   /* Clear Timer Write TC int */
-   outl(APCI3120_CLEAR_WRITE_TC_INT,
-devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
-
-   apci3120_clr_timer2_interrupt(dev);
-
-   /* do some data transfer */
-   apci3120_interrupt_dma(irq, d);
-   } else {
-   apci3120_timer_enable(dev, 0, false);
-   apci3120_timer_enable(dev, 1, false);
-   }
+   apci3120_clr_timer2_interrupt(dev);
 
+   /* do some data transfer */
+   apci3120_interrupt_dma(irq, d);
}
comedi_handle_events(dev, s);
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index c18ee17..98de447 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -133,7 +133,6 @@ struct apci3120_private {
unsigned short ctrl;
unsigned char b_Timer2Mode;
unsigned char b_Timer2Interrupt;
-   unsigned int ai_running:1;
unsigned char b_InterruptMode;
unsigned char b_ExttrigEnable;
struct task_struct *tsk_Current;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 077/108] staging: comedi: addi_apci_3120: introduce apci3120_addon_write()

2014-11-04 Thread H Hartley Sweeten
Introduce a helper function to handle the common code that writes a 32-bit
value to the 16-bit add-on register.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 71 +-
 1 file changed, 29 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0942844..b7c83ca 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -44,8 +44,7 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
  * ADDON RELATED ADDITIONS
  */
 /* Constant */
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW0x00
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH   0x1200
+#define APCI3120_ENABLE_TRANSFER_ADD_ON0x1200
 #define APCI3120_A2P_FIFO_MANAGEMENT   0x04000400L
 #define APCI3120_AMWEN_ENABLE  0x02
 #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01
@@ -57,12 +56,9 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_DISABLE_BUS_MASTER_PCI0x0
 
 /* 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
-#define APCI3120_ADD_ON_MWAR_HIGH  (APCI3120_ADD_ON_MWAR_LOW + 2)
-#define APCI3120_ADD_ON_MWTC_LOW   0x058
-#define APCI3120_ADD_ON_MWTC_HIGH  (APCI3120_ADD_ON_MWTC_LOW + 2)
+#define APCI3120_ADD_ON_MWAR   0x24
+#define APCI3120_ADD_ON_AGCSTS 0x3c
+#define APCI3120_ADD_ON_MWTC   0x58
 
 /* AMCC */
 #define APCI3120_AMCC_OP_MCSR  0x3C
@@ -89,6 +85,20 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_COUNTER   3
 
+static void apci3120_addon_write(struct comedi_device *dev,
+unsigned int val, unsigned int reg)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* 16-bit interface for AMCC add-on registers */
+
+   outw(reg, devpriv-addon + 0);
+   outw(val  0x, devpriv-addon + 2);
+
+   outw(reg + 2, devpriv-addon + 0);
+   outw((val  16)  0x, devpriv-addon + 2);
+}
+
 static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
@@ -119,10 +129,7 @@ static int apci3120_cancel(struct comedi_device *dev,
outw(0, devpriv-addon + 4);
 
/* Disable Bus Master ADD ON */
-   outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv-addon + 0);
-   outw(0, devpriv-addon + 2);
-   outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv-addon + 0);
-   outw(0, devpriv-addon + 2);
+   apci3120_addon_write(dev, 0, APCI3120_ADD_ON_AGCSTS);
 
/* Disable BUS Master PCI */
outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
@@ -213,21 +220,11 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
 static void apci3120_init_dma(struct comedi_device *dev,
  struct apci3120_dmabuf *dmabuf)
 {
-   struct apci3120_private *devpriv = dev-private;
+   /* DMA Start Address */
+   apci3120_addon_write(dev, dmabuf-hw, APCI3120_ADD_ON_MWAR);
 
-   /* DMA Start Address Low */
-   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
-   outw(dmabuf-hw  0x, devpriv-addon + 2);
-   /* DMA Start Address High */
-   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
-   outw((dmabuf-hw  16)  0x, devpriv-addon + 2);
-
-   /* Nbr of acquisition LOW */
-   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
-   outw(dmabuf-use_size  0x, devpriv-addon + 2);
-   /* Nbr of acquisition HIGH */
-   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
-   outw((dmabuf-use_size  16)  0x, devpriv-addon + 2);
+   /* Nbr of acquisition */
+   apci3120_addon_write(dev, dmabuf-use_size, APCI3120_ADD_ON_MWTC);
 }
 
 static void apci3120_setup_dma(struct comedi_device *dev,
@@ -287,13 +284,9 @@ static void apci3120_setup_dma(struct comedi_device *dev,
outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
 devpriv-amcc + AMCC_OP_REG_AGCSTS);
 
-   /* changed  since 16 bit interface for add on */
/* ENABLE BUS MASTER */
-   outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv-addon + 0);
-   outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv-addon + 2);
-
-   outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv-addon + 0);
-   outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv-addon + 2);
+   apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON,
+

[PATCH 031/108] staging: comedi: addi_apci_3120: rename private data 'b_ModeSelectRegister'

2014-11-04 Thread H Hartley Sweeten
Rename this CamelCase member of the private data and tidy up the mask/set
of its bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 198 +++--
 drivers/staging/comedi/drivers/addi_apci_3120.c|   2 +-
 2 files changed, 62 insertions(+), 138 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 84aff80..fcb92e8 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -226,7 +226,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
/*  Clear software registers */
devpriv-timer_mode = 0;
-   devpriv-b_ModeSelectRegister = 0;
+   devpriv-mode = 0;
 
if (insn-unused[0] == 222) {   /*  second insn read */
for (i = 0; i  insn-n; i++)
@@ -252,23 +252,17 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
 
/*  Reset the scan bit and Disables the  EOS, DMA, EOC 
interrupt */
-   devpriv-b_ModeSelectRegister =
-   devpriv-
-   b_ModeSelectRegister  APCI3120_DISABLE_SCAN;
+   devpriv-mode = APCI3120_DISABLE_SCAN;
 
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
 
/* Disables the EOS,DMA and enables the EOC 
interrupt */
-   devpriv-b_ModeSelectRegister =
-   (devpriv-
-   b_ModeSelectRegister 
-   APCI3120_DISABLE_EOS_INT) |
-   APCI3120_ENABLE_EOC_INT;
+   devpriv-mode = APCI3120_DISABLE_EOS_INT;
+   devpriv-mode |= APCI3120_ENABLE_EOC_INT;
inw(dev-iobase + 0);
-
}
 
-   outb(devpriv-b_ModeSelectRegister,
+   outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
apci3120_timer_enable(dev, 0, true);
@@ -312,25 +306,20 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
apci3120_timer_write(dev, 0, divisor);
 
/* Set the scan bit */
-   devpriv-b_ModeSelectRegister =
-   devpriv-
-   b_ModeSelectRegister | APCI3120_ENABLE_SCAN;
-   outb(devpriv-b_ModeSelectRegister,
+   devpriv-mode |= APCI3120_ENABLE_SCAN;
+   outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/* If Interrupt function is loaded */
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
/* Disables the EOC,DMA and enables the EOS 
interrupt */
-   devpriv-b_ModeSelectRegister =
-   (devpriv-
-   b_ModeSelectRegister 
-   APCI3120_DISABLE_EOC_INT) |
-   APCI3120_ENABLE_EOS_INT;
+   devpriv-mode = APCI3120_DISABLE_EOC_INT;
+   devpriv-mode |= APCI3120_ENABLE_EOS_INT;
inw(dev-iobase + 0);
 
}
 
-   outb(devpriv-b_ModeSelectRegister,
+   outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
inw(dev-iobase + APCI3120_RD_STATUS);
@@ -386,9 +375,8 @@ static int apci3120_reset(struct comedi_device *dev)
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);
+   devpriv-mode = 0;
+   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
@@ -422,9 +410,8 @@ static int apci3120_cancel(struct comedi_device *dev,
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
/* DISABLE_ALL_INTERRUPT */
-   devpriv-b_ModeSelectRegister = 0;
-   outb(devpriv-b_ModeSelectRegister,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
+   devpriv-mode = 0;
+   

[PATCH 022/108] staging: comedi: addi_apci_3120: move apci3120_exttrig_enable() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this helper function from the included source file into the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ---
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 30e1298..3683c9c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -472,17 +472,6 @@ static int apci3120_reset(struct comedi_device *dev)
return 0;
 }
 
-static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   if (enable)
-   devpriv-ctrl |= APCI3120_CTRL_EXT_TRIG;
-   else
-   devpriv-ctrl = ~APCI3120_CTRL_EXT_TRIG;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
-}
-
 static int apci3120_cancel(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 7bfb320..8f7d9ef 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -220,6 +220,17 @@ static void apci3120_timer_enable(struct comedi_device 
*dev,
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
+static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   if (enable)
+   devpriv-ctrl |= APCI3120_CTRL_EXT_TRIG;
+   else
+   devpriv-ctrl = ~APCI3120_CTRL_EXT_TRIG;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
+}
+
 #include addi-data/hwdrv_apci3120.c
 
 static void apci3120_dma_alloc(struct comedi_device *dev)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 026/108] staging: comedi: addi_apci_3120: remove 'check' param from apci3120_setup_chan_list()

2014-11-04 Thread H Hartley Sweeten
This parameter is always passed as '0'. Remove it and refactor the code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 23 +-
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index dd7805b..44a3fcd 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -188,31 +188,18 @@ static int apci3120_ai_insn_config(struct comedi_device 
*dev,
return insn-n;
 }
 
-/*
- * This function will first check channel list is ok or not and then
- * initialize the sequence RAM with the polarity, Gain,Channel number.
- * If the last argument of function checkis 1 then it only checks
- * the channel list is ok or not.
- */
 static int apci3120_setup_chan_list(struct comedi_device *dev,
struct comedi_subdevice *s,
-   int n_chan,
-   unsigned int *chanlist,
-   char check)
+   int n_chan, unsigned int *chanlist)
 {
struct apci3120_private *devpriv = dev-private;
int i;
 
/* correct channel and range number check itself comedi/range.c */
if (n_chan  1) {
-   if (!check)
-   dev_err(dev-class_dev,
-   range/channel list is empty!\n);
+   dev_err(dev-class_dev, range/channel list is empty!\n);
return 0;
}
-   /*  All is ok, so we can setup channel/range list */
-   if (check)
-   return 1;
 
/* set scan length (PR) and scan start (PA) */
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
@@ -282,7 +269,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
/*  Initialize the sequence array */
if (!apci3120_setup_chan_list(dev, s, 1,
-   insn-chanspec, 0))
+   insn-chanspec))
return -EINVAL;
 
/* Initialize Timer 0 mode 4 */
@@ -347,7 +334,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
if (!apci3120_setup_chan_list(dev, s,
devpriv-ui_AiNbrofChannels,
-   devpriv-ui_AiChannelList, 0))
+   devpriv-ui_AiChannelList))
return -EINVAL;
 
/* Initialize Timer 0 mode 2 */
@@ -594,7 +581,7 @@ static int apci3120_cyclic_ai(int mode,
 
/* Initializes the sequence array */
if (!apci3120_setup_chan_list(dev, s, devpriv-ui_AiNbrofChannels,
-   cmd-chanlist, 0))
+   cmd-chanlist))
return -EINVAL;
 
divisor0 = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 006/108] staging: comedi: addi_apci_3120: fix counter and external interrupt disable

2014-11-04 Thread H Hartley Sweeten
The APCI3120_DISABLE_ALL_TIMER define define is not needed, and it's used
incorrectly in apci3120_cancel(). The define is a mask of the bits needed
to disable the counters. Writing the value directly sets unintended bits.

Prior to writing the value, the 'devpriv-us_OutputRegister' is set to 0
and written to the register. This disables all the timers and the external
trigger.

Remove the unnecessary apci3120_exttrig_disable() call as well as the write
of APCI3120_DISABLE_ALL_TIMER.

In apci3120_interrupt(), remove the unnecessary mask and write to disable
all the timers. The COMEDI_CB_EOA event will cause the core to call the
(*cancel) operation which will disable the timers.

Remove the unused define.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c   | 21 ++---
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 93b1725..6eaf62a 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -167,9 +167,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI3120_TIMER2_SELECT_EOS 0xc0
 #define APCI3120_COUNTER   3
-#define APCI3120_DISABLE_ALL_TIMER (APCI3120_DISABLE_TIMER0   \
-APCI3120_DISABLE_TIMER1   \
-APCI3120_DISABLE_TIMER2)
 
 /* ANALOG INPUT RANGE */
 static const struct comedi_lrange range_apci3120_ai = {
@@ -613,16 +610,9 @@ static int apci3120_cancel(struct comedi_device *dev,
/* Disable BUS Master PCI */
outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
 
-   /* Disable ext trigger */
-   apci3120_exttrig_disable(dev);
-
+   /* stop all counters and disable external trigger */
devpriv-us_OutputRegister = 0;
-   /* 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);
+   outw(devpriv-us_OutputRegister, dev-iobase + APCI3120_WR_ADDRESS);
 
/* DISABLE_ALL_INTERRUPT */
outb(APCI3120_DISABLE_ALL_INTERRUPT,
@@ -1346,13 +1336,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
outb(devpriv-b_ModeSelectRegister,
dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
-   /*  stop timer 2 */
-   devpriv-us_OutputRegister =
-   devpriv-
-   us_OutputRegister  APCI3120_DISABLE_ALL_TIMER;
-   outw(devpriv-us_OutputRegister,
-   dev-iobase + APCI3120_WR_ADDRESS);
-
s-async-events |= COMEDI_CB_EOA;
break;
 
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 068/108] staging: comedi: addi_apci_3120: tidy up timer programming in apci3120_ai_cmd()

2014-11-04 Thread H Hartley Sweeten
Tidy up the programming of timers 0 and 1 so that only one local variable is
required.

Also, remove the unnecessary clear of devpriv-timer_mode. This value will get
set correctly by each apci3120_timer_set_mode() call. It's not necessary to
clear it first.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 52 --
 1 file changed, 19 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 8fc7803..3656f9d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -373,12 +373,10 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
 {
struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
-   unsigned int divisor1 = 0;
-   unsigned int divisor0;
+   unsigned int divisor;
 
-   /*  clear software  registers */
-   devpriv-timer_mode = 0;
devpriv-mode = 0;
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
/* Clear Timer Write TC int */
outl(APCI3120_CLEAR_WRITE_TC_INT,
@@ -391,12 +389,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
/* load chanlist for command scan */
apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
 
-   divisor0 = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
-   if (cmd-scan_begin_src == TRIG_TIMER) {
-   divisor1 = apci3120_ns_to_timer(dev, 1, cmd-scan_begin_arg,
-   cmd-flags);
-   }
-
if (cmd-start_src == TRIG_EXT) {
devpriv-b_ExttrigEnable = 1;
apci3120_exttrig_enable(dev, true);
@@ -404,27 +396,24 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
devpriv-b_ExttrigEnable = 0;
}
 
-   if (cmd-scan_begin_src == TRIG_FOLLOW) {
-   /*  init timer0 in mode 2 */
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
-
-   /* Set the conversion time */
-   apci3120_timer_write(dev, 0, divisor0);
-   } else {/* TRIG_TIMER */
-   /*  init timer1 in mode 2 */
+   if (cmd-scan_begin_src == TRIG_TIMER) {
+   /*
+* Timer 1 is used in MODE2 (rate generator) to set the
+* start time for each scan.
+*/
+   divisor = apci3120_ns_to_timer(dev, 1, cmd-scan_begin_arg,
+  cmd-flags);
apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
-
-   /* Set the scan begin time */
-   apci3120_timer_write(dev, 1, divisor1);
-
-   /*  init timer0 in mode 2 */
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
-
-   /* Set the conversion time */
-   apci3120_timer_write(dev, 0, divisor0);
+   apci3120_timer_write(dev, 1, divisor);
}
 
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+   /*
+* Timer 0 is used in MODE2 (rate generator) to set the conversion
+* time for each acquisition.
+*/
+   divisor = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
+   apci3120_timer_write(dev, 0, divisor);
 
if (devpriv-us_UseDma) {
devpriv-b_InterruptMode = APCI3120_DMA_MODE;
@@ -459,12 +448,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
}
}
 
-   if (cmd-scan_begin_src == TRIG_FOLLOW) {
-   apci3120_timer_enable(dev, 0, true);
-   } else {/* TRIG_TIMER */
+   if (cmd-scan_begin_src == TRIG_TIMER)
apci3120_timer_enable(dev, 1, true);
-   apci3120_timer_enable(dev, 0, true);
-   }
+   apci3120_timer_enable(dev, 0, true);
 
return 0;
 }
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 065/108] staging: comedi: addi_apci_3120: move timer 2 enable in apci3120_cyclic_ai()

2014-11-04 Thread H Hartley Sweeten
Move the enable of timer 2 to avoid needing the extra if() check.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 31ef047..1481d18 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -462,12 +462,11 @@ static int apci3120_cyclic_ai(int mode,
 
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = 1;
+
+   apci3120_timer_enable(dev, 2, true);
}
}
 
-   if (!devpriv-us_UseDma  cmd-stop_src == TRIG_COUNT)
-   apci3120_timer_enable(dev, 2, true);
-
switch (mode) {
case 1:
apci3120_timer_enable(dev, 0, true);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 062/108] staging: comedi: addi_apci_3120: factor DMA setup out of apci3120_cyclic_ai()

2014-11-04 Thread H Hartley Sweeten
For aesthetics, factor the DMA setup code out of apci3120_cyclic_ai().

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 295 +++--
 1 file changed, 148 insertions(+), 147 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index f7543f6..6377c37 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -224,6 +224,153 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
return 0;
 }
 
+static void apci3120_setup_dma(struct comedi_device *dev,
+  struct comedi_subdevice *s)
+{
+   struct apci3120_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
+   struct apci3120_dmabuf *dmabuf0 = devpriv-dmabuf[0];
+   struct apci3120_dmabuf *dmabuf1 = devpriv-dmabuf[1];
+   unsigned int dmalen0 = dmabuf0-size;
+   unsigned int dmalen1 = dmabuf1-size;
+   unsigned int scan_bytes;
+
+   scan_bytes = comedi_samples_to_bytes(s, cmd-scan_end_arg);
+
+   if (cmd-stop_src == TRIG_COUNT) {
+   /*
+* Must we fill full first buffer? And must we fill
+* full second buffer when first is once filled?
+*/
+   if (dmalen0  (cmd-stop_arg * scan_bytes))
+   dmalen0 = cmd-stop_arg * scan_bytes;
+   else if (dmalen1  (cmd-stop_arg * scan_bytes - dmalen0))
+   dmalen1 = cmd-stop_arg * scan_bytes - dmalen0;
+   }
+
+   if (cmd-flags  CMDF_WAKE_EOS) {
+   /* don't we want wake up every scan? */
+   if (dmalen0  scan_bytes) {
+   dmalen0 = scan_bytes;
+   if (cmd-scan_end_arg  1)
+   dmalen0 += 2;
+   }
+   if (dmalen1  scan_bytes) {
+   dmalen1 = scan_bytes;
+   if (cmd-scan_end_arg  1)
+   dmalen1 -= 2;
+   if (dmalen1  4)
+   dmalen1 = 4;
+   }
+   } else {
+   /* isn't output buff smaller that our DMA buff? */
+   if (dmalen0  s-async-prealloc_bufsz)
+   dmalen0 = s-async-prealloc_bufsz;
+   if (dmalen1  s-async-prealloc_bufsz)
+   dmalen1 = s-async-prealloc_bufsz;
+   }
+   dmabuf0-use_size = dmalen0;
+   dmabuf1-use_size = dmalen1;
+
+   /* Initialize DMA */
+
+   /*
+* Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS
+* register 1
+*/
+   outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+devpriv-amcc + AMCC_OP_REG_AGCSTS);
+
+   /* changed  since 16 bit interface for add on */
+   /* ENABLE BUS MASTER */
+   outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv-addon + 0);
+   outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv-addon + 2);
+
+   outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv-addon + 0);
+   outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv-addon + 2);
+
+   /*
+* TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux
+* driver
+*/
+   outw(0x1000, devpriv-addon + 2);
+   /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+
+   /* 2 No change */
+   /* A2P FIFO MANAGEMENT */
+   /* A2P fifo reset  transfer control enable */
+   outl(APCI3120_A2P_FIFO_MANAGEMENT,
+devpriv-amcc + 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
+*/
+
+   /* DMA Start Address Low */
+   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
+   outw(dmabuf0-hw  0x, devpriv-addon + 2);
+
+   /* DMA Start Address High */
+   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
+   outw((dmabuf0-hw  16)  0x, devpriv-addon + 2);
+
+   /*
+* 4
+* amount of bytes to be transferred set transfer count used ADDON
+* MWTC register commented testing
+*/
+
+   /* Nbr of acquisition LOW */
+   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
+   outw(dmabuf0-use_size  0x, devpriv-addon + 2);
+
+   /* Nbr of acquisition HIGH */
+   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
+   outw((dmabuf0-use_size  16)  0x, devpriv-addon + 2);
+
+   /*
+* 5
+* To configure A2P FIFO testing outl(
+* FIFO_ADVANCE_ON_BYTE_2, devpriv-amcc + 

[PATCH 013/108] staging: comedi: addi_apci_3120: tidy up devpriv-ctrl use

2014-11-04 Thread H Hartley Sweeten
The apci3120_setup_chan_list() function sets devpriv-ctrl to the scan length
(PR) and scan start (PA) values and writes the value to the register. There is
no need to mask the value first.

The apci3120_ai_insn_read() function calles apci3120_setup_chan_list(). There
is no need to clear devpriv-ctrl first or clear any additional bits and write
the register again. This also fixes an incorrect use of APCI3120_DISABLE_TIMER0
to disable the timer.

apci3120_cyclic_ai() also calls apci3120_setup_chan_list() so it does not need
to clear devpriv-ctrl or clear any addidional bits and write the register.

Update the comments in apci3120_reset() and apci3120_cancel().

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 34 --
 drivers/staging/comedi/drivers/addi_apci_3120.c|  2 ++
 2 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 4231e99..71fcaa4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -102,9 +102,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_SEQ_RAM_ADDRESS   0x06
 #define APCI3120_RESET_FIFO0x0c
 #define APCI3120_ENABLE_TIMER0 0x1000
-#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
@@ -246,9 +243,8 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
if (check)
return 1;
 
-   /* Code  to set the PA and PR...Here it set PA to 0 */
-   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
-   devpriv-ctrl = ((n_chan - 1)  0xf)  8;
+   /* set scan length (PR) and scan start (PA) */
+   devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
for (i = 0; i  n_chan; i++) {
@@ -292,7 +288,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
/*  Clear software registers */
devpriv-timer_mode = 0;
devpriv-b_ModeSelectRegister = 0;
-   devpriv-ctrl = 0;
 
if (insn-unused[0] == 222) {   /*  second insn read */
for (i = 0; i  insn-n; i++)
@@ -347,7 +342,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/*  Sets gate 0 */
-   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
devpriv-ctrl |= APCI3120_ENABLE_TIMER0;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
@@ -380,11 +374,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev-iobase + 0);
/*  Clears the FIFO */
inw(dev-iobase + APCI3120_RESET_FIFO);
-   /*  clear PA PR  and disable timer 0 */
-
-   devpriv-ctrl = APCI3120_CLEAR_PA_PR;
-   devpriv-ctrl |= APCI3120_DISABLE_TIMER0;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
if (!apci3120_setup_chan_list(dev, s,
devpriv-ui_AiNbrofChannels,
@@ -484,7 +473,7 @@ static int apci3120_reset(struct comedi_device *dev)
outb(devpriv-b_ModeSelectRegister,
dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
-   /*  Disables all counters, ext trigger and clears PA, PR */
+   /* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
@@ -535,7 +524,7 @@ static int apci3120_cancel(struct comedi_device *dev,
/* Disable BUS Master PCI */
outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
 
-   /* stop all counters and disable external trigger */
+   /* disable all counters, ext trigger, and reset scan */
devpriv-ctrl = 0;
outw(devpriv-ctrl, dev-iobase + APCI3120_WR_ADDRESS);
 
@@ -647,20 +636,12 @@ static int apci3120_cyclic_ai(int mode,
 
/*  clear software  registers */
devpriv-timer_mode = 0;
-   devpriv-ctrl = 0;
devpriv-b_ModeSelectRegister = 0;
 
/* Clear Timer Write TC int */
outl(APCI3120_CLEAR_WRITE_TC_INT,
 devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
-   /* Disables All Timer */
-   /* Sets PR and PA to 0*/
-   devpriv-ctrl = APCI3120_DISABLE_TIMER0 
-APCI3120_DISABLE_TIMER1 
-

[PATCH 073/108] staging: comedi: addi_apci_3120: tidy up devpriv-mode in apci3120_ai_cmd()

2014-11-04 Thread H Hartley Sweeten
There is no reason for the separate updates of the mode register in this
function. Refactor the code so that the mode register is only updated at
the end of the function after all the necessary bits have been set.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 95a1b7d..c7f6130 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -373,8 +373,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
struct comedi_cmd *cmd = s-async-cmd;
unsigned int divisor;
 
-   devpriv-mode = 0;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+   /* set default mode bits */
+   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
+   APCI3120_MODE_TIMER2_AS_TIMER;
 
/* Clear Timer Write TC int */
outl(APCI3120_CLEAR_WRITE_TC_INT,
@@ -415,11 +416,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
devpriv-b_InterruptMode = APCI3120_DMA_MODE;
apci3120_setup_dma(dev, s);
} else {
-   /*  disable EOC and enable EOS */
devpriv-b_InterruptMode = APCI3120_EOS_MODE;
 
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
if (cmd-stop_src == TRIG_COUNT) {
/*
@@ -439,13 +438,15 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
 APCI3120_MODE_TIMER2_CLK_EOS |
 APCI3120_MODE_TIMER2_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = 1;
}
}
 
+   /* set mode to enable acquisition */
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+
if (cmd-scan_begin_src == TRIG_TIMER)
apci3120_timer_enable(dev, 1, true);
apci3120_timer_enable(dev, 0, true);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 072/108] staging: comedi: addi_apci_3120: enable chanlist scanning if needed

2014-11-04 Thread H Hartley Sweeten
The 'SCAN_ENA' bit in the mode register needs to be set if the chanlist
has more than 1 channel. Set the bit in apci3120_set_chanlist() if needed.
The callers write the mode register after setting any additional bits,

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index f258ceb..ec66233 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -307,6 +307,10 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
/* set scan length (PR) and scan start (PA) */
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
+
+   /* enable chanlist scanning if necessary */
+   if (n_chan  1)
+   devpriv-mode |= APCI3120_MODE_SCAN_ENA;
 }
 
 #include addi-data/hwdrv_apci3120.c
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 029/108] staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER

2014-11-04 Thread H Hartley Sweeten
At the start of apci3120_ai_insn_read() the devpriv-b_ModeSelectRegister is set
to '0'. Remove the unnecessary masking to clear the interrupt enable bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index cb2856d..2dd8e66 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -92,8 +92,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_DISABLE_EOS_INT   (~APCI3120_ENABLE_EOS_INT)
 #define APCI3120_ENABLE_EOC_INT0x1
 #define APCI3120_DISABLE_EOC_INT   (~APCI3120_ENABLE_EOC_INT)
-#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)
 
@@ -270,11 +268,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
APCI3120_ENABLE_EOC_INT;
inw(dev-iobase + 0);
 
-   } else {
-   devpriv-b_ModeSelectRegister =
-   devpriv-
-   b_ModeSelectRegister 
-   
APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER;
}
 
outb(devpriv-b_ModeSelectRegister,
@@ -337,11 +330,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
APCI3120_ENABLE_EOS_INT;
inw(dev-iobase + 0);
 
-   } else
-   devpriv-b_ModeSelectRegister =
-   devpriv-
-   b_ModeSelectRegister 
-   
APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER;
+   }
 
outb(devpriv-b_ModeSelectRegister,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 074/108] staging: comedi: addi_apci_3120: remove private data 'b_InterruptMode'

2014-11-04 Thread H Hartley Sweeten
This member of the private data is not really needed. The interrupt mode
can be determined by checking the devpriv-mode value to see if the
interrupt is enabled. Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c  | 18 +++---
 drivers/staging/comedi/drivers/addi_apci_3120.c|  1 -
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index c7f6130..84600d4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -74,10 +74,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_START 1
 #define APCI3120_STOP  0
 
-#define APCI3120_EOC_MODE  1
-#define APCI3120_EOS_MODE  2
-#define APCI3120_DMA_MODE  3
-
 #define APCI3120_RD_FIFO   0x00
 
 /* software trigger dummy register */
@@ -97,8 +93,6 @@ static int apci3120_reset(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
 
-   devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-
/*  variables used in timer subdevice */
devpriv-b_Timer2Mode = 0;
devpriv-b_Timer2Interrupt = 0;
@@ -145,8 +139,6 @@ static int apci3120_cancel(struct comedi_device *dev,
inw(dev-iobase + APCI3120_STATUS_REG);
devpriv-ui_DmaActualBuffer = 0;
 
-   devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-
return 0;
 }
 
@@ -413,11 +405,8 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
apci3120_timer_write(dev, 0, divisor);
 
if (devpriv-us_UseDma) {
-   devpriv-b_InterruptMode = APCI3120_DMA_MODE;
apci3120_setup_dma(dev, s);
} else {
-   devpriv-b_InterruptMode = APCI3120_EOS_MODE;
-
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
 
if (cmd-stop_src == TRIG_COUNT) {
@@ -615,12 +604,12 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
dev_err(dev-class_dev, AMCC IRQ - TARGET DMA ABORT!\n);
 
if ((status  APCI3120_STATUS_EOC_INT) == 0 
-   devpriv-b_InterruptMode == APCI3120_EOC_MODE) {
+   (devpriv-mode  APCI3120_MODE_EOC_IRQ_ENA)) {
/* nothing to do... EOC mode is not currently used */
}
 
if ((status  APCI3120_STATUS_EOS_INT) 
-   devpriv-b_InterruptMode == APCI3120_EOS_MODE) {
+   (devpriv-mode  APCI3120_MODE_EOS_IRQ_ENA)) {
unsigned short val;
int i;
 
@@ -663,8 +652,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
apci3120_clr_timer2_interrupt(dev);
}
 
-   if ((status  APCI3120_STATUS_AMCC_INT) 
-   devpriv-b_InterruptMode == APCI3120_DMA_MODE) {
+   if (status  APCI3120_STATUS_AMCC_INT) {
/* Clear Timer Write TC int */
outl(APCI3120_CLEAR_WRITE_TC_INT,
devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ec66233..a6ae42f 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -133,7 +133,6 @@ struct apci3120_private {
unsigned short ctrl;
unsigned char b_Timer2Mode;
unsigned char b_Timer2Interrupt;
-   unsigned char b_InterruptMode;
unsigned char b_ExttrigEnable;
struct task_struct *tsk_Current;
 };
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 067/108] staging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai()

2014-11-04 Thread H Hartley Sweeten
This functon is called by apci3120_ai_cmd() with one additional parameter,
'mode', The 'mode' is based on the cmd-scan_begin_src.

For aesthetics, absorb the function into apci3120_ai_cmd() and use the
cmd-scan_begin_src directly to determine the 'mode'.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 45 --
 1 file changed, 7 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index b4d6fb4..8fc7803 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -368,15 +368,8 @@ static void apci3120_setup_dma(struct comedi_device *dev,
/* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 }
 
-/*
- * This is used for analog input cyclic acquisition.
- * Performs the command operations.
- * If DMA is configured does DMA initialization otherwise does the
- * acquisition with EOS interrupt.
- */
-static int apci3120_cyclic_ai(int mode,
- struct comedi_device *dev,
- struct comedi_subdevice *s)
+static int apci3120_ai_cmd(struct comedi_device *dev,
+  struct comedi_subdevice *s)
 {
struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
@@ -399,7 +392,7 @@ static int apci3120_cyclic_ai(int mode,
apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
 
divisor0 = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
-   if (mode == 2) {
+   if (cmd-scan_begin_src == TRIG_TIMER) {
divisor1 = apci3120_ns_to_timer(dev, 1, cmd-scan_begin_arg,
cmd-flags);
}
@@ -411,16 +404,13 @@ static int apci3120_cyclic_ai(int mode,
devpriv-b_ExttrigEnable = 0;
}
 
-   switch (mode) {
-   case 1:
+   if (cmd-scan_begin_src == TRIG_FOLLOW) {
/*  init timer0 in mode 2 */
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor0);
-   break;
-
-   case 2:
+   } else {/* TRIG_TIMER */
/*  init timer1 in mode 2 */
apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
 
@@ -432,8 +422,6 @@ static int apci3120_cyclic_ai(int mode,
 
/* Set the conversion time */
apci3120_timer_write(dev, 0, divisor0);
-   break;
-
}
 
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
@@ -471,33 +459,14 @@ static int apci3120_cyclic_ai(int mode,
}
}
 
-   switch (mode) {
-   case 1:
+   if (cmd-scan_begin_src == TRIG_FOLLOW) {
apci3120_timer_enable(dev, 0, true);
-   break;
-   case 2:
+   } else {/* TRIG_TIMER */
apci3120_timer_enable(dev, 1, true);
apci3120_timer_enable(dev, 0, true);
-   break;
}
 
return 0;
-
-}
-
-/*
- * Does asynchronous acquisition.
- * Determines the mode 1 or 2.
- */
-static int apci3120_ai_cmd(struct comedi_device *dev,
-  struct comedi_subdevice *s)
-{
-   struct comedi_cmd *cmd = s-async-cmd;
-
-   if (cmd-scan_begin_src == TRIG_FOLLOW)
-   return apci3120_cyclic_ai(1, dev, s);
-   /* TRIG_TIMER */
-   return apci3120_cyclic_ai(2, dev, s);
 }
 
 /*
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 049/108] staging: comedi: addi_apci_3120: fix apci3120_ai_insn_read()

2014-11-04 Thread H Hartley Sweeten
Now that the scanning and interrupt support have been removed from this
function it can be refactored to work correctly.

The comedi core expects (*insn_read) functions to read insn-n values
from the hardware and return the number of samples read. This function
currently just reads one sample but it returns insn-n.

Fix this function to work like the core expects.

Use comedi_timeout() to prevent a possible deadlock in the loop that
waits for the end-of-conversion.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 90 ++
 1 file changed, 40 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 51cdecb..5fb8848 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -139,6 +139,19 @@ static int apci3120_setup_chan_list(struct comedi_device 
*dev,
return 1;   /*  we can serve this with scan logic */
 }
 
+static int apci3120_ai_eoc(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned long context)
+{
+   unsigned int status;
+
+   status = inw(dev-iobase + APCI3120_RD_STATUS);
+   if ((status  APCI3120_EOC) == 0)
+   return 0;
+   return -EBUSY;
+}
+
 static int apci3120_ai_insn_read(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
@@ -146,67 +159,44 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
 {
struct apci3120_private *devpriv = dev-private;
unsigned int divisor;
-   unsigned int ns;
-   unsigned short us_TmpValue;
-
-   /*  fix conversion time to 10 us */
-   ns = 1;
-
-   /*  Clear software registers */
-   devpriv-timer_mode = 0;
-   devpriv-mode = 0;
-
-   if (insn-unused[0] == 222) {   /*  second insn read */
-   } else {
-   devpriv-tsk_Current = current; /*  Save the current process 
task structure */
-
-   divisor = apci3120_ns_to_timer(dev, 0, ns, CMDF_ROUND_NEAREST);
-
-   us_TmpValue = (unsigned short) devpriv-b_InterruptMode;
-
-   switch (us_TmpValue) {
-
-   case APCI3120_EOC_MODE:
-   apci3120_ai_reset_fifo(dev);
-
-   /*  Initialize the sequence array */
-   if (!apci3120_setup_chan_list(dev, s, 1,
-   insn-chanspec))
-   return -EINVAL;
-
-   /* Initialize Timer 0 mode 4 */
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
+   int ret;
+   int i;
 
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+   /* set mode for A/D conversions by software trigger with timer 0 */
+   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
+   APCI3120_MODE_TIMER2_AS_TIMER;
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
-   apci3120_timer_enable(dev, 0, true);
+   /* load chanlist for single channel scan */
+   if (!apci3120_setup_chan_list(dev, s, 1, insn-chanspec))
+   return -EINVAL;
 
-   /* Set the conversion time */
-   apci3120_timer_write(dev, 0, divisor);
+   /*
+* Timer 0 is used in MODE4 (software triggered strobe) to set the
+* conversion time for each acquisition. Each conversion is triggered
+* when the divisor is written to the timer, The conversion is done
+* when the EOC bit in the status register is '0'.
+*/
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
+   apci3120_timer_enable(dev, 0, true);
 
-   us_TmpValue =
-   (unsigned short) inw(dev-iobase + 
APCI3120_RD_STATUS);
+   /* fixed conversion time of 10 us */
+   divisor = apci3120_ns_to_timer(dev, 0, 1, CMDF_ROUND_NEAREST);
 
-   do {
-   /*  Waiting for the end of conversion */
-   us_TmpValue = inw(dev-iobase +
- APCI3120_RD_STATUS);
-   } while ((us_TmpValue  APCI3120_EOC) == APCI3120_EOC);
+   apci3120_ai_reset_fifo(dev);
 
-   /* Read the result in FIFO  and put it in insn data 
pointer */
-   us_TmpValue = inw(dev-iobase + 0);
-   *data = us_TmpValue;
+   for (i = 0; i  insn-n; i++) {
+   /* trigger conversion 

[PATCH 045/108] staging: comedi: addi_apci_3120: remove private data 'ui_EocEosConversionTime'

2014-11-04 Thread H Hartley Sweeten
This driver tries to be tricky and allow passing an analog input conversion time
for the (*insn_read) in the (*insn_config).  The (*insn_config) doesn't follow
the comedi API and this programmable conversion time is not part of the API for
(*insn_read) operations.

Remove the member from the private data and use a fixed 10us (1ns) 
conversion
time in the (*insn_read).

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 10 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  1 -
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 2656e53..9b18abf 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -114,9 +114,6 @@ static int apci3120_ai_insn_config(struct comedi_device 
*dev,
if (data[0] != APCI3120_EOC_MODE)
return -1;
 
-   /*  Check for Conversion time to be added */
-   devpriv-ui_EocEosConversionTime = data[2];
-
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
if (data[1])
devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
@@ -172,10 +169,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
unsigned short us_TmpValue, i;
 
/*  fix conversion time to 10 us */
-   if (!devpriv-ui_EocEosConversionTime)
-   ns = 1;
-   else
-   ns = devpriv-ui_EocEosConversionTime;
+   ns = 1;
 
/*  Clear software registers */
devpriv-timer_mode = 0;
@@ -240,7 +234,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
dev_err(dev-class_dev, inputs wrong\n);
 
}
-   devpriv-ui_EocEosConversionTime = 0;   /*  re initializing the 
variable */
}
 
return insn-n;
@@ -254,7 +247,6 @@ static int apci3120_reset(struct comedi_device *dev)
devpriv-ai_running = 0;
devpriv-b_EocEosInterrupt = APCI3120_DISABLE;
devpriv-b_InterruptMode = APCI3120_EOC_MODE;
-   devpriv-ui_EocEosConversionTime = 0;   /*  set eoc eos conv time to 0 
*/
 
/*  variables used in timer subdevice */
devpriv-b_Timer2Mode = 0;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 0f3dabf..13c06cd 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -129,7 +129,6 @@ struct apci3120_private {
unsigned int ai_running:1;
unsigned char b_InterruptMode;
unsigned char b_EocEosInterrupt;
-   unsigned int ui_EocEosConversionTime;
unsigned char b_ExttrigEnable;
struct task_struct *tsk_Current;
 };
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 064/108] staging: comedi: addi_apci_3120: flip 'us_UseDma' test in apci3120_cyclic_ai()

2014-11-04 Thread H Hartley Sweeten
For aesthetics, flip this test and do the DMA setup first.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 4760200..31ef047 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -434,8 +434,10 @@ static int apci3120_cyclic_ai(int mode,
 
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
-   /*  If DMA is disabled */
-   if (!devpriv-us_UseDma) {
+   if (devpriv-us_UseDma) {
+   devpriv-b_InterruptMode = APCI3120_DMA_MODE;
+   apci3120_setup_dma(dev, s);
+   } else {
/*  disable EOC and enable EOS */
devpriv-b_InterruptMode = APCI3120_EOS_MODE;
 
@@ -461,9 +463,6 @@ static int apci3120_cyclic_ai(int mode,
devpriv-b_Timer2Mode = APCI3120_COUNTER;
devpriv-b_Timer2Interrupt = 1;
}
-   } else {
-   devpriv-b_InterruptMode = APCI3120_DMA_MODE;
-   apci3120_setup_dma(dev, s);
}
 
if (!devpriv-us_UseDma  cmd-stop_src == TRIG_COUNT)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 036/108] staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_INT

2014-11-04 Thread H Hartley Sweeten
For aesthetics, remove this define and just use ~APCI3120_ENABLE_TIMER_INT.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index f6812ea..31920b6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -108,7 +108,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_TIMER_DISABLE 0
 #define APCI3120_TIMER_ENABLE  1
 #define APCI3120_ENABLE_TIMER_INT  0x04
-#define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT 0x0e
 
 #define APCI3120_RD_STATUS 0x02
@@ -1037,7 +1036,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
default:
 
/*  disable Timer Interrupt */
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT;
+   devpriv-mode = ~APCI3120_ENABLE_TIMER_INT;
outb(devpriv-mode,
 dev-iobase + APCI3120_WRITE_MODE_SELECT);
}
@@ -1093,7 +1092,7 @@ static int apci3120_config_insn_timer(struct 
comedi_device *dev,
apci3120_timer_enable(dev, 2, false);
 
/*  Disable TIMER Interrupt */
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT 
+   devpriv-mode = ~APCI3120_ENABLE_TIMER_INT 
 ~APCI3120_ENABLE_TIMER_COUNTER;
 
/*  Disable Eoc and Eos Interrupts */
@@ -1179,7 +1178,7 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
/*  save the task structure to pass info to user */
devpriv-tsk_Current = current;
} else {
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT;
+   devpriv-mode = ~APCI3120_ENABLE_TIMER_INT;
}
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
@@ -1197,7 +1196,7 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
devpriv-mode = ~APCI3120_ENABLE_WATCHDOG;
}
/*  Disable timer interrupt */
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT;
+   devpriv-mode = ~APCI3120_ENABLE_TIMER_INT;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
apci3120_timer_enable(dev, 2, false);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 076/108] staging: comedi: addi_apci_3120: introduce apci3120_init_dma()

2014-11-04 Thread H Hartley Sweeten
Introduce a helper function to handle the common code that writes the DMA
start address and number of acquisitions to the AMCC Add-on registers.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 75 +++---
 1 file changed, 23 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index b38bbd3..0942844 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -210,6 +210,26 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
return 0;
 }
 
+static void apci3120_init_dma(struct comedi_device *dev,
+ struct apci3120_dmabuf *dmabuf)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* DMA Start Address Low */
+   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
+   outw(dmabuf-hw  0x, devpriv-addon + 2);
+   /* DMA Start Address High */
+   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
+   outw((dmabuf-hw  16)  0x, devpriv-addon + 2);
+
+   /* Nbr of acquisition LOW */
+   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
+   outw(dmabuf-use_size  0x, devpriv-addon + 2);
+   /* Nbr of acquisition HIGH */
+   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
+   outw((dmabuf-use_size  16)  0x, devpriv-addon + 2);
+}
+
 static void apci3120_setup_dma(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
@@ -288,34 +308,7 @@ static void apci3120_setup_dma(struct comedi_device *dev,
outl(APCI3120_A2P_FIFO_MANAGEMENT,
 devpriv-amcc + 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
-*/
-
-   /* DMA Start Address Low */
-   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
-   outw(dmabuf0-hw  0x, devpriv-addon + 2);
-
-   /* DMA Start Address High */
-   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
-   outw((dmabuf0-hw  16)  0x, devpriv-addon + 2);
-
-   /*
-* 4
-* amount of bytes to be transferred set transfer count used ADDON
-* MWTC register commented testing
-*/
-
-   /* Nbr of acquisition LOW */
-   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
-   outw(dmabuf0-use_size  0x, devpriv-addon + 2);
-
-   /* Nbr of acquisition HIGH */
-   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
-   outw((dmabuf0-use_size  16)  0x, devpriv-addon + 2);
+   apci3120_init_dma(dev, dmabuf0);
 
/*
 * 5
@@ -481,21 +474,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv-addon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv-addon + 2); 
/*  0x1000 is out putted in windows driver */
 
-   /* DMA Start Address Low */
-   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
-   outw(next_dmabuf-hw  0x, devpriv-addon + 2);
-
-   /* DMA Start Address High */
-   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
-   outw((next_dmabuf-hw  16)  0x, devpriv-addon + 2);
-
-   /* Nbr of acquisition LOW */
-   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
-   outw(next_dmabuf-use_size  0x, devpriv-addon + 2);
-
-   /* Nbr of acquisition HIGH */
-   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
-   outw((next_dmabuf-use_size  16)  0x, devpriv-addon + 2);
+   apci3120_init_dma(dev, next_dmabuf);
 
/*
 * To configure A2P FIFO
@@ -543,15 +522,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
outl(APCI3120_A2P_FIFO_MANAGEMENT,
 devpriv-amcc + AMCC_OP_REG_MCSR);
 
-   outw(APCI3120_ADD_ON_MWAR_LOW, devpriv-addon + 0);
-   outw(dmabuf-hw  0x, devpriv-addon + 2);
-   outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv-addon + 0);
-   outw((dmabuf-hw  16)  0x, devpriv-addon + 2);
-
-   outw(APCI3120_ADD_ON_MWTC_LOW, devpriv-addon + 0);
-   outw(dmabuf-use_size  0x, devpriv-addon + 2);
-   outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv-addon + 0);
-   outw((dmabuf-use_size  16)  0x, devpriv-addon + 2);
+   apci3120_init_dma(dev, dmabuf);
 
/*
 * To configure A2P FIFO
-- 

[PATCH 032/108] staging: comedi: addi_apci_3120: remove unnecessary devpriv-mode masking

2014-11-04 Thread H Hartley Sweeten
The devpriv-mode is set to '0' at the start of apci3120_ai_insn_read() and
apci3120_cyclic_ai(). There is no need to clear any of the bits or do any
of the additional writes of those cleared bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 23 --
 1 file changed, 23 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index fcb92e8..c58d4a6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -251,13 +251,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
/* Initialize Timer 0 mode 4 */
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4);
 
-   /*  Reset the scan bit and Disables the  EOS, DMA, EOC 
interrupt */
-   devpriv-mode = APCI3120_DISABLE_SCAN;
-
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-
-   /* Disables the EOS,DMA and enables the EOC 
interrupt */
-   devpriv-mode = APCI3120_DISABLE_EOS_INT;
devpriv-mode |= APCI3120_ENABLE_EOC_INT;
inw(dev-iobase + 0);
}
@@ -312,11 +306,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
 
/* If Interrupt function is loaded */
if (devpriv-b_EocEosInterrupt == APCI3120_ENABLE) {
-   /* Disables the EOC,DMA and enables the EOS 
interrupt */
-   devpriv-mode = APCI3120_DISABLE_EOC_INT;
devpriv-mode |= APCI3120_ENABLE_EOS_INT;
inw(dev-iobase + 0);
-
}
 
outb(devpriv-mode,
@@ -563,8 +554,6 @@ static int apci3120_cyclic_ai(int mode,
 
}
 
-   /* common for all modes */
-   devpriv-mode = APCI3120_DISABLE_SCAN;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
/*  If DMA is disabled */
@@ -573,18 +562,12 @@ static int apci3120_cyclic_ai(int mode,
devpriv-b_InterruptMode = APCI3120_EOS_MODE;
devpriv-b_EocEosInterrupt = APCI3120_ENABLE;
 
-   devpriv-mode = APCI3120_DISABLE_EOC_INT;
devpriv-mode |= APCI3120_ENABLE_EOS_INT;
outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
 
if (cmd-stop_src == TRIG_COUNT) {
/* configure Timer2 For counting EOS */
 
-   /*  DISABLE TIMER intERRUPT */
-   devpriv-mode = APCI3120_DISABLE_TIMER_INT  0xef;
-   outb(devpriv-mode,
-dev-iobase + APCI3120_WRITE_MODE_SELECT);
-
/* (1) Init timer 2 in mode 0 and write timer value */
apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0);
 
@@ -594,7 +577,6 @@ static int apci3120_cyclic_ai(int mode,
apci3120_clr_timer2_interrupt(dev);
 
/*  enable timer counter and disable watch dog */
-   devpriv-mode = APCI3120_DISABLE_WATCHDOG;
devpriv-mode |= APCI3120_ENABLE_TIMER_COUNTER;
/*  select EOS clock input for timer 2 */
devpriv-mode |= APCI3120_TIMER2_SELECT_EOS;
@@ -615,11 +597,6 @@ static int apci3120_cyclic_ai(int mode,
 
devpriv-b_InterruptMode = APCI3120_DMA_MODE;
 
-   /* Disables the EOC, EOS interrupt  */
-   devpriv-mode = APCI3120_DISABLE_EOC_INT 
-APCI3120_DISABLE_EOS_INT;
-   outb(devpriv-mode, dev-iobase + APCI3120_WRITE_MODE_SELECT);
-
dmalen0 = dmabuf0-size;
dmalen1 = dmabuf1-size;
 
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 066/108] staging: comedi: addi_apci_3120: move start_src check into apci3120_cyclic_ai()

2014-11-04 Thread H Hartley Sweeten
For aesthetics, move the check of the cmd-start_src.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 1481d18..b4d6fb4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -404,8 +404,12 @@ static int apci3120_cyclic_ai(int mode,
cmd-flags);
}
 
-   if (devpriv-b_ExttrigEnable)
+   if (cmd-start_src == TRIG_EXT) {
+   devpriv-b_ExttrigEnable = 1;
apci3120_exttrig_enable(dev, true);
+   } else {
+   devpriv-b_ExttrigEnable = 0;
+   }
 
switch (mode) {
case 1:
@@ -488,14 +492,8 @@ static int apci3120_cyclic_ai(int mode,
 static int apci3120_ai_cmd(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
-   struct apci3120_private *devpriv = dev-private;
struct comedi_cmd *cmd = s-async-cmd;
 
-   if (cmd-start_src == TRIG_EXT)
-   devpriv-b_ExttrigEnable = 1;
-   else
-   devpriv-b_ExttrigEnable = 0;
-
if (cmd-scan_begin_src == TRIG_FOLLOW)
return apci3120_cyclic_ai(1, dev, s);
/* TRIG_TIMER */
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 088/108] staging: comedi: addi_apci_3120: define the AI FIFO register

2014-11-04 Thread H Hartley Sweeten
Define the offset for the analog input FIFO register.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +---
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 3 ++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 10ab6d8..703e4f9 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -43,8 +43,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_START 1
 #define APCI3120_STOP  0
 
-#define APCI3120_RD_FIFO   0x00
-
 /* software trigger dummy register */
 #define APCI3120_START_CONVERSION  0x02
 
@@ -408,7 +406,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
int i;
 
for (i = 0; i  cmd-chanlist_len; i++) {
-   val = inw(dev-iobase + 0);
+   val = inw(dev-iobase + APCI3120_AI_FIFO_REG);
comedi_buf_write_samples(s, val, 1);
}
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index eec0cdb..322640e 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -16,6 +16,7 @@
 /*
  * PCI BAR 1 register map (dev-iobase)
  */
+#define APCI3120_AI_FIFO_REG   0x00
 #define APCI3120_CTRL_REG  0x00
 #define APCI3120_CTRL_EXT_TRIG (1  15)
 #define APCI3120_CTRL_GATE(x)  (1  (12 + (x)))
@@ -370,7 +371,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
if (ret)
return ret;
 
-   data[i] = inw(dev-iobase + 0);
+   data[i] = inw(dev-iobase + APCI3120_AI_FIFO_REG);
}
 
return insn-n;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 05/10] added media specific (MS) TCP drivers

2014-11-04 Thread Greg KH
On Tue, Nov 04, 2014 at 09:48:33AM +0100, Tobias Klauser wrote:
 On 2014-11-03 at 21:42:52 +0100, Stephanie Wallick 
 stephanie.s.wall...@intel.com wrote:
  This is where we handle media specific packets and transport. The MS driver
  interfaces with a media agnostic (MA) driver via a series of transfer pairs.
  Transfer pairs consist of a set of functions to pass MA USB packets back
  and forth between MA and MS drivers. There is one transfer pair per device
  endpoint and one transfer pair for control/management traffic. When the MA
  driver needs to send an MA USB packet, it hands the packet off to the MS
  layer where the packet is converted into an MS form and sent via TCP over
  the underlying ethernet or wireless medium. When the MS driver receives a
  packet, it converts it into an MA USB packet and hands it off the the MA
  driver for handling.
  
  In addition, the MS driver provides an interface to inititate connection 
  events.
  Because there are no physical MA USB ports in an MA USB host, the host must 
  be
  notified via software when a device is connected.
  
  Lastly, the MS driver contains a number of ioctl functions that are used by 
  a
  utility to adjust medium-related driver parameters and connect or 
  disconnect the
  MA USB host and device drivers.
  
  Signed-off-by: Sean O. Stalley sean.stal...@intel.com
  Signed-off-by: Stephanie Wallick stephanie.s.wall...@intel.com
  ---
   drivers/staging/mausb/drivers/mausb_ioctl.c  | 373 +++
   drivers/staging/mausb/drivers/mausb_ioctl.h  |  99 +
   drivers/staging/mausb/drivers/mausb_msapi.c  | 110 ++
   drivers/staging/mausb/drivers/mausb_msapi.h  | 232 
   drivers/staging/mausb/drivers/mausb_tcp-device.c | 147 
   drivers/staging/mausb/drivers/mausb_tcp-host.c   | 144 
   drivers/staging/mausb/drivers/mausb_tcp.c| 446 
  +++
   drivers/staging/mausb/drivers/mausb_tcp.h| 129 +++
   8 files changed, 1680 insertions(+)
   create mode 100644 drivers/staging/mausb/drivers/mausb_ioctl.c
   create mode 100644 drivers/staging/mausb/drivers/mausb_ioctl.h
   create mode 100644 drivers/staging/mausb/drivers/mausb_msapi.c
   create mode 100644 drivers/staging/mausb/drivers/mausb_msapi.h
   create mode 100644 drivers/staging/mausb/drivers/mausb_tcp-device.c
   create mode 100644 drivers/staging/mausb/drivers/mausb_tcp-host.c
   create mode 100644 drivers/staging/mausb/drivers/mausb_tcp.c
   create mode 100644 drivers/staging/mausb/drivers/mausb_tcp.h
  
  diff --git a/drivers/staging/mausb/drivers/mausb_ioctl.c 
  b/drivers/staging/mausb/drivers/mausb_ioctl.c
  new file mode 100644
  index 000..0c6c6bd
  --- /dev/null
  +++ b/drivers/staging/mausb/drivers/mausb_ioctl.c
 
 [...]
 
  +/**
  + * This function is used to send a message to the user, in other words, the
  + * calling process. It basically copies the message one byte at a time.
  + *
  + * @msg:   The message to be sent to the user.
  + * @buffer:The buffer in which to put the message. This buffer was 
  given to
  + * us to fill.
  + */
  +void to_user(char *msg, long unsigned int buffer)
  +{
  +   int length = (int)strlen(msg);
  +   int bytes = 0;
  +
  +   while (length  *msg) {
  +   put_user(*(msg++), (char *)buffer++);
  +   length--;
  +   bytes++;
  +   }
 
 Any reason not to use copy_to_user here? That way, access_ok would only
 need to be executed once for the whole range.
 
 In any case, the return value of put_user/copy_to_user will need to be
 checked.

Never use put_user if you can help it, this whole function should go
away, and copy_to_user() should be used at the caller sites instead as
you point out.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 10/10] added kernel build, configuration, and TODO files

2014-11-04 Thread sostalle
On Mon, Nov 03, 2014 at 01:24:04PM -0800, Greg KH wrote:
On Mon, Nov 03, 2014 at 12:42:57PM -0800, Stephanie Wallick wrote:
 --- /dev/null
 +++ b/drivers/staging/mausb/TODO
 @@ -0,0 +1,14 @@
 +TODO:
 +- checkpatch.pl cleanups

Is this still true?


checkpatch.pl reports:
total: 7 errors, 208 warnings, 10489 lines checked

And why does this need to be a staging driver?  What's wrong with making
it a real driver now?


The short answer is: We don't think it's ready to be real.

We didn't want to release it as a real driver because:
- It's not stable enough yet.
- It doesn't implement all the features required by the MA USB spec.
- The MA USB spec isn't standalone. It requires a supplemental spec
  to define media-specific behavior, like how MA USB packets are
  encapsulated, how to discover MA USB devices on a network, etc.
  So far, no media-specific specifications have been published.
- There are no commercially-available Media Agnostic USB devices.

We wanted to release it to staging now because:
- We have received requests from multiple companies for our host MA USB
  driver. Putting it in staging seemed the best way to distribute it.
- We feel that releasing what we have to staging now could promote
  collaboration on one driver  help prevent duplicate work.


 +- address miscellaneous TODO statements in code
 +- add support for multiple media agnostic (MA) devices
 +- add/improve support for unimplemented packet types
 +- handle errors and failure with more grace and less crash
 +
 +Please send patches to Greg Kroah-Hartman g...@kroah.com and cc:

You didn't use this email address...

 +Sean Stalley sean.stal...@intel.com
 +Stephanie Wallick stephanie.s.wall...@intel.com
 +

Just make a MAINTAINERS entry please for this info.


We will include a MAINTAINERS entry in our next patch in lieu of emails
(especially incorrect emails) in the TODO.


Thanks,

Sean
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 10/10] added kernel build, configuration, and TODO files

2014-11-04 Thread Greg KH
On Tue, Nov 04, 2014 at 09:55:19AM -0800, sostalle wrote:
 On Mon, Nov 03, 2014 at 01:24:04PM -0800, Greg KH wrote:
 On Mon, Nov 03, 2014 at 12:42:57PM -0800, Stephanie Wallick wrote:
  --- /dev/null
  +++ b/drivers/staging/mausb/TODO
  @@ -0,0 +1,14 @@
  +TODO:
  +  - checkpatch.pl cleanups
 
 Is this still true?
 
 
 checkpatch.pl reports:
 total: 7 errors, 208 warnings, 10489 lines checked

Ok, fair enough.

 And why does this need to be a staging driver?  What's wrong with making
 it a real driver now?
 
 
 The short answer is: We don't think it's ready to be real.
 
 We didn't want to release it as a real driver because:
   - It's not stable enough yet.
   - It doesn't implement all the features required by the MA USB spec.
   - The MA USB spec isn't standalone. It requires a supplemental spec
 to define media-specific behavior, like how MA USB packets are
 encapsulated, how to discover MA USB devices on a network, etc.
 So far, no media-specific specifications have been published.
   - There are no commercially-available Media Agnostic USB devices.
 
 We wanted to release it to staging now because:
   - We have received requests from multiple companies for our host MA USB
 driver. Putting it in staging seemed the best way to distribute it.
   - We feel that releasing what we have to staging now could promote
 collaboration on one driver  help prevent duplicate work.

Ok, please include that information in the first email, it's much more
helpful :)

Can you resend this series, and cc: the linux-usb mailing list, and
address the what about usbip? questions as well?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: comedi: add ioctls to set per-file read and write subdevice

2014-11-04 Thread Ian Abbott
Now that Comedi has the structures in place to support setting the
current read and/or write subdevice on a per-file object basis, add
new ioctls to set them.  The newly chosen read (write) subdevice
needs to support read (write) commands, and the file cannot be busy
handling a read (write) command on the previous subdevice (if any).

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/comedi.h  |  2 +
 drivers/staging/comedi/comedi_compat32.c |  2 +
 drivers/staging/comedi/comedi_fops.c | 90 
 3 files changed, 94 insertions(+)

diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index f302ce6..7455740 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -367,6 +367,8 @@ enum comedi_support_level {
 #define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig)
 #define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo)
 #define COMEDI_POLL _IO(CIO, 15)
+#define COMEDI_SETRSUBD _IO(CIO, 16)
+#define COMEDI_SETWSUBD _IO(CIO, 17)
 
 /* structures */
 
diff --git a/drivers/staging/comedi/comedi_compat32.c 
b/drivers/staging/comedi/comedi_compat32.c
index 9b6f96f..5a4c74f 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -416,6 +416,8 @@ static inline int raw_ioctl(struct file *file, unsigned int 
cmd,
case COMEDI_UNLOCK:
case COMEDI_CANCEL:
case COMEDI_POLL:
+   case COMEDI_SETRSUBD:
+   case COMEDI_SETWSUBD:
/* No translation needed. */
rc = translated_ioctl(file, cmd, arg);
break;
diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 79b852c..f143cb6 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1847,6 +1847,90 @@ static int do_poll_ioctl(struct comedi_device *dev, 
unsigned long arg,
return -EINVAL;
 }
 
+/*
+ * COMEDI_SETRSUBD ioctl
+ * sets the current read subdevice on a per-file basis
+ *
+ * arg:
+ * subdevice number
+ *
+ * reads:
+ * nothing
+ *
+ * writes:
+ * nothing
+ */
+static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
+struct file *file)
+{
+   struct comedi_file *cfp = file-private_data;
+   struct comedi_subdevice *s_old, *s_new;
+
+   if (arg = dev-n_subdevices)
+   return -EINVAL;
+
+   s_new = dev-subdevices[arg];
+   s_old = comedi_file_read_subdevice(file);
+   if (s_old == s_new)
+   return 0;   /* no change */
+
+   if (!(s_new-subdev_flags  SDF_CMD_READ))
+   return -EINVAL;
+
+   /*
+* Check the file isn't still busy handling a read command on the
+* old subdevice (if any).
+*/
+   if (s_old  s_old-busy == file  s_old-async 
+   !(s_old-async-cmd.flags  CMDF_WRITE))
+   return -EBUSY;
+
+   ACCESS_ONCE(cfp-read_subdev) = s_new;
+   return 0;
+}
+
+/*
+ * COMEDI_SETWSUBD ioctl
+ * sets the current write subdevice on a per-file basis
+ *
+ * arg:
+ * subdevice number
+ *
+ * reads:
+ * nothing
+ *
+ * writes:
+ * nothing
+ */
+static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
+struct file *file)
+{
+   struct comedi_file *cfp = file-private_data;
+   struct comedi_subdevice *s_old, *s_new;
+
+   if (arg = dev-n_subdevices)
+   return -EINVAL;
+
+   s_new = dev-subdevices[arg];
+   s_old = comedi_file_write_subdevice(file);
+   if (s_old == s_new)
+   return 0;   /* no change */
+
+   if (!(s_new-subdev_flags  SDF_CMD_WRITE))
+   return -EINVAL;
+
+   /*
+* Check the file isn't still busy handling a write command on the
+* old subdevice (if any).
+*/
+   if (s_old  s_old-busy == file  s_old-async 
+   (s_old-async-cmd.flags  CMDF_WRITE))
+   return -EBUSY;
+
+   ACCESS_ONCE(cfp-write_subdev) = s_new;
+   return 0;
+}
+
 static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
  unsigned long arg)
 {
@@ -1941,6 +2025,12 @@ static long comedi_unlocked_ioctl(struct file *file, 
unsigned int cmd,
case COMEDI_POLL:
rc = do_poll_ioctl(dev, arg, file);
break;
+   case COMEDI_SETRSUBD:
+   rc = do_setrsubd_ioctl(dev, arg, file);
+   break;
+   case COMEDI_SETWSUBD:
+   rc = do_setwsubd_ioctl(dev, arg, file);
+   break;
default:
rc = -ENOTTY;
break;
-- 
2.1.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] staging: comedi: per-file read/write subdevice choice

2014-11-04 Thread Ian Abbott
This series of patches adds a couple of ioctl codes to the Comedi core
to allow the current read and write subdevice to be changed after
opening the comedi device.  The current read and write subdevice
information is stored in file private data allocated for the lifetime of
the file object, so the notion of current read and write subdevice
is local to the file object and does not alter anything in the main
control structure for the comedi device.  An extra level of indirection
is now required to access the main control structure.

I've tested the multiple read subdevice case using a modified version
of the comedi_test module (modifying it to clone the existing AI
subdevice), and a modified version of the comedi_test application
(part of the comedilib installation) modified to use the new ioctls.
There isn't any support in comedilib itself yet.

1) staging: comedi: prepare support for per-file read and write
   subdevices
2) staging: comedi: add ioctls to set per-file read and write subdevice

 drivers/staging/comedi/comedi.h  |   2 +
 drivers/staging/comedi/comedi_compat32.c |   2 +
 drivers/staging/comedi/comedi_fops.c | 217 +++
 3 files changed, 196 insertions(+), 25 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: comedi: prepare support for per-file read and write subdevices

2014-11-04 Thread Ian Abbott
Comedi devices may have several subdevices that support read and/or
write asynchronous commands that use the read or write file
operations for data transfer.  The low-level Comedi drivers may nominate
a default read subdevice and/or a default write subdevice, but it
may have other subdevices that support asynchronous commands.

The Comedi core provides a somewhat clunky mechanism to provide access
to the asynchronous command support of the non-default subdevices.  When
a low-level device is attached to a core Comedi device, it dynamically
allocates a minor device number for each of the subdevices that support
asynchrounous commands and associates them with files created in SysFS
named comediX_subdY, where X is the minor device number of the main
comedi device, and Y is the subdevice number.  An application can open
these subdevice-specific files and they behave like the regular
comediX files except that the read and/or write subdevice may be
different to the default chosen by the low-level driver.

This patch adds a layer of indirection between the file object and the
comedi device object to allow the current read and/or write
subdevice to be altered after opening the Comedi device, on a per-file
object basis.  The advantage is that an application only needs to open
the main Comedi device file and can then choose which subdevice it wants
to read or write.  The main Comedi device file can be opened more
than once, and each file object can choose the read and write
subdevices independently.

The new `struct comedi_file` is created on open and freed on
release.  It includes pointers to the main Comedi device structure,
and to the current read and write subdevice structures (which may be
NULL).  It also has information to keep track of when a low-level device
has been attached or detached since the previous time the file object
was used.  In that case, the current read and write subdevices in
the `struct comedi_file` will be changed to the new defaults (or set to
NULL).  (The change to new defaults is done by `comedi_file_reset()`.
The checking for attach/detach is done by `comedi_file_check()` which
will call `comedi_file_reset()` if there have been any attach/detach
operations since the previous call.)

A subsequent patch will add the ioctls to change the current read and
write subdevices.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/comedi_fops.c | 127 ---
 1 file changed, 102 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 65894fd..79b852c 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -43,6 +43,22 @@
 
 #include comedi_internal.h
 
+/**
+ * struct comedi_file - per-file private data for comedi device
+ * @dev: comedi_device struct
+ * @read_subdev: current read subdevice
+ * @write_subdev: current write subdevice
+ * @last_detach_count: last known detach count
+ * @last_attached: last known attached/detached state
+ */
+struct comedi_file {
+   struct comedi_device *dev;
+   struct comedi_subdevice *read_subdev;
+   struct comedi_subdevice *write_subdev;
+   unsigned int last_detach_count;
+   bool last_attached:1;
+};
+
 #define COMEDI_NUM_MINORS 0x100
 #define COMEDI_NUM_SUBDEVICE_MINORS\
(COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS)
@@ -239,6 +255,54 @@ comedi_write_subdevice(const struct comedi_device *dev, 
unsigned int minor)
return dev-write_subdev;
 }
 
+static void comedi_file_reset(struct file *file)
+{
+   struct comedi_file *cfp = file-private_data;
+   struct comedi_device *dev = cfp-dev;
+   struct comedi_subdevice *s, *read_s, *write_s;
+   unsigned int minor = iminor(file_inode(file));
+
+   read_s = dev-read_subdev;
+   write_s = dev-write_subdev;
+   if (minor = COMEDI_NUM_BOARD_MINORS) {
+   s = comedi_subdevice_from_minor(dev, minor);
+   if (s == NULL || s-subdev_flags  SDF_CMD_READ)
+   read_s = s;
+   if (s == NULL || s-subdev_flags  SDF_CMD_WRITE)
+   write_s = s;
+   }
+   cfp-last_attached = dev-attached;
+   cfp-last_detach_count = dev-detach_count;
+   ACCESS_ONCE(cfp-read_subdev) = read_s;
+   ACCESS_ONCE(cfp-write_subdev) = write_s;
+}
+
+static void comedi_file_check(struct file *file)
+{
+   struct comedi_file *cfp = file-private_data;
+   struct comedi_device *dev = cfp-dev;
+
+   if (cfp-last_attached != dev-attached ||
+   cfp-last_detach_count != dev-detach_count)
+   comedi_file_reset(file);
+}
+
+static struct comedi_subdevice *comedi_file_read_subdevice(struct file *file)
+{
+   struct comedi_file *cfp = file-private_data;
+
+   comedi_file_check(file);
+   return ACCESS_ONCE(cfp-read_subdev);
+}
+
+static struct comedi_subdevice *comedi_file_write_subdevice(struct file *file)

[PATCH 079/108] staging: comedi: addi_apci_3120: define the Add-On registers

2014-11-04 Thread H Hartley Sweeten
Define the add-On registers and bits and remove the magic numbers in the
driver.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 40 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  5 +++
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index a38d799..0e31537 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -44,12 +44,7 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
  * ADDON RELATED ADDITIONS
  */
 /* Constant */
-#define APCI3120_AMWEN_ENABLE  0x02
-#define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01
 #define APCI3120_FIFO_ADVANCE_ON_BYTE_20x2000L
-#define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE  0x0
-#define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0
-#define APCI3120_DISABLE_BUS_MASTER_PCI0x0
 
 #define APCI3120_START 1
 #define APCI3120_STOP  0
@@ -76,11 +71,11 @@ static void apci3120_addon_write(struct comedi_device *dev,
 
/* 16-bit interface for AMCC add-on registers */
 
-   outw(reg, devpriv-addon + 0);
-   outw(val  0x, devpriv-addon + 2);
+   outw(reg, devpriv-addon + APCI3120_ADDON_ADDR_REG);
+   outw(val  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
 
-   outw(reg + 2, devpriv-addon + 0);
-   outw((val  16)  0x, devpriv-addon + 2);
+   outw(reg + 2, devpriv-addon + APCI3120_ADDON_ADDR_REG);
+   outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
 }
 
 static int apci3120_reset(struct comedi_device *dev)
@@ -109,7 +104,7 @@ static int apci3120_cancel(struct comedi_device *dev,
 {
struct apci3120_private *devpriv = dev-private;
 
-   /*  Disable A2P Fifo write and AMWEN signal */
+   /* Add-On - disable DMA */
outw(0, devpriv-addon + 4);
 
/* Add-On - disable bus master */
@@ -282,8 +277,9 @@ static void apci3120_setup_dma(struct comedi_device *dev,
outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL,
 devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */
-   outw(3, devpriv-addon + 4);
+   /* Add-On - enable DMA */
+   outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA,
+devpriv-addon + APCI3120_ADDON_CTRL_REG);
 
/* AMCC- reset A2P flags */
outl(RESET_A2P_FLAGS, devpriv-amcc + AMCC_OP_REG_MCSR);
@@ -413,12 +409,10 @@ static void apci3120_interrupt_dma(int irq, void *d)
 
apci3120_init_dma(dev, next_dmabuf);
 
-   /*
-* To configure A2P FIFO
-* ENABLE A2P FIFO WRITE AND ENABLE AMWEN
-* AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
-*/
-   outw(3, devpriv-addon + 4);
+   /* Add-On - enable DMA */
+   outw(APCI3120_ADDON_CTRL_AMWEN_ENA |
+APCI3120_ADDON_CTRL_A2P_FIFO_ENA,
+devpriv-addon + APCI3120_ADDON_CTRL_REG);
 
/* AMCC - enable write complete (DMA) and set FIFO advance */
outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL,
@@ -457,12 +451,10 @@ static void apci3120_interrupt_dma(int irq, void *d)
 
apci3120_init_dma(dev, dmabuf);
 
-   /*
-* To configure A2P FIFO
-* ENABLE A2P FIFO WRITE AND ENABLE AMWEN
-* AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
-*/
-   outw(3, devpriv-addon + 4);
+   /* Add-On - enable DMA */
+   outw(APCI3120_ADDON_CTRL_AMWEN_ENA |
+APCI3120_ADDON_CTRL_A2P_FIFO_ENA,
+devpriv-addon + APCI3120_ADDON_CTRL_REG);
 
/* AMCC - enable write complete (DMA) and set FIFO advance */
outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL,
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 3900a90..699ba76 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -68,6 +68,11 @@
 /*
  * PCI BAR 2 register map (devpriv-addon)
  */
+#define APCI3120_ADDON_ADDR_REG0x00
+#define APCI3120_ADDON_DATA_REG0x02
+#define APCI3120_ADDON_CTRL_REG0x04
+#define APCI3120_ADDON_CTRL_AMWEN_ENA  (1  1)
+#define APCI3120_ADDON_CTRL_A2P_FIFO_ENA   (1  0)
 
 /*
  * Board revisions
-- 
2.0.3


[PATCH 087/108] staging: comedi: addi_apci_3120: don't use timer 2 to count scans

2014-11-04 Thread H Hartley Sweeten
Timer 2 can be used to count the number of scans when the cmd-stop_src
is TRIG_COUNT. Unfortunately that timer can also be used by userspace and
this breaks the async command. Timer 2 also only works for counting the
number of scans when DMA is not used.

The number of scans is counted by the core using the private data membmer
'scans_done'. Use that to detect the End-Of-Scan for both DMA and none
DMA modes.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 51 ++
 1 file changed, 14 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index ec488d1..10ab6d8 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -293,35 +293,11 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
apci3120_timer_write(dev, 0, divisor);
 
-   if (devpriv-use_dma) {
+   if (devpriv-use_dma)
apci3120_setup_dma(dev, s);
-   } else {
+   else
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
 
-   if (cmd-stop_src == TRIG_COUNT) {
-   /*
-* Timer 2 is used in MODE0 (hardware retriggerable
-* one-shot) to count the number of scans.
-*
-* NOTE: not sure about the -2 value
-*/
-   apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0);
-   apci3120_timer_write(dev, 2, cmd-stop_arg - 2);
-
-   apci3120_clr_timer2_interrupt(dev);
-
-   apci3120_timer_enable(dev, 2, true);
-
-   /* configure Timer 2 For counting EOS */
-   devpriv-mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
-APCI3120_MODE_TIMER2_CLK_EOS |
-APCI3120_MODE_TIMER2_IRQ_ENA;
-
-   devpriv-b_Timer2Mode = APCI3120_COUNTER;
-   devpriv-b_Timer2Interrupt = 1;
-   }
-   }
-
/* set mode to enable acquisition */
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
@@ -343,7 +319,8 @@ static void apci3120_interrupt_dma(int irq, void *d)
struct comedi_device *dev = d;
struct apci3120_private *devpriv = dev-private;
struct comedi_subdevice *s = dev-read_subdev;
-   struct comedi_cmd *cmd = s-async-cmd;
+   struct comedi_async *async = s-async;
+   struct comedi_cmd *cmd = async-cmd;
struct apci3120_dmabuf *dmabuf;
unsigned int samplesinbuf;
 
@@ -373,13 +350,12 @@ static void apci3120_interrupt_dma(int irq, void *d)
comedi_buf_write_samples(s, dmabuf-virt, samplesinbuf);
 
if (!(cmd-flags  CMDF_WAKE_EOS))
-   s-async-events |= COMEDI_CB_EOS;
+   async-events |= COMEDI_CB_EOS;
}
-   if (cmd-stop_src == TRIG_COUNT 
-   s-async-scans_done = cmd-stop_arg) {
-   s-async-events |= COMEDI_CB_EOA;
+
+   if ((async-events  COMEDI_CB_CANCEL_MASK) ||
+   (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg))
return;
-   }
 
if (devpriv-use_double_buffer) {
/* switch dma buffers for next interrupt */
@@ -395,7 +371,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
struct comedi_device *dev = d;
struct apci3120_private *devpriv = dev-private;
struct comedi_subdevice *s = dev-read_subdev;
-   struct comedi_cmd *cmd = s-async-cmd;
+   struct comedi_async *async = s-async;
+   struct comedi_cmd *cmd = async-cmd;
unsigned int status;
unsigned int int_amcc;
 
@@ -442,10 +419,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
if (status  APCI3120_STATUS_TIMER2_INT) {
switch (devpriv-b_Timer2Mode) {
case APCI3120_COUNTER:
-   devpriv-mode = ~APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   s-async-events |= COMEDI_CB_EOA;
break;
 
case APCI3120_TIMER:
@@ -478,6 +451,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
/* do some data transfer */
apci3120_interrupt_dma(irq, d);
}
+
+   if (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg)
+   async-events |= COMEDI_CB_EOA;
+
comedi_handle_events(dev, s);
 
return IRQ_HANDLED;
-- 
2.0.3


[PATCH 090/108] staging: comedi: addi_apci_3120: fix timer (*insn_read)

2014-11-04 Thread H Hartley Sweeten
The timer subdevice in this driver does not follow the comedi API.
Fix the (*insn_read) to work correctly.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 35 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 15 +-
 2 files changed, 14 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0c9a655..7c6dec1 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -608,38 +608,3 @@ static int apci3120_write_insn_timer(struct comedi_device 
*dev,
 
return insn-n;
 }
-
-/*
- * Read the Timer value
- *
- * for Timer: data[0]= Timer constant
- *
- * for watchdog: data[0] = 0 (still running)
- *  = 1 (run down)
- */
-static int apci3120_read_insn_timer(struct comedi_device *dev,
-   struct comedi_subdevice *s,
-   struct comedi_insn *insn,
-   unsigned int *data)
-{
-   struct apci3120_private *devpriv = dev-private;
-   unsigned int status;
-
-   if ((devpriv-b_Timer2Mode != APCI3120_WATCHDOG)
-(devpriv-b_Timer2Mode != APCI3120_TIMER)) {
-   dev_err(dev-class_dev, timer2 not configured\n);
-   }
-   if (devpriv-b_Timer2Mode == APCI3120_TIMER) {
-   data[0] = apci3120_timer_read(dev, 2);
-   } else {
-   /* Read watch dog status */
-   status = inw(dev-iobase + APCI3120_STATUS_REG);
-   if (status  APCI3120_STATUS_TIMER2_INT) {
-   apci3120_clr_timer2_interrupt(dev);
-   data[0] = 1;
-   } else {
-   data[0] = 0;
-   }
-   }
-   return insn-n;
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ec2077c..c67c10f 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -447,6 +447,19 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
return insn-n;
 }
 
+static int apci3120_timer_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++)
+   data[i] = apci3120_timer_read(dev, 2);
+
+   return insn-n;
+}
+
 static void apci3120_dma_alloc(struct comedi_device *dev)
 {
struct apci3120_private *devpriv = dev-private;
@@ -618,8 +631,8 @@ static int apci3120_auto_attach(struct comedi_device *dev,
s-n_chan   = 1;
s-maxdata  = 0x00ff;
s-insn_write   = apci3120_write_insn_timer;
-   s-insn_read= apci3120_read_insn_timer;
s-insn_config  = apci3120_config_insn_timer;
+   s-insn_read= apci3120_timer_insn_read;
 
return 0;
 }
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 084/108] staging: comedi: addi_apci_3120: rename private data 'us_UseDma'

2014-11-04 Thread H Hartley Sweeten
Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index c310cf3..8327e2c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -293,7 +293,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
apci3120_timer_write(dev, 0, divisor);
 
-   if (devpriv-us_UseDma) {
+   if (devpriv-use_dma) {
apci3120_setup_dma(dev, s);
} else {
devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 79a96ac..00caa10 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -129,7 +129,7 @@ struct apci3120_private {
unsigned long amcc;
unsigned long addon;
unsigned int osc_base;
-   unsigned short us_UseDma;
+   unsigned int use_dma:1;
unsigned char b_DmaDoubleBuffer;
unsigned int ui_DmaActualBuffer;
struct apci3120_dmabuf dmabuf[2];
@@ -467,7 +467,7 @@ static void apci3120_dma_alloc(struct comedi_device *dev)
dmabuf-size = PAGE_SIZE  order;
 
if (i == 0)
-   devpriv-us_UseDma = 1;
+   devpriv-use_dma = 1;
if (i == 1)
devpriv-b_DmaDoubleBuffer = 1;
}
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 091/108] staging: comedi: addi_apci_3120: fix timer (*insn_config)

2014-11-04 Thread H Hartley Sweeten
The timer subdevice in this driver does not follow the comedi API.

Fix the (*insn_config) to correctly arm, disarm, set the mode, and
get the status of the timer.

Remove the unnecessary, and broken, (*insn_write).

The new (*insn_config) does not enable the interrupt for timer 2.
Remove the interrupt support code for the timer.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 197 +
 drivers/staging/comedi/drivers/addi_apci_3120.c|  85 -
 2 files changed, 83 insertions(+), 199 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 7c6dec1..b650742 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -40,19 +40,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
   +--+---++
 */
 
-#define APCI3120_START 1
-#define APCI3120_STOP  0
-
-/* 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_COUNTER   3
-
 static void apci3120_addon_write(struct comedi_device *dev,
 unsigned int val, unsigned int reg)
 {
@@ -385,8 +372,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
if (devpriv-ctrl  APCI3120_CTRL_EXT_TRIG)
apci3120_exttrig_enable(dev, false);
 
-   apci3120_clr_timer2_interrupt(dev);
-
if (int_amcc  MASTER_ABORT_INT)
dev_err(dev-class_dev, AMCC IRQ - MASTER DMA ABORT!\n);
if (int_amcc  TARGET_ABORT_INT)
@@ -412,28 +397,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
}
 
if (status  APCI3120_STATUS_TIMER2_INT) {
-   switch (devpriv-b_Timer2Mode) {
-   case APCI3120_COUNTER:
-   break;
-
-   case APCI3120_TIMER:
-
-   /* 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_sig(SIGIO, devpriv-tsk_Current, 0);
-   break;
-
-   default:
-   /*  disable Timer Interrupt */
-   devpriv-mode = ~APCI3120_MODE_TIMER2_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-   }
-
+   /*
+* for safety...
+* timer2 interrupts are not enabled in the driver
+*/
apci3120_clr_timer2_interrupt(dev);
}
 
@@ -441,8 +408,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
/* AMCC- Clear write complete interrupt (DMA) */
outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   apci3120_clr_timer2_interrupt(dev);
-
/* do some data transfer */
apci3120_interrupt_dma(irq, d);
}
@@ -454,157 +419,3 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
 
return IRQ_HANDLED;
 }
-
-/*
- * Configure Timer 2
- *
- * data[0] = TIMER configure as timer
- *= WATCHDOG configure as watchdog
- * data[1] = Timer constant
- * data[2] = Timer2 interrupt (1)enable or(0) disable
- */
-static int apci3120_config_insn_timer(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
-   struct apci3120_private *devpriv = dev-private;
-   unsigned int divisor;
-
-   if (!data[1])
-   dev_err(dev-class_dev, No timer constant!\n);
-
-   devpriv-b_Timer2Interrupt = (unsigned char) data[2];   /*  save info 
whether to enable or disable interrupt */
-
-   divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN);
-
-   apci3120_timer_enable(dev, 2, false);
-
-   /* disable timer 2 interrupt and reset operation mode (timer) */
-   devpriv-mode = ~APCI3120_MODE_TIMER2_IRQ_ENA 
-~APCI3120_MODE_TIMER2_AS_MASK;
-
-   /*  Disable Eoc and Eos Interrupts */
-   devpriv-mode = ~APCI3120_MODE_EOC_IRQ_ENA 
-~APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   if (data[0] == 

[PATCH 095/108] staging: comedi: addi_apci_3120: remove unnecessary include

2014-11-04 Thread H Hartley Sweeten
The linux/sched.h header is not needed by this driver. Remove the
include.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 0591f8b..4f1ec0b 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -23,7 +23,6 @@
 
 #include linux/module.h
 #include linux/pci.h
-#include linux/sched.h
 #include linux/interrupt.h
 
 #include ../comedidev.h
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 092/108] staging: comedi: addi_apci_3120: fix cmd-convert_arg vaildation

2014-11-04 Thread H Hartley Sweeten
Regardless of the cmd-scan_begin_src, the minimum cmd-convert_arg
value is 1 (10us). Fix the validation in apci3120_ai_cmdtest().

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index b650742..3ee1ecd 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -118,13 +118,8 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
if (cmd-scan_begin_src == TRIG_TIMER)  /* Test Delay timing */
err |= cfc_check_trigger_arg_min(cmd-scan_begin_arg, 10);
 
-   if (cmd-scan_begin_src == TRIG_TIMER) {
-   if (cmd-convert_arg)
-   err |= cfc_check_trigger_arg_min(cmd-convert_arg,
-1);
-   } else {
-   err |= cfc_check_trigger_arg_min(cmd-convert_arg, 1);
-   }
+   /* minimum conversion time per sample is 10us */
+   err |= cfc_check_trigger_arg_min(cmd-convert_arg, 1);
 
err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 093/108] staging: comedi: addi_apci_3120: move AI (*do_cmdtest) to main driver

2014-11-04 Thread H Hartley Sweeten
Move apci3120_ai_cmdtest() from the included source file to the main
driver source file. Tidy up Step 4 a bit during the move.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 64 -
 drivers/staging/comedi/drivers/addi_apci_3120.c| 67 ++
 2 files changed, 67 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3ee1ecd..3f40176 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -82,70 +82,6 @@ static int apci3120_cancel(struct comedi_device *dev,
return 0;
 }
 
-static int apci3120_ai_cmdtest(struct comedi_device *dev,
-  struct comedi_subdevice *s,
-  struct comedi_cmd *cmd)
-{
-   int err = 0;
-
-   /* Step 1 : check if triggers are trivially valid */
-
-   err |= cfc_check_trigger_src(cmd-start_src, TRIG_NOW | TRIG_EXT);
-   err |= cfc_check_trigger_src(cmd-scan_begin_src,
-   TRIG_TIMER | TRIG_FOLLOW);
-   err |= cfc_check_trigger_src(cmd-convert_src, TRIG_TIMER);
-   err |= cfc_check_trigger_src(cmd-scan_end_src, TRIG_COUNT);
-   err |= cfc_check_trigger_src(cmd-stop_src, TRIG_COUNT | TRIG_NONE);
-
-   if (err)
-   return 1;
-
-   /* Step 2a : make sure trigger sources are unique */
-
-   err |= cfc_check_trigger_is_unique(cmd-start_src);
-   err |= cfc_check_trigger_is_unique(cmd-scan_begin_src);
-   err |= cfc_check_trigger_is_unique(cmd-stop_src);
-
-   /* Step 2b : and mutually compatible */
-
-   if (err)
-   return 2;
-
-   /* Step 3: check if arguments are trivially valid */
-
-   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
-
-   if (cmd-scan_begin_src == TRIG_TIMER)  /* Test Delay timing */
-   err |= cfc_check_trigger_arg_min(cmd-scan_begin_arg, 10);
-
-   /* minimum conversion time per sample is 10us */
-   err |= cfc_check_trigger_arg_min(cmd-convert_arg, 1);
-
-   err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
-   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
-
-   if (cmd-stop_src == TRIG_COUNT)
-   err |= cfc_check_trigger_arg_min(cmd-stop_arg, 1);
-   else/*  TRIG_NONE */
-   err |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
-
-   if (err)
-   return 3;
-
-   /*  step 4: fix up any arguments */
-
-   if (cmd-scan_begin_src == TRIG_TIMER 
-   cmd-scan_begin_arg  cmd-convert_arg * cmd-scan_end_arg) {
-   cmd-scan_begin_arg = cmd-convert_arg * cmd-scan_end_arg;
-   err |= -EINVAL;
-   }
-
-   if (err)
-   return 4;
-
-   return 0;
-}
-
 static void apci3120_init_dma(struct comedi_device *dev,
  struct apci3120_dmabuf *dmabuf)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 806f756..da7da56 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -318,6 +318,73 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_ai_cmdtest(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_cmd *cmd)
+{
+   unsigned int arg;
+   int err = 0;
+
+   /* Step 1 : check if triggers are trivially valid */
+
+   err |= cfc_check_trigger_src(cmd-start_src, TRIG_NOW | TRIG_EXT);
+   err |= cfc_check_trigger_src(cmd-scan_begin_src,
+   TRIG_TIMER | TRIG_FOLLOW);
+   err |= cfc_check_trigger_src(cmd-convert_src, TRIG_TIMER);
+   err |= cfc_check_trigger_src(cmd-scan_end_src, TRIG_COUNT);
+   err |= cfc_check_trigger_src(cmd-stop_src, TRIG_COUNT | TRIG_NONE);
+
+   if (err)
+   return 1;
+
+   /* Step 2a : make sure trigger sources are unique */
+
+   err |= cfc_check_trigger_is_unique(cmd-start_src);
+   err |= cfc_check_trigger_is_unique(cmd-scan_begin_src);
+   err |= cfc_check_trigger_is_unique(cmd-stop_src);
+
+   /* Step 2b : and mutually compatible */
+
+   if (err)
+   return 2;
+
+   /* Step 3: check if arguments are trivially valid */
+
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+
+   if (cmd-scan_begin_src == TRIG_TIMER)  /* Test Delay timing */
+   err |= cfc_check_trigger_arg_min(cmd-scan_begin_arg, 10);
+
+   /* minimum conversion time per sample is 10us */
+   

[PATCH 096/108] staging: comedi: addi_apci_3120: move apci3120_addon_write() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 --
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 14 ++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3cbcc0c..1799833 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1,17 +1,3 @@
-static void apci3120_addon_write(struct comedi_device *dev,
-unsigned int val, unsigned int reg)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   /* 16-bit interface for AMCC add-on registers */
-
-   outw(reg, devpriv-addon + APCI3120_ADDON_ADDR_REG);
-   outw(val  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
-
-   outw(reg + 2, devpriv-addon + APCI3120_ADDON_ADDR_REG);
-   outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
-}
-
 static int apci3120_cancel(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 4f1ec0b..dab81cb 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -163,6 +163,20 @@ struct apci3120_private {
unsigned short ctrl;
 };
 
+static void apci3120_addon_write(struct comedi_device *dev,
+unsigned int val, unsigned int reg)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* 16-bit interface for AMCC add-on registers */
+
+   outw(reg, devpriv-addon + APCI3120_ADDON_ADDR_REG);
+   outw(val  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
+
+   outw(reg + 2, devpriv-addon + APCI3120_ADDON_ADDR_REG);
+   outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
+}
+
 /*
  * There are three timers on the board. They all use the same base
  * clock with a fixed prescaler for each timer. The base clock used
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 100/108] staging: comedi: addi_apci_3120: use async-events to report hardware error

2014-11-04 Thread H Hartley Sweeten
In apci3120_interrupt_dma(), use the async-events to report the hardware
error and allow the core to (*cancel) the command instead of calling the
(*cancel) function directly.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 396aa47..505901c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -50,7 +50,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
dev_err(dev-class_dev, Interrupted DMA transfer!\n);
if (samplesinbuf  1) {
dev_err(dev-class_dev, Odd count of bytes in DMA ring!\n);
-   apci3120_cancel(dev, s);
+   async-events |= COMEDI_CB_ERROR;
return;
}
samplesinbuf = samplesinbuf  1;   /*  number of received samples 
*/
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 094/108] staging: comedi: addi_apci_3120: add copyright information

2014-11-04 Thread H Hartley Sweeten
Remove the copyright info from the included source file and add it
to the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 42 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 23 
 2 files changed, 23 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 3f40176..3cbcc0c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1,45 +1,3 @@
-/**
-@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
-   i...@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.
-
-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.
-
-@endverbatim
-*/
-/*
-  +---+
-  | (C) ADDI-DATA GmbH  Dieselstrasse 3  D-77833 Ottersweier  |
-  +---+
-  | Tel : +49 (0) 7223/9493-0 | email: i...@addi-data.com |
-  | Fax : +49 (0) 7223/9493-92| Internet : http://www.addi-data.com   |
-  +---+
-  | Project : APCI-3120   | Compiler   : GCC  |
-  | Module name : hwdrv_apci3120.c| Version: 2.96 |
-  +---+---+
-  | Project manager: Eric Stolz   | Date   :  02/12/2002  |
-  +---+
-  | Description :APCI3120 Module.  Hardware abstraction Layer for APCI3120|
-  +---+
-  | UPDATE'S  |
-  +---+
-  |   Date   |   Author  |  Description of updates|
-  +--+---++
-  |  |  |  
  |
-  |  |   |   |
-  +--+---++
-*/
-
 static void apci3120_addon_write(struct comedi_device *dev,
 unsigned int val, unsigned int reg)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index da7da56..0591f8b 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -1,3 +1,26 @@
+/*
+ * addi_apci_3120.c
+ * 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
+ * i...@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.
+ *
+ * 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.
+ */
+
 #include linux/module.h
 #include linux/pci.h
 #include linux/sched.h
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 103/108] staging: comedi: addi_apci_3120: use comedi_bytes_to_samples()

2014-11-04 Thread H Hartley Sweeten
Use the helper function to calculate the number of samples in the DMA
buffer. For aesthetics, tidy up the local variables.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index f18622c..c600871 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -12,20 +12,21 @@ static void apci3120_interrupt_dma(int irq, void *d)
struct comedi_async *async = s-async;
struct comedi_cmd *cmd = async-cmd;
struct apci3120_dmabuf *dmabuf;
-   unsigned int samplesinbuf;
+   unsigned int nbytes;
+   unsigned int nsamples;
 
dmabuf = devpriv-dmabuf[devpriv-cur_dmabuf];
 
-   samplesinbuf = dmabuf-use_size - inl(devpriv-amcc + AMCC_OP_REG_MWTC);
+   nbytes = dmabuf-use_size - inl(devpriv-amcc + AMCC_OP_REG_MWTC);
 
-   if (samplesinbuf  dmabuf-use_size)
+   if (nbytes  dmabuf-use_size)
dev_err(dev-class_dev, Interrupted DMA transfer!\n);
-   if (samplesinbuf  1) {
+   if (nbytes  1) {
dev_err(dev-class_dev, Odd count of bytes in DMA ring!\n);
async-events |= COMEDI_CB_ERROR;
return;
}
-   samplesinbuf = samplesinbuf  1;   /*  number of received samples 
*/
+   nsamples = comedi_bytes_to_samples(s, nbytes);
 
if (devpriv-use_double_buffer) {
struct apci3120_dmabuf *next_dmabuf;
@@ -36,8 +37,8 @@ static void apci3120_interrupt_dma(int irq, void *d)
apci3120_init_dma(dev, next_dmabuf);
}
 
-   if (samplesinbuf) {
-   comedi_buf_write_samples(s, dmabuf-virt, samplesinbuf);
+   if (nsamples) {
+   comedi_buf_write_samples(s, dmabuf-virt, nsamples);
 
if (!(cmd-flags  CMDF_WAKE_EOS))
async-events |= COMEDI_CB_EOS;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 104/108] staging: comedi: addi_apci_3120: move apci3120_interrupt_dma() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Remove the now empty included source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 58 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 53 +++-
 2 files changed, 52 insertions(+), 59 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
deleted file mode 100644
index c600871..000
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This is a handler for the DMA interrupt.
- * This function copies the data to Comedi Buffer.
- * For continuous DMA it reinitializes the DMA operation.
- * For single mode DMA it stop the acquisition.
- */
-static void apci3120_interrupt_dma(int irq, void *d)
-{
-   struct comedi_device *dev = d;
-   struct apci3120_private *devpriv = dev-private;
-   struct comedi_subdevice *s = dev-read_subdev;
-   struct comedi_async *async = s-async;
-   struct comedi_cmd *cmd = async-cmd;
-   struct apci3120_dmabuf *dmabuf;
-   unsigned int nbytes;
-   unsigned int nsamples;
-
-   dmabuf = devpriv-dmabuf[devpriv-cur_dmabuf];
-
-   nbytes = dmabuf-use_size - inl(devpriv-amcc + AMCC_OP_REG_MWTC);
-
-   if (nbytes  dmabuf-use_size)
-   dev_err(dev-class_dev, Interrupted DMA transfer!\n);
-   if (nbytes  1) {
-   dev_err(dev-class_dev, Odd count of bytes in DMA ring!\n);
-   async-events |= COMEDI_CB_ERROR;
-   return;
-   }
-   nsamples = comedi_bytes_to_samples(s, nbytes);
-
-   if (devpriv-use_double_buffer) {
-   struct apci3120_dmabuf *next_dmabuf;
-
-   next_dmabuf = devpriv-dmabuf[!devpriv-cur_dmabuf];
-
-   /* start DMA on next buffer */
-   apci3120_init_dma(dev, next_dmabuf);
-   }
-
-   if (nsamples) {
-   comedi_buf_write_samples(s, dmabuf-virt, nsamples);
-
-   if (!(cmd-flags  CMDF_WAKE_EOS))
-   async-events |= COMEDI_CB_EOS;
-   }
-
-   if ((async-events  COMEDI_CB_CANCEL_MASK) ||
-   (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg))
-   return;
-
-   if (devpriv-use_double_buffer) {
-   /* switch dma buffers for next interrupt */
-   devpriv-cur_dmabuf = !devpriv-cur_dmabuf;
-   } else {
-   /* restart DMA if is not using double buffering */
-   apci3120_init_dma(dev, dmabuf);
-   }
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index fce177b..9bdd727 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -435,7 +435,58 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
devpriv-mode |= APCI3120_MODE_SCAN_ENA;
 }
 
-#include addi-data/hwdrv_apci3120.c
+static void apci3120_interrupt_dma(int irq, void *d)
+{
+   struct comedi_device *dev = d;
+   struct apci3120_private *devpriv = dev-private;
+   struct comedi_subdevice *s = dev-read_subdev;
+   struct comedi_async *async = s-async;
+   struct comedi_cmd *cmd = async-cmd;
+   struct apci3120_dmabuf *dmabuf;
+   unsigned int nbytes;
+   unsigned int nsamples;
+
+   dmabuf = devpriv-dmabuf[devpriv-cur_dmabuf];
+
+   nbytes = dmabuf-use_size - inl(devpriv-amcc + AMCC_OP_REG_MWTC);
+
+   if (nbytes  dmabuf-use_size)
+   dev_err(dev-class_dev, Interrupted DMA transfer!\n);
+   if (nbytes  1) {
+   dev_err(dev-class_dev, Odd count of bytes in DMA ring!\n);
+   async-events |= COMEDI_CB_ERROR;
+   return;
+   }
+   nsamples = comedi_bytes_to_samples(s, nbytes);
+
+   if (devpriv-use_double_buffer) {
+   struct apci3120_dmabuf *next_dmabuf;
+
+   next_dmabuf = devpriv-dmabuf[!devpriv-cur_dmabuf];
+
+   /* start DMA on next buffer */
+   apci3120_init_dma(dev, next_dmabuf);
+   }
+
+   if (nsamples) {
+   comedi_buf_write_samples(s, dmabuf-virt, nsamples);
+
+   if (!(cmd-flags  CMDF_WAKE_EOS))
+   async-events |= COMEDI_CB_EOS;
+   }
+
+   if ((async-events  COMEDI_CB_CANCEL_MASK) ||
+   (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg))
+   return;
+
+   if (devpriv-use_double_buffer) {
+   /* switch dma buffers for next interrupt */
+   devpriv-cur_dmabuf = !devpriv-cur_dmabuf;
+   } else {
+

[PATCH 107/108] staging: comedi: addi_apci_3120: enable AI async commands

2014-11-04 Thread H Hartley Sweeten
The async command support should now work. Enable the hook up of the command
support functions in apci3120_auto_attach().

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ba96fe5..f00b9ba0 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -1038,7 +1038,7 @@ static int apci3120_auto_attach(struct comedi_device *dev,
s-maxdata  = this_board-ai_is_16bit ? 0x : 0x0fff;
s-range_table  = apci3120_ai_range;
s-insn_read= apci3120_ai_insn_read;
-   if (0 /* dev-irq */) {
+   if (dev-irq) {
dev-read_subdev = s;
s-subdev_flags |= SDF_CMD_READ;
s-len_chanlist = s-n_chan;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 099/108] staging: comedi: addi_apci_3120: move apci3120_ai_cmd() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 56 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 56 ++
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 771ac87..396aa47 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -26,62 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev,
return 0;
 }
 
-static int apci3120_ai_cmd(struct comedi_device *dev,
-  struct comedi_subdevice *s)
-{
-   struct apci3120_private *devpriv = dev-private;
-   struct comedi_cmd *cmd = s-async-cmd;
-   unsigned int divisor;
-
-   /* set default mode bits */
-   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
-   APCI3120_MODE_TIMER2_AS_TIMER;
-
-   /* AMCC- Clear write complete interrupt (DMA) */
-   outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
-
-   devpriv-cur_dmabuf = 0;
-
-   /* load chanlist for command scan */
-   apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
-
-   if (cmd-start_src == TRIG_EXT)
-   apci3120_exttrig_enable(dev, true);
-
-   if (cmd-scan_begin_src == TRIG_TIMER) {
-   /*
-* Timer 1 is used in MODE2 (rate generator) to set the
-* start time for each scan.
-*/
-   divisor = apci3120_ns_to_timer(dev, 1, cmd-scan_begin_arg,
-  cmd-flags);
-   apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
-   apci3120_timer_write(dev, 1, divisor);
-   }
-
-   /*
-* Timer 0 is used in MODE2 (rate generator) to set the conversion
-* time for each acquisition.
-*/
-   divisor = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
-   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
-   apci3120_timer_write(dev, 0, divisor);
-
-   if (devpriv-use_dma)
-   apci3120_setup_dma(dev, s);
-   else
-   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-
-   /* set mode to enable acquisition */
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   if (cmd-scan_begin_src == TRIG_TIMER)
-   apci3120_timer_enable(dev, 1, true);
-   apci3120_timer_enable(dev, 0, true);
-
-   return 0;
-}
-
 /*
  * This is a handler for the DMA interrupt.
  * This function copies the data to Comedi Buffer.
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index b5ac5b8..8fd498d 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -437,6 +437,62 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
 
 #include addi-data/hwdrv_apci3120.c
 
+static int apci3120_ai_cmd(struct comedi_device *dev,
+  struct comedi_subdevice *s)
+{
+   struct apci3120_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
+   unsigned int divisor;
+
+   /* set default mode bits */
+   devpriv-mode = APCI3120_MODE_TIMER2_CLK_OSC |
+   APCI3120_MODE_TIMER2_AS_TIMER;
+
+   /* AMCC- Clear write complete interrupt (DMA) */
+   outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
+
+   devpriv-cur_dmabuf = 0;
+
+   /* load chanlist for command scan */
+   apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
+
+   if (cmd-start_src == TRIG_EXT)
+   apci3120_exttrig_enable(dev, true);
+
+   if (cmd-scan_begin_src == TRIG_TIMER) {
+   /*
+* Timer 1 is used in MODE2 (rate generator) to set the
+* start time for each scan.
+*/
+   divisor = apci3120_ns_to_timer(dev, 1, cmd-scan_begin_arg,
+  cmd-flags);
+   apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
+   apci3120_timer_write(dev, 1, divisor);
+   }
+
+   /*
+* Timer 0 is used in MODE2 (rate generator) to set the conversion
+* time for each acquisition.
+*/
+   divisor = apci3120_ns_to_timer(dev, 0, cmd-convert_arg, cmd-flags);
+   apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
+   apci3120_timer_write(dev, 0, divisor);
+
+   if (devpriv-use_dma)
+   apci3120_setup_dma(dev, s);
+   else
+   devpriv-mode |= 

[PATCH 102/108] staging: comedi: addi_apci_3120: move apci3120_interrupt() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 72 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 72 ++
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 66e71d5..f18622c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -55,75 +55,3 @@ static void apci3120_interrupt_dma(int irq, void *d)
apci3120_init_dma(dev, dmabuf);
}
 }
-
-static irqreturn_t apci3120_interrupt(int irq, void *d)
-{
-   struct comedi_device *dev = d;
-   struct apci3120_private *devpriv = dev-private;
-   struct comedi_subdevice *s = dev-read_subdev;
-   struct comedi_async *async = s-async;
-   struct comedi_cmd *cmd = async-cmd;
-   unsigned int status;
-   unsigned int int_amcc;
-
-   status = inw(dev-iobase + APCI3120_STATUS_REG);
-   int_amcc = inl(devpriv-amcc + AMCC_OP_REG_INTCSR);
-
-   if (!(status  APCI3120_STATUS_INT_MASK) 
-   !(int_amcc  ANY_S593X_INT)) {
-   dev_err(dev-class_dev, IRQ from unknown source\n);
-   return IRQ_NONE;
-   }
-
-   outl(int_amcc | AINT_INT_MASK, devpriv-amcc + AMCC_OP_REG_INTCSR);
-
-   if (devpriv-ctrl  APCI3120_CTRL_EXT_TRIG)
-   apci3120_exttrig_enable(dev, false);
-
-   if (int_amcc  MASTER_ABORT_INT)
-   dev_err(dev-class_dev, AMCC IRQ - MASTER DMA ABORT!\n);
-   if (int_amcc  TARGET_ABORT_INT)
-   dev_err(dev-class_dev, AMCC IRQ - TARGET DMA ABORT!\n);
-
-   if ((status  APCI3120_STATUS_EOC_INT) == 0 
-   (devpriv-mode  APCI3120_MODE_EOC_IRQ_ENA)) {
-   /* nothing to do... EOC mode is not currently used */
-   }
-
-   if ((status  APCI3120_STATUS_EOS_INT) 
-   (devpriv-mode  APCI3120_MODE_EOS_IRQ_ENA)) {
-   unsigned short val;
-   int i;
-
-   for (i = 0; i  cmd-chanlist_len; i++) {
-   val = inw(dev-iobase + APCI3120_AI_FIFO_REG);
-   comedi_buf_write_samples(s, val, 1);
-   }
-
-   devpriv-mode |= APCI3120_MODE_EOS_IRQ_ENA;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-   }
-
-   if (status  APCI3120_STATUS_TIMER2_INT) {
-   /*
-* for safety...
-* timer2 interrupts are not enabled in the driver
-*/
-   apci3120_clr_timer2_interrupt(dev);
-   }
-
-   if (status  APCI3120_STATUS_AMCC_INT) {
-   /* AMCC- Clear write complete interrupt (DMA) */
-   outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
-
-   /* do some data transfer */
-   apci3120_interrupt_dma(irq, d);
-   }
-
-   if (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg)
-   async-events |= COMEDI_CB_EOA;
-
-   comedi_handle_events(dev, s);
-
-   return IRQ_HANDLED;
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index fd5306e..fce177b 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -437,6 +437,78 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
 
 #include addi-data/hwdrv_apci3120.c
 
+static irqreturn_t apci3120_interrupt(int irq, void *d)
+{
+   struct comedi_device *dev = d;
+   struct apci3120_private *devpriv = dev-private;
+   struct comedi_subdevice *s = dev-read_subdev;
+   struct comedi_async *async = s-async;
+   struct comedi_cmd *cmd = async-cmd;
+   unsigned int status;
+   unsigned int int_amcc;
+
+   status = inw(dev-iobase + APCI3120_STATUS_REG);
+   int_amcc = inl(devpriv-amcc + AMCC_OP_REG_INTCSR);
+
+   if (!(status  APCI3120_STATUS_INT_MASK) 
+   !(int_amcc  ANY_S593X_INT)) {
+   dev_err(dev-class_dev, IRQ from unknown source\n);
+   return IRQ_NONE;
+   }
+
+   outl(int_amcc | AINT_INT_MASK, devpriv-amcc + AMCC_OP_REG_INTCSR);
+
+   if (devpriv-ctrl  APCI3120_CTRL_EXT_TRIG)
+   apci3120_exttrig_enable(dev, false);
+
+   if (int_amcc  MASTER_ABORT_INT)
+   dev_err(dev-class_dev, AMCC IRQ - MASTER DMA ABORT!\n);
+   if (int_amcc  TARGET_ABORT_INT)
+   dev_err(dev-class_dev, AMCC IRQ - TARGET DMA ABORT!\n);
+
+   if ((status  APCI3120_STATUS_EOC_INT) == 0 
+   (devpriv-mode  APCI3120_MODE_EOC_IRQ_ENA)) {
+   /* nothing 

[PATCH 083/108] staging: comedi: addi_apci_3120: move apci3120_reset() to driver source

2014-11-04 Thread H Hartley Sweeten
Move this function from the included hwdrv_apci31210.c source file to
the main driver source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 
 drivers/staging/comedi/drivers/addi_apci_3120.c   | 12 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index f5948fd..c310cf3 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -72,18 +72,6 @@ static void apci3120_addon_write(struct comedi_device *dev,
outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
 }
 
-static void apci3120_reset(struct comedi_device *dev)
-{
-   /* disable all interrupt sources */
-   outb(0, dev-iobase + APCI3120_MODE_REG);
-
-   /* disable all counters, ext trigger, and reset scan */
-   outw(0, dev-iobase + APCI3120_CTRL_REG);
-
-   /* clear interrupt status */
-   inw(dev-iobase + APCI3120_STATUS_REG);
-}
-
 static int apci3120_cancel(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 7ad7621..79a96ac 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -491,6 +491,18 @@ static void apci3120_dma_free(struct comedi_device *dev)
}
 }
 
+static void apci3120_reset(struct comedi_device *dev)
+{
+   /* disable all interrupt sources */
+   outb(0, dev-iobase + APCI3120_MODE_REG);
+
+   /* disable all counters, ext trigger, and reset scan */
+   outw(0, dev-iobase + APCI3120_CTRL_REG);
+
+   /* clear interrupt status */
+   inw(dev-iobase + APCI3120_STATUS_REG);
+}
+
 static int apci3120_auto_attach(struct comedi_device *dev,
unsigned long context)
 {
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 108/108] staging: comedi: addi_apci_3120: absorb apci3120_ai_reset_fifo()

2014-11-04 Thread H Hartley Sweeten
This function is only called by apci3120_set_chanlist(). Absorb it.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index f00b9ba0..e9816e7 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -395,12 +395,6 @@ static void apci3120_exttrig_enable(struct comedi_device 
*dev, bool enable)
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
-static void apci3120_ai_reset_fifo(struct comedi_device *dev)
-{
-   /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */
-   inw(dev-iobase + APCI3120_TIMER_MODE_REG);
-}
-
 static void apci3120_set_chanlist(struct comedi_device *dev,
  struct comedi_subdevice *s,
  int n_chan, unsigned int *chanlist)
@@ -424,7 +418,8 @@ static void apci3120_set_chanlist(struct comedi_device *dev,
outw(val, dev-iobase + APCI3120_CHANLIST_REG);
}
 
-   apci3120_ai_reset_fifo(dev);
+   /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */
+   inw(dev-iobase + APCI3120_TIMER_MODE_REG);
 
/* set scan length (PR) and scan start (PA) */
devpriv-ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0);
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 082/108] staging: comedi: addi_apci_3120: tidy up apci3120_reset()

2014-11-04 Thread H Hartley Sweeten
This function is only called during the attach of the driver and it's
called after the private data has been kzalloc'd. There is no reason
to clear any of the private data members.

Simplify the function by just writing '0' to the necessary registers
to disable all the interrupt sources and stop the timers.

For aesthetics, change the return type to void.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 78d3597..f5948fd 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -72,25 +72,16 @@ static void apci3120_addon_write(struct comedi_device *dev,
outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
 }
 
-static int apci3120_reset(struct comedi_device *dev)
+static void apci3120_reset(struct comedi_device *dev)
 {
-   struct apci3120_private *devpriv = dev-private;
-
-   /*  variables used in timer subdevice */
-   devpriv-b_Timer2Mode = 0;
-   devpriv-b_Timer2Interrupt = 0;
-
-   /* Disable all interrupts, watchdog for the anolog output */
-   devpriv-mode = 0;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+   /* disable all interrupt sources */
+   outb(0, dev-iobase + APCI3120_MODE_REG);
 
/* disable all counters, ext trigger, and reset scan */
-   devpriv-ctrl = 0;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
+   outw(0, dev-iobase + APCI3120_CTRL_REG);
 
+   /* clear interrupt status */
inw(dev-iobase + APCI3120_STATUS_REG);
-
-   return 0;
 }
 
 static int apci3120_cancel(struct comedi_device *dev,
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 106/108] staging: comedi: addi_apci_3120: switch DMA buffers after writing samples

2014-11-04 Thread H Hartley Sweeten
Currently the DMA buffers are switched before writing the current samples to
the async buffer. This works but when the EOA event happens we end up with an
outstanding DMA operation in progress that gets terminated by the (*cancel).

Avoid the outstanding DMA operation by switching the DMA buffers after writing
the samples. The driver will detect the EOA event and not retart the DMA.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index ea53694..ba96fe5 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -456,17 +456,8 @@ static void apci3120_interrupt_dma(struct comedi_device 
*dev,
async-events |= COMEDI_CB_ERROR;
return;
}
-   nsamples = comedi_bytes_to_samples(s, nbytes);
-
-   if (devpriv-use_double_buffer) {
-   struct apci3120_dmabuf *next_dmabuf;
-
-   next_dmabuf = devpriv-dmabuf[!devpriv-cur_dmabuf];
-
-   /* start DMA on next buffer */
-   apci3120_init_dma(dev, next_dmabuf);
-   }
 
+   nsamples = comedi_bytes_to_samples(s, nbytes);
if (nsamples) {
comedi_buf_write_samples(s, dmabuf-virt, nsamples);
 
@@ -479,10 +470,12 @@ static void apci3120_interrupt_dma(struct comedi_device 
*dev,
return;
 
if (devpriv-use_double_buffer) {
-   /* switch dma buffers for next interrupt */
+   /* switch DMA buffers for next interrupt */
devpriv-cur_dmabuf = !devpriv-cur_dmabuf;
+   dmabuf = devpriv-dmabuf[devpriv-cur_dmabuf];
+   apci3120_init_dma(dev, dmabuf);
} else {
-   /* restart DMA if is not using double buffering */
+   /* restart DMA if not using double buffering */
apci3120_init_dma(dev, dmabuf);
}
 }
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 078/108] staging: comedi: addi_apci_3120: use amcc_s5933.h defines

2014-11-04 Thread H Hartley Sweeten
Use the defines for the AMCC 5933 PCI controller registers and bits instead
of creating private defines in this driver.

Move the generic AGCSTS_TC_ENABLE define from this driver to the header.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 151 +++--
 drivers/staging/comedi/drivers/amcc_s5933.h|   2 +
 2 files changed, 50 insertions(+), 103 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index b7c83ca..a38d799 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -44,29 +44,13 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
  * ADDON RELATED ADDITIONS
  */
 /* Constant */
-#define APCI3120_ENABLE_TRANSFER_ADD_ON0x1200
-#define APCI3120_A2P_FIFO_MANAGEMENT   0x04000400L
 #define APCI3120_AMWEN_ENABLE  0x02
 #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01
 #define APCI3120_FIFO_ADVANCE_ON_BYTE_20x2000L
-#define APCI3120_ENABLE_WRITE_TC_INT   0x4000L
-#define APCI3120_CLEAR_WRITE_TC_INT0x0004L
 #define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE  0x0
 #define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0
 #define APCI3120_DISABLE_BUS_MASTER_PCI0x0
 
-/* ADD_ON ::: this needed since apci supports 16 bit interface to add on */
-#define APCI3120_ADD_ON_MWAR   0x24
-#define APCI3120_ADD_ON_AGCSTS 0x3c
-#define APCI3120_ADD_ON_MWTC   0x58
-
-/* AMCC */
-#define APCI3120_AMCC_OP_MCSR  0x3C
-#define APCI3120_AMCC_OP_REG_INTCSR0x38
-
-/* for transfer count enable bit */
-#define AGCSTS_TC_ENABLE   0x1000
-
 #define APCI3120_START 1
 #define APCI3120_STOP  0
 
@@ -128,10 +112,10 @@ static int apci3120_cancel(struct comedi_device *dev,
/*  Disable A2P Fifo write and AMWEN signal */
outw(0, devpriv-addon + 4);
 
-   /* Disable Bus Master ADD ON */
-   apci3120_addon_write(dev, 0, APCI3120_ADD_ON_AGCSTS);
+   /* Add-On - disable bus master */
+   apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS);
 
-   /* Disable BUS Master PCI */
+   /* AMCC - disable bus master */
outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
 
/* disable all counters, ext trigger, and reset scan */
@@ -220,11 +204,11 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
 static void apci3120_init_dma(struct comedi_device *dev,
  struct apci3120_dmabuf *dmabuf)
 {
-   /* DMA Start Address */
-   apci3120_addon_write(dev, dmabuf-hw, APCI3120_ADD_ON_MWAR);
+   /* Add-On - DMA start address */
+   apci3120_addon_write(dev, dmabuf-hw, AMCC_OP_REG_AMWAR);
 
-   /* Nbr of acquisition */
-   apci3120_addon_write(dev, dmabuf-use_size, APCI3120_ADD_ON_MWTC);
+   /* Add-On - Number of acquisitions */
+   apci3120_addon_write(dev, dmabuf-use_size, AMCC_OP_REG_AMWTC);
 }
 
 static void apci3120_setup_dma(struct comedi_device *dev,
@@ -277,70 +261,32 @@ static void apci3120_setup_dma(struct comedi_device *dev,
 
/* Initialize DMA */
 
-   /*
-* Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS
-* register 1
-*/
+   /* AMCC- enable transfer count and reset A2P FIFO */
outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
 devpriv-amcc + AMCC_OP_REG_AGCSTS);
 
-   /* ENABLE BUS MASTER */
-   apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON,
-APCI3120_ADD_ON_AGCSTS);
-
-   /*
-* TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux
-* driver
-*/
-   outw(0x1000, devpriv-addon + 2);
-   /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+   /* Add-On - enable transfer count and reset A2P FIFO */
+   apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+AMCC_OP_REG_AGCSTS);
 
-   /* 2 No change */
-   /* A2P FIFO MANAGEMENT */
-   /* A2P fifo reset  transfer control enable */
-   outl(APCI3120_A2P_FIFO_MANAGEMENT,
-devpriv-amcc + APCI3120_AMCC_OP_MCSR);
+   /* AMCC - enable transfers and reset A2P flags */
+   outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS,
+devpriv-amcc + AMCC_OP_REG_MCSR);
 
apci3120_init_dma(dev, dmabuf0);
 
-   /*
-* 5
-* To configure A2P FIFO testing outl(
-* FIFO_ADVANCE_ON_BYTE_2, devpriv-amcc + AMCC_OP_REG_INTCSR);
-*/
-
-   /* A2P FIFO RESET */
-   /*
-* TO VERIFY 

[PATCH 086/108] staging: comedi: addi_apci_3120: rename private data 'ui_DmaActualBuffer'

2014-11-04 Thread H Hartley Sweeten
Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 10 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c   |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 0275506..ec488d1 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -95,7 +95,7 @@ static int apci3120_cancel(struct comedi_device *dev,
outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
 
inw(dev-iobase + APCI3120_STATUS_REG);
-   devpriv-ui_DmaActualBuffer = 0;
+   devpriv-cur_dmabuf = 0;
 
return 0;
 }
@@ -266,7 +266,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
/* AMCC- Clear write complete interrupt (DMA) */
outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
 
-   devpriv-ui_DmaActualBuffer = 0;
+   devpriv-cur_dmabuf = 0;
 
/* load chanlist for command scan */
apci3120_set_chanlist(dev, s, cmd-chanlist_len, cmd-chanlist);
@@ -347,7 +347,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
struct apci3120_dmabuf *dmabuf;
unsigned int samplesinbuf;
 
-   dmabuf = devpriv-dmabuf[devpriv-ui_DmaActualBuffer];
+   dmabuf = devpriv-dmabuf[devpriv-cur_dmabuf];
 
samplesinbuf = dmabuf-use_size - inl(devpriv-amcc + AMCC_OP_REG_MWTC);
 
@@ -363,7 +363,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
if (devpriv-use_double_buffer) {
struct apci3120_dmabuf *next_dmabuf;
 
-   next_dmabuf = devpriv-dmabuf[1 - devpriv-ui_DmaActualBuffer];
+   next_dmabuf = devpriv-dmabuf[!devpriv-cur_dmabuf];
 
/* start DMA on next buffer */
apci3120_init_dma(dev, next_dmabuf);
@@ -383,7 +383,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
 
if (devpriv-use_double_buffer) {
/* switch dma buffers for next interrupt */
-   devpriv-ui_DmaActualBuffer = 1 - devpriv-ui_DmaActualBuffer;
+   devpriv-cur_dmabuf = !devpriv-cur_dmabuf;
} else {
/* restart DMA if is not using double buffering */
apci3120_init_dma(dev, dmabuf);
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index f768845..eec0cdb 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -131,7 +131,7 @@ struct apci3120_private {
unsigned int osc_base;
unsigned int use_dma:1;
unsigned int use_double_buffer:1;
-   unsigned int ui_DmaActualBuffer;
+   unsigned int cur_dmabuf:1;
struct apci3120_dmabuf dmabuf[2];
unsigned char do_bits;
unsigned char timer_mode;
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 027/108] staging: comedi: addi_apci_3120: introduce apci3120_ai_reset_fifo()

2014-11-04 Thread H Hartley Sweeten
A dummy read of APCI3120_TIMER_MODE_REG resets the analog input FIFO. Introduce
a helper function to clarify this.

It's not necessary to do a dummy read of the FIFO (base + 0) before reseting it.
Remove the unnecessary dummy reads.

The APCI3120_TIMER_MODE_REG is a 16-bit register. This fixes a couple 8-bit 
reads.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 30 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c|  6 +
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 44a3fcd..0673e4f 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -84,8 +84,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI3120_RD_STATUS 0x02
 #define APCI3120_RD_FIFO   0x00
 
-#define APCI3120_RESET_FIFO0x0c
-
 /* nWrMode_Select */
 #define APCI3120_ENABLE_SCAN   0x8
 #define APCI3120_DISABLE_SCAN  (~APCI3120_ENABLE_SCAN)
@@ -261,11 +259,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
switch (us_TmpValue) {
 
case APCI3120_EOC_MODE:
-
-   /*
-* Testing the interrupt flag and set the EOC bit 
Clears the FIFO
-*/
-   inw(dev-iobase + APCI3120_RESET_FIFO);
+   apci3120_ai_reset_fifo(dev);
 
/*  Initialize the sequence array */
if (!apci3120_setup_chan_list(dev, s, 1,
@@ -321,16 +315,13 @@ static int apci3120_ai_insn_read(struct comedi_device 
*dev,
us_TmpValue = inw(dev-iobase + 0);
*data = us_TmpValue;
 
-   inw(dev-iobase + APCI3120_RESET_FIFO);
+   apci3120_ai_reset_fifo(dev);
}
 
break;
 
case APCI3120_EOS_MODE:
-
-   inw(dev-iobase + 0);
-   /*  Clears the FIFO */
-   inw(dev-iobase + APCI3120_RESET_FIFO);
+   apci3120_ai_reset_fifo(dev);
 
if (!apci3120_setup_chan_list(dev, s,
devpriv-ui_AiNbrofChannels,
@@ -430,8 +421,7 @@ static int apci3120_reset(struct comedi_device *dev)
devpriv-ctrl = 0;
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 
-   inw(dev-iobase + 0);   /* make a dummy read */
-   inb(dev-iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
+   apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_RD_STATUS);  /*  flush A/D status register */
 
return 0;
@@ -461,8 +451,8 @@ static int apci3120_cancel(struct comedi_device *dev,
/* DISABLE_ALL_INTERRUPT */
outb(APCI3120_DISABLE_ALL_INTERRUPT,
dev-iobase + APCI3120_WRITE_MODE_SELECT);
-   /* Flush FIFO */
-   inb(dev-iobase + APCI3120_RESET_FIFO);
+
+   apci3120_ai_reset_fifo(dev);
inw(dev-iobase + APCI3120_RD_STATUS);
devpriv-ui_DmaActualBuffer = 0;
 
@@ -559,9 +549,6 @@ static int apci3120_cyclic_ai(int mode,
unsigned int dmalen1 = 0;
unsigned int divisor0;
 
-   /* Resets the FIFO */
-   inb(dev-iobase + APCI3120_RESET_FIFO);
-
devpriv-ai_running = 1;
 
/*  clear software  registers */
@@ -572,10 +559,7 @@ static int apci3120_cyclic_ai(int mode,
outl(APCI3120_CLEAR_WRITE_TC_INT,
 devpriv-amcc + APCI3120_AMCC_OP_REG_INTCSR);
 
-   /* Resets the FIFO */
-   /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
-   inb(dev-iobase + APCI3120_RESET_FIFO);
-   /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+   apci3120_ai_reset_fifo(dev);
 
devpriv-ui_DmaActualBuffer = 0;
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 45add76..8dfee45 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -242,6 +242,12 @@ static void apci3120_exttrig_enable(struct comedi_device 
*dev, bool enable)
outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
 }
 
+static void apci3120_ai_reset_fifo(struct comedi_device *dev)
+{
+   /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */
+   inw(dev-iobase + APCI3120_TIMER_MODE_REG);
+}
+
 #include addi-data/hwdrv_apci3120.c
 
 static void apci3120_dma_alloc(struct comedi_device *dev)
-- 
2.0.3


[PATCH 105/108] staging: comedi: addi_apci_3120: change params to apci3120_interrupt_dma()

2014-11-04 Thread H Hartley Sweeten
Pass the comedi_device and comedi_subdevice pointers to this function instead
of the irq number and void pointer.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3120.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 9bdd727..ea53694 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -435,11 +435,10 @@ static void apci3120_set_chanlist(struct comedi_device 
*dev,
devpriv-mode |= APCI3120_MODE_SCAN_ENA;
 }
 
-static void apci3120_interrupt_dma(int irq, void *d)
+static void apci3120_interrupt_dma(struct comedi_device *dev,
+  struct comedi_subdevice *s)
 {
-   struct comedi_device *dev = d;
struct apci3120_private *devpriv = dev-private;
-   struct comedi_subdevice *s = dev-read_subdev;
struct comedi_async *async = s-async;
struct comedi_cmd *cmd = async-cmd;
struct apci3120_dmabuf *dmabuf;
@@ -549,7 +548,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
outl(AINT_WT_COMPLETE, devpriv-amcc + AMCC_OP_REG_INTCSR);
 
/* do some data transfer */
-   apci3120_interrupt_dma(irq, d);
+   apci3120_interrupt_dma(dev, s);
}
 
if (cmd-stop_src == TRIG_COUNT  async-scans_done = cmd-stop_arg)
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 101/108] staging: comedi: addi_apci_3120: move apci3120_cancel() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 28 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 28 ++
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 505901c..66e71d5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1,31 +1,3 @@
-static int apci3120_cancel(struct comedi_device *dev,
-  struct comedi_subdevice *s)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   /* Add-On - disable DMA */
-   outw(0, devpriv-addon + 4);
-
-   /* Add-On - disable bus master */
-   apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS);
-
-   /* AMCC - disable bus master */
-   outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
-
-   /* disable all counters, ext trigger, and reset scan */
-   devpriv-ctrl = 0;
-   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
-
-   /* DISABLE_ALL_INTERRUPT */
-   devpriv-mode = 0;
-   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
-
-   inw(dev-iobase + APCI3120_STATUS_REG);
-   devpriv-cur_dmabuf = 0;
-
-   return 0;
-}
-
 /*
  * This is a handler for the DMA interrupt.
  * This function copies the data to Comedi Buffer.
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 8fd498d..fd5306e 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -560,6 +560,34 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
return 0;
 }
 
+static int apci3120_cancel(struct comedi_device *dev,
+  struct comedi_subdevice *s)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* Add-On - disable DMA */
+   outw(0, devpriv-addon + 4);
+
+   /* Add-On - disable bus master */
+   apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS);
+
+   /* AMCC - disable bus master */
+   outl(0, devpriv-amcc + AMCC_OP_REG_MCSR);
+
+   /* disable all counters, ext trigger, and reset scan */
+   devpriv-ctrl = 0;
+   outw(devpriv-ctrl, dev-iobase + APCI3120_CTRL_REG);
+
+   /* DISABLE_ALL_INTERRUPT */
+   devpriv-mode = 0;
+   outb(devpriv-mode, dev-iobase + APCI3120_MODE_REG);
+
+   inw(dev-iobase + APCI3120_STATUS_REG);
+   devpriv-cur_dmabuf = 0;
+
+   return 0;
+}
+
 static int apci3120_ai_eoc(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 097/108] staging: comedi: addi_apci_3120: move apci3120_init_dma() to driver

2014-11-04 Thread H Hartley Sweeten
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 32 --
 drivers/staging/comedi/drivers/addi_apci_3120.c| 32 ++
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 1799833..a241368 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -26,38 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev,
return 0;
 }
 
-static void apci3120_init_dma(struct comedi_device *dev,
- struct apci3120_dmabuf *dmabuf)
-{
-   struct apci3120_private *devpriv = dev-private;
-
-   /* AMCC - enable transfer count and reset A2P FIFO */
-   outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
-devpriv-amcc + AMCC_OP_REG_AGCSTS);
-
-   /* Add-On - enable transfer count and reset A2P FIFO */
-   apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
-AMCC_OP_REG_AGCSTS);
-
-   /* AMCC - enable transfers and reset A2P flags */
-   outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS,
-devpriv-amcc + AMCC_OP_REG_MCSR);
-
-   /* Add-On - DMA start address */
-   apci3120_addon_write(dev, dmabuf-hw, AMCC_OP_REG_AMWAR);
-
-   /* Add-On - Number of acquisitions */
-   apci3120_addon_write(dev, dmabuf-use_size, AMCC_OP_REG_AMWTC);
-
-   /* AMCC - enable write complete (DMA) and set FIFO advance */
-   outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL,
-devpriv-amcc + AMCC_OP_REG_INTCSR);
-
-   /* Add-On - enable DMA */
-   outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA,
-devpriv-addon + APCI3120_ADDON_CTRL_REG);
-}
-
 static void apci3120_setup_dma(struct comedi_device *dev,
   struct comedi_subdevice *s)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index dab81cb..d66e910 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -177,6 +177,38 @@ static void apci3120_addon_write(struct comedi_device *dev,
outw((val  16)  0x, devpriv-addon + APCI3120_ADDON_DATA_REG);
 }
 
+static void apci3120_init_dma(struct comedi_device *dev,
+ struct apci3120_dmabuf *dmabuf)
+{
+   struct apci3120_private *devpriv = dev-private;
+
+   /* AMCC - enable transfer count and reset A2P FIFO */
+   outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+devpriv-amcc + AMCC_OP_REG_AGCSTS);
+
+   /* Add-On - enable transfer count and reset A2P FIFO */
+   apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO,
+AMCC_OP_REG_AGCSTS);
+
+   /* AMCC - enable transfers and reset A2P flags */
+   outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS,
+devpriv-amcc + AMCC_OP_REG_MCSR);
+
+   /* Add-On - DMA start address */
+   apci3120_addon_write(dev, dmabuf-hw, AMCC_OP_REG_AMWAR);
+
+   /* Add-On - Number of acquisitions */
+   apci3120_addon_write(dev, dmabuf-use_size, AMCC_OP_REG_AMWTC);
+
+   /* AMCC - enable write complete (DMA) and set FIFO advance */
+   outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL,
+devpriv-amcc + AMCC_OP_REG_INTCSR);
+
+   /* Add-On - enable DMA */
+   outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA,
+devpriv-addon + APCI3120_ADDON_CTRL_REG);
+}
+
 /*
  * There are three timers on the board. They all use the same base
  * clock with a fixed prescaler for each timer. The base clock used
-- 
2.0.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 0/2] staging: comedi: per-file read/write subdevice choice

2014-11-04 Thread Hartley Sweeten
On Tuesday, November 04, 2014 11:09 AM, Ian Abbott wrote:
 This series of patches adds a couple of ioctl codes to the Comedi core
 to allow the current read and write subdevice to be changed after
 opening the comedi device.  The current read and write subdevice
 information is stored in file private data allocated for the lifetime of
 the file object, so the notion of current read and write subdevice
 is local to the file object and does not alter anything in the main
 control structure for the comedi device.  An extra level of indirection
 is now required to access the main control structure.

 I've tested the multiple read subdevice case using a modified version
 of the comedi_test module (modifying it to clone the existing AI
 subdevice), and a modified version of the comedi_test application
 (part of the comedilib installation) modified to use the new ioctls.
 There isn't any support in comedilib itself yet.

 1) staging: comedi: prepare support for per-file read and write
subdevices
 2) staging: comedi: add ioctls to set per-file read and write subdevice

  drivers/staging/comedi/comedi.h  |   2 +
  drivers/staging/comedi/comedi_compat32.c |   2 +
  drivers/staging/comedi/comedi_fops.c | 217 
 +++
  3 files changed, 196 insertions(+), 25 deletions(-)

Ian,

If I understand this correctly, the user can now open the comediX
device which will give then access to the default dev-read_subdev
and dev-write_subdev. They can then use the new ioctls to change
the read/write subdevice and use them without having the open the
comediX_subdY devices.

If this is correct it seems like a good idea.

Reviewed-by: H Hartley Sweeten hswee...@visionengravers.com

Also, does this mean we can get rid of comedi_alloc_subdevice_minor()
and the comediX_sudbY stuff?

Regards,
Hartley

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/10] MA USB drivers cover letter

2014-11-04 Thread sostalle
On Tue, Nov 04, 2014 at 10:00:32AM +0100, Bjørn Mork wrote:
 [added linux-...@vger.kernel.org Cc]

 Nice.  But don't you think this deserves the attention of the linux-usb
 mailing list?  Yes, Greg's attention is of course good to have too :-)
 But  I believe this is of interest to more people, who might not read
 everything on linux-kernel.

This is probably more relevant/interesting to the people on linux-usb.
Since we were trying to get this driver into staging, we thought linux-kernel
was the right place to send the patches. We can send the next set out to
linux-usb as well.

 Has there been any thought/discussion about the relationship to the
 existing usbip drivers, which just moved out of staging? Is a usbip
 userspace compatibility layer feasible sometime in the future?

That discussion hasn't happened. usbip has a different protocol than MA USB,
so much of the code cannot be reused.

I just briefly looked into the userspace code for usbip. It looks like the
userspace compatibility layer is just a utility for establishing the TCP
connection between the host and device  choosing what devices to connect,
correct? We have a similar utility (see patch 9/10) which could probably
be replaced by the usbip userspace utilities.

 Bjørn
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/10] MA USB drivers cover letter

2014-11-04 Thread sostalle
On Tue, Nov 04, 2014 at 10:00:32AM +0100, Bjørn Mork wrote:
 [added linux-...@vger.kernel.org Cc]

 Nice.  But don't you think this deserves the attention of the linux-usb
 mailing list?  Yes, Greg's attention is of course good to have too :-)
 But  I believe this is of interest to more people, who might not read
 everything on linux-kernel.

This is probably more relevant/interesting to the people on linux-usb.
Since we were trying to get this driver into staging, we thought linux-kernel
was the right place to send the patches. We can send the next set out to
linux-usb as well.

 Has there been any thought/discussion about the relationship to the
 existing usbip drivers, which just moved out of staging? Is a usbip
 userspace compatibility layer feasible sometime in the future?

That discussion hasn't happened. usbip has a different protocol than MA USB,
so much of the code cannot be reused.

I just briefly looked into the userspace code for usbip. It looks like the
userspace compatibility layer is just a utility for establishing the TCP
connection between the host and device  choosing what devices to connect,
correct? We have a similar utility (see patch 9/10) which could probably
be replaced by the usbip userspace utilities.

 Bjørn
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: unisys: virtpci: Remove GET_BUS_DEV macro

2014-11-04 Thread Bryan Thompson
The GET_BUS_DEV macro contained flow control statements that are undesirable.
This patch removes the macro and places the code in each function.

Signed-off-by: Bryan Thompson bryan.thomp...@unisys.com
---
 drivers/staging/unisys/virtpci/virtpci.c |   48 --
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index e212c7a..39b828d 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -303,17 +303,6 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
  sizeof(struct vhba_config_max));  \
}
 
-/* find bus device with the busid that matches - match_busid matches bus_id */
-#define GET_BUS_DEV(busno) { \
-   sprintf(busid, vbus%d, busno); \
-   vbus = bus_find_device(virtpci_bus_type, NULL, \
-  (void *)busid, match_busid); \
-   if (!vbus) { \
-   LOGERR( FAILED to find vbus %s\n, busid); \
-   return 0; \
-   } \
-}
-
 /* adds a vhba
  * returns 0 failure, 1 success,
  */
@@ -334,7 +323,14 @@ static int add_vhba(struct add_virt_guestpart *addparams)
 
GET_SCSIADAPINFO_FROM_CHANPTR(addparams-chanptr);
 
-   GET_BUS_DEV(addparams-bus_no);
+   /* find bus device with the busid that matches match_busid */
+   sprintf(busid, vbus%d, addparams-bus_no);
+   vbus = bus_find_device(virtpci_bus_type, NULL,
+  (void *)busid, match_busid);
+   if (!vbus) {
+   LOGERR( FAILED to find vbus %s\n, busid);
+   return 0;
+   }
 
LOGINF(Adding vhba wwnn:%x:%x config:%d-%d-%d-%d chanptr:%p\n,
   scsi.wwnn.wwnn1, scsi.wwnn.wwnn2,
@@ -390,7 +386,14 @@ add_vnic(struct add_virt_guestpart *addparams)
 
GET_NETADAPINFO_FROM_CHANPTR(addparams-chanptr);
 
-   GET_BUS_DEV(addparams-bus_no);
+   /* find bus device with the busid that matches match_busid */
+   sprintf(busid, vbus%d, addparams-bus_no);
+   vbus = bus_find_device(virtpci_bus_type, NULL,
+  (void *)busid, match_busid);
+   if (!vbus) {
+   LOGERR( FAILED to find vbus %s\n, busid);
+   return 0;
+   }
 
LOGINF(Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d 
mtu:%d chanptr:%p%pUL\n,
   net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
@@ -417,7 +420,15 @@ delete_vbus(struct del_vbus_guestpart *delparams)
struct device *vbus;
unsigned char busid[BUS_ID_SIZE];
 
-   GET_BUS_DEV(delparams-bus_no);
+   /* find bus device with the busid that matches match_busid */
+   sprintf(busid, vbus%d, delparams-bus_no);
+   vbus = bus_find_device(virtpci_bus_type, NULL,
+  (void *)busid, match_busid);
+   if (!vbus) {
+   LOGERR( FAILED to find vbus %s\n, busid);
+   return 0;
+   }
+
/* ensure that bus has no devices? -- TBD */
LOGINF(Deleting %s\n, BUS_ID(vbus));
if (delete_vbus_device(vbus, NULL))
@@ -621,7 +632,14 @@ static int delete_all_virt(enum virtpci_dev_type devtype,
unsigned char busid[BUS_ID_SIZE];
struct device *vbus;
 
-   GET_BUS_DEV(delparams-bus_no);
+   /* find bus device with the busid that matches match_busid */
+   sprintf(busid, vbus%d, delparams-bus_no);
+   vbus = bus_find_device(virtpci_bus_type, NULL,
+  (void *)busid, match_busid);
+   if (!vbus) {
+   LOGERR( FAILED to find vbus %s\n, busid);
+   return 0;
+   }
 
if ((devtype != VIRTHBA_TYPE)  (devtype != VIRTNIC_TYPE)) {
LOGERR( FAILED to delete all devices; devtype:%d not 
vhba:%d or vnic:%d\n,
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


<    1   2   3   >