[PATCH] staging: frontier: fix memory leak in usb_alphatrack_probe()

2014-03-07 Thread Daeseok Youn

oldi_buffer and write_buffer need to free when usb_alphatrack_delete()
is called.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/frontier/alphatrack.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/frontier/alphatrack.c 
b/drivers/staging/frontier/alphatrack.c
index edd5cef..4d630da 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -208,6 +208,8 @@ static void usb_alphatrack_delete(struct usb_alphatrack 
*dev)
kfree(dev->ring_buffer);
kfree(dev->interrupt_in_buffer);
kfree(dev->interrupt_out_buffer);
+   kfree(dev->oldi_buffer);
+   kfree(dev->write_buffer);
kfree(dev); /* fixme oldi_buffer */
 }
 
-- 
1.7.4.4


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


Re: [PATCH] [staging][r8188eu]: memory leak in rtw_free_cmd_obj if command is (_Set_Drv_Extra)

2014-03-07 Thread Dan Carpenter
On Fri, Mar 07, 2014 at 03:01:34PM -0500, Wang, Xiaoming wrote:
> pcmd->parmbuf->pbuf has been allocated if command is 
> GEN_CMD_CODE(_Set_Drv_Extra),
> and it enqueued by rtw_enqueue_cmd. rtw_cmd_thread dequeue pcmd by 
> rtw_dequeue_cmd.
> The memory leak happened on this branch "if( _FAIL == 
> rtw_cmd_filter(pcmdpriv, pcmd) )"
> which goto post_process directly against freeing pcmd->parmbuf->pbuf in
> rtw_drvextra_cmd_hdl which is the cmd_hdl if command is (_Set_Drv_Extra).
> This patch free pcmd->parmbuf->pbuf on forgotten branch to avoid memory leak.
> 
> Signed-off-by: Zhang Dongxing 
> Signed-off-by: xiaoming wang 

This code looks completely different in linux-next.  Please redo on top
of linux-next if it's still needed.

regards,
dan carpenter

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


Re: [PATCH] staging: frontier: fix memory leak in usb_alphatrack_probe()

2014-03-07 Thread Dan Carpenter
On Fri, Mar 07, 2014 at 05:02:25PM +0900, Daeseok Youn wrote:
> 
> oldi_buffer and write_buffer need to free when usb_alphatrack_delete()
> is called.
> 
> Signed-off-by: Daeseok Youn 
> ---
>  drivers/staging/frontier/alphatrack.c |2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/frontier/alphatrack.c 
> b/drivers/staging/frontier/alphatrack.c
> index edd5cef..4d630da 100644
> --- a/drivers/staging/frontier/alphatrack.c
> +++ b/drivers/staging/frontier/alphatrack.c
> @@ -208,6 +208,8 @@ static void usb_alphatrack_delete(struct usb_alphatrack 
> *dev)
>   kfree(dev->ring_buffer);
>   kfree(dev->interrupt_in_buffer);
>   kfree(dev->interrupt_out_buffer);
> + kfree(dev->oldi_buffer);
> + kfree(dev->write_buffer);
>   kfree(dev); /* fixme oldi_buffer */
   ^
Remove this comment now?

regards,
dan carpenter

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


Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number of pfns we can handle

2014-03-07 Thread Dan Carpenter
On Thu, Mar 06, 2014 at 11:15:08PM -0800, K. Y. Srinivasan wrote:
> Increase the maximum number of pfns we can handle is a single vmbus packet.
^^ in
> 

What are the user visible effects of this patch?

regards,
dan carpenter

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


Re: [PATCH] staging: frontier: fix memory leak in usb_alphatrack_probe()

2014-03-07 Thread DaeSeok Youn
OK. I will remove that comment and send again.

Thanks.
Daeseok Youn.

2014-03-07 17:14 GMT+09:00 Dan Carpenter :
> On Fri, Mar 07, 2014 at 05:02:25PM +0900, Daeseok Youn wrote:
>>
>> oldi_buffer and write_buffer need to free when usb_alphatrack_delete()
>> is called.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/frontier/alphatrack.c |2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/staging/frontier/alphatrack.c 
>> b/drivers/staging/frontier/alphatrack.c
>> index edd5cef..4d630da 100644
>> --- a/drivers/staging/frontier/alphatrack.c
>> +++ b/drivers/staging/frontier/alphatrack.c
>> @@ -208,6 +208,8 @@ static void usb_alphatrack_delete(struct usb_alphatrack 
>> *dev)
>>   kfree(dev->ring_buffer);
>>   kfree(dev->interrupt_in_buffer);
>>   kfree(dev->interrupt_out_buffer);
>> + kfree(dev->oldi_buffer);
>> + kfree(dev->write_buffer);
>>   kfree(dev); /* fixme oldi_buffer */
>^
> Remove this comment now?
>
> regards,
> dan carpenter
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: frontier: fix memory leak in usb_alphatrack_probe()

2014-03-07 Thread Daeseok Youn

oldi_buffer and write_buffer need to free when usb_alphatrack_delete()
is called.

Signed-off-by: Daeseok Youn 
---
v2: remove the unneeded comment.

 drivers/staging/frontier/alphatrack.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/frontier/alphatrack.c 
b/drivers/staging/frontier/alphatrack.c
index edd5cef..e59ee51 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -208,7 +208,9 @@ static void usb_alphatrack_delete(struct usb_alphatrack 
*dev)
kfree(dev->ring_buffer);
kfree(dev->interrupt_in_buffer);
kfree(dev->interrupt_out_buffer);
-   kfree(dev); /* fixme oldi_buffer */
+   kfree(dev->oldi_buffer);
+   kfree(dev->write_buffer);
+   kfree(dev);
 }
 
 /** usb_alphatrack_interrupt_in_callback */
-- 
1.7.4.4


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


Re: [PATCH 5/5] Staging: comedi: addi-data: tidy up counter register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
>On Thursday, March 6, 2014 11:59 AM, Hartley Sweeten 
> wrote:

>>On Thursday, March 06, 2014 12:26 AM, Chase Southwood wrote:
>>
>>This patch for hwdrv_apci1564.c fixes the register map defines for the
>>digital input registers such that they are all the real offsets to each
>>register, rather than a mix of real offsets and adders to those offsets.
>>
>>Signed-off-by: Chase Southwood 
>>---
>> .../comedi/drivers/addi-data/hwdrv_apci1564.c      | 101 
>> +
>> 1 file changed, 44 insertions(+), 57 deletions(-)>
>
>This one is incomplete and breaks the build.
>
> CC [M]  drivers/staging/comedi/drivers/addi_apci_1564.o
>In file included from drivers/staging/comedi/drivers/addi_apci_1564.c:11:0:
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c: In function 
>>'i_APCI1564_ConfigTimerCounterWatchdog':
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:352:4: error: 
>'APCI1564_TCW_PROG' >undeclared (first use in this function)
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:352:4: note: each 
>undeclared identifier is >reported only once for each function it appears in
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:359:4: error: 
>'APCI1564_TCW_RELOAD_VALUE' >undeclared (first use in this function)
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c: In function 
>>'i_APCI1564_StartStopWriteTimerCounterWatchdog':
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:463:19: error: 
>'APCI1564_TCW_PROG' >undeclared (first use in this function)
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c: In function 
>>'i_APCI1564_ReadTimerCounterWatchdog':
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:526:4: error: 
>>'APCI1564_TCW_SYNC_ENABLEDISABLE' undeclared (first use in this function)
>drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c:529:19: error: 
>'APCI1564_TCW_TRIG_STATUS' >undeclared (first use in this function)
>make[4]: *** [drivers/staging/comedi/drivers/addi_apci_1564.o] Error 1
>make[3]: *** [drivers/staging/comedi/drivers] Error 2
>make[2]: *** [drivers/staging/comedi] Error 2
>make[1]: *** [drivers/staging] Error 2
>make: *** [drivers] Error 2
>
>Be sure to do a build after each patch to make sure it works.

Hartley,
I'm sorry for this, it appears that this whole patch series was sloppy
and quite untested by myself.  I have made up a fixed patchset and have
tested everything this time around, I trust that you should have a better
time reviewing this one.  I will not let this happen again in the future.

Thanks,
Chase

>
>Regards,
>Hartley

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


[PATCH v2 1/5] Staging: comedi: addi-data: tidy up digital input register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
This patch fixes the register map defines for the digital input registers
such that they are all the real offsets to each register, rather than a
mix of real offsets and adders to those offsets.

Further, some of the old defines were being used incorrectly in the
i_APCI1564_Reset() function.  Upon swapping the old defines out for the
new ones in this function, their use has been corrected.

Signed-off-by: Chase Southwood 
---

2: Simplified commit message, fixed indentation.

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 78 +-
 1 file changed, 31 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 2b47fa1..2c2bbd8 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -47,11 +47,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_ADDRESS_RANGE 128
 
 /* DIGITAL INPUT-OUTPUT DEFINE */
-/* Input defines */
-#define APCI1564_DIGITAL_IP0x04
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE14
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE28
-#define APCI1564_DIGITAL_IP_IRQ16
 
 /* Output defines */
 #define APCI1564_DIGITAL_OP0x18
@@ -63,9 +58,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define ADDIDATA_OR0
 #define ADDIDATA_AND   1
 
-/* Digital Input Interrupt Status */
-#define APCI1564_DIGITAL_IP_INTERRUPT_STATUS   12
-
 /* Digital Output Interrupt Status */
 #define APCI1564_DIGITAL_OP_INTERRUPT_STATUS   8
 
@@ -99,6 +91,15 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_TCW_WARN_TIMEVAL  24
 #define APCI1564_TCW_WARN_TIMEBASE 28
 
+/*
+ * devpriv->i_IobaseAmcc Register Map
+ */
+#define APCI1564_DI_REG0x04
+#define APCI1564_DI_INT_MODE1_REG  0x08
+#define APCI1564_DI_INT_MODE2_REG  0x0c
+#define APCI1564_DI_INT_STATUS_REG 0x10
+#define APCI1564_DI_IRQ_REG0x14
+
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
 static unsigned int ui_InterruptData, ui_Type;
@@ -143,31 +144,17 @@ static int i_APCI1564_ConfigDigitalInput(struct 
comedi_device *dev,
if (data[0] == ADDIDATA_ENABLE) {
data[2] = data[2] << 4;
data[3] = data[3] << 4;
-   outl(data[2],
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-   outl(data[3],
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
+   outl(data[2], devpriv->i_IobaseAmcc + 
APCI1564_DI_INT_MODE1_REG);
+   outl(data[3], devpriv->i_IobaseAmcc + 
APCI1564_DI_INT_MODE2_REG);
if (data[1] == ADDIDATA_OR) {
-   outl(0x4,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_IRQ);
+   outl(0x4, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
} else {
-   outl(0x6,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_IRQ);
+   outl(0x6, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
}
} else {
-   outl(0x0,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-   outl(0x0,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
-   outl(0x0,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-   APCI1564_DIGITAL_IP_IRQ);
+   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
+   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
+   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
}
 
return insn->n;
@@ -180,7 +167,7 @@ static int apci1564_di_insn_bits(struct comedi_device *dev,
 {
struct addi_private *devpriv = dev->private;
 
-   data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
+   data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DI_REG);
 
return insn->n;
 }
@@ -329,9 +316,7 @@ static int i_APCI1564_ConfigTimerCounte

[PATCH v2 3/5] Staging: comedi: addi-data: tidy up watchdog register

2014-03-07 Thread Chase Southwood
This patch for fixes the register map defines for the watchdog registers
such that they are all the real offsets to each register, rather than a
mix of real offsets and adders to those offsets.

Signed-off-by: Chase Southwood 
---

2: Simplified commit message, fixed indentation and whitespace damage.
I have test applied this patch, it should work now.

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 48 --
 1 file changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index d493d01..8ff8693 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -65,7 +65,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define ADDIDATA_TIMER 0
 #define ADDIDATA_COUNTER   1
 #define ADDIDATA_WATCHDOG  2
-#define APCI1564_DIGITAL_OP_WATCHDOG   0x28
 #define APCI1564_TIMER 0x48
 #define APCI1564_COUNTER1  0x0
 #define APCI1564_COUNTER2  0x20
@@ -92,6 +91,14 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_DO_INT_CTRL_REG   0x1c
 #define APCI1564_DO_INT_STATUS_REG 0x20
 #define APCI1564_DO_IRQ_REG0x24
+#define APCI1564_WDOG_REG  0x28
+#define APCI1564_WDOG_RELOAD_REG   0x2c
+#define APCI1564_WDOG_TIMEBASE_REG 0x30
+#define APCI1564_WDOG_CTRL_REG 0x34
+#define APCI1564_WDOG_STATUS_REG   0x38
+#define APCI1564_WDOG_IRQ_REG  0x3c
+#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x40
+#define APCI1564_WDOG_WARN_TIMEBASE_REG0x44
 
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
@@ -285,13 +292,9 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;
 
/* Disable the watchdog */
-   outl(0x0,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG +
-   APCI1564_TCW_PROG);
+   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_WDOG_CTRL_REG);
/* Loading the Reload value */
-   outl(data[3],
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG +
-   APCI1564_TCW_RELOAD_VALUE);
+   outl(data[3], devpriv->i_IobaseAmcc + APCI1564_WDOG_RELOAD_REG);
} else if (data[0] == ADDIDATA_TIMER) {
/* First Stop The Timer */
ul_Command1 =
@@ -305,10 +308,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + 
APCI1564_TCW_PROG); /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG);
-   outl(0x0,
-   devpriv->i_IobaseAmcc +
-   APCI1564_DIGITAL_OP_WATCHDOG +
-   APCI1564_TCW_IRQ);
+   outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_WDOG_IRQ_REG);
outl(0x0,
devpriv->iobase + APCI1564_COUNTER1 +
APCI1564_TCW_IRQ);
@@ -427,19 +427,14 @@ static int 
i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d
if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
switch (data[1]) {
case 0: /* stop the watchdog */
-   outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG);/* disable the watchdog */
+   /* disable the watchdog */
+   outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_WDOG_CTRL_REG);
break;
case 1: /* start the watchdog */
-   outl(0x0001,
-   devpriv->i_IobaseAmcc +
-   APCI1564_DIGITAL_OP_WATCHDOG +
-   APCI1564_TCW_PROG);
+   outl(0x0001, devpriv->i_IobaseAmcc + 
APCI1564_WDOG_CTRL_REG);
break;
case 2: /* Software trigger */
-   outl(0x0201,
-   devpriv->i_IobaseAmcc +
- 

[PATCH v2 5/5] Staging: comedi: addi-data: tidy up counter register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
This patch fixes the register map defines for the counter registers such
that they are all the real offsets to each register, rather than a mix of
real offsets and adders to those offsets.

Signed-off-by: Chase Southwood 
---

2: Simplified commit message, fixed indentation and whitespace damage.
I have test applied this patch, it should work now.
v2 also fixes several build breakages, and I have compile tested as well.
Everything should be fixed.

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 143 +
 1 file changed, 60 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 2a3523f..e2d3433 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -61,22 +61,13 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE   0xfffd
 
 /* TIMER COUNTER WATCHDOG DEFINES */
-
 #define ADDIDATA_TIMER 0
 #define ADDIDATA_COUNTER   1
 #define ADDIDATA_WATCHDOG  2
-#define APCI1564_COUNTER1  0x0
-#define APCI1564_COUNTER2  0x20
-#define APCI1564_COUNTER3  0x40
-#define APCI1564_COUNTER4  0x60
-#define APCI1564_TCW_SYNC_ENABLEDISABLE0
-#define APCI1564_TCW_RELOAD_VALUE  4
-#define APCI1564_TCW_TIMEBASE  8
-#define APCI1564_TCW_PROG  12
-#define APCI1564_TCW_TRIG_STATUS   16
-#define APCI1564_TCW_IRQ   20
-#define APCI1564_TCW_WARN_TIMEVAL  24
-#define APCI1564_TCW_WARN_TIMEBASE 28
+#define APCI1564_COUNTER1  0
+#define APCI1564_COUNTER2  1
+#define APCI1564_COUNTER3  2
+#define APCI1564_COUNTER4  3
 
 /*
  * devpriv->i_IobaseAmcc Register Map
@@ -107,6 +98,18 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_TIMER_WARN_TIMEVAL_REG0x60
 #define APCI1564_TIMER_WARN_TIMEBASE_REG   0x64
 
+/*
+ * devpriv->iobase Register Map
+ */
+#define APCI1564_TCW_REG(x)(0x00 + ((x) * 
0x20))
+#define APCI1564_TCW_RELOAD_REG(x) (0x04 + ((x) * 
0x20))
+#define APCI1564_TCW_TIMEBASE_REG(x)   (0x08 + ((x) * 0x20))
+#define APCI1564_TCW_CTRL_REG(x)   (0x0c + ((x) * 
0x20))
+#define APCI1564_TCW_STATUS_REG(x) (0x10 + ((x) * 
0x20))
+#define APCI1564_TCW_IRQ_REG(x)(0x14 + ((x) * 
0x20))
+#define APCI1564_TCW_WARN_TIMEVAL_REG(x)   (0x18 + ((x) * 0x20))
+#define APCI1564_TCW_WARN_TIMEBASE_REG(x)  (0x1c + ((x) * 0x20))
+
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
 static unsigned int ui_InterruptData, ui_Type;
@@ -317,17 +320,13 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG);
outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_WDOG_IRQ_REG);
outl(0x0,
-   devpriv->iobase + APCI1564_COUNTER1 +
-   APCI1564_TCW_IRQ);
+   devpriv->iobase + 
APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1));
outl(0x0,
-   devpriv->iobase + APCI1564_COUNTER2 +
-   APCI1564_TCW_IRQ);
+   devpriv->iobase + 
APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2));
outl(0x0,
-   devpriv->iobase + APCI1564_COUNTER3 +
-   APCI1564_TCW_IRQ);
+   devpriv->iobase + 
APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3));
outl(0x0,
-   devpriv->iobase + APCI1564_COUNTER4 +
-   APCI1564_TCW_IRQ);
+   devpriv->iobase + 
APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4));
} else {
/* disable Timer interrupt */
outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_TIMER_CTRL_REG);
@@ -348,16 +347,13 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
devpriv->b_ModeSelectRegister = data[5];
 
/* First Stop The Counter */
-   ul_Command1 =
-   inl(devpriv-

[PATCH v2 4/5] Staging: comedi: addi-data: tidy up timer register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
This patch for fixes the register map defines for the timer registers such
that they are all the real offsets to each register, rather than a mix of
real offsets and adders to those offsets.

Signed-off-by: Chase Southwood 
---

2: Simplified commit message, fixed indentation and whitespace damage.
I have test applied this patch, it should work now.

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 82 +-
 1 file changed, 33 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 8ff8693..2a3523f 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -65,7 +65,6 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define ADDIDATA_TIMER 0
 #define ADDIDATA_COUNTER   1
 #define ADDIDATA_WATCHDOG  2
-#define APCI1564_TIMER 0x48
 #define APCI1564_COUNTER1  0x0
 #define APCI1564_COUNTER2  0x20
 #define APCI1564_COUNTER3  0x40
@@ -99,6 +98,14 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_WDOG_IRQ_REG  0x3c
 #define APCI1564_WDOG_WARN_TIMEVAL_REG 0x40
 #define APCI1564_WDOG_WARN_TIMEBASE_REG0x44
+#define APCI1564_TIMER_REG 0x48
+#define APCI1564_TIMER_RELOAD_REG  0x4c
+#define APCI1564_TIMER_TIMEBASE_REG0x50
+#define APCI1564_TIMER_CTRL_REG0x54
+#define APCI1564_TIMER_STATUS_REG  0x58
+#define APCI1564_TIMER_IRQ_REG 0x5c
+#define APCI1564_TIMER_WARN_TIMEVAL_REG0x60
+#define APCI1564_TIMER_WARN_TIMEBASE_REG   0x64
 
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
@@ -297,15 +304,15 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
outl(data[3], devpriv->i_IobaseAmcc + APCI1564_WDOG_RELOAD_REG);
} else if (data[0] == ADDIDATA_TIMER) {
/* First Stop The Timer */
-   ul_Command1 =
-   inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
-   APCI1564_TCW_PROG);
+   ul_Command1 = inl(devpriv->i_IobaseAmcc + 
APCI1564_TIMER_CTRL_REG);
ul_Command1 = ul_Command1 & 0xF9FEUL;
-   outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + 
APCI1564_TCW_PROG);  /* Stop The Timer */
+   /* Stop The Timer */
+   outl(ul_Command1, devpriv->i_IobaseAmcc + 
APCI1564_TIMER_CTRL_REG);
 
devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
if (data[1] == 1) {
-   outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + 
APCI1564_TCW_PROG); /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
+   /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES 
*/
+   outl(0x02, devpriv->i_IobaseAmcc + 
APCI1564_TIMER_CTRL_REG);
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG);
outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_WDOG_IRQ_REG);
@@ -322,25 +329,20 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
devpriv->iobase + APCI1564_COUNTER4 +
APCI1564_TCW_IRQ);
} else {
-   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + 
APCI1564_TCW_PROG);  /* disable Timer interrupt */
+   /* disable Timer interrupt */
+   outl(0x0, devpriv->i_IobaseAmcc + 
APCI1564_TIMER_CTRL_REG);
}
 
/*  Loading Timebase */
-   outl(data[2],
-   devpriv->i_IobaseAmcc + APCI1564_TIMER +
-   APCI1564_TCW_TIMEBASE);
+   outl(data[2], devpriv->i_IobaseAmcc + 
APCI1564_TIMER_TIMEBASE_REG);
 
/* Loading the Reload value */
-   outl(data[3],
-   devpriv->i_IobaseAmcc + APCI1564_TIMER +
-   APCI1564_TCW_RELOAD_VALUE);
+   outl(data[3], devpriv->i_IobaseAmcc + 
APCI1564_TIMER_RELOAD_REG);
 
-   ul_Command1 =
-   inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
-   APCI1564_TCW_PROG);
-   ul_Command1 =
-   (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
- 

[PATCH v2 2/5] Staging: comedi: addi-data: tidy up digital output register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
This patch fixes the register map defines for the digital output registers
such that they are all the real offsets to each register, rather than a
mix of real offsets and adders to those offsets.

Further, some of the old defines were being used incorrectly in the
i_APCI1564_Reset() function.  Upon swapping the old defines out for the
new ones in this function, their use has been corrected.

Signed-off-by: Chase Southwood 
---

2: Simplified commit message, fixed indentation and whitespace damage.
I have test applied this patch, it should work now.

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 50 +++---
 1 file changed, 16 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 2c2bbd8..d493d01 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -46,21 +46,10 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 
 #define APCI1564_ADDRESS_RANGE 128
 
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-/* Output defines */
-#define APCI1564_DIGITAL_OP0x18
-#define APCI1564_DIGITAL_OP_RW 0
-#define APCI1564_DIGITAL_OP_INTERRUPT  4
-#define APCI1564_DIGITAL_OP_IRQ12
-
 /* Digital Input IRQ Function Selection */
 #define ADDIDATA_OR0
 #define ADDIDATA_AND   1
 
-/* Digital Output Interrupt Status */
-#define APCI1564_DIGITAL_OP_INTERRUPT_STATUS   8
-
 /* Digital Input Interrupt Enable Disable. */
 #define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE   0x4
 #define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE  0xfffb
@@ -99,6 +88,10 @@ This program is distributed in the hope that it will be 
useful, but WITHOUT ANY
 #define APCI1564_DI_INT_MODE2_REG  0x0c
 #define APCI1564_DI_INT_STATUS_REG 0x10
 #define APCI1564_DI_IRQ_REG0x14
+#define APCI1564_DO_REG0x18
+#define APCI1564_DO_INT_CTRL_REG   0x1c
+#define APCI1564_DO_INT_STATUS_REG 0x20
+#define APCI1564_DO_IRQ_REG0x24
 
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
@@ -226,12 +219,8 @@ static int i_APCI1564_ConfigDigitalOutput(struct 
comedi_device *dev,
else
ul_Command = ul_Command & 0xFFFD;
 
-   outl(ul_Command,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_INTERRUPT);
-   ui_InterruptData =
-   inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_INTERRUPT);
+   outl(ul_Command, devpriv->i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG);
+   ui_InterruptData = inl(devpriv->i_IobaseAmcc + 
APCI1564_DO_INT_CTRL_REG);
devpriv->tsk_Current = current;
return insn->n;
 }
