[PATCH resend] staging: zcache: fix "zcache=" kernel parameter

2013-07-29 Thread Bartlomiej Zolnierkiewicz
From: Piotr Sarna 

Commit 835f2f5 ("staging: zcache: enable zcache to be built/loaded as
a module") introduced an incorrect handling of "zcache=" parameter.

Inside zcache_comp_init() function, zcache_comp_name variable is
checked for being empty. If not empty, the above variable is tested
for being compatible with Crypto API. Unfortunately, after that
function ends unconditionally (by the "goto out" directive) and returns:
- non-zero value if verification succeeded, wrongly indicating an error
- zero value if verification failed, falsely informing that function
  zcache_comp_init() ended properly.

A solution to this problem is as following:
1. Move the "goto out" directive inside the "if (!ret)" statement
2. In case that crypto_has_comp() returned 0, change the value of ret
   to non-zero before "goto out" to indicate an error.

This patch replaces an earlier one from Michal Hocko (based on report
from Cristian Rodriguez):

http://permalink.gmane.org/gmane.linux.kernel.mm/102484

It also addressed the same issue but didn't fix the zcache_comp_init()
for case when the compressor data passed to "zcache=" option was invalid
or unsupported.

Signed-off-by: Piotr Sarna 
[bzolnier: updated patch description]
Acked-by: Bartlomiej Zolnierkiewicz 
Signed-off-by: Kyungmin Park 
Acked-by: Konrad Rzeszutek Wilk 
Acked-by: Michal Hocko 
Cc: Cristian Rodriguez 
Cc: Bob Liu 
---
 drivers/staging/zcache/zcache-main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c 
b/drivers/staging/zcache/zcache-main.c
index dcceed2..81972fa 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1811,10 +1811,12 @@ static int zcache_comp_init(void)
 #else
if (*zcache_comp_name != '\0') {
ret = crypto_has_comp(zcache_comp_name, 0, 0);
-   if (!ret)
+   if (!ret) {
pr_info("zcache: %s not supported\n",
zcache_comp_name);
-   goto out;
+   ret = 1;
+   goto out;
+   }
}
if (!ret)
strcpy(zcache_comp_name, "lzo");
-- 
1.8.2.3

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


Re: [patch] staging: comedi: dt9812: Resolves sparse endian warnings.

2013-07-29 Thread Ian Abbott

On 2013-07-26 19:19, H Hartley Sweeten wrote:

On Friday, July 26, 2013 10:59 AM, Shaun Laing wrote:

Please make sure to copy the mailing list... ;-)


I'm sorry Hartley,

I'm really new at this so there's probably something I'm doing wrong.
Do you have time to help me figure this out?  Here's how I'm building
this module:

shaun@rivendell:~/src/linux/staging$ make O=../staging-build C=1
CF=-D__CHECK_ENDIAN__ drivers/staging/comedi/drivers/dt9812.o


Ah.. That's the difference.

I usually don't pass the CF=-D__CHECK_ENDIAN__ option.

With that option it appears there are a number of comedi drivers that
have some endian issues.

Your patch does fix these four in the dt9812 driver:

drivers/staging/comedi/drivers/dt9812.c:739:18: warning: cast to restricted 
__le16
drivers/staging/comedi/drivers/dt9812.c:746:19: warning: cast to restricted 
__le16
drivers/staging/comedi/drivers/dt9812.c:753:27: warning: cast to restricted 
__le16
drivers/staging/comedi/drivers/dt9812.c:760:18: warning: cast to restricted 
__le32

So, FWIW:

Reviewed-by: H Hartley Sweeten 


These endian warnings still exist in the driver:

drivers/staging/comedi/drivers/dt9812.c:260:17: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:260:17:expected unsigned int 
[unsigned] [usertype] cmd
drivers/staging/comedi/drivers/dt9812.c:260:17:got restricted __le32 [usertype] 

drivers/staging/comedi/drivers/dt9812.c:261:39: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:261:39:expected unsigned short 
[unsigned] [usertype] address
drivers/staging/comedi/drivers/dt9812.c:261:39:got restricted __le16 [usertype] 

drivers/staging/comedi/drivers/dt9812.c:263:40: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:263:40:expected unsigned short 
[unsigned] [usertype] numbytes
drivers/staging/comedi/drivers/dt9812.c:263:40:got restricted __le16 [usertype] 

drivers/staging/comedi/drivers/dt9812.c:284:17: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:284:17:expected unsigned int 
[unsigned] [usertype] cmd
drivers/staging/comedi/drivers/dt9812.c:284:17:got restricted __le32 [usertype] 

drivers/staging/comedi/drivers/dt9812.c:308:17: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:308:17:expected unsigned int 
[unsigned] [usertype] cmd
drivers/staging/comedi/drivers/dt9812.c:308:17:got restricted __le32 [usertype] 

drivers/staging/comedi/drivers/dt9812.c:329:17: warning: incorrect type in 
assignment (different base types)
drivers/staging/comedi/drivers/dt9812.c:329:17:expected unsigned int 
[unsigned] [usertype] cmd
drivers/staging/comedi/drivers/dt9812.c:329:17:got restricted __le32 [usertype] 


It appears they can be "fixed" by changing the types in the struct 
dt9812_flash_data
and struct dt9812_usb_cmd. But I'm not positive if this is the "correct" fix. 
Hopefully
someone with a bit more endian knowledge will comment. If they do, and this is 
the
right fix, feel free to add this chunk to your patch.

Regards,
Hartley



@@ -188,8 +188,8 @@ enum {
  };

  struct dt9812_flash_data {
-   u16 numbytes;
-   u16 address;
+   __le16 numbytes;
+   __le16 address;
  };

  #define DT9812_MAX_NUM_MULTI_BYTE_RDS  \
@@ -230,7 +230,7 @@ struct dt9812_rmw_multi {
  };

  struct dt9812_usb_cmd {
-   u32 cmd;
+   __le32 cmd;
 union {
 struct dt9812_flash_data flash_data_info;
 struct dt9812_read_multi read_multi_info;





Yes, your additions look correct, Hartley.

--
-=( Ian Abbott @ MEV Ltd.E-mail: )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587 )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [patch] staging: comedi: dt9812: Resolves sparse endian warnings.

2013-07-29 Thread Shaun Laing
Ok,

I'll send in this additional patch.

On Mon, Jul 29, 2013 at 9:03 AM, Ian Abbott  wrote:
> On 2013-07-26 19:19, H Hartley Sweeten wrote:
>>
>> On Friday, July 26, 2013 10:59 AM, Shaun Laing wrote:
>>
>> Please make sure to copy the mailing list... ;-)
>>
>>> I'm sorry Hartley,
>>>
>>> I'm really new at this so there's probably something I'm doing wrong.
>>> Do you have time to help me figure this out?  Here's how I'm building
>>> this module:
>>>
>>> shaun@rivendell:~/src/linux/staging$ make O=../staging-build C=1
>>> CF=-D__CHECK_ENDIAN__ drivers/staging/comedi/drivers/dt9812.o
>>
>>
>> Ah.. That's the difference.
>>
>> I usually don't pass the CF=-D__CHECK_ENDIAN__ option.
>>
>> With that option it appears there are a number of comedi drivers that
>> have some endian issues.
>>
>> Your patch does fix these four in the dt9812 driver:
>>
>> drivers/staging/comedi/drivers/dt9812.c:739:18: warning: cast to
>> restricted __le16
>> drivers/staging/comedi/drivers/dt9812.c:746:19: warning: cast to
>> restricted __le16
>> drivers/staging/comedi/drivers/dt9812.c:753:27: warning: cast to
>> restricted __le16
>> drivers/staging/comedi/drivers/dt9812.c:760:18: warning: cast to
>> restricted __le32
>>
>> So, FWIW:
>>
>> Reviewed-by: H Hartley Sweeten 
>>
>>
>> These endian warnings still exist in the driver:
>>
>> drivers/staging/comedi/drivers/dt9812.c:260:17: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:260:17:expected unsigned int
>> [unsigned] [usertype] cmd
>> drivers/staging/comedi/drivers/dt9812.c:260:17:got restricted __le32
>> [usertype] 
>> drivers/staging/comedi/drivers/dt9812.c:261:39: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:261:39:expected unsigned short
>> [unsigned] [usertype] address
>> drivers/staging/comedi/drivers/dt9812.c:261:39:got restricted __le16
>> [usertype] 
>> drivers/staging/comedi/drivers/dt9812.c:263:40: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:263:40:expected unsigned short
>> [unsigned] [usertype] numbytes
>> drivers/staging/comedi/drivers/dt9812.c:263:40:got restricted __le16
>> [usertype] 
>> drivers/staging/comedi/drivers/dt9812.c:284:17: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:284:17:expected unsigned int
>> [unsigned] [usertype] cmd
>> drivers/staging/comedi/drivers/dt9812.c:284:17:got restricted __le32
>> [usertype] 
>> drivers/staging/comedi/drivers/dt9812.c:308:17: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:308:17:expected unsigned int
>> [unsigned] [usertype] cmd
>> drivers/staging/comedi/drivers/dt9812.c:308:17:got restricted __le32
>> [usertype] 
>> drivers/staging/comedi/drivers/dt9812.c:329:17: warning: incorrect type in
>> assignment (different base types)
>> drivers/staging/comedi/drivers/dt9812.c:329:17:expected unsigned int
>> [unsigned] [usertype] cmd
>> drivers/staging/comedi/drivers/dt9812.c:329:17:got restricted __le32
>> [usertype] 
>>
>> It appears they can be "fixed" by changing the types in the struct
>> dt9812_flash_data
>> and struct dt9812_usb_cmd. But I'm not positive if this is the "correct"
>> fix. Hopefully
>> someone with a bit more endian knowledge will comment. If they do, and
>> this is the
>> right fix, feel free to add this chunk to your patch.
>>
>> Regards,
>> Hartley
>>
>>
>>
>> @@ -188,8 +188,8 @@ enum {
>>   };
>>
>>   struct dt9812_flash_data {
>> -   u16 numbytes;
>> -   u16 address;
>> +   __le16 numbytes;
>> +   __le16 address;
>>   };
>>
>>   #define DT9812_MAX_NUM_MULTI_BYTE_RDS  \
>> @@ -230,7 +230,7 @@ struct dt9812_rmw_multi {
>>   };
>>
>>   struct dt9812_usb_cmd {
>> -   u32 cmd;
>> +   __le32 cmd;
>>  union {
>>  struct dt9812_flash_data flash_data_info;
>>  struct dt9812_read_multi read_multi_info;
>>
>>
>>
>
> Yes, your additions look correct, Hartley.
>
> --
> -=( Ian Abbott @ MEV Ltd.E-mail: )=-
> -=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587 )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


JOB OFFER

2013-07-29 Thread morgan
Hello Dear,

I am Mr. Tony Morgan, Native of Scotland . I am residing in Rome for about Three
months now working, but my family is in London,I will love to hire a caring 
male or
female house keeper directly who is willing to work in my house in London as a 
house
keeper.I will like you to know that I have 2 daughters 10 and 8 years old, I 
can afford
to be paying you 2000 pounds every four weeks and an up keep money every week 
as 200
Pounds per week and this is outside your 2000 pounds, your responsibility in my 
house is
just to take care of the house.Kindly get back to this email 
[tony_mor...@mail.com] if you are interested in this offer.
Thanks and best regards

Mr.Tony Morgan.
+447014246434
150 School Lane
Kenilworth
Warwickshire
UK
CV8 2GR
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/20] staging: octeon-usb: cvmx-usb: eliminate cvmx_likely/unlikely

2013-07-29 Thread Aaro Koskinen
Just use likely/unlikely.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 94 +--
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 9604353..efea87b 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -68,9 +68,7 @@
 #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, 
offset)
 #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : 
[rs] "d" (input))
 
-#define cvmx_likely likely
 #define cvmx_wait_usec udelay
-#define cvmx_unlikely unlikely
 #define cvmx_le16_to_cpu le16_to_cpu
 
 #define MAX_RETRIES 3   /* Maximum number of times to retry failed 
transactions */
@@ -1108,31 +1106,31 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, 
cvmx_usb_pipe_flags_t flags,
 cvmx_usb_pipe_t *pipe;
 cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
 
-if (cvmx_unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS)))
+if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS)))
 return -EINVAL;
-if (cvmx_unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT)))
+if (unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT)))
 return -EINVAL;
-if (cvmx_unlikely(device_speed > CVMX_USB_SPEED_LOW))
+if (unlikely(device_speed > CVMX_USB_SPEED_LOW))
 return -EINVAL;
-if (cvmx_unlikely((max_packet <= 0) || (max_packet > 1024)))
+if (unlikely((max_packet <= 0) || (max_packet > 1024)))
 return -EINVAL;
-if (cvmx_unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT))
+if (unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT))
 return -EINVAL;
-if (cvmx_unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) &&
+if (unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) &&
 (transfer_dir != CVMX_USB_DIRECTION_IN)))
 return -EINVAL;
-if (cvmx_unlikely(interval < 0))
+if (unlikely(interval < 0))
 return -EINVAL;
-if (cvmx_unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && 
interval))
+if (unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval))
 return -EINVAL;
-if (cvmx_unlikely(multi_count < 0))
+if (unlikely(multi_count < 0))
 return -EINVAL;
-if (cvmx_unlikely((device_speed != CVMX_USB_SPEED_HIGH) &&
+if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) &&
 (multi_count != 0)))
 return -EINVAL;
-if (cvmx_unlikely((hub_device_addr < 0) || (hub_device_addr > 
MAX_USB_ADDRESS)))
+if (unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS)))
 return -EINVAL;
-if (cvmx_unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT)))
+if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT)))
 return -EINVAL;
 
 /* Find a free pipe */
@@ -1783,7 +1781,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t 
*usb, int is_sof)
 /* Find an idle channel */
 CVMX_CLZ(channel, usb->idle_hardware_channels);
 channel = 31 - channel;
-if (cvmx_unlikely(channel > 7))
+if (unlikely(channel > 7))
 break;
 
 /* Find a pipe needing service */
@@ -1793,12 +1791,12 @@ static void 
__cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof)
 sure that the periodic data is sent in the beginning of the
 frame */
 pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + 
CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number);
-if (cvmx_likely(!pipe))
+if (likely(!pipe))
 pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + 
CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number);
 }
-if (cvmx_likely(!pipe)) {
+if (likely(!pipe)) {
 pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + 
CVMX_USB_TRANSFER_CONTROL, usb->frame_number);
-if (cvmx_likely(!pipe))
+if (likely(!pipe))
 pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + 
CVMX_USB_TRANSFER_BULK, usb->frame_number);
 }
 if (!pipe)
@@ -1896,7 +1894,7 @@ static void 
__cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb,
 
 /* Isochronous transactions need extra processing as they might not be done
 after a single data transfer */
-if (cvmx_unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) {
+if (unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) {
 /* Update the number of bytes transferred in this ISO packet */
 transaction->iso_packets[0].length = transaction->actual_bytes;
 transaction->iso_packets[0].status = complete_code;
@@ -1979,16 +1977,16 @@ static int 
__cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb,
 cvmx_usb_tran

[PATCH 04/20] staging: octeon-usb: cvmx-usb: delete redundant debug flags

2013-07-29 Thread Aaro Koskinen
Delete redudant debug flags and dead code behind them.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 87 +--
 drivers/staging/octeon-usb/cvmx-usb.h |  7 ---
 2 files changed, 2 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 6a1e14a..dd8653c 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -439,8 +439,6 @@ static inline cvmx_usb_transaction_t 
*__cvmx_usb_alloc_transaction(cvmx_usb_inte
 if (!usb->free_transaction_head)
 usb->free_transaction_tail = NULL;
 }
-else if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: Failed to allocate a transaction\n", __FUNCTION__);
 if (t) {
 memset(t, 0, sizeof(*t));
 t->flags = __CVMX_USB_TRANSACTION_FLAGS_IN_USE;
@@ -791,8 +789,6 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 
 {
 /* Host Port Initialization */
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: USB%d is in host mode\n", __FUNCTION__, 
usb->index);
 
 /* 1. Program the host-port interrupt-mask field to unmask,
 USBC_GINTMSK[PRTINT] = 1 */
@@ -881,8 +877,6 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state)
 
 /* If there is nothing plugged into the port then fail immediately */
 if (!usb->usbcx_hprt.s.prtconnsts) {
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: USB%d Nothing plugged into the port\n", 
__FUNCTION__, usb->index);
 return CVMX_USB_TIMEOUT;
 }
 
@@ -898,21 +892,11 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state)
 
 /* Wait for the USBC_HPRT[PRTENA]. */
 if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t,
-  prtena, ==, 1, 10)) {
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: Timeout waiting for the port to finish reset\n",
- __FUNCTION__);
+  prtena, ==, 1, 10))
 return CVMX_USB_TIMEOUT;
-}
 
 /* Read the port speed field to get the enumerated speed, 
USBC_HPRT[PRTSPD]. */
 usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, 
CVMX_USBCX_HPRT(usb->index));
-if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: USB%d is in %s speed mode\n", __FUNCTION__, 
usb->index,
- (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH) ? 
"high" :
- (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_FULL) ? 
"full" :
- "low");
-
 usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, 
CVMX_USBCX_GHWCFG3(usb->index));
 
 /* 13. Program the USBC_GRXFSIZ register to select the size of the receive
@@ -1003,15 +987,6 @@ cvmx_usb_port_status_t 
cvmx_usb_get_status(cvmx_usb_state_t *state)
 result.connected = usbc_hprt.s.prtconnsts;
 result.connect_change = (result.connected != usb->port_status.connected);
 
-if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS))
-cvmx_dprintf("%*s%s: returned port enabled=%d, over_current=%d, 
powered=%d, speed=%d, connected=%d, connect_change=%d\n",
- 2*(--usb->indent), "", __FUNCTION__,
- result.port_enabled,
- result.port_over_current,
- result.port_powered,
- result.port_speed,
- result.connected,
- result.connect_change);
 return result;
 }
 
@@ -1526,13 +1501,6 @@ static void 
__cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb,
 {
 cvmx_usb_transaction_t *transaction = pipe->head;
 
-if (cvmx_unlikely((usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) ||
-(pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS)))
-cvmx_dprintf("%s: Channel %d started. Pipe %d transaction %d stage 
%d\n",
- __FUNCTION__, channel, __cvmx_usb_get_pipe_handle(usb, 
pipe),
- __cvmx_usb_get_submit_handle(usb, transaction),
- transaction->stage);
-
 /* Make sure all writes to the DMA region get flushed */
 CVMX_SYNCW;
 
@@ -1820,11 +1788,8 @@ static void 
__cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof)
 /* Find an idle channel */
 CVMX_CLZ(channel, usb->idle_hardware_channels);
 channel = 31 - channel;
-if (cvmx_unlikely(channel > 7)) {
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
-cvmx_dprintf("%s: Idle hardware channels has a channel higher 
than 7. This is wrong\n", __FUNCTION__);
+if (

[PATCH 12/20] staging: octeon-usb: cvmx-usb: delete __cvmx_usb_complete_to_string()

2013-07-29 Thread Aaro Koskinen
Delete a redundant function.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 28 
 1 file changed, 28 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 49a1794..976ba19 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -324,34 +324,6 @@ static inline void 
__cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb,
 cvmx_write64_uint64(address, value);
 }
 
-
-/**
- * @INTERNAL
- * Utility function to convert complete codes into strings
- *
- * @param complete_code
- *   Code to convert
- *
- * @return Human readable string
- */
-static const char *__cvmx_usb_complete_to_string(cvmx_usb_complete_t 
complete_code)
-{
-switch (complete_code)
-{
-case CVMX_USB_COMPLETE_SUCCESS: return "SUCCESS";
-case CVMX_USB_COMPLETE_SHORT:   return "SHORT";
-case CVMX_USB_COMPLETE_CANCEL:  return "CANCEL";
-case CVMX_USB_COMPLETE_ERROR:   return "ERROR";
-case CVMX_USB_COMPLETE_STALL:   return "STALL";
-case CVMX_USB_COMPLETE_XACTERR: return "XACTERR";
-case CVMX_USB_COMPLETE_DATATGLERR: return "DATATGLERR";
-case CVMX_USB_COMPLETE_BABBLEERR: return "BABBLEERR";
-case CVMX_USB_COMPLETE_FRAMEERR: return "FRAMEERR";
-}
-return "Update __cvmx_usb_complete_to_string";
-}
-
-
 /**
  * @INTERNAL
  * Return non zero if this pipe connects to a non HIGH speed
-- 
1.8.3.2

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


[PATCH 03/20] staging: octeon-usb: cvmx-usb: delete driver-specific tracing code

2013-07-29 Thread Aaro Koskinen
Delete call, parameter, and return value tracing.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 325 +-
 1 file changed, 87 insertions(+), 238 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 6c7bcf3..6a1e14a 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -211,33 +211,6 @@ typedef struct {
 cvmx_usb_tx_fifo_t nonperiodic;
 } cvmx_usb_internal_state_t;
 
-/* This macro logs out whenever a function is called if debugging is on */
-#define CVMX_USB_LOG_CALLED() \
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
-cvmx_dprintf("%*s%s: called\n", 2*usb->indent++, "", __FUNCTION__);
-
-/* This macro logs out each function parameter if debugging is on */
-#define CVMX_USB_LOG_PARAM(format, param) \
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
-cvmx_dprintf("%*s%s: param %s = " format "\n", 2*usb->indent, "", 
__FUNCTION__, #param, param);
-
-/* This macro logs out when a function returns a value */
-#define CVMX_USB_RETURN(v)  \
-do {\
-typeof(v) r = v;\
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS))\
-cvmx_dprintf("%*s%s: returned %s(%d)\n", 2*--usb->indent, "", 
__FUNCTION__, #v, r); \
-return r;   \
-} while (0);
-
-/* This macro logs out when a function doesn't return a value */
-#define CVMX_USB_RETURN_NOTHING()   \
-do {\
-if (cvmx_unlikely(usb->init_flags & 
CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS))\
-cvmx_dprintf("%*s%s: returned\n", 2*--usb->indent, "", 
__FUNCTION__); \
-return; \
-} while (0);
-
 /* This macro spins on a field waiting for it to reach a value */
 #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
 ({int result;   \
@@ -574,20 +547,16 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
 
 usb->init_flags = flags;
-CVMX_USB_LOG_CALLED();
-CVMX_USB_LOG_PARAM("%p", state);
-CVMX_USB_LOG_PARAM("%d", usb_port_number);
-CVMX_USB_LOG_PARAM("0x%x", flags);
 
 /* Make sure that state is large enough to store the internal state */
 if (sizeof(*state) < sizeof(*usb))
-CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+return CVMX_USB_INVALID_PARAM;
 /* At first allow 0-1 for the usb port number */
 if ((usb_port_number < 0) || (usb_port_number > 1))
-CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+return CVMX_USB_INVALID_PARAM;
 /* For all chips except 52XX there is only one port */
 if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0))
-CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+return CVMX_USB_INVALID_PARAM;
 /* Try to determine clock type automatically */
 if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI |
   CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) {
@@ -611,7 +580,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ;
 break;
 default:
-CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+return CVMX_USB_INVALID_PARAM;
 break;
 }
 }
@@ -847,7 +816,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 /* Steps 4-15 from the manual are done later in the port enable */
 }
 
-CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+return CVMX_USB_SUCCESS;
 }
 
 
@@ -867,16 +836,13 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t 
*state)
 cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
 cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
 
-CVMX_USB_LOG_CALLED();
-CVMX_USB_LOG_PARAM("%p", state);
-
 /* Make sure all pipes are closed */
 if (usb->idle_pipes.head ||
 usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS].head ||
 usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head ||
 usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head ||
 usb->active_pipes[CVMX_USB_TRANSFER_BULK].head)
-CVMX_USB_RETURN(CVMX_USB_BUSY);
+return CVMX_USB_BUSY;
 
 /* Disable the clocks and put them in power on reset */
 usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, 
CVMX_USBNX_CLK_CTL(usb->index));
@@ -887,7 +853,7 @@ cvmx_us

[PATCH 07/20] staging: octeon-usb: cvmx-usb: utilize Linux error codes

2013-07-29 Thread Aaro Koskinen
Use generic Linux error codes to replace cvmx_usb_status_t.

The conversion table:

Before  After
cvmx_usb_status_t   int
CVMX_USB_SUCCESS0
CVMX_USB_INVALID_PARAM  -EINVAL
CVMX_USB_NO_MEMORY  -ENOMEM
CVMX_USB_BUSY   -EBUSY
CVMX_USB_TIMEOUT-ETIMEDOUT
CVMX_USB_INCORRECT_MODE Deleted (was never used)

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 191 --
 drivers/staging/octeon-usb/cvmx-usb.h |  89 ++--
 2 files changed, 117 insertions(+), 163 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index dd8653c..9604353 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -533,12 +533,10 @@ static inline void 
__cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
  *   cvmx_usb_initialize_flags_t for the flag
  *   definitions. Some flags are mandatory.
  *
- * @return CVMX_USB_SUCCESS or a negative error code defined in
- * cvmx_usb_status_t.
+ * @return 0 or a negative error code.
  */
-cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state,
-  int usb_port_number,
-  cvmx_usb_initialize_flags_t flags)
+int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
+   cvmx_usb_initialize_flags_t flags)
 {
 cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
 cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status;
@@ -548,13 +546,13 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 
 /* Make sure that state is large enough to store the internal state */
 if (sizeof(*state) < sizeof(*usb))
-return CVMX_USB_INVALID_PARAM;
+return -EINVAL;
 /* At first allow 0-1 for the usb port number */
 if ((usb_port_number < 0) || (usb_port_number > 1))
-return CVMX_USB_INVALID_PARAM;
+return -EINVAL;
 /* For all chips except 52XX there is only one port */
 if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0))
-return CVMX_USB_INVALID_PARAM;
+return -EINVAL;
 /* Try to determine clock type automatically */
 if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI |
   CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) {
@@ -578,7 +576,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ;
 break;
 default:
-return CVMX_USB_INVALID_PARAM;
+return -EINVAL;
 break;
 }
 }
@@ -812,7 +810,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
 /* Steps 4-15 from the manual are done later in the port enable */
 }
 
-return CVMX_USB_SUCCESS;
+return 0;
 }
 
 
@@ -824,10 +822,9 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t 
*state,
  * @param state  USB device state populated by
  *   cvmx_usb_initialize().
  *
- * @return CVMX_USB_SUCCESS or a negative error code defined in
- * cvmx_usb_status_t.
+ * @return 0 or a negative error code.
  */
-cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state)
+int cvmx_usb_shutdown(cvmx_usb_state_t *state)
 {
 cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
 cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
@@ -838,7 +835,7 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state)
 usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head ||
 usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head ||
 usb->active_pipes[CVMX_USB_TRANSFER_BULK].head)
-return CVMX_USB_BUSY;
+return -EBUSY;
 
 /* Disable the clocks and put them in power on reset */
 usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, 
CVMX_USBNX_CLK_CTL(usb->index));
@@ -849,7 +846,7 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state)
 usbn_clk_ctl.s.hrst = 0;
 __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
usbn_clk_ctl.u64);
-return CVMX_USB_SUCCESS;
+return 0;
 }
 
 
@@ -860,10 +857,9 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t 
*state)
  * @param state  USB device state populated by
  *   cvmx_usb_initialize().
  *
- * @return CVMX_USB_SUCCESS or a negative error code defined in
- * cvmx_usb_status_t.
+ * @return 0 or a negative error code.
  */
-cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state)
+int cvmx_usb_enable(cvmx_usb_state_t *state)
 {
 cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3;
 cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
@@ -873,11 +869,11 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state

[PATCH 02/20] staging: octeon-usb: use correct board type for EdgeRouter Lite

2013-07-29 Thread Aaro Koskinen
Use CVMX_BOARD_TYPE_UBNT_E100 for EdgeRouter Lite.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index bf36649..6c7bcf3 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -280,14 +280,9 @@ static int octeon_usb_get_clock_type(void)
case CVMX_BOARD_TYPE_LANAI2_A:
case CVMX_BOARD_TYPE_LANAI2_U:
case CVMX_BOARD_TYPE_LANAI2_G:
+   case CVMX_BOARD_TYPE_UBNT_E100:
return USB_CLOCK_TYPE_CRYSTAL_12;
}
-
-   /* FIXME: This should use CVMX_BOARD_TYPE_UBNT_E100 */
-   if (OCTEON_IS_MODEL(OCTEON_CN50XX) &&
-   cvmx_sysinfo_get()->board_type == 20002)
-   return USB_CLOCK_TYPE_CRYSTAL_12;
-
return USB_CLOCK_TYPE_REF_48;
 }
 
-- 
1.8.3.2

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


[PATCH 00/20] staging: octeon-usb: cvmx-usb cleanups

2013-07-29 Thread Aaro Koskinen
Hi,

These are cleanups mainly for cvmx-usb file. No functional changes.
Tested with EdgeRouter Lite + USB mass storage.

Aaro Koskinen (20):
  staging: octeon-usb: depend on CAVIUM_OCTEON_SOC
  staging: octeon-usb: use correct board type for EdgeRouter Lite
  staging: octeon-usb: cvmx-usb: delete driver-specific tracing code
  staging: octeon-usb: cvmx-usb: delete redundant debug flags
  staging: octeon-usb: cvmx-usb: delete redundant example code
  staging: octeon-usb: cvmx-usb: delete __cplusplus
  staging: octeon-usb: cvmx-usb: utilize Linux error codes
  staging: octeon-usb: cvmx-usb: eliminate cvmx_likely/unlikely
  staging: octeon-usb: cvmx-usb: replace long udelays with mdelays
  staging: octeon-usb: cvmx-usb: replace cvmx_wait_usec with udelay
  staging: octeon-usb: cvmx-usb: replace cvmx_le16_to_cpu with
le16_to_cpu
  staging: octeon-usb: cvmx-usb: delete __cvmx_usb_complete_to_string()
  staging: octeon-usb: cvmx-usb: fix whitespace issues
  staging: octeon-usb: cvmx-usb: reformat long comments
  staging: octeon-usb: cvmx-usb: delete @INTERNAL
  staging: octeon-usb: cvmx-usb: delete duplicated documentation from .h
file
  staging: octeon-usb: cvmx-usb: convert @param
  staging: octeon-usb: cvmx-usb: convert @return
  staging: octeon-usb: cvmx-usb: delete CVS keyword markers
  staging: octeon-usb: cvmx-usb: reformat documentation

 drivers/staging/octeon-usb/Kconfig|2 +-
 drivers/staging/octeon-usb/cvmx-usb.c | 5160 -
 drivers/staging/octeon-usb/cvmx-usb.h |  749 +
 3 files changed, 2573 insertions(+), 3338 deletions(-)

-- 
1.8.3.2

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


[PATCH 19/20] staging: octeon-usb: cvmx-usb: delete CVS keyword markers

2013-07-29 Thread Aaro Koskinen
Delete CVS keyword markers.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 2 --
 drivers/staging/octeon-usb/cvmx-usb.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index a3ac340..fa029e3 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -46,8 +46,6 @@
  * systems. These functions provide a generic API to the Octeon
  * USB blocks, hiding the internal hardware specific
  * operations.
- *
- * $Revision: 32636 $
  */
 #include 
 #include 
diff --git a/drivers/staging/octeon-usb/cvmx-usb.h 
b/drivers/staging/octeon-usb/cvmx-usb.h
index 30d7213..b8e9054 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.h
+++ b/drivers/staging/octeon-usb/cvmx-usb.h
@@ -234,8 +234,6 @@
  *
  * If you aren't using interrupts, simple call cvmx_usb_poll()
  * in your main processing loop.
- *
- * $Revision: 32636 $
  */
 
 #ifndef __CVMX_USB_H__
-- 
1.8.3.2

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


[PATCH 09/20] staging: octeon-usb: cvmx-usb: replace long udelays with mdelays

2013-07-29 Thread Aaro Koskinen
Replace long udelays with mdelays.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index efea87b..fadc695 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -672,7 +672,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
 __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
usbn_clk_ctl.u64);
 /* 4. Wait 1 ms for PHY clock to start */
-cvmx_wait_usec(1000);
+mdelay(1);
 /* 5. Program the Reset input from automatic test equipment field in the
 USBP control and status register: USBN_USBP_CTL_STATUS[ATE_RESET] = 1 
*/
 usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, 
CVMX_USBNX_USBP_CTL_STATUS(usb->index));
@@ -879,7 +879,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state)
 
 /* Wait at least 50ms (high speed), or 10ms (full speed) for the reset
 process to complete. */
-cvmx_wait_usec(5);
+mdelay(50);
 
 /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */
 USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 0);
-- 
1.8.3.2

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


[PATCH 10/20] staging: octeon-usb: cvmx-usb: replace cvmx_wait_usec with udelay

2013-07-29 Thread Aaro Koskinen
Just use udelay().

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index fadc695..906c7d8 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -68,7 +68,6 @@
 #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, 
offset)
 #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : 
[rs] "d" (input))
 
-#define cvmx_wait_usec udelay
 #define cvmx_le16_to_cpu le16_to_cpu
 
 #define MAX_RETRIES 3   /* Maximum number of times to retry failed 
transactions */
@@ -698,7 +697,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
 __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index),
usbn_usbp_ctl_status.u64);
 /* 10. Wait 1 us */
-cvmx_wait_usec(1);
+udelay(1);
 /* 11. Program the hreset_n field in the USBN clock-control register:
 USBN_CLK_CTL[HRST] = 1 */
 usbn_clk_ctl.s.hrst = 1;
@@ -708,7 +707,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
 usbn_clk_ctl.s.enable = 1;
 __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
usbn_clk_ctl.u64);
-cvmx_wait_usec(1);
+udelay(1);
 
 /* USB Core Initialization */
 
-- 
1.8.3.2

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


[PATCH 05/20] staging: octeon-usb: cvmx-usb: delete redundant example code

2013-07-29 Thread Aaro Koskinen
Delete redundant example code found in comments. It's already there in
the driver proper.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.h | 209 +-
 1 file changed, 1 insertion(+), 208 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.h 
b/drivers/staging/octeon-usb/cvmx-usb.h
index eed6ba4..ffabfbe 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.h
+++ b/drivers/staging/octeon-usb/cvmx-usb.h
@@ -217,214 +217,7 @@
  * messages similar to the usb 2.0 spec for hub control and
  * status. For these systems it may be necessary to write
  * function to decode standard usb control messages into
- * equivalent cvmx-usb API calls. As an example, the following
- * code is used under Linux for some of the basic hub control
- * messages.
- *
- * @code
- * static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 
wValue, u16 wIndex, char *buf, u16 wLength)
- * {
- * cvmx_usb_state_t *usb = (cvmx_usb_state_t *)hcd->hcd_priv;
- * cvmx_usb_port_status_t usb_port_status;
- * int port_status;
- * struct usb_hub_descriptor *desc;
- * unsigned long flags;
- *
- * switch (typeReq)
- * {
- * case ClearHubFeature:
- * DEBUG_ROOT_HUB("OcteonUSB: ClearHubFeature\n");
- * switch (wValue)
- * {
- * case C_HUB_LOCAL_POWER:
- * case C_HUB_OVER_CURRENT:
- * // Nothing required here
- * break;
- * default:
- * return -EINVAL;
- * }
- * break;
- * case ClearPortFeature:
- * DEBUG_ROOT_HUB("OcteonUSB: ClearPortFeature");
- * if (wIndex != 1)
- * {
- * DEBUG_ROOT_HUB(" INVALID\n");
- * return -EINVAL;
- * }
- *
- * switch (wValue)
- * {
- * case USB_PORT_FEAT_ENABLE:
- * DEBUG_ROOT_HUB(" ENABLE");
- * local_irq_save(flags);
- * cvmx_usb_disable(usb);
- * local_irq_restore(flags);
- * break;
- * case USB_PORT_FEAT_SUSPEND:
- * DEBUG_ROOT_HUB(" SUSPEND");
- * // Not supported on Octeon
- * break;
- * case USB_PORT_FEAT_POWER:
- * DEBUG_ROOT_HUB(" POWER");
- * // Not supported on Octeon
- * break;
- * case USB_PORT_FEAT_INDICATOR:
- * DEBUG_ROOT_HUB(" INDICATOR");
- * // Port inidicator not supported
- * break;
- * case USB_PORT_FEAT_C_CONNECTION:
- * DEBUG_ROOT_HUB(" C_CONNECTION");
- * // Clears drivers internal connect status change flag
- * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb));
- * break;
- * case USB_PORT_FEAT_C_RESET:
- * DEBUG_ROOT_HUB(" C_RESET");
- * // Clears the driver's internal Port Reset Change flag
- * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb));
- * break;
- * case USB_PORT_FEAT_C_ENABLE:
- * DEBUG_ROOT_HUB(" C_ENABLE");
- * // Clears the driver's internal Port Enable/Disable 
Change flag
- * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb));
- * break;
- * case USB_PORT_FEAT_C_SUSPEND:
- * DEBUG_ROOT_HUB(" C_SUSPEND");
- * // Clears the driver's internal Port Suspend Change 
flag,
- * which is set when resume signaling on the host port 
is
- * complete
- * break;
- * case USB_PORT_FEAT_C_OVER_CURRENT:
- * DEBUG_ROOT_HUB(" C_OVER_CURRENT");
- * // Clears the driver's overcurrent Change flag
- * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb));
- * break;
- * default:
- * DEBUG_ROOT_HUB(" UNKNOWN\n");
- * return -EINVAL;
- * }
- * DEBUG_ROOT_HUB("\n");
- * break;
- * case GetHubDescriptor:
- * DEBUG_ROOT_HUB("OcteonUSB: GetHubDescriptor\n");
- * desc = (struct usb_hub_descriptor *)buf;
- * desc->bDescLength = 9;
- * desc->bDescriptorType = 0x29;
- * desc->bNbrPorts = 1;
- * desc->wHubCharacteristics = 0x08;
- * desc->bPwrOn2PwrGood = 1;
- * desc->bHubContrCurrent = 0;
- * desc->bitmap[0] = 0;
- * desc->bitmap[1] = 0xff;
- * break;
- * case

[PATCH 11/20] staging: octeon-usb: cvmx-usb: replace cvmx_le16_to_cpu with le16_to_cpu

2013-07-29 Thread Aaro Koskinen
Replace cvmx_le16_to_cpu() with le16_to_cpu().

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 906c7d8..49a1794 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -68,8 +68,6 @@
 #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, 
offset)
 #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : 
[rs] "d" (input))
 
-#define cvmx_le16_to_cpu le16_to_cpu
-
 #define MAX_RETRIES 3   /* Maximum number of times to retry failed 
transactions */
 #define MAX_PIPES   32  /* Maximum number of pipes that can be open at 
once */
 #define MAX_TRANSACTIONS256 /* Maximum number of outstanding transactions 
across all pipes */
@@ -2200,7 +2198,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int 
pipe_handle,
 if (unlikely(!buffer && (buffer_length != 0)))
 return -EINVAL;
 if ((header->s.request_type & 0x80) == 0)
-buffer_length = cvmx_le16_to_cpu(header->s.length);
+buffer_length = le16_to_cpu(header->s.length);
 
 submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle,
  CVMX_USB_TRANSFER_CONTROL,
-- 
1.8.3.2

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


[PATCH 06/20] staging: octeon-usb: cvmx-usb: delete __cplusplus

2013-07-29 Thread Aaro Koskinen
Delete __cplusplus.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.h 
b/drivers/staging/octeon-usb/cvmx-usb.h
index ffabfbe..e7b524b 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.h
+++ b/drivers/staging/octeon-usb/cvmx-usb.h
@@ -241,10 +241,6 @@
 #ifndef __CVMX_USB_H__
 #define __CVMX_USB_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /**
  * Enumerations representing the status of function calls.
  */
@@ -864,8 +860,4 @@ extern int cvmx_usb_get_frame_number(cvmx_usb_state_t 
*state);
  */
 extern cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif  /* __CVMX_USB_H__ */
-- 
1.8.3.2

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


[PATCH 01/20] staging: octeon-usb: depend on CAVIUM_OCTEON_SOC

2013-07-29 Thread Aaro Koskinen
The USB driver should depend on SOC instead of CPU.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/octeon-usb/Kconfig 
b/drivers/staging/octeon-usb/Kconfig
index 018af6d..16ea17f 100644
--- a/drivers/staging/octeon-usb/Kconfig
+++ b/drivers/staging/octeon-usb/Kconfig
@@ -1,6 +1,6 @@
 config OCTEON_USB
tristate "Cavium Networks Octeon USB support"
-   depends on CPU_CAVIUM_OCTEON && USB
+   depends on CAVIUM_OCTEON_SOC && USB
help
  This driver supports USB host controller on some Cavium
  Networks' products in the Octeon family.
-- 
1.8.3.2

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


[PATCH 17/20] staging: octeon-usb: cvmx-usb: convert @param

2013-07-29 Thread Aaro Koskinen
Convert "@param name" inside comments to "@name:".

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 268 +-
 1 file changed, 134 insertions(+), 134 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index d3da546..9a7b53a 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -262,8 +262,8 @@ static int octeon_usb_get_clock_type(void)
  * for 32bit CSRs and logs the value in a readable format if
  * debugging is on.
  *
- * @param usb USB block this access is for
- * @param address 64bit address to read
+ * @usb: USB block this access is for
+ * @address: 64bit address to read
  *
  * @return Result of the read
  */
@@ -280,9 +280,9 @@ static inline uint32_t 
__cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb,
  * swizzle for 32bit CSRs and logs the value in a readable format
  * if debugging is on.
  *
- * @param usb USB block this access is for
- * @param address 64bit address to write
- * @param value   Value to write
+ * @usb: USB block this access is for
+ * @address: 64bit address to write
+ * @value:   Value to write
  */
 static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb,
  uint64_t address, uint32_t value)
@@ -296,8 +296,8 @@ static inline void 
__cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb,
  * Read a USB 64bit CSR. It logs the value in a readable format if
  * debugging is on.
  *
- * @param usb USB block this access is for
- * @param address 64bit address to read
+ * @usb: USB block this access is for
+ * @address: 64bit address to read
  *
  * @return Result of the read
  */
@@ -313,9 +313,9 @@ static inline uint64_t 
__cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb,
  * Write a USB 64bit CSR. It logs the value in a readable format
  * if debugging is on.
  *
- * @param usb USB block this access is for
- * @param address 64bit address to write
- * @param value   Value to write
+ * @usb: USB block this access is for
+ * @address: 64bit address to write
+ * @value:   Value to write
  */
 static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb,
  uint64_t address, uint64_t value)
@@ -327,8 +327,8 @@ static inline void 
__cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb,
  * Return non zero if this pipe connects to a non HIGH speed
  * device through a high speed hub.
  *
- * @param usbUSB block this access is for
- * @param pipe   Pipe to check
+ * @usb:USB block this access is for
+ * @pipe:   Pipe to check
  *
  * @return Non zero if we need to do split transactions
  */
@@ -341,7 +341,7 @@ static inline int 
__cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv
 /**
  * Trivial utility function to return the correct PID for a pipe
  *
- * @param pipe   pipe to check
+ * @pipe:   pipe to check
  *
  * @return PID for pipe
  */
@@ -388,7 +388,7 @@ int cvmx_usb_get_num_ports(void)
 /**
  * Allocate a usb transaction for use
  *
- * @param usb   USB device state populated by
+ * @usb:USB device state populated by
  *  cvmx_usb_initialize().
  *
  * @return Transaction or NULL
@@ -413,9 +413,9 @@ static inline cvmx_usb_transaction_t 
*__cvmx_usb_alloc_transaction(cvmx_usb_inte
 /**
  * Free a usb transaction
  *
- * @param usb   USB device state populated by
+ * @usb:USB device state populated by
  *  cvmx_usb_initialize().
- * @param transaction
+ * @transaction:
  *  Transaction to free
  */
 static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb,
@@ -434,8 +434,8 @@ static inline void 
__cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb,
 
 /**
  * Add a pipe to the tail of a list
- * @param list   List to add pipe to
- * @param pipe   Pipe to add
+ * @list:   List to add pipe to
+ * @pipe:   Pipe to add
  */
 static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, 
cvmx_usb_pipe_t *pipe)
 {
@@ -451,8 +451,8 @@ static inline void 
__cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
 
 /**
  * Remove a pipe from a list
- * @param list   List to remove pipe from
- * @param pipe   Pipe to remove
+ * @list:   List to remove pipe from
+ * @pipe:   Pipe to remove
  */
 static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, 
cvmx_usb_pipe_t *pipe)
 {
@@ -481,13 +481,13 @@ static inline void 
__cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
  * other access to the Octeon USB port is made. The port starts
  * off in the disabled state.
  *
- * @param state  Pointer to an empty cvmx_usb_state_t structure
+ * @state:  Pointer to an empty cvmx_usb_state_t structure
  *  that will be populated by the initialize call.
  *  This structure is then passed to all other USB
  *  functions.
- * @param usb_por

[PATCH 14/20] staging: octeon-usb: cvmx-usb: reformat long comments

2013-07-29 Thread Aaro Koskinen
Reformat long comments according to multi-line comment style.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 717 ++
 1 file changed, 462 insertions(+), 255 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index e8fad48..025671a 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -78,9 +78,11 @@
 #define MAX_TRANSFER_BYTES ((1<<19)-1) /* The low level hardware can 
transfer a maximum of this number of bytes in each transfer. The field is 19 
bits wide */
 #define MAX_TRANSFER_PACKETS   ((1<<10)-1) /* The low level hardware can 
transfer a maximum of this number of packets in each transfer. The field is 10 
bits wide */
 
-/* These defines disable the normal read and write csr. This is so I can add
-   extra debug stuff to the usb specific version and I won't use the normal
-   version by mistake */
+/*
+ * These defines disable the normal read and write csr. This is so I can add
+ * extra debug stuff to the usb specific version and I won't use the normal
+ * version by mistake
+ */
 #define cvmx_read_csr use_cvmx_usb_read_csr64_instead_of_cvmx_read_csr
 #define cvmx_write_csr use_cvmx_usb_write_csr64_instead_of_cvmx_write_csr
 
@@ -227,8 +229,10 @@ typedef struct {
} while (0);\
result; })
 
-/* This macro logically sets a single field in a CSR. It does the sequence
-   read, modify, and write */
+/*
+ * This macro logically sets a single field in a CSR. It does the sequence
+ * read, modify, and write
+ */
 #define USB_SET_FIELD32(address, type, field, value)   \
do {\
type c; \
@@ -562,23 +566,30 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
__cvmx_usb_append_pipe(&usb->free_pipes, usb->pipe + i);
}
 
-   /* Power On Reset and PHY Initialization */
-
-   /* 1. Wait for DCOK to assert (nothing to do) */
-   /* 2a. Write USBN0/1_CLK_CTL[POR] = 1 and
-  USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 */
+   /*
+* Power On Reset and PHY Initialization
+*
+* 1. Wait for DCOK to assert (nothing to do)
+*
+* 2a. Write USBN0/1_CLK_CTL[POR] = 1 and
+* USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0
+*/
usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, 
CVMX_USBNX_CLK_CTL(usb->index));
usbn_clk_ctl.s.por = 1;
usbn_clk_ctl.s.hrst = 0;
usbn_clk_ctl.s.prst = 0;
usbn_clk_ctl.s.hclk_rst = 0;
usbn_clk_ctl.s.enable = 0;
-   /* 2b. Select the USB reference clock/crystal parameters by writing
-  appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, 
P_COM_ON] */
+   /*
+* 2b. Select the USB reference clock/crystal parameters by writing
+* appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, P_COM_ON]
+*/
if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) {
-   /* The USB port uses 12/24/48MHz 2.5V board clock
-  source at USB_XO. USB_XI should be tied to GND.
-  Most Octeon evaluation boards require this setting */
+   /*
+* The USB port uses 12/24/48MHz 2.5V board clock
+* source at USB_XO. USB_XI should be tied to GND.
+* Most Octeon evaluation boards require this setting
+*/
if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
usbn_clk_ctl.cn31xx.p_rclk  = 1; /* From CN31XX,CN30XX 
manual */
usbn_clk_ctl.cn31xx.p_xenbn = 0;
@@ -599,8 +610,10 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
break;
}
} else {
-   /* The USB port uses a 12MHz crystal as clock source
-  at USB_XO and USB_XI */
+   /*
+* The USB port uses a 12MHz crystal as clock source
+* at USB_XO and USB_XI
+*/
if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
usbn_clk_ctl.cn31xx.p_rclk  = 1; /* From CN31XX,CN30XX 
manual */
usbn_clk_ctl.cn31xx.p_xenbn = 1;
@@ -611,9 +624,11 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
 
usbn_clk_ctl.s.p_c_sel = 0;
}
-   /* 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and
-  setting USBN0/1_CLK_CTL[ENABLE] = 1.  Divide the core clock down 
such
-  that USB is as close as possible to 125Mhz */
+   /*
+* 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and
+* setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide t

[PATCH 15/20] staging: octeon-usb: cvmx-usb: delete @INTERNAL

2013-07-29 Thread Aaro Koskinen
Delete "@INTERNAL" from comments.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 025671a..d3da546 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -258,7 +258,6 @@ static int octeon_usb_get_clock_type(void)
 }
 
 /**
- * @INTERNAL
  * Read a USB 32bit CSR. It performs the necessary address swizzle
  * for 32bit CSRs and logs the value in a readable format if
  * debugging is on.
@@ -277,7 +276,6 @@ static inline uint32_t 
__cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Write a USB 32bit CSR. It performs the necessary address
  * swizzle for 32bit CSRs and logs the value in a readable format
  * if debugging is on.
@@ -295,7 +293,6 @@ static inline void 
__cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Read a USB 64bit CSR. It logs the value in a readable format if
  * debugging is on.
  *
@@ -313,7 +310,6 @@ static inline uint64_t 
__cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Write a USB 64bit CSR. It logs the value in a readable format
  * if debugging is on.
  *
@@ -328,7 +324,6 @@ static inline void 
__cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb,
 }
 
 /**
- * @INTERNAL
  * Return non zero if this pipe connects to a non HIGH speed
  * device through a high speed hub.
  *
@@ -344,7 +339,6 @@ static inline int 
__cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv
 
 
 /**
- * @INTERNAL
  * Trivial utility function to return the correct PID for a pipe
  *
  * @param pipe   pipe to check
@@ -392,7 +386,6 @@ int cvmx_usb_get_num_ports(void)
 
 
 /**
- * @INTERNAL
  * Allocate a usb transaction for use
  *
  * @param usb   USB device state populated by
@@ -418,7 +411,6 @@ static inline cvmx_usb_transaction_t 
*__cvmx_usb_alloc_transaction(cvmx_usb_inte
 
 
 /**
- * @INTERNAL
  * Free a usb transaction
  *
  * @param usb   USB device state populated by
@@ -441,7 +433,6 @@ static inline void 
__cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Add a pipe to the tail of a list
  * @param list   List to add pipe to
  * @param pipe   Pipe to add
@@ -459,7 +450,6 @@ static inline void 
__cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
 
 
 /**
- * @INTERNAL
  * Remove a pipe from a list
  * @param list   List to remove pipe from
  * @param pipe   Pipe to remove
@@ -1024,7 +1014,6 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, 
cvmx_usb_port_status_t port_st
 
 
 /**
- * @INTERNAL
  * Convert a USB transaction into a handle
  *
  * @param usbUSB device state populated by
@@ -1043,7 +1032,6 @@ static inline int 
__cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Convert a USB pipe into a handle
  *
  * @param usbUSB device state populated by
@@ -1199,7 +1187,6 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, 
cvmx_usb_pipe_flags_t flags,
 
 
 /**
- * @INTERNAL
  * Poll the RX FIFOs and remove data as needed. This function is only used
  * in non DMA mode. It is very important that this function be called quickly
  * enough to prevent FIFO overflow.
@@ -1335,7 +1322,6 @@ static void 
__cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb)
 
 
 /**
- * @INTERNAL
  * Fill the TX FIFO with an outgoing packet
  *
  * @param usbUSB device state populated by
@@ -1383,7 +1369,6 @@ static void 
__cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel)
 }
 
 /**
- * @INTERNAL
  * Perform channel specific setup for Control transactions. All
  * the generic stuff will already have been done in
  * __cvmx_usb_start_channel()
@@ -1515,7 +1500,6 @@ static void 
__cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Start a channel to perform the pipe's head transaction
  *
  * @param usbUSB device state populated by
@@ -1803,7 +1787,6 @@ static void 
__cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Find a pipe that is ready to be scheduled to hardware.
  * @param usb   USB device state populated by
  *  cvmx_usb_initialize().
@@ -1832,7 +1815,6 @@ static cvmx_usb_pipe_t 
*__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *us
 
 
 /**
- * @INTERNAL
  * Called whenever a pipe might need to be scheduled to the
  * hardware.
  *
@@ -1907,7 +1889,6 @@ done:
 
 
 /**
- * @INTERNAL
  * Call a user's callback for a specific reason.
  *
  * @param usb   USB device state populated by
@@ -1953,7 +1934,6 @@ static void 
__cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb,
 
 
 /**
- * @INTERNAL
  * Signal the completion of a transaction and free it. The
  * transaction will be removed from the pipe transaction list.
  *
@@ -2020,7 +2000,6 @@ done:
 
 
 /**
- * @INTERNAL
  * Submit a us

[PATCH 16/20] staging: octeon-usb: cvmx-usb: delete duplicated documentation from .h file

2013-07-29 Thread Aaro Koskinen
Delete duplicated function call documentation from the .h file. These
functions are just internal anyway, and the .h file will be completely
removed in the future when the driver will be made a single self-contained
.c file.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.h | 363 --
 1 file changed, 363 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.h 
b/drivers/staging/octeon-usb/cvmx-usb.h
index dc366c8..30d7213 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.h
+++ b/drivers/staging/octeon-usb/cvmx-usb.h
@@ -409,160 +409,14 @@ typedef enum
 __CVMX_USB_PIPE_FLAGS_NEED_PING = 1<<18,/**< Used internally to 
determine if a high speed pipe is in the ping state. Do not use */
 } cvmx_usb_pipe_flags_t;
 