@@ -243,12 +232,10 @@ static int apci1564_do_insn_bits(struct comedi_device 
*dev,
 {
struct addi_private *devpriv = dev->private;
 
-   s->state = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_RW);
+   s->state = inl(devpriv->i_IobaseAmcc + APCI1564_DO_REG);
 
if (comedi_dio_update_state(s, data))
-   outl(s->state, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_RW);
+   outl(s->state, devpriv->i_IobaseAmcc + APCI1564_DO_REG);
 
data[1] = s->state;
 
@@ -317,9 +304,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct 
comedi_device *dev,
if (data[1] == 1) {
outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + 
APCI1564_TCW_PROG); /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
-   outl(0x0,
-   devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_IRQ);
+   outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG);
outl(0x0,
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP_WATCHDOG +
@@ -634,8 +619,7 @@ static void v_APCI1564_Interrupt(int irq, void *d)
unsigned int ul_Command2 = 0;
 
ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG) & 0x01;
-   ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
-   APCI1564_DIGITAL_OP_IRQ) & 0x01;
+   ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG) & 0x01;
ui_Timer =
inl(devpr

re: staging: visorchannel module

2014-03-07 Thread Dan Carpenter
Hello Ken Cox,

The patch e423812a9e43: "staging: visorchannel module" from Mar 4,
2014, leads to the following Smatch warning:

drivers/staging/unisys/include/guidutils.h:60 GUID_format2()
error: format string overflow. buf_size: 50 length: 63

drivers/staging/unisys/include/guidutils.h
57  static inline char *
58  GUID_format2(const GUID *guid, char *s)
59  {
60  sprintf(s, 
"{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x}",
61  (ulong) guid->data1,
62  guid->data2,
63  guid->data3,
64  guid->data4[0],
65  guid->data4[1],
66  guid->data4[2],
67  guid->data4[3],
68  guid->data4[4], guid->data4[5], guid->data4[6], 
guid->data4[7]);
69  return s;
70  }

The 50 character buf size comes from the CHANNEL_GUID_MISMATCH() macros.
I'm not sure how it's calculating that it takes 63 characters.  printf
formats make my head hurt.  My test said the max was 95 characters?

You would need to have Smatch's cross function db set up to see this
error message.  But there might be useful stuff without the cross
function db.  Give it a whirl.

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


RE: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number of pfns we can handle

2014-03-07 Thread KY Srinivasan


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, March 7, 2014 1:46 PM
> To: KY Srinivasan
> Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com
> Subject: Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number
> of pfns we can handle
> 
> On Thu, Mar 06, 2014 at 11:15:08PM -0800, K. Y. Srinivasan wrote:
> > Increase the maximum number of pfns we can handle is a single vmbus
> packet.
> ^^ in

Thanks Dan. I am traveling in India and it shows. I have already sent a 
corrected patch.

> >
> 
> What are the user visible effects of this patch?
The current code will drop these packets that have more PFNs than the limit.
Upping the limit will mitigate this problem.

Regards,

K. Y

> 
> regards,
> dan carpenter

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


Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number of pfns we can handle

2014-03-07 Thread Dan Carpenter
On Fri, Mar 07, 2014 at 09:07:42AM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > Sent: Friday, March 7, 2014 1:46 PM
> > To: KY Srinivasan
> > Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > jasow...@redhat.com
> > Subject: Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number
> > of pfns we can handle
> > 
> > On Thu, Mar 06, 2014 at 11:15:08PM -0800, K. Y. Srinivasan wrote:
> > > Increase the maximum number of pfns we can handle is a single vmbus
> > packet.
> > ^^ in
> 
> Thanks Dan. I am traveling in India and it shows. I have already sent a 
> corrected patch.
> 

Yeah.  I saw that.  Thanks.

> > >
> > 
> > What are the user visible effects of this patch?
> The current code will drop these packets that have more PFNs than the limit.
> Upping the limit will mitigate this problem.
> 

Meanwhile, the revised patch says that it is not a bugfix.  It sort of
sounds like upping the limit does improve performance for some people?

I am confused now.

regards,
dan carpenter

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


Re: [PATCH] checkpatch: net and drivers/net: Warn on missing blank line after variable declaration

2014-03-07 Thread Joe Perches
On Fri, 2014-03-07 at 10:54 +0300, Dan Carpenter wrote:
> How many warnings does this generate does this generate when you run it
> across the whole tree?

A lot.

Check back with me after the week or so
it'll take to run on this little netboook.

Try this with both patches applied if you want
to know yourself...

$ git ls-files | grep "\.[ch]$"| \
  xargs ./scripts/checkpatch.pl -f --strict --types=spacing --emacs --terse | \
  grep "Missing a blank"



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


[patch] staging: unisys/uislib: kthread_create() returns an ERR_PTR

2014-03-07 Thread Dan Carpenter
kthread_create() returns an ERR_PTR on error, it never returns NULL.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index ecf4bfcb34a6..782b06aad56d 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -45,7 +45,7 @@ uisthread_start(struct uisthread_info *thrinfo,
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
-   if (thrinfo->task == NULL) {
+   if (IS_ERR(thrinfo->task)) {
thrinfo->id = 0;
return 0;   /* failure */
}
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Ken Cox
A character array was declared on the stack with variable length.  This has
been corrected to use a fixed length.

Reported-by: Dan Carpenter 
Signed-off-by: Ken Cox 
---
 drivers/staging/unisys/virthba/virthba.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index c292293..3820c57 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1439,12 +1439,17 @@ static ssize_t
 enable_ints_write(struct file *file, const char __user *buffer,
  size_t count, loff_t *ppos)
 {
-   char buf[count + 1];
+   char buf[4];
int i, new_value;
struct virthba_info *virthbainfo;
U64 *Features_addr;
U64 mask;
 
+   if (count > 2) {
+   LOGERR("invalid  count<<%lu>>\n", count);
+   return -EINVAL;
+   }
+
buf[count] = '\0';
if (copy_from_user(buf, buffer, count)) {
LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
-- 
1.8.5.3

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


Re: [PATCH] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Dan Carpenter
On Fri, Mar 07, 2014 at 07:10:57AM -0600, Ken Cox wrote:
> A character array was declared on the stack with variable length.  This has
> been corrected to use a fixed length.
> 
> Reported-by: Dan Carpenter 
> Signed-off-by: Ken Cox 
> ---
>  drivers/staging/unisys/virthba/virthba.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/unisys/virthba/virthba.c 
> b/drivers/staging/unisys/virthba/virthba.c
> index c292293..3820c57 100644
> --- a/drivers/staging/unisys/virthba/virthba.c
> +++ b/drivers/staging/unisys/virthba/virthba.c
> @@ -1439,12 +1439,17 @@ static ssize_t
>  enable_ints_write(struct file *file, const char __user *buffer,
> size_t count, loff_t *ppos)
>  {
> - char buf[count + 1];
> + char buf[4];
>   int i, new_value;
>   struct virthba_info *virthbainfo;
>   U64 *Features_addr;
>   U64 mask;
>  
> + if (count > 2) {

2 seems wrong.  It should be something related to buf.  Anyway please
write it like this:

if (count >= ARRAY_SIZE(buf)) {


> + LOGERR("invalid  count<<%lu>>\n", count);
> + return -EINVAL;
> + }
> +
>   buf[count] = '\0';
>   if (copy_from_user(buf, buffer, count)) {
>   LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",

regards,
dan carpenter

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


[Patch V2] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Ken Cox
A character array was declared on the stack with variable length.  This has
been corrected to use a fixed length.

Reported-by: Dan Carpenter 
Signed-off-by: Ken Cox 
---
 drivers/staging/unisys/virthba/virthba.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index c292293..cabd86b 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1439,12 +1439,17 @@ static ssize_t
 enable_ints_write(struct file *file, const char __user *buffer,
  size_t count, loff_t *ppos)
 {
-   char buf[count + 1];
+   char buf[4];
int i, new_value;
struct virthba_info *virthbainfo;
U64 *Features_addr;
U64 mask;
 
+   if (count >= ARRAY_SIZE(buf)) {
+   LOGERR("invalid  count<<%lu>>\n", count);
+   return -EINVAL;
+   }
+
buf[count] = '\0';
if (copy_from_user(buf, buffer, count)) {
LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
-- 
1.8.5.3

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


Re: [PATCH 1/1] staging: unisys: Fix MAINTAINERS

2014-03-07 Thread Romer, Benjamin M

On Thu, 2014-03-06 at 12:01 -0800, gre...@linuxfoundation.org wrote:
> On Thu, Mar 06, 2014 at 10:01:04AM -0600, Romer, Benjamin M wrote:
> > This patch updates the MAINTAINERS file to add the maintainer for the
> > Unisys s-Par driver set.
> > 
> > Signed-off-by: Ken Cox 
> > signed-off-by: Ben Romer 
> 
> Please capitalize things properly.
> 
> And your From: address does not match your "Signed-off-by:" line.  Why
> are you trying to use an "alias" as a maintainer or a sign-off?  We want
> a "real" address / name please, especially as it's obvious you have one :)
> 
> thanks,
> 
> greg k-h

The email address I listed is a group address - I'll change the contents of the 
file
so they more accurately describe how we've set things up.


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


Re: [PATCH v9][ 6/8] staging: imx-drm: parallel display: add regulator support.

2014-03-07 Thread Lothar Waßmann
Hi,

Denis Carikli wrote:
> Signed-off-by: Denis Carikli 
> ---
> ChangeLog v8->v9:
> - Removed the Cc. They are now set in git-send-email directly.
> - Rebased.
> 
> ChangeLog v7->v8:
> - Shrinked even more the Cc list.
> - Rebased.
> 
> ChangeLog v6->v7:
> - Shrinked even more the Cc list.
> - Rebased the patch and included video/of_display_timing.h
> ---
>  .../bindings/staging/imx-drm/fsl-imx-drm.txt   |1 +
>  drivers/staging/imx-drm/parallel-display.c |   13 +
>  2 files changed, 14 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt 
> b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
> index 2d24425..4dd7ce5 100644
> --- a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
> +++ b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
> @@ -28,6 +28,7 @@ Required properties:
>  - compatible: Should be "fsl,imx-parallel-display"
>  - crtc: the crtc this display is connected to, see below
>  Optional properties:
> +- display-supply : phandle to the regulator device tree node if needed.
>
Any reason why this is named 'display-supply' rather than 'lcd-supply'
like for imxfb?


Lothar Waßmann
-- 
___

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | i...@karo-electronics.de
___
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] staging: unisys: Fix MAINTAINERS

2014-03-07 Thread Dan Carpenter
On Fri, Mar 07, 2014 at 08:18:44AM -0600, Romer, Benjamin M wrote:
> 
> On Thu, 2014-03-06 at 12:01 -0800, gre...@linuxfoundation.org wrote:
> > On Thu, Mar 06, 2014 at 10:01:04AM -0600, Romer, Benjamin M wrote:
> > > This patch updates the MAINTAINERS file to add the maintainer for the
> > > Unisys s-Par driver set.
> > > 
> > > Signed-off-by: Ken Cox 
> > > signed-off-by: Ben Romer 
> > 
> > Please capitalize things properly.
> > 
> > And your From: address does not match your "Signed-off-by:" line.  Why
> > are you trying to use an "alias" as a maintainer or a sign-off?  We want
> > a "real" address / name please, especially as it's obvious you have one :)
> > 
> > thanks,
> > 
> > greg k-h
> 
> The email address I listed is a group address - I'll change the contents of 
> the file
> so they more accurately describe how we've set things up.

The file is fine (I think).

Signed-off-by is like signing a legal document.  You should sign on your
own behalf and not for a group of people.  And if the Signed-off-by
doesn't match your From then how do we know it's really you?

regards,
dan carpenter

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


Re: [PATCH 1/1] staging: unisys: Fix MAINTAINERS

2014-03-07 Thread Romer, Benjamin M
On Fri, 2014-03-07 at 17:41 +0300, Dan Carpenter wrote:
> On Fri, Mar 07, 2014 at 08:18:44AM -0600, Romer, Benjamin M wrote:
> > 
> > On Thu, 2014-03-06 at 12:01 -0800, gre...@linuxfoundation.org wrote:
> > > On Thu, Mar 06, 2014 at 10:01:04AM -0600, Romer, Benjamin M wrote:
> > > > This patch updates the MAINTAINERS file to add the maintainer for the
> > > > Unisys s-Par driver set.
> > > > 
> > > > Signed-off-by: Ken Cox 
> > > > signed-off-by: Ben Romer 
> > > 
> > > Please capitalize things properly.
> > > 
> > > And your From: address does not match your "Signed-off-by:" line.  Why
> > > are you trying to use an "alias" as a maintainer or a sign-off?  We want
> > > a "real" address / name please, especially as it's obvious you have one :)
> > > 
> > > thanks,
> > > 
> > > greg k-h
> > 
> > The email address I listed is a group address - I'll change the contents of 
> > the file
> > so they more accurately describe how we've set things up.
> 
> The file is fine (I think).
> 
> Signed-off-by is like signing a legal document.  You should sign on your
> own behalf and not for a group of people.  And if the Signed-off-by
> doesn't match your From then how do we know it's really you?
> 
> regards,
> dan carpenter
> 

That's what I mean though, the file isn't quite accurate.
sparmaintai...@unisys.com is a group email address for which I'm the
primary contact, but there are other developers and managers with access
to it. I'll list myself and one other person by email address for
handling patches, and put the group address as the mailing list entry. 

Also, the file should say "Supported" instead of "Maintained", so that
wasn't quite right either. :)

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


RE: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number of pfns we can handle

2014-03-07 Thread KY Srinivasan


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, March 7, 2014 2:51 PM
> To: KY Srinivasan
> Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com
> Subject: Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on the number
> of pfns we can handle
> 
> On Fri, Mar 07, 2014 at 09:07:42AM +, KY Srinivasan wrote:
> >
> >
> > > -Original Message-
> > > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > > Sent: Friday, March 7, 2014 1:46 PM
> > > To: KY Srinivasan
> > > Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> > > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > > jasow...@redhat.com
> > > Subject: Re: [PATCH 1/1] Drivers: hv: vmbus: Include the limit on
> > > the number of pfns we can handle
> > >
> > > On Thu, Mar 06, 2014 at 11:15:08PM -0800, K. Y. Srinivasan wrote:
> > > > Increase the maximum number of pfns we can handle is a single
> > > > vmbus
> > > packet.
> > > ^^ in
> >
> > Thanks Dan. I am traveling in India and it shows. I have already sent a
> corrected patch.
> >
> 
> Yeah.  I saw that.  Thanks.
> 
> > > >
> > >
> > > What are the user visible effects of this patch?
> > The current code will drop these packets that have more PFNs than the
> limit.
> > Upping the limit will mitigate this problem.
> >
> 
> Meanwhile, the revised patch says that it is not a bugfix.  It sort of sounds 
> like
> upping the limit does improve performance for some people?
> 
> I am confused now.

With the current network code this condition cannot occur since we neither 
support scatter/gather I/O
nor segmentation offload. I have submitted patches that enable these features 
for our network driver.
Once TSO is turned on, the network stack can send packets that may need more 
than the current limit of
PFNs in a packet.

Hope this helps,

K. Y
> 
> regards,
> dan carpenter

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


Re: [PATCH] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Greg KH
On Fri, Mar 07, 2014 at 07:10:57AM -0600, Ken Cox wrote:
> A character array was declared on the stack with variable length.  This has
> been corrected to use a fixed length.
> 
> Reported-by: Dan Carpenter 
> Signed-off-by: Ken Cox 
> ---
>  drivers/staging/unisys/virthba/virthba.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/unisys/virthba/virthba.c 
> b/drivers/staging/unisys/virthba/virthba.c
> index c292293..3820c57 100644
> --- a/drivers/staging/unisys/virthba/virthba.c
> +++ b/drivers/staging/unisys/virthba/virthba.c
> @@ -1439,12 +1439,17 @@ static ssize_t
>  enable_ints_write(struct file *file, const char __user *buffer,
> size_t count, loff_t *ppos)
>  {
> - char buf[count + 1];
> + char buf[4];
>   int i, new_value;
>   struct virthba_info *virthbainfo;
>   U64 *Features_addr;
>   U64 mask;
>  
> + if (count > 2) {
> + LOGERR("invalid  count<<%lu>>\n", count);

Nice, a simple way to DoS the syslog from any user :)

Don't even log this, you are going to be ripping all of those macros out
eventually, so don't add new ones...

thanks,

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


Re: [PATCH] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Ken Cox


On 03/07/2014 10:02 AM, Greg KH wrote:

On Fri, Mar 07, 2014 at 07:10:57AM -0600, Ken Cox wrote:

A character array was declared on the stack with variable length.  This has
been corrected to use a fixed length.

Reported-by: Dan Carpenter 
Signed-off-by: Ken Cox 
---
  drivers/staging/unisys/virthba/virthba.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index c292293..3820c57 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1439,12 +1439,17 @@ static ssize_t
  enable_ints_write(struct file *file, const char __user *buffer,
  size_t count, loff_t *ppos)
  {
-   char buf[count + 1];
+   char buf[4];
int i, new_value;
struct virthba_info *virthbainfo;
U64 *Features_addr;
U64 mask;
  
+	if (count > 2) {

+   LOGERR("invalid  count<<%lu>>\n", count);

Nice, a simple way to DoS the syslog from any user :)

Don't even log this, you are going to be ripping all of those macros out
eventually, so don't add new ones...

Good point.  Revised patch coming.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[Patch V3] Staging: unisys: virthba: Fix variable length array

2014-03-07 Thread Ken Cox
A character array was declared on the stack with variable length.  This has
been corrected to use a fixed length.

Reported-by: Dan Carpenter 
Signed-off-by: Ken Cox 
---
 drivers/staging/unisys/virthba/virthba.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index c292293..277851f 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1439,12 +1439,15 @@ static ssize_t
 enable_ints_write(struct file *file, const char __user *buffer,
  size_t count, loff_t *ppos)
 {
-   char buf[count + 1];
+   char buf[4];
int i, new_value;
struct virthba_info *virthbainfo;
U64 *Features_addr;
U64 mask;
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
buf[count] = '\0';
if (copy_from_user(buf, buffer, count)) {
LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
-- 
1.8.5.3

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


Re: [PATCH v9][ 4/8] imx-drm: Match ipu_di_signal_cfg's clk_pol with its description.

2014-03-07 Thread Russell King - ARM Linux
On Thu, Mar 06, 2014 at 05:04:25PM +0100, Denis Carikli wrote:
> According to the datasheet, setting the di0_polarity_disp_clk
> field in the GENERAL di register sets the output clock polarity
> to active high.
> 
> Signed-off-by: Denis Carikli 
> ---
> ChangeLog v8->v9:
> - New patch that is now needed by the
>   "staging: imx-drm: Use de-active and pixelclk-active" patch.
> ---
>  drivers/staging/imx-drm/ipu-v3/ipu-di.c |2 +-
>  drivers/staging/imx-drm/ipuv3-crtc.c|2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c 
> b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> index 82a9eba..849b3e1 100644
> --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> @@ -595,7 +595,7 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
> ipu_di_signal_cfg *sig)
>   }
>   }
>  
> - if (!sig->clk_pol)
> + if (sig->clk_pol)
>   di_gen |= DI_GEN_POLARITY_DISP_CLK;
>  
>   ipu_di_write(di, di_gen, DI_GENERAL);
> diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
> b/drivers/staging/imx-drm/ipuv3-crtc.c
> index e646017..f506075 100644
> --- a/drivers/staging/imx-drm/ipuv3-crtc.c
> +++ b/drivers/staging/imx-drm/ipuv3-crtc.c
> @@ -158,7 +158,7 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
>   sig_cfg.Vsync_pol = 1;
>  
>   sig_cfg.enable_pol = 1;
> - sig_cfg.clk_pol = 1;
> + sig_cfg.clk_pol = 0;
>   sig_cfg.width = mode->hdisplay;
>   sig_cfg.height = mode->vdisplay;
>   sig_cfg.pixel_fmt = out_pixel_fmt;

I brought this up a while back:

http://archive.arm.linux.org.uk/lurker/message/20131015.103500.0c058eb9.en.html

it looks like it was never properly addressed, so yes, I think this is
the right solution, and brings the kernel inline with the code which
was in uboot back in October, and the value of sig_cfg.clk_pol now
matches the register bit.

However, I think an even better solution would be to have the clk_pol
values to be defined: CLK_POL_ACTIVE_HIGH and CLK_POL_ACTIVE_LOW.
This makes the actual value used irrelevant, and helps readability.
Maybe something to consider for a future patch?

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v9][ 5/8] staging: imx-drm: Use de-active and pixelclk-active display-timings.

2014-03-07 Thread Russell King - ARM Linux
On Thu, Mar 06, 2014 at 05:04:26PM +0100, Denis Carikli wrote:
> diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c 
> b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> index 849b3e1..5d273c1 100644
> --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c
> @@ -595,8 +595,12 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
> ipu_di_signal_cfg *sig)
>   }
>   }
>  
> - if (sig->clk_pol)
> - di_gen |= DI_GEN_POLARITY_DISP_CLK;
> + if (sig->set_mask & SET_CLK_POL) {
> + if (sig->clk_pol)
> + di_gen |= DI_GEN_POLARITY_DISP_CLK;
> + else
> + di_gen &= ~DI_GEN_POLARITY_DISP_CLK;
> + }
>  
>   ipu_di_write(di, di_gen, DI_GENERAL);
>  
> @@ -606,8 +610,13 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct 
> ipu_di_signal_cfg *sig)
>   reg = ipu_di_read(di, DI_POL);
>   reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);
>  
> - if (sig->enable_pol)
> - reg |= DI_POL_DRDY_POLARITY_15;
> + if (sig->set_mask & SET_DE_POL) {
> + if (sig->enable_pol)
> + reg |= DI_POL_DRDY_POLARITY_15;
> + else
> + reg &= ~DI_POL_DRDY_POLARITY_15;
> + }
> +
>   if (sig->data_pol)
>   reg |= DI_POL_DRDY_DATA_POLARITY;
>  
> diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
> b/drivers/staging/imx-drm/ipuv3-crtc.c
> index f506075..71f757f 100644
> --- a/drivers/staging/imx-drm/ipuv3-crtc.c
> +++ b/drivers/staging/imx-drm/ipuv3-crtc.c
> @@ -157,8 +157,22 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
>   if (mode->flags & DRM_MODE_FLAG_PVSYNC)
>   sig_cfg.Vsync_pol = 1;
>  
> - sig_cfg.enable_pol = 1;
> - sig_cfg.clk_pol = 0;
> + if (mode->private_flags & IMXDRM_MODE_FLAG_DE_HIGH) {
> + sig_cfg.enable_pol = 1;
> + sig_cfg.set_mask |= SET_DE_POL;
> + } else if (mode->private_flags & IMXDRM_MODE_FLAG_DE_LOW) {
> + sig_cfg.enable_pol = 0;
> + sig_cfg.set_mask |= SET_DE_POL;
> + }
> +
> + if (mode->private_flags & IMXDRM_MODE_FLAG_PIXDATA_POSEDGE) {
> + sig_cfg.clk_pol = 1;
> + sig_cfg.set_mask |= SET_CLK_POL;
> + } else if (mode->private_flags & IMXDRM_MODE_FLAG_PIXDATA_NEGEDGE) {
> + sig_cfg.clk_pol = 0;
> + sig_cfg.set_mask |= SET_CLK_POL;
> + }

So how does this work for other displays, for example, HDMI, where we need
enable_pol=1 and clk_pol=0 ?

>From what I can see, we end up with sig_cfg.enable_pol=0, sig_cfg.clk_pol=0,
sig_cfg.set_mask=0.

What we end up with for enable_pol is this:

reg = ipu_di_read(di, DI_POL);
reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);

-   if (sig->enable_pol)
-   reg |= DI_POL_DRDY_POLARITY_15;
+   if (sig->set_mask & SET_DE_POL) {
+   if (sig->enable_pol)
+   reg |= DI_POL_DRDY_POLARITY_15;
+   else
+   reg &= ~DI_POL_DRDY_POLARITY_15;
+   }

which is no different from:

reg = ipu_di_read(di, DI_POL);
reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);

if (sig->set_mask & SET_DE_POL && sig->enable_pol)
reg |= DI_POL_DRDY_POLARITY_15;

because even with SET_DE_POL unset, we still end up clearing the bit.

Similar seems to happen with the clock polarity as well - in order for
that bit to be set, buth the set_mask and the clk_pol but must be set.

Dovetailing in to my previous reply, if we want to do this, maybe we
should convert clk_pol and enable_pol to be a tristate (can be an
u8 or enum).  Essentially, it has three values: preserve, active high,
active low.

However, one of the things that really worries me here is the "preserve"
action - what if it's not correctly set initially, and we don't have
anything specifying either polarity, which will happen if the only
encoder/connector you have is imx-hdmi.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 5/5] Staging: comedi: addi-data: tidy up counter register map defines in hwdrv_apci1564.c

2014-03-07 Thread Hartley Sweeten
On Friday, March 07, 2014 1:32 AM, Chase Southwood wrote:
>>On Thursday, March 6, 2014 11:59 AM, Hartley Sweeten 
>> wrote:
>> This one is incomplete and breaks the build.
>> Be sure to do a build after each patch to make sure it works.
>
> Hartley,
> I'm sorry for this, it appears that this whole patch series was sloppy
> and quite untested by myself.  I have made up a fixed patchset and have
> tested everything this time around, I trust that you should have a better
> time reviewing this one.  I will not let this happen again in the future.

Not a problem. Just make sure to test any patches before posting them. :-)

I'm looking over your new series now.

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


Re: [PATCH 2/2] imx-drm: imx-ldb: Use OF graph to find connected panel

2014-03-07 Thread Russell King - ARM Linux
On Thu, Mar 06, 2014 at 02:54:40PM +0100, Philipp Zabel wrote:
> @@ -566,9 +566,18 @@ static int imx_ldb_bind(struct device *dev, struct 
> device *master, void *data)
>   return -EINVAL;
>   }
>  
> - panel_node = of_parse_phandle(child, "fsl,panel", 0);
> - if (panel_node)
> - channel->panel = of_drm_find_panel(panel_node);
> + /* The output port is port@4 with mux or port@1 without mux */
> + port = of_graph_get_port_by_id(child, imx_ldb->lvds_mux ? 4 : 
> 1);

I guess we're holding off on these two patches while the last bits of
the of-graph get sorted - the above function doesn't currently exist
so causes a build failure.

Thanks.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] imx-drm: imx-ldb: Add drm_panel support

2014-03-07 Thread Russell King - ARM Linux
On Thu, Mar 06, 2014 at 02:54:39PM +0100, Philipp Zabel wrote:
> This patch allows to optionally attach the lvds-channel to a panel
> supported by a drm_panel driver instead of supplying the modes via
> device tree.

Hmm, I think something may be missing in this patch... you're introducing
calls into the drm panel code, but there's nothign which ensures that
code gets built alongside imx-ldb.c.  With imx-ldb built as a module,
I get:

ERROR: "drm_panel_attach" [drivers/staging/imx-drm/imx-ldb.ko] undefined!
ERROR: "of_drm_find_panel" [drivers/staging/imx-drm/imx-ldb.ko] undefined!

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2 5/5] Staging: comedi: addi-data: tidy up counter register map defines in hwdrv_apci1564.c

2014-03-07 Thread Hartley Sweeten
On Friday, March 07, 2014 1:38 AM, Chase Southwood wrote:
> This patch fixes the register map defines for the counter registers such
> that they are all the real offsets to each register, rather than a mix of
> real offsets and adders to those offsets.
>
> Signed-off-by: Chase Southwood 
> ---
>
> 2: Simplified commit message, fixed indentation and whitespace damage.
> I have test applied this patch, it should work now.
> v2 also fixes several build breakages, and I have compile tested as well.
> Everything should be fixed.

Chase,

Looks better, the patches apply now.

The register map whitespace is still a bit of a mess. This is what it looks like
after applying all 5 patches:

/*
 * devpriv->i_IobaseAmcc Register Map
 */
#define APCI1564_DI_REG 0x04
#define APCI1564_DI_INT_MODE1_REG   0x08
#define APCI1564_DI_INT_MODE2_REG   0x0c
#define APCI1564_DI_INT_STATUS_REG  0x10
#define APCI1564_DI_IRQ_REG 0x14
#define APCI1564_DO_REG 0x18
#define APCI1564_DO_INT_CTRL_REG0x1c
#define APCI1564_DO_INT_STATUS_REG  0x20
#define APCI1564_DO_IRQ_REG 0x24
#define APCI1564_WDOG_REG   0x28
#define APCI1564_WDOG_RELOAD_REG0x2c
#define APCI1564_WDOG_TIMEBASE_REG  0x30
#define APCI1564_WDOG_CTRL_REG  0x34
#define APCI1564_WDOG_STATUS_REG0x38
#define APCI1564_WDOG_IRQ_REG   0x3c
#define APCI1564_WDOG_WARN_TIMEVAL_REG  0x40
#define APCI1564_WDOG_WARN_TIMEBASE_REG 0x44
#define APCI1564_TIMER_REG  0x48
#define APCI1564_TIMER_RELOAD_REG   0x4c
#define APCI1564_TIMER_TIMEBASE_REG 0x50
#define APCI1564_TIMER_CTRL_REG 0x54
#define APCI1564_TIMER_STATUS_REG   0x58
#define APCI1564_TIMER_IRQ_REG  0x5c
#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x60
#define APCI1564_TIMER_WARN_TIMEBASE_REG0x64

/*
 * devpriv->iobase Register Map
 */
#define APCI1564_TCW_REG(x) (0x00 + ((x) * 
0x20))
#define APCI1564_TCW_RELOAD_REG(x)  (0x04 + ((x) * 
0x20))
#define APCI1564_TCW_TIMEBASE_REG(x)(0x08 + ((x) * 0x20))
#define APCI1564_TCW_CTRL_REG(x)(0x0c + ((x) * 
0x20))
#define APCI1564_TCW_STATUS_REG(x)  (0x10 + ((x) * 
0x20))
#define APCI1564_TCW_IRQ_REG(x) (0x14 + ((x) * 0x20))
#define APCI1564_TCW_WARN_TIMEVAL_REG(x)(0x18 + ((x) * 0x20))
#define APCI1564_TCW_WARN_TIMEBASE_REG(x)   (0x1c + ((x) * 0x20))

Check your tab settings in your editor. Normal tab spacing is 8 characters.
It looks like all the defines align properly at column 49 which is one tab after
the define on this line:

#define APCI1564_TCW_WARN_TIMEBASE_REG(x)   (0x1c + ((x) * 0x20))

Other than that the patches look good.

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


Re: [PATCH 1/2] imx-drm: imx-ldb: Add drm_panel support

2014-03-07 Thread Philipp Zabel
Hi Russell,

Am Freitag, den 07.03.2014, 17:22 + schrieb Russell King - ARM
Linux:
> On Thu, Mar 06, 2014 at 02:54:39PM +0100, Philipp Zabel wrote:
> > This patch allows to optionally attach the lvds-channel to a panel
> > supported by a drm_panel driver instead of supplying the modes via
> > device tree.
> 
> Hmm, I think something may be missing in this patch... you're introducing
> calls into the drm panel code, but there's nothign which ensures that
> code gets built alongside imx-ldb.c.  With imx-ldb built as a module,
> I get:
> 
> ERROR: "drm_panel_attach" [drivers/staging/imx-drm/imx-ldb.ko] undefined!
> ERROR: "of_drm_find_panel" [drivers/staging/imx-drm/imx-ldb.ko] undefined!

Thanks for testing. Yes, this Kconfig change is missing from patch 1:

diff --git a/drivers/staging/imx-drm/Kconfig
b/drivers/staging/imx-drm/Kconfig
index 82fb758..8e5b7e9 100644
--- a/drivers/staging/imx-drm/Kconfig
+++ b/drivers/staging/imx-drm/Kconfig
@@ -35,6 +35,7 @@ config DRM_IMX_TVE
 config DRM_IMX_LDB
tristate "Support for LVDS displays"
depends on DRM_IMX && MFD_SYSCON
+   select DRM_PANEL
help
  Choose this to enable the internal LVDS Display Bridge (LDB)
  found on i.MX53 and i.MX6 processors.

I haven't noticed because I've enabled the parallel display driver,
which does correctly select DRM_PANEL.

regards
Philipp

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


Re: [PATCH v5 00/11] imx-drm dt bindings

2014-03-07 Thread Russell King - ARM Linux
On Wed, Mar 05, 2014 at 10:20:51AM +0100, Philipp Zabel wrote:
> Hi,
> 
> this latest version of the imx-drm DT binding patches applies
> on top of staging-next and also depends on the OF graph binding
> patchset that moves the v4l2_of helpers to drivers/of.
> Currently, the two patchsets are also available at:
> git://git.pengutronix.de/git/pza/linux.git topic/of-graph
> git://git.pengutronix.de/git/pza/linux.git topic/imx-drm-dt

Okay, having looked at the second tree, pulling that will result in
pulling in all of the staging tree here, which I'd rather not do.  Unless
there's any objection, I'd like to take these as patches on top of the
imx-drm stuff which I sent to Greg plus the of-graph stuff which they
depend upon.  In other words, exactly how I've been testing it today.

Any objections?

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: unisys: uislib: Fix locking in info_proc_read_helper()

2014-03-07 Thread Ken Cox
Make sure BusListLock is unlocked before returning.  If an error is encountered
early on in info_proc_read_helper() the function can return without unlocking.

Also changed the PROCLINE macro so that it doesn't include a goto statement.

Reported-by: Dan Carpenter 
Signed-off-by: Ken Cox 
---
 drivers/staging/unisys/uislib/uislib.c | 95 --
 1 file changed, 55 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c 
b/drivers/staging/unisys/uislib/uislib.c
index d77df9a..b9bf7b4 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -1622,13 +1622,8 @@ chipset_proc_write(struct file *file, const char __user 
*buffer,
return -EFAULT;
 }
 
-#define PROCLINE(...)  \
-   do {\
-   if (uisutil_add_proc_line_ex(&tot, buff,\
-buff_len, __VA_ARGS__) < 0) { \
-   goto err_done;  \
-   }   \
-   } while (0)
+#define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \
+  buff_len, __VA_ARGS__)
 
 static int
 info_proc_read_helper(char **buff, int *buff_len)
@@ -1636,55 +1631,75 @@ info_proc_read_helper(char **buff, int *buff_len)
int i, tot = 0;
struct bus_info *bus;
 
-   PROCLINE("\nBuses:\n");
+   if (PLINE("\nBuses:\n") < 0)
+   goto err_done;
 
read_lock(&BusListLock);
for (bus = BusListHead; bus; bus = bus->next) {
 
-   PROCLINE("bus=0x%p, busNo=%d, deviceCount=%d\n",
-bus, bus->busNo, bus->deviceCount);
+   if (PLINE("bus=0x%p, busNo=%d, deviceCount=%d\n",
+ bus, bus->busNo, bus->deviceCount) < 0)
+   goto err_done_unlock;
 
-   PROCLINE("Devices:\n");
+
+   if (PLINE("Devices:\n") < 0)
+   goto err_done_unlock;
 
for (i = 0; i < bus->deviceCount; i++) {
if (bus->device[i]) {
-   PROCLINE("busNo %d, device[%i]: 
0x%p, chanptr=0x%p, swtch=0x%p\n",
-bus->busNo, i, bus->device[i],
-bus->device[i]->chanptr,
-bus->device[i]->swtch);
-   PROCLINE("first_busy_cnt=%llu, 
moved_to_tail_cnt=%llu, last_on_list_cnt=%llu\n",
-bus->device[i]->first_busy_cnt,
-bus->device[i]->moved_to_tail_cnt,
-bus->device[i]->last_on_list_cnt);
+   if (PLINE("busNo %d, device[%i]: 
0x%p, chanptr=0x%p, swtch=0x%p\n",
+ bus->busNo, i, bus->device[i],
+ bus->device[i]->chanptr,
+ bus->device[i]->swtch) < 0)
+   goto err_done_unlock;
+
+   if (PLINE("first_busy_cnt=%llu, 
moved_to_tail_cnt=%llu, last_on_list_cnt=%llu\n",
+ bus->device[i]->first_busy_cnt,
+ bus->device[i]->moved_to_tail_cnt,
+ bus->device[i]->last_on_list_cnt) < 0)
+   goto err_done_unlock;
}
}
}
read_unlock(&BusListLock);
 
-   PROCLINE("Malloc bytes in use: %d\n", atomic_read(&Malloc_BytesInUse));
-   PROCLINE("Malloc buffers in use: %d\n",
-atomic_read(&Malloc_BuffersInUse));
-   PROCLINE("Malloc allocation failures: %d\n",
-atomic_read(&Malloc_FailuresAlloc));
-   PROCLINE("Malloc free failures: %d\n",
-atomic_read(&Malloc_FailuresFree));
-   PROCLINE("Malloc total mallocs: %u (may overflow)\n",
-(unsigned) atomic_read(&Malloc_TotalMallocs));
-   PROCLINE("Malloc total frees: %u (may overflow)\n",
-(unsigned) atomic_read(&Malloc_TotalFrees));
-   PROCLINE("UisUtils_Registered_Services: %d\n",
-atomic_read(&UisUtils_Registered_Services));
-
-   PROCLINE("cycles_before_wait %llu wait_cycles:%llu\n",
-cycles_before_wait, wait_cycles);
-   PROCLINE("tot_wakeup_cnt %llu:tot_wait_cnt %llu:tot_schedule_cnt 
%llu\n",
-tot_wakeup_cnt, tot_wait_cnt, tot_schedule_cnt);
-   PROCLINE("en_smart_wakeup %d\n", en_smart_wakeup);
-   PROCLINE("tot_moved_to_tail_cnt %llu\n", tot_moved_to_tail_cnt);
+ 

Re: [PATCH v5 00/11] imx-drm dt bindings

2014-03-07 Thread Greg Kroah-Hartman
On Fri, Mar 07, 2014 at 05:56:12PM +, Russell King - ARM Linux wrote:
> On Wed, Mar 05, 2014 at 10:20:51AM +0100, Philipp Zabel wrote:
> > Hi,
> > 
> > this latest version of the imx-drm DT binding patches applies
> > on top of staging-next and also depends on the OF graph binding
> > patchset that moves the v4l2_of helpers to drivers/of.
> > Currently, the two patchsets are also available at:
> > git://git.pengutronix.de/git/pza/linux.git topic/of-graph
> > git://git.pengutronix.de/git/pza/linux.git topic/imx-drm-dt
> 
> Okay, having looked at the second tree, pulling that will result in
> pulling in all of the staging tree here, which I'd rather not do.  Unless
> there's any objection, I'd like to take these as patches on top of the
> imx-drm stuff which I sent to Greg plus the of-graph stuff which they
> depend upon.  In other words, exactly how I've been testing it today.
> 
> Any objections?

None from me!  :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 00/11] imx-drm dt bindings

2014-03-07 Thread Philipp Zabel
[Added Shawn to Cc:]

On Fri, Mar 7, 2014 at 7:28 PM, Greg Kroah-Hartman
 wrote:
> On Fri, Mar 07, 2014 at 05:56:12PM +, Russell King - ARM Linux wrote:
>> On Wed, Mar 05, 2014 at 10:20:51AM +0100, Philipp Zabel wrote:
>> > Hi,
>> >
>> > this latest version of the imx-drm DT binding patches applies
>> > on top of staging-next and also depends on the OF graph binding
>> > patchset that moves the v4l2_of helpers to drivers/of.
>> > Currently, the two patchsets are also available at:
>> > git://git.pengutronix.de/git/pza/linux.git topic/of-graph
>> > git://git.pengutronix.de/git/pza/linux.git topic/imx-drm-dt
>>
>> Okay, having looked at the second tree, pulling that will result in
>> pulling in all of the staging tree here, which I'd rather not do.  Unless
>> there's any objection, I'd like to take these as patches on top of the
>> imx-drm stuff which I sent to Greg plus the of-graph stuff which they
>> depend upon.  In other words, exactly how I've been testing it today.
>>
>> Any objections?
>
> None from me!  :)

Nor from me. But I'd like to point out that there already is one merge issue
with Shawn's for-next branch in arch/arm/boot/dts/imx53-qsb.dts between
d5eb195 "ARM: dts: i.MX53: move common QSB nodes to new file"
and these two patches:
17b5001 "imx-drm: convert to componentised device support".
"ARM: dts: imx53: Add IPU DI ports and endpoints, move imx-drm node to dtsi"
The first one already is in staging-next.

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


[PATCH 1/1] staging: unisys: update MAINTAINERS and TODO

2014-03-07 Thread Romer, Benjamin M
This patch adds the Unisys s-Par driver maintainers to the MAINTAINERS
file, changes the state to "Supported", modifies TODO to address patches
to the Unisys mailing list, and adds Greg Kroah-Hartman to the patch
recipients list.
 
Signed-off-by: Benjamin Romer 
---
diff --git a/MAINTAINERS b/MAINTAINERS
index c3ff623..405c4c9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9031,6 +9031,13 @@ F:   drivers/cdrom/cdrom.c
 F: include/linux/cdrom.h
 F: include/uapi/linux/cdrom.h
 
+UNISYS S-PAR DRIVERS
+M: Benjamin Romer 
+M: David Kershner 
+L: sparmaintai...@unisys.com (Unisys internal)
+S: Supported
+F: drivers/staging/unisys/
+
 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
 M: Vinayak Holikatti 
 M: Santosh Y 
diff --git a/drivers/staging/unisys/TODO b/drivers/staging/unisys/TODO
index c4265a2..034ac61 100644
--- a/drivers/staging/unisys/TODO
+++ b/drivers/staging/unisys/TODO
@@ -16,5 +16,6 @@ TODO:

 
 Patches to:
+   Greg Kroah-Hartman 
Ken Cox 
-   Ben Romer 
+   Unisys s-Par maintainer mailing list 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: visorchannel module

2014-03-07 Thread Greg KH
On Fri, Mar 07, 2014 at 11:38:03AM +0300, Dan Carpenter wrote:
> Hello Ken Cox,
> 
> The patch e423812a9e43: "staging: visorchannel module" from Mar 4,
> 2014, leads to the following Smatch warning:
> 
>   drivers/staging/unisys/include/guidutils.h:60 GUID_format2()
>   error: format string overflow. buf_size: 50 length: 63
> 
> drivers/staging/unisys/include/guidutils.h
> 57  static inline char *
> 58  GUID_format2(const GUID *guid, char *s)
> 59  {
> 60  sprintf(s, 
> "{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x}",
> 61  (ulong) guid->data1,
> 62  guid->data2,
> 63  guid->data3,
> 64  guid->data4[0],
> 65  guid->data4[1],
> 66  guid->data4[2],
> 67  guid->data4[3],
> 68  guid->data4[4], guid->data4[5], guid->data4[6], 
> guid->data4[7]);
> 69  return s;
> 70  }
> 
> The 50 character buf size comes from the CHANNEL_GUID_MISMATCH() macros.
> I'm not sure how it's calculating that it takes 63 characters.  printf
> formats make my head hurt.  My test said the max was 95 characters?

There should be a built-in guid printk() macro (or function to do it)
already in the kernel, so this code should be able to just be deleted
entirely.

thanks,

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


Re: [PATCH v5 00/11] imx-drm dt bindings

2014-03-07 Thread Russell King - ARM Linux
On Fri, Mar 07, 2014 at 07:57:51PM +0100, Philipp Zabel wrote:
> [Added Shawn to Cc:]
> 
> On Fri, Mar 7, 2014 at 7:28 PM, Greg Kroah-Hartman
>  wrote:
> > On Fri, Mar 07, 2014 at 05:56:12PM +, Russell King - ARM Linux wrote:
> >> On Wed, Mar 05, 2014 at 10:20:51AM +0100, Philipp Zabel wrote:
> >> > Hi,
> >> >
> >> > this latest version of the imx-drm DT binding patches applies
> >> > on top of staging-next and also depends on the OF graph binding
> >> > patchset that moves the v4l2_of helpers to drivers/of.
> >> > Currently, the two patchsets are also available at:
> >> > git://git.pengutronix.de/git/pza/linux.git topic/of-graph
> >> > git://git.pengutronix.de/git/pza/linux.git topic/imx-drm-dt
> >>
> >> Okay, having looked at the second tree, pulling that will result in
> >> pulling in all of the staging tree here, which I'd rather not do.  Unless
> >> there's any objection, I'd like to take these as patches on top of the
> >> imx-drm stuff which I sent to Greg plus the of-graph stuff which they
> >> depend upon.  In other words, exactly how I've been testing it today.
> >>
> >> Any objections?
> >
> > None from me!  :)
> 
> Nor from me. But I'd like to point out that there already is one merge issue
> with Shawn's for-next branch in arch/arm/boot/dts/imx53-qsb.dts between
> d5eb195 "ARM: dts: i.MX53: move common QSB nodes to new file"
> and these two patches:
> 17b5001 "imx-drm: convert to componentised device support".
> "ARM: dts: imx53: Add IPU DI ports and endpoints, move imx-drm node to 
> dtsi"
> The first one already is in staging-next.

Yes, I'm aware of that (since I've been encountering it when creating
the build tree for my autobuilder.)

Thanks.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: visorchannel module

2014-03-07 Thread Peter Hüwe
Am Freitag, 7. März 2014, 20:17:56 schrieb Greg KH:
> On Fri, Mar 07, 2014 at 11:38:03AM +0300, Dan Carpenter wrote:
> > drivers/staging/unisys/include/guidutils.h
> > 
> > 57  static inline char *
> > 58  GUID_format2(const GUID *guid, char *s)
> > 59  {
> > 60  sprintf(s,
> > "{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%
> > -2.2x}", 61  (ulong) guid->data1,
> > 62  guid->data2,
> > 63  guid->data3,
> > 64  guid->data4[0],
> > 65  guid->data4[1],
> > 66  guid->data4[2],
> > 67  guid->data4[3],
> > 68  guid->data4[4], guid->data4[5], guid->data4[6],
> > guid->data4[7]); 69  return s;
> > 70  }
> > 
> > The 50 character buf size comes from the CHANNEL_GUID_MISMATCH() macros.
> > I'm not sure how it's calculating that it takes 63 characters.  printf
> > formats make my head hurt.  My test said the max was 95 characters?
> 
> There should be a built-in guid printk() macro (or function to do it)
> already in the kernel, so this code should be able to just be deleted
> entirely.


Yes there is
UUID/GUID addresses:

%pUb00010203-0405-0607-0809-0a0b0c0d0e0f
%pUB00010203-0405-0607-0809-0A0B0C0D0E0F
%pUl03020100-0504-0706-0809-0a0b0c0e0e0f
%pUL03020100-0504-0706-0809-0A0B0C0E0E0F

For printing 16-byte UUID/GUIDs addresses. The additional 'l', 'L',
'b' and 'B' specifiers are used to specify a little endian order in
lower ('l') or upper case ('L') hex characters - and big endian order
in lower ('b') or upper case ('B') hex characters.

Where no additional specifiers are used the default little endian
order with lower case hex characters will be printed.

From
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/printk-formats.txt?id=HEAD#n163


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


Re: staging: visorchannel module