-/**
- * Return the number of USB ports supported by this Octeon
- * chip. If the chip doesn't support USB, or is not supported
- * by this API, a zero will be returned. Most Octeon chips
- * support one usb port, but some support two ports.
- * cvmx_usb_initialize() must be called on independent
- * cvmx_usb_state_t structures.
- *
- * @return Number of port, zero if usb isn't supported
- */
 extern int cvmx_usb_get_num_ports(void);
-
-/**
- * Initialize a USB port for use. This must be called before any
- * other access to the Octeon USB port is made. The port starts
- * off in the disabled state.
- *
- * @param state  Pointer to an empty cvmx_usb_state_t structure
- *   that will be populated by the initialize call.
- *   This structure is then passed to all other USB
- *   functions.
- * @param usb_port_number
- *   Which Octeon USB port to initialize.
- * @param flags  Flags to control hardware initialization. See
- *   cvmx_usb_initialize_flags_t for the flag
- *   definitions. Some flags are mandatory.
- *
- * @return 0 or a negative error code.
- */
 extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
   cvmx_usb_initialize_flags_t flags);
-
-/**
- * Shutdown a USB port after a call to cvmx_usb_initialize().
- * The port should be disabled with all pipes closed when this
- * function is called.
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- *
- * @return 0 or a negative error code.
- */
 extern int cvmx_usb_shutdown(cvmx_usb_state_t *state);
-
-/**
- * Enable a USB port. After this call succeeds, the USB port is
- * online and servicing requests.
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- *
- * @return 0 or a negative error code.
- */
 extern int cvmx_usb_enable(cvmx_usb_state_t *state);
-
-/**
- * Disable a USB port. After this call the USB port will not
- * generate data transfers and will not generate events.
- * Transactions in process will fail and call their
- * associated callbacks.
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- *
- * @return 0 or a negative error code.
- */
 extern int cvmx_usb_disable(cvmx_usb_state_t *state);
-
-/**
- * Get the current state of the USB port. Use this call to
- * determine if the usb port has anything connected, is enabled,
- * or has some sort of error condition. The return value of this
- * call has "changed" bits to signal of the value of some fields
- * have changed between calls. These "changed" fields are based
- * on the last call to cvmx_usb_set_status(). In order to clear
- * them, you must update the status through cvmx_usb_set_status().
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- *
- * @return Port status information
- */
 extern cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state);
-
-/**
- * Set the current state of the USB port. The status is used as
- * a reference for the "changed" bits returned by
- * cvmx_usb_get_status(). Other than serving as a reference, the
- * status passed to this function is not used. No fields can be
- * changed through this call.
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- * @param port_status
- *   Port status to set, most like returned by 
cvmx_usb_get_status()
- */
 extern void cvmx_usb_set_status(cvmx_usb_state_t *state, 
cvmx_usb_port_status_t port_status);
-
-/**
- * Open a virtual pipe between the host and a USB device. A pipe
- * must be opened before data can be transferred between a device
- * and Octeon.
- *
- * @param state  USB device state populated by
- *   cvmx_usb_initialize().
- * @param flags  Optional pipe flags defined in
- *   cvmx_usb_pipe_flags_t.
- * @param device_addr
- *   USB device address to open the pipe to
- *   (0-127).
- * @param endpoint_num
- *   USB endpoint number to open the pipe to
- *   (0-15).
- * @pa

[PATCH 20/20] staging: octeon-usb: cvmx-usb: reformat documentation

2013-07-29 Thread Aaro Koskinen
Reformat the high-level documentation to human readable plain text by
removing HTML and other tags.

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.h | 101 --
 1 file changed, 48 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.h 
b/drivers/staging/octeon-usb/cvmx-usb.h
index b8e9054..4b425e5 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.h
+++ b/drivers/staging/octeon-usb/cvmx-usb.h
@@ -39,8 +39,6 @@
 
 
 /**
- * @file
- *
  * "cvmx-usb.h" defines a set of low level USB functions to help
  * developers create Octeon USB drivers for various operating
  * systems. These functions provide a generic API to the Octeon
@@ -49,24 +47,24 @@
  *
  * At a high level the device driver needs to:
  *
- * -# Call cvmx_usb_get_num_ports() to get the number of
- *  supported ports.
- * -# Call cvmx_usb_initialize() for each Octeon USB port.
- * -# Enable the port using cvmx_usb_enable().
- * -# Either periodically, or in an interrupt handler, call
- *  cvmx_usb_poll() to service USB events.
- * -# Manage pipes using cvmx_usb_open_pipe() and
- *  cvmx_usb_close_pipe().
- * -# Manage transfers using cvmx_usb_submit_*() and
- *  cvmx_usb_cancel*().
- * -# Shutdown USB on unload using cvmx_usb_shutdown().
+ * - Call cvmx_usb_get_num_ports() to get the number of
+ *   supported ports.
+ * - Call cvmx_usb_initialize() for each Octeon USB port.
+ * - Enable the port using cvmx_usb_enable().
+ * - Either periodically, or in an interrupt handler, call
+ *   cvmx_usb_poll() to service USB events.
+ * - Manage pipes using cvmx_usb_open_pipe() and
+ *   cvmx_usb_close_pipe().
+ * - Manage transfers using cvmx_usb_submit_*() and
+ *   cvmx_usb_cancel*().
+ * - Shutdown USB on unload using cvmx_usb_shutdown().
  *
  * To monitor USB status changes, the device driver must use
  * cvmx_usb_register_callback() to register for events that it
  * is interested in. Below are a few hints on successfully
  * implementing a driver on top of this API.
  *
- * Initialization
+ * == Initialization ==
  *
  * When a driver is first loaded, it is normally not necessary
  * to bring up the USB port completely. Most operating systems
@@ -75,24 +73,24 @@
  * initialize anything found, and then enable the hardware.
  *
  * In the probe phase you should:
- * -# Use cvmx_usb_get_num_ports() to determine the number of
- *  USB port to be supported.
- * -# Allocate space for a cvmx_usb_state_t structure for each
- *  port.
- * -# Tell the operating system about each port
+ * - Use cvmx_usb_get_num_ports() to determine the number of
+ *   USB port to be supported.
+ * - Allocate space for a cvmx_usb_state_t structure for each
+ *   port.
+ * - Tell the operating system about each port
  *
  * In the initialization phase you should:
- * -# Use cvmx_usb_initialize() on each port.
- * -# Do not call cvmx_usb_enable(). This leaves the USB port in
- *  the disabled state until the operating system is ready.
+ * - Use cvmx_usb_initialize() on each port.
+ * - Do not call cvmx_usb_enable(). This leaves the USB port in
+ *   the disabled state until the operating system is ready.
  *
  * Finally, in the enable phase you should:
- * -# Call cvmx_usb_enable() on the appropriate port.
- * -# Note that some operating system use a RESET instead of an
- *  enable call. To implement RESET, you should call
- *  cvmx_usb_disable() followed by cvmx_usb_enable().
+ * - Call cvmx_usb_enable() on the appropriate port.
+ * - Note that some operating system use a RESET instead of an
+ *   enable call. To implement RESET, you should call
+ *   cvmx_usb_disable() followed by cvmx_usb_enable().
  *
- * Locking
+ * == Locking ==
  *
  * All of the functions in the cvmx-usb API assume exclusive
  * access to the USB hardware and internal data structures. This
@@ -112,7 +110,7 @@
  * take a lock to make sure that another core cannot call
  * cvmx-usb.
  *
- * Port callback
+ * == Port callback ==
  *
  * The port callback prototype needs to look as follows:
  *
@@ -123,14 +121,13 @@
  *int submit_handle,
  *int bytes_transferred,
  *void *user_data);
- * - @b usb is the cvmx_usb_state_t for the port.
- * - @b reason will always be
- *   CVMX_USB_CALLBACK_PORT_CHANGED.
- * - @b status will always be CVMX_USB_COMPLETE_SUCCESS.
- * - @b pipe_handle will always be -1.
- * - @b submit_handle will always be -1.
- * - @b bytes_transferred will always be 0.
- * - @b user_data is the void pointer originally passed along
+ * - "usb" is the cvmx_usb_state_t for the port.
+ * - "reason" will always be CVMX_USB_CALLBACK_PORT_CHANGED.
+ * - "status" will always be CVMX_USB_COMPLETE_SUCCESS.
+ * - "pipe_handle" will always be -1.
+ * - "submit_handle" will always be -1.
+ * - "bytes_transferred" will always be 0.
+ * - "user_data" is the void pointer originally passed along
  *   with the callback. Use this for any state information you
  *   need.
  *

[PATCH 18/20] staging: octeon-usb: cvmx-usb: convert @return

2013-07-29 Thread Aaro Koskinen
Convert "@return" to "Returns: ".

Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/cvmx-usb.c | 72 +--
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usb.c 
b/drivers/staging/octeon-usb/cvmx-usb.c
index 9a7b53a..a3ac340 100644
--- a/drivers/staging/octeon-usb/cvmx-usb.c
+++ b/drivers/staging/octeon-usb/cvmx-usb.c
@@ -265,7 +265,7 @@ static int octeon_usb_get_clock_type(void)
  * @usb: USB block this access is for
  * @address: 64bit address to read
  *
- * @return Result of the read
+ * Returns: Result of the read
  */
 static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb,
 uint64_t address)
@@ -299,7 +299,7 @@ static inline void 
__cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb,
  * @usb: USB block this access is for
  * @address: 64bit address to read
  *
- * @return Result of the read
+ * Returns: Result of the read
  */
 static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb,
 uint64_t address)
@@ -330,7 +330,7 @@ static inline void 
__cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb,
  * @usb:USB block this access is for
  * @pipe:   Pipe to check
  *
- * @return Non zero if we need to do split transactions
+ * Returns: Non zero if we need to do split transactions
  */
 static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, 
cvmx_usb_pipe_t *pipe)
 {
@@ -343,7 +343,7 @@ static inline int 
__cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv
  *
  * @pipe:   pipe to check
  *
- * @return PID for pipe
+ * Returns: PID for pipe
  */
 static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe)
 {
@@ -362,7 +362,7 @@ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t 
*pipe)
  * cvmx_usb_initialize() must be called on independent
  * cvmx_usb_state_t structures.
  *
- * @return Number of port, zero if usb isn't supported
+ * Returns: Number of port, zero if usb isn't supported
  */
 int cvmx_usb_get_num_ports(void)
 {
@@ -391,7 +391,7 @@ int cvmx_usb_get_num_ports(void)
  * @usb:USB device state populated by
  *  cvmx_usb_initialize().
  *
- * @return Transaction or NULL
+ * Returns: Transaction or NULL
  */
 static inline cvmx_usb_transaction_t 
*__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb)
 {
@@ -491,7 +491,7 @@ static inline void 
__cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
  *  cvmx_usb_initialize_flags_t for the flag
  *  definitions. Some flags are mandatory.
  *
- * @return 0 or a negative error code.
+ * Returns: 0 or a negative error code.
  */
 int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
cvmx_usb_initialize_flags_t flags)
@@ -818,7 +818,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int 
usb_port_number,
  * @state: USB device state populated by
  *cvmx_usb_initialize().
  *
- * @return 0 or a negative error code.
+ * Returns: 0 or a negative error code.
  */
 int cvmx_usb_shutdown(cvmx_usb_state_t *state)
 {
@@ -853,7 +853,7 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state)
  * @state: USB device state populated by
  *cvmx_usb_initialize().
  *
- * @return 0 or a negative error code.
+ * Returns: 0 or a negative error code.
  */
 int cvmx_usb_enable(cvmx_usb_state_t *state)
 {
@@ -947,7 +947,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state)
  * @state: USB device state populated by
  *cvmx_usb_initialize().
  *
- * @return 0 or a negative error code.
+ * Returns: 0 or a negative error code.
  */
 int cvmx_usb_disable(cvmx_usb_state_t *state)
 {
@@ -971,7 +971,7 @@ int cvmx_usb_disable(cvmx_usb_state_t *state)
  * @state: USB device state populated by
  *cvmx_usb_initialize().
  *
- * @return Port status information
+ * Returns: Port status information
  */
 cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state)
 {
@@ -1021,7 +1021,7 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, 
cvmx_usb_port_status_t port_st
  * @transaction:
  *  Transaction to get handle for
  *
- * @return Handle
+ * Returns: Handle
  */
 static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb,
   cvmx_usb_transaction_t 
*transaction)
@@ -1038,7 +1038,7 @@ static inline int 
__cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb,
  *  cvmx_usb_initialize().
  * @pipe:   Pipe to get handle for
  *
- * @return Handle
+ * Returns: Handle
  */
 static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb,
 cvmx_usb_pipe_t *pipe)
@@ -1100,8 +1100,8 @@ static inline int 
__cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb,
  *  this is only used for full/low speed
  *

Re: linux-next: Tree for Jul 29 (staging/gdm724x)

2013-07-29 Thread Randy Dunlap
On 07/28/13 23:39, Stephen Rothwell wrote:
> Hi all,
> 
> Changes since 20130726:
> 

on i386:
# CONFIG_TTY is not set


ERROR: "tty_port_tty_get" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_port_close_end" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_register_driver" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_buffer_request_room" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "put_tty_driver" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_port_close_start" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_set_operations" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_port_init" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_insert_flip_string_fixed_flag" [drivers/staging/gdm724x/gdmtty.ko] 
undefined!
ERROR: "tty_register_device" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_unregister_device" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_std_termios" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_unregister_driver" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "__tty_alloc_driver" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_flip_buffer_push" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_port_tty_set" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_wakeup" [drivers/staging/gdm724x/gdmtty.ko] undefined!
ERROR: "tty_port_block_til_ready" [drivers/staging/gdm724x/gdmtty.ko] undefined!



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


Re: [PATCH 09/20] staging: octeon-usb: cvmx-usb: replace long udelays with mdelays

2013-07-29 Thread Andi Shyti
Hi Aaro,

> -cvmx_wait_usec(1000);
> +mdelay(1);

why not udelay here?

> -cvmx_wait_usec(5);
> +mdelay(50);

and why not msleep here?

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


Re: [PATCH 09/20] staging: octeon-usb: cvmx-usb: replace long udelays with mdelays

2013-07-29 Thread Aaro Koskinen
Hi,

On Mon, Jul 29, 2013 at 07:52:14PM +0200, Andi Shyti wrote:
> > -cvmx_wait_usec(1000);
> > +mdelay(1);
> 
> why not udelay here?

It's long enough so that mdelay can be used. :)

> > -cvmx_wait_usec(5);
> > +mdelay(50);
> 
> and why not msleep here?

cvmx_usb_enable() is called holding a spinlock with interrupts disabled.
We cannot sleep here.

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


Re: [PATCH 09/20] staging: octeon-usb: cvmx-usb: replace long udelays with mdelays

2013-07-29 Thread Andi Shyti
> > > -cvmx_wait_usec(1000);
> > > +mdelay(1);
> > 
> > why not udelay here?
> 
> It's long enough so that mdelay can be used. :)

sorry, I was meaning usleep_range :)

> > > -cvmx_wait_usec(5);
> > > +mdelay(50);
> > 
> > and why not msleep here?
> 
> cvmx_usb_enable() is called holding a spinlock with interrupts disabled.
> We cannot sleep here.

Arrgghhh! OK, makes sense then.

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


Re: [PATCH] staging: android: logger..c fixed a brace coding style issue

2013-07-29 Thread Greg KH
On Sun, Jul 28, 2013 at 04:47:51PM +0300, abbasjasim wrote:
> fixed a coding style issue.
> 
> Signed-off-by: Abbas J. Mohammed 
> ---
>  drivers/staging/android/logger.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/logger.c 
> b/drivers/staging/android/logger.c
> index ffc2d04..3d5180a 100644
> --- a/drivers/staging/android/logger.c
> +++ b/drivers/staging/android/logger.c
> @@ -81,8 +81,9 @@ static inline struct logger_log *file_get_log(struct file 
> *file)
>   if (file->f_mode & FMODE_READ) {
>   struct logger_reader *reader = file->private_data;
>   return reader->log;
> - } else
> + } else {
>   return file->private_data;
> + }

I think the existing code is just fine, no need for this patch.

thanks,

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


Re: [PATCH v2 1/5] Staging: bcm: LeakyBucket: Fixed spacing/tabing issues