2014-03-07 Thread Peter Hüwe
Am Freitag, 7. März 2014, 20:28:20 schrieb Peter Hüwe:
> Am Freitag, 7. März 2014, 20:17:56 schrieb Greg KH:
> > On Fri, Mar 07, 2014 at 11:38:03AM +0300, Dan Carpenter wrote:
> > > drivers/staging/unisys/include/guidutils.h
> > > 
> > > 57  static inline char *
> > > 58  GUID_format2(const GUID *guid, char *s)
> > > 59  {
> > > 60  sprintf(s,
> > > "{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x
> > > % -2.2x}", 61  (ulong) guid->data1,
> > > 62  guid->data2,
> > > 63  guid->data3,
> > > 64  guid->data4[0],
> > > 65  guid->data4[1],
> > > 66  guid->data4[2],
> > > 67  guid->data4[3],
> > > 68  guid->data4[4], guid->data4[5], guid->data4[6],
> > > guid->data4[7]); 69  return s;
> > > 70  }
> > > 
> > > The 50 character buf size comes from the CHANNEL_GUID_MISMATCH()
> > > macros. I'm not sure how it's calculating that it takes 63 characters.
> > >  printf formats make my head hurt.  My test said the max was 95
> > > characters?
> > 
> > There should be a built-in guid printk() macro (or function to do it)
> > already in the kernel, so this code should be able to just be deleted
> > entirely.
> 
> Yes there is
> UUID/GUID addresses:


Or atleast for the  guid->data4[x] fields

Raw buffer as a hex string:
%*ph00 01 02  ...  3f
%*phC   00:01:02: ... :3f
%*phD   00-01-02- ... -3f
%*phN   000102 ... 3f

For printing a small buffers (up to 64 bytes long) as a hex string with
certain separator. For the larger buffers consider to use
print_hex_dump().


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


[PATCH] Staging: unisys: Fix multiple variable length array declarations

2014-03-07 Thread Ken Cox
There were multiple variable length arrays declared on the stack in proc
handlers:
char buf[count];

I changed these to be fixed length arrays.

Signed-off-by: Ken Cox 
---
 drivers/staging/unisys/uislib/uislib.c   | 39 +---
 drivers/staging/unisys/virthba/virthba.c |  5 +++-
 drivers/staging/unisys/virtpci/virtpci.c |  5 +++-
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c 
b/drivers/staging/unisys/uislib/uislib.c
index b9bf7b4..8d7ff94 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -1509,9 +1509,12 @@ vnic_proc_write(struct file *file, const char __user 
*buffer,
size_t count, loff_t *ppos)
 {
int action = 0x, busNo = 0, i, result = 0;
-   char buf[count];
+   char buf[4];
char direction;
 /* GUID guid; */
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
if (copy_from_user(buf, buffer, count)) {
LOGERR("echo > /proc/uislib/vnic copy_from_user FAILED.\n");
return -EFAULT;
@@ -1566,9 +1569,12 @@ chipset_proc_write(struct file *file, const char __user 
*buffer,
   size_t count, loff_t *ppos)
 {
int i, action = 0x;
-   char buf[count];
+   char buf[4];
CONTROLVM_MESSAGE msg;
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
 
if (copy_from_user(buf, buffer, count)) {
@@ -1811,10 +1817,13 @@ bus_proc_write(struct file *file, const char __user 
*buffer,
 {
int server_flag = 0;
int i, action = 0x, result;
-   char buf[count];
+   char buf[16];
CONTROLVM_MESSAGE msg;
U32 busNo, deviceCount;
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
 
if (copy_from_user(buf, buffer, count)) {
@@ -1892,10 +1901,13 @@ dev_proc_write(struct file *file, const char __user 
*buffer,
int server_flag = 0;
CONTROLVM_MESSAGE msg;
U32 busNo, devNo;
-   char buf[count];
+   char buf[32];
unsigned int chanptr;
int type, i, action = 0x, result;
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
if (copy_from_user(buf, buffer, count)) {
LOGERR("echo > /proc/uislib/device: copy_from_user 
FAILED.");
return -EFAULT;
@@ -1985,7 +1997,7 @@ static ssize_t
 cycles_before_wait_proc_write(struct file *file, const char __user *buffer,
  size_t count, loff_t *ppos)
 {
-   char buf[count];
+   char buf[16];
 
 #define CYCLES_BEFORE_WAIT_USE_ERROR  { \
LOGERR("Incorrect Call Home Input.\n"); \
@@ -1993,6 +2005,8 @@ cycles_before_wait_proc_write(struct file *file, const 
char __user *buffer,
pr_info("EventID Category 
Type[parameter1][parameter2][parameter3][parameter4][parameter5][parameter6]\n");
 \
return -EFAULT; \
 }
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
 
if (count == 0)
CYCLES_BEFORE_WAIT_USE_ERROR;
@@ -2014,7 +2028,7 @@ static ssize_t
 reset_counts_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
 {
-   char buf[count];
+   char buf[16];
unsigned long long new_value;
struct bus_info *bus;
int i;
@@ -2026,6 +2040,9 @@ reset_counts_proc_write(struct file *file, const char 
__user *buffer,
return -EFAULT; \
}
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
if (count == 0)
RESET_COUNTS_USE_ERROR;
 
@@ -2061,7 +2078,7 @@ static ssize_t
 smart_wakeup_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
 {
-   char buf[count];
+   char buf[16];
int new_value;
 
 #define SMART_WAKEUP_USE_ERROR  { \
@@ -2071,6 +2088,9 @@ smart_wakeup_proc_write(struct file *file, const char 
__user *buffer,
return -EFAULT; \
}
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
if (count == 0)
SMART_WAKEUP_USE_ERROR;
 
@@ -2092,10 +2112,13 @@ test_proc_write(struct file *file, const char __user 
*buffer,
size_t count, loff_t *ppos)
 {
int i, action = 0x;
-   char buf[count];
+   char buf[16];
CONTROLVM_MESSAGE msg;
S64 vrtc_offset;
 
+   if (count >= ARRAY_SIZE(buf))
+   return -EINVAL;
+
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
 
if (copy_from_user(buf, buffer, count)) {
diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 277851f..cac2532 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/stag

[PATCH 08/14] staging: comedi: jr3_pci: tidy up jr3_pci_open()

2014-03-07 Thread H Hartley Sweeten
For aesthetics, rename the subdevice private data pointer from 'p' to
'spriv' and add a local variable for the comedi_subdevice pointer.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index ceaf417..83f2f8b 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -286,18 +286,18 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev,
 
 static int jr3_pci_open(struct comedi_device *dev)
 {
-   int i;
struct jr3_pci_dev_private *devpriv = dev->private;
+   struct jr3_pci_subdev_private *spriv;
+   struct comedi_subdevice *s;
+   int i;
 
dev_dbg(dev->class_dev, "jr3_pci_open\n");
for (i = 0; i < devpriv->n_channels; i++) {
-   struct jr3_pci_subdev_private *p;
-
-   p = dev->subdevices[i].private;
-   if (p) {
-   dev_dbg(dev->class_dev, "serial: %p %d (%d)\n", p,
-   p->serial_no, p->channel_no);
-   }
+   s = &dev->subdevices[i];
+   spriv = s->private;
+   if (spriv)
+   dev_dbg(dev->class_dev, "serial: %p %d (%d)\n",
+   spriv, spriv->serial_no, spriv->channel_no);
}
return 0;
 }
-- 
1.8.5.2

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


[PATCH 01/14] staging: comedi: jr3_pci: tidy up subdevice init

2014-03-07 Thread H Hartley Sweeten
For aesthetics, use a pointer to the comedi_subdevice instead of
accessing the dev->subdevices array directly.

Move the local variable for the subdevice private data so that
this function does not declare the variable twice.

Change the kzalloc for the subdevice private data to remove the
sizeof(struct foo).

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 38 +---
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 73ef31e..bfb0a13 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -627,10 +627,12 @@ static void jr3_pci_poll_dev(unsigned long data)
 static int jr3_pci_auto_attach(struct comedi_device *dev,
 unsigned long context_unused)
 {
-   int result;
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-   int i;
struct jr3_pci_dev_private *devpriv;
+   struct jr3_pci_subdev_private *p;
+   struct comedi_subdevice *s;
+   int result;
+   int i;
 
if (sizeof(struct jr3_channel) != 0xc00) {
dev_err(dev->class_dev,
@@ -679,18 +681,18 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
 
dev->open = jr3_pci_open;
for (i = 0; i < devpriv->n_channels; i++) {
-   dev->subdevices[i].type = COMEDI_SUBD_AI;
-   dev->subdevices[i].subdev_flags = SDF_READABLE | SDF_GROUND;
-   dev->subdevices[i].n_chan = 8 * 7 + 2;
-   dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
-   dev->subdevices[i].private =
-   kzalloc(sizeof(struct jr3_pci_subdev_private),
-   GFP_KERNEL);
-   if (dev->subdevices[i].private) {
-   struct jr3_pci_subdev_private *p;
+   s = &dev->subdevices[i];
+   s->type = COMEDI_SUBD_AI;
+   s->subdev_flags = SDF_READABLE | SDF_GROUND;
+   s->n_chan   = 8 * 7 + 2;
+   s->insn_read= jr3_pci_ai_insn_read;
+
+   p = kzalloc(sizeof(*p), GFP_KERNEL);
+   if (p) {
int j;
 
-   p = dev->subdevices[i].private;
+   s->private = p;
+
p->channel = &devpriv->iobase->channel[i].data;
dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
p->channel, devpriv->iobase,
@@ -721,11 +723,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
p->maxdata_list[56] = 0x;
p->maxdata_list[57] = 0x;
/*  Channel specific range and maxdata */
-   dev->subdevices[i].range_table = NULL;
-   dev->subdevices[i].range_table_list =
-   p->range_table_list;
-   dev->subdevices[i].maxdata = 0;
-   dev->subdevices[i].maxdata_list = p->maxdata_list;
+   s->range_table = NULL;
+   s->range_table_list = p->range_table_list;
+   s->maxdata = 0;
+   s->maxdata_list = p->maxdata_list;
}
}
 
@@ -762,7 +763,8 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
 
/*  Start card timer */
for (i = 0; i < devpriv->n_channels; i++) {
-   struct jr3_pci_subdev_private *p = dev->subdevices[i].private;
+   s = &dev->subdevices[i];
+   p = s->private;
 
p->next_time_min = jiffies + msecs_to_jiffies(500);
p->next_time_max = jiffies + msecs_to_jiffies(2000);
-- 
1.8.5.2

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


[PATCH 05/14] staging: comedi: jr3_pci: tidy up jr3_pci_poll_dev()

2014-03-07 Thread H Hartley Sweeten
For aesthetics, rename the subdevice private data pointer from 'subdevpriv'
to 'spriv' and add a local variable for the comedi_subdevice pointer.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 4553016..b04cf39 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -588,9 +588,11 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct 
comedi_subdevice *s)
 
 static void jr3_pci_poll_dev(unsigned long data)
 {
-   unsigned long flags;
struct comedi_device *dev = (struct comedi_device *)data;
struct jr3_pci_dev_private *devpriv = dev->private;
+   struct jr3_pci_subdev_private *spriv;
+   struct comedi_subdevice *s;
+   unsigned long flags;
unsigned long now;
int delay;
int i;
@@ -598,18 +600,22 @@ static void jr3_pci_poll_dev(unsigned long data)
spin_lock_irqsave(&dev->spinlock, flags);
delay = 1000;
now = jiffies;
-   /*  Poll all channels that are ready to be polled */
+
+   /* Poll all channels that are ready to be polled */
for (i = 0; i < devpriv->n_channels; i++) {
-   struct jr3_pci_subdev_private *subdevpriv =
-   dev->subdevices[i].private;
-   if (now > subdevpriv->next_time_min) {
+   s = &dev->subdevices[i];
+   spriv = s->private;
+
+   if (now > spriv->next_time_min) {
struct poll_delay_t sub_delay;
 
-   sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
-   subdevpriv->next_time_min =
-   jiffies + msecs_to_jiffies(sub_delay.min);
-   subdevpriv->next_time_max =
-   jiffies + msecs_to_jiffies(sub_delay.max);
+   sub_delay = jr3_pci_poll_subdevice(s);
+
+   spriv->next_time_min = jiffies +
+  msecs_to_jiffies(sub_delay.min);
+   spriv->next_time_max = jiffies +
+  msecs_to_jiffies(sub_delay.max);
+
if (sub_delay.max && sub_delay.max < delay)
/*
 * Wake up as late as possible ->
-- 
1.8.5.2

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


[PATCH 07/14] staging: comedi: jr3_pci: tidy up jr3_download_firmware()

2014-03-07 Thread H Hartley Sweeten
This callback function for comedi_load_firmware() first validates that
the firmware data is the correct format then it writes the data to each
subdevice.

Split the two operations out as separate functions to clarify the code.
Tidy up the new functions.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 157 ---
 drivers/staging/comedi/drivers/jr3_pci.h |   6 +-
 2 files changed, 85 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index af06339..ceaf417 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -326,105 +326,112 @@ static int read_idm_word(const u8 *data, size_t size, 
int *pos,
return result;
 }
 
-static int jr3_download_firmware(struct comedi_device *dev,
-const u8 *data, size_t size,
-unsigned long context)
+static int jr3_check_firmware(struct comedi_device *dev,
+ const u8 *data, size_t size)
 {
+   int more = 1;
+   int pos = 0;
+
/*
 * IDM file format is:
 *   { count, address, data  } *
 *   
 */
-   int result, more, pos, OK;
-
-   result = 0;
-   more = 1;
-   pos = 0;
-   OK = 0;
while (more) {
-   unsigned int count, addr;
+   unsigned int count = 0;
+   unsigned int addr = 0;
 
more = more && read_idm_word(data, size, &pos, &count);
-   if (more && count == 0x) {
-   OK = 1;
-   break;
-   }
+   if (more && count == 0x)
+   return 0;
+
more = more && read_idm_word(data, size, &pos, &addr);
while (more && count > 0) {
-   unsigned int dummy;
+   unsigned int dummy = 0;
+
more = more && read_idm_word(data, size, &pos, &dummy);
count--;
}
}
 
-   if (!OK) {
-   result = -ENODATA;
-   } else {
-   int i;
-   struct jr3_pci_dev_private *p = dev->private;
+   return -ENODATA;
+}
+
+static void jr3_write_firmware(struct comedi_device *dev,
+  int subdev, const u8 *data, size_t size)
+{
+   struct jr3_pci_dev_private *devpriv = dev->private;
+   struct jr3_t __iomem *iobase = devpriv->iobase;
+   u32 __iomem *lo;
+   u32 __iomem *hi;
+   int more = 1;
+   int pos = 0;
 
-   for (i = 0; i < p->n_channels; i++) {
-   struct jr3_pci_subdev_private *sp;
+   while (more) {
+   unsigned int count = 0;
+   unsigned int addr = 0;
+
+   more = more && read_idm_word(data, size, &pos, &count);
+   if (more && count == 0x)
+   return;
+
+   more = more && read_idm_word(data, size, &pos, &addr);
+
+   dev_dbg(dev->class_dev, "Loading#%d %4.4x bytes at %4.4x\n",
+   subdev, count, addr);
+
+   while (more && count > 0) {
+   if (addr & 0x4000) {
+   /* 16 bit data, never seen in real life!! */
+   unsigned int data1 = 0;
+
+   more = more &&
+  read_idm_word(data, size, &pos, &data1);
+   count--;
+   /* jr3[addr + 0x2 * pnum] = data1; */
+   } else {
+   /* Download 24 bit program */
+   unsigned int data1 = 0;
+   unsigned int data2 = 0;
+
+   lo = &iobase->channel[subdev].program_lo[addr];
+   hi = &iobase->channel[subdev].program_hi[addr];
 
-   sp = dev->subdevices[i].private;
-   more = 1;
-   pos = 0;
-   while (more) {
-   unsigned int count, addr;
more = more &&
-  read_idm_word(data, size, &pos, &count);
-   if (more && count == 0x)
-   break;
+  read_idm_word(data, size, &pos, &data1);
more = more &&
-  read_idm_word(data, size, &pos, &addr);
-   dev_dbg(dev->class_dev,
-   "Loading#%d %4.4x bytes at %4.4x\n",
-   i, count, addr);
-

[PATCH 06/14] staging: comedi: jr3_pci: tidy up jr3_pci_poll_subdevice()

2014-03-07 Thread H Hartley Sweeten
Refactor the function to reduce the indent level.

For aesthetics, rename the subdevice private data pointer from 'p'
to 'spriv'.

Rename the lacal variable used for the channel->full_scale to 'fs'
to reduce the line lengths.

Remove the setting of range[8]. The min,max values are the same as
the ones used when the subdevice private data was allocated and
initialized.

Remove the poll_delay_min_max() that are the same as the default.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 277 +++
 1 file changed, 130 insertions(+), 147 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index b04cf39..af06339 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -429,160 +429,143 @@ static int jr3_download_firmware(struct comedi_device 
*dev,
 
 static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 {
+   struct jr3_pci_subdev_private *spriv = s->private;
struct poll_delay_t result = poll_delay_min_max(1000, 2000);
-   struct jr3_pci_subdev_private *p = s->private;
+   struct jr3_channel __iomem *channel;
+   u16 model_no;
+   u16 serial_no;
+   int errors;
int i;
 
-   if (p) {
-   struct jr3_channel __iomem *channel = p->channel;
-   int errors = get_u16(&channel->errors);
-
-   if (errors != p->errors)
-   p->errors = errors;
-
-   if (errors & (watch_dog | watch_dog2 | sensor_change))
-   /*  Sensor communication lost, force poll mode */
-   p->state = state_jr3_poll;
-
-   switch (p->state) {
-   case state_jr3_poll: {
-   u16 model_no = get_u16(&channel->model_no);
-   u16 serial_no = get_u16(&channel->serial_no);
-   if ((errors & (watch_dog | watch_dog2)) ||
-   model_no == 0 || serial_no == 0) {
-   /*
-* Still no sensor, keep on polling.
-* Since it takes up to 10 seconds
-* for offsets to stabilize, polling
-* each second should suffice.
-*/
-   result = poll_delay_min_max(1000, 2000);
-   } else {
-   p->retries = 0;
-   p->state =
-   state_jr3_init_wait_for_offset;
-   result = poll_delay_min_max(1000, 2000);
-   }
+   if (!spriv)
+   return result;
+
+   channel = spriv->channel;
+   errors = get_u16(&channel->errors);
+
+   if (errors != spriv->errors)
+   spriv->errors = errors;
+
+   /* Sensor communication lost? force poll mode */
+   if (errors & (watch_dog | watch_dog2 | sensor_change))
+   spriv->state = state_jr3_poll;
+
+   switch (spriv->state) {
+   case state_jr3_poll:
+   model_no = get_u16(&channel->model_no);
+   serial_no = get_u16(&channel->serial_no);
+
+   if ((errors & (watch_dog | watch_dog2)) ||
+   model_no == 0 || serial_no == 0) {
+   /*
+* Still no sensor, keep on polling.
+* Since it takes up to 10 seconds for offsets to
+* stabilize, polling each second should suffice.
+*/
+   } else {
+   spriv->retries = 0;
+   spriv->state = state_jr3_init_wait_for_offset;
+   }
+   break;
+   case state_jr3_init_wait_for_offset:
+   spriv->retries++;
+   if (spriv->retries < 10) {
+   /*
+* Wait for offeset to stabilize
+* (< 10 s according to manual)
+*/
+   } else {
+   struct transform_t transf;
+
+   spriv->model_no = get_u16(&channel->model_no);
+   spriv->serial_no = get_u16(&channel->serial_no);
+
+   /* Transformation all zeros */
+   for (i = 0; i < ARRAY_SIZE(transf.link); i++) {
+   transf.link[i].link_type = (enum link_types)0;
+   transf.link[i].link_amount = 0;
}
-   break;
-   case state_jr3_init_wait_for_offset:
-   

[PATCH 03/14] staging: comedi: jr3_pci: factor subdevice private data init out of (*attach)

2014-03-07 Thread H Hartley Sweeten
Factor the code that allocates and initializes the subdevice private data
out of the (*attach) to reduce the indent level and make the code easier
to follow.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 84 ++--
 1 file changed, 47 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index f1028b8..8dc1ccb 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -624,6 +624,49 @@ static void jr3_pci_poll_dev(unsigned long data)
add_timer(&devpriv->timer);
 }
 
+static struct jr3_pci_subdev_private *
+jr3_pci_alloc_spriv(struct comedi_device *dev, struct comedi_subdevice *s)
+{
+   struct jr3_pci_dev_private *devpriv = dev->private;
+   struct jr3_pci_subdev_private *spriv;
+   int j;
+   int k;
+
+   spriv = comedi_alloc_spriv(s, sizeof(*spriv));
+   if (!spriv)
+   return NULL;
+
+   spriv->channel = &devpriv->iobase->channel[s->index].data;
+   spriv->channel_no = s->index;
+
+   for (j = 0; j < 8; j++) {
+   spriv->range[j].length = 1;
+   spriv->range[j].range.min = -100;
+   spriv->range[j].range.max = 100;
+
+   for (k = 0; k < 7; k++) {
+   spriv->range_table_list[j + k * 8] =
+   (struct comedi_lrange *)&spriv->range[j];
+   spriv->maxdata_list[j + k * 8] = 0x7fff;
+   }
+   }
+   spriv->range[8].length = 1;
+   spriv->range[8].range.min = 0;
+   spriv->range[8].range.max = 65536;
+
+   spriv->range_table_list[56] = (struct comedi_lrange *)&spriv->range[8];
+   spriv->range_table_list[57] = (struct comedi_lrange *)&spriv->range[8];
+   spriv->maxdata_list[56] = 0x;
+   spriv->maxdata_list[57] = 0x;
+
+   dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
+   spriv->channel, devpriv->iobase,
+   ((char __iomem *)spriv->channel -
+(char __iomem *)devpriv->iobase));
+
+   return spriv;
+}
+
 static int jr3_pci_auto_attach(struct comedi_device *dev,
 unsigned long context_unused)
 {
@@ -687,44 +730,11 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
s->n_chan   = 8 * 7 + 2;
s->insn_read= jr3_pci_ai_insn_read;
 
-   p = comedi_alloc_spriv(s, sizeof(*p));
+   p = jr3_pci_alloc_spriv(dev, s);
if (p) {
-   int j;
-
-   p->channel = &devpriv->iobase->channel[i].data;
-   dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
-   p->channel, devpriv->iobase,
-   ((char __iomem *)p->channel -
-(char __iomem *)devpriv->iobase));
-   p->channel_no = i;
-   for (j = 0; j < 8; j++) {
-   int k;
-
-   p->range[j].length = 1;
-   p->range[j].range.min = -100;
-   p->range[j].range.max = 100;
-   for (k = 0; k < 7; k++) {
-   p->range_table_list[j + k * 8] =
-   (struct comedi_lrange *)&p->
-   range[j];
-   p->maxdata_list[j + k * 8] = 0x7fff;
-   }
-   }
-   p->range[8].length = 1;
-   p->range[8].range.min = 0;
-   p->range[8].range.max = 65536;
-
-   p->range_table_list[56] =
-   (struct comedi_lrange *)&p->range[8];
-   p->range_table_list[57] =
-   (struct comedi_lrange *)&p->range[8];
-   p->maxdata_list[56] = 0x;
-   p->maxdata_list[57] = 0x;
-   /*  Channel specific range and maxdata */
-   s->range_table = NULL;
-   s->range_table_list = p->range_table_list;
-   s->maxdata = 0;
-   s->maxdata_list = p->maxdata_list;
+   /* Channel specific range and maxdata */
+   s->range_table_list = p->range_table_list;
+   s->maxdata_list = p->maxdata_list;
}
}
 
-- 
1.8.5.2

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


[PATCH 02/14] staging: comedi: jr3_pci: use comedi_alloc_spriv()

2014-03-07 Thread H Hartley Sweeten
Use the helper function to allocate the subdevice private data. This
sets the s->private variable for us and allows the comedi core to
automatically kfree() the memory during the (*detach).

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index bfb0a13..f1028b8 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -687,12 +687,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
s->n_chan   = 8 * 7 + 2;
s->insn_read= jr3_pci_ai_insn_read;
 
-   p = kzalloc(sizeof(*p), GFP_KERNEL);
+   p = comedi_alloc_spriv(s, sizeof(*p));
if (p) {
int j;
 
-   s->private = p;
-
p->channel = &devpriv->iobase->channel[i].data;
dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
p->channel, devpriv->iobase,
@@ -780,16 +778,11 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
 
 static void jr3_pci_detach(struct comedi_device *dev)
 {
-   int i;
struct jr3_pci_dev_private *devpriv = dev->private;
 
if (devpriv) {
del_timer_sync(&devpriv->timer);
 
-   if (dev->subdevices) {
-   for (i = 0; i < devpriv->n_channels; i++)
-   kfree(dev->subdevices[i].private);
-   }
if (devpriv->iobase)
iounmap(devpriv->iobase);
}
-- 
1.8.5.2

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


[PATCH 04/14] staging: comedi: jr3_pci: rename some local vars in the (*attach)

2014-03-07 Thread H Hartley Sweeten
For aesthetics, rename the subdevice private data pointer from 'p'
to 'spriv' and the variable used to check the errno from 'result'
to 'ret'.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 43 
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 8dc1ccb..4553016 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -672,9 +672,9 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
 {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct jr3_pci_dev_private *devpriv;
-   struct jr3_pci_subdev_private *p;
+   struct jr3_pci_subdev_private *spriv;
struct comedi_subdevice *s;
-   int result;
+   int ret;
int i;
 
if (sizeof(struct jr3_channel) != 0xc00) {
@@ -710,17 +710,17 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
break;
}
 
-   result = comedi_pci_enable(dev);
-   if (result)
-   return result;
+   ret = comedi_pci_enable(dev);
+   if (ret)
+   return ret;
 
devpriv->iobase = pci_ioremap_bar(pcidev, 0);
if (!devpriv->iobase)
return -ENOMEM;
 
-   result = comedi_alloc_subdevices(dev, devpriv->n_channels);
-   if (result)
-   return result;
+   ret = comedi_alloc_subdevices(dev, devpriv->n_channels);
+   if (ret)
+   return ret;
 
dev->open = jr3_pci_open;
for (i = 0; i < devpriv->n_channels; i++) {
@@ -730,24 +730,23 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
s->n_chan   = 8 * 7 + 2;
s->insn_read= jr3_pci_ai_insn_read;
 
-   p = jr3_pci_alloc_spriv(dev, s);
-   if (p) {
+   spriv = jr3_pci_alloc_spriv(dev, s);
+   if (spriv) {
/* Channel specific range and maxdata */
-   s->range_table_list = p->range_table_list;
-   s->maxdata_list = p->maxdata_list;
+   s->range_table_list = spriv->range_table_list;
+   s->maxdata_list = spriv->maxdata_list;
}
}
 
/*  Reset DSP card */
writel(0, &devpriv->iobase->channel[0].reset);
 
-   result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
- "comedi/jr3pci.idm",
- jr3_download_firmware, 0);
-   dev_dbg(dev->class_dev, "Firmare load %d\n", result);
-
-   if (result < 0)
-   return result;
+   ret = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
+  "comedi/jr3pci.idm",
+  jr3_download_firmware, 0);
+   dev_dbg(dev->class_dev, "Firmare load %d\n", ret);
+   if (ret < 0)
+   return ret;
/*
 * TODO: use firmware to load preferred offset tables. Suggested
 * format:
@@ -772,10 +771,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
/*  Start card timer */
for (i = 0; i < devpriv->n_channels; i++) {
s = &dev->subdevices[i];
-   p = s->private;
+   spriv = s->private;
 
-   p->next_time_min = jiffies + msecs_to_jiffies(500);
-   p->next_time_max = jiffies + msecs_to_jiffies(2000);
+   spriv->next_time_min = jiffies + msecs_to_jiffies(500);
+   spriv->next_time_max = jiffies + msecs_to_jiffies(2000);
}
 
devpriv->timer.data = (unsigned long)dev;
-- 
1.8.5.2

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


[PATCH 10/14] staging: comedi: jr3_pci: introduce boardinfo for the supported boards

2014-03-07 Thread H Hartley Sweeten
Create an enum for the boards supported by this driver and pass that enum in
the pci_driver id_table as the driver_data.

Introduce a boardinfo struct to hold the board specific data for the boards
supported by this driver. Use the boardinfo when attaching to the driver
instead of using the pcidev->device and the switch.

Since the PCI device ids are now only used in the id_table, remove the
defines and open code the device ids.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 77 +++-
 1 file changed, 46 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index f80bfcb..904104e 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -51,11 +51,37 @@
 #include "jr3_pci.h"
 
 #define PCI_VENDOR_ID_JR3 0x1762
-#define PCI_DEVICE_ID_JR3_1_CHANNEL 0x3111
-#define PCI_DEVICE_ID_JR3_1_CHANNEL_NEW 0x
-#define PCI_DEVICE_ID_JR3_2_CHANNEL 0x3112
-#define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113
-#define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
+
+enum jr3_pci_boardid {
+   BOARD_JR3_1,
+   BOARD_JR3_2,
+   BOARD_JR3_3,
+   BOARD_JR3_4,
+};
+
+struct jr3_pci_board {
+   const char *name;
+   int n_subdevs;
+};
+
+static const struct jr3_pci_board jr3_pci_boards[] = {
+   [BOARD_JR3_1] = {
+   .name   = "jr3_pci_1",
+   .n_subdevs  = 1,
+   },
+   [BOARD_JR3_2] = {
+   .name   = "jr3_pci_2",
+   .n_subdevs  = 2,
+   },
+   [BOARD_JR3_3] = {
+   .name   = "jr3_pci_3",
+   .n_subdevs  = 3,
+   },
+   [BOARD_JR3_4] = {
+   .name   = "jr3_pci_4",
+   .n_subdevs  = 4,
+   },
+};
 
 struct jr3_pci_dev_private {
struct jr3_t __iomem *iobase;
@@ -654,9 +680,10 @@ jr3_pci_alloc_spriv(struct comedi_device *dev, struct 
comedi_subdevice *s)
 }
 
 static int jr3_pci_auto_attach(struct comedi_device *dev,
-unsigned long context_unused)
+  unsigned long context)
 {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+   static const struct jr3_pci_board *board = NULL;
struct jr3_pci_dev_private *devpriv;
struct jr3_pci_subdev_private *spriv;
struct comedi_subdevice *s;
@@ -670,31 +697,18 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
return -EINVAL;
}
 
+   if (context < ARRAY_SIZE(jr3_pci_boards))
+   board = &jr3_pci_boards[context];
+   if (!board)
+   return -ENODEV;
+   dev->board_ptr = board;
+   dev->board_name = board->name;
+
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
 
init_timer(&devpriv->timer);
-   switch (pcidev->device) {
-   case PCI_DEVICE_ID_JR3_1_CHANNEL:
-   case PCI_DEVICE_ID_JR3_1_CHANNEL_NEW:
-   devpriv->n_channels = 1;
-   break;
-   case PCI_DEVICE_ID_JR3_2_CHANNEL:
-   devpriv->n_channels = 2;
-   break;
-   case PCI_DEVICE_ID_JR3_3_CHANNEL:
-   devpriv->n_channels = 3;
-   break;
-   case PCI_DEVICE_ID_JR3_4_CHANNEL:
-   devpriv->n_channels = 4;
-   break;
-   default:
-   dev_err(dev->class_dev, "jr3_pci: pci %s not supported\n",
-   pci_name(pcidev));
-   return -EINVAL;
-   break;
-   }
 
ret = comedi_pci_enable(dev);
if (ret)
@@ -704,6 +718,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
if (!devpriv->iobase)
return -ENOMEM;
 
+   devpriv->n_channels = board->n_subdevs;
ret = comedi_alloc_subdevices(dev, devpriv->n_channels);
if (ret)
return ret;
@@ -798,11 +813,11 @@ static int jr3_pci_pci_probe(struct pci_dev *dev,
 }
 
 static const struct pci_device_id jr3_pci_pci_table[] = {
-   { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL) },
-   { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL_NEW) },
-   { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL) },
-   { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL) },
-   { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL) },
+   { PCI_DEVICE(PCI_VENDOR_ID_JR3, 0x), BOARD_JR3_1 },
+   { PCI_DEVICE(PCI_VENDOR_ID_JR3, 0x3111), BOARD_JR3_1 },
+   { PCI_DEVICE(PCI_VENDOR_ID_JR3, 0x3112), BOARD_JR3_2 },
+   { PCI_DEVICE(PCI_VENDOR_ID_JR3, 0x3113), BOARD_JR3_3 },
+   { PCI_DEVICE(PCI_VENDOR_ID_JR3, 0x3114), BOARD_JR3_4 },
{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
-- 
1.8.5.2

_

[PATCH 00/14] staging: comedi: jr3_pci: start cleaning up driver

2014-03-07 Thread H Hartley Sweeten
Cleanup the (*attach) of this driver and tidy up the existing code.

H Hartley Sweeten (14):
  staging: comedi: jr3_pci: tidy up subdevice init
  staging: comedi: jr3_pci: use comedi_alloc_spriv()
  staging: comedi: jr3_pci: factor subdevice private data init out of (*attach)
  staging: comedi: jr3_pci: rename some local vars in the (*attach)
  staging: comedi: jr3_pci: tidy up jr3_pci_poll_dev()
  staging: comedi: jr3_pci: tidy up jr3_pci_poll_subdevice()
  staging: comedi: jr3_pci: tidy up jr3_download_firmware()
  staging: comedi: jr3_pci: tidy up jr3_pci_open()
  staging: comedi: jr3_pci: tidy up jr3_pci_ai_insn_read()
  staging: comedi: jr3_pci: introduce boardinfo for the supported boards
  staging: comedi: jr3_pci: remove 'n_channels' from private data
  staging: comedi: jr3_pci: rename struct transform_t
  staging: comedi: jr3_pci: rename struct poll_delay_t
  staging: comedi: jr3_pci: remove 'channel_no' from subdevice private data

 drivers/staging/comedi/drivers/jr3_pci.c | 889 +++
 drivers/staging/comedi/drivers/jr3_pci.h |   6 +-
 2 files changed, 447 insertions(+), 448 deletions(-)

-- 
1.8.5.2

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


[PATCH 13/14] staging: comedi: jr3_pci: rename struct poll_delay_t

2014-03-07 Thread H Hartley Sweeten
Rename this private struct so it has namespace associated with the
driver.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 5ad2173..2367509 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -90,16 +90,16 @@ struct jr3_pci_transform {
} link[8];
 };
 
+struct jr3_pci_poll_delay {
+   int min;
+   int max;
+};
+
 struct jr3_pci_dev_private {
struct jr3_t __iomem *iobase;
struct timer_list timer;
 };
 
-struct poll_delay_t {
-   int min;
-   int max;
-};
-
 struct jr3_pci_subdev_private {
struct jr3_channel __iomem *channel;
unsigned long next_time_min;
@@ -124,9 +124,9 @@ struct jr3_pci_subdev_private {
int retries;
 };
 
-static struct poll_delay_t poll_delay_min_max(int min, int max)
+static struct jr3_pci_poll_delay poll_delay_min_max(int min, int max)
 {
-   struct poll_delay_t result;
+   struct jr3_pci_poll_delay result;
 
result.min = min;
result.max = max;
@@ -447,10 +447,10 @@ static int jr3_download_firmware(struct comedi_device 
*dev,
return 0;
 }
 
-static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
+static struct jr3_pci_poll_delay jr3_pci_poll_subdevice(struct 
comedi_subdevice *s)
 {
struct jr3_pci_subdev_private *spriv = s->private;
-   struct poll_delay_t result = poll_delay_min_max(1000, 2000);
+   struct jr3_pci_poll_delay result = poll_delay_min_max(1000, 2000);
struct jr3_channel __iomem *channel;
u16 model_no;
u16 serial_no;
@@ -610,7 +610,7 @@ static void jr3_pci_poll_dev(unsigned long data)
spriv = s->private;
 
if (now > spriv->next_time_min) {
-   struct poll_delay_t sub_delay;
+   struct jr3_pci_poll_delay sub_delay;
 
sub_delay = jr3_pci_poll_subdevice(s);
 
-- 
1.8.5.2

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


[PATCH 14/14] staging: comedi: jr3_pci: remove 'channel_no' from subdevice private data

2014-03-07 Thread H Hartley Sweeten
This member of the subdevice private data is just the subdevice 'index'. Use
that instead and remove the member.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 2367509..19c1d97 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -111,7 +111,6 @@ struct jr3_pci_subdev_private {
state_jr3_init_use_offset_complete,
state_jr3_done
} state;
-   int channel_no;
int serial_no;
int model_no;
struct {
@@ -311,7 +310,7 @@ static int jr3_pci_open(struct comedi_device *dev)
spriv = s->private;
if (spriv)
dev_dbg(dev->class_dev, "serial: %p %d (%d)\n",
-   spriv, spriv->serial_no, spriv->channel_no);
+   spriv, spriv->serial_no, s->index);
}
return 0;
 }
@@ -646,7 +645,6 @@ jr3_pci_alloc_spriv(struct comedi_device *dev, struct 
comedi_subdevice *s)
return NULL;
 
spriv->channel = &devpriv->iobase->channel[s->index].data;
-   spriv->channel_no = s->index;
 
for (j = 0; j < 8; j++) {
spriv->range[j].length = 1;
-- 
1.8.5.2

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


[PATCH 11/14] staging: comedi: jr3_pci: remove 'n_channels' from private data

2014-03-07 Thread H Hartley Sweeten
This member of the private data is actually the number of subdevices. We
can get that information directly from the comedi_device. Do that instead
and remove the unnecessary member from the private data.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 904104e..c67fecc 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -85,7 +85,6 @@ static const struct jr3_pci_board jr3_pci_boards[] = {
 
 struct jr3_pci_dev_private {
struct jr3_t __iomem *iobase;
-   int n_channels;
struct timer_list timer;
 };
 
@@ -302,13 +301,12 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev,
 
 static int jr3_pci_open(struct comedi_device *dev)
 {
-   struct jr3_pci_dev_private *devpriv = dev->private;
struct jr3_pci_subdev_private *spriv;
struct comedi_subdevice *s;
int i;
 
dev_dbg(dev->class_dev, "jr3_pci_open\n");
-   for (i = 0; i < devpriv->n_channels; i++) {
+   for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
spriv = s->private;
if (spriv)
@@ -434,7 +432,6 @@ static int jr3_download_firmware(struct comedi_device *dev,
 const u8 *data, size_t size,
 unsigned long context)
 {
-   struct jr3_pci_dev_private *devpriv = dev->private;
int subdev;
int ret;
 
@@ -444,7 +441,7 @@ static int jr3_download_firmware(struct comedi_device *dev,
return ret;
 
/* write firmware to each subdevice */
-   for (subdev = 0; subdev < devpriv->n_channels; subdev++)
+   for (subdev = 0; subdev < dev->n_subdevices; subdev++)
jr3_write_firmware(dev, subdev, data, size);
 
return 0;
@@ -608,7 +605,7 @@ static void jr3_pci_poll_dev(unsigned long data)
now = jiffies;
 
/* Poll all channels that are ready to be polled */
-   for (i = 0; i < devpriv->n_channels; i++) {
+   for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
spriv = s->private;
 
@@ -718,13 +715,12 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
if (!devpriv->iobase)
return -ENOMEM;
 
-   devpriv->n_channels = board->n_subdevs;
-   ret = comedi_alloc_subdevices(dev, devpriv->n_channels);
+   ret = comedi_alloc_subdevices(dev, board->n_subdevs);
if (ret)
return ret;
 
dev->open = jr3_pci_open;
-   for (i = 0; i < devpriv->n_channels; i++) {
+   for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
@@ -770,7 +766,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
}
 
/*  Start card timer */
-   for (i = 0; i < devpriv->n_channels; i++) {
+   for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
spriv = s->private;
 
-- 
1.8.5.2

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


[PATCH 09/14] staging: comedi: jr3_pci: tidy up jr3_pci_ai_insn_read()

2014-03-07 Thread H Hartley Sweeten
Refactor this function to make it clearer.

The channel does not need to be validated. The comedi core does that for us.

Exit early if the subdevice private data is invalid.

Exit early if the subdevice 'state' is not done or there is an error.

Factor out the code that actually reads the channel data to reduce the
indent level.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 156 +++
 1 file changed, 73 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index 83f2f8b..f80bfcb 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -194,94 +194,84 @@ static struct six_axis_t get_max_full_scales(struct 
jr3_channel __iomem
return result;
 }
 
+static unsigned int jr3_pci_ai_read_chan(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int chan)
+{
+   struct jr3_pci_subdev_private *spriv = s->private;
+   unsigned int val = 0;
+
+   if (spriv->state != state_jr3_done)
+   return 0;
+
+   if (chan < 56) {
+   unsigned int axis = chan % 8;
+   unsigned filter = chan / 8;
+
+   switch (axis) {
+   case 0:
+   val = get_s16(&spriv->channel->filter[filter].fx);
+   break;
+   case 1:
+   val = get_s16(&spriv->channel->filter[filter].fy);
+   break;
+   case 2:
+   val = get_s16(&spriv->channel->filter[filter].fz);
+   break;
+   case 3:
+   val = get_s16(&spriv->channel->filter[filter].mx);
+   break;
+   case 4:
+   val = get_s16(&spriv->channel->filter[filter].my);
+   break;
+   case 5:
+   val = get_s16(&spriv->channel->filter[filter].mz);
+   break;
+   case 6:
+   val = get_s16(&spriv->channel->filter[filter].v1);
+   break;
+   case 7:
+   val = get_s16(&spriv->channel->filter[filter].v2);
+   break;
+   }
+   val += 0x4000;
+   } else if (chan == 56) {
+   val = get_u16(&spriv->channel->model_no);
+   } else if (chan == 57) {
+   val = get_u16(&spriv->channel->serial_no);
+   }
+
+   return val;
+}
+
 static int jr3_pci_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
-   struct comedi_insn *insn, unsigned int *data)
+   struct comedi_insn *insn,
+   unsigned int *data)
 {
-   int result;
-   struct jr3_pci_subdev_private *p;
-   int channel;
-
-   p = s->private;
-   channel = CR_CHAN(insn->chanspec);
-   if (p == NULL || channel > 57) {
-   result = -EINVAL;
-   } else {
-   int i;
-
-   result = insn->n;
-   if (p->state != state_jr3_done ||
-   (get_u16(&p->channel->errors) & (watch_dog | watch_dog2 |
-sensor_change))) {
-   /* No sensor or sensor changed */
-   if (p->state == state_jr3_done) {
-   /* Restart polling */
-   p->state = state_jr3_poll;
-   }
-   result = -EAGAIN;
-   }
-   for (i = 0; i < insn->n; i++) {
-   if (channel < 56) {
-   int axis, filter;
-
-   axis = channel % 8;
-   filter = channel / 8;
-   if (p->state != state_jr3_done) {
-   data[i] = 0;
-   } else {
-   int F = 0;
-   switch (axis) {
-   case 0:
-   F = get_s16(&p->channel->
-   filter[filter].fx);
-   break;
-   case 1:
-   F = get_s16(&p->channel->
-   filter[filter].fy);
-   break;
-   case 2:
-   F = get_s16(&p->channel->
-  

[PATCH 12/14] staging: comedi: jr3_pci: rename struct transform_t

2014-03-07 Thread H Hartley Sweeten
Rename this private struct so it has namespace associated with the
driver.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/jr3_pci.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c 
b/drivers/staging/comedi/drivers/jr3_pci.c
index c67fecc..5ad2173 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -83,6 +83,13 @@ static const struct jr3_pci_board jr3_pci_boards[] = {
},
 };
 
+struct jr3_pci_transform {
+   struct {
+   u16 link_type;
+   s16 link_amount;
+   } link[8];
+};
+
 struct jr3_pci_dev_private {
struct jr3_t __iomem *iobase;
struct timer_list timer;
@@ -131,15 +138,8 @@ static int is_complete(struct jr3_channel __iomem *channel)
return get_s16(&channel->command_word0) == 0;
 }
 
-struct transform_t {
-   struct {
-   u16 link_type;
-   s16 link_amount;
-   } link[8];
-};
-
 static void set_transforms(struct jr3_channel __iomem *channel,
-  struct transform_t transf, short num)
+  struct jr3_pci_transform transf, short num)
 {
int i;
 
@@ -495,7 +495,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct 
comedi_subdevice *s)
 * (< 10 s according to manual)
 */
} else {
-   struct transform_t transf;
+   struct jr3_pci_transform transf;
 
spriv->model_no = get_u16(&channel->model_no);
spriv->serial_no = get_u16(&channel->serial_no);
-- 
1.8.5.2

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


[PATCH] staging: cxt1e1: change declaration of TWV_table

2014-03-07 Thread Shaun Laing
Changes the declaration of TWV_table to 'static void' to eliminate a sparse
"should it be static" warning.

Signed-off-by: Shaun Laing 
---
 drivers/staging/cxt1e1/comet.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/cxt1e1/comet.c b/drivers/staging/cxt1e1/comet.c
index c4c8c0f..953d96a 100644
--- a/drivers/staging/cxt1e1/comet.c
+++ b/drivers/staging/cxt1e1/comet.c
@@ -33,7 +33,7 @@ static void WrtRcvEqualizerTbl(ci_t *ci, struct s_comet_reg 
*comet, u_int32_t *t
 static void WrtXmtWaveformTbl(ci_t *ci, struct s_comet_reg *comet, u_int8_t 
table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]);
 
 
-void   *TWV_table[12] = {
+static void *TWV_table[12] = {
TWVLongHaul0DB, TWVLongHaul7_5DB, TWVLongHaul15DB, TWVLongHaul22_5DB,
TWVShortHaul0, TWVShortHaul1, TWVShortHaul2, TWVShortHaul3,
TWVShortHaul4, TWVShortHaul5,
-- 
1.7.9.5

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


Re: [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O

2014-03-07 Thread David Miller
From: "K. Y. Srinivasan" 
Date: Thu,  6 Mar 2014 21:32:36 -0800

> +static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
> + struct hv_page_buffer *pb)
> +{
> + int j = 0;
> +
> + /* Deal with compund pages by ignoring unused part
> +  * of the page.
> +  */
> + page += offset  >> PAGE_SHIFT;

Please only one space between "offset" and ">>"

> + offset &= ~PAGE_MASK;
> +
> + while (len > 0) {
> + unsigned long bytes;
> +
> + bytes = PAGE_SIZE - offset;
> + if (bytes > len)
> + bytes = len;
> + pb[j].pfn = page_to_pfn(page);
> + pb[j].offset = offset;
> + pb[j].len = bytes;
> +
> + offset += bytes;
> + len -= bytes;
> +
> + if (offset == PAGE_SIZE && len) {
> + page++;
> + offset = 0;
> + j++;
> + }
> + }
> +
> + return j + 1;
> +}

I think this function has some edge case errors.

As I understand it, this function returns how many page buffer entries
were filled in.

But if we fill exactly the end of a page, we will report one too many
in the return value.

Consider an "offset" of X, where X is smaller than PAGE_SIZE.  And a
"len" which is exactly "PAGE_SIZE - offset".

We will fill in exactly one page buffer entry, however we will
erroneously return 2 from this function.

I believe the fix is to first replace the test at the end of the loop
with:

page++;
offset = 0;
j++;

And subsequently change the function to just return plain "j".
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RFC] staging: dgap: more 80+ char lines work

2014-03-07 Thread Mark Hounschell
This is just for comments. The indentation was alread so far
over 80 chars I (as recommended earlier) make a couple of
new functions. Somehow I don't think this is proper and there
is probably a better way to do this. This is untested.

Signed-off-by: Mark Hounschell 
---
 drivers/staging/dgap/dgap.c | 93 ++---
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index af87df9..477ae0b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -5732,6 +5732,44 @@ static void dgap_parity_scan(struct channel_t *ch, 
unsigned char *cbuf,
*len = count;
 }
 
+static void dgap_try_tty_write_wakeup(ulong lock_flags, ulong lock_flags2,
+ struct channel_t *ch)
+{
+   void (*write_wakeup)(struct tty_struct *);
+   struct board_t *bd = ch->ch_bd;
+
+   write_wakeup = ch->ch_tun.un_tty->ldisc->ops->write_wakeup;
+   if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+   write_wakeup) {
+   DGAP_UNLOCK(ch->ch_lock, lock_flags2);
+   DGAP_UNLOCK(bd->bd_lock, lock_flags);
+   (*write_wakeup)(ch->ch_tun.un_tty);
+   DGAP_LOCK(bd->bd_lock, lock_flags);
+   DGAP_LOCK(ch->ch_lock, lock_flags2);
+   }
+   wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
+   wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+}
+
+static void dgap_try_pr_write_wakeup(ulong lock_flags, ulong lock_flags2,
+struct channel_t *ch)
+{
+   void (*write_wakeup)(struct tty_struct *);
+   struct board_t *bd = ch->ch_bd;
+
+   write_wakeup = ch->ch_pun.un_tty->ldisc->ops->write_wakeup;
+   if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+   write_wakeup) {
+   DGAP_UNLOCK(ch->ch_lock, lock_flags2);
+   DGAP_UNLOCK(bd->bd_lock, lock_flags);
+   (*write_wakeup)(ch->ch_pun.un_tty);
+   DGAP_LOCK(bd->bd_lock, lock_flags);
+   DGAP_LOCK(ch->ch_lock, lock_flags2);
+   }
+   wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
+   wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+}
+
 /*===
  *
  *  dgap_event - FEP to host event processing routine.
@@ -5889,36 +5927,17 @@ static int dgap_event(struct board_t *bd)
 
if (ch->ch_tun.un_flags & UN_LOW) {
ch->ch_tun.un_flags &= ~UN_LOW;
-
if (ch->ch_tun.un_flags & UN_ISOPEN) {
-   if ((ch->ch_tun.un_tty->flags &
-  (1 << TTY_DO_WRITE_WAKEUP)) &&
-   
ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
-   DGAP_UNLOCK(ch->ch_lock, 
lock_flags2);
-   DGAP_UNLOCK(bd->bd_lock, 
lock_flags);
-   
(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
-   DGAP_LOCK(bd->bd_lock, 
lock_flags);
-   DGAP_LOCK(ch->ch_lock, 
lock_flags2);
-   }
-   
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
-   
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+   dgap_try_tty_write_wakeup
+   (lock_flags, lock_flags2, ch);
}
}
 
if (ch->ch_pun.un_flags & UN_LOW) {
ch->ch_pun.un_flags &= ~UN_LOW;
if (ch->ch_pun.un_flags & UN_ISOPEN) {
-   if ((ch->ch_pun.un_tty->flags &
-  (1 << TTY_DO_WRITE_WAKEUP)) &&
-   
ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
-   DGAP_UNLOCK(ch->ch_lock, 
lock_flags2);
-   DGAP_UNLOCK(bd->bd_lock, 
lock_flags);
-   
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
-   DGAP_LOCK(bd->bd_lock, 
lock_flags);
-   DGAP_LOCK(ch->ch_lock, 
lock_flags2);
-   }
-   
wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
-   
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+   

[GIT PULL] imx-drm staging changes

2014-03-07 Thread Russell King
Greg,

Please incorporate the latest imx-drm changes, which can be found at:

  git://ftp.arm.linux.org.uk/~rmk/linux-arm.git imx-drm-staging

with SHA1 6a6317113391b482a6715d1c826b2d78bfdf9366.


This set of changes reorganises imx-drm's DT bindings by re-using the OF
graph parsing code which was located in drivers/media, removing the
temporary bindings.

The result is that more TODO entries are now removed.  While we're not
quite done with this yet as there's a few straggling updates to imx-ldb
to come, but leaving these out is not detrimental at this point in time
- they are more an enhancement.

However, this pull has the additional complication that we're sharing
seven commits with Mauro's V4L git tree, which move the OF graph parsing
code out of drivers/media into drivers/of.  Philipp's imx-drm changes
depend on these and my previously committed round of imx-drm commits.
Hence, the diffstat below is from a test merge with your tree head
(17b02809cfa7).

Mauro merged those seven commits earlier today as a git pull, so both
trees will be sharing exactly the same commit IDs.

I've given these changes a spin here on both my Hummingboard and Cubox-i4
(one is iMX6Solo, the other is iMX6Quad based), which includes Xorg using
the DRM device directly, and I find nothing wrong.

The diffstat does look a little scarey - this is because we're having to
update the ARM DT files along with this change, and obviously the 
dependency on the OF graph parsing code.


This will update the following files:

 Documentation/devicetree/bindings/graph.txt   | 129 
++
 Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt |  48 
++--
 Documentation/devicetree/bindings/staging/imx-drm/hdmi.txt|  58 
++
 Documentation/devicetree/bindings/staging/imx-drm/ldb.txt |  20 -
 arch/arm/boot/dts/imx51-apf51dev.dts  |  11 ++-
 arch/arm/boot/dts/imx51-babbage.dts   |  28 +--
 arch/arm/boot/dts/imx51.dtsi  |  22 +-
 arch/arm/boot/dts/imx53-m53evk.dts|  17 ++--
 arch/arm/boot/dts/imx53-mba53.dts |  17 ++--
 arch/arm/boot/dts/imx53-qsb.dts   |  17 ++--
 arch/arm/boot/dts/imx53.dtsi  |  64 
++-
 arch/arm/boot/dts/imx6dl.dtsi |  22 +++---
 arch/arm/boot/dts/imx6q-sabresd.dts   |   4 -
 arch/arm/boot/dts/imx6q.dtsi  | 124 
+++--
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi|   6 --
 arch/arm/boot/dts/imx6qdl.dtsi| 128 
+-
 drivers/media/i2c/adv7343.c   |   4 +-
 drivers/media/i2c/mt9p031.c   |   4 +-
 drivers/media/i2c/s5k5baf.c   |   3 +-
 drivers/media/i2c/tvp514x.c   |   3 +-
 drivers/media/i2c/tvp7002.c   |   3 +-
 drivers/media/platform/exynos4-is/fimc-is.c   |   6 +-
 drivers/media/platform/exynos4-is/media-dev.c |  13 +--
 drivers/media/platform/exynos4-is/mipi-csis.c |   5 +-
 drivers/media/v4l2-core/v4l2-of.c | 133 
+--
 drivers/of/base.c | 151 
+++
 drivers/staging/imx-drm/TODO  |   5 --
 drivers/staging/imx-drm/imx-drm-core.c| 217 
---
 drivers/staging/imx-drm/imx-drm.h |   5 +-
 drivers/staging/imx-drm/imx-hdmi.c|   4 +-
 drivers/staging/imx-drm/imx-ldb.c |   4 +-
 drivers/staging/imx-drm/imx-tve.c |   2 +-
 drivers/staging/imx-drm/ipuv3-crtc.c  |  47 
+--
 include/linux/of_graph.h  |  66 

 include/media/v4l2-of.h   |  33 
+---
 35 files changed, 1087 insertions(+), 336 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/graph.txt
 create mode 100644 Documentation/devicetree/bindings/staging/imx-drm/hdmi.txt
 create mode 100644 include/linux/of_graph.h

through these changes:

Philipp Zabel (18):
  [media] of: move graph helpers from drivers/media/v4l2-core to drivers/of
  Documentation: of: Document graph bindings
  of: Warn if of_graph_get_next_endpoint is called with the root node
  of: Reduce indentation in of_g

Re: [GIT PULL] imx-drm staging changes

2014-03-07 Thread Greg Kroah-Hartman
On Fri, Mar 07, 2014 at 10:02:03PM +, Russell King wrote:
> Greg,
> 
> Please incorporate the latest imx-drm changes, which can be found at:
> 
>   git://ftp.arm.linux.org.uk/~rmk/linux-arm.git imx-drm-staging
> 
> with SHA1 6a6317113391b482a6715d1c826b2d78bfdf9366.

Pulled and now pushed out, thanks.

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


Re: [PATCH RFC] staging: dgap: more 80+ char lines work

2014-03-07 Thread Greg KH
On Fri, Mar 07, 2014 at 04:57:50PM -0500, Mark Hounschell wrote:
> This is just for comments. The indentation was alread so far
> over 80 chars I (as recommended earlier) make a couple of
> new functions. Somehow I don't think this is proper and there
> is probably a better way to do this. This is untested.

Looks good to me, as long as you test it :)

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


Re: [PATCH RFC] staging: dgap: more 80+ char lines work

2014-03-07 Thread Dan Carpenter
I still prefer my patch.  Unless I'm missing something?  Could you
review it and I will submit it as a patch tomorrow.

regards,
dan carpenter

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index d00283a226a2..783cd75a2d96 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -5730,6 +5730,33 @@ static void dgap_parity_scan(struct channel_t *ch, 
unsigned char *cbuf,
*len = count;
 }
 
+static void dgap_write_wakeup(struct board_t *bd, struct channel_t *ch,
+ struct un_t *un, u32 mask,
+ unsigned long *irq_flags1,
+ unsigned long *irq_flags2)
+{
+   if (!(un->un_flags & mask))
+   return;
+
+   un->un_flags &= ~mask;
+
+   if (!(un->un_flags & UN_ISOPEN))
+   return;
+
+   if ((un->un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+   un->un_tty->ldisc->ops->write_wakeup) {
+   spin_unlock_irqrestore(&ch->ch_lock, *irq_flags2);
+   spin_unlock_irqrestore(&bd->bd_lock, *irq_flags1);
+
+   (un->un_tty->ldisc->ops->write_wakeup)(un->un_tty);
+
+   spin_lock_irqsave(&bd->bd_lock, *irq_flags1);
+   spin_lock_irqsave(&ch->ch_lock, *irq_flags2);
+   }
+   wake_up_interruptible(&un->un_tty->write_wait);
+   wake_up_interruptible(&un->un_flags_wait);
+}
+
 /*===
  *
  *  dgap_event - FEP to host event processing routine.
@@ -5881,42 +5908,10 @@ static int dgap_event(struct board_t *bd)
 * Process Transmit low.
 */
if (reason & IFTLW) {
-
-   if (ch->ch_tun.un_flags & UN_LOW) {
-   ch->ch_tun.un_flags &= ~UN_LOW;
-
-   if (ch->ch_tun.un_flags & UN_ISOPEN) {
-   if ((ch->ch_tun.un_tty->flags &
-  (1 << TTY_DO_WRITE_WAKEUP)) &&
-   
ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
-   DGAP_UNLOCK(ch->ch_lock, 
lock_flags2);
-   DGAP_UNLOCK(bd->bd_lock, 
lock_flags);
-   
(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
-   DGAP_LOCK(bd->bd_lock, 
lock_flags);
-   DGAP_LOCK(ch->ch_lock, 
lock_flags2);
-   }
-   
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
-   
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
-   }
-   }
-
-   if (ch->ch_pun.un_flags & UN_LOW) {
-   ch->ch_pun.un_flags &= ~UN_LOW;
-   if (ch->ch_pun.un_flags & UN_ISOPEN) {
-   if ((ch->ch_pun.un_tty->flags &
-  (1 << TTY_DO_WRITE_WAKEUP)) &&
-   
ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
-   DGAP_UNLOCK(ch->ch_lock, 
lock_flags2);
-   DGAP_UNLOCK(bd->bd_lock, 
lock_flags);
-   
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
-   DGAP_LOCK(bd->bd_lock, 
lock_flags);
-   DGAP_LOCK(ch->ch_lock, 
lock_flags2);
-   }
-   
wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
-   
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
-   }
-   }
-
+   dgap_write_wakeup(bd, ch, &ch->ch_tun, UN_LOW,
+ &lock_flags, &lock_flags2);
+   dgap_write_wakeup(bd, ch, &ch->ch_pun, UN_LOW,
+ &lock_flags, &lock_flags2);
if (ch->ch_flags & CH_WLOW) {
ch->ch_flags &= ~CH_WLOW;
wake_up_interruptible(&ch->ch_flags_wait);
@@ -5927,42 +5922,10 @@ static int dgap_event(struct board_t *bd)
 * Process Transmit empty.
 */
if (reason & IFTEM) {
-   if (ch->ch_tun.un_flags & UN_EMPTY) {
-   ch->ch_tun.un_flags &= ~UN_EMPTY;
-   if (ch->ch_tun.un_flags & UN_ISOPEN) {
-   if ((ch->ch_tun

[PATCH 04/31] staging: comedi: comedi_fc: remove unnecessary prefix in dev_warn() message

2014-03-07 Thread H Hartley Sweeten
The dev_warn() will automatically have the "comedi" prefix.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 9bf2d4b..157b61c 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -47,7 +47,7 @@ unsigned int cfc_write_array_to_buffer(struct 
comedi_subdevice *s,
 
retval = comedi_buf_write_alloc(async, num_bytes);
if (retval != num_bytes) {
-   dev_warn(s->device->class_dev, "comedi: buffer overrun\n");
+   dev_warn(s->device->class_dev, "buffer overrun\n");
async->events |= COMEDI_CB_OVERFLOW;
return 0;
}
-- 
1.8.5.2

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


[PATCH 05/31] staging: comedi: comedi_fc: tidy up multi-line comment in header

2014-03-07 Thread H Hartley Sweeten
Tidy up the multi-line comment to follow the CodingStyle.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.h | 37 +++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index 8558b07..ad96c6a 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -1,23 +1,22 @@
 /*
-comedi_fc.h
-
-This is a place for code driver writers wish to share between
-two or more drivers. These functions are meant to be used only
-by drivers, they are NOT part of the kcomedilib API!
-
-Author:  Frank Mori Hess 
-Copyright (C) 2002 Frank Mori Hess
-
-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.
-*/
+ * comedi_fc.h
+ * This is a place for code driver writers wish to share between
+ * two or more drivers. These functions are meant to be used only
+ * by drivers, they are NOT part of the kcomedilib API!
+ *
+ * Author: Frank Mori Hess 
+ * Copyright (C) 2002 Frank Mori Hess
+ *
+ * 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.
+ */
 
 #ifndef _COMEDI_FC_H
 #define _COMEDI_FC_H
-- 
1.8.5.2

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


[PATCH 07/31] staging: comedi: comedi_fc: rename comedi_subdevice variables in header

2014-03-07 Thread H Hartley Sweeten
Typically the comedi_subdevice variable is simply named 's'. Rename
the variables in comedi_fc.h.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index a5b9d11..042bf87 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -27,16 +27,16 @@
 unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *,
   void *data, unsigned int num_bytes);
 
-static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *subd,
+static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *s,
   unsigned short data)
 {
-   return cfc_write_array_to_buffer(subd, &data, sizeof(data));
+   return cfc_write_array_to_buffer(s, &data, sizeof(data));
 };
 
-static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice
-   *subd, unsigned int data)
+static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *s,
+   unsigned int data)
 {
-   return cfc_write_array_to_buffer(subd, &data, sizeof(data));
+   return cfc_write_array_to_buffer(s, &data, sizeof(data));
 };
 
 unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *,
@@ -45,24 +45,24 @@ unsigned int cfc_read_array_from_buffer(struct 
comedi_subdevice *,
 unsigned int cfc_handle_events(struct comedi_device *,
   struct comedi_subdevice *);
 
-static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *subd)
+static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
 {
int num_samples;
int bits_per_sample;
 
-   switch (subd->type) {
+   switch (s->type) {
case COMEDI_SUBD_DI:
case COMEDI_SUBD_DO:
case COMEDI_SUBD_DIO:
-   bits_per_sample = 8 * bytes_per_sample(subd);
-   num_samples = (subd->async->cmd.chanlist_len +
+   bits_per_sample = 8 * bytes_per_sample(s);
+   num_samples = (s->async->cmd.chanlist_len +
   bits_per_sample - 1) / bits_per_sample;
break;
default:
-   num_samples = subd->async->cmd.chanlist_len;
+   num_samples = s->async->cmd.chanlist_len;
break;
}
-   return num_samples * bytes_per_sample(subd);
+   return num_samples * bytes_per_sample(s);
 }
 
 /**
-- 
1.8.5.2

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


[PATCH 10/31] staging: comedi: comedi_fc: export increment_scan_progress()

2014-03-07 Thread H Hartley Sweeten
Rename this function to cfc_inc_scan_progress() and export it for
use by the comedi drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.c | 8 
 drivers/staging/comedi/drivers/comedi_fc.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 5d8aa80..9d9b146 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -44,8 +44,7 @@ unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
 }
 EXPORT_SYMBOL_GPL(cfc_bytes_per_scan);
 
-static void increment_scan_progress(struct comedi_subdevice *s,
-   unsigned int num_bytes)
+void cfc_inc_scan_progress(struct comedi_subdevice *s, unsigned int num_bytes)
 {
struct comedi_async *async = s->async;
unsigned int scan_length = cfc_bytes_per_scan(s);
@@ -56,6 +55,7 @@ static void increment_scan_progress(struct comedi_subdevice 
*s,
async->events |= COMEDI_CB_EOS;
}
 }
+EXPORT_SYMBOL_GPL(cfc_inc_scan_progress);
 
 /* Writes an array of data points to comedi's buffer */
 unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s,
@@ -76,7 +76,7 @@ unsigned int cfc_write_array_to_buffer(struct 
comedi_subdevice *s,
 
comedi_buf_memcpy_to(async, 0, data, num_bytes);
comedi_buf_write_free(async, num_bytes);
-   increment_scan_progress(s, num_bytes);
+   cfc_inc_scan_progress(s, num_bytes);
async->events |= COMEDI_CB_BLOCK;
 
return num_bytes;
@@ -94,7 +94,7 @@ unsigned int cfc_read_array_from_buffer(struct 
comedi_subdevice *s,
num_bytes = comedi_buf_read_alloc(async, num_bytes);
comedi_buf_memcpy_from(async, 0, data, num_bytes);
comedi_buf_read_free(async, num_bytes);
-   increment_scan_progress(s, num_bytes);
+   cfc_inc_scan_progress(s, num_bytes);
async->events |= COMEDI_CB_BLOCK;
 
return num_bytes;
diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index 2d57ad4..541b937 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -24,6 +24,7 @@
 #include "../comedidev.h"
 
 unsigned int cfc_bytes_per_scan(struct comedi_subdevice *);
+void cfc_inc_scan_progress(struct comedi_subdevice *, unsigned int num_bytes);
 
 /* Writes an array of data points to comedi's buffer */
 unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *,
-- 
1.8.5.2

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


[PATCH 15/31] staging: comedi: das16m1: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

In the Kconfig, COMEDI_DAS16M1 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/das16m1.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das16m1.c 
b/drivers/staging/comedi/drivers/das16m1.c
index 0a90ab3..70aecbc 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -449,8 +449,8 @@ static void das16m1_handler(struct comedi_device *dev, 
unsigned int status)
devpriv->adc_count += num_samples;
 
if (cmd->stop_src == TRIG_COUNT) {
-   if (devpriv->adc_count >= cmd->stop_arg * cmd->chanlist_len) {  
/* end of acquisition */
-   das16m1_cancel(dev, s);
+   if (devpriv->adc_count >= cmd->stop_arg * cmd->chanlist_len) {
+   /* end of acquisition */
async->events |= COMEDI_CB_EOA;
}
}
@@ -458,13 +458,11 @@ static void das16m1_handler(struct comedi_device *dev, 
unsigned int status)
/* this probably won't catch overruns since the card doesn't generate
 * overrun interrupts, but we might as well try */
if (status & OVRUN) {
-   das16m1_cancel(dev, s);
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_error(dev, "fifo overflow");
}
 
-   comedi_event(dev, s);
-
+   cfc_handle_events(dev, s);
 }
 
 static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s)
-- 
1.8.5.2

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


[PATCH 03/31] staging: comedi: comedi_fc: rename comedi_subdevice variables

2014-03-07 Thread H Hartley Sweeten
Typically the comedi_subdevice variable is simply named 's'. Rename
the variables in this file.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 88be74f..9bf2d4b 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -22,11 +22,11 @@
 
 #include "comedi_fc.h"
 
-static void increment_scan_progress(struct comedi_subdevice *subd,
+static void increment_scan_progress(struct comedi_subdevice *s,
unsigned int num_bytes)
 {
-   struct comedi_async *async = subd->async;
-   unsigned int scan_length = cfc_bytes_per_scan(subd);
+   struct comedi_async *async = s->async;
+   unsigned int scan_length = cfc_bytes_per_scan(s);
 
async->scan_progress += num_bytes;
if (async->scan_progress >= scan_length) {
@@ -36,10 +36,10 @@ static void increment_scan_progress(struct comedi_subdevice 
*subd,
 }
 
 /* Writes an array of data points to comedi's buffer */
-unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd,
+unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s,
   void *data, unsigned int num_bytes)
 {
-   struct comedi_async *async = subd->async;
+   struct comedi_async *async = s->async;
unsigned int retval;
 
if (num_bytes == 0)
@@ -47,24 +47,24 @@ unsigned int cfc_write_array_to_buffer(struct 
comedi_subdevice *subd,
 
retval = comedi_buf_write_alloc(async, num_bytes);
if (retval != num_bytes) {
-   dev_warn(subd->device->class_dev, "comedi: buffer overrun\n");
+   dev_warn(s->device->class_dev, "comedi: buffer overrun\n");
async->events |= COMEDI_CB_OVERFLOW;
return 0;
}
 
comedi_buf_memcpy_to(async, 0, data, num_bytes);
comedi_buf_write_free(async, num_bytes);
-   increment_scan_progress(subd, num_bytes);
+   increment_scan_progress(s, num_bytes);
async->events |= COMEDI_CB_BLOCK;
 
return num_bytes;
 }
 EXPORT_SYMBOL_GPL(cfc_write_array_to_buffer);
 
-unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd,
+unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *s,
void *data, unsigned int num_bytes)
 {
-   struct comedi_async *async = subd->async;
+   struct comedi_async *async = s->async;
 
if (num_bytes == 0)
return 0;
@@ -72,7 +72,7 @@ unsigned int cfc_read_array_from_buffer(struct 
comedi_subdevice *subd,
num_bytes = comedi_buf_read_alloc(async, num_bytes);
comedi_buf_memcpy_from(async, 0, data, num_bytes);
comedi_buf_read_free(async, num_bytes);
-   increment_scan_progress(subd, num_bytes);
+   increment_scan_progress(s, num_bytes);
async->events |= COMEDI_CB_BLOCK;
 
return num_bytes;
@@ -80,17 +80,17 @@ unsigned int cfc_read_array_from_buffer(struct 
comedi_subdevice *subd,
 EXPORT_SYMBOL_GPL(cfc_read_array_from_buffer);
 
 unsigned int cfc_handle_events(struct comedi_device *dev,
-  struct comedi_subdevice *subd)
+  struct comedi_subdevice *s)
 {
-   unsigned int events = subd->async->events;
+   unsigned int events = s->async->events;
 
if (events == 0)
return events;
 
if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
-   subd->cancel(dev, subd);
+   s->cancel(dev, s);
 
-   comedi_event(dev, subd);
+   comedi_event(dev, s);
 
return events;
 }
-- 
1.8.5.2

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


[PATCH 19/31] staging: comedi: ni_at_a2150: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Also, remove the clearing of the events, comedi_event() does that.

In the Kconfig, COMEDI_NI_AT_A2150 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_at_a2150.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c 
b/drivers/staging/comedi/drivers/ni_at_a2150.c
index 740f149..4e39b1f 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -184,7 +184,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
}
/*  initialize async here to make sure s is not NULL */
async = s->async;
-   async->events = 0;
cmd = &async->cmd;
 
status = inw(dev->iobase + STATUS_REG);
@@ -196,15 +195,14 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
 
if (status & OVFL_BIT) {
comedi_error(dev, "fifo overflow");
-   a2150_cancel(dev, s);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
+   cfc_handle_events(dev, s);
}
 
if ((status & DMA_TC_BIT) == 0) {
comedi_error(dev, "caught non-dma interrupt?  Aborting.");
-   a2150_cancel(dev, s);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
}
 
@@ -249,7 +247,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
cfc_write_to_buffer(s, dpnt);
if (cmd->stop_src == TRIG_COUNT) {
if (--devpriv->count == 0) {/* end of acquisition */
-   a2150_cancel(dev, s);
async->events |= COMEDI_CB_EOA;
break;
}
@@ -265,7 +262,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
 
async->events |= COMEDI_CB_BLOCK;
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 
/* clear interrupt */
outw(0x00, dev->iobase + DMA_TC_CLEAR_REG);
-- 
1.8.5.2

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


[PATCH 02/31] staging: comedi: comedi_fc: tidy up multi-line comment

2014-03-07 Thread H Hartley Sweeten
Tidy up the multi-line comment to follow the CodingStyle.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.c | 36 ++
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index c53d9e6..88be74f 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -1,23 +1,21 @@
 /*
-comedi/drivers/comedi_fc.c
-
-This is a place for code driver writers wish to share between
-two or more drivers.  fc is short
-for frank-common.
-
-Author:  Frank Mori Hess 
-Copyright (C) 2002 Frank Mori Hess
-
-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.
-*/
+ * comedi_fc.c
+ * This is a place for code driver writers wish to share between
+ * two or more drivers.  fc is short for frank-common.
+ *
+ * Author: Frank Mori Hess 
+ * Copyright (C) 2002 Frank Mori Hess
+ *
+ * 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 
 #include "../comedidev.h"
-- 
1.8.5.2

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


[PATCH 25/31] staging: comedi: pcl818: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig so that COMEDI_PCL818 selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig  | 1 +
 drivers/staging/comedi/drivers/pcl818.c | 7 +--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index df7010b..2fb0cc0 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -199,6 +199,7 @@ config COMEDI_PCL816
 config COMEDI_PCL818
tristate "Advantech PCL-718 and PCL-818 ISA card support"
depends on VIRT_TO_BUS && ISA_DMA_API
+   select COMEDI_FC
---help---
  Enable support for Advantech PCL-818 ISA cards
  PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718
diff --git a/drivers/staging/comedi/drivers/pcl818.c 
b/drivers/staging/comedi/drivers/pcl818.c
index d4d5c38..6463476 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -510,7 +510,6 @@ static bool pcl818_ai_dropout(struct comedi_device *dev,
(devpriv->dma) ? "DMA" :
(devpriv->usefifo) ? "FIFO" : "IRQ",
chan, expected_chan);
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
return true;
}
@@ -538,7 +537,6 @@ static bool pcl818_ai_next_chan(struct comedi_device *dev,
 
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan == 0) {
/* all data sampled */
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
return false;
}
@@ -554,7 +552,6 @@ static void pcl818_handle_eoc(struct comedi_device *dev,
 
if (pcl818_ai_eoc(dev, s, NULL, 0)) {
comedi_error(dev, "A/D mode1/3 IRQ without DRDY!");
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
return;
}
@@ -612,14 +609,12 @@ static void pcl818_handle_fifo(struct comedi_device *dev,
 
if (status & 4) {
comedi_error(dev, "A/D mode1/3 FIFO overflow!");
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
return;
}
 
if (status & 1) {
comedi_error(dev, "A/D mode1/3 FIFO interrupt without data!");
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
return;
}
@@ -674,7 +669,7 @@ static irqreturn_t pcl818_interrupt(int irq, void *d)
 
pcl818_ai_clear_eoc(dev);
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
-- 
1.8.5.2

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


[PATCH 17/31] staging: comedi: das1800: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

In the Kconfig, COMEDI_DAS1800 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/das1800.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c 
b/drivers/staging/comedi/drivers/das1800.c
index 320d95a..9f353cf 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -665,9 +665,8 @@ static void das1800_ai_handler(struct comedi_device *dev)
/*  clear OVF interrupt bit */
outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS);
comedi_error(dev, "DAS1800 FIFO overflow");
-   das1800_cancel(dev, s);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
/*  stop taking data if appropriate */
@@ -680,16 +679,12 @@ static void das1800_ai_handler(struct comedi_device *dev)
das1800_flush_dma(dev, s);
else
das1800_handle_fifo_not_empty(dev, s);
-   das1800_cancel(dev, s); /* disable hardware conversions */
async->events |= COMEDI_CB_EOA;
} else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) {
/*  stop_src TRIG_COUNT */
-   das1800_cancel(dev, s); /* disable hardware conversions */
async->events |= COMEDI_CB_EOA;
}
 
-   comedi_event(dev, s);
-
-   return;
+   cfc_handle_events(dev, s);
 }
 
 static int das1800_ai_poll(struct comedi_device *dev,
-- 
1.8.5.2

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


[PATCH 06/31] staging: comedi: comedi_fc: remove 'extern' from function prototypes

2014-03-07 Thread H Hartley Sweeten
The 'extern' is not needed in the prototypes for the exported functions
in the header. Remove it.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.h | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index ad96c6a..a5b9d11 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -24,9 +24,8 @@
 #include "../comedidev.h"
 
 /* Writes an array of data points to comedi's buffer */
-extern unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd,
- void *data,
- unsigned int num_bytes);
+unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *,
+  void *data, unsigned int num_bytes);
 
 static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *subd,
   unsigned short data)
@@ -40,12 +39,11 @@ static inline unsigned int cfc_write_long_to_buffer(struct 
comedi_subdevice
return cfc_write_array_to_buffer(subd, &data, sizeof(data));
 };
 
-extern unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd,
-  void *data,
-  unsigned int num_bytes);
+unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *,
+   void *data, unsigned int num_bytes);
 
-extern unsigned int cfc_handle_events(struct comedi_device *dev,
- struct comedi_subdevice *subd);
+unsigned int cfc_handle_events(struct comedi_device *,
+  struct comedi_subdevice *);
 
 static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *subd)
 {
-- 
1.8.5.2

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


[PATCH 13/31] staging: comedi: adl_pci9111: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

In the Kconfig, COMEDI_ADL_PCI9111 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/adl_pci9111.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c 
b/drivers/staging/comedi/drivers/adl_pci9111.c
index 80a0560..a29ceac 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -592,9 +592,8 @@ static irqreturn_t pci9111_interrupt(int irq, void 
*p_device)
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow");
outb(0, dev->iobase + PCI9111_INT_CLR_REG);
-   pci9111_ai_cancel(dev, s);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 
return IRQ_HANDLED;
}
@@ -672,16 +671,14 @@ static irqreturn_t pci9111_interrupt(int irq, void 
*p_device)
}
}
 
-   if ((dev_private->stop_counter == 0) && (!dev_private->stop_is_none)) {
+   if (dev_private->stop_counter == 0 && !dev_private->stop_is_none)
async->events |= COMEDI_CB_EOA;
-   pci9111_ai_cancel(dev, s);
-   }
 
outb(0, dev->iobase + PCI9111_INT_CLR_REG);
 
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 
return IRQ_HANDLED;
 }
-- 
1.8.5.2

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


[PATCH 20/31] staging: comedi: ni_mio_common: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
The ni_event() function in this file is an open coded version of
cfc_handle_events() where instead of calling the subdevice (*cancel)
function a switch is used to call the function based on the subdevice
'index'.

Use the comedi_fc helper function to simplify the code.

This also allows removing a couple of the forward declarations.

Fix the #ifdef/#endif for the ni_gpct_cancel() foward declaration and
around the function. This function is now only referenced by code that
is blocked with #ifdef PCIDMA.

This source file is included by the ni_atmio, ni_mio_cs, and ni_pcimio
drivers. In the Kconfig, the config options for these drivers already
select COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 52 +-
 1 file changed, 9 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 3a86d48..8a0e3b7 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -256,7 +256,6 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
 static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice 
*s);
 static int ni_read_eeprom(struct comedi_device *dev, int addr);
 
-static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s);
 #ifndef PCIDMA
 static void ni_handle_fifo_half_full(struct comedi_device *dev);
 static int ni_ao_fifo_half_empty(struct comedi_device *dev,
@@ -272,15 +271,12 @@ static void shutdown_ai_command(struct comedi_device 
*dev);
 static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
 unsigned int trignum);
 
-static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s);
-
 static int ni_8255_callback(int dir, int port, int data, unsigned long arg);
 
 #ifdef PCIDMA
 static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice 
*s);
 #endif
-static int ni_gpct_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
 static void handle_gpct_interrupt(struct comedi_device *dev,
  unsigned short counter_index);
 
@@ -947,32 +943,6 @@ static void shutdown_ai_command(struct comedi_device *dev)
s->async->events |= COMEDI_CB_EOA;
 }
 
-static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-   if (s->
-   async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW |
-COMEDI_CB_EOA)) {
-   switch (s->index) {
-   case NI_AI_SUBDEV:
-   ni_ai_reset(dev, s);
-   break;
-   case NI_AO_SUBDEV:
-   ni_ao_reset(dev, s);
-   break;
-   case NI_GPCT0_SUBDEV:
-   case NI_GPCT1_SUBDEV:
-   ni_gpct_cancel(dev, s);
-   break;
-   case NI_DIO_SUBDEV:
-   ni_cdio_cancel(dev, s);
-   break;
-   default:
-   break;
-   }
-   }
-   comedi_event(dev, s);
-}
-
 static void handle_gpct_interrupt(struct comedi_device *dev,
  unsigned short counter_index)
 {
@@ -984,8 +954,7 @@ static void handle_gpct_interrupt(struct comedi_device *dev,
 
ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index],
s);
-   if (s->async->events)
-   ni_event(dev, s);
+   cfc_handle_events(dev, s);
 #endif
 }
 
@@ -1043,7 +1012,7 @@ static void handle_a_interrupt(struct comedi_device *dev, 
unsigned short status,
if (comedi_is_subdevice_running(s)) {
s->async->events |=
COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   ni_event(dev, s);
+   cfc_handle_events(dev, s);
}
return;
}
@@ -1058,8 +1027,7 @@ static void handle_a_interrupt(struct comedi_device *dev, 
unsigned short status,
if (status & (AI_Overrun_St | AI_Overflow_St))
s->async->events |= COMEDI_CB_OVERFLOW;
 
-   ni_event(dev, s);
-
+   cfc_handle_events(dev, s);
return;
}
if (status & AI_SC_TC_St) {
@@ -1086,7 +1054,7 @@ static void handle_a_interrupt(struct comedi_device *dev, 
unsigned short status,
if ((status & AI_STOP_St))
ni_handle_eos(dev, s);
 
-   ni_event(dev, s);
+   cfc_handle_events(dev, s);
 }
 
 static void ack_b_interrupt(struct comed

[PATCH 31/31] staging: comedi: drivers should not clear the async->events

2014-03-07 Thread H Hartley Sweeten
The comedi core resets the async->events in comedi_buf_reset() which is
called when the subdevice is restored to an idle state and at the start
of an async command. The async->events are also cleared after handling
the events in comedi_event().

Drivers should not clear the events manually.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 --
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 1 -
 drivers/staging/comedi/drivers/adl_pci9118.c  | 2 --
 drivers/staging/comedi/drivers/comedi_test.c  | 1 -
 drivers/staging/comedi/drivers/das16m1.c  | 1 -
 drivers/staging/comedi/drivers/das1800.c  | 1 -
 drivers/staging/comedi/drivers/das800.c   | 1 -
 drivers/staging/comedi/drivers/gsc_hpdi.c | 2 --
 drivers/staging/comedi/drivers/me4000.c   | 3 ---
 9 files changed, 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 bd05857..978cc57 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1574,8 +1574,6 @@ static int i_APCI3120_InterruptHandleEos(struct 
comedi_device *dev)
 
n_chan = devpriv->ui_AiNbrofChannels;
 
-   s->async->events = 0;
-
for (i = 0; i < n_chan; i++)
err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
 
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index 8c85a09..89ffc1f 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -2619,7 +2619,6 @@ static int i_APCI3200_InterruptHandleEos(struct 
comedi_device *dev)
/* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 
0.7.68 */
/* This value is not used */
/* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos 
[dev->minor].i_Offset + 24); */
-   s->async->events = 0;
/* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 
*/
 
   /*/
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 980ce49..3cfa175 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -955,8 +955,6 @@ static void interrupt_pci9118_ai_onesample(struct 
comedi_device *dev,
struct pci9118_private *devpriv = dev->private;
unsigned short sampl;
 
-   s->async->events = 0;
-
if (int_adstat & devpriv->ai_maskerr)
if (pci9118_decode_error_status(dev, s, int_adstat))
return;
diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 3f59666..cd95625 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -185,7 +185,6 @@ static void waveform_ai_interrupt(unsigned long arg)
(devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
devpriv->usec_remainder =
(devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
-   async->events = 0;
 
if (cmd->stop_src == TRIG_COUNT) {
unsigned int remaining = cmd->stop_arg - devpriv->ai_count;
diff --git a/drivers/staging/comedi/drivers/das16m1.c 
b/drivers/staging/comedi/drivers/das16m1.c
index 70aecbc..7792258 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -416,7 +416,6 @@ static void das16m1_handler(struct comedi_device *dev, 
unsigned int status)
 
s = dev->read_subdev;
async = s->async;
-   async->events = 0;
cmd = &async->cmd;
 
/*  figure out how many samples are in fifo */
diff --git a/drivers/staging/comedi/drivers/das1800.c 
b/drivers/staging/comedi/drivers/das1800.c
index 9f353cf..8e975d6 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -646,7 +646,6 @@ static void das1800_ai_handler(struct comedi_device *dev)
struct comedi_cmd *cmd = &async->cmd;
unsigned int status = inb(dev->iobase + DAS1800_STATUS);
 
-   async->events = 0;
/*  select adc for base address + 0 */
outb(ADC, dev->iobase + DAS1800_SELECT);
/*  dma buffer full */
diff --git a/drivers/staging/comedi/drivers/das800.c 
b/drivers/staging/comedi/drivers/das800.c
index a4fb3d6..3e40837 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -448,7 +448,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
das800_ind_write(dev, conv_bits, CONV_CONTROL)

[PATCH 22/31] staging: comedi: cb_pcidas: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Also, remove the clearing of the events, comedi_event() does that.

In the Kconfig, COMEDI_CB_PCIDAS already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/cb_pcidas.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c 
b/drivers/staging/comedi/drivers/cb_pcidas.c
index 5452b71..83a265f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -1277,8 +1277,6 @@ static void handle_ao_interrupt(struct comedi_device 
*dev, unsigned int status)
unsigned int num_points;
unsigned long flags;
 
-   async->events = 0;
-
if (status & DAEMI) {
/*  clear dac empty interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
@@ -1290,7 +1288,6 @@ static void handle_ao_interrupt(struct comedi_device 
*dev, unsigned int status)
(cmd->stop_src == TRIG_COUNT
 && devpriv->ao_count)) {
comedi_error(dev, "dac fifo underflow");
-   cb_pcidas_ao_cancel(dev, s);
async->events |= COMEDI_CB_ERROR;
}
async->events |= COMEDI_CB_EOA;
@@ -1320,7 +1317,7 @@ static void handle_ao_interrupt(struct comedi_device 
*dev, unsigned int status)
spin_unlock_irqrestore(&dev->spinlock, flags);
}
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 }
 
 static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
@@ -1340,7 +1337,6 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
return IRQ_NONE;
 
async = s->async;
-   async->events = 0;
 
s5933_status = inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR);
 
@@ -1372,10 +1368,8 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
cfc_write_array_to_buffer(s, devpriv->ai_buffer,
  num_samples * sizeof(short));
devpriv->count -= num_samples;
-   if (async->cmd.stop_src == TRIG_COUNT && devpriv->count == 0) {
+   if (async->cmd.stop_src == TRIG_COUNT && devpriv->count == 0)
async->events |= COMEDI_CB_EOA;
-   cb_pcidas_cancel(dev, s);
-   }
/*  clear half-full interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | INT,
@@ -1392,7 +1386,6 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
if (async->cmd.stop_src == TRIG_COUNT &&
--devpriv->count == 0) {
/* end of acquisition */
-   cb_pcidas_cancel(dev, s);
async->events |= COMEDI_CB_EOA;
break;
}
@@ -1419,11 +1412,10 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
outw(devpriv->adc_fifo_bits | LADFUL,
 devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
-   cb_pcidas_cancel(dev, s);
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 
return IRQ_HANDLED;
 }
-- 
1.8.5.2

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


[PATCH 26/31] staging: comedi: ni_660x: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function instead of duplicating the code.

In the Kconfig, COMEDI_NI_660X selects COMEDI_FC indirectly by selecting
COMEDI_NI_TIOCMD which selects COMEDI_MITE which selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_660x.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_660x.c 
b/drivers/staging/comedi/drivers/ni_660x.c
index b8c3fbe..0d4b901 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -40,6 +40,7 @@
 
 #include "../comedidev.h"
 
+#include "comedi_fc.h"
 #include "mite.h"
 #include "ni_tio.h"
 
@@ -789,13 +790,7 @@ static void ni_660x_handle_gpct_interrupt(struct 
comedi_device *dev,
struct ni_gpct *counter = s->private;
 
ni_tio_handle_interrupt(counter, s);
-   if (s->async->events) {
-   if (s->async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
-   COMEDI_CB_OVERFLOW)) {
-   ni_660x_cancel(dev, s);
-   }
-   comedi_event(dev, s);
-   }
+   cfc_handle_events(dev, s);
 }
 
 static irqreturn_t ni_660x_interrupt(int irq, void *d)
-- 
1.8.5.2

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


[PATCH 01/31] staging: comedi: comedi_fc: tidy up module init

2014-03-07 Thread H Hartley Sweeten
For aesthetics, move the MODULE_* information to the end of the file
and move the module_{init,exit}() after the functions.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 26d9dbc..c53d9e6 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -98,18 +98,17 @@ unsigned int cfc_handle_events(struct comedi_device *dev,
 }
 EXPORT_SYMBOL_GPL(cfc_handle_events);
 
-MODULE_AUTHOR("Frank Mori Hess ");
-MODULE_DESCRIPTION("Shared functions for Comedi low-level drivers");
-MODULE_LICENSE("GPL");
-
 static int __init comedi_fc_init_module(void)
 {
return 0;
 }
+module_init(comedi_fc_init_module);
 
 static void __exit comedi_fc_cleanup_module(void)
 {
 }
-
-module_init(comedi_fc_init_module);
 module_exit(comedi_fc_cleanup_module);
+
+MODULE_AUTHOR("Frank Mori Hess ");
+MODULE_DESCRIPTION("Shared functions for Comedi low-level drivers");
+MODULE_LICENSE("GPL");
-- 
1.8.5.2

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


[PATCH 08/31] staging: comedi: comedi_fc: tidy up cfc_bytes_per_scan()

2014-03-07 Thread H Hartley Sweeten
This function returns the total number of bytes for a full scan of
an async command chanlist. The returned value is an unsigned int.

Change all the local variables to unsigned int and use a local
variable for the s->async->cmd.chanlist_len.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/comedi_fc.h | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index 042bf87..b8d125e 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -47,19 +47,20 @@ unsigned int cfc_handle_events(struct comedi_device *,
 
 static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
 {
-   int num_samples;
-   int bits_per_sample;
+   unsigned int chanlist_len = s->async->cmd.chanlist_len;
+   unsigned int num_samples;
+   unsigned int bits_per_sample;
 
switch (s->type) {
case COMEDI_SUBD_DI:
case COMEDI_SUBD_DO:
case COMEDI_SUBD_DIO:
bits_per_sample = 8 * bytes_per_sample(s);
-   num_samples = (s->async->cmd.chanlist_len +
-  bits_per_sample - 1) / bits_per_sample;
+   num_samples = (chanlist_len + bits_per_sample - 1) /
+   bits_per_sample;
break;
default:
-   num_samples = s->async->cmd.chanlist_len;
+   num_samples = chanlist_len;
break;
}
return num_samples * bytes_per_sample(s);
-- 
1.8.5.2

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


[PATCH 29/31] staging: comedi: ni_pcidio: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function instead of duplicating the code.

In the Kconfig, COMEDI_NI_PCIDIO selects COMEDI_FC indirectly by
selecting COMEDI_MITE which selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_pcidio.c | 16 +---
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c 
b/drivers/staging/comedi/drivers/ni_pcidio.c
index 30c46a3..85ac2d9 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -263,9 +263,6 @@ enum FPGA_Control_Bits {
 #define IntEn (TransferReady|CountExpired|Waited|PrimaryTC|SecondaryTC)
 #endif
 
-static int ni_pcidio_cancel(struct comedi_device *dev,
-   struct comedi_subdevice *s);
-
 enum nidio_boardid {
BOARD_PCIDIO_32HS,
BOARD_PXI6533,
@@ -353,17 +350,6 @@ static void ni_pcidio_release_di_mite_channel(struct 
comedi_device *dev)
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
 }
 
-static void ni_pcidio_event(struct comedi_device *dev,
-   struct comedi_subdevice *s)
-{
-   if (s->
-   async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
-COMEDI_CB_OVERFLOW)) {
-   ni_pcidio_cancel(dev, s);
-   }
-   comedi_event(dev, s);
-}
-
 static int ni_pcidio_poll(struct comedi_device *dev, struct comedi_subdevice 
*s)
 {
struct nidio96_private *devpriv = dev->private;
@@ -501,7 +487,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
}
 
 out:
-   ni_pcidio_event(dev, s);
+   cfc_handle_events(dev, s);
 #if 0
if (!tag) {
writeb(0x03,
-- 
1.8.5.2

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


[PATCH 09/31] staging: comedi: comedi_fc: export cfc_bytes_per_scan()

2014-03-07 Thread H Hartley Sweeten
This helper function is a bit long to be inlined. Move it to the
source file and export it.

The mite driver is the only external user right now. Update the
Kconfig to select COMEDI_FC when COMEDI_MITE is enabled.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig |  1 +
 drivers/staging/comedi/drivers/comedi_fc.c | 22 ++
 drivers/staging/comedi/drivers/comedi_fc.h | 23 ++-
 3 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 89e25b4..b89b145 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1101,6 +1101,7 @@ config COMEDI_S626
 
 config COMEDI_MITE
depends on HAS_DMA
+   select COMEDI_FC
tristate
 
 config COMEDI_NI_TIOCMD
diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 157b61c..5d8aa80 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -22,6 +22,28 @@
 
 #include "comedi_fc.h"
 
+unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
+{
+   unsigned int chanlist_len = s->async->cmd.chanlist_len;
+   unsigned int num_samples;
+   unsigned int bits_per_sample;
+
+   switch (s->type) {
+   case COMEDI_SUBD_DI:
+   case COMEDI_SUBD_DO:
+   case COMEDI_SUBD_DIO:
+   bits_per_sample = 8 * bytes_per_sample(s);
+   num_samples = (chanlist_len + bits_per_sample - 1) /
+   bits_per_sample;
+   break;
+   default:
+   num_samples = chanlist_len;
+   break;
+   }
+   return num_samples * bytes_per_sample(s);
+}
+EXPORT_SYMBOL_GPL(cfc_bytes_per_scan);
+
 static void increment_scan_progress(struct comedi_subdevice *s,
unsigned int num_bytes)
 {
diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index b8d125e..2d57ad4 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -23,6 +23,8 @@
 
 #include "../comedidev.h"
 
+unsigned int cfc_bytes_per_scan(struct comedi_subdevice *);
+
 /* Writes an array of data points to comedi's buffer */
 unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *,
   void *data, unsigned int num_bytes);
@@ -45,27 +47,6 @@ unsigned int cfc_read_array_from_buffer(struct 
comedi_subdevice *,
 unsigned int cfc_handle_events(struct comedi_device *,
   struct comedi_subdevice *);
 
-static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
-{
-   unsigned int chanlist_len = s->async->cmd.chanlist_len;
-   unsigned int num_samples;
-   unsigned int bits_per_sample;
-
-   switch (s->type) {
-   case COMEDI_SUBD_DI:
-   case COMEDI_SUBD_DO:
-   case COMEDI_SUBD_DIO:
-   bits_per_sample = 8 * bytes_per_sample(s);
-   num_samples = (chanlist_len + bits_per_sample - 1) /
-   bits_per_sample;
-   break;
-   default:
-   num_samples = chanlist_len;
-   break;
-   }
-   return num_samples * bytes_per_sample(s);
-}
-
 /**
  * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
  * @src: pointer to the trigger source to validate
-- 
1.8.5.2

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


[PATCH 00/31] staging: comedi: comedi_fc: tidy up and use

2014-03-07 Thread H Hartley Sweeten
This module has a number of helper functions for common operations in
comedi drivers. Tidy it up and then use the helpers in the drivers to
remove some of the duplicate code.

H Hartley Sweeten (31):
  staging: comedi: comedi_fc: tidy up module init
  staging: comedi: comedi_fc: tidy up multi-line comment
  staging: comedi: comedi_fc: rename comedi_subdevice variables
  staging: comedi: comedi_fc: remove unnecessary prefix in dev_warn() message
  staging: comedi: comedi_fc: tidy up multi-line comment in header
  staging: comedi: comedi_fc: remove 'extern' from function prototypes
  staging: comedi: comedi_fc: rename comedi_subdevice variables in header
  staging: comedi: comedi_fc: tidy up cfc_bytes_per_scan()
  staging: comedi: comedi_fc: export cfc_bytes_per_scan()
  staging: comedi: comedi_fc: export increment_scan_progress()
  staging: comedi: mite: use cfc_inc_scan_progress()
  staging: comedi: adl_pci9118: use cfc_handle_events()
  staging: comedi: adl_pci9111: use cfc_handle_events()
  staging: comedi: adv_pci1710: use cfc_handle_events()
  staging: comedi: das16m1: use cfc_handle_events()
  staging: comedi: das800: use cfc_handle_events()
  staging: comedi: das1800: use cfc_handle_events()
  staging: comedi: dt282x: use cfc_handle_events()
  staging: comedi: ni_at_a2150: use cfc_handle_events()
  staging: comedi: ni_mio_common: use cfc_handle_events()
  staging: comedi: amplc_pci224: use cfc_handle_events()
  staging: comedi: cb_pcidas: use cfc_handle_events()
  staging: comedi: pcl812: use cfc_handle_events()
  staging: comedi: pcl816: use cfc_handle_events()
  staging: comedi: pcl818: use cfc_handle_events()
  staging: comedi: ni_660x: use cfc_handle_events()
  staging: comedi: dt3000: use cfc_handle_events()
  staging: comedi: ni_labpc: use cfc_handle_events()
  staging: comedi: ni_pcidio: use cfc_handle_events()
  staging: comedi: quatech_daqp_cs: use cfc_handle_events()
  staging: comedi: drivers should not clear the async->events

 drivers/staging/comedi/Kconfig |  7 ++
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  |  2 -
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  |  1 -
 drivers/staging/comedi/drivers/adl_pci9111.c   |  9 +-
 drivers/staging/comedi/drivers/adl_pci9118.c   | 37 +++-
 drivers/staging/comedi/drivers/adv_pci1710.c   | 28 +++---
 drivers/staging/comedi/drivers/amplc_pci224.c  | 12 +--
 drivers/staging/comedi/drivers/cb_pcidas.c | 14 +--
 drivers/staging/comedi/drivers/comedi_fc.c | 99 +-
 drivers/staging/comedi/drivers/comedi_fc.h | 84 +++---
 drivers/staging/comedi/drivers/comedi_test.c   |  1 -
 drivers/staging/comedi/drivers/das16m1.c   |  9 +-
 drivers/staging/comedi/drivers/das1800.c   | 10 +--
 drivers/staging/comedi/drivers/das800.c|  8 +-
 drivers/staging/comedi/drivers/dt282x.c| 11 +--
 drivers/staging/comedi/drivers/dt3000.c|  6 +-
 drivers/staging/comedi/drivers/gsc_hpdi.c  |  2 -
 drivers/staging/comedi/drivers/me4000.c|  3 -
 drivers/staging/comedi/drivers/mite.c  | 11 +--
 drivers/staging/comedi/drivers/ni_660x.c   |  9 +-
 drivers/staging/comedi/drivers/ni_at_a2150.c   |  9 +-
 drivers/staging/comedi/drivers/ni_labpc.c  | 12 +--
 drivers/staging/comedi/drivers/ni_mio_common.c | 52 ++--
 drivers/staging/comedi/drivers/ni_pcidio.c | 16 +---
 drivers/staging/comedi/drivers/pcl812.c|  4 +-
 drivers/staging/comedi/drivers/pcl816.c|  5 +-
 drivers/staging/comedi/drivers/pcl818.c|  7 +-
 drivers/staging/comedi/drivers/quatech_daqp_cs.c   |  5 +-
 28 files changed, 172 insertions(+), 301 deletions(-)

-- 
1.8.5.2

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


[PATCH 28/31] staging: comedi: ni_labpc: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Also, remove the clearing of the events, comedi_event() does that.

In the Kconfig, COMEDI_NI_LABPC already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c 
b/drivers/staging/comedi/drivers/ni_labpc.c
index 037b46e..f4216e8 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -947,7 +947,6 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
 
async = s->async;
cmd = &async->cmd;
-   async->events = 0;
 
/* read board status */
devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG);
@@ -965,7 +964,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
/* clear error interrupt */
devpriv->write_byte(0x1, dev->iobase + ADC_FIFO_CLEAR_REG);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
comedi_error(dev, "overrun");
return IRQ_HANDLED;
}
@@ -985,7 +984,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
/*  clear error interrupt */
devpriv->write_byte(0x1, dev->iobase + ADC_FIFO_CLEAR_REG);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
comedi_error(dev, "overflow");
return IRQ_HANDLED;
}
@@ -993,20 +992,17 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
if (cmd->stop_src == TRIG_EXT) {
if (devpriv->stat2 & STAT2_OUTA1) {
labpc_drain_dregs(dev);
-   labpc_cancel(dev, s);
async->events |= COMEDI_CB_EOA;
}
}
 
/* TRIG_COUNT end of acquisition */
if (cmd->stop_src == TRIG_COUNT) {
-   if (devpriv->count == 0) {
-   labpc_cancel(dev, s);
+   if (devpriv->count == 0)
async->events |= COMEDI_CB_EOA;
-   }
}
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
-- 
1.8.5.2

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


[PATCH 18/31] staging: comedi: dt282x: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

This also fixes two bugs.
  1) the analog input command is canceled due to a buffer overflow
 without sending an event (@@ -341,7 +340,7 @@).
  2) an analog output error causes the command to cancel but the event
 is reported to the analog input subdevice (@@ -449,15 +447,13 @@).

In the Kconfig, COMEDI_DT282X already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/dt282x.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index 6cc8f1d..16cc100 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -306,7 +306,6 @@ static void dt282x_ao_dma_interrupt(struct comedi_device 
*dev)
size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
if (size == 0) {
dev_err(dev->class_dev, "AO underrun\n");
-   dt282x_ao_cancel(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW;
return;
}
@@ -341,7 +340,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev)
dt282x_munge(dev, ptr, size);
ret = cfc_write_array_to_buffer(s, ptr, size);
if (ret != size) {
-   dt282x_ai_cancel(dev, s);
+   s->async->events |= COMEDI_CB_OVERFLOW;
return;
}
devpriv->nread -= size / 2;
@@ -351,7 +350,6 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev)
devpriv->nread = 0;
}
if (!devpriv->nread) {
-   dt282x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
return;
}
@@ -449,15 +447,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
if (adcsr & DT2821_ADERR) {
if (devpriv->nread != 0) {
comedi_error(dev, "A/D error");
-   dt282x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_ERROR;
}
handled = 1;
}
if (dacsr & DT2821_DAERR) {
comedi_error(dev, "D/A error");
-   dt282x_ao_cancel(dev, s_ao);
-   s->async->events |= COMEDI_CB_ERROR;
+   s_ao->async->events |= COMEDI_CB_ERROR;
handled = 1;
}
 #if 0
@@ -486,7 +482,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
handled = 1;
}
 #endif
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
+   cfc_handle_events(dev, s_ao);
 
return IRQ_RETVAL(handled);
 }
-- 
1.8.5.2

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


[PATCH 16/31] staging: comedi: das800: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Also, remove the clearing of the event, comedi_event() does that.

In the Kconfig, COMEDI_DAS800 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/das800.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das800.c 
b/drivers/staging/comedi/drivers/das800.c
index 8c15929..a4fb3d6 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -521,10 +521,8 @@ static irqreturn_t das800_interrupt(int irq, void *d)
 
if (fifo_overflow) {
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
-   das800_cancel(dev, s);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   comedi_event(dev, s);
-   async->events = 0;
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
}
 
@@ -540,8 +538,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
das800_disable(dev);
async->events |= COMEDI_CB_EOA;
}
-   comedi_event(dev, s);
-   async->events = 0;
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
-- 
1.8.5.2

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


[PATCH 24/31] staging: comedi: pcl816: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig so that COMEDI_PCL816 selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig  | 1 +
 drivers/staging/comedi/drivers/pcl816.c | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 627c67b..df7010b 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -189,6 +189,7 @@ config COMEDI_PCL812
 config COMEDI_PCL816
tristate "Advantech PCL-814 and PCL-816 ISA card support"
depends on VIRT_TO_BUS && ISA_DMA_API
+   select COMEDI_FC
---help---
  Enable support for Advantech PCL-814 and PCL-816 ISA cards
 
diff --git a/drivers/staging/comedi/drivers/pcl816.c 
b/drivers/staging/comedi/drivers/pcl816.c
index 6386ef7..6f276f2 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -307,7 +307,6 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev,
if (cmd->stop_src == TRIG_COUNT &&
devpriv->ai_act_scan >= cmd->stop_arg) {
/* all data sampled */
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
return false;
}
@@ -362,7 +361,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
 
pcl816_ai_clear_eoc(dev);
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
@@ -520,7 +519,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct 
comedi_subdevice *s)
devpriv->ai_poll_ptr = top1;/*  new buffer position */
spin_unlock_irqrestore(&dev->spinlock, flags);
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 
return s->async->buf_write_count - s->async->buf_read_count;
 }
-- 
1.8.5.2

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


[PATCH 21/31] staging: comedi: amplc_pci224: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

In the Kconfig, COMEDI_AMPLC_PCI224 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/amplc_pci224.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c 
b/drivers/staging/comedi/drivers/amplc_pci224.c
index 8be36b8..29e01e2 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -533,9 +533,8 @@ static void pci224_ao_start(struct comedi_device *dev,
set_bit(AO_CMD_STARTED, &devpriv->state);
if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) {
/* An empty acquisition! */
-   pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
} else {
/* Enable interrupts. */
spin_lock_irqsave(&devpriv->ao_spinlock, flags);
@@ -585,9 +584,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
room = PCI224_FIFO_ROOM_EMPTY;
if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 
0) {
/* FIFO empty at end of counted acquisition. */
-   pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
break;
@@ -605,9 +603,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
/* FIFO is less than half-full. */
if (num_scans == 0) {
/* Nothing left to put in the FIFO. */
-   pci224_ao_stop(dev, s);
-   s->async->events |= COMEDI_CB_OVERFLOW;
dev_err(dev->class_dev, "AO buffer underrun\n");
+   s->async->events |= COMEDI_CB_OVERFLOW;
}
}
/* Determine how many new scans can be put in the FIFO. */
@@ -670,9 +667,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
  PCI224_DACCON_TRIG_MASK);
outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
}
-   if (s->async->events)
-   comedi_event(dev, s);
 
+   cfc_handle_events(dev, s);
 }
 
 /*
-- 
1.8.5.2

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


[PATCH 14/31] staging: comedi: adv_pci1710: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig to select COMEDI_FC when COMEDI_ADL_PCI9111 is enabled.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig   |  1 +
 drivers/staging/comedi/drivers/adv_pci1710.c | 28 ++--
 2 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index b89b145..8076734 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -753,6 +753,7 @@ config COMEDI_ADL_PCI9118
 
 config COMEDI_ADV_PCI1710
tristate "Advantech PCI-171x, PCI-1720 and PCI-1731 support"
+   select COMEDI_FC
---help---
  Enable support for Advantech PCI-1710, PCI-1710HG, PCI-1711,
  PCI-1713, PCI-1720 and PCI-1731
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c 
b/drivers/staging/comedi/drivers/adv_pci1710.c
index 5978ae6..28ec485 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -759,17 +759,15 @@ static void interrupt_pci1710_every_sample(void *d)
m = inw(dev->iobase + PCI171x_STATUS);
if (m & Status_FE) {
dev_dbg(dev->class_dev, "A/D FIFO empty (%4x)\n", m);
-   pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
if (m & Status_FF) {
dev_dbg(dev->class_dev,
"A/D FIFO Full status (Fatal Error!) (%4x)\n", m);
-   pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
 
@@ -788,10 +786,9 @@ static void interrupt_pci1710_every_sample(void *d)
  act_chanlist[s->
   async->cur_chan] & 0xf000) >>
 12);
-   pci171x_ai_cancel(dev, s);
s->async->events |=
COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
comedi_buf_put(s->async, sampl & 0x0fff);
@@ -810,9 +807,8 @@ static void interrupt_pci1710_every_sample(void *d)
if ((!devpriv->neverending_ai) &&
(devpriv->ai_act_scan >= devpriv->ai_scans)) {
/*  all data sampled */
-   pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
}
@@ -820,7 +816,7 @@ static void interrupt_pci1710_every_sample(void *d)
 
outb(0, dev->iobase + PCI171x_CLRINT);  /*  clear our INT request */
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 }
 
 /*
@@ -848,10 +844,9 @@ static int move_block_from_fifo(struct comedi_device *dev,
(devpriv->act_chanlist[j] & 0xf000) >> 
12,
i, j, devpriv->ai_act_scan, n, turn,
sampl);
-   pci171x_ai_cancel(dev, s);
s->async->events |=
COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return 1;
}
comedi_buf_put(s->async, sampl & 0x0fff);
@@ -883,17 +878,15 @@ static void interrupt_pci1710_half_fifo(void *d)
m = inw(dev->iobase + PCI171x_STATUS);
if (!(m & Status_FH)) {
dev_dbg(dev->class_dev, "A/D FIFO not half full! (%4x)\n", m);
-   pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
if (m & Status_FF) {
dev_dbg(dev->class_dev,
"A/D FIFO Full status (Fatal Error!) (%4x)\n", m);
-   pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);

[PATCH 12/31] staging: comedi: adl_pci9118: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

In the Kconfig, COMEDI_ADL_PCI9118 already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/adl_pci9118.c | 35 +++-
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 6ca6c42..980ce49 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -919,8 +919,7 @@ static char pci9118_decode_error_status(struct 
comedi_device *dev,
}
if (m & devpriv->ai_maskharderr) {
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   pci9118_ai_cancel(dev, s);
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return 1;
}
 
@@ -973,8 +972,7 @@ static void interrupt_pci9118_ai_onesample(struct 
comedi_device *dev,
 sampl & 0x000f,
 devpriv->chanlist[s->async->cur_chan]);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   pci9118_ai_cancel(dev, s);
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
}
@@ -985,16 +983,14 @@ static void interrupt_pci9118_ai_onesample(struct 
comedi_device *dev,
/* one scan done */
s->async->cur_chan %= devpriv->ai_n_scanlen;
devpriv->ai_act_scan++;
-   if (!(devpriv->ai_neverending))
-   if (devpriv->ai_act_scan >= devpriv->ai_scans) {
-   /* all data sampled */
-   pci9118_ai_cancel(dev, s);
+   if (!devpriv->ai_neverending) {
+   /* all data sampled? */
+   if (devpriv->ai_act_scan >= devpriv->ai_scans)
s->async->events |= COMEDI_CB_EOA;
-   }
+   }
}
 
-   if (s->async->events)
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 }
 
 static void interrupt_pci9118_ai_dma(struct comedi_device *dev,
@@ -1009,16 +1005,14 @@ static void interrupt_pci9118_ai_dma(struct 
comedi_device *dev,
if (int_amcc & MASTER_ABORT_INT) {
comedi_error(dev, "AMCC IRQ - MASTER DMA ABORT!");
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   pci9118_ai_cancel(dev, s);
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
 
if (int_amcc & TARGET_ABORT_INT) {
comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-   pci9118_ai_cancel(dev, s);
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return;
}
if (int_adstat & devpriv->ai_maskerr)
@@ -1056,12 +1050,11 @@ static void interrupt_pci9118_ai_dma(struct 
comedi_device *dev,
m = m - sampls; /* m= how many samples was transferred 
*/
}
 
-   if (!devpriv->ai_neverending)
-   if (devpriv->ai_act_scan >= devpriv->ai_scans) {
-   /* all data sampled */
-   pci9118_ai_cancel(dev, s);
+   if (!devpriv->ai_neverending) {
+   /* all data sampled? */
+   if (devpriv->ai_act_scan >= devpriv->ai_scans)
s->async->events |= COMEDI_CB_EOA;
-   }
+   }
 
if (devpriv->dma_doublebuf) {   /* switch dma buffers */
devpriv->dma_actbuf = 1 - devpriv->dma_actbuf;
@@ -1074,7 +1067,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device 
*dev,
interrupt_pci9118_ai_mode4_switch(dev);
}
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
 }
 
 static irqreturn_t interrupt_pci9118(int irq, void *d)
-- 
1.8.5.2

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


[PATCH 23/31] staging: comedi: pcl812: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig so that COMEDI_PCL812 selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig  | 1 +
 drivers/staging/comedi/drivers/pcl812.c | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 8076734..627c67b 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -177,6 +177,7 @@ config COMEDI_PCL730
 config COMEDI_PCL812
tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216"
depends on VIRT_TO_BUS && ISA_DMA_API
+   select COMEDI_FC
---help---
  Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink
  ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA,
diff --git a/drivers/staging/comedi/drivers/pcl812.c 
b/drivers/staging/comedi/drivers/pcl812.c
index 5436cd9..160eac8 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -863,7 +863,6 @@ static bool pcl812_ai_next_chan(struct comedi_device *dev,
if (cmd->stop_src == TRIG_COUNT &&
devpriv->ai_act_scan >= cmd->stop_arg) {
/* all data sampled */
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
return false;
}
@@ -879,7 +878,6 @@ static void pcl812_handle_eoc(struct comedi_device *dev,
 
if (pcl812_ai_eoc(dev, s, NULL, 0)) {
dev_dbg(dev->class_dev, "A/D cmd IRQ without DRDY!\n");
-   s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
return;
}
@@ -948,7 +946,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d)
 
pcl812_ai_clear_eoc(dev);
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
-- 
1.8.5.2

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


[PATCH 27/31] staging: comedi: dt3000: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig so that COMEDI_DT3000 selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig  | 1 +
 drivers/staging/comedi/drivers/dt3000.c | 6 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 2fb0cc0..279364a 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -860,6 +860,7 @@ config COMEDI_DAS08_PCI
 
 config COMEDI_DT3000
tristate "Data Translation DT3000 series support"
+   select COMEDI_FC
---help---
  Enable support for Data Translation DT3000 series
  DT3001, DT3001-PGL, DT3002, DT3003, DT3003-PGL, DT3004, DT3005 and
diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index f54685e..436e451 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -369,12 +369,10 @@ static irqreturn_t dt3k_interrupt(int irq, void *d)
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 
debug_n_ints++;
-   if (debug_n_ints >= 10) {
-   dt3k_ai_cancel(dev, s);
+   if (debug_n_ints >= 10)
s->async->events |= COMEDI_CB_EOA;
-   }
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
return IRQ_HANDLED;
 }
 
-- 
1.8.5.2

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


[PATCH 30/31] staging: comedi: quatech_daqp_cs: use cfc_handle_events()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

Update the Kconfig so that COMEDI_QUATECH_DAQP_CS selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/Kconfig   | 1 +
 drivers/staging/comedi/drivers/quatech_daqp_cs.c | 5 +
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 279364a..1a7e8e1 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1185,6 +1185,7 @@ config COMEDI_NI_MIO_CS
 
 config COMEDI_QUATECH_DAQP_CS
tristate "Quatech DAQP PCMCIA data capture card support"
+   select COMEDI_FC
---help---
  Enable support for the Quatech DAQP PCMCIA data capture cards
  DAQP-208 and DAQP-308
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c 
b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 96a4695..298dba0 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -214,7 +214,6 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
s->async->events |=
COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
dev_warn(dev->class_dev, "data lost\n");
-   daqp_ai_cancel(dev, s);
break;
}
 
@@ -231,7 +230,6 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
if (devpriv->count > 0) {
devpriv->count--;
if (devpriv->count == 0) {
-   daqp_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
break;
}
@@ -244,13 +242,12 @@ static enum irqreturn daqp_interrupt(int irq, void 
*dev_id)
if (loop_limit <= 0) {
dev_warn(dev->class_dev,
 "loop_limit reached in daqp_interrupt()\n");
-   daqp_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
 
s->async->events |= COMEDI_CB_BLOCK;
 
-   comedi_event(dev, s);
+   cfc_handle_events(dev, s);
}
return IRQ_HANDLED;
 }
-- 
1.8.5.2

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


[PATCH 11/31] staging: comedi: mite: use cfc_inc_scan_progress()

2014-03-07 Thread H Hartley Sweeten
Use the comedi_fc helper function instead of duplicating the code.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/mite.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index 9c9a0ee..1a572c8 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -527,9 +527,9 @@ EXPORT_SYMBOL_GPL(mite_dma_disarm);
 int mite_sync_input_dma(struct mite_channel *mite_chan,
struct comedi_async *async)
 {
+   struct comedi_subdevice *s = async->subdevice;
int count;
unsigned int nbytes, old_alloc_count;
-   const unsigned bytes_per_scan = cfc_bytes_per_scan(async->subdevice);
 
old_alloc_count = async->buf_write_alloc_count;
/* write alloc as much as we can */
@@ -538,7 +538,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
nbytes = mite_bytes_written_to_memory_lb(mite_chan);
if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
  old_alloc_count) > 0) {
-   dev_warn(async->subdevice->device->class_dev,
+   dev_warn(s->device->class_dev,
 "mite: DMA overwrite of free area\n");
async->events |= COMEDI_CB_OVERFLOW;
return -1;
@@ -551,12 +551,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
return 0;
 
comedi_buf_write_free(async, count);
-
-   async->scan_progress += count;
-   if (async->scan_progress >= bytes_per_scan) {
-   async->scan_progress %= bytes_per_scan;
-   async->events |= COMEDI_CB_EOS;
-   }
+   cfc_inc_scan_progress(s, count);
async->events |= COMEDI_CB_BLOCK;
return 0;
 }
-- 
1.8.5.2

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


Re: [PATCH v2 5/5] Staging: comedi: addi-data: tidy up counter register map defines in hwdrv_apci1564.c

2014-03-07 Thread Chase Southwood
>On Friday, March 7, 2014 11:38 AM, Hartley Sweeten 
> wrote:

>>On Friday, March 07, 2014 1:38 AM, Chase Southwood wrote:
>>This patch fixes the register map defines for the counter registers such
>>that they are all the real offsets to each register, rather than a mix of
>>real offsets and adders to those offsets.
>>
>>Signed-off-by: Chase Southwood 
>>---
>>
>>2: Simplified commit message, fixed indentation and whitespace damage.
>>I have test applied this patch, it should work now.
>>v2 also fixes several build breakages, and I have compile tested as well.
>>Everything should be fixed.
>
>Chase,
>
>Looks better, the patches apply now.
>
>The register map whitespace is still a bit of a mess. This is what it looks 
>like
>after applying all 5 patches:
>

[snip]

>
>Check your tab settings in your editor. Normal tab spacing is 8 characters.
>It looks like all the defines align properly at column 49 which is one tab 
>after
>the define on this line:
>
>#define APCI1564_TCW_WARN_TIMEBASE_REG(x)    (0x1c + ((x) * 0x20))
>
>Other than that the patches look good.

OK, yeah, for whatever reason my editor was set to 4 space tabs...I suppose
that explains why it looked perfectly aligned to me but horrifying to everyone 
else.
I have fixed this setting so it shouldn't be a problem going forward.
Everything appears to be properly aligned for real now, in the v3 I am
sending out momentarily.

Thanks,
Chase

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


  1   2   >