2013-07-29 Thread Greg KH
On Sun, Jul 28, 2013 at 03:34:43AM +0800, Lilis Iskandar wrote:
> Sorry, I'm using git send-email now (previously Evolution). Fingers
> crossed there won't be any more formatting issues. I also tested the
> patches by emailing them to myself and use git am.
> 
> Joe, I don't understand what you mean by mentioning "git diff -w".
> Perhaps you can clarify it for me? Sorry :(
> 
> Summary:
> The series of patches fixes coding style issues. This one fixes
> spacing/tabbing issues.

In the future, please put this in the 0/5 email, not in 1/5, because I
have to edit this out by hand :(

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


Re: linux-next: Tree for Jul 29 (staging/gdm724x)

2013-07-29 Thread Greg Kroah-Hartman
On Mon, Jul 29, 2013 at 10:04:41AM -0700, Randy Dunlap wrote:
> On 07/28/13 23:39, Stephen Rothwell wrote:
> > Hi all,
> > 
> > Changes since 20130726:
> > 
> 
> on i386:
> # CONFIG_TTY is not set

Thanks, now fixed.

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


[PATCH 00/38] staging: comedi: das16: cleanup driver

2013-07-29 Thread H Hartley Sweeten
Remove the disabled interrupt support code. This driver always uses
a timer with DMA due to the hardware dropping samples when interrrupts
are used.

Cleanup the boardinfo to just contain the necessary board specific
information.

Tidy up the driver.

H Hartley Sweeten (38):
  staging: comedi: das16: "timer_mode" is always used for DMA
  staging: comedi: das16: remove DMA irq support
  staging: comedi: das16: fix DMA init during board attach
  staging: comedi: das16: all supported board have analog inputs
  staging: comedi: das16: change boardinfo 'ai_nbits' to 'ai_maxdata'
  staging: comedi: das16: all supported board have digital inputs
  staging: comedi: das16: all supported board have digital outputs
  staging: comedi: das16: cleanup analog output subdevice
  staging: comedi: das16: tidy up the comedi_lrange tables
  staging: comedi: das16: remove unused struct definition
  staging: comedi: das16: remove 'ai_unipolar' and 'ai_singleended'
  staging: comedi: das16: remove reg_dump()
  staging: comedi: das16: remove DEBUG_PRINT macro
  staging: comedi: das16: remove 'volatile' on private data variables
  staging: comedi: das16: add a 'can_burst' flag to the private data
  staging: comedi: das16: remove unused DAS16_SIZE
  staging: comedi: das16: remove unused static const variable
  staging: comedi: das16: remove the register map comments
  staging: comedi: das16: introduce das16_ai_{en,dis}able() helpers
  staging: comedi: das16: tidy up das16_ai_insn_read()
  staging: comedi: das16: move some functions to improve readability
  staging: comedi: das16: remove unnecessary test in das16_interrupt()
  staging: comedi: das16: move boardinfo declaration
  staging: comedi: das16: remove 'i8254_offset' from boardinfo
  staging: comedi: das16: tidy up 8255 digital i/o subdevice
  staging: comedi: das16: tidy up the register map defines
  staging: comedi: das16: fail attach if board id is incorrect
  staging: comedi: das16: cleanup printk message in board attach
  staging: comedi: das16: absorb das1600_mode_detect() into caller
  staging: comedi: das16: fix a > 80 char line issue
  staging: comedi: das16: cleanup comedi_error() messages
  staging: comedi: das16: tidy up private data definition
  staging: comedi: das16: change MODULE_DESCRIPTION
  staging: comedi: das16: fix das16_detach()
  staging: comedi: das16: remove an unnecessary check in the attach
  staging: comedi: das16: tidy up user ai/ao range initialization
  staging: comedi: das16: remove some unnecessary parentheses
  staging: comedi: das16: tidy up multi-line comments

 drivers/staging/comedi/drivers/das16.c | 2022 +---
 1 file changed, 806 insertions(+), 1216 deletions(-)

-- 
1.8.3.2

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


[PATCH 01/38] staging: comedi: das16: "timer_mode" is always used for DMA

2013-07-29 Thread H Hartley Sweeten
As noted in the driver, a timer is always used by this driver to handle the
DMA due to buggy DMA controllers and the lack of a hardware fifo in some of
the supported boards.

Remove all the non-timer mode specific code.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 593ec38..2dd03da 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -387,7 +387,6 @@ struct das16_private_struct {
 
struct timer_list timer;/*  for timed interrupt */
volatile short timer_running;
-   volatile short timer_mode;  /*  true if using timer mode */
 
unsigned long extra_iobase;
 };
@@ -516,49 +515,6 @@ static int das16_cmd_test(struct comedi_device *dev, 
struct comedi_subdevice *s,
return 0;
 }
 
-/* utility function that suggests a dma transfer size in bytes */
-static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
-   const struct comedi_cmd *cmd)
-{
-   struct das16_private_struct *devpriv = dev->private;
-   unsigned int size;
-   unsigned int freq;
-
-   /* if we are using timer interrupt, we don't care how long it
-* will take to complete transfer since it will be interrupted
-* by timer interrupt */
-   if (devpriv->timer_mode)
-   return DAS16_DMA_SIZE;
-
-   /* otherwise, we are relying on dma terminal count interrupt,
-* so pick a reasonable size */
-   if (cmd->convert_src == TRIG_TIMER)
-   freq = 10 / cmd->convert_arg;
-   else if (cmd->scan_begin_src == TRIG_TIMER)
-   freq = (10 / cmd->scan_begin_arg) * cmd->chanlist_len;
-   /*  return some default value */
-   else
-   freq = 0x;
-
-   if (cmd->flags & TRIG_WAKE_EOS) {
-   size = sample_size * cmd->chanlist_len;
-   } else {
-   /*  make buffer fill in no more than 1/3 second */
-   size = (freq / 3) * sample_size;
-   }
-
-   /*  set a minimum and maximum size allowed */
-   if (size > DAS16_DMA_SIZE)
-   size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size;
-   else if (size < sample_size)
-   size = sample_size;
-
-   if (cmd->stop_src == TRIG_COUNT && size > devpriv->adc_byte_count)
-   size = devpriv->adc_byte_count;
-
-   return size;
-}
-
 static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
int rounding_flags)
 {
@@ -585,13 +541,6 @@ static int das16_cmd_exec(struct comedi_device *dev, 
struct comedi_subdevice *s)
unsigned long flags;
int range;
 
-   if (devpriv->dma_chan == 0 || (dev->irq == 0
-  && devpriv->timer_mode == 0)) {
-   comedi_error(dev,
-   "irq (or use of 'timer mode') dma required to "
-   "execute comedi_cmd");
-   return -1;
-   }
if (cmd->flags & TRIG_RT) {
comedi_error(dev, "isa dma transfers cannot be performed with "
"TRIG_RT, aborting");
@@ -648,24 +597,16 @@ static int das16_cmd_exec(struct comedi_device *dev, 
struct comedi_subdevice *s)
devpriv->current_buffer = 0;
set_dma_addr(devpriv->dma_chan,
 devpriv->dma_buffer_addr[devpriv->current_buffer]);
-   /*  set appropriate size of transfer */
-   devpriv->dma_transfer_size = das16_suggest_transfer_size(dev, cmd);
+   devpriv->dma_transfer_size = DAS16_DMA_SIZE;
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
release_dma_lock(flags);
 
/*  set up interrupt */
-   if (devpriv->timer_mode) {
-   devpriv->timer_running = 1;
-   devpriv->timer.expires = jiffies + timer_period();
-   add_timer(&devpriv->timer);
-   devpriv->control_state &= ~DAS16_INTE;
-   } else {
-   /* clear interrupt bit */
-   outb(0x00, dev->iobase + DAS16_STATUS);
-   /* enable interrupts */
-   devpriv->control_state |= DAS16_INTE;
-   }
+   devpriv->timer_running = 1;
+   devpriv->timer.expires = jiffies + timer_period();
+   add_timer(&devpriv->timer);
+   devpriv->control_state &= ~DAS16_INTE;
devpriv->control_state |= DMA_ENABLE;
devpriv->control_state &= ~PACING_MASK;
if (cmd->convert_src == TRIG_EXT)
@@ -696,7 +637,7 @@ static int das16_cancel(struct comedi_device *dev, struct 
comedi

[PATCH 04/38] staging: comedi: das16: all supported board have analog inputs

2013-07-29 Thread H Hartley Sweeten
All the boards supported by this driver have analog inputs and all
of then use the same function to handle the (*insn_read) for the
subdevice.

Remove the 'ai' member from the boardinfo and always initalize the
analog input subdevice during the board attach.

Tidy up the subdevice init a bit.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index f35aabd..0b76af6 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -338,7 +338,6 @@ struct munge_info {
 
 struct das16_board {
const char *name;
-   void *ai;
unsigned int ai_nbits;
unsigned int ai_speed;  /*  max conversion speed in nanosec */
unsigned int ai_pg;
@@ -659,8 +658,10 @@ static void das16_reset(struct comedi_device *dev)
outb(0, dev->iobase + DAS16_CNTR_CONTROL);
 }
 
-static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice 
*s,
- struct comedi_insn *insn, unsigned int *data)
+static int das16_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
 {
const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv = dev->private;
@@ -1099,39 +1100,34 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
if (ret)
return ret;
 
+   /* Analog Input subdevice */
s = &dev->subdevices[0];
-   /* ai */
-   if (board->ai) {
-   s->type = COMEDI_SUBD_AI;
-   s->subdev_flags = SDF_READABLE;
-   if (devpriv->ai_singleended) {
-   s->n_chan = 16;
-   s->len_chanlist = 16;
-   s->subdev_flags |= SDF_GROUND;
-   } else {
-   s->n_chan = 8;
-   s->len_chanlist = 8;
-   s->subdev_flags |= SDF_DIFF;
-   }
-   s->maxdata = (1 << board->ai_nbits) - 1;
-   if (devpriv->user_ai_range_table) { /*  user defined ai range */
-   s->range_table = devpriv->user_ai_range_table;
-   } else if (devpriv->ai_unipolar) {
-   s->range_table = das16_ai_uni_lranges[board->ai_pg];
-   } else {
-   s->range_table = das16_ai_bip_lranges[board->ai_pg];
-   }
-   s->insn_read = board->ai;
-   if (devpriv->dma_chan) {
-   dev->read_subdev = s;
-   s->subdev_flags |= SDF_CMD_READ;
-   s->do_cmdtest = das16_cmd_test;
-   s->do_cmd = das16_cmd_exec;
-   s->cancel = das16_cancel;
-   s->munge = das16_ai_munge;
-   }
+   s->type = COMEDI_SUBD_AI;
+   s->subdev_flags = SDF_READABLE;
+   if (devpriv->ai_singleended) {
+   s->subdev_flags |= SDF_GROUND;
+   s->n_chan   = 16;
} else {
-   s->type = COMEDI_SUBD_UNUSED;
+   s->subdev_flags |= SDF_DIFF;
+   s->n_chan   = 8;
+   }
+   s->len_chanlist = s->n_chan;
+   s->maxdata  = (1 << board->ai_nbits) - 1;
+   if (devpriv->user_ai_range_table) { /*  user defined ai range */
+   s->range_table  = devpriv->user_ai_range_table;
+   } else if (devpriv->ai_unipolar) {
+   s->range_table  = das16_ai_uni_lranges[board->ai_pg];
+   } else {
+   s->range_table  = das16_ai_bip_lranges[board->ai_pg];
+   }
+   s->insn_read= das16_ai_insn_read;
+   if (devpriv->dma_chan) {
+   dev->read_subdev = s;
+   s->subdev_flags |= SDF_CMD_READ;
+   s->do_cmdtest   = das16_cmd_test;
+   s->do_cmd   = das16_cmd_exec;
+   s->cancel   = das16_cancel;
+   s->munge= das16_ai_munge;
}
 
s = &dev->subdevices[1];
@@ -1232,7 +1228,6 @@ static void das16_detach(struct comedi_device *dev)
 static const struct das16_board das16_boards[] = {
{
.name   = "das-16",
-   .ai = das16_ai_rinsn,
.ai_nbits   = 12,
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
@@ -1246,7 +1241,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00,
}, {
.name   = "das-16g",
-   .ai = das16_ai_rinsn,
.ai_nbits   =

[PATCH 02/38] staging: comedi: das16: remove DMA irq support

2013-07-29 Thread H Hartley Sweeten
As noted in the driver, a timer is always used by this driver to handle
the DMA because samples could be dropped while waiting for the DMA done
interrupt.

Remove the irq setup code as well as the interrupt handler.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 2dd03da..52f98a7 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -872,24 +872,6 @@ static void das16_interrupt(struct comedi_device *dev)
cfc_handle_events(dev, s);
 }
 
-static irqreturn_t das16_dma_interrupt(int irq, void *d)
-{
-   int status;
-   struct comedi_device *dev = d;
-
-   status = inb(dev->iobase + DAS16_STATUS);
-
-   if ((status & DAS16_INT) == 0) {
-   DEBUG_PRINT("spurious interrupt\n");
-   return IRQ_NONE;
-   }
-
-   /* clear interrupt */
-   outb(0x00, dev->iobase + DAS16_STATUS);
-   das16_interrupt(dev);
-   return IRQ_HANDLED;
-}
-
 static void das16_timer_interrupt(unsigned long arg)
 {
struct comedi_device *dev = (struct comedi_device *)arg;
@@ -1006,18 +988,10 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
struct das16_private_struct *devpriv;
struct comedi_subdevice *s;
int ret;
-   unsigned int irq;
unsigned int dma_chan;
unsigned long flags;
struct comedi_krange *user_ai_range, *user_ao_range;
 
-#if 0
-   irq = it->options[1];
-#endif
-   /* always use time_mode since using irq can drop samples while
-* waiting for dma done interrupt (due to hardware limitations) */
-   irq = 0;
-
/*  check that clock setting is valid */
if (it->options[3]) {
if (it->options[3] != 0 &&
@@ -1065,22 +1039,6 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
das1600_mode_detect(dev);
}
 
-   /* now for the irq */
-   if (irq > 1 && irq < 8) {
-   ret = request_irq(irq, das16_dma_interrupt, 0,
- dev->board_name, dev);
-
-   if (ret < 0)
-   return ret;
-   dev->irq = irq;
-   printk(KERN_INFO " ( irq = %u )", irq);
-   } else if (irq == 0) {
-   printk(" ( no irq )");
-   } else {
-   printk(" invalid irq\n");
-   return -EINVAL;
-   }
-
/*  initialize dma */
dma_chan = it->options[2];
if (dma_chan == 1 || dma_chan == 3) {
-- 
1.8.3.2

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


[PATCH 03/38] staging: comedi: das16: fix DMA init during board attach

2013-07-29 Thread H Hartley Sweeten
DMA support is optional in this driver. To enable it, the user
passes the desired DMA channel during the board attach. A timer
is then used by the driver to periodically get the analog input
data from the DMA.

Since the DMA support is optional, modify the init code so that
it only fails if the DMA channel is unavailable or the DMA buffers
can not be allocated. Don't fail just because the user passed an
invalid DMA channel (only DMA channels 1 and 3 are valid).

Remove the printk() noise about the DMA. Change the printk() when
the request_dma() fails into a dev_err().

Move the timer initialization so it's only setup if DMA is available.
It's not needed otherwise. Also, only hook up the subdevice command
support functions if DMA is available. This allows removing a couple
sanity checks in the command support.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 52f98a7..f35aabd 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -633,8 +633,7 @@ static int das16_cancel(struct comedi_device *dev, struct 
comedi_subdevice *s)
/* disable interrupts, dma and pacer clocked conversions */
devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
-   if (devpriv->dma_chan)
-   disable_dma(devpriv->dma_chan);
+   disable_dma(devpriv->dma_chan);
 
/*  disable SW timer */
if (devpriv->timer_running) {
@@ -821,11 +820,6 @@ static void das16_interrupt(struct comedi_device *dev)
async = s->async;
cmd = &async->cmd;
 
-   if (devpriv->dma_chan == 0) {
-   comedi_error(dev, "interrupt with no dma channel?");
-   return;
-   }
-
spin_lock_irqsave(&dev->spinlock, spin_flags);
if ((devpriv->control_state & DMA_ENABLE) == 0) {
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
@@ -987,10 +981,10 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv;
struct comedi_subdevice *s;
+   struct comedi_krange *user_ai_range;
+   struct comedi_krange *user_ao_range;
+   unsigned int dma_chan = it->options[2];
int ret;
-   unsigned int dma_chan;
-   unsigned long flags;
-   struct comedi_krange *user_ai_range, *user_ao_range;
 
/*  check that clock setting is valid */
if (it->options[3]) {
@@ -1039,35 +1033,38 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
das1600_mode_detect(dev);
}
 
-   /*  initialize dma */
-   dma_chan = it->options[2];
+   /* initialize dma */
if (dma_chan == 1 || dma_chan == 3) {
-   /*  allocate dma buffers */
+   unsigned long flags;
int i;
-   for (i = 0; i < 2; i++) {
-   devpriv->dma_buffer[i] = pci_alloc_consistent(
-   NULL, DAS16_DMA_SIZE,
-   &devpriv->dma_buffer_addr[i]);
 
-   if (devpriv->dma_buffer[i] == NULL)
-   return -ENOMEM;
-   }
if (request_dma(dma_chan, dev->board_name)) {
-   printk(KERN_ERR " failed to allocate dma channel %i\n",
-  dma_chan);
+   dev_err(dev->class_dev,
+   "failed to request dma channel %i\n",
+   dma_chan);
return -EINVAL;
}
devpriv->dma_chan = dma_chan;
+
+   /* allocate dma buffers */
+   for (i = 0; i < 2; i++) {
+   void *p;
+
+   p = pci_alloc_consistent(NULL, DAS16_DMA_SIZE,
+&devpriv->dma_buffer_addr[i]);
+   if (!p)
+   return -ENOMEM;
+   devpriv->dma_buffer[i] = p;
+   }
+
flags = claim_dma_lock();
disable_dma(devpriv->dma_chan);
set_dma_mode(devpriv->dma_chan, DMA_MODE_READ);
release_dma_lock(flags);
-   printk(KERN_INFO " ( dma = %u)\n", dma_chan);
-   } else if (dma_chan == 0) {
-   printk(KERN_INFO " ( no dma )\n");
-   } else {
-   printk(KERN_ERR " invalid dma channel\n");
-   return -EINVAL;
+
+   init_timer(&(devpriv->timer));
+   devpriv->

[PATCH 05/38] staging: comedi: das16: change boardinfo 'ai_nbits' to 'ai_maxdata'

2013-07-29 Thread H Hartley Sweeten
The subdevice functions that used this boardinfo can use the subdevice
's->maxdata' value instead. Tidy up those functions.

Change the boardinfo so that the calculation is not needed during the
attach.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 0b76af6..11e5787 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -338,7 +338,7 @@ struct munge_info {
 
 struct das16_board {
const char *name;
-   unsigned int ai_nbits;
+   unsigned int ai_maxdata;
unsigned int ai_speed;  /*  max conversion speed in nanosec */
unsigned int ai_pg;
void *ao;
@@ -668,7 +668,6 @@ static int das16_ai_insn_read(struct comedi_device *dev,
int i, n;
int range;
int chan;
-   int msb, lsb;
 
/*  disable interrupts and pacing */
devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK;
@@ -687,6 +686,8 @@ static int das16_ai_insn_read(struct comedi_device *dev,
}
 
for (n = 0; n < insn->n; n++) {
+   unsigned int val;
+
/* trigger conversion */
outb_p(0, dev->iobase + DAS16_TRIG);
 
@@ -698,13 +699,14 @@ static int das16_ai_insn_read(struct comedi_device *dev,
printk("das16: timeout\n");
return -ETIME;
}
-   msb = inb(dev->iobase + DAS16_AI_MSB);
-   lsb = inb(dev->iobase + DAS16_AI_LSB);
-   if (board->ai_nbits == 12)
-   data[n] = ((lsb >> 4) & 0xf) | (msb << 4);
-   else
-   data[n] = lsb | (msb << 8);
 
+   val = inb(dev->iobase + DAS16_AI_MSB) << 8;
+   val |= inb(dev->iobase + DAS16_AI_LSB);
+   if (s->maxdata == 0x0fff)
+   data[n] >>= 4;
+   val &= s->maxdata;
+
+   data[n] = val;
}
 
return n;
@@ -957,15 +959,14 @@ static void das16_ai_munge(struct comedi_device *dev,
   unsigned int num_bytes,
   unsigned int start_chan_index)
 {
-   const struct das16_board *board = comedi_board(dev);
unsigned int i, num_samples = num_bytes / sizeof(short);
short *data = array;
 
for (i = 0; i < num_samples; i++) {
data[i] = le16_to_cpu(data[i]);
-   if (board->ai_nbits == 12)
-   data[i] = (data[i] >> 4) & 0xfff;
-
+   if (s->maxdata == 0x0fff)
+   data[i] >>= 4;
+   data[i] &= s->maxdata;
}
 }
 
@@ -1112,7 +1113,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
s->n_chan   = 8;
}
s->len_chanlist = s->n_chan;
-   s->maxdata  = (1 << board->ai_nbits) - 1;
+   s->maxdata  = board->ai_maxdata;
if (devpriv->user_ai_range_table) { /*  user defined ai range */
s->range_table  = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
@@ -1228,7 +1229,7 @@ static void das16_detach(struct comedi_device *dev)
 static const struct das16_board das16_boards[] = {
{
.name   = "das-16",
-   .ai_nbits   = 12,
+   .ai_maxdata = 0x0fff,
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
@@ -1241,7 +1242,7 @@ static const struct das16_board das16_boards[] = {
.id = 0x00,
}, {
.name   = "das-16g",
-   .ai_nbits   = 12,
+   .ai_maxdata = 0x0fff,
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
@@ -1254,7 +1255,7 @@ static const struct das16_board das16_boards[] = {
.id = 0x00,
}, {
.name   = "das-16f",
-   .ai_nbits   = 12,
+   .ai_maxdata = 0x0fff,
.ai_speed   = 8500,
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
@@ -1267,7 +1268,7 @@ static const struct das16_board das16_boards[] = {
.id = 0x00,
}, {
.name   = "cio-das16",
-   .ai_nbits   = 12,
+   .ai_maxdata = 0x0fff,
.ai_speed   = 2,
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
@@ -1280,7 +1281,7 @@ static const struct das16_board das16_boards[] 

[PATCH 07/38] staging: comedi: das16: all supported board have digital outputs

2013-07-29 Thread H Hartley Sweeten
All the boards supported by this driver have digital outputs and all
of then use the same function to handle the (*insn_bits) for the
subdevice.

Remove the 'do_' member from the boardinfo and always initialize the
digital output subdevice during the board attach.

Tidy up the subdevice init a bit as well as the (*insn_bits) function.
Remove SDF_READABLE from the subdev_flags. This is a pure digital output
subdevice and the outputs are not readable.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 3528c82..22d2bf4 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -343,7 +343,6 @@ struct das16_board {
unsigned int ai_pg;
void *ao;
unsigned int ao_nbits;
-   void *do_;
 
unsigned int i8255_offset;
unsigned int i8254_offset;
@@ -721,22 +720,22 @@ static int das16_di_insn_bits(struct comedi_device *dev,
return insn->n;
 }
 
-static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice 
*s,
- struct comedi_insn *insn, unsigned int *data)
+static int das16_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
 {
-   unsigned int wbits;
-
-   /*  only set bits that have been masked */
-   data[0] &= 0xf;
-   wbits = s->state;
-   /*  zero bits that have been masked */
-   wbits &= ~data[0];
-   /*  set masked bits */
-   wbits |= data[0] & data[1];
-   s->state = wbits;
-   data[1] = wbits;
+   unsigned int mask = data[0];
+   unsigned int bits = data[1];
 
-   outb(s->state, dev->iobase + DAS16_DIO);
+   if (mask) {
+   s->state &= ~mask;
+   s->state |= (bits & mask);
+
+   outb(s->state, dev->iobase + DAS16_DIO);
+   }
+
+   data[1] = s->state;
 
return insn->n;
 }
@@ -1155,20 +1154,17 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
s->range_table  = &range_digital;
s->insn_bits= das16_di_insn_bits;
 
+   /* Digital Output subdevice */
s = &dev->subdevices[3];
-   /* do */
-   if (board->do_) {
-   s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-   s->n_chan = 4;
-   s->maxdata = 1;
-   s->range_table = &range_digital;
-   s->insn_bits = board->do_;
-   /*  initialize digital output lines */
-   outb(s->state, dev->iobase + DAS16_DIO);
-   } else {
-   s->type = COMEDI_SUBD_UNUSED;
-   }
+   s->type = COMEDI_SUBD_DO;
+   s->subdev_flags = SDF_WRITABLE;
+   s->n_chan   = 4;
+   s->maxdata  = 1;
+   s->range_table  = &range_digital;
+   s->insn_bits= das16_do_insn_bits;
+
+   /* initialize digital output lines */
+   outb(s->state, dev->iobase + DAS16_DIO);
 
s = &dev->subdevices[4];
/* 8255 */
@@ -1227,7 +1223,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1239,7 +1234,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1251,7 +1245,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1263,7 +1256,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1275,7 +1267,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg

[PATCH 06/38] staging: comedi: das16: all supported board have digital inputs

2013-07-29 Thread H Hartley Sweeten
All the boards supported by this driver have digital inputs and all
of then use the same function to handle the (*insn_bits) for the
subdevice.

Remove the 'di' member from the boardinfo and always initialize the
digital input subdevice during the board attach.

Tidy up the subdevice init a bit as well as the (*insn_bits) function.
The (*insn_bits) function does not need to clear data[0].

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 11e5787..3528c82 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -343,7 +343,6 @@ struct das16_board {
unsigned int ai_pg;
void *ao;
unsigned int ao_nbits;
-   void *di;
void *do_;
 
unsigned int i8255_offset;
@@ -712,14 +711,12 @@ static int das16_ai_insn_read(struct comedi_device *dev,
return n;
 }
 
-static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice 
*s,
- struct comedi_insn *insn, unsigned int *data)
+static int das16_di_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
 {
-   unsigned int bits;
-
-   bits = inb(dev->iobase + DAS16_DIO) & 0xf;
-   data[1] = bits;
-   data[0] = 0;
+   data[1] = inb(dev->iobase + DAS16_DIO) & 0xf;
 
return insn->n;
 }
@@ -1149,18 +1146,14 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
s->type = COMEDI_SUBD_UNUSED;
}
 
+   /* Digital Input subdevice */
s = &dev->subdevices[2];
-   /* di */
-   if (board->di) {
-   s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE;
-   s->n_chan = 4;
-   s->maxdata = 1;
-   s->range_table = &range_digital;
-   s->insn_bits = board->di;
-   } else {
-   s->type = COMEDI_SUBD_UNUSED;
-   }
+   s->type = COMEDI_SUBD_DI;
+   s->subdev_flags = SDF_READABLE;
+   s->n_chan   = 4;
+   s->maxdata  = 1;
+   s->range_table  = &range_digital;
+   s->insn_bits= das16_di_insn_bits;
 
s = &dev->subdevices[3];
/* do */
@@ -1234,7 +1227,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
@@ -1247,7 +1239,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
@@ -1260,7 +1251,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
@@ -1273,7 +1263,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
@@ -1286,7 +1275,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.ao = das16_ao_winsn,
.ao_nbits   = 12,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
@@ -1298,7 +1286,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 7692,
.ai_pg  = das16_pg_16jr,
.ao = NULL,
-   .di = das16_di_rbits,
.do_= das16_do_wbits,
.i8255_offset   = 0,
.i8254_offset   = 0x0c,
@@ -1310,7 +1297,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed

[PATCH 09/38] staging: comedi: das16: tidy up the comedi_lrange tables

2013-07-29 Thread H Hartley Sweeten
Cleanup the whitespace in the tables.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index bad39d7..93c3a88 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -238,62 +238,67 @@ static const int sample_size = 2;
 #define   DAS1600_WS   0x02
 #define   DAS1600_CLK_10MHZ0x01
 
-static const struct comedi_lrange range_das1x01_bip = { 4, {
-   BIP_RANGE(10),
-   BIP_RANGE(1),
-   BIP_RANGE(0.1),
-   BIP_RANGE(0.01),
-   }
+static const struct comedi_lrange range_das1x01_bip = {
+   4, {
+   BIP_RANGE(10),
+   BIP_RANGE(1),
+   BIP_RANGE(0.1),
+   BIP_RANGE(0.01)
+   }
 };
 
-static const struct comedi_lrange range_das1x01_unip = { 4, {
-UNI_RANGE(10),
-UNI_RANGE(1),
-UNI_RANGE(0.1),
-UNI_RANGE(0.01),
-}
+static const struct comedi_lrange range_das1x01_unip = {
+   4, {
+   UNI_RANGE(10),
+   UNI_RANGE(1),
+   UNI_RANGE(0.1),
+   UNI_RANGE(0.01)
+   }
 };
 
-static const struct comedi_lrange range_das1x02_bip = { 4, {
-   BIP_RANGE(10),
-   BIP_RANGE(5),
-   BIP_RANGE(2.5),
-   BIP_RANGE(1.25),
-   }
+static const struct comedi_lrange range_das1x02_bip = {
+   4, {
+   BIP_RANGE(10),
+   BIP_RANGE(5),
+   BIP_RANGE(2.5),
+   BIP_RANGE(1.25)
+   }
 };
 
-static const struct comedi_lrange range_das1x02_unip = { 4, {
-UNI_RANGE(10),
-UNI_RANGE(5),
-UNI_RANGE(2.5),
-UNI_RANGE(1.25),
-}
+static const struct comedi_lrange range_das1x02_unip = {
+   4, {
+   UNI_RANGE(10),
+   UNI_RANGE(5),
+   UNI_RANGE(2.5),
+   UNI_RANGE(1.25)
+   }
 };
 
-static const struct comedi_lrange range_das16jr = { 9, {
-   /*  also used by 16/330 */
-   BIP_RANGE(10),
-   BIP_RANGE(5),
-   BIP_RANGE(2.5),
-   BIP_RANGE(1.25),
-   BIP_RANGE(0.625),
-   UNI_RANGE(10),
-   UNI_RANGE(5),
-   UNI_RANGE(2.5),
-   UNI_RANGE(1.25),
-   }
+static const struct comedi_lrange range_das16jr = {
+   9, {
+   BIP_RANGE(10),
+   BIP_RANGE(5),
+   BIP_RANGE(2.5),
+   BIP_RANGE(1.25),
+   BIP_RANGE(0.625),
+   UNI_RANGE(10),
+   UNI_RANGE(5),
+   UNI_RANGE(2.5),
+   UNI_RANGE(1.25)
+   }
 };
 
-static const struct comedi_lrange range_das16jr_16 = { 8, {
-  BIP_RANGE(10),
-  BIP_RANGE(5),
-  BIP_RANGE(2.5),
-  BIP_RANGE(1.25),
-  UNI_RANGE(10),
-  UNI_RANGE(5),
-  UNI_RANGE(2.5),
-

[PATCH 08/38] staging: comedi: das16: cleanup analog output subdevice

2013-07-29 Thread H Hartley Sweeten
All the boards supported by this driver that have analog outputs use
the same function to handle the (*insn_write) for the subdevice. They
all also have 12-bit resolution (maxdata = 0x0fff).

Remove the 'ao' and 'ao_nbits' members from the boardinfo and replace
them with a simple bit-field flag 'has_ao'.

Tidy up the subdevice init a bit as well as the (*insn_write) function.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 22d2bf4..bad39d7 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -341,8 +341,7 @@ struct das16_board {
unsigned int ai_maxdata;
unsigned int ai_speed;  /*  max conversion speed in nanosec */
unsigned int ai_pg;
-   void *ao;
-   unsigned int ao_nbits;
+   unsigned int has_ao:1;
 
unsigned int i8255_offset;
unsigned int i8254_offset;
@@ -740,29 +739,24 @@ static int das16_do_insn_bits(struct comedi_device *dev,
return insn->n;
 }
 
-static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice 
*s,
- struct comedi_insn *insn, unsigned int *data)
+static int das16_ao_insn_write(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned int *data)
 {
-   const struct das16_board *board = comedi_board(dev);
+   unsigned int chan = CR_CHAN(insn->chanspec);
+   unsigned int val;
int i;
-   int lsb, msb;
-   int chan;
-
-   chan = CR_CHAN(insn->chanspec);
 
for (i = 0; i < insn->n; i++) {
-   if (board->ao_nbits == 12) {
-   lsb = (data[i] << 4) & 0xff;
-   msb = (data[i] >> 4) & 0xff;
-   } else {
-   lsb = data[i] & 0xff;
-   msb = (data[i] >> 8) & 0xff;
-   }
-   outb(lsb, dev->iobase + DAS16_AO_LSB(chan));
-   outb(msb, dev->iobase + DAS16_AO_MSB(chan));
+   val = data[i];
+   val <<= 4;
+
+   outb(val & 0xff, dev->iobase + DAS16_AO_LSB(chan));
+   outb((val >> 8) & 0xff, dev->iobase + DAS16_AO_MSB(chan));
}
 
-   return i;
+   return insn->n;
 }
 
 /* the pc104-das16jr (at least) has problems if the dma
@@ -1127,22 +1121,21 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
s->munge= das16_ai_munge;
}
 
+   /* Analog Output subdevice */
s = &dev->subdevices[1];
-   /* ao */
-   if (board->ao) {
-   s->type = COMEDI_SUBD_AO;
-   s->subdev_flags = SDF_WRITABLE;
-   s->n_chan = 2;
-   s->maxdata = (1 << board->ao_nbits) - 1;
-   /*  user defined ao range */
+   if (board->has_ao) {
+   s->type = COMEDI_SUBD_AO;
+   s->subdev_flags = SDF_WRITABLE;
+   s->n_chan   = 2;
+   s->maxdata  = 0x0fff;
if (devpriv->user_ao_range_table)
-   s->range_table = devpriv->user_ao_range_table;
+   s->range_table  = devpriv->user_ao_range_table;
else
-   s->range_table = &range_unknown;
+   s->range_table  = &range_unknown;
 
-   s->insn_write = board->ao;
+   s->insn_write   = das16_ao_insn_write;
} else {
-   s->type = COMEDI_SUBD_UNUSED;
+   s->type = COMEDI_SUBD_UNUSED;
}
 
/* Digital Input subdevice */
@@ -1221,8 +1214,7 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
-   .ao = das16_ao_winsn,
-   .ao_nbits   = 12,
+   .has_ao = 1,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1232,8 +1224,7 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
-   .ao = das16_ao_winsn,
-   .ao_nbits   = 12,
+   .has_ao = 1,
.i8255_offset   = 0x10,
.i8254_offset   = 0x0c,
.size   = 0x14,
@@ -1243,8 +1234,7 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 8500,
 

[PATCH 11/38] staging: comedi: das16: remove 'ai_unipolar' and 'ai_singleended'

2013-07-29 Thread H Hartley Sweeten
These members in the private data are only used during the board attach.

Move the reading of the status register to the board attach and just
check the value where needed when initializing the analog input subdevice.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 14d2aa0..ccb0acd 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -360,8 +360,6 @@ static inline int timer_period(void)
 }
 
 struct das16_private_struct {
-   unsigned int ai_unipolar;   /*  unipolar flag */
-   unsigned int ai_singleended;/*  single ended flag */
unsigned int clockbase; /*  master clock speed in ns */
volatile unsigned int control_state;/*  dma, interrupt and trigger 
control bits */
volatile unsigned long adc_byte_count;  /*  number of bytes remaining */
@@ -891,28 +889,9 @@ static void reg_dump(struct comedi_device *dev)
 static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
 {
const struct das16_board *board = comedi_board(dev);
-   struct das16_private_struct *devpriv = dev->private;
-   int status;
int diobits;
 
-   /* status is available on all boards */
-
-   status = inb(dev->iobase + DAS16_STATUS);
-
-   if ((status & UNIPOLAR))
-   devpriv->ai_unipolar = 1;
-   else
-   devpriv->ai_unipolar = 0;
-
-
-   if ((status & DAS16_MUXBIT))
-   devpriv->ai_singleended = 1;
-   else
-   devpriv->ai_singleended = 0;
-
-
/* diobits indicates boards */
-
diobits = inb(dev->iobase + DAS16_DIO) & 0xf0;
 
printk(KERN_INFO " id bits are 0x%02x\n", diobits);
@@ -976,6 +955,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
struct comedi_krange *user_ai_range;
struct comedi_krange *user_ao_range;
unsigned int dma_chan = it->options[2];
+   unsigned int status;
int ret;
 
/*  check that clock setting is valid */
@@ -1091,11 +1071,13 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
if (ret)
return ret;
 
+   status = inb(dev->iobase + DAS16_STATUS);
+
/* Analog Input subdevice */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE;
-   if (devpriv->ai_singleended) {
+   if (status & DAS16_MUXBIT) {
s->subdev_flags |= SDF_GROUND;
s->n_chan   = 16;
} else {
@@ -1106,7 +1088,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
s->maxdata  = board->ai_maxdata;
if (devpriv->user_ai_range_table) { /*  user defined ai range */
s->range_table  = devpriv->user_ai_range_table;
-   } else if (devpriv->ai_unipolar) {
+   } else if (status & UNIPOLAR) {
s->range_table  = das16_ai_uni_lranges[board->ai_pg];
} else {
s->range_table  = das16_ai_bip_lranges[board->ai_pg];
-- 
1.8.3.2

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


[PATCH 10/38] staging: comedi: das16: remove unused struct definition

2013-07-29 Thread H Hartley Sweeten
This struct is not used by the driver. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 93c3a88..14d2aa0 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -336,11 +336,6 @@ static const struct comedi_lrange *const 
das16_ai_bip_lranges[] = {
&range_das1x02_bip,
 };
 
-struct munge_info {
-   uint8_t byte;
-   unsigned have_byte:1;
-};
-
 struct das16_board {
const char *name;
unsigned int ai_maxdata;
-- 
1.8.3.2

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


[PATCH 12/38] staging: comedi: das16: remove reg_dump()

2013-07-29 Thread H Hartley Sweeten
This function just prints some development debug information. There is
no reason to leave this in the final driver.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index ccb0acd..ae3a3ea 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -868,24 +868,6 @@ static void das16_timer_interrupt(unsigned long arg)
mod_timer(&devpriv->timer, jiffies + timer_period());
 }
 
-static void reg_dump(struct comedi_device *dev)
-{
-   DEBUG_PRINT("DAS1600 REGISTER DUMP\n");
-   DEBUG_PRINT("DAS16_MUX: %x\n", inb(dev->iobase + DAS16_MUX));
-   DEBUG_PRINT("DAS16_DIO: %x\n", inb(dev->iobase + DAS16_DIO));
-   DEBUG_PRINT("DAS16_STATUS: %x\n", inb(dev->iobase + DAS16_STATUS));
-   DEBUG_PRINT("DAS16_CONTROL: %x\n", inb(dev->iobase + DAS16_CONTROL));
-   DEBUG_PRINT("DAS16_PACER: %x\n", inb(dev->iobase + DAS16_PACER));
-   DEBUG_PRINT("DAS16_GAIN: %x\n", inb(dev->iobase + DAS16_GAIN));
-   DEBUG_PRINT("DAS16_CNTR_CONTROL: %x\n",
-   inb(dev->iobase + DAS16_CNTR_CONTROL));
-   DEBUG_PRINT("DAS1600_CONV: %x\n", inb(dev->iobase + DAS1600_CONV));
-   DEBUG_PRINT("DAS1600_BURST: %x\n", inb(dev->iobase + DAS1600_BURST));
-   DEBUG_PRINT("DAS1600_ENABLE: %x\n", inb(dev->iobase + DAS1600_ENABLE));
-   DEBUG_PRINT("DAS1600_STATUS_B: %x\n",
-   inb(dev->iobase + DAS1600_STATUS_B));
-}
-
 static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
 {
const struct das16_board *board = comedi_board(dev);
@@ -918,8 +900,6 @@ static int das1600_mode_detect(struct comedi_device *dev)
printk(KERN_INFO " 1MHz pacer clock\n");
}
 
-   reg_dump(dev);
-
return 0;
 }
 
-- 
1.8.3.2

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


[PATCH 13/38] staging: comedi: das16: remove DEBUG_PRINT macro

2013-07-29 Thread H Hartley Sweeten
This macro outputs some printk() debug info that is just added noise.
Remove it as well as the DEBUG stuff.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index ae3a3ea..d86ed2c 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -86,16 +86,6 @@ www.measurementcomputing.com
 #include "8255.h"
 #include "comedi_fc.h"
 
-#undef DEBUG
-/* #define DEBUG */
-
-#ifdef DEBUG
-#define DEBUG_PRINT(format, args...)   \
-   printk(KERN_DEBUG "das16: " format, ## args)
-#else
-#define DEBUG_PRINT(format, args...)
-#endif
-
 #define DAS16_SIZE 20  /*  number of ioports */
 #define DAS16_DMA_SIZE 0xff00  /*  size in bytes of allocated dma buffer */
 
@@ -566,7 +556,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
cmd->convert_arg =
das16_set_pacer(dev, cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
-   DEBUG_PRINT("pacer period: %d ns\n", cmd->convert_arg);
 
/* enable counters */
byte = 0;
@@ -814,7 +803,6 @@ static void das16_interrupt(struct comedi_device *dev)
spin_lock_irqsave(&dev->spinlock, spin_flags);
if ((devpriv->control_state & DMA_ENABLE) == 0) {
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
-   DEBUG_PRINT("interrupt while dma disabled?\n");
return;
}
 
-- 
1.8.3.2

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


[PATCH 14/38] staging: comedi: das16: remove 'volatile' on private data variables

2013-07-29 Thread H Hartley Sweeten
As indicated by checkpatch.pl, "WARNING: Use of volatile is usually
wrong: ...". The variables in the private data that are marked
volatile don't need to be. Remove the volatile.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index d86ed2c..95261a6 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -351,8 +351,8 @@ static inline int timer_period(void)
 
 struct das16_private_struct {
unsigned int clockbase; /*  master clock speed in ns */
-   volatile unsigned int control_state;/*  dma, interrupt and trigger 
control bits */
-   volatile unsigned long adc_byte_count;  /*  number of bytes remaining */
+   unsigned int control_state; /*  dma, interrupt and trigger control 
bits */
+   unsigned long adc_byte_count;   /*  number of bytes remaining */
/*  divisor dividing master clock to get conversion frequency */
unsigned int divisor1;
/*  divisor dividing master clock to get conversion frequency */
@@ -361,7 +361,7 @@ struct das16_private_struct {
uint16_t *dma_buffer[2];
dma_addr_t dma_buffer_addr[2];
unsigned int current_buffer;
-   volatile unsigned int dma_transfer_size;/*  target number of 
bytes to transfer per dma shot */
+   unsigned int dma_transfer_size; /*  target number of bytes to transfer 
per dma shot */
/**
 * user-defined analog input and output ranges
 * defined from config options
@@ -370,7 +370,7 @@ struct das16_private_struct {
struct comedi_lrange *user_ao_range_table;
 
struct timer_list timer;/*  for timed interrupt */
-   volatile short timer_running;
+   short timer_running;
 
unsigned long extra_iobase;
 };
-- 
1.8.3.2

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


[PATCH 15/38] staging: comedi: das16: add a 'can_burst' flag to the private data

2013-07-29 Thread H Hartley Sweeten
If the boardinfo 'size' is > 0x400 it indicates that the board has
additional registers that allow bursting of analog input data.

To better indicate this add a flag to the private data.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 95261a6..009c074 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -373,6 +373,7 @@ struct das16_private_struct {
short timer_running;
 
unsigned long extra_iobase;
+   unsigned int can_burst:1;
 };
 
 static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice 
*s,
@@ -389,15 +390,13 @@ static int das16_cmd_test(struct comedi_device *dev, 
struct comedi_subdevice *s,
err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
 
mask = TRIG_FOLLOW;
-   /*  if board supports burst mode */
-   if (board->size > 0x400)
+   if (devpriv->can_burst)
mask |= TRIG_TIMER | TRIG_EXT;
err |= cfc_check_trigger_src(&cmd->scan_begin_src, mask);
 
tmp = cmd->convert_src;
mask = TRIG_TIMER | TRIG_EXT;
-   /*  if board supports burst mode */
-   if (board->size > 0x400)
+   if (devpriv->can_burst)
mask |= TRIG_NOW;
err |= cfc_check_trigger_src(&cmd->convert_src, mask);
 
@@ -534,8 +533,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
devpriv->adc_byte_count =
cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
 
-   /*  disable conversions for das1600 mode */
-   if (board->size > 0x400)
+   if (devpriv->can_burst)
outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV);
 
/*  set scan limits */
@@ -559,8 +557,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
 
/* enable counters */
byte = 0;
-   /* Enable burst mode if appropriate. */
-   if (board->size > 0x400) {
+   if (devpriv->can_burst) {
if (cmd->convert_src == TRIG_NOW) {
outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST);
/*  set burst length */
@@ -598,8 +595,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
devpriv->control_state |= INT_PACER;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
 
-   /* Enable conversions if using das1600 mode */
-   if (board->size > 0x400)
+   if (devpriv->can_burst)
outb(0, dev->iobase + DAS1600_CONV);
 
 
@@ -608,7 +604,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
 
 static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-   const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv = dev->private;
unsigned long flags;
 
@@ -624,11 +619,9 @@ static int das16_cancel(struct comedi_device *dev, struct 
comedi_subdevice *s)
del_timer(&devpriv->timer);
}
 
-   /* disable burst mode */
-   if (board->size > 0x400)
+   if (devpriv->can_burst)
outb(0, dev->iobase + DAS1600_BURST);
 
-
spin_unlock_irqrestore(&dev->spinlock, flags);
 
return 0;
@@ -955,6 +948,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
if (ret)
return ret;
devpriv->extra_iobase = dev->iobase + 0x400;
+   devpriv->can_burst = 1;
}
 
/*  probe id bits to make sure they are consistent */
@@ -964,13 +958,13 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
}
 
/*  get master clock speed */
-   if (board->size < 0x400) {
+   if (devpriv->can_burst) {
+   das1600_mode_detect(dev);
+   } else {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
else
devpriv->clockbase = 1000;  /*  1 MHz default */
-   } else {
-   das1600_mode_detect(dev);
}
 
/* initialize dma */
@@ -1123,8 +1117,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
devpriv->control_state = DAS16_IRQ(dev->irq);
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
 
-   /*  turn on das1600 mode if available */
-   if (board->size > 0x400) {
+   if (devpriv->can_burst) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
outb(0, dev->iobase + DAS1600_CONV);
outb(0, dev->iobase + DAS1600_BURST);
-- 

[PATCH 16/38] staging: comedi: das16: remove unused DAS16_SIZE

2013-07-29 Thread H Hartley Sweeten
This define is not used in the driver. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 009c074..577e2a8 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -86,7 +86,6 @@ www.measurementcomputing.com
 #include "8255.h"
 #include "comedi_fc.h"
 
-#define DAS16_SIZE 20  /*  number of ioports */
 #define DAS16_DMA_SIZE 0xff00  /*  size in bytes of allocated dma buffer */
 
 /*
-- 
1.8.3.2

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


[PATCH 17/38] staging: comedi: das16: remove unused static const variable

2013-07-29 Thread H Hartley Sweeten
This variable is not used in the driver. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 577e2a8..96c081b 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -174,9 +174,6 @@ www.measurementcomputing.com
 
 */
 
-/*  size in bytes of a sample from board */
-static const int sample_size = 2;
-
 #define DAS16_TRIG 0
 #define DAS16_AI_LSB   0
 #define DAS16_AI_MSB   1
-- 
1.8.3.2

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


[PATCH 18/38] staging: comedi: das16: remove the register map comments

2013-07-29 Thread H Hartley Sweeten
This is just extra cruft. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 96c081b..bd5f516 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -89,91 +89,8 @@ www.measurementcomputing.com
 #define DAS16_DMA_SIZE 0xff00  /*  size in bytes of allocated dma buffer */
 
 /*
-cio-das16.pdf
-
-"das16"
-"das16/f"
-
-  0a/d bits 0-3start 12 bit
-  1a/d bits 4-11   unused
-  2mux readmux set
-  3di 4 bitdo 4 bit
-  4unused  ao0_lsb
-  5unused  ao0_msb
-  6unused  ao1_lsb
-  7unused  ao1_msb
-  8status eoc uni/bip  interrupt reset
-  9dma, int, trig ctrl set dma, int
-  apacer control   unused
-  breservedreserved
-  cdef 8254
-  0123 8255
-
-*/
-
-/*
-cio-das16jr.pdf
-
-"das16jr"
-
-  0a/d bits 0-3start 12 bit
-  1a/d bits 4-11   unused
-  2mux readmux set
-  3di 4 bitdo 4 bit
-  4567 unused  unused
-  8status eoc uni/bip  interrupt reset
-  9dma, int, trig ctrl set dma, int
-  apacer control   unused
-  bgain status gain control
-  cdef 8254
-
-*/
-
-/*
-cio-das16jr_16.pdf
-
-"das16jr_16"
-
-  0a/d bits 0-7start 16 bit
-  1a/d bits 8-15   unused
-  2mux readmux set
-  3di 4 bitdo 4 bit
-  4567 unused  unused
-  8status eoc uni/bip  interrupt reset
-  9dma, int, trig ctrl set dma, int
-  apacer control   unused
-  bgain status gain control
-  cdef 8254
-
-*/
-/*
-cio-das160x-1x.pdf
-
-"das1601/12"
-"das1602/12"
-"das1602/16"
-
-  0a/d bits 0-3start 12 bit
-  1a/d bits 4-11   unused
-  2mux readmux set
-  3di 4 bitdo 4 bit
-  4unused  ao0_lsb
-  5unused  ao0_msb
-  6unused  ao1_lsb
-  7unused  ao1_msb
-  8status eoc uni/bip  interrupt reset
-  9dma, int, trig ctrl set dma, int
-  apacer control   unused
-  bgain status gain control
-  cdef 8254
-  400  8255
-  404  unused  conversion enable
-  405  unused  burst enable
-  406  unused  das1600 enable
-  407  status
-
-*/
-
+ * Register I/O map
+ */
 #define DAS16_TRIG 0
 #define DAS16_AI_LSB   0
 #define DAS16_AI_MSB   1
-- 
1.8.3.2

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


[PATCH 19/38] staging: comedi: das16: introduce das16_ai_{en, dis}able() helpers

2013-07-29 Thread H Hartley Sweeten
Introduce a couple helper functions to enable and disable the
analog input interrupt/dma conversions.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index bd5f516..f6d0f7e 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -264,7 +264,7 @@ static inline int timer_period(void)
 
 struct das16_private_struct {
unsigned int clockbase; /*  master clock speed in ns */
-   unsigned int control_state; /*  dma, interrupt and trigger control 
bits */
+   unsigned int ctrl_reg;
unsigned long adc_byte_count;   /*  number of bytes remaining */
/*  divisor dividing master clock to get conversion frequency */
unsigned int divisor1;
@@ -289,6 +289,30 @@ struct das16_private_struct {
unsigned int can_burst:1;
 };
 
+static void das16_ai_enable(struct comedi_device *dev,
+   unsigned int mode, unsigned int src)
+{
+   struct das16_private_struct *devpriv = dev->private;
+
+   devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK);
+   devpriv->ctrl_reg |= mode;
+
+   if (src == TRIG_EXT)
+   devpriv->ctrl_reg |= EXT_PACER;
+   else
+   devpriv->ctrl_reg |= INT_PACER;
+   outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL);
+}
+
+static void das16_ai_disable(struct comedi_device *dev)
+{
+   struct das16_private_struct *devpriv = dev->private;
+
+   /* disable interrupts, dma and pacer clocked conversions */
+   devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK);
+   outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL);
+}
+
 static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice 
*s,
  struct comedi_cmd *cmd)
 {
@@ -499,19 +523,12 @@ static int das16_cmd_exec(struct comedi_device *dev, 
struct comedi_subdevice *s)
devpriv->timer_running = 1;
devpriv->timer.expires = jiffies + timer_period();
add_timer(&devpriv->timer);
-   devpriv->control_state &= ~DAS16_INTE;
-   devpriv->control_state |= DMA_ENABLE;
-   devpriv->control_state &= ~PACING_MASK;
-   if (cmd->convert_src == TRIG_EXT)
-   devpriv->control_state |= EXT_PACER;
-   else
-   devpriv->control_state |= INT_PACER;
-   outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
+
+   das16_ai_enable(dev, DMA_ENABLE, cmd->convert_src);
 
if (devpriv->can_burst)
outb(0, dev->iobase + DAS1600_CONV);
 
-
return 0;
 }
 
@@ -521,9 +538,8 @@ static int das16_cancel(struct comedi_device *dev, struct 
comedi_subdevice *s)
unsigned long flags;
 
spin_lock_irqsave(&dev->spinlock, flags);
-   /* disable interrupts, dma and pacer clocked conversions */
-   devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE;
-   outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
+
+   das16_ai_disable(dev);
disable_dma(devpriv->dma_chan);
 
/*  disable SW timer */
@@ -554,14 +570,11 @@ static int das16_ai_insn_read(struct comedi_device *dev,
  unsigned int *data)
 {
const struct das16_board *board = comedi_board(dev);
-   struct das16_private_struct *devpriv = dev->private;
int i, n;
int range;
int chan;
 
-   /*  disable interrupts and pacing */
-   devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK;
-   outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
+   das16_ai_disable(dev);
 
/* set multiplexer */
chan = CR_CHAN(insn->chanspec);
@@ -707,7 +720,7 @@ static void das16_interrupt(struct comedi_device *dev)
cmd = &async->cmd;
 
spin_lock_irqsave(&dev->spinlock, spin_flags);
-   if ((devpriv->control_state & DMA_ENABLE) == 0) {
+   if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) {
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
return;
}
@@ -1027,8 +1040,8 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
das16_reset(dev);
/* set the interrupt level */
-   devpriv->control_state = DAS16_IRQ(dev->irq);
-   outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
+   devpriv->ctrl_reg = DAS16_IRQ(dev->irq);
+   outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL);
 
if (devpriv->can_burst) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
-- 
1.8.3.2

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


[PATCH 20/38] staging: comedi: das16: tidy up das16_ai_insn_read()

2013-07-29 Thread H Hartley Sweeten
Factor out the loop that waits for the ai conversion to complete.

Tidy up the function a bit.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
This also fixes a bug introduced by PATCH 05/38. The 'val' should be >> 4
not the 'data[n]'. If necessary I will rebase this series to fix the patch.

 drivers/staging/comedi/drivers/das16.c | 50 ++
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index f6d0f7e..a482bd5 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -253,8 +253,6 @@ struct das16_board {
unsigned int id;
 };
 
-#define DAS16_TIMEOUT 1000
-
 /* Period for timer interrupt in jiffies.  It's a function
  * to deal with possibility of dynamic HZ patches  */
 static inline int timer_period(void)
@@ -564,55 +562,61 @@ static void das16_reset(struct comedi_device *dev)
outb(0, dev->iobase + DAS16_CNTR_CONTROL);
 }
 
+static int das16_ai_wait_for_conv(struct comedi_device *dev,
+ unsigned int timeout)
+{
+   unsigned int status;
+   int i;
+
+   for (i = 0; i < timeout; i++) {
+   status = inb(dev->iobase + DAS16_STATUS);
+   if (!(status & BUSY))
+   return 0;
+   }
+   return -ETIME;
+}
+
 static int das16_ai_insn_read(struct comedi_device *dev,
  struct comedi_subdevice *s,
  struct comedi_insn *insn,
  unsigned int *data)
 {
const struct das16_board *board = comedi_board(dev);
-   int i, n;
-   int range;
-   int chan;
+   unsigned int chan = CR_CHAN(insn->chanspec);
+   unsigned int range = CR_RANGE(insn->chanspec);
+   unsigned int val;
+   int ret;
+   int i;
 
das16_ai_disable(dev);
 
/* set multiplexer */
-   chan = CR_CHAN(insn->chanspec);
-   chan |= CR_CHAN(insn->chanspec) << 4;
-   outb(chan, dev->iobase + DAS16_MUX);
+   outb(chan | (chan << 4), dev->iobase + DAS16_MUX);
 
/* set gain */
if (board->ai_pg != das16_pg_none) {
-   range = CR_RANGE(insn->chanspec);
outb((das16_gainlists[board->ai_pg])[range],
 dev->iobase + DAS16_GAIN);
}
 
-   for (n = 0; n < insn->n; n++) {
-   unsigned int val;
-
+   for (i = 0; i < insn->n; i++) {
/* trigger conversion */
outb_p(0, dev->iobase + DAS16_TRIG);
 
-   for (i = 0; i < DAS16_TIMEOUT; i++) {
-   if (!(inb(dev->iobase + DAS16_STATUS) & BUSY))
-   break;
-   }
-   if (i == DAS16_TIMEOUT) {
-   printk("das16: timeout\n");
-   return -ETIME;
-   }
+   ret = das16_ai_wait_for_conv(dev, 1000);
+   if (ret)
+   return ret;
 
val = inb(dev->iobase + DAS16_AI_MSB) << 8;
val |= inb(dev->iobase + DAS16_AI_LSB);
if (s->maxdata == 0x0fff)
-   data[n] >>= 4;
+   val >>= 4;
val &= s->maxdata;
 
-   data[n] = val;
+   data[i] = val;
}
 
-   return n;
+   return insn->n;
 }
 
 static int das16_di_insn_bits(struct comedi_device *dev,
-- 
1.8.3.2

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


[PATCH 23/38] staging: comedi: das16: move boardinfo declaration

2013-07-29 Thread H Hartley Sweeten
Now that the boardinfo does not require any forward declarations,
move it near the definition of the struct.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index df7bf1e..b04b3ae6 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -253,6 +253,218 @@ struct das16_board {
unsigned int id;
 };
 
+static const struct das16_board das16_boards[] = {
+   {
+   .name   = "das-16",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 15000,
+   .ai_pg  = das16_pg_none,
+   .has_ao = 1,
+   .i8255_offset   = 0x10,
+   .i8254_offset   = 0x0c,
+   .size   = 0x14,
+   .id = 0x00,
+   }, {
+   .name   = "das-16g",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 15000,
+   .ai_pg  = das16_pg_none,
+   .has_ao = 1,
+   .i8255_offset   = 0x10,
+   .i8254_offset   = 0x0c,
+   .size   = 0x14,
+   .id = 0x00,
+   }, {
+   .name   = "das-16f",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 8500,
+   .ai_pg  = das16_pg_none,
+   .has_ao = 1,
+   .i8255_offset   = 0x10,
+   .i8254_offset   = 0x0c,
+   .size   = 0x14,
+   .id = 0x00,
+   }, {
+   .name   = "cio-das16",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 2,
+   .ai_pg  = das16_pg_none,
+   .has_ao = 1,
+   .i8255_offset   = 0x10,
+   .i8254_offset   = 0x0c,
+   .size   = 0x14,
+   .id = 0x80,
+   }, {
+   .name   = "cio-das16/f",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 1,
+   .ai_pg  = das16_pg_none,
+   .has_ao = 1,
+   .i8255_offset   = 0x10,
+   .i8254_offset   = 0x0c,
+   .size   = 0x14,
+   .id = 0x80,
+   }, {
+   .name   = "cio-das16/jr",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 7692,
+   .ai_pg  = das16_pg_16jr,
+   .i8255_offset   = 0,
+   .i8254_offset   = 0x0c,
+   .size   = 0x10,
+   .id = 0x00,
+   }, {
+   .name   = "pc104-das16jr",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 3300,
+   .ai_pg  = das16_pg_16jr,
+   .i8255_offset   = 0,
+   .i8254_offset   = 0x0c,
+   .size   = 0x10,
+   .id = 0x00,
+   }, {
+   .name   = "cio-das16jr/16",
+   .ai_maxdata = 0x,
+   .ai_speed   = 1,
+   .ai_pg  = das16_pg_16jr_16,
+   .i8255_offset   = 0,
+   .i8254_offset   = 0x0c,
+   .size   = 0x10,
+   .id = 0x00,
+   }, {
+   .name   = "pc104-das16jr/16",
+   .ai_maxdata = 0x,
+   .ai_speed   = 1,
+   .ai_pg  = das16_pg_16jr_16,
+   .i8255_offset   = 0,
+   .i8254_offset   = 0x0c,
+   .size   = 0x10,
+   .id = 0x00,
+   }, {
+   .name   = "das-1201",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 2,
+   .ai_pg  = das16_pg_none,
+   .i8255_offset   = 0x400,
+   .i8254_offset   = 0x0c,
+   .size   = 0x408,
+   .id = 0x20,
+   }, {
+   .name   = "das-1202",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 1,
+   .ai_pg  = das16_pg_none,
+   .i8255_offset   = 0x400,
+   .i8254_offset   = 0x0c,
+   .size   = 0x408,
+   .id = 0x20,
+   }, {
+   .name   = "das-1401",
+   .ai_maxdata = 0x0fff,
+   .ai_speed   = 1,
+   .ai_pg  = das16_pg_1601,
+   .i8255_offset   = 0x0,
+   .i8254_offset   = 0x0c,
+

[PATCH 22/38] staging: comedi: das16: remove unnecessary test in das16_interrupt()

2013-07-29 Thread H Hartley Sweeten
The timer is only started by the ai subdevice in das16_cmd_exec()
and this function can only be called if the device is attached.

Remove the unnecessary sanity check.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index cd2fa4c..df7bf1e 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -350,21 +350,14 @@ static int disable_dma_on_even(struct comedi_device *dev)
 static void das16_interrupt(struct comedi_device *dev)
 {
struct das16_private_struct *devpriv = dev->private;
-   unsigned long dma_flags, spin_flags;
struct comedi_subdevice *s = dev->read_subdev;
-   struct comedi_async *async;
-   struct comedi_cmd *cmd;
+   struct comedi_async *async = s->async;
+   struct comedi_cmd *cmd = &async->cmd;
+   unsigned long spin_flags;
+   unsigned long dma_flags;
int num_bytes, residue;
int buffer_index;
 
-   if (!dev->attached) {
-   comedi_error(dev, "premature interrupt");
-   return;
-   }
-   /*  initialize async here to make sure it is not NULL */
-   async = s->async;
-   cmd = &async->cmd;
-
spin_lock_irqsave(&dev->spinlock, spin_flags);
if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) {
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
-- 
1.8.3.2

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


[PATCH 21/38] staging: comedi: das16: move some functions to improve readability

2013-07-29 Thread H Hartley Sweeten
For aesthetics, move some of the functions to make the code easier
to follow.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index a482bd5..cd2fa4c 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -311,6 +311,116 @@ static void das16_ai_disable(struct comedi_device *dev)
outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL);
 }
 
+/* the pc104-das16jr (at least) has problems if the dma
+   transfer is interrupted in the middle of transferring
+   a 16 bit sample, so this function takes care to get
+   an even transfer count after disabling dma
+   channel.
+*/
+static int disable_dma_on_even(struct comedi_device *dev)
+{
+   struct das16_private_struct *devpriv = dev->private;
+   int residue;
+   int i;
+   static const int disable_limit = 100;
+   static const int enable_timeout = 100;
+
+   disable_dma(devpriv->dma_chan);
+   residue = get_dma_residue(devpriv->dma_chan);
+   for (i = 0; i < disable_limit && (residue % 2); ++i) {
+   int j;
+   enable_dma(devpriv->dma_chan);
+   for (j = 0; j < enable_timeout; ++j) {
+   int new_residue;
+   udelay(2);
+   new_residue = get_dma_residue(devpriv->dma_chan);
+   if (new_residue != residue)
+   break;
+   }
+   disable_dma(devpriv->dma_chan);
+   residue = get_dma_residue(devpriv->dma_chan);
+   }
+   if (i == disable_limit) {
+   comedi_error(dev, "failed to get an even dma transfer, "
+   "could be trouble.");
+   }
+   return residue;
+}
+
+static void das16_interrupt(struct comedi_device *dev)
+{
+   struct das16_private_struct *devpriv = dev->private;
+   unsigned long dma_flags, spin_flags;
+   struct comedi_subdevice *s = dev->read_subdev;
+   struct comedi_async *async;
+   struct comedi_cmd *cmd;
+   int num_bytes, residue;
+   int buffer_index;
+
+   if (!dev->attached) {
+   comedi_error(dev, "premature interrupt");
+   return;
+   }
+   /*  initialize async here to make sure it is not NULL */
+   async = s->async;
+   cmd = &async->cmd;
+
+   spin_lock_irqsave(&dev->spinlock, spin_flags);
+   if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) {
+   spin_unlock_irqrestore(&dev->spinlock, spin_flags);
+   return;
+   }
+
+   dma_flags = claim_dma_lock();
+   clear_dma_ff(devpriv->dma_chan);
+   residue = disable_dma_on_even(dev);
+
+   /*  figure out how many points to read */
+   if (residue > devpriv->dma_transfer_size) {
+   comedi_error(dev, "residue > transfer size!\n");
+   async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
+   num_bytes = 0;
+   } else
+   num_bytes = devpriv->dma_transfer_size - residue;
+
+   if (cmd->stop_src == TRIG_COUNT &&
+   num_bytes >= devpriv->adc_byte_count) {
+   num_bytes = devpriv->adc_byte_count;
+   async->events |= COMEDI_CB_EOA;
+   }
+
+   buffer_index = devpriv->current_buffer;
+   devpriv->current_buffer = (devpriv->current_buffer + 1) % 2;
+   devpriv->adc_byte_count -= num_bytes;
+
+   /*  re-enable  dma */
+   if ((async->events & COMEDI_CB_EOA) == 0) {
+   set_dma_addr(devpriv->dma_chan,
+devpriv->dma_buffer_addr[devpriv->current_buffer]);
+   set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
+   enable_dma(devpriv->dma_chan);
+   }
+   release_dma_lock(dma_flags);
+
+   spin_unlock_irqrestore(&dev->spinlock, spin_flags);
+
+   cfc_write_array_to_buffer(s,
+ devpriv->dma_buffer[buffer_index], num_bytes);
+
+   cfc_handle_events(dev, s);
+}
+
+static void das16_timer_interrupt(unsigned long arg)
+{
+   struct comedi_device *dev = (struct comedi_device *)arg;
+   struct das16_private_struct *devpriv = dev->private;
+
+   das16_interrupt(dev);
+
+   if (devpriv->timer_running)
+   mod_timer(&devpriv->timer, jiffies + timer_period());
+}
+
 static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice 
*s,
  struct comedi_cmd *cmd)
 {
@@ -554,12 +664,20 @@ static int das16_cancel(struct comedi_device *dev, struct 
comedi_subdevice *s)
return 0;
 }
 
-static void das16_reset(struct comedi_device *dev)
+static void das16_ai_munge(struct c

[PATCH 24/38] staging: comedi: das16: remove 'i8254_offset' from boardinfo

2013-07-29 Thread H Hartley Sweeten
All the boards supported by this driver have an 8254 timer at offset
0x0c. Remove this unused information from the boardinfo.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index b04b3ae6..c7b664a 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -247,7 +247,6 @@ struct das16_board {
unsigned int has_ao:1;
 
unsigned int i8255_offset;
-   unsigned int i8254_offset;
 
unsigned int size;
unsigned int id;
@@ -261,7 +260,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.has_ao = 1,
.i8255_offset   = 0x10,
-   .i8254_offset   = 0x0c,
.size   = 0x14,
.id = 0x00,
}, {
@@ -271,7 +269,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.has_ao = 1,
.i8255_offset   = 0x10,
-   .i8254_offset   = 0x0c,
.size   = 0x14,
.id = 0x00,
}, {
@@ -281,7 +278,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.has_ao = 1,
.i8255_offset   = 0x10,
-   .i8254_offset   = 0x0c,
.size   = 0x14,
.id = 0x00,
}, {
@@ -291,7 +287,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.has_ao = 1,
.i8255_offset   = 0x10,
-   .i8254_offset   = 0x0c,
.size   = 0x14,
.id = 0x80,
}, {
@@ -301,7 +296,6 @@ static const struct das16_board das16_boards[] = {
.ai_pg  = das16_pg_none,
.has_ao = 1,
.i8255_offset   = 0x10,
-   .i8254_offset   = 0x0c,
.size   = 0x14,
.id = 0x80,
}, {
@@ -310,7 +304,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 7692,
.ai_pg  = das16_pg_16jr,
.i8255_offset   = 0,
-   .i8254_offset   = 0x0c,
.size   = 0x10,
.id = 0x00,
}, {
@@ -319,7 +312,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 3300,
.ai_pg  = das16_pg_16jr,
.i8255_offset   = 0,
-   .i8254_offset   = 0x0c,
.size   = 0x10,
.id = 0x00,
}, {
@@ -328,7 +320,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_16jr_16,
.i8255_offset   = 0,
-   .i8254_offset   = 0x0c,
.size   = 0x10,
.id = 0x00,
}, {
@@ -337,7 +328,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_16jr_16,
.i8255_offset   = 0,
-   .i8254_offset   = 0x0c,
.size   = 0x10,
.id = 0x00,
}, {
@@ -346,7 +336,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 2,
.ai_pg  = das16_pg_none,
.i8255_offset   = 0x400,
-   .i8254_offset   = 0x0c,
.size   = 0x408,
.id = 0x20,
}, {
@@ -355,7 +344,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_none,
.i8255_offset   = 0x400,
-   .i8254_offset   = 0x0c,
.size   = 0x408,
.id = 0x20,
}, {
@@ -364,7 +352,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_1601,
.i8255_offset   = 0x0,
-   .i8254_offset   = 0x0c,
.size   = 0x408,
.id = 0xc0,
}, {
@@ -373,7 +360,6 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_1602,
.i8255_offset   = 0x0,
-   .i8254_offset   = 0x0c,
.size   = 0x408,
 

[PATCH 25/38] staging: comedi: das16: tidy up 8255 digital i/o subdevice

2013-07-29 Thread H Hartley Sweeten
The 8255 digital i/o subdevice is only available on some of the boards
supported by this driver. Currently the 'i8255_offset' member of the
boardinfo is used to indicate that it is available.

To clarify this support, add a 'has_8255' bit-field flag to the boardinfo.
We can then use this flag to conditionally allocate the space for the
subdevice only when it is needed.

Also, make sure to check that subdev_8255_init() is successful and propagate
any errors.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index c7b664a..8da7ee3 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -245,6 +245,7 @@ struct das16_board {
unsigned int ai_speed;  /*  max conversion speed in nanosec */
unsigned int ai_pg;
unsigned int has_ao:1;
+   unsigned int has_8255:1;
 
unsigned int i8255_offset;
 
@@ -259,6 +260,7 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
.has_ao = 1,
+   .has_8255   = 1,
.i8255_offset   = 0x10,
.size   = 0x14,
.id = 0x00,
@@ -268,6 +270,7 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 15000,
.ai_pg  = das16_pg_none,
.has_ao = 1,
+   .has_8255   = 1,
.i8255_offset   = 0x10,
.size   = 0x14,
.id = 0x00,
@@ -277,6 +280,7 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 8500,
.ai_pg  = das16_pg_none,
.has_ao = 1,
+   .has_8255   = 1,
.i8255_offset   = 0x10,
.size   = 0x14,
.id = 0x00,
@@ -286,6 +290,7 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 2,
.ai_pg  = das16_pg_none,
.has_ao = 1,
+   .has_8255   = 1,
.i8255_offset   = 0x10,
.size   = 0x14,
.id = 0x80,
@@ -295,6 +300,7 @@ static const struct das16_board das16_boards[] = {
.ai_speed   = 1,
.ai_pg  = das16_pg_none,
.has_ao = 1,
+   .has_8255   = 1,
.i8255_offset   = 0x10,
.size   = 0x14,
.id = 0x80,
@@ -303,7 +309,6 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 7692,
.ai_pg  = das16_pg_16jr,
-   .i8255_offset   = 0,
.size   = 0x10,
.id = 0x00,
}, {
@@ -311,7 +316,6 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 3300,
.ai_pg  = das16_pg_16jr,
-   .i8255_offset   = 0,
.size   = 0x10,
.id = 0x00,
}, {
@@ -319,7 +323,6 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x,
.ai_speed   = 1,
.ai_pg  = das16_pg_16jr_16,
-   .i8255_offset   = 0,
.size   = 0x10,
.id = 0x00,
}, {
@@ -327,7 +330,6 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x,
.ai_speed   = 1,
.ai_pg  = das16_pg_16jr_16,
-   .i8255_offset   = 0,
.size   = 0x10,
.id = 0x00,
}, {
@@ -335,6 +337,7 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 2,
.ai_pg  = das16_pg_none,
+   .has_8255   = 1,
.i8255_offset   = 0x400,
.size   = 0x408,
.id = 0x20,
@@ -343,6 +346,7 @@ static const struct das16_board das16_boards[] = {
.ai_maxdata = 0x0fff,
.ai_speed   = 1,
.ai_pg  = das16_pg_none,
+   .has_8255   = 1,
.i8255_offset   = 0x400,
.size   = 0x408,
.id = 0x20,
@@ -351,7 +355,6 @@ static const st

[PATCH 26/38] staging: comedi: das16: tidy up the register map defines

2013-07-29 Thread H Hartley Sweeten
Add the suffix _REG to all the register defines to better indicate
what they are.

Add a prefix to all the register bit defines to avoid namespace clashes
and to better indicate what they are.

Tidy up the whitesapce.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 8da7ee3..97ba2bd 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -91,55 +91,45 @@ www.measurementcomputing.com
 /*
  * Register I/O map
  */
-#define DAS16_TRIG 0
-#define DAS16_AI_LSB   0
-#define DAS16_AI_MSB   1
-#define DAS16_MUX  2
-#define DAS16_DIO  3
-#define DAS16_AO_LSB(x)((x) ? 6 : 4)
-#define DAS16_AO_MSB(x)((x) ? 7 : 5)
-#define DAS16_STATUS   8
-#define   BUSY (1<<7)
-#define   UNIPOLAR (1<<6)
-#define   DAS16_MUXBIT (1<<5)
-#define   DAS16_INT(1<<4)
-#define DAS16_CONTROL  9
-#define   DAS16_INTE   (1<<7)
-#define   DAS16_IRQ(x) (((x) & 0x7) << 4)
-#define   DMA_ENABLE   (1<<2)
-#define   PACING_MASK  0x3
-#define   INT_PACER0x03
-#define   EXT_PACER0x02
-#define   DAS16_SOFT   0x00
-#define DAS16_PACER0x0A
-#define   DAS16_CTR0   (1<<1)
-#define   DAS16_TRIG0  (1<<0)
-#define   BURST_LEN_BITS(x)(((x) & 0xf) << 4)
-#define DAS16_GAIN 0x0B
-#define DAS16_CNTR0_DATA   0x0C
-#define DAS16_CNTR1_DATA   0x0D
-#define DAS16_CNTR2_DATA   0x0E
-#define DAS16_CNTR_CONTROL 0x0F
-#define   DAS16_TERM_CNT   0x00
-#define   DAS16_ONE_SHOT   0x02
-#define   DAS16_RATE_GEN   0x04
-#define   DAS16_CNTR_LSB_MSB   0x30
-#define   DAS16_CNTR0  0x00
-#define   DAS16_CNTR1  0x40
-#define   DAS16_CNTR2  0x80
-
-#define DAS1600_CONV   0x404
-#define   DAS1600_CONV_DISABLE 0x40
-#define DAS1600_BURST  0x405
-#define   DAS1600_BURST_VAL0x40
-#define DAS1600_ENABLE 0x406
-#define   DAS1600_ENABLE_VAL   0x40
-#define DAS1600_STATUS_B   0x407
-#define   DAS1600_BME  0x40
-#define   DAS1600_ME   0x20
-#define   DAS1600_CD   0x10
-#define   DAS1600_WS   0x02
-#define   DAS1600_CLK_10MHZ0x01
+#define DAS16_TRIG_REG 0x00
+#define DAS16_AI_LSB_REG   0x00
+#define DAS16_AI_MSB_REG   0x01
+#define DAS16_MUX_REG  0x02
+#define DAS16_DIO_REG  0x03
+#define DAS16_AO_LSB_REG(x)((x) ? 0x06 : 0x04)
+#define DAS16_AO_MSB_REG(x)((x) ? 0x07 : 0x05)
+#define DAS16_STATUS_REG   0x08
+#define DAS16_STATUS_BUSY  (1 << 7)
+#define DAS16_STATUS_UNIPOLAR  (1 << 6)
+#define DAS16_STATUS_MUXBIT(1 << 5)
+#define DAS16_STATUS_INT   (1 << 4)
+#define DAS16_CTRL_REG 0x09
+#define DAS16_CTRL_INTE(1 << 7)
+#define DAS16_CTRL_IRQ(x)  (((x) & 0x7) << 4)
+#define DAS16_CTRL_DMAE(1 << 2)
+#define DAS16_CTRL_PACING_MASK (3 << 0)
+#define DAS16_CTRL_INT_PACER   (3 << 0)
+#define DAS16_CTRL_EXT_PACER   (2 << 0)
+#define DAS16_CTRL_SOFT_PACER  (0 << 0)
+#define DAS16_PACER_REG0x0a
+#define DAS16_PACER_BURST_LEN(x)   (((x) & 0xf) << 4)
+#define DAS16_PACER_CTR0   (1 << 1)
+#define DAS16_PACER_TRIG0  (1 << 0)
+#define DAS16_GAIN_REG 0x0b
+#define DAS16_TIMER_BASE_REG   0x0c/* to 0x0f */
+
+#define DAS1600_CONV_REG   0x404
+#define DAS1600_CONV_DISABLE   (1 << 6)
+#define DAS1600_BURST_REG  0x405
+#define DAS1600_BURST_VAL  (1 << 6)
+#define DAS1600_ENABLE_REG 0x406
+#define DAS1600_ENABLE_VAL (1 << 6)
+#define DAS1600_STATUS_REG 0x407
+#define DAS1600_STATUS_BME (1 << 6)
+#define DAS1600_STATUS_ME  (1 << 5)
+#define DAS1600_STATUS_CD  (1 << 4)
+#define DAS1600_STATUS_WS  (1 << 1)
+#define DAS1600_STATUS_CLK_10MHZ   (1 << 0)
 
 static const struct comedi_lrange range_das1x01_bip = {
4, {
@@ -484,14 +474,16 @@ static void das16_ai_enable(struct comedi_device *dev,
 {
struct das16_private_struct *devpriv = dev->private;
 
-   devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK);
+   devpriv->ctrl_reg &= ~(DAS16_CTRL_INTE |
+  DAS16_CTRL_DMAE |
+   

[PATCH 27/38] staging: comedi: das16: fail attach if board id is incorrect

2013-07-29 Thread H Hartley Sweeten
This driver probes the board id during the attach to ensure that the
user is attempting to attach to the correct board type. Currently an
error message is output if the ids are not consistent but the attach
continues anyway.

Make the attach fail if the id bits do not match. Also, cleanup the
printk messages and use a dev_err() only if the probe fails.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 97ba2bd..8f4b3dd 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -974,11 +974,11 @@ static int das16_probe(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
/* diobits indicates boards */
diobits = inb(dev->iobase + DAS16_DIO_REG) & 0xf0;
-
-   printk(KERN_INFO " id bits are 0x%02x\n", diobits);
if (board->id != diobits) {
-   printk(KERN_INFO " requested board's id bits are 0x%x 
(ignore)\n",
-  board->id);
+   dev_err(dev->class_dev,
+   "requested board's id bits are incorrect (0x%x != 
0x%x)\n",
+   board->id, diobits);
+   return -EINVAL;
}
 
return 0;
@@ -1054,10 +1054,8 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
}
 
/*  probe id bits to make sure they are consistent */
-   if (das16_probe(dev, it)) {
-   printk(KERN_ERR " id bits do not match selected board, 
aborting\n");
+   if (das16_probe(dev, it))
return -EINVAL;
-   }
 
/*  get master clock speed */
if (devpriv->can_burst) {
-- 
1.8.3.2

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


[PATCH 32/38] staging: comedi: das16: tidy up private data definition

2013-07-29 Thread H Hartley Sweeten
Remove the comments and add some whitespace to help readability.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index fb3e0e0..e7b7bcd 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -443,30 +443,22 @@ static inline int timer_period(void)
 }
 
 struct das16_private_struct {
-   unsigned int clockbase; /*  master clock speed in ns */
-   unsigned int ctrl_reg;
-   unsigned long adc_byte_count;   /*  number of bytes remaining */
-   /*  divisor dividing master clock to get conversion frequency */
-   unsigned int divisor1;
-   /*  divisor dividing master clock to get conversion frequency */
-   unsigned int divisor2;
-   unsigned int dma_chan;  /*  dma channel */
-   uint16_t *dma_buffer[2];
-   dma_addr_t dma_buffer_addr[2];
-   unsigned int current_buffer;
-   unsigned int dma_transfer_size; /*  target number of bytes to transfer 
per dma shot */
-   /**
-* user-defined analog input and output ranges
-* defined from config options
-*/
-   struct comedi_lrange *user_ai_range_table;
-   struct comedi_lrange *user_ao_range_table;
-
-   struct timer_list timer;/*  for timed interrupt */
-   short timer_running;
-
-   unsigned long extra_iobase;
-   unsigned int can_burst:1;
+   unsigned intclockbase;
+   unsigned intctrl_reg;
+   unsigned long   adc_byte_count;
+   unsigned intdivisor1;
+   unsigned intdivisor2;
+   unsigned intdma_chan;
+   uint16_t*dma_buffer[2];
+   dma_addr_t  dma_buffer_addr[2];
+   unsigned intcurrent_buffer;
+   unsigned intdma_transfer_size;
+   struct comedi_lrange*user_ai_range_table;
+   struct comedi_lrange*user_ao_range_table;
+   struct timer_list   timer;
+   short   timer_running;
+   unsigned long   extra_iobase;
+   unsigned intcan_burst:1;
 };
 
 static void das16_ai_enable(struct comedi_device *dev,
-- 
1.8.3.2

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


[PATCH 29/38] staging: comedi: das16: absorb das1600_mode_detect() into caller

2013-07-29 Thread H Hartley Sweeten
This function is only called during the board attach to determine the
pacer clock speed for the boards capable of bursting.

Absorb it into the caller and remove the attach noise.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 2169cd7..7dae83e 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -984,24 +984,6 @@ static int das16_probe(struct comedi_device *dev, struct 
comedi_devconfig *it)
return 0;
 }
 
-static int das1600_mode_detect(struct comedi_device *dev)
-{
-   struct das16_private_struct *devpriv = dev->private;
-   int status = 0;
-
-   status = inb(dev->iobase + DAS1600_STATUS_REG);
-
-   if (status & DAS1600_STATUS_CLK_10MHZ) {
-   devpriv->clockbase = 100;
-   printk(KERN_INFO " 10MHz pacer clock\n");
-   } else {
-   devpriv->clockbase = 1000;
-   printk(KERN_INFO " 1MHz pacer clock\n");
-   }
-
-   return 0;
-}
-
 static void das16_reset(struct comedi_device *dev)
 {
outb(0, dev->iobase + DAS16_STATUS_REG);
@@ -1058,7 +1040,12 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
 
/*  get master clock speed */
if (devpriv->can_burst) {
-   das1600_mode_detect(dev);
+   status = inb(dev->iobase + DAS1600_STATUS_REG);
+
+   if (status & DAS1600_STATUS_CLK_10MHZ)
+   devpriv->clockbase = 100;
+   else
+   devpriv->clockbase = 1000;
} else {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
-- 
1.8.3.2

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


[PATCH 31/38] staging: comedi: das16: cleanup comedi_error() messages

2013-07-29 Thread H Hartley Sweeten
Some of these messages are missing the terminating '\n' and most of them
have the quoted string split across lines.

Change all of them to dev_err() messages and fix the issues.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index c4f0853..fb3e0e0 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -527,8 +527,8 @@ static int disable_dma_on_even(struct comedi_device *dev)
residue = get_dma_residue(devpriv->dma_chan);
}
if (i == disable_limit) {
-   comedi_error(dev, "failed to get an even dma transfer, "
-   "could be trouble.");
+   dev_err(dev->class_dev,
+   "failed to get an even dma transfer, could be 
trouble\n");
}
return residue;
 }
@@ -556,7 +556,7 @@ static void das16_interrupt(struct comedi_device *dev)
 
/*  figure out how many points to read */
if (residue > devpriv->dma_transfer_size) {
-   comedi_error(dev, "residue > transfer size!\n");
+   dev_err(dev->class_dev, "residue > transfer size!\n");
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
num_bytes = 0;
} else
@@ -702,16 +702,13 @@ static int das16_cmd_test(struct comedi_device *dev, 
struct comedi_subdevice *s,
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
(start_chan + i) % s->n_chan) {
-   comedi_error(dev,
-   "entries in chanlist must be "
-   "consecutive channels, "
-   "counting upwards\n");
+   dev_err(dev->class_dev,
+   "entries in chanlist must be 
consecutive channels, counting upwards\n");
err++;
}
if (CR_RANGE(cmd->chanlist[i]) != gain) {
-   comedi_error(dev,
-   "entries in chanlist must all "
-   "have the same gain\n");
+   dev_err(dev->class_dev,
+   "entries in chanlist must all have the 
same gain\n");
err++;
}
}
@@ -750,8 +747,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
int range;
 
if (cmd->flags & TRIG_RT) {
-   comedi_error(dev, "isa dma transfers cannot be performed with "
-   "TRIG_RT, aborting");
+   dev_err(dev->class_dev,
+"isa dma transfers cannot be performed with TRIG_RT, 
aborting\n");
return -1;
}
 
-- 
1.8.3.2

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


[PATCH 30/38] staging: comedi: das16: fix a > 80 char line issue

2013-07-29 Thread H Hartley Sweeten
Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/das16.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 7dae83e..c4f0853 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -784,7 +784,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct 
comedi_subdevice *s)
byte = 0;
if (devpriv->can_burst) {
if (cmd->convert_src == TRIG_NOW) {
-   outb(DAS1600_BURST_VAL, dev->iobase + 
DAS1600_BURST_REG);
+   outb(DAS1600_BURST_VAL,
+dev->iobase + DAS1600_BURST_REG);
/*  set burst length */
byte |= DAS16_PACER_BURST_LEN(cmd->chanlist_len - 1);
} else {
-- 
1.8.3.2

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


[PATCH 28/38] staging: comedi: das16: cleanup printk message in board attach

2013-07-29 Thread H Hartley Sweeten
Convert this printk message into a dev_err().

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 8f4b3dd..2169cd7 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1025,9 +1025,8 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
if (it->options[3]) {
if (it->options[3] != 0 &&
it->options[3] != 1 && it->options[3] != 10) {
-   printk
-   ("\n Invalid option.  Master clock must be set "
-   "to 1 or 10 (MHz)\n");
+   dev_err(dev->class_dev,
+   "Invalid option. Master clock must be set to 1 
or 10 (MHz)\n");
return -EINVAL;
}
}
-- 
1.8.3.2

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


[PATCH 34/38] staging: comedi: das16: fix das16_detach()

2013-07-29 Thread H Hartley Sweeten
The function das16_reset() needs a valid dev->iobase. Since the iobase
is requested after the devpriv has been allocated in the attach, move
the das16_reset() call into the if (devpriv) and add a if (dev->iobase).

Also, move the release of the extra iobase into the if (devpriv) to
prevent an invalid memory access.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 60895e6..9944f71 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1206,10 +1206,12 @@ static void das16_detach(struct comedi_device *dev)
 {
const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv = dev->private;
+   int i;
 
-   das16_reset(dev);
if (devpriv) {
-   int i;
+   if (dev->iobase)
+   das16_reset(dev);
+
for (i = 0; i < 2; i++) {
if (devpriv->dma_buffer[i])
pci_free_consistent(NULL, DAS16_DMA_SIZE,
@@ -1221,9 +1223,12 @@ static void das16_detach(struct comedi_device *dev)
free_dma(devpriv->dma_chan);
kfree(devpriv->user_ai_range_table);
kfree(devpriv->user_ao_range_table);
+
+   if (devpriv->extra_iobase)
+   release_region(devpriv->extra_iobase,
+  board->size & 0x3ff);
}
-   if (devpriv->extra_iobase)
-   release_region(devpriv->extra_iobase, board->size & 0x3ff);
+
comedi_legacy_detach(dev);
 }
 
-- 
1.8.3.2

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


[PATCH 35/38] staging: comedi: das16: remove an unnecessary check in the attach

2013-07-29 Thread H Hartley Sweeten
If the user does not specify the analog output range the private data
'user_ao_range_table' will not be allocated. The comedi core will detect
the NULL s->range_table and automatically set it to &range_unknown.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 9944f71..00ecb3c 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1148,11 +1148,7 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
s->subdev_flags = SDF_WRITABLE;
s->n_chan   = 2;
s->maxdata  = 0x0fff;
-   if (devpriv->user_ao_range_table)
-   s->range_table  = devpriv->user_ao_range_table;
-   else
-   s->range_table  = &range_unknown;
-
+   s->range_table  = devpriv->user_ao_range_table;
s->insn_write   = das16_ao_insn_write;
} else {
s->type = COMEDI_SUBD_UNUSED;
-- 
1.8.3.2

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


[PATCH 33/38] staging: comedi: das16: change MODULE_DESCRIPTION

2013-07-29 Thread H Hartley Sweeten
Change the MODULE_DESCRIPTION to something useful instead of the
generic "Comedi low-level driver".

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index e7b7bcd..60895e6 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1239,5 +1239,5 @@ static struct comedi_driver das16_driver = {
 module_comedi_driver(das16_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org";);
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for DAS16 compatible boards");
 MODULE_LICENSE("GPL");
-- 
1.8.3.2

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


[PATCH 36/38] staging: comedi: das16: tidy up user ai/ao range initialization

2013-07-29 Thread H Hartley Sweeten
The allocation of the user range tables could fail. Make sure to check
for it.

Change the kmalloc()'s to kzalloc()'s to make sure the allocated range
tables are initialized to a known state.

Change the local variables so they can be used for both the ai and ao
range initialization and use shorter names to keep the lines < 80 chars.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 00ecb3c..da64080 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -987,8 +987,8 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv;
struct comedi_subdevice *s;
-   struct comedi_krange *user_ai_range;
-   struct comedi_krange *user_ao_range;
+   struct comedi_lrange *lrange;
+   struct comedi_krange *krange;
unsigned int dma_chan = it->options[2];
unsigned int status;
int ret;
@@ -1077,32 +1077,37 @@ static int das16_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
devpriv->timer.data = (unsigned long)dev;
}
 
-   /*  get any user-defined input range */
+   /* get any user-defined input range */
if (board->ai_pg == das16_pg_none &&
(it->options[4] || it->options[5])) {
-   /*  allocate single-range range table */
-   devpriv->user_ai_range_table =
-   kmalloc(sizeof(struct comedi_lrange) +
-   sizeof(struct comedi_krange), GFP_KERNEL);
-   /*  initialize ai range */
-   devpriv->user_ai_range_table->length = 1;
-   user_ai_range = devpriv->user_ai_range_table->range;
-   user_ai_range->min = it->options[4];
-   user_ai_range->max = it->options[5];
-   user_ai_range->flags = UNIT_volt;
+   /* allocate single-range range table */
+   lrange = kzalloc(sizeof(*lrange) + sizeof(*krange), GFP_KERNEL);
+   if (!lrange)
+   return -ENOMEM;
+
+   /* initialize ai range */
+   devpriv->user_ai_range_table = lrange;
+   lrange->length = 1;
+   krange = devpriv->user_ai_range_table->range;
+   krange->min = it->options[4];
+   krange->max = it->options[5];
+   krange->flags = UNIT_volt;
}
-   /*  get any user-defined output range */
+
+   /* get any user-defined output range */
if (it->options[6] || it->options[7]) {
-   /*  allocate single-range range table */
-   devpriv->user_ao_range_table =
-   kmalloc(sizeof(struct comedi_lrange) +
-   sizeof(struct comedi_krange), GFP_KERNEL);
-   /*  initialize ao range */
-   devpriv->user_ao_range_table->length = 1;
-   user_ao_range = devpriv->user_ao_range_table->range;
-   user_ao_range->min = it->options[6];
-   user_ao_range->max = it->options[7];
-   user_ao_range->flags = UNIT_volt;
+   /* allocate single-range range table */
+   lrange = kzalloc(sizeof(*lrange) + sizeof(*krange), GFP_KERNEL);
+   if (!lrange)
+   return -ENOMEM;
+
+   /* initialize ao range */
+   devpriv->user_ao_range_table = lrange;
+   lrange->length = 1;
+   krange = devpriv->user_ao_range_table->range;
+   krange->min = it->options[6];
+   krange->max = it->options[7];
+   krange->flags = UNIT_volt;
}
 
ret = comedi_alloc_subdevices(dev, 4 + board->has_8255);
-- 
1.8.3.2

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


[PATCH 38/38] staging: comedi: das16: tidy up multi-line comments

2013-07-29 Thread H Hartley Sweeten
Tidy up the multi-line comments to follow the CodingStyle.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 599be27..93a8f09 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1,77 +1,84 @@
 /*
-comedi/drivers/das16.c
-DAS16 driver
-
-COMEDI - Linux Control and Measurement Device Interface
-Copyright (C) 2000 David A. Schleef 
-Copyright (C) 2000 Chris R. Baugher 
-Copyright (C) 2001,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.
-*/
-/*
-Driver: das16
-Description: DAS16 compatible boards
-Author: Sam Moore, Warren Jasper, ds, Chris Baugher, Frank Hess, Roman Fietze
-Devices: [Keithley Metrabyte] DAS-16 (das-16), DAS-16G (das-16g),
-  DAS-16F (das-16f), DAS-1201 (das-1201), DAS-1202 (das-1202),
-  DAS-1401 (das-1401), DAS-1402 (das-1402), DAS-1601 (das-1601),
-  DAS-1602 (das-1602),
-  [ComputerBoards] PC104-DAS16/JR (pc104-das16jr),
-  PC104-DAS16JR/16 (pc104-das16jr/16),
-  CIO-DAS16JR/16 (cio-das16jr/16),
-  CIO-DAS16/JR (cio-das16/jr), CIO-DAS1401/12 (cio-das1401/12),
-  CIO-DAS1402/12 (cio-das1402/12), CIO-DAS1402/16 (cio-das1402/16),
-  CIO-DAS1601/12 (cio-das1601/12), CIO-DAS1602/12 (cio-das1602/12),
-  CIO-DAS1602/16 (cio-das1602/16), CIO-DAS16/330 (cio-das16/330)
-Status: works
-Updated: 2003-10-12
-
-A rewrite of the das16 and das1600 drivers.
-Options:
-   [0] - base io address
-   [1] - irq (does nothing, irq is not used anymore)
-   [2] - dma (optional, required for comedi_command support)
-   [3] - master clock speed in MHz (optional, 1 or 10, ignored if
-   board can probe clock, defaults to 1)
-   [4] - analog input range lowest voltage in microvolts (optional,
-   only useful if your board does not have software
-   programmable gain)
-   [5] - analog input range highest voltage in microvolts (optional,
-   only useful if board does not have software programmable
-   gain)
-   [6] - analog output range lowest voltage in microvolts (optional)
-   [7] - analog output range highest voltage in microvolts (optional)
-   [8] - use timer mode for DMA.  Timer mode is needed e.g. for
-   buggy DMA controllers in NS CS5530A (Geode Companion), and for
-   'jr' cards that lack a hardware fifo.  This option is no
-   longer needed, since timer mode is _always_ used.
-
-Passing a zero for an option is the same as leaving it unspecified.
+ * das16.c
+ * DAS16 driver
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef 
+ * Copyright (C) 2000 Chris R. Baugher 
+ * Copyright (C) 2001,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.
+ */
 
-*/
 /*
+ * Driver: das16
+ * Description: DAS16 compatible boards
+ * Author: Sam Moore, Warren Jasper, ds, Chris Baugher, Frank Hess, Roman 
Fietze
+ * Devices: (Keithley Metrabyte) DAS-16 [das-16]
+ * (Keithley Metrabyte) DAS-16G [das-16g]
+ * (Keithley Metrabyte) DAS-16F [das-16f]
+ * (Keithley Metrabyte) DAS-1201 [das-1201]
+ * (Keithley Metrabyte) DAS-1202 [das-1202]
+ * (Keithley Metrabyte) DAS-1401 [das-1401]
+ * (Keithley Metrabyte) DAS-1402 [das-1402]
+ * (Keithley Metrabyte) DAS-1601 [das-1601]
+ * (Keithley Metrabyte) DAS-1602 [das-1602]
+ * (ComputerBoards) PC104-DAS16/JR [pc104-das16jr]
+ * (ComputerBoards) PC104-DAS16JR/16 [pc104-das16jr/16]
+ * (ComputerBoards) CIO-DAS16 [cio-das16]
+ * (ComputerBoards) CIO-DAS16F [cio-das16/f]
+ * (ComputerBoards) CIO-DAS16/JR [cio-das16/jr]
+ * (ComputerBoards) CIO-DAS16JR/16 [cio-das16jr/16]
+ * (ComputerBoards) CIO-DAS1401/12 [cio

[PATCH 37/38] staging: comedi: das16: remove some unnecessary parentheses

2013-07-29 Thread H Hartley Sweeten
These parentheses are not necessary.

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index da64080..599be27 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -668,9 +668,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct 
comedi_subdevice *s,
unsigned int tmp = cmd->scan_begin_arg;
/*  set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
-  &(devpriv->divisor1),
-  &(devpriv->divisor2),
-  &(cmd->scan_begin_arg),
+  &devpriv->divisor1,
+  &devpriv->divisor2,
+  &cmd->scan_begin_arg,
   cmd->flags & TRIG_ROUND_MASK);
err += (tmp != cmd->scan_begin_arg);
}
@@ -678,9 +678,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct 
comedi_subdevice *s,
unsigned int tmp = cmd->convert_arg;
/*  set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
-  &(devpriv->divisor1),
-  &(devpriv->divisor2),
-  &(cmd->convert_arg),
+  &devpriv->divisor1,
+  &devpriv->divisor2,
+  &cmd->convert_arg,
   cmd->flags & TRIG_ROUND_MASK);
err += (tmp != cmd->convert_arg);
}
@@ -717,8 +717,10 @@ static unsigned int das16_set_pacer(struct comedi_device 
*dev, unsigned int ns,
struct das16_private_struct *devpriv = dev->private;
unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
 
-   i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
-  &(devpriv->divisor2), &ns,
+   i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
+  &devpriv->divisor1,
+  &devpriv->divisor2,
+  &ns,
   rounding_flags & TRIG_ROUND_MASK);
 
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
@@ -1072,7 +1074,7 @@ static int das16_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
set_dma_mode(devpriv->dma_chan, DMA_MODE_READ);
release_dma_lock(flags);
 
-   init_timer(&(devpriv->timer));
+   init_timer(&devpriv->timer);
devpriv->timer.function = das16_timer_interrupt;
devpriv->timer.data = (unsigned long)dev;
}
-- 
1.8.3.2

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


[PATCH 2/2] staging: olpc_dcon: provide detailed FB_OLPC_DCON help section

2013-07-29 Thread Jens Frederich
The FB_OLPC_DCON help section is to short according to checkpatch.pl.
We want more information about the controller type, its task, its video
pipeline position and so on.

There are no style issues, remove checkpatch.pl TODO entry.

Signed-off-by: Jens Frederich 
---
 drivers/staging/olpc_dcon/Kconfig |   11 ---
 drivers/staging/olpc_dcon/TODO|1 -
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/olpc_dcon/Kconfig 
b/drivers/staging/olpc_dcon/Kconfig
index fe40e0b..2ff015d 100644
--- a/drivers/staging/olpc_dcon/Kconfig
+++ b/drivers/staging/olpc_dcon/Kconfig
@@ -4,9 +4,14 @@ config FB_OLPC_DCON
select I2C
select BACKLIGHT_CLASS_DEVICE
---help---
- Add support for the OLPC XO DCON controller.  This controller is
- only available on OLPC platforms.   Unless you have one of these
- platforms, you will want to say 'N'.
+ In order to support very low power operation, the XO laptop uses a
+ secondary Display CONtroller, or DCON.  This secondary controller
+ is present in the video pipeline between the primary display
+ controller (integrate into the processor or chipset) and the LCD
+ panel.  It allows the main processor/display controller to be
+ completely powered off while still retaining an image on the display.
+ This controller is only available on OLPC platforms.  Unless you have
+ one of these platforms, you will want to say 'N'.
 
 config FB_OLPC_DCON_1
bool "OLPC XO-1 DCON support"
diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO
index 35f9cda..f378e84 100644
--- a/drivers/staging/olpc_dcon/TODO
+++ b/drivers/staging/olpc_dcon/TODO
@@ -1,5 +1,4 @@
 TODO:
-   - checkpatch.pl cleanups
- see if vx855 gpio API can be made similar enough to cs5535 so we can
  share more code
- allow simultaneous XO-1 and XO-1.5 support
-- 
1.7.9.5

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


[PATCH v2] staging/lustre: lloop depends on BLOCK

2013-07-29 Thread Xiong Zhou
From: Xiong Zhou 

In the lustre client driver, lloop depends on BLOCK. Add an
option for this dependence. Last version of this patch makes
LUSTRE_FS depends on BLOCK.
Remove unnecessary jdb head files which depends on BLOCK.

Signed-off-by: Xiong Zhou 
---
 drivers/staging/lustre/lustre/Kconfig  |7 ++-
 drivers/staging/lustre/lustre/fld/fld_cache.c  |1 -
 drivers/staging/lustre/lustre/fld/fld_request.c|1 -
 .../lustre/lustre/include/linux/lustre_compat25.h  |2 ++
 drivers/staging/lustre/lustre/llite/Makefile   |2 +-
 drivers/staging/lustre/lustre/lvfs/fsfilt.c|1 -
 6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/Kconfig 
b/drivers/staging/lustre/lustre/Kconfig
index 0b45de0..4e898e4 100644
--- a/drivers/staging/lustre/lustre/Kconfig
+++ b/drivers/staging/lustre/lustre/Kconfig
@@ -1,6 +1,6 @@
 config LUSTRE_FS
tristate "Lustre file system client support"
-   depends on STAGING && INET && BLOCK && m
+   depends on INET && m
select LNET
select CRYPTO
select CRYPTO_CRC32
@@ -53,3 +53,8 @@ config LUSTRE_TRANSLATE_ERRNOS
bool
depends on LUSTRE_FS && !X86
default true
+
+config LUSTRE_LLITE_LLOOP
+   bool "Lustre virtual block device"
+   depends on LUSTRE_FS && BLOCK
+   default m
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c 
b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 347f2ae..8410107 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -45,7 +45,6 @@
 
 # include 
 # include 
-# include 
 # include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index c99b945..049322a 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -44,7 +44,6 @@
 
 # include 
 # include 
-# include 
 # include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h 
b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
index 426533b..c0156e3 100644
--- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
+++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
@@ -111,12 +111,14 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, 
struct vfsmount *mnt,
 #define TREE_READ_LOCK_IRQ(mapping)spin_lock_irq(&(mapping)->tree_lock)
 #define TREE_READ_UNLOCK_IRQ(mapping)  spin_unlock_irq(&(mapping)->tree_lock)
 
+#ifdef CONFIG_BLOCK
 static inline
 int ll_unregister_blkdev(unsigned int dev, const char *name)
 {
unregister_blkdev(dev, name);
return 0;
 }
+#endif
 
 #define ll_invalidate_bdev(a,b) invalidate_bdev((a))
 
diff --git a/drivers/staging/lustre/lustre/llite/Makefile 
b/drivers/staging/lustre/lustre/llite/Makefile
index dff0c04..f493e07 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_LUSTRE_FS) += lustre.o
-obj-$(CONFIG_LUSTRE_FS) += llite_lloop.o
+obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o
 lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \
rw.o lproc_llite.o namei.o symlink.o llite_mmap.o \
xattr.o remote_perm.o llite_rmtacl.o llite_capa.o \
diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c 
b/drivers/staging/lustre/lustre/lvfs/fsfilt.c
index 064445c..ce71f80 100644
--- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c
+++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c
@@ -35,7 +35,6 @@
 #define DEBUG_SUBSYSTEM S_FILTER
 
 #include 
-#include 
 #include 
 #include 
 #include 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/18] staging: comedi: usbduxsigma: generalize the ai/ao usb_kill_urb()

2013-07-29 Thread H Hartley Sweeten
Generalize a helper function to replace for() loops in 
usbduxsigma_{ai,ao}_stop()
that call usb_kill_urb() to unlink all the urbs.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 1af2354..b31e400 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -195,18 +195,20 @@ struct usbduxsigma_private {
struct semaphore sem;
 };
 
+static void usbduxsigma_unlink_urbs(struct urb **urbs, int num_urbs)
+{
+   int i;
+
+   for (i = 0; i < num_urbs; i++)
+   usb_kill_urb(urbs[i]);
+}
+
 static void usbduxsigma_ai_stop(struct comedi_device *dev, int do_unlink)
 {
struct usbduxsigma_private *devpriv = dev->private;
 
-   if (do_unlink) {
-   int i;
-
-   for (i = 0; i < devpriv->n_ai_urbs; i++) {
-   if (devpriv->ai_urbs[i])
-   usb_kill_urb(devpriv->ai_urbs[i]);
-   }
-   }
+   if (do_unlink && devpriv->ai_urbs)
+   usbduxsigma_unlink_urbs(devpriv->ai_urbs, devpriv->n_ai_urbs);
 
devpriv->ai_cmd_running = 0;
 }
@@ -342,14 +344,8 @@ static void usbduxsigma_ao_stop(struct comedi_device *dev, 
int do_unlink)
 {
struct usbduxsigma_private *devpriv = dev->private;
 
-   if (do_unlink) {
-   int i;
-
-   for (i = 0; i < devpriv->n_ao_urbs; i++) {
-   if (devpriv->ao_urbs[i])
-   usb_kill_urb(devpriv->ao_urbs[i]);
-   }
-   }
+   if (do_unlink && devpriv->ao_urbs)
+   usbduxsigma_unlink_urbs(devpriv->ao_urbs, devpriv->n_ao_urbs);
 
devpriv->ao_cmd_running = 0;
 }
-- 
1.8.3.2

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


[PATCH 01/18] staging: comedi: usbdux: generalize the usb_submit_urb functions

2013-07-29 Thread H Hartley Sweeten
Generalize a helper function to replace usbduxsub_submit_{in,out}urbs().

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 7ff731f..bf6c9ff 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -531,7 +531,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
}
 }
 
-static int usbduxsub_submit_inurbs(struct comedi_device *dev)
+static int usbdux_submit_urbs(struct comedi_device *dev,
+ struct urb **urbs, int num_urbs,
+ int input_urb)
 {
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usbdux_private *devpriv = dev->private;
@@ -540,35 +542,12 @@ static int usbduxsub_submit_inurbs(struct comedi_device 
*dev)
int i;
 
/* Submit all URBs and start the transfer on the bus */
-   for (i = 0; i < devpriv->n_ai_urbs; i++) {
-   urb = devpriv->ai_urbs[i];
-
-   /* in case of a resubmission after an unlink... */
-   urb->interval = devpriv->ai_interval;
-   urb->context = dev;
-   urb->dev = usb;
-   urb->status = 0;
-   urb->transfer_flags = URB_ISO_ASAP;
-
-   ret = usb_submit_urb(urb, GFP_ATOMIC);
-   if (ret)
-   return ret;
-   }
-   return 0;
-}
-
-static int usbduxsub_submit_outurbs(struct comedi_device *dev)
-{
-   struct usb_device *usb = comedi_to_usb_dev(dev);
-   struct usbdux_private *devpriv = dev->private;
-   struct urb *urb;
-   int ret;
-   int i;
-
-   for (i = 0; i < devpriv->n_ao_urbs; i++) {
-   urb = devpriv->ao_urbs[i];
+   for (i = 0; i < num_urbs; i++) {
+   urb = urbs[i];
 
/* in case of a resubmission after an unlink... */
+   if (input_urb)
+   urb->interval = devpriv->ai_interval;
urb->context = dev;
urb->dev = usb;
urb->status = 0;
@@ -725,7 +704,8 @@ static int usbdux_ai_inttrig(struct comedi_device *dev,
 
if (!devpriv->ai_cmd_running) {
devpriv->ai_cmd_running = 1;
-   ret = usbduxsub_submit_inurbs(dev);
+   ret = usbdux_submit_urbs(dev, devpriv->ai_urbs,
+devpriv->n_ai_urbs, 1);
if (ret < 0) {
devpriv->ai_cmd_running = 0;
goto ai_trig_exit;
@@ -807,7 +787,8 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
if (cmd->start_src == TRIG_NOW) {
/* enable this acquisition operation */
devpriv->ai_cmd_running = 1;
-   ret = usbduxsub_submit_inurbs(dev);
+   ret = usbdux_submit_urbs(dev, devpriv->ai_urbs,
+devpriv->n_ai_urbs, 1);
if (ret < 0) {
devpriv->ai_cmd_running = 0;
/* fixme: unlink here?? */
@@ -944,7 +925,8 @@ static int usbdux_ao_inttrig(struct comedi_device *dev,
 
if (!devpriv->ao_cmd_running) {
devpriv->ao_cmd_running = 1;
-   ret = usbduxsub_submit_outurbs(dev);
+   ret = usbdux_submit_urbs(dev, devpriv->ao_urbs,
+devpriv->n_ao_urbs, 0);
if (ret < 0) {
devpriv->ao_cmd_running = 0;
goto ao_trig_exit;
@@ -1105,7 +1087,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
if (cmd->start_src == TRIG_NOW) {
/* enable this acquisition operation */
devpriv->ao_cmd_running = 1;
-   ret = usbduxsub_submit_outurbs(dev);
+   ret = usbdux_submit_urbs(dev, devpriv->ao_urbs,
+devpriv->n_ao_urbs, 0);
if (ret < 0) {
devpriv->ao_cmd_running = 0;
/* fixme: unlink here?? */
-- 
1.8.3.2

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


[PATCH 00/18] staging: comedi: tidy up usbdux drivers

2013-07-29 Thread H Hartley Sweeten
The usbdux and usbduxsigma drivers are very similar and should be able
to share some common code.

Tidy up the drivers a bit so that the common pieces can be located and
pulled out.

H Hartley Sweeten (18):
  staging: comedi: usbdux: generalize the usb_submit_urb functions
  staging: comedi: usbduxsigma: generalize the ai/ao usb_kill_urb()
  staging: comedi: usbduxsigma: remove the usb endpoint defines
  staging: comedi: usbdux: tidy up usbdux_pwm_period()
  staging: comedi: usbdux: tidy up usbdux_pwm_pattern()
  staging: comedi: usbdux: tidy up usbdux_pwm_write()
  staging: comedi: usbdux: remove usbdux_pwm_read()
  staging: comedi: usbdux: tidy up usbdux_pwm_config()
  staging: comedi: usbdux: return void from usbdux_pwm_pattern()
  staging: comedi: usbduxsigma: return void from usbduxsigma_pwm_pattern()
  staging: comedi: usbdux: tidy up usbdux_alloc_usb_buffers()
  staging: comedi: usbduxsigma: 'dac_commands' does not need to be kzalloc()'d
  staging: comedi: usbduxsigma: init 'pwm_buf_sz' in usbduxsigma_auto_attach()
  staging: comedi: usbduxsigma: move urb unlink into usbduxsigma_detach()
  staging: comedi: usbduxsigma: always clear the usb intfdata in (*detach)
  staging: comedi: usbdux: tidy up usbdux_detach()
  staging: comedi: usbdux: tidy up usbdux_free_usb_buffers()
  staging: comedi: usbduxsigma: absorb usbduxsigma_attach_common() into caller

 drivers/staging/comedi/drivers/usbdux.c  | 242 +--
 drivers/staging/comedi/drivers/usbduxsigma.c | 276 ---
 2 files changed, 207 insertions(+), 311 deletions(-)

-- 
1.8.3.2

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


[PATCH 05/18] staging: comedi: usbdux: tidy up usbdux_pwm_pattern()

2013-07-29 Thread H Hartley Sweeten
Rename the local variable used for the private data pointer to 'devpriv'.

Remove the sanity check of the private data. This function can only be
called if the private data was successfully allocated in the attach.

Tidy up the function to make it more concise.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 0683c8e..72094d9 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1396,45 +1396,30 @@ pwm_start_exit:
return ret;
 }
 
-/* generates the bit pattern for PWM with the optional sign bit */
 static int usbdux_pwm_pattern(struct comedi_device *dev,
- struct comedi_subdevice *s, int channel,
- unsigned int value, unsigned int sign)
+ struct comedi_subdevice *s,
+ unsigned int chan,
+ unsigned int value,
+ unsigned int sign)
 {
-   struct usbdux_private *this_usbduxsub = dev->private;
-   int i, szbuf;
-   char *p_buf;
-   char pwm_mask;
-   char sgn_mask;
-   char c;
-
-   if (!this_usbduxsub)
-   return -EFAULT;
+   struct usbdux_private *devpriv = dev->private;
+   char pwm_mask = (1 << chan);/* DIO bit for the PWM data */
+   char sgn_mask = (16 << chan);   /* DIO bit for the sign */
+   char *buf = (char *)(devpriv->pwm_urb->transfer_buffer);
+   int szbuf = devpriv->pwm_buf_sz;
+   int i;
 
-   /* this is the DIO bit which carries the PWM data */
-   pwm_mask = (1 << channel);
-   /* this is the DIO bit which carries the optional direction bit */
-   sgn_mask = (16 << channel);
-   /* this is the buffer which will be filled with the with bit */
-   /* pattern for one period */
-   szbuf = this_usbduxsub->pwm_buf_sz;
-   p_buf = (char *)(this_usbduxsub->pwm_urb->transfer_buffer);
for (i = 0; i < szbuf; i++) {
-   c = *p_buf;
-   /* reset bits */
-   c = c & (~pwm_mask);
-   /* set the bit as long as the index is lower than the value */
+   char c = *buf;
+
+   c &= ~pwm_mask;
if (i < value)
-   c = c | pwm_mask;
-   /* set the optional sign bit for a relay */
-   if (!sign) {
-   /* positive value */
-   c = c & (~sgn_mask);
-   } else {
-   /* negative value */
-   c = c | sgn_mask;
-   }
-   *(p_buf++) = c;
+   c |= pwm_mask;
+   if (!sign)
+   c &= ~sgn_mask;
+   else
+   c |= sgn_mask;
+   *buf++ = c;
}
return 1;
 }
-- 
1.8.3.2

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


[PATCH 04/18] staging: comedi: usbdux: tidy up usbdux_pwm_period()

2013-07-29 Thread H Hartley Sweeten
Rename the local variable used for the private data pointer to 'devpriv'.

Fix the fx2delay calculation so it does not use floating point values.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index bf6c9ff..0683c8e 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1347,20 +1347,21 @@ static int usbduxsub_submit_pwm_urbs(struct 
comedi_device *dev)
 }
 
 static int usbdux_pwm_period(struct comedi_device *dev,
-struct comedi_subdevice *s, unsigned int period)
+struct comedi_subdevice *s,
+unsigned int period)
 {
-   struct usbdux_private *this_usbduxsub = dev->private;
+   struct usbdux_private *devpriv = dev->private;
int fx2delay = 255;
 
if (period < MIN_PWM_PERIOD) {
return -EAGAIN;
} else {
-   fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6;
+   fx2delay = (period / (6 * 512 * 1000 / 33)) - 6;
if (fx2delay > 255)
return -EAGAIN;
}
-   this_usbduxsub->pwm_delay = fx2delay;
-   this_usbduxsub->pwm_period = period;
+   devpriv->pwm_delay = fx2delay;
+   devpriv->pwm_period = period;
 
return 0;
 }
-- 
1.8.3.2

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


[PATCH 03/18] staging: comedi: usbduxsigma: remove the usb endpoint defines

2013-07-29 Thread H Hartley Sweeten
The endpoint defines are each only used in one place and don't help
clarify the code. Remove the defines and just open code the values.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index b31e400..ca6d952 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -66,13 +66,6 @@
 /* internal addresses of the 8051 processor */
 #define USBDUXSUB_CPUCS 0xE600
 
-/* USB endpoints */
-#define USBDUXSIGMA_CMD_OUT_EP 1   /* command output */
-#define USBDUXSIGMA_ISO_OUT_EP 2   /* analog output ISO/IRQ */
-#define USBDUXSIGMA_PWM_OUT_EP 4   /* pwm output */
-#define USBDUXSIGMA_ISO_IN_EP  6   /* analog input ISO/IRQ */
-#define USBDUXSIGMA_CMD_IN_EP  8   /* command input */
-
 /* 300Hz max frequ under PWM */
 #define MIN_PWM_PERIOD  ((long)(1E9/300))
 
@@ -639,7 +632,7 @@ static int usbbuxsigma_send_cmd(struct comedi_device *dev, 
int cmd_type)
 
devpriv->dux_commands[0] = cmd_type;
 
-   return usb_bulk_msg(usb, usb_sndbulkpipe(usb, USBDUXSIGMA_CMD_OUT_EP),
+   return usb_bulk_msg(usb, usb_sndbulkpipe(usb, 1),
devpriv->dux_commands, SIZEOFDUXBUFFER,
&nsent, BULK_TIMEOUT);
 }
@@ -653,8 +646,7 @@ static int usbduxsigma_receive_cmd(struct comedi_device 
*dev, int command)
int i;
 
for (i = 0; i < RETRIES; i++) {
-   ret = usb_bulk_msg(usb,
-  usb_rcvbulkpipe(usb, USBDUXSIGMA_CMD_IN_EP),
+   ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, 8),
   devpriv->insn_buf, SIZEINSNBUF,
   &nrec, BULK_TIMEOUT);
if (ret < 0)
@@ -1194,8 +1186,7 @@ static int usbduxsigma_submit_pwm_urb(struct 
comedi_device *dev)
struct urb *urb = devpriv->pwm_urb;
 
/* in case of a resubmission after an unlink... */
-   usb_fill_bulk_urb(urb,
- usb, usb_sndbulkpipe(usb, USBDUXSIGMA_PWM_OUT_EP),
+   usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, 4),
  urb->transfer_buffer, devpriv->pwm_buf_sz,
  usbduxsigma_pwm_urb_complete, dev);
 
@@ -1573,7 +1564,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
/* will be filled later with a pointer to the comedi-device */
/* and ONLY then the urb should be submitted */
urb->context = NULL;
-   urb->pipe = usb_rcvisocpipe(usb, USBDUXSIGMA_ISO_IN_EP);
+   urb->pipe = usb_rcvisocpipe(usb, 6);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
@@ -1595,7 +1586,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
/* will be filled later with a pointer to the comedi-device */
/* and ONLY then the urb should be submitted */
urb->context = NULL;
-   urb->pipe = usb_sndisocpipe(usb, USBDUXSIGMA_ISO_OUT_EP);
+   urb->pipe = usb_sndisocpipe(usb, 2);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
-- 
1.8.3.2

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


[PATCH 06/18] staging: comedi: usbdux: tidy up usbdux_pwm_write()

2013-07-29 Thread H Hartley Sweeten
Remove the sanity check of the private data. This function can only be
called if the private data was successfully allocated in the attach.

Tidy up the function a bit.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 72094d9..214a49f 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1426,27 +1426,23 @@ static int usbdux_pwm_pattern(struct comedi_device *dev,
 
 static int usbdux_pwm_write(struct comedi_device *dev,
struct comedi_subdevice *s,
-   struct comedi_insn *insn, unsigned int *data)
+   struct comedi_insn *insn,
+   unsigned int *data)
 {
-   struct usbdux_private *this_usbduxsub = dev->private;
-
-   if (!this_usbduxsub)
-   return -EFAULT;
+   unsigned int chan = CR_CHAN(insn->chanspec);
 
-   if ((insn->n) != 1) {
-   /*
-* doesn't make sense to have more than one value here because
-* it would just overwrite the PWM buffer a couple of times
-*/
+   /*
+* It doesn't make sense to support more than one value here
+* because it would just overwrite the PWM buffer.
+*/
+   if (insn->n != 1)
return -EINVAL;
-   }
 
/*
-* the sign is set via a special INSN only, this gives us 8 bits for
-* normal operation
-* relay sign 0 by default
+* The sign is set via a special INSN only, this gives us 8 bits
+* for normal operation, sign is 0 by default.
 */
-   return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec), data[0], 0);
+   return usbdux_pwm_pattern(dev, s, chan, data[0], 0);
 }
 
 static int usbdux_pwm_read(struct comedi_device *x1,
-- 
1.8.3.2

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


[PATCH 09/18] staging: comedi: usbdux: return void from usbdux_pwm_pattern()

2013-07-29 Thread H Hartley Sweeten
This function never fails and currently returns '1' so that the
usbdux_pwm_write() function returns to proper value (insn->n).

It's also called by usbdux_pwm_config() which also returns the '1'
value. The proper return code for this function should be '0' to
indicate success.

Change the return type of the function to void and just have the
callers return the proper values.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index b1fe329..9dcb297 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1396,11 +1396,11 @@ pwm_start_exit:
return ret;
 }
 
-static int usbdux_pwm_pattern(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int chan,
- unsigned int value,
- unsigned int sign)
+static void usbdux_pwm_pattern(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  unsigned int chan,
+  unsigned int value,
+  unsigned int sign)
 {
struct usbdux_private *devpriv = dev->private;
char pwm_mask = (1 << chan);/* DIO bit for the PWM data */
@@ -1421,7 +1421,6 @@ static int usbdux_pwm_pattern(struct comedi_device *dev,
c |= sgn_mask;
*buf++ = c;
}
-   return 1;
 }
 
 static int usbdux_pwm_write(struct comedi_device *dev,
@@ -1442,7 +1441,9 @@ static int usbdux_pwm_write(struct comedi_device *dev,
 * The sign is set via a special INSN only, this gives us 8 bits
 * for normal operation, sign is 0 by default.
 */
-   return usbdux_pwm_pattern(dev, s, chan, data[0], 0);
+   usbdux_pwm_pattern(dev, s, chan, data[0], 0);
+
+   return insn->n;
 }
 
 static int usbdux_pwm_config(struct comedi_device *dev,
@@ -1477,8 +1478,8 @@ static int usbdux_pwm_config(struct comedi_device *dev,
 * data[1] = value
 * data[2] = sign (for a relay)
 */
-   return usbdux_pwm_pattern(dev, s, chan,
- data[1], (data[2] != 0));
+   usbdux_pwm_pattern(dev, s, chan, data[1], (data[2] != 0));
+   return 0;
case INSN_CONFIG_PWM_GET_H_BRIDGE:
/* values are not kept in this driver, nothing to return here */
return -EINVAL;
-- 
1.8.3.2

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


[PATCH 07/18] staging: comedi: usbdux: remove usbdux_pwm_read()

2013-07-29 Thread H Hartley Sweeten
The pwm subdevice is not readable so this callback function is not
needed. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 214a49f..9f97e3e 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1445,14 +1445,6 @@ static int usbdux_pwm_write(struct comedi_device *dev,
return usbdux_pwm_pattern(dev, s, chan, data[0], 0);
 }
 
-static int usbdux_pwm_read(struct comedi_device *x1,
-  struct comedi_subdevice *x2, struct comedi_insn *x3,
-  unsigned int *x4)
-{
-   /* not needed */
-   return -EINVAL;
-};
-
 /* switches on/off PWM */
 static int usbdux_pwm_config(struct comedi_device *dev,
 struct comedi_subdevice *s,
@@ -1819,7 +1811,6 @@ static int usbdux_auto_attach(struct comedi_device *dev,
s->n_chan   = 8;
s->maxdata  = devpriv->pwm_buf_sz;
s->insn_write   = usbdux_pwm_write;
-   s->insn_read= usbdux_pwm_read;
s->insn_config  = usbdux_pwm_config;
 
usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
-- 
1.8.3.2

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


[PATCH 08/18] staging: comedi: usbdux: tidy up usbdux_pwm_config()

2013-07-29 Thread H Hartley Sweeten
Rename the local variable used for the private data pointer to 'devpriv'.

Tidy up the function a bit.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 9f97e3e..b1fe329 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1445,15 +1445,16 @@ static int usbdux_pwm_write(struct comedi_device *dev,
return usbdux_pwm_pattern(dev, s, chan, data[0], 0);
 }
 
-/* switches on/off PWM */
 static int usbdux_pwm_config(struct comedi_device *dev,
 struct comedi_subdevice *s,
-struct comedi_insn *insn, unsigned int *data)
+struct comedi_insn *insn,
+unsigned int *data)
 {
-   struct usbdux_private *this_usbduxsub = dev->private;
+   struct usbdux_private *devpriv = dev->private;
+   unsigned int chan = CR_CHAN(insn->chanspec);
+
switch (data[0]) {
case INSN_CONFIG_ARM:
-   /* switch it on */
/*
 * if not zero the PWM is limited to a certain time which is
 * not supported here
@@ -1464,27 +1465,20 @@ static int usbdux_pwm_config(struct comedi_device *dev,
case INSN_CONFIG_DISARM:
return usbdux_pwm_cancel(dev, s);
case INSN_CONFIG_GET_PWM_STATUS:
-   /*
-* to check if the USB transmission has failed or in case PWM
-* was limited to n cycles to check if it has terminated
-*/
-   data[1] = this_usbduxsub->pwm_cmd_running;
+   data[1] = devpriv->pwm_cmd_running;
return 0;
case INSN_CONFIG_PWM_SET_PERIOD:
return usbdux_pwm_period(dev, s, data[1]);
case INSN_CONFIG_PWM_GET_PERIOD:
-   data[1] = this_usbduxsub->pwm_period;
+   data[1] = devpriv->pwm_period;
return 0;
case INSN_CONFIG_PWM_SET_H_BRIDGE:
-   /* value in the first byte and the sign in the second for a
-  relay */
-   return usbdux_pwm_pattern(dev, s,
- /* the channel number */
- CR_CHAN(insn->chanspec),
- /* actual PWM data */
- data[1],
- /* just a sign */
- (data[2] != 0));
+   /*
+* data[1] = value
+* data[2] = sign (for a relay)
+*/
+   return usbdux_pwm_pattern(dev, s, chan,
+ data[1], (data[2] != 0));
case INSN_CONFIG_PWM_GET_H_BRIDGE:
/* values are not kept in this driver, nothing to return here */
return -EINVAL;
-- 
1.8.3.2

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


[PATCH 10/18] staging: comedi: usbduxsigma: return void from usbduxsigma_pwm_pattern()

2013-07-29 Thread H Hartley Sweeten
This function never fails and currently returns '1' so that the
usbduxsigma_pwm_write() function returns to proper value (insn->n).

It's also called by usbduxsigma_pwm_config() which also returns the
'1' value. The proper return code for this function should be '0' to
indicate success.

Change the return type of the function to void and just have the
callers return the proper values.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index ca6d952..660eec2 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1238,11 +1238,11 @@ static int usbduxsigma_pwm_start(struct comedi_device 
*dev,
return 0;
 }
 
-static int usbduxsigma_pwm_pattern(struct comedi_device *dev,
-  struct comedi_subdevice *s,
-  unsigned int chan,
-  unsigned int value,
-  unsigned int sign)
+static void usbduxsigma_pwm_pattern(struct comedi_device *dev,
+   struct comedi_subdevice *s,
+   unsigned int chan,
+   unsigned int value,
+   unsigned int sign)
 {
struct usbduxsigma_private *devpriv = dev->private;
char pwm_mask = (1 << chan);/* DIO bit for the PWM data */
@@ -1263,7 +1263,6 @@ static int usbduxsigma_pwm_pattern(struct comedi_device 
*dev,
c |= sgn_mask;
*buf++ = c;
}
-   return 1;
 }
 
 static int usbduxsigma_pwm_write(struct comedi_device *dev,
@@ -1284,7 +1283,9 @@ static int usbduxsigma_pwm_write(struct comedi_device 
*dev,
 * The sign is set via a special INSN only, this gives us 8 bits
 * for normal operation, sign is 0 by default.
 */
-   return usbduxsigma_pwm_pattern(dev, s, chan, data[0], 0);
+   usbduxsigma_pwm_pattern(dev, s, chan, data[0], 0);
+
+   return insn->n;
 }
 
 static int usbduxsigma_pwm_config(struct comedi_device *dev,
@@ -1319,8 +1320,8 @@ static int usbduxsigma_pwm_config(struct comedi_device 
*dev,
 * data[1] = value
 * data[2] = sign (for a relay)
 */
-   return usbduxsigma_pwm_pattern(dev, s, chan,
-  data[1], (data[2] != 0));
+   usbduxsigma_pwm_pattern(dev, s, chan, data[1], (data[2] != 0));
+   return 0;
case INSN_CONFIG_PWM_GET_H_BRIDGE:
/* values are not kept in this driver, nothing to return */
return -EINVAL;
-- 
1.8.3.2

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


[PATCH 12/18] staging: comedi: usbduxsigma: 'dac_commands' does not need to be kzalloc()'d

2013-07-29 Thread H Hartley Sweeten
The 'dac_commands' buffer is used to pass the ao channel list from
usbduxsigma_ao_cmd() to the urb callback, usbduxsigma_ao_urb_complete().
This buffer does not need to be allocated.

Change it into a simple array of the correct size. Rename the variable
to 'ao_chanlist' to clarify what it actually is.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 660eec2..df56395 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -161,6 +161,7 @@ struct usbduxsigma_private {
/* input buffer for single insn */
int8_t *insn_buf;
 
+   int8_t ao_chanlist[USBDUXSIGMA_NUM_AO_CHAN];
unsigned int ao_readback[USBDUXSIGMA_NUM_AO_CHAN];
 
unsigned high_speed:1;
@@ -181,8 +182,6 @@ struct usbduxsigma_private {
unsigned int ao_counter;
/* interval in frames/uframes */
unsigned int ai_interval;
-   /* D/A commands */
-   uint8_t *dac_commands;
/* commands */
uint8_t *dux_commands;
struct semaphore sem;
@@ -421,7 +420,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb)
len = s->async->cmd.chanlist_len;
*datap++ = len;
for (i = 0; i < len; i++) {
-   unsigned int chan = devpriv->dac_commands[i];
+   unsigned int chan = devpriv->ao_chanlist[i];
short val;
 
ret = comedi_buf_get(s->async, &val);
@@ -1011,7 +1010,7 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev,
/* set current channel of the running acquisition to zero */
s->async->cur_chan = 0;
for (i = 0; i < cmd->chanlist_len; ++i)
-   devpriv->dac_commands[i] = CR_CHAN(cmd->chanlist[i]);
+   devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
 
devpriv->ao_counter = devpriv->ao_timer;
 
@@ -1542,7 +1541,6 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
struct urb *urb;
int i;
 
-   devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL);
devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL);
devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL);
@@ -1550,8 +1548,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
   GFP_KERNEL);
devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb),
   GFP_KERNEL);
-   if (!devpriv->dac_commands || !devpriv->dux_commands ||
-   !devpriv->in_buf || !devpriv->insn_buf ||
+   if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf ||
!devpriv->ai_urbs || !devpriv->ao_urbs)
return -ENOMEM;
 
@@ -1660,7 +1657,6 @@ static void usbduxsigma_free_usb_buffers(struct 
comedi_device *dev)
kfree(devpriv->insn_buf);
kfree(devpriv->in_buf);
kfree(devpriv->dux_commands);
-   kfree(devpriv->dac_commands);
 }
 
 static int usbduxsigma_auto_attach(struct comedi_device *dev,
-- 
1.8.3.2

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


[PATCH 13/18] staging: comedi: usbduxsigma: init 'pwm_buf_sz' in usbduxsigma_auto_attach()

2013-07-29 Thread H Hartley Sweeten
Initialize this variable with then_ai_urbs and n_ao_urbs in the
attach. Then usbduxsigma_alloc_usb_buffers() can just check the
variable to determine if the urb needs to be allocated.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index df56395..68a3cd2 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1600,19 +1600,16 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
urb->interval = 1;  /* frames */
}
 
-   if (devpriv->high_speed) {
-   /* max bulk ep size in high speed */
-   devpriv->pwm_buf_sz = 512;
+   if (devpriv->pwm_buf_sz) {
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
return -ENOMEM;
devpriv->pwm_urb = urb;
-   urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, GFP_KERNEL);
+
+   urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz,
+  GFP_KERNEL);
if (!urb->transfer_buffer)
return -ENOMEM;
-   } else {
-   devpriv->pwm_urb = NULL;
-   devpriv->pwm_buf_sz = 0;
}
 
return 0;
@@ -1687,9 +1684,11 @@ static int usbduxsigma_auto_attach(struct comedi_device 
*dev,
if (devpriv->high_speed) {
devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH;
devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH;
+   devpriv->pwm_buf_sz = 512;
} else {
devpriv->n_ai_urbs = NUMOFINBUFFERSFULL;
devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL;
+   devpriv->pwm_buf_sz = 0;
}
 
ret = usbduxsigma_alloc_usb_buffers(dev);
-- 
1.8.3.2

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


[PATCH 11/18] staging: comedi: usbdux: tidy up usbdux_alloc_usb_buffers()

2013-07-29 Thread H Hartley Sweeten
Tidy up the error path by doing all the basic allocations then checking
for failures.

We have the comedi device now so fill in the urb->context.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 9dcb297..75b2de3 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1566,25 +1566,15 @@ static int usbdux_alloc_usb_buffers(struct 
comedi_device *dev)
struct urb *urb;
int i;
 
-   /* create space for the commands going to the usb device */
devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
-   if (!devpriv->dux_commands)
-   return -ENOMEM;
-
-   /* create space for the in buffer and set it to zero */
devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL);
-   if (!devpriv->in_buf)
-   return -ENOMEM;
-
-   /* create space of the instruction buffer */
devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL);
-   if (!devpriv->insn_buf)
-   return -ENOMEM;
-
-   /* in urbs */
devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb),
   GFP_KERNEL);
-   if (!devpriv->ai_urbs)
+   devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb),
+  GFP_KERNEL);
+   if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf ||
+   !devpriv->ai_urbs || !devpriv->ao_urbs)
return -ENOMEM;
 
for (i = 0; i < devpriv->n_ai_urbs; i++) {
@@ -1595,9 +1585,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
devpriv->ai_urbs[i] = urb;
 
urb->dev = usb;
-   /* will be filled later with a pointer to the comedi-device */
-   /* and ONLY then the urb should be submitted */
-   urb->context = NULL;
+   urb->context = dev;
urb->pipe = usb_rcvisocpipe(usb, 6);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL);
@@ -1611,12 +1599,6 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
urb->iso_frame_desc[0].length = SIZEINBUF;
}
 
-   /* out urbs */
-   devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb),
-  GFP_KERNEL);
-   if (!devpriv->ao_urbs)
-   return -ENOMEM;
-
for (i = 0; i < devpriv->n_ao_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
@@ -1625,9 +1607,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
devpriv->ao_urbs[i] = urb;
 
urb->dev = usb;
-   /* will be filled later with a pointer to the comedi-device */
-   /* and ONLY then the urb should be submitted */
-   urb->context = NULL;
+   urb->context = dev;
urb->pipe = usb_sndisocpipe(usb, 2);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL);
-- 
1.8.3.2

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


[PATCH 15/18] staging: comedi: usbduxsigma: always clear the usb intfdata in (*detach)

2013-07-29 Thread H Hartley Sweeten
Make sure the usb intfdata is always cleared when the device is
detached.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 6362094..60815a3 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1703,11 +1703,11 @@ static void usbduxsigma_detach(struct comedi_device 
*dev)
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usbduxsigma_private *devpriv = dev->private;
 
+   usb_set_intfdata(intf, NULL);
+
if (!devpriv)
return;
 
-   usb_set_intfdata(intf, NULL);
-
down(&devpriv->sem);
 
/* force unlink all urbs */
-- 
1.8.3.2

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


[PATCH 14/18] staging: comedi: usbduxsigma: move urb unlink into usbduxsigma_detach()

2013-07-29 Thread H Hartley Sweeten
For aesthetics, move the final force unlink of the urbs from
usbduxsigma_free_usb_buffers() to usbduxsigma_detach().

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 68a3cd2..6362094 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1621,11 +1621,6 @@ static void usbduxsigma_free_usb_buffers(struct 
comedi_device *dev)
struct urb *urb;
int i;
 
-   /* force unlink all urbs */
-   usbduxsigma_ai_stop(dev, 1);
-   usbduxsigma_ao_stop(dev, 1);
-   usbduxsigma_pwm_stop(dev, 1);
-
urb = devpriv->pwm_urb;
if (urb) {
kfree(urb->transfer_buffer);
@@ -1714,7 +1709,14 @@ static void usbduxsigma_detach(struct comedi_device *dev)
usb_set_intfdata(intf, NULL);
 
down(&devpriv->sem);
+
+   /* force unlink all urbs */
+   usbduxsigma_ai_stop(dev, 1);
+   usbduxsigma_ao_stop(dev, 1);
+   usbduxsigma_pwm_stop(dev, 1);
+
usbduxsigma_free_usb_buffers(dev);
+
up(&devpriv->sem);
 }
 
-- 
1.8.3.2

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


[PATCH 17/18] staging: comedi: usbdux: tidy up usbdux_free_usb_buffers()

2013-07-29 Thread H Hartley Sweeten
For aesthetics, pass the comedi_device pointer to this function
instead of the private data pointer.

The usb_kill_urb() calls are not needed. All the urbs were unlinked
before this function was called.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 991c425..689b452 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1642,15 +1642,15 @@ static int usbdux_alloc_usb_buffers(struct 
comedi_device *dev)
return 0;
 }
 
-static void usbdux_free_usb_buffers(struct usbdux_private *devpriv)
+static void usbdux_free_usb_buffers(struct comedi_device *dev)
 {
+   struct usbdux_private *devpriv = dev->private;
struct urb *urb;
int i;
 
urb = devpriv->pwm_urb;
if (urb) {
kfree(urb->transfer_buffer);
-   usb_kill_urb(urb);
usb_free_urb(urb);
}
if (devpriv->ao_urbs) {
@@ -1658,7 +1658,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private 
*devpriv)
urb = devpriv->ao_urbs[i];
if (urb) {
kfree(urb->transfer_buffer);
-   usb_kill_urb(urb);
usb_free_urb(urb);
}
}
@@ -1669,7 +1668,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private 
*devpriv)
urb = devpriv->ai_urbs[i];
if (urb) {
kfree(urb->transfer_buffer);
-   usb_kill_urb(urb);
usb_free_urb(urb);
}
}
@@ -1811,7 +1809,7 @@ static void usbdux_detach(struct comedi_device *dev)
usbdux_ao_stop(dev, 1);
usbdux_ai_stop(dev, 1);
 
-   usbdux_free_usb_buffers(devpriv);
+   usbdux_free_usb_buffers(dev);
 
up(&devpriv->sem);
 }
-- 
1.8.3.2

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


[PATCH 18/18] staging: comedi: usbduxsigma: absorb usbduxsigma_attach_common() into caller

2013-07-29 Thread H Hartley Sweeten
This function is only called by usbduxsigma_auto_attach(). Absorb it
and refactor the code a bit to match the usbdux driver.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 60815a3..fca89c3 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1379,90 +1379,6 @@ static int usbduxsigma_getstatusinfo(struct 
comedi_device *dev, int chan)
return (int)val;
 }
 
-static int usbduxsigma_attach_common(struct comedi_device *dev)
-{
-   struct usbduxsigma_private *devpriv = dev->private;
-   struct comedi_subdevice *s;
-   int n_subdevs;
-   int offset;
-   int ret;
-
-   down(&devpriv->sem);
-
-   if (devpriv->high_speed)
-   n_subdevs = 4;  /* with pwm */
-   else
-   n_subdevs = 3;  /* without pwm */
-   ret = comedi_alloc_subdevices(dev, n_subdevs);
-   if (ret) {
-   up(&devpriv->sem);
-   return ret;
-   }
-
-   /* Analog Input subdevice */
-   s = &dev->subdevices[0];
-   dev->read_subdev = s;
-   s->type = COMEDI_SUBD_AI;
-   s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ | SDF_LSAMPL;
-   s->n_chan   = NUMCHANNELS;
-   s->len_chanlist = NUMCHANNELS;
-   s->maxdata  = 0x00ff;
-   s->range_table  = &usbduxsigma_ai_range;
-   s->insn_read= usbduxsigma_ai_insn_read;
-   s->do_cmdtest   = usbduxsigma_ai_cmdtest;
-   s->do_cmd   = usbduxsigma_ai_cmd;
-   s->cancel   = usbduxsigma_ai_cancel;
-
-   /* Analog Output subdevice */
-   s = &dev->subdevices[1];
-   dev->write_subdev = s;
-   s->type = COMEDI_SUBD_AO;
-   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
-   s->n_chan   = USBDUXSIGMA_NUM_AO_CHAN;
-   s->len_chanlist = s->n_chan;
-   s->maxdata  = 0x00ff;
-   s->range_table  = &range_unipolar2_5;
-   s->insn_write   = usbduxsigma_ao_insn_write;
-   s->insn_read= usbduxsigma_ao_insn_read;
-   s->do_cmdtest   = usbduxsigma_ao_cmdtest;
-   s->do_cmd   = usbduxsigma_ao_cmd;
-   s->cancel   = usbduxsigma_ao_cancel;
-
-   /* Digital I/O subdevice */
-   s = &dev->subdevices[2];
-   s->type = COMEDI_SUBD_DIO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-   s->n_chan   = 24;
-   s->maxdata  = 1;
-   s->range_table  = &range_digital;
-   s->insn_bits= usbduxsigma_dio_insn_bits;
-   s->insn_config  = usbduxsigma_dio_insn_config;
-
-   if (devpriv->high_speed) {
-   /* Timer / pwm subdevice */
-   s = &dev->subdevices[3];
-   s->type = COMEDI_SUBD_PWM;
-   s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
-   s->n_chan   = 8;
-   s->maxdata  = devpriv->pwm_buf_sz;
-   s->insn_write   = usbduxsigma_pwm_write;
-   s->insn_config  = usbduxsigma_pwm_config;
-
-   usbduxsigma_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
-   }
-
-   up(&devpriv->sem);
-
-   offset = usbduxsigma_getstatusinfo(dev, 0);
-   if (offset < 0)
-   dev_err(dev->class_dev,
-   "Communication to USBDUXSIGMA failed! Check firmware 
and cabling\n");
-
-   dev_info(dev->class_dev, "attached, ADC_zero = %x\n", offset);
-
-   return 0;
-}
-
 static int usbduxsigma_firmware_upload(struct comedi_device *dev,
   const u8 *data, size_t size,
   unsigned long context)
@@ -1657,6 +1573,8 @@ static int usbduxsigma_auto_attach(struct comedi_device 
*dev,
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usbduxsigma_private *devpriv;
+   struct comedi_subdevice *s;
+   int offset;
int ret;
 
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
@@ -1664,17 +1582,9 @@ static int usbduxsigma_auto_attach(struct comedi_device 
*dev,
return -ENOMEM;
 
sema_init(&devpriv->sem, 1);
-   usb_set_intfdata(intf, devpriv);
 
-   ret = usb_set_interface(usb,
-   intf->altsetting->desc.bInterfaceNumber, 3);
-   if (ret < 0) {
-   dev_err(dev->class_dev,
-   "could not set alternate setting 3 in high speed\n");
-   return -ENODEV;
-   }
+   usb_set_intfdata(intf, devpriv);
 
-   /* test if it is high speed (USB 2.0) */
devpriv->high_speed = (usb->speed == USB_SPEED_HIGH);
if (devpriv->high_speed) {
   

[PATCH 16/18] staging: comedi: usbdux: tidy up usbdux_detach()

2013-07-29 Thread H Hartley Sweeten
Make sure the usb intfdata is always cleared when the device is
detached.

Refactor the code to remove an indent level.

Always unlink the urbs when the device is detached.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 75b2de3..991c425 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1799,20 +1799,21 @@ static void usbdux_detach(struct comedi_device *dev)
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usbdux_private *devpriv = dev->private;
 
-   if (devpriv) {
-   down(&devpriv->sem);
+   usb_set_intfdata(intf, NULL);
 
-   usb_set_intfdata(intf, NULL);
+   if (!devpriv)
+   return;
+
+   down(&devpriv->sem);
 
-   /* stop and unlink any submitted urbs */
-   usbdux_pwm_stop(dev, devpriv->pwm_cmd_running);
-   usbdux_ao_stop(dev, devpriv->ao_cmd_running);
-   usbdux_ai_stop(dev, devpriv->ai_cmd_running);
+   /* force unlink all urbs */
+   usbdux_pwm_stop(dev, 1);
+   usbdux_ao_stop(dev, 1);
+   usbdux_ai_stop(dev, 1);
 
-   usbdux_free_usb_buffers(devpriv);
+   usbdux_free_usb_buffers(devpriv);
 
-   up(&devpriv->sem);
-   }
+   up(&devpriv->sem);
 }
 
 static struct comedi_driver usbdux_driver = {
-- 
1.8.3.2

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


RE: [PATCH] staging: comedi: allow ISA and PC/104 drivers on non-ISA systems

2013-07-29 Thread H Hartley Sweeten
On Friday, July 26, 2013 3:09 AM, Ian Abbott wrote:
> On 2013-07-26 00:32, H Hartley Sweeten wrote:
>> On Thursday, July 25, 2013 3:43 AM, Ian Abbott wrote:
>>> On 2013-07-24 19:24, H Hartley Sweeten wrote:



menuconfig COMEDI_ISA_DRIVERS
bool "Comedi ISA and PC/104 drivers"
 -  depends on ISA
 +  depends on ISA || COMEDI_ENABLE_ISA



> You're probably right, but in that case there should be an option to 
> enable ISA support higher up than comedi.
>
> Besides, the boolean option COMEDI_ENABLE_ISA seems unnecessary as you 
> could achieve the same effect by making the COMEDI_ISA_DRIVERS menu 
> option not depend on ISA (except you'd only have to enable one 
> configuration option then instead of two).

Would you prefer to just drop the 'depends on ISA' for the
COMEDI_ISA_DRIVERS option?

Regards,
Hartley

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