diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/android/binder.c linux-2.6.31-rc4-git2-staging/drivers/staging/android/binder.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/android/binder.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/android/binder.c 2009-07-30 09:25:20.000000000 -0700 @@ -31,18 +31,21 @@ #include #include #include + #include "binder.h" static DEFINE_MUTEX(binder_lock); +static DEFINE_MUTEX(binder_deferred_lock); + static HLIST_HEAD(binder_procs); +static HLIST_HEAD(binder_deferred_list); +static HLIST_HEAD(binder_dead_nodes); + +static struct proc_dir_entry *binder_proc_dir_entry_root; +static struct proc_dir_entry *binder_proc_dir_entry_proc; static struct binder_node *binder_context_mgr_node; static uid_t binder_context_mgr_uid = -1; static int binder_last_id; -static struct proc_dir_entry *binder_proc_dir_entry_root; -static struct proc_dir_entry *binder_proc_dir_entry_proc; -static struct hlist_head binder_dead_nodes; -static HLIST_HEAD(binder_deferred_list); -static DEFINE_MUTEX(binder_deferred_lock); static int binder_read_proc_proc(char *page, char **start, off_t off, int count, int *eof, void *data); @@ -100,6 +103,12 @@ module_param_call(stop_on_user_error, binder_set_stop_on_user_error, param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO); +#define binder_debug(mask, x...) \ + do { \ + if (binder_debug_mask & mask) \ + printk(KERN_INFO x); \ + } while (0) + #define binder_user_error(x...) \ do { \ if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \ @@ -108,7 +117,7 @@ binder_stop_on_user_error = 2; \ } while (0) -enum { +enum binder_stat_types { BINDER_STAT_PROC, BINDER_STAT_THREAD, BINDER_STAT_NODE, @@ -128,6 +137,16 @@ static struct binder_stats binder_stats; +static inline void binder_stats_deleted(enum binder_stat_types type) +{ + binder_stats.obj_deleted[type]++; +} + +static inline void binder_stats_created(enum binder_stat_types type) +{ + binder_stats.obj_created[type]++; +} + struct binder_transaction_log_entry { int debug_id; int call_type; @@ -237,7 +256,7 @@ uint8_t data[0]; }; -enum { +enum binder_deferred_state { BINDER_DEFERRED_PUT_FILES = 0x01, BINDER_DEFERRED_FLUSH = 0x02, BINDER_DEFERRED_RELEASE = 0x04, @@ -320,7 +339,8 @@ uid_t sender_euid; }; -static void binder_defer_work(struct binder_proc *proc, int defer); +static void +binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer); /* * copied from get_unused_fd_flags @@ -468,9 +488,9 @@ return; } min_nice = 20 - current->signal->rlim[RLIMIT_NICE].rlim_cur; - if (binder_debug_mask & BINDER_DEBUG_PRIORITY_CAP) - printk(KERN_INFO "binder: %d: nice value %ld not allowed use " - "%ld instead\n", current->pid, nice, min_nice); + binder_debug(BINDER_DEBUG_PRIORITY_CAP, + "binder: %d: nice value %ld not allowed use " + "%ld instead\n", current->pid, nice, min_nice); set_user_nice(current, min_nice); if (min_nice < 20) return; @@ -500,9 +520,9 @@ new_buffer_size = binder_buffer_size(proc, new_buffer); - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: add free buffer, size %zd, " - "at %p\n", proc->pid, new_buffer_size, new_buffer); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: add free buffer, size %zd, " + "at %p\n", proc->pid, new_buffer_size, new_buffer); while (*p) { parent = *p; @@ -579,9 +599,9 @@ struct page **page; struct mm_struct *mm; - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: %s pages %p-%p\n", - proc->pid, allocate ? "allocate" : "free", start, end); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: %s pages %p-%p\n", proc->pid, + allocate ? "allocate" : "free", start, end); if (end <= start) return 0; @@ -696,10 +716,9 @@ if (is_async && proc->free_async_space < size + sizeof(struct binder_buffer)) { - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_ERR - "binder: %d: binder_alloc_buf size %zd failed, " - "no async space left\n", proc->pid, size); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: binder_alloc_buf size %zd" + "failed, no async space left\n", proc->pid, size); return NULL; } @@ -727,9 +746,10 @@ buffer = rb_entry(best_fit, struct binder_buffer, rb_node); buffer_size = binder_buffer_size(proc, buffer); } - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd got buff" - "er %p size %zd\n", proc->pid, size, buffer, buffer_size); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: binder_alloc_buf size %zd got buff" + "er %p size %zd\n", proc->pid, size, buffer, buffer_size); has_page_addr = (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK); @@ -756,18 +776,18 @@ new_buffer->free = 1; binder_insert_free_buffer(proc, new_buffer); } - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd got " - "%p\n", proc->pid, size, buffer); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: binder_alloc_buf size %zd got " + "%p\n", proc->pid, size, buffer); buffer->data_size = data_size; buffer->offsets_size = offsets_size; buffer->async_transaction = is_async; if (is_async) { proc->free_async_space -= size + sizeof(struct binder_buffer); - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC_ASYNC) - printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd " - "async free %zd\n", proc->pid, size, - proc->free_async_space); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, + "binder: %d: binder_alloc_buf size %zd " + "async free %zd\n", proc->pid, size, + proc->free_async_space); } return buffer; @@ -797,9 +817,9 @@ free_page_start = 0; if (buffer_end_page(prev) == buffer_end_page(buffer)) free_page_end = 0; - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: merge free, buffer %p " - "share page with %p\n", proc->pid, buffer, prev); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: merge free, buffer %p " + "share page with %p\n", proc->pid, buffer, prev); } if (!list_is_last(&buffer->entry, &proc->buffers)) { @@ -810,19 +830,19 @@ if (buffer_start_page(next) == buffer_start_page(buffer)) free_page_start = 0; - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: merge free, " - "buffer %p share page with %p\n", - proc->pid, buffer, prev); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: merge free, buffer" + " %p share page with %p\n", proc->pid, + buffer, prev); } } list_del(&buffer->entry); if (free_page_start || free_page_end) { - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: merge free, buffer %p do " - "not share page%s%s with with %p or %p\n", - proc->pid, buffer, free_page_start ? "" : " end", - free_page_end ? "" : " start", prev, next); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: merge free, buffer %p do " + "not share page%s%s with with %p or %p\n", + proc->pid, buffer, free_page_start ? "" : " end", + free_page_end ? "" : " start", prev, next); binder_update_page_range(proc, 0, free_page_start ? buffer_start_page(buffer) : buffer_end_page(buffer), (free_page_end ? buffer_end_page(buffer) : @@ -839,9 +859,10 @@ size = ALIGN(buffer->data_size, sizeof(void *)) + ALIGN(buffer->offsets_size, sizeof(void *)); - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO "binder: %d: binder_free_buf %p size %zd buffer" - "_size %zd\n", proc->pid, buffer, size, buffer_size); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder: %d: binder_free_buf %p size %zd buffer" + "_size %zd\n", proc->pid, buffer, size, buffer_size); BUG_ON(buffer->free); BUG_ON(size > buffer_size); @@ -851,10 +872,11 @@ if (buffer->async_transaction) { proc->free_async_space += size + sizeof(struct binder_buffer); - if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC_ASYNC) - printk(KERN_INFO "binder: %d: binder_free_buf size %zd " - "async free %zd\n", proc->pid, size, - proc->free_async_space); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, + "binder: %d: binder_free_buf size %zd " + "async free %zd\n", proc->pid, size, + proc->free_async_space); } binder_update_page_range(proc, 0, @@ -925,7 +947,7 @@ node = kzalloc(sizeof(*node), GFP_KERNEL); if (node == NULL) return NULL; - binder_stats.obj_created[BINDER_STAT_NODE]++; + binder_stats_created(BINDER_STAT_NODE); rb_link_node(&node->rb_node, parent, p); rb_insert_color(&node->rb_node, &proc->nodes); node->debug_id = ++binder_last_id; @@ -935,10 +957,10 @@ node->work.type = BINDER_WORK_NODE; INIT_LIST_HEAD(&node->work.entry); INIT_LIST_HEAD(&node->async_todo); - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d:%d node %d u%p c%p created\n", - proc->pid, current->pid, node->debug_id, - node->ptr, node->cookie); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d:%d node %d u%p c%p created\n", + proc->pid, current->pid, node->debug_id, + node->ptr, node->cookie); return node; } @@ -1003,15 +1025,17 @@ list_del_init(&node->work.entry); if (node->proc) { rb_erase(&node->rb_node, &node->proc->nodes); - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: refless node %d deleted\n", node->debug_id); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: refless node %d deleted\n", + node->debug_id); } else { hlist_del(&node->dead_node); - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: dead node %d deleted\n", node->debug_id); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: dead node %d deleted\n", + node->debug_id); } kfree(node); - binder_stats.obj_deleted[BINDER_STAT_NODE]++; + binder_stats_deleted(BINDER_STAT_NODE); } } @@ -1060,7 +1084,7 @@ new_ref = kzalloc(sizeof(*ref), GFP_KERNEL); if (new_ref == NULL) return NULL; - binder_stats.obj_created[BINDER_STAT_REF]++; + binder_stats_created(BINDER_STAT_REF); new_ref->debug_id = ++binder_last_id; new_ref->proc = proc; new_ref->node = node; @@ -1091,25 +1115,27 @@ rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); if (node) { hlist_add_head(&new_ref->node_entry, &node->refs); - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d new ref %d desc %d for " - "node %d\n", proc->pid, new_ref->debug_id, - new_ref->desc, node->debug_id); + + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d new ref %d desc %d for " + "node %d\n", proc->pid, new_ref->debug_id, + new_ref->desc, node->debug_id); } else { - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d new ref %d desc %d for " - "dead node\n", proc->pid, new_ref->debug_id, - new_ref->desc); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d new ref %d desc %d for " + "dead node\n", proc->pid, new_ref->debug_id, + new_ref->desc); } return new_ref; } static void binder_delete_ref(struct binder_ref *ref) { - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d delete ref %d desc %d for " - "node %d\n", ref->proc->pid, ref->debug_id, - ref->desc, ref->node->debug_id); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d delete ref %d desc %d for " + "node %d\n", ref->proc->pid, ref->debug_id, + ref->desc, ref->node->debug_id); + rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); if (ref->strong) @@ -1117,16 +1143,16 @@ hlist_del(&ref->node_entry); binder_dec_node(ref->node, 0, 1); if (ref->death) { - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder: %d delete ref %d desc %d " - "has death notification\n", ref->proc->pid, - ref->debug_id, ref->desc); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder: %d delete ref %d desc %d " + "has death notification\n", ref->proc->pid, + ref->debug_id, ref->desc); list_del(&ref->death->work.entry); kfree(ref->death); - binder_stats.obj_deleted[BINDER_STAT_DEATH]++; + binder_stats_deleted(BINDER_STAT_DEATH); } kfree(ref); - binder_stats.obj_deleted[BINDER_STAT_REF]++; + binder_stats_deleted(BINDER_STAT_REF); } static int binder_inc_ref(struct binder_ref *ref, int strong, @@ -1198,7 +1224,7 @@ if (t->buffer) t->buffer->transaction = NULL; kfree(t); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION); } static void binder_send_failed_reply(struct binder_transaction *t, @@ -1216,9 +1242,11 @@ target_thread->return_error = BR_OK; } if (target_thread->return_error == BR_OK) { - if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION) - printk(KERN_INFO "binder: send failed reply for transaction %d to %d:%d\n", - t->debug_id, target_thread->proc->pid, target_thread->pid); + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "binder: send failed reply for " + "transaction %d to %d:%d\n", + t->debug_id, target_thread->proc->pid, + target_thread->pid); binder_pop_transaction(target_thread, t); target_thread->return_error = error_code; @@ -1234,29 +1262,100 @@ } else { struct binder_transaction *next = t->from_parent; - if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION) - printk(KERN_INFO "binder: send failed reply " - "for transaction %d, target dead\n", - t->debug_id); + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "binder: send failed reply " + "for transaction %d, target dead\n", + t->debug_id); binder_pop_transaction(target_thread, t); if (next == NULL) { - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder: reply failed," - " no target thread at root\n"); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder: reply failed," + " no target thread at root\n"); return; } t = next; - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder: reply failed, no targ" - "et thread -- retry %d\n", t->debug_id); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder: reply failed, no target " + "thread -- retry %d\n", t->debug_id); } } } static void binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer *buffer, - size_t *failed_at); + size_t *failed_at) +{ + size_t *offp, *off_end; + int debug_id = buffer->debug_id; + + binder_debug(BINDER_DEBUG_TRANSACTION, + "binder: %d buffer release %d, size %zd-%zd, failed at %p\n", + proc->pid, buffer->debug_id, + buffer->data_size, buffer->offsets_size, failed_at); + + if (buffer->target_node) + binder_dec_node(buffer->target_node, 1, 0); + + offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *))); + if (failed_at) + off_end = failed_at; + else + off_end = (void *)offp + buffer->offsets_size; + for (; offp < off_end; offp++) { + struct flat_binder_object *fp; + if (*offp > buffer->data_size - sizeof(*fp) || + buffer->data_size < sizeof(*fp) || + !IS_ALIGNED(*offp, sizeof(void *))) { + printk(KERN_ERR "binder: transaction release %d bad" + "offset %zd, size %zd\n", debug_id, + *offp, buffer->data_size); + continue; + } + fp = (struct flat_binder_object *)(buffer->data + *offp); + switch (fp->type) { + case BINDER_TYPE_BINDER: + case BINDER_TYPE_WEAK_BINDER: { + struct binder_node *node = binder_get_node(proc, fp->binder); + if (node == NULL) { + printk(KERN_ERR "binder: transaction release %d" + " bad node %p\n", debug_id, fp->binder); + break; + } + binder_debug(BINDER_DEBUG_TRANSACTION, + " node %d u%p\n", + node->debug_id, node->ptr); + binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0); + } break; + case BINDER_TYPE_HANDLE: + case BINDER_TYPE_WEAK_HANDLE: { + struct binder_ref *ref = binder_get_ref(proc, fp->handle); + if (ref == NULL) { + printk(KERN_ERR "binder: transaction release %d" + " bad handle %ld\n", debug_id, + fp->handle); + break; + } + binder_debug(BINDER_DEBUG_TRANSACTION, + " ref %d desc %d (node %d)\n", + ref->debug_id, ref->desc, ref->node->debug_id); + binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE); + } break; + + case BINDER_TYPE_FD: + binder_debug(BINDER_DEBUG_TRANSACTION, + " fd %ld\n", fp->handle); + if (failed_at) + task_close_fd(proc, fp->handle); + break; + + default: + printk(KERN_ERR "binder: transaction release %d bad " + "object type %lx\n", debug_id, fp->type); + break; + } + } +} static void binder_transaction(struct binder_proc *proc, struct binder_thread *thread, @@ -1387,34 +1486,34 @@ return_error = BR_FAILED_REPLY; goto err_alloc_t_failed; } - binder_stats.obj_created[BINDER_STAT_TRANSACTION]++; + binder_stats_created(BINDER_STAT_TRANSACTION); tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL); if (tcomplete == NULL) { return_error = BR_FAILED_REPLY; goto err_alloc_tcomplete_failed; } - binder_stats.obj_created[BINDER_STAT_TRANSACTION_COMPLETE]++; + binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE); t->debug_id = ++binder_last_id; e->debug_id = t->debug_id; - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) { - if (reply) - printk(KERN_INFO "binder: %d:%d BC_REPLY %d -> %d:%d, " - "data %p-%p size %zd-%zd\n", - proc->pid, thread->pid, t->debug_id, - target_proc->pid, target_thread->pid, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); - else - printk(KERN_INFO "binder: %d:%d BC_TRANSACTION %d -> " - "%d - node %d, data %p-%p size %zd-%zd\n", - proc->pid, thread->pid, t->debug_id, - target_proc->pid, target_node->debug_id, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); - } + if (reply) + binder_debug(BINDER_DEBUG_TRANSACTION, + "binder: %d:%d BC_REPLY %d -> %d:%d, " + "data %p-%p size %zd-%zd\n", + proc->pid, thread->pid, t->debug_id, + target_proc->pid, target_thread->pid, + tr->data.ptr.buffer, tr->data.ptr.offsets, + tr->data_size, tr->offsets_size); + else + binder_debug(BINDER_DEBUG_TRANSACTION, + "binder: %d:%d BC_TRANSACTION %d -> " + "%d - node %d, data %p-%p size %zd-%zd\n", + proc->pid, thread->pid, t->debug_id, + target_proc->pid, target_node->debug_id, + tr->data.ptr.buffer, tr->data.ptr.offsets, + tr->data_size, tr->offsets_size); if (!reply && !(tr->flags & TF_ONE_WAY)) t->from = thread; @@ -1505,10 +1604,13 @@ else fp->type = BINDER_TYPE_WEAK_HANDLE; fp->handle = ref->desc; - binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, &thread->todo); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " node %d u%p -> ref %d desc %d\n", - node->debug_id, node->ptr, ref->debug_id, ref->desc); + binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, + &thread->todo); + + binder_debug(BINDER_DEBUG_TRANSACTION, + " node %d u%p -> ref %d desc %d\n", + node->debug_id, node->ptr, ref->debug_id, + ref->desc); } break; case BINDER_TYPE_HANDLE: case BINDER_TYPE_WEAK_HANDLE: { @@ -1529,9 +1631,10 @@ fp->binder = ref->node->ptr; fp->cookie = ref->node->cookie; binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " ref %d desc %d -> node %d u%p\n", - ref->debug_id, ref->desc, ref->node->debug_id, ref->node->ptr); + binder_debug(BINDER_DEBUG_TRANSACTION, + " ref %d desc %d -> node %d u%p\n", + ref->debug_id, ref->desc, ref->node->debug_id, + ref->node->ptr); } else { struct binder_ref *new_ref; new_ref = binder_get_ref_for_node(target_proc, ref->node); @@ -1541,9 +1644,10 @@ } fp->handle = new_ref->desc; binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " ref %d desc %d -> ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, new_ref->debug_id, new_ref->desc, ref->node->debug_id); + binder_debug(BINDER_DEBUG_TRANSACTION, + " ref %d desc %d -> ref %d desc %d (node %d)\n", + ref->debug_id, ref->desc, new_ref->debug_id, + new_ref->desc, ref->node->debug_id); } } break; @@ -1579,8 +1683,8 @@ goto err_get_unused_fd_failed; } task_fd_install(target_proc, target_fd, file); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " fd %ld -> %d\n", fp->handle, target_fd); + binder_debug(BINDER_DEBUG_TRANSACTION, + " fd %ld -> %d\n", fp->handle, target_fd); /* TODO: fput? */ fp->handle = target_fd; } break; @@ -1632,21 +1736,20 @@ binder_free_buf(target_proc, t->buffer); err_binder_alloc_buf_failed: kfree(tcomplete); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); err_alloc_tcomplete_failed: kfree(t); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION); err_alloc_t_failed: err_bad_call_stack: err_empty_call_stack: err_dead_binder: err_invalid_target_handle: err_no_context_mgr_node: - if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION) - printk(KERN_INFO "binder: %d:%d transaction failed %d, size" - "%zd-%zd\n", - proc->pid, thread->pid, return_error, - tr->data_size, tr->offsets_size); + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "binder: %d:%d transaction failed %d, size %zd-%zd\n", + proc->pid, thread->pid, return_error, + tr->data_size, tr->offsets_size); { struct binder_transaction_log_entry *fe; @@ -1662,76 +1765,6 @@ thread->return_error = return_error; } -static void binder_transaction_buffer_release(struct binder_proc *proc, - struct binder_buffer *buffer, - size_t *failed_at) -{ - size_t *offp, *off_end; - int debug_id = buffer->debug_id; - - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO "binder: %d buffer release %d, size %zd-%zd, failed at %p\n", - proc->pid, buffer->debug_id, - buffer->data_size, buffer->offsets_size, failed_at); - - if (buffer->target_node) - binder_dec_node(buffer->target_node, 1, 0); - - offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *))); - if (failed_at) - off_end = failed_at; - else - off_end = (void *)offp + buffer->offsets_size; - for (; offp < off_end; offp++) { - struct flat_binder_object *fp; - if (*offp > buffer->data_size - sizeof(*fp) || - buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(void *))) { - printk(KERN_ERR "binder: transaction release %d bad" - "offset %zd, size %zd\n", debug_id, *offp, buffer->data_size); - continue; - } - fp = (struct flat_binder_object *)(buffer->data + *offp); - switch (fp->type) { - case BINDER_TYPE_BINDER: - case BINDER_TYPE_WEAK_BINDER: { - struct binder_node *node = binder_get_node(proc, fp->binder); - if (node == NULL) { - printk(KERN_ERR "binder: transaction release %d bad node %p\n", debug_id, fp->binder); - break; - } - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " node %d u%p\n", - node->debug_id, node->ptr); - binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0); - } break; - case BINDER_TYPE_HANDLE: - case BINDER_TYPE_WEAK_HANDLE: { - struct binder_ref *ref = binder_get_ref(proc, fp->handle); - if (ref == NULL) { - printk(KERN_ERR "binder: transaction release %d bad handle %ld\n", debug_id, fp->handle); - break; - } - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, ref->node->debug_id); - binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE); - } break; - - case BINDER_TYPE_FD: - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO " fd %ld\n", fp->handle); - if (failed_at) - task_close_fd(proc, fp->handle); - break; - - default: - printk(KERN_ERR "binder: transaction release %d bad object type %lx\n", debug_id, fp->type); - break; - } - } -} - int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread, void __user *buffer, int size, signed long *consumed) { @@ -1799,9 +1832,10 @@ binder_dec_ref(ref, 0); break; } - if (binder_debug_mask & BINDER_DEBUG_USER_REFS) - printk(KERN_INFO "binder: %d:%d %s ref %d desc %d s %d w %d for node %d\n", - proc->pid, thread->pid, debug_string, ref->debug_id, ref->desc, ref->strong, ref->weak, ref->node->debug_id); + binder_debug(BINDER_DEBUG_USER_REFS, + "binder: %d:%d %s ref %d desc %d s %d w %d for node %d\n", + proc->pid, thread->pid, debug_string, ref->debug_id, + ref->desc, ref->strong, ref->weak, ref->node->debug_id); break; } case BC_INCREFS_DONE: @@ -1859,9 +1893,11 @@ node->pending_weak_ref = 0; } binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0); - if (binder_debug_mask & BINDER_DEBUG_USER_REFS) - printk(KERN_INFO "binder: %d:%d %s node %d ls %d lw %d\n", - proc->pid, thread->pid, cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", node->debug_id, node->local_strong_refs, node->local_weak_refs); + binder_debug(BINDER_DEBUG_USER_REFS, + "binder: %d:%d %s node %d ls %d lw %d\n", + proc->pid, thread->pid, + cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", + node->debug_id, node->local_strong_refs, node->local_weak_refs); break; } case BC_ATTEMPT_ACQUIRE: @@ -1893,10 +1929,10 @@ proc->pid, thread->pid, data_ptr); break; } - if (binder_debug_mask & BINDER_DEBUG_FREE_BUFFER) - printk(KERN_INFO "binder: %d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n", - proc->pid, thread->pid, data_ptr, buffer->debug_id, - buffer->transaction ? "active" : "finished"); + binder_debug(BINDER_DEBUG_FREE_BUFFER, + "binder: %d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n", + proc->pid, thread->pid, data_ptr, buffer->debug_id, + buffer->transaction ? "active" : "finished"); if (buffer->transaction) { buffer->transaction->buffer = NULL; @@ -1926,9 +1962,9 @@ } case BC_REGISTER_LOOPER: - if (binder_debug_mask & BINDER_DEBUG_THREADS) - printk(KERN_INFO "binder: %d:%d BC_REGISTER_LOOPER\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_THREADS, + "binder: %d:%d BC_REGISTER_LOOPER\n", + proc->pid, thread->pid); if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { thread->looper |= BINDER_LOOPER_STATE_INVALID; binder_user_error("binder: %d:%d ERROR:" @@ -1948,9 +1984,9 @@ thread->looper |= BINDER_LOOPER_STATE_REGISTERED; break; case BC_ENTER_LOOPER: - if (binder_debug_mask & BINDER_DEBUG_THREADS) - printk(KERN_INFO "binder: %d:%d BC_ENTER_LOOPER\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_THREADS, + "binder: %d:%d BC_ENTER_LOOPER\n", + proc->pid, thread->pid); if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { thread->looper |= BINDER_LOOPER_STATE_INVALID; binder_user_error("binder: %d:%d ERROR:" @@ -1961,9 +1997,9 @@ thread->looper |= BINDER_LOOPER_STATE_ENTERED; break; case BC_EXIT_LOOPER: - if (binder_debug_mask & BINDER_DEBUG_THREADS) - printk(KERN_INFO "binder: %d:%d BC_EXIT_LOOPER\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_THREADS, + "binder: %d:%d BC_EXIT_LOOPER\n", + proc->pid, thread->pid); thread->looper |= BINDER_LOOPER_STATE_EXITED; break; @@ -1992,14 +2028,14 @@ break; } - if (binder_debug_mask & BINDER_DEBUG_DEATH_NOTIFICATION) - printk(KERN_INFO "binder: %d:%d %s %p ref %d desc %d s %d w %d for node %d\n", - proc->pid, thread->pid, - cmd == BC_REQUEST_DEATH_NOTIFICATION ? - "BC_REQUEST_DEATH_NOTIFICATION" : - "BC_CLEAR_DEATH_NOTIFICATION", - cookie, ref->debug_id, ref->desc, - ref->strong, ref->weak, ref->node->debug_id); + binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, + "binder: %d:%d %s %p ref %d desc %d s %d w %d for node %d\n", + proc->pid, thread->pid, + cmd == BC_REQUEST_DEATH_NOTIFICATION ? + "BC_REQUEST_DEATH_NOTIFICATION" : + "BC_CLEAR_DEATH_NOTIFICATION", + cookie, ref->debug_id, ref->desc, + ref->strong, ref->weak, ref->node->debug_id); if (cmd == BC_REQUEST_DEATH_NOTIFICATION) { if (ref->death) { @@ -2013,13 +2049,13 @@ death = kzalloc(sizeof(*death), GFP_KERNEL); if (death == NULL) { thread->return_error = BR_ERROR; - if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION) - printk(KERN_INFO "binder: %d:%d " - "BC_REQUEST_DEATH_NOTIFICATION failed\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "binder: %d:%d " + "BC_REQUEST_DEATH_NOTIFICATION failed\n", + proc->pid, thread->pid); break; } - binder_stats.obj_created[BINDER_STAT_DEATH]++; + binder_stats_created(BINDER_STAT_DEATH); INIT_LIST_HEAD(&death->work.entry); death->cookie = cookie; ref->death = death; @@ -2082,9 +2118,9 @@ break; } } - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder: %d:%d BC_DEAD_BINDER_DONE %p found %p\n", - proc->pid, thread->pid, cookie, death); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder: %d:%d BC_DEAD_BINDER_DONE %p found %p\n", + proc->pid, thread->pid, cookie, death); if (death == NULL) { binder_user_error("binder: %d:%d BC_DEAD" "_BINDER_DONE %p not found\n", @@ -2240,13 +2276,13 @@ ptr += sizeof(uint32_t); binder_stat_br(proc, thread, cmd); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION_COMPLETE) - printk(KERN_INFO "binder: %d:%d BR_TRANSACTION_COMPLETE\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE, + "binder: %d:%d BR_TRANSACTION_COMPLETE\n", + proc->pid, thread->pid); list_del(&w->entry); kfree(w); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); } break; case BINDER_WORK_NODE: { struct binder_node *node = container_of(w, struct binder_node, work); @@ -2287,22 +2323,24 @@ ptr += sizeof(void *); binder_stat_br(proc, thread, cmd); - if (binder_debug_mask & BINDER_DEBUG_USER_REFS) - printk(KERN_INFO "binder: %d:%d %s %d u%p c%p\n", - proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie); + binder_debug(BINDER_DEBUG_USER_REFS, + "binder: %d:%d %s %d u%p c%p\n", + proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie); } else { list_del_init(&w->entry); if (!weak && !strong) { - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d:%d node %d u%p c%p deleted\n", - proc->pid, thread->pid, node->debug_id, node->ptr, node->cookie); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d:%d node %d u%p c%p deleted\n", + proc->pid, thread->pid, node->debug_id, + node->ptr, node->cookie); rb_erase(&node->rb_node, &proc->nodes); kfree(node); - binder_stats.obj_deleted[BINDER_STAT_NODE]++; + binder_stats_deleted(BINDER_STAT_NODE); } else { - if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) - printk(KERN_INFO "binder: %d:%d node %d u%p c%p state unchanged\n", - proc->pid, thread->pid, node->debug_id, node->ptr, node->cookie); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "binder: %d:%d node %d u%p c%p state unchanged\n", + proc->pid, thread->pid, node->debug_id, node->ptr, + node->cookie); } } } break; @@ -2323,18 +2361,18 @@ if (put_user(death->cookie, (void * __user *)ptr)) return -EFAULT; ptr += sizeof(void *); - if (binder_debug_mask & BINDER_DEBUG_DEATH_NOTIFICATION) - printk(KERN_INFO "binder: %d:%d %s %p\n", - proc->pid, thread->pid, - cmd == BR_DEAD_BINDER ? - "BR_DEAD_BINDER" : - "BR_CLEAR_DEATH_NOTIFICATION_DONE", - death->cookie); + binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, + "binder: %d:%d %s %p\n", + proc->pid, thread->pid, + cmd == BR_DEAD_BINDER ? + "BR_DEAD_BINDER" : + "BR_CLEAR_DEATH_NOTIFICATION_DONE", + death->cookie); if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) { list_del(&w->entry); kfree(death); - binder_stats.obj_deleted[BINDER_STAT_DEATH]++; + binder_stats_deleted(BINDER_STAT_DEATH); } else list_move(&w->entry, &proc->delivered_death); if (cmd == BR_DEAD_BINDER) @@ -2391,16 +2429,16 @@ ptr += sizeof(tr); binder_stat_br(proc, thread, cmd); - if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) - printk(KERN_INFO "binder: %d:%d %s %d %d:%d, cmd %d" - "size %zd-%zd ptr %p-%p\n", - proc->pid, thread->pid, - (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : - "BR_REPLY", - t->debug_id, t->from ? t->from->proc->pid : 0, - t->from ? t->from->pid : 0, cmd, - t->buffer->data_size, t->buffer->offsets_size, - tr.data.ptr.buffer, tr.data.ptr.offsets); + binder_debug(BINDER_DEBUG_TRANSACTION, + "binder: %d:%d %s %d %d:%d, cmd %d" + "size %zd-%zd ptr %p-%p\n", + proc->pid, thread->pid, + (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : + "BR_REPLY", + t->debug_id, t->from ? t->from->proc->pid : 0, + t->from ? t->from->pid : 0, cmd, + t->buffer->data_size, t->buffer->offsets_size, + tr.data.ptr.buffer, tr.data.ptr.offsets); list_del(&t->work.entry); t->buffer->allow_user_free = 1; @@ -2411,7 +2449,7 @@ } else { t->buffer->transaction = NULL; kfree(t); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION); } break; } @@ -2425,9 +2463,9 @@ BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */ /*spawn a new thread if we leave this out */) { proc->requested_threads++; - if (binder_debug_mask & BINDER_DEBUG_THREADS) - printk(KERN_INFO "binder: %d:%d BR_SPAWN_LOOPER\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_THREADS, + "binder: %d:%d BR_SPAWN_LOOPER\n", + proc->pid, thread->pid); if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer)) return -EFAULT; } @@ -2450,7 +2488,7 @@ } break; case BINDER_WORK_TRANSACTION_COMPLETE: { kfree(w); - binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++; + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); } break; default: break; @@ -2480,7 +2518,7 @@ thread = kzalloc(sizeof(*thread), GFP_KERNEL); if (thread == NULL) return NULL; - binder_stats.obj_created[BINDER_STAT_THREAD]++; + binder_stats_created(BINDER_STAT_THREAD); thread->proc = proc; thread->pid = current->pid; init_waitqueue_head(&thread->wait); @@ -2507,11 +2545,12 @@ send_reply = t; while (t) { active_transactions++; - if (binder_debug_mask & BINDER_DEBUG_DEAD_TRANSACTION) - printk(KERN_INFO "binder: release %d:%d transaction %d " - "%s, still active\n", proc->pid, thread->pid, - t->debug_id, - (t->to_thread == thread) ? "in" : "out"); + binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, + "binder: release %d:%d transaction %d " + "%s, still active\n", proc->pid, thread->pid, + t->debug_id, + (t->to_thread == thread) ? "in" : "out"); + if (t->to_thread == thread) { t->to_proc = NULL; t->to_thread = NULL; @@ -2530,7 +2569,7 @@ binder_send_failed_reply(send_reply, BR_DEAD_REPLY); binder_release_work(&thread->todo); kfree(thread); - binder_stats.obj_deleted[BINDER_STAT_THREAD]++; + binder_stats_deleted(BINDER_STAT_THREAD); return active_transactions; } @@ -2596,9 +2635,11 @@ ret = -EFAULT; goto err; } - if (binder_debug_mask & BINDER_DEBUG_READ_WRITE) - printk(KERN_INFO "binder: %d:%d write %ld at %08lx, read %ld at %08lx\n", - proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, bwr.read_size, bwr.read_buffer); + binder_debug(BINDER_DEBUG_READ_WRITE, + "binder: %d:%d write %ld at %08lx, read %ld at %08lx\n", + proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, + bwr.read_size, bwr.read_buffer); + if (bwr.write_size > 0) { ret = binder_thread_write(proc, thread, (void __user *)bwr.write_buffer, bwr.write_size, &bwr.write_consumed); if (ret < 0) { @@ -2618,9 +2659,10 @@ goto err; } } - if (binder_debug_mask & BINDER_DEBUG_READ_WRITE) - printk(KERN_INFO "binder: %d:%d wrote %ld of %ld, read return %ld of %ld\n", - proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, bwr.read_consumed, bwr.read_size); + binder_debug(BINDER_DEBUG_READ_WRITE, + "binder: %d:%d wrote %ld of %ld, read return %ld of %ld\n", + proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, + bwr.read_consumed, bwr.read_size); if (copy_to_user(ubuf, &bwr, sizeof(bwr))) { ret = -EFAULT; goto err; @@ -2661,9 +2703,8 @@ binder_context_mgr_node->has_weak_ref = 1; break; case BINDER_THREAD_EXIT: - if (binder_debug_mask & BINDER_DEBUG_THREADS) - printk(KERN_INFO "binder: %d:%d exit\n", - proc->pid, thread->pid); + binder_debug(BINDER_DEBUG_THREADS, "binder: %d:%d exit\n", + proc->pid, thread->pid); binder_free_thread(proc, thread); thread = NULL; break; @@ -2695,24 +2736,22 @@ static void binder_vma_open(struct vm_area_struct *vma) { struct binder_proc *proc = vma->vm_private_data; - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO - "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); dump_stack(); } static void binder_vma_close(struct vm_area_struct *vma) { struct binder_proc *proc = vma->vm_private_data; - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO - "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); proc->vma = NULL; binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES); } @@ -2733,12 +2772,11 @@ if ((vma->vm_end - vma->vm_start) > SZ_4M) vma->vm_end = vma->vm_start + SZ_4M; - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO - "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { ret = -EPERM; @@ -2818,9 +2856,8 @@ { struct binder_proc *proc; - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO "binder_open: %d:%d\n", - current->group_leader->pid, current->pid); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n", + current->group_leader->pid, current->pid); proc = kzalloc(sizeof(*proc), GFP_KERNEL); if (proc == NULL) @@ -2831,7 +2868,7 @@ init_waitqueue_head(&proc->wait); proc->default_priority = task_nice(current); mutex_lock(&binder_lock); - binder_stats.obj_created[BINDER_STAT_PROC]++; + binder_stats_created(BINDER_STAT_PROC); hlist_add_head(&proc->proc_node, &binder_procs); proc->pid = current->group_leader->pid; INIT_LIST_HEAD(&proc->delivered_death); @@ -2873,8 +2910,9 @@ } wake_up_interruptible_all(&proc->wait); - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO "binder_flush: %d woke %d threads\n", proc->pid, wake_count); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder_flush: %d woke %d threads\n", proc->pid, + wake_count); } static int binder_release(struct inode *nodp, struct file *filp) @@ -2903,8 +2941,9 @@ hlist_del(&proc->proc_node); if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) { - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder_release: %d context_mgr_node gone\n", proc->pid); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder_release: %d context_mgr_node gone\n", + proc->pid); binder_context_mgr_node = NULL; } @@ -2925,7 +2964,7 @@ list_del_init(&node->work.entry); if (hlist_empty(&node->refs)) { kfree(node); - binder_stats.obj_deleted[BINDER_STAT_NODE]++; + binder_stats_deleted(BINDER_STAT_NODE); } else { struct binder_ref *ref; int death = 0; @@ -2947,10 +2986,10 @@ BUG(); } } - if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) - printk(KERN_INFO "binder: node %d now dead, " - "refs %d, death %d\n", node->debug_id, - incoming_refs, death); + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "binder: node %d now dead, " + "refs %d, death %d\n", node->debug_id, + incoming_refs, death); } } outgoing_refs = 0; @@ -2979,20 +3018,18 @@ buffers++; } - binder_stats.obj_deleted[BINDER_STAT_PROC]++; + binder_stats_deleted(BINDER_STAT_PROC); page_count = 0; if (proc->pages) { int i; for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) { if (proc->pages[i]) { - if (binder_debug_mask & - BINDER_DEBUG_BUFFER_ALLOC) - printk(KERN_INFO - "binder_release: %d: " - "page %d at %p not freed\n", - proc->pid, i, - proc->buffer + i * PAGE_SIZE); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "binder_release: %d: " + "page %d at %p not freed\n", + proc->pid, i, + proc->buffer + i * PAGE_SIZE); __free_page(proc->pages[i]); page_count++; } @@ -3003,13 +3040,12 @@ put_task_struct(proc->tsk); - if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) - printk(KERN_INFO - "binder_release: %d threads %d, nodes %d (ref %d), " - "refs %d, active transactions %d, buffers %d, " - "pages %d\n", - proc->pid, threads, nodes, incoming_refs, outgoing_refs, - active_transactions, buffers, page_count); + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder_release: %d threads %d, nodes %d (ref %d), " + "refs %d, active transactions %d, buffers %d, " + "pages %d\n", + proc->pid, threads, nodes, incoming_refs, outgoing_refs, + active_transactions, buffers, page_count); kfree(proc); } @@ -3055,7 +3091,8 @@ } static DECLARE_WORK(binder_deferred_work, binder_deferred_func); -static void binder_defer_work(struct binder_proc *proc, int defer) +static void +binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) { mutex_lock(&binder_deferred_lock); proc->deferred_work |= defer; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/android/lowmemorykiller.c linux-2.6.31-rc4-git2-staging/drivers/staging/android/lowmemorykiller.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/android/lowmemorykiller.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/android/lowmemorykiller.c 2009-07-30 09:25:20.000000000 -0700 @@ -1,5 +1,21 @@ /* drivers/misc/lowmemorykiller.c * + * The lowmemorykiller driver lets user-space specify a set of memory thresholds + * where processes with a range of oom_adj values will get killed. Specify the + * minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the + * number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both + * files take a comma separated list of numbers in ascending order. + * + * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and + * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes + * with a oom_adj value of 8 or higher when the free memory drops below 4096 pages + * and kill processes with a oom_adj value of 0 or higher when the free memory + * drops below 1024 pages. + * + * The driver considers memory used for caches to be free, but if a large + * percentage of the cached memory is locked this can be very inaccurate + * and processes may not get killed until the normal oom killer is triggered. + * * Copyright (C) 2007-2008 Google, Inc. * * This software is licensed under the terms of the GNU General Public @@ -19,12 +35,6 @@ #include #include -static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask); - -static struct shrinker lowmem_shrinker = { - .shrink = lowmem_shrink, - .seeks = DEFAULT_SEEKS * 16 -}; static uint32_t lowmem_debug_level = 2; static int lowmem_adj[6] = { 0, @@ -96,19 +106,21 @@ read_lock(&tasklist_lock); for_each_process(p) { + struct mm_struct *mm; int oom_adj; task_lock(p); - if (!p->mm) { + mm = p->mm; + if (!mm) { task_unlock(p); continue; } - oom_adj = p->oomkilladj; + oom_adj = mm->oom_adj; if (oom_adj < min_adj) { task_unlock(p); continue; } - tasksize = get_mm_rss(p->mm); + tasksize = get_mm_rss(mm); task_unlock(p); if (tasksize <= 0) continue; @@ -138,6 +150,11 @@ return rem; } +static struct shrinker lowmem_shrinker = { + .shrink = lowmem_shrink, + .seeks = DEFAULT_SEEKS * 16 +}; + static int __init lowmem_init(void) { register_shrinker(&lowmem_shrinker); diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/android/lowmemorykiller.txt linux-2.6.31-rc4-git2-staging/drivers/staging/android/lowmemorykiller.txt --- linux-2.6.31-rc4-git2-usb/drivers/staging/android/lowmemorykiller.txt 2009-03-24 09:44:03.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/android/lowmemorykiller.txt 1969-12-31 16:00:00.000000000 -0800 @@ -1,16 +0,0 @@ -The lowmemorykiller driver lets user-space specify a set of memory thresholds -where processes with a range of oom_adj values will get killed. Specify the -minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the -number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both -files take a comma separated list of numbers in ascending order. - -For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and -"1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes -with a oom_adj value of 8 or higher when the free memory drops below 4096 pages -and kill processes with a oom_adj value of 0 or higher when the free memory -drops below 1024 pages. - -The driver considers memory used for caches to be free, but if a large -percentage of the cached memory is locked this can be very inaccurate -and processes may not get killed until the normal oom killer is triggered. - diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/at76_usb/at76_usb.c linux-2.6.31-rc4-git2-staging/drivers/staging/at76_usb/at76_usb.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/at76_usb/at76_usb.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/at76_usb/at76_usb.c 2009-07-30 09:25:35.000000000 -0700 @@ -558,20 +558,6 @@ return ret; } -#define MAC2STR_BUFFERS 4 - -static inline char *mac2str(u8 *mac) -{ - static atomic_t a = ATOMIC_INIT(0); - static char bufs[MAC2STR_BUFFERS][6 * 3]; - char *str; - - str = bufs[atomic_inc_return(&a) & (MAC2STR_BUFFERS - 1)]; - sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - return str; -} - /* LED trigger */ static int tx_activity; static void at76_ledtrig_tx_timerfunc(unsigned long data); @@ -1071,13 +1057,12 @@ goto exit; } - at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x", - priv->netdev->name, - mac2str(m->mac_addr), m->res[0], m->res[1]); + at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %pM res 0x%x 0x%x", + priv->netdev->name, m->mac_addr, m->res[0], m->res[1]); for (i = 0; i < ARRAY_SIZE(m->group_addr); i++) - at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, " + at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %pM, " "status %d", priv->netdev->name, i, - mac2str(m->group_addr[i]), m->group_addr_status[i]); + m->group_addr[i], m->group_addr_status[i]); exit: kfree(m); } @@ -1140,7 +1125,7 @@ at76_dbg(DBG_MIB, "%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration " "%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d " "CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d " - "current_bssid %s current_essid %s current_bss_type %d " + "current_bssid %pM scurrent_essid %s current_bss_type %d " "pm_mode %d ibss_change %d res %d " "multi_domain_capability_implemented %d " "international_roaming %d country_string %.3s", @@ -1149,7 +1134,7 @@ le16_to_cpu(m->medium_occupancy_limit), le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window), m->CFP_mode, m->privacy_option_implemented, m->DTIM_period, - m->CFP_period, mac2str(m->current_bssid), + m->CFP_period, m->current_bssid, hex2str(m->current_essid, IW_ESSID_MAX_SIZE), m->current_bss_type, m->power_mgmt_mode, m->ibss_change, m->res, m->multi_domain_capability_implemented, @@ -1178,7 +1163,7 @@ "cwmin %d cwmax %d short_retry_time %d long_retry_time %d " "scan_type %d scan_channel %d probe_delay %u " "min_channel_time %d max_channel_time %d listen_int %d " - "desired_ssid %s desired_bssid %s desired_bsstype %d", + "desired_ssid %s desired_bssid %pM desired_bsstype %d", priv->netdev->name, le32_to_cpu(m->max_tx_msdu_lifetime), le32_to_cpu(m->max_rx_lifetime), le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold), @@ -1189,7 +1174,7 @@ le16_to_cpu(m->max_channel_time), le16_to_cpu(m->listen_interval), hex2str(m->desired_ssid, IW_ESSID_MAX_SIZE), - mac2str(m->desired_bssid), m->desired_bsstype); + m->desired_bssid, m->desired_bsstype); exit: kfree(m); } @@ -1297,8 +1282,8 @@ goto error; } memcpy(priv->bssid, mac_mgmt->current_bssid, ETH_ALEN); - printk(KERN_INFO "%s: using BSSID %s\n", priv->netdev->name, - mac2str(priv->bssid)); + printk(KERN_INFO "%s: using BSSID %pM\n", priv->netdev->name, + priv->bssid); error: kfree(mac_mgmt); exit: @@ -1468,8 +1453,8 @@ join.timeout = cpu_to_le16(2000); at76_dbg(DBG_PROGRESS, - "%s join addr %s ssid %s type %d ch %d timeout %d", - priv->netdev->name, mac2str(join.bssid), join.essid, + "%s join addr %pM ssid %s stype %d ch %d timeout %d", + priv->netdev->name, join.bssid, join.essid, join.bss_type, join.channel, le16_to_cpu(join.timeout)); return at76_set_card_command(priv->udev, CMD_JOIN, &join, sizeof(struct at76_req_join)); @@ -1670,8 +1655,8 @@ /* init. at76_priv tx header */ tx_buffer->wlength = cpu_to_le16(buf_len - AT76_TX_HDRLEN); - at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %s alg %d seq_nr %d", - priv->netdev->name, mac2str(mgmt->addr3), + at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %pM alg %d seq_nr %d", + priv->netdev->name, mgmt->addr3, le16_to_cpu(req->algorithm), le16_to_cpu(req->transaction)); if (seq_nr == 3) at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...", @@ -1746,8 +1731,8 @@ next_ie(&ie); /* points to IE of rates now */ at76_dbg(DBG_TX_MGMT, - "%s: AssocReq bssid %s capa 0x%04x ssid %.*s rates %s", - priv->netdev->name, mac2str(mgmt->addr3), + "%s: AssocReq bssid %pM capa 0x%04x ssid %.*s rates %s", + priv->netdev->name, mgmt->addr3, le16_to_cpu(req->capability), essid_len, essid, hex2str(ie->data, ie->len)); @@ -1773,8 +1758,8 @@ if (ptr != priv->curr_bss && time_after(jiffies, ptr->last_rx + BSS_LIST_TIMEOUT)) { at76_dbg(DBG_BSS_TABLE_RM, - "%s: bss_list: removing old BSS %s ch %d", - priv->netdev->name, mac2str(ptr->bssid), + "%s: bss_list: removing old BSS %pM ch %d", + priv->netdev->name, ptr->bssid, ptr->channel); list_del(&ptr->list); kfree(ptr); @@ -1806,9 +1791,9 @@ list_for_each(lptr, &priv->bss_list) { ptr = list_entry(lptr, struct bss_info, list); - at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %s channel %d ssid %.*s " + at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %pM channel %d ssid %.*s " "(%s) capa 0x%04x rates %s rssi %d link %d noise %d", - ptr, mac2str(ptr->bssid), ptr->channel, ptr->ssid_len, + ptr, ptr->bssid, ptr->channel, ptr->ssid_len, ptr->ssid, hex2str(ptr->ssid, ptr->ssid_len), ptr->capa, hex2str(ptr->rates, ptr->rates_len), ptr->rssi, ptr->link_qual, ptr->noise_level); @@ -1855,8 +1840,8 @@ netif_wake_queue(priv->netdev); at76_set_mac_state(priv, MAC_CONNECTED); at76_iwevent_bss_connect(priv->netdev, priv->curr_bss->bssid); - at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %s", - priv->netdev->name, mac2str(priv->curr_bss->bssid)); + at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %pM", + priv->netdev->name, priv->curr_bss->bssid); exit: mutex_unlock(&priv->mtx); @@ -2218,8 +2203,8 @@ { struct at76_priv *priv = netdev_priv(netdev); - at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %s", netdev->name, - mac2str(ap_addr->sa_data)); + at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %pM", netdev->name, + ap_addr->sa_data); /* if the incoming address == ff:ff:ff:ff:ff:ff, the user has chosen any or auto AP preference */ @@ -2244,8 +2229,8 @@ ap_addr->sa_family = ARPHRD_ETHER; memcpy(ap_addr->sa_data, priv->bssid, ETH_ALEN); - at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %s", netdev->name, - mac2str(ap_addr->sa_data)); + at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %pM", netdev->name, + ap_addr->sa_data); return 0; } @@ -3323,8 +3308,8 @@ set the mac address in the device ! */ if (compare_ether_addr(netdev->dev_addr, priv->mac_addr)) { if (at76_add_mac_address(priv, netdev->dev_addr) >= 0) - at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %s", - netdev->name, mac2str(netdev->dev_addr)); + at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %pM", + netdev->name, netdev->dev_addr); } priv->scan_state = SCAN_IDLE; @@ -3581,11 +3566,11 @@ return 1; at76_dbg(DBG_BSS_MATCH, - "%s: requested bssid - %s does not match", - priv->netdev->name, mac2str(priv->wanted_bssid)); + "%s: requested bssid - %pM does not match", + priv->netdev->name, priv->wanted_bssid); at76_dbg(DBG_BSS_MATCH, - " AP bssid - %s of bss table entry %p", - mac2str(ptr->bssid), ptr); + " AP bssid - %pM of bss table entry %p", + ptr->bssid, ptr); return 0; } @@ -3668,9 +3653,9 @@ printk(KERN_ERR "%s: join_bss completed with %d\n", priv->netdev->name, ret); else - printk(KERN_INFO "%s: join_bss ssid %s timed out\n", + printk(KERN_INFO "%s: join_bss ssid %pM timed out\n", priv->netdev->name, - mac2str(priv->curr_bss->bssid)); + priv->curr_bss->bssid); /* retry next BSS immediately */ schedule_work(&priv->work_join); @@ -3788,8 +3773,8 @@ goto exit; /* We haven't received any beacons from out AP for BEACON_TIMEOUT */ - printk(KERN_INFO "%s: lost beacon bssid %s\n", - priv->netdev->name, mac2str(priv->curr_bss->bssid)); + printk(KERN_INFO "%s: lost beacon bssid %pM\n", + priv->netdev->name, priv->curr_bss->bssid); netif_carrier_off(priv->netdev); netif_stop_queue(priv->netdev); @@ -3879,7 +3864,7 @@ at76_dbg(DBG_PROGRESS, "ibss_change = 0x%2x", mac_mgmt.ibss_change); memcpy(priv->bssid, mac_mgmt.current_bssid, ETH_ALEN); - at76_dbg(DBG_PROGRESS, "using BSSID %s", mac2str(priv->bssid)); + at76_dbg(DBG_PROGRESS, "using BSSID %pM", priv->bssid); at76_iwevent_bss_connect(priv->netdev, priv->bssid); @@ -4116,9 +4101,9 @@ u16 assoc_id = le16_to_cpu(resp->aid); u16 status = le16_to_cpu(resp->status); - at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa 0x%04x status " + at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %pM capa 0x%04x status " "0x%04x assoc_id 0x%04x rates %s", priv->netdev->name, - mac2str(resp->header.addr3), le16_to_cpu(resp->capability), + resp->header.addr3, le16_to_cpu(resp->capability), status, assoc_id, hex2str(resp->info_element->data, resp->info_element->len)); @@ -4155,9 +4140,9 @@ struct ieee80211_hdr_3addr *mgmt = &resp->header; at76_dbg(DBG_RX_MGMT, - "%s: rx DisAssoc bssid %s reason 0x%04x destination %s", - priv->netdev->name, mac2str(mgmt->addr3), - le16_to_cpu(resp->reason), mac2str(mgmt->addr1)); + "%s: rx DisAssoc bssid %pM reason 0x%04x destination %pM", + priv->netdev->name, mgmt->addr3, + le16_to_cpu(resp->reason), mgmt->addr1); /* We are not connected, ignore */ if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT @@ -4203,9 +4188,9 @@ int status = le16_to_cpu(resp->status); at76_dbg(DBG_RX_MGMT, - "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d " - "destination %s", priv->netdev->name, mac2str(mgmt->addr3), - alg, seq_nr, status, mac2str(mgmt->addr1)); + "%s: rx AuthFrame bssid %pM alg %d seq_nr %d status %d " + "destination %pM", priv->netdev->name, mgmt->addr3, + alg, seq_nr, status, mgmt->addr1); if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2) at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...", @@ -4262,9 +4247,9 @@ struct ieee80211_hdr_3addr *mgmt = &resp->header; at76_dbg(DBG_RX_MGMT | DBG_PROGRESS, - "%s: rx DeAuth bssid %s reason 0x%04x destination %s", - priv->netdev->name, mac2str(mgmt->addr3), - le16_to_cpu(resp->reason), mac2str(mgmt->addr1)); + "%s: rx DeAuth bssid %pM reason 0x%04x destination %pM", + priv->netdev->name, mgmt->addr3, + le16_to_cpu(resp->reason), mgmt->addr1); if (priv->mac_state != MAC_AUTH && priv->mac_state != MAC_ASSOC && priv->mac_state != MAC_CONNECTED) { @@ -4366,8 +4351,8 @@ match->link_qual = buf->link_quality; match->noise_level = buf->noise_level; memcpy(match->bssid, mgmt->addr3, ETH_ALEN); - at76_dbg(DBG_RX_BEACON, "%s: bssid %s", priv->netdev->name, - mac2str(match->bssid)); + at76_dbg(DBG_RX_BEACON, "%s: bssid %pM", priv->netdev->name, + match->bssid); ie = bdata->info_element; @@ -4677,9 +4662,9 @@ unsigned long oldest = ~0UL; at76_dbg(DBG_RX_FRAGS, - "%s: rx data frame_ctl %04x addr2 %s seq/frag %d/%d " + "%s: rx data frame_ctl %04x addr2 %pM seq/frag %d/%d " "length %d data %d: %s ...", priv->netdev->name, frame_ctl, - mac2str(i802_11_hdr->addr2), seqnr, fragnr, length, data_len, + i802_11_hdr->addr2, seqnr, fragnr, length, data_len, hex2str(data, 32)); at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p " @@ -4838,8 +4823,8 @@ priv->rx_skb = skb; at76_dbg(DBG_RX_FRAGS, - "%s: free old contents: sender %s seq/frag %d/%d", - priv->netdev->name, mac2str(optr->sender), + "%s: free old contents: sender %pM seq/frag %d/%d", + priv->netdev->name, optr->sender, optr->seqnr, optr->fragnr); } else { @@ -5319,10 +5304,12 @@ /* Add pointers to enable iwspy support. */ priv->wireless_data.spy_data = &priv->spy_data; +#ifdef CONFIG_WIRELESS_EXT netdev->wireless_data = &priv->wireless_data; + netdev->wireless_handlers = &at76_handler_def; +#endif netdev->watchdog_timeo = 2 * HZ; - netdev->wireless_handlers = &at76_handler_def; dev_alloc_name(netdev, "wlan%d"); ret = register_netdev(priv->netdev); @@ -5333,8 +5320,8 @@ } priv->netdev_registered = 1; - printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n", - netdev->name, dev_name(&interface->dev), mac2str(priv->mac_addr), + printk(KERN_INFO "%s: USB %s, MAC %pM, firmware %d.%d.%d-%d\n", + netdev->name, dev_name(&interface->dev), priv->mac_addr, priv->fw_version.major, priv->fw_version.minor, priv->fw_version.patch, priv->fw_version.build); printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", netdev->name, diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/b3dfg/b3dfg.c linux-2.6.31-rc4-git2-staging/drivers/staging/b3dfg/b3dfg.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/b3dfg/b3dfg.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/b3dfg/b3dfg.c 2009-07-30 09:25:37.000000000 -0700 @@ -632,18 +632,15 @@ fgdev->cur_dma_frame_addr = 0; buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list); - if (buf) { - dev_dbg(dev, "handle frame completion\n"); - if (fgdev->cur_dma_frame_idx == B3DFG_FRAMES_PER_BUFFER - 1) { - - /* last frame of that triplet completed */ - dev_dbg(dev, "triplet completed\n"); - buf->state = B3DFG_BUFFER_POPULATED; - list_del_init(&buf->list); - wake_up_interruptible(&fgdev->buffer_waitqueue); - } - } else { - dev_err(dev, "got frame but no buffer!\n"); + + dev_dbg(dev, "handle frame completion\n"); + if (fgdev->cur_dma_frame_idx == B3DFG_FRAMES_PER_BUFFER - 1) { + + /* last frame of that triplet completed */ + dev_dbg(dev, "triplet completed\n"); + buf->state = B3DFG_BUFFER_POPULATED; + list_del_init(&buf->list); + wake_up_interruptible(&fgdev->buffer_waitqueue); } } @@ -663,19 +660,15 @@ dev_dbg(dev, "program DMA transfer for next frame: %d\n", idx); buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list); - if (buf) { - if (idx == fgdev->cur_dma_frame_idx + 2) { - if (setup_frame_transfer(fgdev, buf, idx - 1)) - dev_err(dev, "unable to map DMA buffer\n"); - need_ack = 0; - } else { - dev_err(dev, "frame mismatch, got %d, expected %d\n", - idx, fgdev->cur_dma_frame_idx + 2); - - /* FIXME: handle dropped triplets here */ - } + if (idx == fgdev->cur_dma_frame_idx + 2) { + if (setup_frame_transfer(fgdev, buf, idx - 1)) + dev_err(dev, "unable to map DMA buffer\n"); + need_ack = 0; } else { - dev_err(dev, "cannot setup DMA, no buffer\n"); + dev_err(dev, "frame mismatch, got %d, expected %d\n", + idx, fgdev->cur_dma_frame_idx + 2); + + /* FIXME: handle dropped triplets here */ } return need_ack; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_compat32.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_compat32.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_compat32.c 2009-06-15 12:15:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_compat32.c 2009-07-30 09:25:29.000000000 -0700 @@ -51,7 +51,7 @@ struct comedi32_chaninfo_struct { unsigned int subdev; compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */ - compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */ + compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */ compat_uptr_t rangelist; /* 32-bit 'unsigned int *' */ unsigned int unused[4]; }; @@ -74,16 +74,16 @@ unsigned int scan_end_arg; unsigned int stop_src; unsigned int stop_arg; - compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */ + compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */ unsigned int chanlist_len; - compat_uptr_t data; /* 32-bit 'short *' */ + compat_uptr_t data; /* 32-bit 'short *' */ unsigned int data_len; }; struct comedi32_insn_struct { unsigned int insn; unsigned int n; - compat_uptr_t data; /* 32-bit 'unsigned int *' */ + compat_uptr_t data; /* 32-bit 'unsigned int *' */ unsigned int subdev; unsigned int chanspec; unsigned int unused[3]; @@ -91,19 +91,19 @@ struct comedi32_insnlist_struct { unsigned int n_insns; - compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */ + compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */ }; /* Handle translated ioctl. */ static int translated_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + unsigned long arg) { if (!file->f_op) return -ENOTTY; #ifdef HAVE_UNLOCKED_IOCTL if (file->f_op->unlocked_ioctl) { - int rc = (int)(*file->f_op->unlocked_ioctl)(file, cmd, arg); + int rc = (int)(*file->f_op->unlocked_ioctl) (file, cmd, arg); if (rc == -ENOIOCTLCMD) rc = -ENOTTY; return rc; @@ -112,8 +112,8 @@ if (file->f_op->ioctl) { int rc; lock_kernel(); - rc = (*file->f_op->ioctl)(file->f_dentry->d_inode, - file, cmd, arg); + rc = (*file->f_op->ioctl) (file->f_dentry->d_inode, + file, cmd, arg); unlock_kernel(); return rc; } @@ -136,8 +136,7 @@ /* Copy chaninfo structure. Ignore unused members. */ if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32)) - || !access_ok(VERIFY_WRITE, chaninfo, - sizeof(*chaninfo))) { + || !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo))) { return -EFAULT; } err = 0; @@ -171,8 +170,7 @@ /* Copy rangeinfo structure. */ if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32)) - || !access_ok(VERIFY_WRITE, rangeinfo, - sizeof(*rangeinfo))) { + || !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo))) { return -EFAULT; } err = 0; @@ -184,12 +182,12 @@ return -EFAULT; return translated_ioctl(file, COMEDI_RANGEINFO, - (unsigned long)rangeinfo); + (unsigned long)rangeinfo); } /* Copy 32-bit cmd structure to native cmd structure. */ -static int get_compat_cmd(struct comedi_cmd __user *cmd, - struct comedi32_cmd_struct __user *cmd32) +static int get_compat_cmd(struct comedi_cmd __user * cmd, + struct comedi32_cmd_struct __user * cmd32) { int err; union { @@ -199,7 +197,7 @@ /* Copy cmd structure. */ if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32)) - || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) { + || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) { return -EFAULT; } err = 0; @@ -239,7 +237,8 @@ } /* Copy native cmd structure to 32-bit cmd structure. */ -static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comedi_cmd __user *cmd) +static int put_compat_cmd(struct comedi32_cmd_struct __user * cmd32, + struct comedi_cmd __user * cmd) { int err; unsigned int temp; @@ -249,7 +248,7 @@ /* (Could use ptr_to_compat() to set them, but that wasn't implemented * until kernel version 2.6.11.) */ if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd)) - || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) { + || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) { return -EFAULT; } err = 0; @@ -329,8 +328,8 @@ } /* Copy 32-bit insn structure to native insn structure. */ -static int get_compat_insn(struct comedi_insn __user *insn, - struct comedi32_insn_struct __user *insn32) +static int get_compat_insn(struct comedi_insn __user * insn, + struct comedi32_insn_struct __user * insn32) { int err; union { @@ -341,7 +340,7 @@ /* Copy insn structure. Ignore the unused members. */ err = 0; if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32)) - || !access_ok(VERIFY_WRITE, insn, sizeof(*insn))) + || !access_ok(VERIFY_WRITE, insn, sizeof(*insn))) return -EFAULT; err |= __get_user(temp.uint, &insn32->insn); @@ -385,7 +384,7 @@ /* Allocate user memory to copy insnlist and insns into. */ s = compat_alloc_user_space(offsetof(struct combined_insnlist, - insn[n_insns])); + insn[n_insns])); /* Set native insnlist structure. */ if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) { @@ -404,7 +403,7 @@ } return translated_ioctl(file, COMEDI_INSNLIST, - (unsigned long)&s->insnlist); + (unsigned long)&s->insnlist); } /* Handle 32-bit COMEDI_INSN ioctl. */ @@ -427,7 +426,7 @@ /* Process untranslated ioctl. */ /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */ static inline int raw_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + unsigned long arg) { int rc; @@ -477,8 +476,7 @@ /* compat_ioctl file operation. */ /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */ -long comedi_compat_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) +long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { return raw_ioctl(file, cmd, arg); } @@ -497,7 +495,7 @@ /* Handler for all 32-bit ioctl codes registered by this driver. */ static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, - struct file *file) + struct file *file) { int rc; @@ -515,27 +513,27 @@ struct ioctl32_map { unsigned int cmd; - int (*handler)(unsigned int, unsigned int, unsigned long, + int (*handler) (unsigned int, unsigned int, unsigned long, struct file *); int registered; }; static struct ioctl32_map comedi_ioctl32_map[] = { - { COMEDI_DEVCONFIG, mapped_ioctl, 0 }, - { COMEDI_DEVINFO, mapped_ioctl, 0 }, - { COMEDI_SUBDINFO, mapped_ioctl, 0 }, - { COMEDI_BUFCONFIG, mapped_ioctl, 0 }, - { COMEDI_BUFINFO, mapped_ioctl, 0 }, - { COMEDI_LOCK, mapped_ioctl, 0 }, - { COMEDI_UNLOCK, mapped_ioctl, 0 }, - { COMEDI_CANCEL, mapped_ioctl, 0 }, - { COMEDI_POLL, mapped_ioctl, 0 }, - { COMEDI32_CHANINFO, mapped_ioctl, 0 }, - { COMEDI32_RANGEINFO, mapped_ioctl, 0 }, - { COMEDI32_CMD, mapped_ioctl, 0 }, - { COMEDI32_CMDTEST, mapped_ioctl, 0 }, - { COMEDI32_INSNLIST, mapped_ioctl, 0 }, - { COMEDI32_INSN, mapped_ioctl, 0 }, + {COMEDI_DEVCONFIG, mapped_ioctl, 0}, + {COMEDI_DEVINFO, mapped_ioctl, 0}, + {COMEDI_SUBDINFO, mapped_ioctl, 0}, + {COMEDI_BUFCONFIG, mapped_ioctl, 0}, + {COMEDI_BUFINFO, mapped_ioctl, 0}, + {COMEDI_LOCK, mapped_ioctl, 0}, + {COMEDI_UNLOCK, mapped_ioctl, 0}, + {COMEDI_CANCEL, mapped_ioctl, 0}, + {COMEDI_POLL, mapped_ioctl, 0}, + {COMEDI32_CHANINFO, mapped_ioctl, 0}, + {COMEDI32_RANGEINFO, mapped_ioctl, 0}, + {COMEDI32_CMD, mapped_ioctl, 0}, + {COMEDI32_CMDTEST, mapped_ioctl, 0}, + {COMEDI32_INSNLIST, mapped_ioctl, 0}, + {COMEDI32_INSN, mapped_ioctl, 0}, }; #define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map) @@ -547,13 +545,13 @@ for (n = 0; n < NUM_IOCTL32_MAPS; n++) { rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd, - comedi_ioctl32_map[n].handler); + comedi_ioctl32_map[n].handler); if (rc) { printk(KERN_WARNING - "comedi: failed to register 32-bit " - "compatible ioctl handler for 0x%X - " - "expect bad things to happen!\n", - comedi_ioctl32_map[n].cmd); + "comedi: failed to register 32-bit " + "compatible ioctl handler for 0x%X - " + "expect bad things to happen!\n", + comedi_ioctl32_map[n].cmd); } comedi_ioctl32_map[n].registered = !rc; } @@ -566,15 +564,16 @@ for (n = 0; n < NUM_IOCTL32_MAPS; n++) { if (comedi_ioctl32_map[n].registered) { - rc = unregister_ioctl32_conversion( - comedi_ioctl32_map[n].cmd, - comedi_ioctl32_map[n].handler); + rc = unregister_ioctl32_conversion(comedi_ioctl32_map + [n].cmd, + comedi_ioctl32_map + [n].handler); if (rc) { printk(KERN_ERR - "comedi: failed to unregister 32-bit " - "compatible ioctl handler for 0x%X - " - "expect kernel Oops!\n", - comedi_ioctl32_map[n].cmd); + "comedi: failed to unregister 32-bit " + "compatible ioctl handler for 0x%X - " + "expect kernel Oops!\n", + comedi_ioctl32_map[n].cmd); } else { comedi_ioctl32_map[n].registered = 0; } @@ -582,6 +581,6 @@ } } -#endif /* HAVE_COMPAT_IOCTL */ +#endif /* HAVE_COMPAT_IOCTL */ -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_COMPAT */ diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_compat32.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_compat32.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_compat32.h 2009-03-24 09:44:03.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_compat32.h 2009-07-30 09:25:29.000000000 -0700 @@ -28,14 +28,14 @@ #define _COMEDI_COMPAT32_H #include -#include /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */ +#include /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */ #ifdef CONFIG_COMPAT #ifdef HAVE_COMPAT_IOCTL extern long comedi_compat_ioctl(struct file *file, unsigned int cmd, - unsigned long arg); + unsigned long arg); #define comedi_register_ioctl32() do {} while (0) #define comedi_unregister_ioctl32() do {} while (0) diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedidev.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedidev.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedidev.h 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedidev.h 2009-07-30 09:25:29.000000000 -0700 @@ -156,28 +156,30 @@ unsigned int *chanlist; /* driver-owned chanlist (not used) */ - int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, - unsigned int *); - int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, - unsigned int *); - int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, - unsigned int *); - int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, - unsigned int *); + int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *); - int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, struct comedi_cmd *); + int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, + struct comedi_cmd *); int (*poll) (struct comedi_device *, struct comedi_subdevice *); int (*cancel) (struct comedi_device *, struct comedi_subdevice *); /* int (*do_lock)(struct comedi_device *,struct comedi_subdevice *); */ /* int (*do_unlock)(struct comedi_device *,struct comedi_subdevice *); */ /* called when the buffer changes */ - int (*buf_change) (struct comedi_device *dev, struct comedi_subdevice *s, - unsigned long new_size); + int (*buf_change) (struct comedi_device * dev, + struct comedi_subdevice * s, unsigned long new_size); - void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, void *data, - unsigned int num_bytes, unsigned int start_chan_index); + void (*munge) (struct comedi_device * dev, struct comedi_subdevice * s, + void *data, unsigned int num_bytes, + unsigned int start_chan_index); enum dma_data_direction async_dma_dir; unsigned int state; @@ -231,7 +233,7 @@ int (*cb_func) (unsigned int flags, void *); void *cb_arg; - int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s, + int (*inttrig) (struct comedi_device * dev, struct comedi_subdevice * s, unsigned int x); }; @@ -281,8 +283,8 @@ struct fasync_struct *async_queue; - void (*open) (struct comedi_device *dev); - void (*close) (struct comedi_device *dev); + void (*open) (struct comedi_device * dev); + void (*close) (struct comedi_device * dev); }; struct comedi_device_file_info { @@ -316,8 +318,9 @@ struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor); -static inline struct comedi_subdevice *comedi_get_read_subdevice( - const struct comedi_device_file_info *info) +static inline struct comedi_subdevice *comedi_get_read_subdevice(const struct + comedi_device_file_info + *info) { if (info->read_subdevice) return info->read_subdevice; @@ -326,8 +329,9 @@ return info->device->read_subdev; } -static inline struct comedi_subdevice *comedi_get_write_subdevice( - const struct comedi_device_file_info *info) +static inline struct comedi_subdevice *comedi_get_write_subdevice(const struct + comedi_device_file_info + *info) { if (info->write_subdevice) return info->write_subdevice; @@ -337,7 +341,8 @@ } void comedi_device_detach(struct comedi_device *dev); -int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it); +int comedi_device_attach(struct comedi_device *dev, + struct comedi_devconfig *it); int comedi_driver_register(struct comedi_driver *); int comedi_driver_unregister(struct comedi_driver *); @@ -346,8 +351,8 @@ void start_polling(struct comedi_device *); void stop_polling(struct comedi_device *); -int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long - new_size); +int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned long new_size); #ifdef CONFIG_PROC_FS void comedi_proc_init(void); @@ -356,6 +361,7 @@ static inline void comedi_proc_init(void) { } + static inline void comedi_proc_cleanup(void) { } @@ -378,10 +384,10 @@ int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg); int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist); void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask, - unsigned bits); + unsigned bits); unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s); int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); /* range stuff */ @@ -421,7 +427,8 @@ dev->n_subdevices = num_subdevices; dev->subdevices = - kcalloc(num_subdevices, sizeof(struct comedi_subdevice), GFP_KERNEL); + kcalloc(num_subdevices, sizeof(struct comedi_subdevice), + GFP_KERNEL); if (!dev->subdevices) return -ENOMEM; for (i = 0; i < num_subdevices; ++i) { @@ -451,7 +458,8 @@ /* must be used in attach to set dev->hw_dev if you wish to dma directly into comedi's buffer */ -static inline void comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev) +static inline void comedi_set_hw_dev(struct comedi_device *dev, + struct device *hw_dev) { if (dev->hw_dev) put_device(dev->hw_dev); @@ -467,21 +475,23 @@ int comedi_buf_get(struct comedi_async *async, short *x); unsigned int comedi_buf_write_n_available(struct comedi_async *async); -unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nbytes); +unsigned int comedi_buf_write_alloc(struct comedi_async *async, + unsigned int nbytes); unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async, - unsigned int nbytes); + unsigned int nbytes); unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes); unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes); unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes); unsigned int comedi_buf_read_n_available(struct comedi_async *async); void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, - const void *source, unsigned int num_bytes); + const void *source, unsigned int num_bytes); void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, - void *destination, unsigned int num_bytes); + void *destination, unsigned int num_bytes); static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async) { return async->buf_write_alloc_count - async->buf_write_count; } + static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async) { return async->buf_read_alloc_count - async->buf_read_count; @@ -516,25 +526,26 @@ int comedi_alloc_board_minor(struct device *hardware_device); void comedi_free_board_minor(unsigned minor); -int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s); +int comedi_alloc_subdevice_minor(struct comedi_device *dev, + struct comedi_subdevice *s); void comedi_free_subdevice_minor(struct comedi_subdevice *s); int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name); void comedi_pci_auto_unconfig(struct pci_dev *pcidev); -struct usb_device; /* forward declaration */ +struct usb_device; /* forward declaration */ int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name); void comedi_usb_auto_unconfig(struct usb_device *usbdev); #ifdef CONFIG_COMEDI_PCI_DRIVERS - #define CONFIG_COMEDI_PCI +#define CONFIG_COMEDI_PCI #endif #ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE - #define CONFIG_COMEDI_PCI +#define CONFIG_COMEDI_PCI #endif #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS - #define CONFIG_COMEDI_PCMCIA +#define CONFIG_COMEDI_PCMCIA #endif #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE - #define CONFIG_COMEDI_PCMCIA +#define CONFIG_COMEDI_PCMCIA #endif #endif /* _COMEDIDEV_H */ diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_fops.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_fops.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_fops.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_fops.c 2009-07-30 09:25:29.000000000 -0700 @@ -68,26 +68,33 @@ static DEFINE_SPINLOCK(comedi_file_info_table_lock); static struct comedi_device_file_info - *comedi_file_info_table[COMEDI_NUM_MINORS]; +*comedi_file_info_table[COMEDI_NUM_MINORS]; -static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg); +static int do_devconfig_ioctl(struct comedi_device *dev, + struct comedi_devconfig *arg); static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg); -static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg, - struct file *file); -static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg, - void *file); -static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg); +static int do_devinfo_ioctl(struct comedi_device *dev, + struct comedi_devinfo *arg, struct file *file); +static int do_subdinfo_ioctl(struct comedi_device *dev, + struct comedi_subdinfo *arg, void *file); +static int do_chaninfo_ioctl(struct comedi_device *dev, + struct comedi_chaninfo *arg); static int do_bufinfo_ioctl(struct comedi_device *dev, void *arg); static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file); -static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file); -static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file); -static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file); +static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, + void *file); +static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, + void *file); +static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, + void *file); static int do_cmdtest_ioctl(struct comedi_device *dev, void *arg, void *file); static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file); static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file); -static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd, void *file); +static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd, + void *file); -extern void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s); +extern void do_become_nonbusy(struct comedi_device *dev, + struct comedi_subdevice *s); static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int comedi_fasync(int fd, struct file *file, int on); @@ -202,7 +209,8 @@ writes: none */ -static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg) +static int do_devconfig_ioctl(struct comedi_device *dev, + struct comedi_devconfig *arg) { struct comedi_devconfig it; int ret; @@ -342,8 +350,8 @@ devinfo structure */ -static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg, - struct file *file) +static int do_devinfo_ioctl(struct comedi_device *dev, + struct comedi_devinfo *arg, struct file *file) { struct comedi_devinfo devinfo; const unsigned minor = iminor(file->f_dentry->d_inode); @@ -392,14 +400,16 @@ array of subdevice info structures at arg */ -static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg, - void *file) +static int do_subdinfo_ioctl(struct comedi_device *dev, + struct comedi_subdinfo *arg, void *file) { int ret, i; struct comedi_subdinfo *tmp, *us; struct comedi_subdevice *s; - tmp = kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo), GFP_KERNEL); + tmp = + kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo), + GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -472,7 +482,8 @@ arrays at elements of chaninfo structure */ -static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg) +static int do_chaninfo_ioctl(struct comedi_device *dev, + struct comedi_chaninfo *arg) { struct comedi_subdevice *s; struct comedi_chaninfo it; @@ -514,7 +525,7 @@ } #if 0 if (copy_to_user(it.rangelist, s->range_type_list, - s->n_chan*sizeof(unsigned int))) + s->n_chan * sizeof(unsigned int))) return -EFAULT; #endif } @@ -589,8 +600,8 @@ return 0; } -static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data, - void *file); +static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, + unsigned int *data, void *file); /* * COMEDI_INSNLIST * synchronous instructions @@ -626,7 +637,8 @@ goto error; } - insns = kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL); + insns = + kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL); if (!insns) { DPRINTK("kmalloc failed\n"); ret = -ENOMEM; @@ -678,7 +690,8 @@ return i; } -static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data) +static int check_insn_config_length(struct comedi_insn *insn, + unsigned int *data) { if (insn->n < 1) return -EINVAL; @@ -725,22 +738,22 @@ if (insn->n == 5) return 0; break; - /* by default we allow the insn since we don't have checks for - * all possible cases yet */ + /* by default we allow the insn since we don't have checks for + * all possible cases yet */ default: printk("comedi: no check for data length of config insn id " - "%i is implemented.\n" - " Add a check to %s in %s.\n" - " Assuming n=%i is correct.\n", data[0], __func__, - __FILE__, insn->n); + "%i is implemented.\n" + " Add a check to %s in %s.\n" + " Assuming n=%i is correct.\n", data[0], __func__, + __FILE__, insn->n); return 0; break; } return -EINVAL; } -static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data, - void *file) +static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, + unsigned int *data, void *file) { struct comedi_subdevice *s; int ret = 0; @@ -920,7 +933,8 @@ if (insn.n > MAX_SAMPLES) insn.n = MAX_SAMPLES; if (insn.insn & INSN_MASK_WRITE) { - if (copy_from_user(data, insn.data, insn.n * sizeof(unsigned int))) { + if (copy_from_user + (data, insn.data, insn.n * sizeof(unsigned int))) { ret = -EFAULT; goto error; } @@ -929,7 +943,8 @@ if (ret < 0) goto error; if (insn.insn & INSN_MASK_READ) { - if (copy_to_user(insn.data, data, insn.n * sizeof(unsigned int))) { + if (copy_to_user + (insn.data, data, insn.n * sizeof(unsigned int))) { ret = -EFAULT; goto error; } @@ -1202,7 +1217,8 @@ */ -static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file) +static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, + void *file) { int ret = 0; unsigned long flags; @@ -1246,7 +1262,8 @@ This function isn't protected by the semaphore, since we already own the lock. */ -static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file) +static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, + void *file) { struct comedi_subdevice *s; @@ -1286,7 +1303,8 @@ nothing */ -static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file) +static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, + void *file) { struct comedi_subdevice *s; @@ -1322,7 +1340,8 @@ nothing */ -static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, void *file) +static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, + void *file) { struct comedi_subdevice *s; @@ -1371,7 +1390,7 @@ } static struct vm_operations_struct comedi_vm_ops = { - .close = comedi_unmap, + .close = comedi_unmap, }; static int comedi_mmap(struct file *file, struct vm_area_struct *vma) @@ -1428,10 +1447,10 @@ n_pages = size >> PAGE_SHIFT; for (i = 0; i < n_pages; ++i) { if (remap_pfn_range(vma, start, - page_to_pfn(virt_to_page(async-> - buf_page_list[i]. - virt_addr)), - PAGE_SIZE, PAGE_SHARED)) { + page_to_pfn(virt_to_page + (async->buf_page_list + [i].virt_addr)), PAGE_SIZE, + PAGE_SHARED)) { retval = -EAGAIN; goto done; } @@ -1449,7 +1468,7 @@ return retval; } -static unsigned int comedi_poll(struct file *file, poll_table *wait) +static unsigned int comedi_poll(struct file *file, poll_table * wait) { unsigned int mask = 0; const unsigned minor = iminor(file->f_dentry->d_inode); @@ -1496,7 +1515,7 @@ } static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes, - loff_t *offset) + loff_t * offset) { struct comedi_subdevice *s; struct comedi_async *async; @@ -1598,7 +1617,7 @@ } static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes, - loff_t *offset) + loff_t * offset) { struct comedi_subdevice *s; struct comedi_async *async; @@ -1729,7 +1748,8 @@ const unsigned minor = iminor(inode); struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(minor); - struct comedi_device *dev = dev_file_info ? dev_file_info->device : NULL; + struct comedi_device *dev = + dev_file_info ? dev_file_info->device : NULL; if (dev == NULL) { DPRINTK("invalid minor number\n"); @@ -1846,22 +1866,22 @@ } const struct file_operations comedi_fops = { - .owner = THIS_MODULE, + .owner = THIS_MODULE, #ifdef HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = comedi_unlocked_ioctl, + .unlocked_ioctl = comedi_unlocked_ioctl, #else - .ioctl = comedi_ioctl, + .ioctl = comedi_ioctl, #endif #ifdef HAVE_COMPAT_IOCTL - .compat_ioctl = comedi_compat_ioctl, + .compat_ioctl = comedi_compat_ioctl, #endif - .open = comedi_open, - .release = comedi_close, - .read = comedi_read, - .write = comedi_write, - .mmap = comedi_mmap, - .poll = comedi_poll, - .fasync = comedi_fasync, + .open = comedi_open, + .release = comedi_close, + .read = comedi_read, + .write = comedi_write, + .mmap = comedi_mmap, + .poll = comedi_poll, + .fasync = comedi_fasync, }; struct class *comedi_class; @@ -1952,7 +1972,6 @@ for (i = 0; i < COMEDI_NUM_MINORS; ++i) BUG_ON(comedi_file_info_table[i]); - class_destroy(comedi_class); cdev_del(&comedi_cdev); unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); @@ -1981,8 +2000,9 @@ if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0) return; - if (s->async-> - events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) { + if (s-> + async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | + COMEDI_CB_OVERFLOW)) { runflags_mask |= SRF_RUNNING; } /* remember if an error event has occured, so an error @@ -2000,12 +2020,10 @@ if (comedi_get_subdevice_runflags(s) & SRF_USER) { wake_up_interruptible(&async->wait_head); if (s->subdev_flags & SDF_CMD_READ) { - kill_fasync(&dev->async_queue, SIGIO, - POLL_IN); + kill_fasync(&dev->async_queue, SIGIO, POLL_IN); } if (s->subdev_flags & SDF_CMD_WRITE) { - kill_fasync(&dev->async_queue, SIGIO, - POLL_OUT); + kill_fasync(&dev->async_queue, SIGIO, POLL_OUT); } } else { if (async->cb_func) @@ -2103,7 +2121,8 @@ comedi_device_cleanup(info->device); kfree(info->device); kfree(info); - printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR + "comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } info->device->minor = i; @@ -2115,29 +2134,33 @@ dev_set_drvdata(csdev, info); retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_max_read_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_read_buffer_kb.attr.name); comedi_free_board_minor(i); return retval; } retval = device_create_file(csdev, &dev_attr_read_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_read_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_read_buffer_kb.attr.name); comedi_free_board_minor(i); return retval; } retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_max_write_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_write_buffer_kb.attr.name); comedi_free_board_minor(i); return retval; } retval = device_create_file(csdev, &dev_attr_write_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_write_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_write_buffer_kb.attr.name); comedi_free_board_minor(i); return retval; } @@ -2194,7 +2217,8 @@ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); if (i == COMEDI_NUM_MINORS) { kfree(info); - printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n"); + printk(KERN_ERR + "comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } s->minor = i; @@ -2207,29 +2231,33 @@ dev_set_drvdata(csdev, info); retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_max_read_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_read_buffer_kb.attr.name); comedi_free_subdevice_minor(s); return retval; } retval = device_create_file(csdev, &dev_attr_read_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_read_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_read_buffer_kb.attr.name); comedi_free_subdevice_minor(s); return retval; } retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_max_write_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_max_write_buffer_kb.attr.name); comedi_free_subdevice_minor(s); return retval; } retval = device_create_file(csdev, &dev_attr_write_buffer_kb); if (retval) { - printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n", - dev_attr_write_buffer_kb.attr.name); + printk(KERN_ERR + "comedi: failed to create sysfs attribute file \"%s\".\n", + dev_attr_write_buffer_kb.attr.name); comedi_free_subdevice_minor(s); return retval; } @@ -2295,7 +2323,7 @@ return -EINVAL; /* make sure buffer is an integral number of pages - * (we round up) */ + * (we round up) */ new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK; retval = comedi_buf_alloc(dev, s, new_size); @@ -2324,16 +2352,16 @@ struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned max_buffer_size_kb = 0; struct comedi_subdevice *const read_subdevice = - comedi_get_read_subdevice(info); + comedi_get_read_subdevice(info); mutex_lock(&info->device->mutex); if (read_subdevice && (read_subdevice->subdev_flags & SDF_CMD_READ) && read_subdevice->async) { max_buffer_size_kb = read_subdevice->async->max_bufsize / - bytes_per_kibi; + bytes_per_kibi; } - retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); + retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); mutex_unlock(&info->device->mutex); return retval; @@ -2347,14 +2375,14 @@ unsigned long new_max_size_kb; uint64_t new_max_size; struct comedi_subdevice *const read_subdevice = - comedi_get_read_subdevice(info); + comedi_get_read_subdevice(info); if (strict_strtoul(buf, 10, &new_max_size_kb)) return -EINVAL; - if (new_max_size_kb != (uint32_t)new_max_size_kb) + if (new_max_size_kb != (uint32_t) new_max_size_kb) return -EINVAL; - new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi; - if (new_max_size != (uint32_t)new_max_size) + new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi; + if (new_max_size != (uint32_t) new_max_size) return -EINVAL; mutex_lock(&info->device->mutex); @@ -2372,9 +2400,8 @@ static struct device_attribute dev_attr_max_read_buffer_kb = { .attr = { - .name = "max_read_buffer_kb", - .mode = S_IRUGO | S_IWUSR - }, + .name = "max_read_buffer_kb", + .mode = S_IRUGO | S_IWUSR}, .show = &show_max_read_buffer_kb, .store = &store_max_read_buffer_kb }; @@ -2386,16 +2413,16 @@ struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned buffer_size_kb = 0; struct comedi_subdevice *const read_subdevice = - comedi_get_read_subdevice(info); + comedi_get_read_subdevice(info); mutex_lock(&info->device->mutex); if (read_subdevice && - (read_subdevice->subdev_flags & SDF_CMD_READ) && - read_subdevice->async) { + (read_subdevice->subdev_flags & SDF_CMD_READ) && + read_subdevice->async) { buffer_size_kb = read_subdevice->async->prealloc_bufsz / - bytes_per_kibi; + bytes_per_kibi; } - retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); + retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); mutex_unlock(&info->device->mutex); return retval; @@ -2410,14 +2437,14 @@ uint64_t new_size; int retval; struct comedi_subdevice *const read_subdevice = - comedi_get_read_subdevice(info); + comedi_get_read_subdevice(info); if (strict_strtoul(buf, 10, &new_size_kb)) return -EINVAL; - if (new_size_kb != (uint32_t)new_size_kb) + if (new_size_kb != (uint32_t) new_size_kb) return -EINVAL; - new_size = ((uint64_t)new_size_kb) * bytes_per_kibi; - if (new_size != (uint32_t)new_size) + new_size = ((uint64_t) new_size_kb) * bytes_per_kibi; + if (new_size != (uint32_t) new_size) return -EINVAL; mutex_lock(&info->device->mutex); @@ -2438,9 +2465,8 @@ static struct device_attribute dev_attr_read_buffer_kb = { .attr = { - .name = "read_buffer_kb", - .mode = S_IRUGO | S_IWUSR | S_IWGRP - }, + .name = "read_buffer_kb", + .mode = S_IRUGO | S_IWUSR | S_IWGRP}, .show = &show_read_buffer_kb, .store = &store_read_buffer_kb }; @@ -2453,16 +2479,16 @@ struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned max_buffer_size_kb = 0; struct comedi_subdevice *const write_subdevice = - comedi_get_write_subdevice(info); + comedi_get_write_subdevice(info); mutex_lock(&info->device->mutex); if (write_subdevice && (write_subdevice->subdev_flags & SDF_CMD_WRITE) && write_subdevice->async) { max_buffer_size_kb = write_subdevice->async->max_bufsize / - bytes_per_kibi; + bytes_per_kibi; } - retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); + retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb); mutex_unlock(&info->device->mutex); return retval; @@ -2476,14 +2502,14 @@ unsigned long new_max_size_kb; uint64_t new_max_size; struct comedi_subdevice *const write_subdevice = - comedi_get_write_subdevice(info); + comedi_get_write_subdevice(info); if (strict_strtoul(buf, 10, &new_max_size_kb)) return -EINVAL; - if (new_max_size_kb != (uint32_t)new_max_size_kb) + if (new_max_size_kb != (uint32_t) new_max_size_kb) return -EINVAL; - new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi; - if (new_max_size != (uint32_t)new_max_size) + new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi; + if (new_max_size != (uint32_t) new_max_size) return -EINVAL; mutex_lock(&info->device->mutex); @@ -2501,9 +2527,8 @@ static struct device_attribute dev_attr_max_write_buffer_kb = { .attr = { - .name = "max_write_buffer_kb", - .mode = S_IRUGO | S_IWUSR - }, + .name = "max_write_buffer_kb", + .mode = S_IRUGO | S_IWUSR}, .show = &show_max_write_buffer_kb, .store = &store_max_write_buffer_kb }; @@ -2515,16 +2540,16 @@ struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned buffer_size_kb = 0; struct comedi_subdevice *const write_subdevice = - comedi_get_write_subdevice(info); + comedi_get_write_subdevice(info); mutex_lock(&info->device->mutex); if (write_subdevice && (write_subdevice->subdev_flags & SDF_CMD_WRITE) && write_subdevice->async) { buffer_size_kb = write_subdevice->async->prealloc_bufsz / - bytes_per_kibi; + bytes_per_kibi; } - retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); + retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb); mutex_unlock(&info->device->mutex); return retval; @@ -2539,14 +2564,14 @@ uint64_t new_size; int retval; struct comedi_subdevice *const write_subdevice = - comedi_get_write_subdevice(info); + comedi_get_write_subdevice(info); if (strict_strtoul(buf, 10, &new_size_kb)) return -EINVAL; - if (new_size_kb != (uint32_t)new_size_kb) + if (new_size_kb != (uint32_t) new_size_kb) return -EINVAL; - new_size = ((uint64_t)new_size_kb) * bytes_per_kibi; - if (new_size != (uint32_t)new_size) + new_size = ((uint64_t) new_size_kb) * bytes_per_kibi; + if (new_size != (uint32_t) new_size) return -EINVAL; mutex_lock(&info->device->mutex); @@ -2557,7 +2582,7 @@ return -EINVAL; } retval = resize_async_buffer(info->device, write_subdevice, - write_subdevice->async, new_size); + write_subdevice->async, new_size); mutex_unlock(&info->device->mutex); if (retval < 0) @@ -2567,9 +2592,8 @@ static struct device_attribute dev_attr_write_buffer_kb = { .attr = { - .name = "write_buffer_kb", - .mode = S_IRUGO | S_IWUSR | S_IWGRP - }, + .name = "write_buffer_kb", + .mode = S_IRUGO | S_IWUSR | S_IWGRP}, .show = &show_write_buffer_kb, .store = &store_write_buffer_kb }; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi.h 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi.h 2009-07-30 09:25:31.000000000 -0700 @@ -121,10 +121,10 @@ #define TRIG_BOGUS 0x0001 /* do the motions */ #define TRIG_DITHER 0x0002 /* enable dithering */ #define TRIG_DEGLITCH 0x0004 /* enable deglitching */ -/*#define TRIG_RT 0x0008 */ /* perform op in real time */ + /*#define TRIG_RT 0x0008 *//* perform op in real time */ #define TRIG_CONFIG 0x0010 /* perform configuration, not triggering */ #define TRIG_WAKE_EOS 0x0020 /* wake up on end-of-scan events */ -/*#define TRIG_WRITE 0x0040*/ /* write to bidirectional devices */ + /*#define TRIG_WRITE 0x0040*//* write to bidirectional devices */ /* command flags */ /* These flags are used in comedi_cmd structures */ @@ -199,93 +199,91 @@ #define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */ #define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */ /* re recyle these flags for PWM */ -#define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */ -#define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */ - - +#define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */ +#define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */ /* subdevice types */ -enum comedi_subdevice_type { - COMEDI_SUBD_UNUSED, /* unused by driver */ - COMEDI_SUBD_AI, /* analog input */ - COMEDI_SUBD_AO, /* analog output */ - COMEDI_SUBD_DI, /* digital input */ - COMEDI_SUBD_DO, /* digital output */ - COMEDI_SUBD_DIO, /* digital input/output */ - COMEDI_SUBD_COUNTER, /* counter */ - COMEDI_SUBD_TIMER, /* timer */ - COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */ - COMEDI_SUBD_CALIB, /* calibration DACs */ - COMEDI_SUBD_PROC, /* processor, DSP */ - COMEDI_SUBD_SERIAL, /* serial IO */ - COMEDI_SUBD_PWM /* PWM */ -}; + enum comedi_subdevice_type { + COMEDI_SUBD_UNUSED, /* unused by driver */ + COMEDI_SUBD_AI, /* analog input */ + COMEDI_SUBD_AO, /* analog output */ + COMEDI_SUBD_DI, /* digital input */ + COMEDI_SUBD_DO, /* digital output */ + COMEDI_SUBD_DIO, /* digital input/output */ + COMEDI_SUBD_COUNTER, /* counter */ + COMEDI_SUBD_TIMER, /* timer */ + COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */ + COMEDI_SUBD_CALIB, /* calibration DACs */ + COMEDI_SUBD_PROC, /* processor, DSP */ + COMEDI_SUBD_SERIAL, /* serial IO */ + COMEDI_SUBD_PWM /* PWM */ + }; /* configuration instructions */ -enum configuration_ids { - INSN_CONFIG_DIO_INPUT = 0, - INSN_CONFIG_DIO_OUTPUT = 1, - INSN_CONFIG_DIO_OPENDRAIN = 2, - INSN_CONFIG_ANALOG_TRIG = 16, + enum configuration_ids { + INSN_CONFIG_DIO_INPUT = 0, + INSN_CONFIG_DIO_OUTPUT = 1, + INSN_CONFIG_DIO_OPENDRAIN = 2, + INSN_CONFIG_ANALOG_TRIG = 16, /* INSN_CONFIG_WAVEFORM = 17, */ /* INSN_CONFIG_TRIG = 18, */ /* INSN_CONFIG_COUNTER = 19, */ - INSN_CONFIG_ALT_SOURCE = 20, - INSN_CONFIG_DIGITAL_TRIG = 21, - INSN_CONFIG_BLOCK_SIZE = 22, - INSN_CONFIG_TIMER_1 = 23, - INSN_CONFIG_FILTER = 24, - INSN_CONFIG_CHANGE_NOTIFY = 25, - - /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26, - INSN_CONFIG_BIDIRECTIONAL_DATA = 27, - INSN_CONFIG_DIO_QUERY = 28, - INSN_CONFIG_PWM_OUTPUT = 29, - INSN_CONFIG_GET_PWM_OUTPUT = 30, - INSN_CONFIG_ARM = 31, - INSN_CONFIG_DISARM = 32, - INSN_CONFIG_GET_COUNTER_STATUS = 33, - INSN_CONFIG_RESET = 34, - INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, /* Use CTR as single pulsegenerator */ - INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, /* Use CTR as pulsetraingenerator */ - INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, /* Use the counter as encoder */ - INSN_CONFIG_SET_GATE_SRC = 2001, /* Set gate source */ - INSN_CONFIG_GET_GATE_SRC = 2002, /* Get gate source */ - INSN_CONFIG_SET_CLOCK_SRC = 2003, /* Set master clock source */ - INSN_CONFIG_GET_CLOCK_SRC = 2004, /* Get master clock source */ - INSN_CONFIG_SET_OTHER_SRC = 2005, /* Set other source */ -/* INSN_CONFIG_GET_OTHER_SRC = 2006,*/ /* Get other source */ - INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, /* Get size in bytes of - subdevice's on-board - fifos used during - streaming - input/output */ - INSN_CONFIG_SET_COUNTER_MODE = 4097, - INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, /* deprecated */ - INSN_CONFIG_8254_READ_STATUS = 4098, - INSN_CONFIG_SET_ROUTING = 4099, - INSN_CONFIG_GET_ROUTING = 4109, + INSN_CONFIG_ALT_SOURCE = 20, + INSN_CONFIG_DIGITAL_TRIG = 21, + INSN_CONFIG_BLOCK_SIZE = 22, + INSN_CONFIG_TIMER_1 = 23, + INSN_CONFIG_FILTER = 24, + INSN_CONFIG_CHANGE_NOTIFY = 25, + + /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26, + INSN_CONFIG_BIDIRECTIONAL_DATA = 27, + INSN_CONFIG_DIO_QUERY = 28, + INSN_CONFIG_PWM_OUTPUT = 29, + INSN_CONFIG_GET_PWM_OUTPUT = 30, + INSN_CONFIG_ARM = 31, + INSN_CONFIG_DISARM = 32, + INSN_CONFIG_GET_COUNTER_STATUS = 33, + INSN_CONFIG_RESET = 34, + INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, /* Use CTR as single pulsegenerator */ + INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, /* Use CTR as pulsetraingenerator */ + INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, /* Use the counter as encoder */ + INSN_CONFIG_SET_GATE_SRC = 2001, /* Set gate source */ + INSN_CONFIG_GET_GATE_SRC = 2002, /* Get gate source */ + INSN_CONFIG_SET_CLOCK_SRC = 2003, /* Set master clock source */ + INSN_CONFIG_GET_CLOCK_SRC = 2004, /* Get master clock source */ + INSN_CONFIG_SET_OTHER_SRC = 2005, /* Set other source */ + /* INSN_CONFIG_GET_OTHER_SRC = 2006,*//* Get other source */ + INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, /* Get size in bytes of + subdevice's on-board + fifos used during + streaming + input/output */ + INSN_CONFIG_SET_COUNTER_MODE = 4097, + INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, /* deprecated */ + INSN_CONFIG_8254_READ_STATUS = 4098, + INSN_CONFIG_SET_ROUTING = 4099, + INSN_CONFIG_GET_ROUTING = 4109, /* PWM */ - INSN_CONFIG_PWM_SET_PERIOD = 5000, /* sets frequency */ - INSN_CONFIG_PWM_GET_PERIOD = 5001, /* gets frequency */ - INSN_CONFIG_GET_PWM_STATUS = 5002, /* is it running? */ - INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, /* sets H bridge: duty cycle and sign bit for a relay at the same time*/ - INSN_CONFIG_PWM_GET_H_BRIDGE = 5004 /* gets H bridge data: duty cycle and the sign bit */ -}; - -enum comedi_io_direction { - COMEDI_INPUT = 0, - COMEDI_OUTPUT = 1, - COMEDI_OPENDRAIN = 2 -}; - -enum comedi_support_level { - COMEDI_UNKNOWN_SUPPORT = 0, - COMEDI_SUPPORTED, - COMEDI_UNSUPPORTED -}; + INSN_CONFIG_PWM_SET_PERIOD = 5000, /* sets frequency */ + INSN_CONFIG_PWM_GET_PERIOD = 5001, /* gets frequency */ + INSN_CONFIG_GET_PWM_STATUS = 5002, /* is it running? */ + INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, /* sets H bridge: duty cycle and sign bit for a relay at the same time */ + INSN_CONFIG_PWM_GET_H_BRIDGE = 5004 /* gets H bridge data: duty cycle and the sign bit */ + }; + + enum comedi_io_direction { + COMEDI_INPUT = 0, + COMEDI_OUTPUT = 1, + COMEDI_OPENDRAIN = 2 + }; + + enum comedi_support_level { + COMEDI_UNKNOWN_SUPPORT = 0, + COMEDI_SUPPORTED, + COMEDI_UNSUPPORTED + }; /* ioctls */ @@ -309,133 +307,132 @@ /* structures */ -struct comedi_trig { - unsigned int subdev; /* subdevice */ - unsigned int mode; /* mode */ - unsigned int flags; - unsigned int n_chan; /* number of channels */ - unsigned int *chanlist; /* channel/range list */ - short *data; /* data list, size depends on subd flags */ - unsigned int n; /* number of scans */ - unsigned int trigsrc; - unsigned int trigvar; - unsigned int trigvar1; - unsigned int data_len; - unsigned int unused[3]; -}; - -struct comedi_insn { - unsigned int insn; - unsigned int n; - unsigned int *data; - unsigned int subdev; - unsigned int chanspec; - unsigned int unused[3]; -}; - -struct comedi_insnlist { - unsigned int n_insns; - struct comedi_insn *insns; -}; - -struct comedi_cmd { - unsigned int subdev; - unsigned int flags; - - unsigned int start_src; - unsigned int start_arg; - - unsigned int scan_begin_src; - unsigned int scan_begin_arg; - - unsigned int convert_src; - unsigned int convert_arg; - - unsigned int scan_end_src; - unsigned int scan_end_arg; - - unsigned int stop_src; - unsigned int stop_arg; - - unsigned int *chanlist; /* channel/range list */ - unsigned int chanlist_len; - - short *data; /* data list, size depends on subd flags */ - unsigned int data_len; -}; - -struct comedi_chaninfo { - unsigned int subdev; - unsigned int *maxdata_list; - unsigned int *flaglist; - unsigned int *rangelist; - unsigned int unused[4]; -}; - -struct comedi_rangeinfo { - unsigned int range_type; - void *range_ptr; -}; - -struct comedi_krange { - int min; /* fixed point, multiply by 1e-6 */ - int max; /* fixed point, multiply by 1e-6 */ - unsigned int flags; -}; - - -struct comedi_subdinfo { - unsigned int type; - unsigned int n_chan; - unsigned int subd_flags; - unsigned int timer_type; - unsigned int len_chanlist; - unsigned int maxdata; - unsigned int flags; /* channel flags */ - unsigned int range_type; /* lookup in kernel */ - unsigned int settling_time_0; - unsigned insn_bits_support; /* see support_level enum for values*/ - unsigned int unused[8]; -}; - -struct comedi_devinfo { - unsigned int version_code; - unsigned int n_subdevs; - char driver_name[COMEDI_NAMELEN]; - char board_name[COMEDI_NAMELEN]; - int read_subdevice; - int write_subdevice; - int unused[30]; -}; - -struct comedi_devconfig { - char board_name[COMEDI_NAMELEN]; - int options[COMEDI_NDEVCONFOPTS]; -}; - -struct comedi_bufconfig { - unsigned int subdevice; - unsigned int flags; - - unsigned int maximum_size; - unsigned int size; - - unsigned int unused[4]; -}; - -struct comedi_bufinfo { - unsigned int subdevice; - unsigned int bytes_read; - - unsigned int buf_write_ptr; - unsigned int buf_read_ptr; - unsigned int buf_write_count; - unsigned int buf_read_count; + struct comedi_trig { + unsigned int subdev; /* subdevice */ + unsigned int mode; /* mode */ + unsigned int flags; + unsigned int n_chan; /* number of channels */ + unsigned int *chanlist; /* channel/range list */ + short *data; /* data list, size depends on subd flags */ + unsigned int n; /* number of scans */ + unsigned int trigsrc; + unsigned int trigvar; + unsigned int trigvar1; + unsigned int data_len; + unsigned int unused[3]; + }; + + struct comedi_insn { + unsigned int insn; + unsigned int n; + unsigned int *data; + unsigned int subdev; + unsigned int chanspec; + unsigned int unused[3]; + }; + + struct comedi_insnlist { + unsigned int n_insns; + struct comedi_insn *insns; + }; + + struct comedi_cmd { + unsigned int subdev; + unsigned int flags; + + unsigned int start_src; + unsigned int start_arg; + + unsigned int scan_begin_src; + unsigned int scan_begin_arg; + + unsigned int convert_src; + unsigned int convert_arg; + + unsigned int scan_end_src; + unsigned int scan_end_arg; + + unsigned int stop_src; + unsigned int stop_arg; + + unsigned int *chanlist; /* channel/range list */ + unsigned int chanlist_len; + + short *data; /* data list, size depends on subd flags */ + unsigned int data_len; + }; + + struct comedi_chaninfo { + unsigned int subdev; + unsigned int *maxdata_list; + unsigned int *flaglist; + unsigned int *rangelist; + unsigned int unused[4]; + }; + + struct comedi_rangeinfo { + unsigned int range_type; + void *range_ptr; + }; + + struct comedi_krange { + int min; /* fixed point, multiply by 1e-6 */ + int max; /* fixed point, multiply by 1e-6 */ + unsigned int flags; + }; + + struct comedi_subdinfo { + unsigned int type; + unsigned int n_chan; + unsigned int subd_flags; + unsigned int timer_type; + unsigned int len_chanlist; + unsigned int maxdata; + unsigned int flags; /* channel flags */ + unsigned int range_type; /* lookup in kernel */ + unsigned int settling_time_0; + unsigned insn_bits_support; /* see support_level enum for values */ + unsigned int unused[8]; + }; + + struct comedi_devinfo { + unsigned int version_code; + unsigned int n_subdevs; + char driver_name[COMEDI_NAMELEN]; + char board_name[COMEDI_NAMELEN]; + int read_subdevice; + int write_subdevice; + int unused[30]; + }; + + struct comedi_devconfig { + char board_name[COMEDI_NAMELEN]; + int options[COMEDI_NDEVCONFOPTS]; + }; + + struct comedi_bufconfig { + unsigned int subdevice; + unsigned int flags; + + unsigned int maximum_size; + unsigned int size; + + unsigned int unused[4]; + }; + + struct comedi_bufinfo { + unsigned int subdevice; + unsigned int bytes_read; + + unsigned int buf_write_ptr; + unsigned int buf_read_ptr; + unsigned int buf_write_count; + unsigned int buf_read_count; - unsigned int bytes_written; + unsigned int bytes_written; - unsigned int unused[4]; -}; + unsigned int unused[4]; + }; /* range stuff */ @@ -486,298 +483,284 @@ */ -enum i8254_mode { - I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */ - I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */ - I8254_MODE2 = (2 << 1), /* Rate generator */ - I8254_MODE3 = (3 << 1), /* Square wave mode */ - I8254_MODE4 = (4 << 1), /* Software triggered strobe */ - I8254_MODE5 = (5 << 1), /* Hardware triggered strobe (retriggerable) */ - I8254_BCD = 1, /* use binary-coded decimal instead of binary (pretty useless) */ - I8254_BINARY = 0 -}; - -static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) -{ - if (pfi_channel < 10) - return 0x1 + pfi_channel; - else - return 0xb + pfi_channel; -} -static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel) -{ - if (rtsi_channel < 7) - return 0xb + rtsi_channel; - else - return 0x1b; -} + enum i8254_mode { + I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */ + I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */ + I8254_MODE2 = (2 << 1), /* Rate generator */ + I8254_MODE3 = (3 << 1), /* Square wave mode */ + I8254_MODE4 = (4 << 1), /* Software triggered strobe */ + I8254_MODE5 = (5 << 1), /* Hardware triggered strobe (retriggerable) */ + I8254_BCD = 1, /* use binary-coded decimal instead of binary (pretty useless) */ + I8254_BINARY = 0 + }; + + static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) { + if (pfi_channel < 10) + return 0x1 + pfi_channel; + else + return 0xb + pfi_channel; + } static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel) { + if (rtsi_channel < 7) + return 0xb + rtsi_channel; + else + return 0x1b; + } /* mode bits for NI general-purpose counters, set with * INSN_CONFIG_SET_COUNTER_MODE */ #define NI_GPCT_COUNTING_MODE_SHIFT 16 #define NI_GPCT_INDEX_PHASE_BITSHIFT 20 #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24 -enum ni_gpct_mode_bits { - NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4, - NI_GPCT_EDGE_GATE_MODE_MASK = 0x18, - NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0, - NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8, - NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10, - NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18, - NI_GPCT_STOP_MODE_MASK = 0x60, - NI_GPCT_STOP_ON_GATE_BITS = 0x00, - NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20, - NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40, - NI_GPCT_LOAD_B_SELECT_BIT = 0x80, - NI_GPCT_OUTPUT_MODE_MASK = 0x300, - NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100, - NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200, - NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300, - NI_GPCT_HARDWARE_DISARM_MASK = 0xc00, - NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000, - NI_GPCT_DISARM_AT_TC_BITS = 0x400, - NI_GPCT_DISARM_AT_GATE_BITS = 0x800, - NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00, - NI_GPCT_LOADING_ON_TC_BIT = 0x1000, - NI_GPCT_LOADING_ON_GATE_BIT = 0x4000, - NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_NORMAL_BITS = - 0x0 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS = - 0x1 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS = - 0x2 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS = - 0x3 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS = - 0x4 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS = - 0x6 << NI_GPCT_COUNTING_MODE_SHIFT, - NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, - NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS = - 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT, - NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS = - 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT, - NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS = - 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT, - NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS = - 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, - NI_GPCT_INDEX_ENABLE_BIT = 0x400000, - NI_GPCT_COUNTING_DIRECTION_MASK = - 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, - NI_GPCT_COUNTING_DIRECTION_DOWN_BITS = - 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT, - NI_GPCT_COUNTING_DIRECTION_UP_BITS = - 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT, - NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS = - 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT, - NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS = - 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, - NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000, - NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0, - NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000, - NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000, - NI_GPCT_OR_GATE_BIT = 0x10000000, - NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000 -}; + enum ni_gpct_mode_bits { + NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4, + NI_GPCT_EDGE_GATE_MODE_MASK = 0x18, + NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0, + NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8, + NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10, + NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18, + NI_GPCT_STOP_MODE_MASK = 0x60, + NI_GPCT_STOP_ON_GATE_BITS = 0x00, + NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20, + NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40, + NI_GPCT_LOAD_B_SELECT_BIT = 0x80, + NI_GPCT_OUTPUT_MODE_MASK = 0x300, + NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100, + NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200, + NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300, + NI_GPCT_HARDWARE_DISARM_MASK = 0xc00, + NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000, + NI_GPCT_DISARM_AT_TC_BITS = 0x400, + NI_GPCT_DISARM_AT_GATE_BITS = 0x800, + NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00, + NI_GPCT_LOADING_ON_TC_BIT = 0x1000, + NI_GPCT_LOADING_ON_GATE_BIT = 0x4000, + NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_NORMAL_BITS = + 0x0 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS = + 0x1 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS = + 0x2 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS = + 0x3 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS = + 0x4 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS = + 0x6 << NI_GPCT_COUNTING_MODE_SHIFT, + NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, + NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS = + 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT, + NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS = + 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT, + NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS = + 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT, + NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS = + 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, + NI_GPCT_INDEX_ENABLE_BIT = 0x400000, + NI_GPCT_COUNTING_DIRECTION_MASK = + 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, + NI_GPCT_COUNTING_DIRECTION_DOWN_BITS = + 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT, + NI_GPCT_COUNTING_DIRECTION_UP_BITS = + 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT, + NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS = + 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT, + NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS = + 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, + NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000, + NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0, + NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000, + NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000, + NI_GPCT_OR_GATE_BIT = 0x10000000, + NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000 + }; /* Bits for setting a clock source with * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. */ -enum ni_gpct_clock_source_bits { - NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f, - NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0, - NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1, - NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2, - NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3, - NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4, - NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5, - NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, /* NI 660x-specific */ - NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7, - NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8, - NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9, - NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000, - NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0, - NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, /* divide source by 2 */ - NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */ - NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000 -}; -static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) -{ - /* NI 660x-specific */ - return 0x10 + n; -} -static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) -{ - return 0x18 + n; -} -static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) -{ - /* no pfi on NI 660x */ - return 0x20 + n; -} + enum ni_gpct_clock_source_bits { + NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f, + NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0, + NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1, + NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2, + NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3, + NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4, + NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5, + NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, /* NI 660x-specific */ + NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7, + NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8, + NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9, + NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000, + NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0, + NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, /* divide source by 2 */ + NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */ + NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000 + }; + static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) { + /* NI 660x-specific */ + return 0x10 + n; + } + static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) { + return 0x18 + n; + } + static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) { + /* no pfi on NI 660x */ + return 0x20 + n; + } /* Possibilities for setting a gate source with INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters. May be bitwise-or'd with CR_EDGE or CR_INVERT. */ -enum ni_gpct_gate_select { - /* m-series gates */ - NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0, - NI_GPCT_AI_START2_GATE_SELECT = 0x12, - NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13, - NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14, - NI_GPCT_AI_START1_GATE_SELECT = 0x1c, - NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d, - NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e, - NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f, - /* more gates for 660x */ - NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100, - NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101, - /* more gates for 660x "second gate" */ - NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201, - NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e, - /* m-series "second gate" sources are unknown, - we should add them here with an offset of 0x300 when known. */ - NI_GPCT_DISABLED_GATE_SELECT = 0x8000, -}; -static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) -{ - return 0x102 + n; -} -static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) -{ - return NI_USUAL_RTSI_SELECT(n); -} -static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) -{ - return NI_USUAL_PFI_SELECT(n); -} -static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) -{ - return 0x202 + n; -} + enum ni_gpct_gate_select { + /* m-series gates */ + NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0, + NI_GPCT_AI_START2_GATE_SELECT = 0x12, + NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13, + NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14, + NI_GPCT_AI_START1_GATE_SELECT = 0x1c, + NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d, + NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e, + NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f, + /* more gates for 660x */ + NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100, + NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101, + /* more gates for 660x "second gate" */ + NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201, + NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e, + /* m-series "second gate" sources are unknown, + we should add them here with an offset of 0x300 when known. */ + NI_GPCT_DISABLED_GATE_SELECT = 0x8000, + }; + static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) { + return 0x102 + n; + } + static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) { + return NI_USUAL_RTSI_SELECT(n); + } + static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) { + return NI_USUAL_PFI_SELECT(n); + } + static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) { + return 0x202 + n; + } /* Possibilities for setting a source with INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */ -enum ni_gpct_other_index { - NI_GPCT_SOURCE_ENCODER_A, - NI_GPCT_SOURCE_ENCODER_B, - NI_GPCT_SOURCE_ENCODER_Z -}; -enum ni_gpct_other_select { - /* m-series gates */ - /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */ - NI_GPCT_DISABLED_OTHER_SELECT = 0x8000, -}; -static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) -{ - return NI_USUAL_PFI_SELECT(n); -} + enum ni_gpct_other_index { + NI_GPCT_SOURCE_ENCODER_A, + NI_GPCT_SOURCE_ENCODER_B, + NI_GPCT_SOURCE_ENCODER_Z + }; + enum ni_gpct_other_select { + /* m-series gates */ + /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */ + NI_GPCT_DISABLED_OTHER_SELECT = 0x8000, + }; + static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) { + return NI_USUAL_PFI_SELECT(n); + } /* start sources for ni general-purpose counters for use with INSN_CONFIG_ARM */ -enum ni_gpct_arm_source { - NI_GPCT_ARM_IMMEDIATE = 0x0, - NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, /* Start both the counter and - the adjacent paired counter - simultaneously */ - /* NI doesn't document bits for selecting hardware arm triggers. If - * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least - * significant bits (3 bits for 660x or 5 bits for m-series) through to - * the hardware. This will at least allow someone to figure out what - * the bits do later. */ - NI_GPCT_ARM_UNKNOWN = 0x1000, -}; + enum ni_gpct_arm_source { + NI_GPCT_ARM_IMMEDIATE = 0x0, + NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, /* Start both the counter and + the adjacent paired counter + simultaneously */ + /* NI doesn't document bits for selecting hardware arm triggers. If + * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least + * significant bits (3 bits for 660x or 5 bits for m-series) through to + * the hardware. This will at least allow someone to figure out what + * the bits do later. */ + NI_GPCT_ARM_UNKNOWN = 0x1000, + }; /* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */ -enum ni_gpct_filter_select { - NI_GPCT_FILTER_OFF = 0x0, - NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1, - NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2, - NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3, - NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4, - NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5, - NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6 -}; + enum ni_gpct_filter_select { + NI_GPCT_FILTER_OFF = 0x0, + NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1, + NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2, + NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3, + NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4, + NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5, + NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6 + }; /* PFI digital filtering options for ni m-series for use with * INSN_CONFIG_FILTER. */ -enum ni_pfi_filter_select { - NI_PFI_FILTER_OFF = 0x0, - NI_PFI_FILTER_125ns = 0x1, - NI_PFI_FILTER_6425ns = 0x2, - NI_PFI_FILTER_2550us = 0x3 -}; + enum ni_pfi_filter_select { + NI_PFI_FILTER_OFF = 0x0, + NI_PFI_FILTER_125ns = 0x1, + NI_PFI_FILTER_6425ns = 0x2, + NI_PFI_FILTER_2550us = 0x3 + }; /* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */ -enum ni_mio_clock_source { - NI_MIO_INTERNAL_CLOCK = 0, - NI_MIO_RTSI_CLOCK = 1, /* doesn't work for m-series, use - NI_MIO_PLL_RTSI_CLOCK() */ - /* the NI_MIO_PLL_* sources are m-series only */ - NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2, - NI_MIO_PLL_PXI10_CLOCK = 3, - NI_MIO_PLL_RTSI0_CLOCK = 4 -}; -static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) -{ - return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel; -} + enum ni_mio_clock_source { + NI_MIO_INTERNAL_CLOCK = 0, + NI_MIO_RTSI_CLOCK = 1, /* doesn't work for m-series, use + NI_MIO_PLL_RTSI_CLOCK() */ + /* the NI_MIO_PLL_* sources are m-series only */ + NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2, + NI_MIO_PLL_PXI10_CLOCK = 3, + NI_MIO_PLL_RTSI0_CLOCK = 4 + }; + static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) { + return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel; + } /* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING. The numbers assigned are not arbitrary, they correspond to the bits required to program the board. */ -enum ni_rtsi_routing { - NI_RTSI_OUTPUT_ADR_START1 = 0, - NI_RTSI_OUTPUT_ADR_START2 = 1, - NI_RTSI_OUTPUT_SCLKG = 2, - NI_RTSI_OUTPUT_DACUPDN = 3, - NI_RTSI_OUTPUT_DA_START1 = 4, - NI_RTSI_OUTPUT_G_SRC0 = 5, - NI_RTSI_OUTPUT_G_GATE0 = 6, - NI_RTSI_OUTPUT_RGOUT0 = 7, - NI_RTSI_OUTPUT_RTSI_BRD_0 = 8, - NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock - on line 7 */ -}; -static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) -{ - return NI_RTSI_OUTPUT_RTSI_BRD_0 + n; -} + enum ni_rtsi_routing { + NI_RTSI_OUTPUT_ADR_START1 = 0, + NI_RTSI_OUTPUT_ADR_START2 = 1, + NI_RTSI_OUTPUT_SCLKG = 2, + NI_RTSI_OUTPUT_DACUPDN = 3, + NI_RTSI_OUTPUT_DA_START1 = 4, + NI_RTSI_OUTPUT_G_SRC0 = 5, + NI_RTSI_OUTPUT_G_GATE0 = 6, + NI_RTSI_OUTPUT_RGOUT0 = 7, + NI_RTSI_OUTPUT_RTSI_BRD_0 = 8, + NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock + on line 7 */ + }; + static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) { + return NI_RTSI_OUTPUT_RTSI_BRD_0 + n; + } /* Signals which can be routed to an NI PFI pin on an m-series board with * INSN_CONFIG_SET_ROUTING. These numbers are also returned by * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing * cannot be changed. The numbers assigned are not arbitrary, they correspond * to the bits required to program the board. */ -enum ni_pfi_routing { - NI_PFI_OUTPUT_PFI_DEFAULT = 0, - NI_PFI_OUTPUT_AI_START1 = 1, - NI_PFI_OUTPUT_AI_START2 = 2, - NI_PFI_OUTPUT_AI_CONVERT = 3, - NI_PFI_OUTPUT_G_SRC1 = 4, - NI_PFI_OUTPUT_G_GATE1 = 5, - NI_PFI_OUTPUT_AO_UPDATE_N = 6, - NI_PFI_OUTPUT_AO_START1 = 7, - NI_PFI_OUTPUT_AI_START_PULSE = 8, - NI_PFI_OUTPUT_G_SRC0 = 9, - NI_PFI_OUTPUT_G_GATE0 = 10, - NI_PFI_OUTPUT_EXT_STROBE = 11, - NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12, - NI_PFI_OUTPUT_GOUT0 = 13, - NI_PFI_OUTPUT_GOUT1 = 14, - NI_PFI_OUTPUT_FREQ_OUT = 15, - NI_PFI_OUTPUT_PFI_DO = 16, - NI_PFI_OUTPUT_I_ATRIG = 17, - NI_PFI_OUTPUT_RTSI0 = 18, - NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26, - NI_PFI_OUTPUT_SCXI_TRIG1 = 27, - NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28, - NI_PFI_OUTPUT_CDI_SAMPLE = 29, - NI_PFI_OUTPUT_CDO_UPDATE = 30 -}; -static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) -{ - return NI_PFI_OUTPUT_RTSI0 + rtsi_channel; -} + enum ni_pfi_routing { + NI_PFI_OUTPUT_PFI_DEFAULT = 0, + NI_PFI_OUTPUT_AI_START1 = 1, + NI_PFI_OUTPUT_AI_START2 = 2, + NI_PFI_OUTPUT_AI_CONVERT = 3, + NI_PFI_OUTPUT_G_SRC1 = 4, + NI_PFI_OUTPUT_G_GATE1 = 5, + NI_PFI_OUTPUT_AO_UPDATE_N = 6, + NI_PFI_OUTPUT_AO_START1 = 7, + NI_PFI_OUTPUT_AI_START_PULSE = 8, + NI_PFI_OUTPUT_G_SRC0 = 9, + NI_PFI_OUTPUT_G_GATE0 = 10, + NI_PFI_OUTPUT_EXT_STROBE = 11, + NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12, + NI_PFI_OUTPUT_GOUT0 = 13, + NI_PFI_OUTPUT_GOUT1 = 14, + NI_PFI_OUTPUT_FREQ_OUT = 15, + NI_PFI_OUTPUT_PFI_DO = 16, + NI_PFI_OUTPUT_I_ATRIG = 17, + NI_PFI_OUTPUT_RTSI0 = 18, + NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26, + NI_PFI_OUTPUT_SCXI_TRIG1 = 27, + NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28, + NI_PFI_OUTPUT_CDI_SAMPLE = 29, + NI_PFI_OUTPUT_CDO_UPDATE = 30 + }; + static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) { + return NI_PFI_OUTPUT_RTSI0 + rtsi_channel; + } /* Signals which can be routed to output on a NI PFI pin on a 660x board with INSN_CONFIG_SET_ROUTING. The numbers assigned are @@ -785,72 +768,67 @@ to program the board. Lines 0 to 7 can only be set to NI_660X_PFI_OUTPUT_DIO. Lines 32 to 39 can only be set to NI_660X_PFI_OUTPUT_COUNTER. */ -enum ni_660x_pfi_routing { - NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */ - NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */ -}; + enum ni_660x_pfi_routing { + NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */ + NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */ + }; /* NI External Trigger lines. These values are not arbitrary, but are related * to the bits required to program the board (offset by 1 for historical * reasons). */ -static inline unsigned NI_EXT_PFI(unsigned pfi_channel) -{ - return NI_USUAL_PFI_SELECT(pfi_channel) - 1; -} -static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) -{ - return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1; -} + static inline unsigned NI_EXT_PFI(unsigned pfi_channel) { + return NI_USUAL_PFI_SELECT(pfi_channel) - 1; + } + static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) { + return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1; + } /* status bits for INSN_CONFIG_GET_COUNTER_STATUS */ -enum comedi_counter_status_flags { - COMEDI_COUNTER_ARMED = 0x1, - COMEDI_COUNTER_COUNTING = 0x2, - COMEDI_COUNTER_TERMINAL_COUNT = 0x4, -}; + enum comedi_counter_status_flags { + COMEDI_COUNTER_ARMED = 0x1, + COMEDI_COUNTER_COUNTING = 0x2, + COMEDI_COUNTER_TERMINAL_COUNT = 0x4, + }; /* Clock sources for CDIO subdevice on NI m-series boards. Used as the * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd * with CR_INVERT to change polarity. */ -enum ni_m_series_cdio_scan_begin_src { - NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0, - NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18, - NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19, - NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20, - NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28, - NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29, - NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30, - NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31, - NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32, - NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33 -}; -static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) -{ - return NI_USUAL_PFI_SELECT(pfi_channel); -} -static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) -{ - return NI_USUAL_RTSI_SELECT(rtsi_channel); -} + enum ni_m_series_cdio_scan_begin_src { + NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0, + NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18, + NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19, + NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20, + NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28, + NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29, + NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30, + NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31, + NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32, + NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33 + }; + static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) { + return NI_USUAL_PFI_SELECT(pfi_channel); + } + static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned + rtsi_channel) { + return NI_USUAL_RTSI_SELECT(rtsi_channel); + } /* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI * boards. These scan begin sources can also be bitwise-or'd with CR_INVERT to * change polarity. */ -static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) -{ - return NI_USUAL_PFI_SELECT(pfi_channel); -} -static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) -{ - return NI_USUAL_RTSI_SELECT(rtsi_channel); -} + static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) { + return NI_USUAL_PFI_SELECT(pfi_channel); + } + static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) { + return NI_USUAL_RTSI_SELECT(rtsi_channel); + } /* Bits for setting a clock source with * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */ -enum ni_freq_out_clock_source_bits { - NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */ - NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */ -}; + enum ni_freq_out_clock_source_bits { + NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */ + NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */ + }; /* Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). */ diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_ksyms.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_ksyms.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedi_ksyms.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedi_ksyms.c 2009-07-30 09:25:33.000000000 -0700 @@ -22,9 +22,6 @@ */ #define __NO_VERSION__ -#ifndef EXPORT_SYMTAB -#define EXPORT_SYMTAB -#endif #include "comedidev.h" diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedilib.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedilib.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/comedilib.h 2009-06-15 12:15:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/comedilib.h 2009-07-30 09:25:31.000000000 -0700 @@ -58,29 +58,31 @@ int comedi_cancel(void *dev, unsigned int subdev); int comedi_register_callback(void *dev, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, void *), void *arg); + unsigned int mask, int (*cb) (unsigned int, + void *), void *arg); int comedi_command(void *dev, struct comedi_cmd *cmd); int comedi_command_test(void *dev, struct comedi_cmd *cmd); int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); + unsigned int range, unsigned int aref, unsigned int data); int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); + unsigned int range, unsigned int aref, unsigned int *data); int comedi_data_read_hint(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, unsigned int aref); -int comedi_data_read_delayed(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, unsigned int aref, - unsigned int *data, unsigned int nano_sec); + unsigned int chan, unsigned int range, + unsigned int aref); +int comedi_data_read_delayed(void *dev, unsigned int subdev, unsigned int chan, + unsigned int range, unsigned int aref, + unsigned int *data, unsigned int nano_sec); int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, - unsigned int io); + unsigned int io); int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int *val); + unsigned int *val); int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int val); + unsigned int val); int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, - unsigned int *bits); + unsigned int *bits); int comedi_get_n_subdevices(void *dev); int comedi_get_version_code(void *dev); const char *comedi_get_driver_name(void *dev); @@ -89,31 +91,29 @@ int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); int comedi_get_n_channels(void *dev, unsigned int subdevice); unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned - int chan); -int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int - chan); + int chan); +int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int chan); int comedi_do_insn(void *dev, struct comedi_insn *insn); int comedi_poll(void *dev, unsigned int subdev); /* DEPRECATED functions */ -int comedi_get_rangetype(void *dev, unsigned int subdevice, - unsigned int chan); +int comedi_get_rangetype(void *dev, unsigned int subdevice, unsigned int chan); /* ALPHA functions */ unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice); int comedi_get_len_chanlist(void *dev, unsigned int subdevice); int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); + chan, unsigned int range, struct comedi_krange *krange); unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice); int comedi_set_user_int_count(void *dev, unsigned int subdevice, - unsigned int buf_user_count); + unsigned int buf_user_count); int comedi_map(void *dev, unsigned int subdev, void *ptr); int comedi_unmap(void *dev, unsigned int subdev); int comedi_get_buffer_size(void *dev, unsigned int subdev); int comedi_mark_buffer_read(void *dev, unsigned int subdevice, - unsigned int num_bytes); + unsigned int num_bytes); int comedi_mark_buffer_written(void *d, unsigned int subdevice, - unsigned int num_bytes); + unsigned int num_bytes); int comedi_get_buffer_contents(void *dev, unsigned int subdevice); int comedi_get_buffer_offset(void *dev, unsigned int subdevice); @@ -135,53 +135,56 @@ int comedi_cancel(unsigned int minor, unsigned int subdev); int comedi_register_callback(unsigned int minor, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, void *), void *arg); + unsigned int mask, int (*cb) (unsigned int, + void *), void *arg); int comedi_command(unsigned int minor, struct comedi_cmd *cmd); int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd); -int comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it); -int __comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it); +int comedi_trigger(unsigned int minor, unsigned int subdev, + struct comedi_trig *it); +int __comedi_trigger(unsigned int minor, unsigned int subdev, + struct comedi_trig *it); int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); + unsigned int range, unsigned int aref, unsigned int data); int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); + unsigned int range, unsigned int aref, unsigned int *data); int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int io); + unsigned int io); int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int *val); + unsigned int *val); int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int val); + unsigned int val); int comedi_dio_bitfield(unsigned int dev, unsigned int subdev, - unsigned int mask, unsigned int *bits); + unsigned int mask, unsigned int *bits); int comedi_get_n_subdevices(unsigned int dev); int comedi_get_version_code(unsigned int dev); char *comedi_get_driver_name(unsigned int dev); char *comedi_get_board_name(unsigned int minor); int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice); int comedi_find_subdevice_by_type(unsigned int minor, int type, - unsigned int subd); + unsigned int subd); int comedi_get_n_channels(unsigned int minor, unsigned int subdevice); unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned - int chan); + int chan); int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int - chan); + chan); int comedi_do_insn(unsigned int minor, struct comedi_insn *insn); int comedi_poll(unsigned int minor, unsigned int subdev); /* DEPRECATED functions */ int comedi_get_rangetype(unsigned int minor, unsigned int subdevice, - unsigned int chan); + unsigned int chan); /* ALPHA functions */ unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int - subdevice); + subdevice); int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice); int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); + chan, unsigned int range, struct comedi_krange *krange); unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int - subdevice); + subdevice); int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice, - unsigned int buf_user_count); + unsigned int buf_user_count); int comedi_map(unsigned int minor, unsigned int subdev, void **ptr); int comedi_unmap(unsigned int minor, unsigned int subdev); diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8253.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8253.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8253.h 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8253.h 2009-07-30 09:25:31.000000000 -0700 @@ -29,8 +29,10 @@ #define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base, - unsigned int *d1, unsigned int *d2, unsigned int *nanosec, - int round_mode) + unsigned int *d1, + unsigned int *d2, + unsigned int *nanosec, + int round_mode) { int divider; int div1, div2; @@ -78,8 +80,10 @@ } static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base, - unsigned int *d1, unsigned int *d2, unsigned int *nanosec, - int round_mode) + unsigned int *d1, + unsigned int *d2, + unsigned int *nanosec, + int round_mode) { int div1, div2; int base; @@ -118,8 +122,10 @@ } static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, - unsigned int *d1, unsigned int *d2, unsigned int *nanosec, - int round_mode) + unsigned int *d1, + unsigned int *d2, + unsigned int *nanosec, + int round_mode) { unsigned int divider; unsigned int div1, div2; @@ -136,12 +142,11 @@ div2 = *d2 ? *d2 : max_count; divider = div1 * div2; if (div1 * div2 * i8253_osc_base == *nanosec && - div1 > 1 && div1 <= max_count && - div2 > 1 && div2 <= max_count && - /* check for overflow */ - divider > div1 && divider > div2 && - divider * i8253_osc_base > divider && - divider * i8253_osc_base > i8253_osc_base) { + div1 > 1 && div1 <= max_count && div2 > 1 && div2 <= max_count && + /* check for overflow */ + divider > div1 && divider > div2 && + divider * i8253_osc_base > divider && + divider * i8253_osc_base > i8253_osc_base) { return; } @@ -158,10 +163,10 @@ if (start < 2) start = 2; for (div1 = start; div1 <= divider / div1 + 1 && div1 <= max_count; - div1++) { + div1++) { for (div2 = divider / div1; - div1 * div2 <= divider + div1 + 1 && div2 <= max_count; - div2++) { + div1 * div2 <= divider + div1 + 1 && div2 <= max_count; + div2++) { ns = i8253_osc_base * div1 * div2; if (ns <= *nanosec && ns > ns_glb) { ns_glb = ns; @@ -229,7 +234,8 @@ #define i8254_control_reg 3 static inline int i8254_load(unsigned long base_address, unsigned int regshift, - unsigned int counter_number, unsigned int count, unsigned int mode) + unsigned int counter_number, unsigned int count, + unsigned int mode) { unsigned int byte; @@ -255,7 +261,8 @@ } static inline int i8254_mm_load(void *base_address, unsigned int regshift, - unsigned int counter_number, unsigned int count, unsigned int mode) + unsigned int counter_number, unsigned int count, + unsigned int mode) { unsigned int byte; @@ -282,7 +289,7 @@ /* Returns 16 bit counter value, should work for 8253 also.*/ static inline int i8254_read(unsigned long base_address, unsigned int regshift, - unsigned int counter_number) + unsigned int counter_number) { unsigned int byte; int ret; @@ -303,7 +310,7 @@ } static inline int i8254_mm_read(void *base_address, unsigned int regshift, - unsigned int counter_number) + unsigned int counter_number) { unsigned int byte; int ret; @@ -325,7 +332,8 @@ /* Loads 16 bit initial counter value, should work for 8253 also. */ static inline void i8254_write(unsigned long base_address, - unsigned int regshift, unsigned int counter_number, unsigned int count) + unsigned int regshift, + unsigned int counter_number, unsigned int count) { unsigned int byte; @@ -339,7 +347,9 @@ } static inline void i8254_mm_write(void *base_address, - unsigned int regshift, unsigned int counter_number, unsigned int count) + unsigned int regshift, + unsigned int counter_number, + unsigned int count) { unsigned int byte; @@ -360,7 +370,8 @@ * I8254_BCD, I8254_BINARY */ static inline int i8254_set_mode(unsigned long base_address, - unsigned int regshift, unsigned int counter_number, unsigned int mode) + unsigned int regshift, + unsigned int counter_number, unsigned int mode) { unsigned int byte; @@ -378,7 +389,9 @@ } static inline int i8254_mm_set_mode(void *base_address, - unsigned int regshift, unsigned int counter_number, unsigned int mode) + unsigned int regshift, + unsigned int counter_number, + unsigned int mode) { unsigned int byte; @@ -396,18 +409,20 @@ } static inline int i8254_status(unsigned long base_address, - unsigned int regshift, unsigned int counter_number) + unsigned int regshift, + unsigned int counter_number) { outb(0xE0 | (2 << counter_number), - base_address + (i8254_control_reg << regshift)); + base_address + (i8254_control_reg << regshift)); return inb(base_address + (counter_number << regshift)); } static inline int i8254_mm_status(void *base_address, - unsigned int regshift, unsigned int counter_number) + unsigned int regshift, + unsigned int counter_number) { writeb(0xE0 | (2 << counter_number), - base_address + (i8254_control_reg << regshift)); + base_address + (i8254_control_reg << regshift)); return readb(base_address + (counter_number << regshift)); } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8255.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8255.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8255.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8255.c 2009-07-30 09:25:31.000000000 -0700 @@ -105,7 +105,8 @@ #define CALLBACK_FUNC (((struct subdev_8255_struct *)s->private)->cb_func) #define subdevpriv ((struct subdev_8255_struct *)s->private) -static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it); +static int dev_8255_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int dev_8255_detach(struct comedi_device *dev); static struct comedi_driver driver_8255 = { .driver_name = "8255", @@ -116,9 +117,10 @@ COMEDI_INITCLEANUP(driver_8255); -static void do_config(struct comedi_device *dev, struct comedi_subdevice * s); +static void do_config(struct comedi_device *dev, struct comedi_subdevice *s); -void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice * s) +void subdev_8255_interrupt(struct comedi_device *dev, + struct comedi_subdevice *s) { short d; @@ -143,8 +145,9 @@ } } -static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn *insn, unsigned int *data) +static int subdev_8255_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -152,13 +155,13 @@ if (data[0] & 0xff) CALLBACK_FUNC(1, _8255_DATA, s->state & 0xff, - CALLBACK_ARG); + CALLBACK_ARG); if (data[0] & 0xff00) CALLBACK_FUNC(1, _8255_DATA + 1, (s->state >> 8) & 0xff, - CALLBACK_ARG); + CALLBACK_ARG); if (data[0] & 0xff0000) CALLBACK_FUNC(1, _8255_DATA + 2, - (s->state >> 16) & 0xff, CALLBACK_ARG); + (s->state >> 16) & 0xff, CALLBACK_ARG); } data[1] = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG); @@ -168,8 +171,9 @@ return 2; } -static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn *insn, unsigned int *data) +static int subdev_8255_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; unsigned int bits; @@ -205,7 +209,7 @@ return 1; } -static void do_config(struct comedi_device *dev, struct comedi_subdevice * s) +static void do_config(struct comedi_device *dev, struct comedi_subdevice *s) { int config; @@ -222,8 +226,9 @@ CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG); } -static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_cmd *cmd) +static int subdev_8255_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -297,22 +302,25 @@ return 0; } -static int subdev_8255_cmd(struct comedi_device *dev, struct comedi_subdevice * s) +static int subdev_8255_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) { /* FIXME */ return 0; } -static int subdev_8255_cancel(struct comedi_device *dev, struct comedi_subdevice * s) +static int subdev_8255_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { /* FIXME */ return 0; } -int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice * s, int (*cb) (int, - int, int, unsigned long), unsigned long arg) +int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*cb) (int, int, int, unsigned long), + unsigned long arg) { s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; @@ -340,8 +348,9 @@ return 0; } -int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s, - int (*cb) (int, int, int, unsigned long), unsigned long arg) +int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, + int (*cb) (int, int, int, unsigned long), + unsigned long arg) { int ret; @@ -358,7 +367,7 @@ return 0; } -void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s) +void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { if (s->private) { /* this test does nothing, so comment it out @@ -376,7 +385,8 @@ */ -static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it) +static int dev_8255_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { int ret; unsigned long iobase; @@ -410,7 +420,7 @@ dev->subdevices[i].type = COMEDI_SUBD_UNUSED; } else { subdev_8255_init(dev, dev->subdevices + i, NULL, - iobase); + iobase); } } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8255.h linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8255.h --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/8255.h 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/8255.h 2009-07-30 09:25:31.000000000 -0700 @@ -29,16 +29,20 @@ #if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE) int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*cb) (int, int, int, unsigned long), unsigned long arg); + int (*cb) (int, int, int, unsigned long), + unsigned long arg); int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, - int (*cb) (int, int, int, unsigned long), unsigned long arg); + int (*cb) (int, int, int, unsigned long), + unsigned long arg); void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s); -void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice *s); +void subdev_8255_interrupt(struct comedi_device *dev, + struct comedi_subdevice *s); #else -static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - void *x, unsigned long y) +static inline int subdev_8255_init(struct comedi_device *dev, + struct comedi_subdevice *s, void *x, + unsigned long y) { printk("8255 support not configured -- disabling subdevice\n"); @@ -48,7 +52,7 @@ } static inline void subdev_8255_cleanup(struct comedi_device *dev, - struct comedi_subdevice *s) + struct comedi_subdevice *s) { } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/acl7225b.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/acl7225b.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/acl7225b.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/acl7225b.c 2009-07-30 09:25:31.000000000 -0700 @@ -22,7 +22,8 @@ #define ACL7225_DI_LO 2 /* Digital input low byte (DI0-DI7) */ #define ACL7225_DI_HI 3 /* Digital input high byte (DI8-DI15) */ -static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it); +static int acl7225b_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int acl7225b_detach(struct comedi_device *dev); struct boardtype { @@ -50,8 +51,9 @@ COMEDI_INITCLEANUP(driver_acl7225b); -static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn *insn, unsigned int *data) +static int acl7225b_do_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -64,26 +66,28 @@ outb(s->state & 0xff, dev->iobase + (unsigned long)s->private); if (data[0] & 0xff00) outb((s->state >> 8), - dev->iobase + (unsigned long)s->private + 1); + dev->iobase + (unsigned long)s->private + 1); data[1] = s->state; return 2; } -static int acl7225b_di_insn(struct comedi_device *dev, struct comedi_subdevice * s, - struct comedi_insn *insn, unsigned int *data) +static int acl7225b_di_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; data[1] = inb(dev->iobase + (unsigned long)s->private) | - (inb(dev->iobase + (unsigned long)s->private + 1) << 8); + (inb(dev->iobase + (unsigned long)s->private + 1) << 8); return 2; } -static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it) +static int acl7225b_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int iobase, iorange; @@ -91,7 +95,7 @@ iobase = it->options[0]; iorange = this_board->io_range; printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor, - this_board->name, iobase); + this_board->name, iobase); if (!request_region(iobase, iorange, "acl7225b")) { printk("I/O port conflict\n"); return -EIO; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci6208.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci6208.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci6208.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci6208.c 2009-07-30 09:25:31.000000000 -0700 @@ -66,23 +66,23 @@ static const struct pci6208_board pci6208_boards[] = { /*{ - .name = "pci6208v", - .dev_id = 0x6208, // not sure - .ao_chans = 8 - // , .ao_bits = 16 + .name = "pci6208v", + .dev_id = 0x6208, // not sure + .ao_chans = 8 + // , .ao_bits = 16 }, { - .name = "pci6216v", - .dev_id = 0x6208, // not sure - .ao_chans = 16 - // , .ao_bits = 16 + .name = "pci6216v", + .dev_id = 0x6208, // not sure + .ao_chans = 16 + // , .ao_bits = 16 }, */ { - .name = "pci6208a", - .dev_id = 0x6208, - .ao_chans = 8 - /* , .ao_bits = 16 */ - } + .name = "pci6208a", + .dev_id = 0x6208, + .ao_chans = 8 + /* , .ao_bits = 16 */ + } }; /* This is used by modprobe to translate PCI IDs to drivers. Should @@ -90,8 +90,9 @@ static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = { /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ - {PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci6208_pci_table); @@ -107,7 +108,8 @@ #define devpriv ((struct pci6208_private *)dev->private) -static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci6208_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci6208_detach(struct comedi_device *dev); static struct comedi_driver driver_pci6208 = { @@ -122,13 +124,15 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot); static int pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, - int dev_minor); + int dev_minor); /*read/write functions*/ -static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int pci6208_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pci6208_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data); */ /* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */ @@ -140,7 +144,8 @@ * in the driver structure, dev->board_ptr contains that * address. */ -static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci6208_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int retval; @@ -217,8 +222,9 @@ return 0; } -static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci6208_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i = 0, Data_Read; unsigned short chan = CR_CHAN(insn->chanspec); @@ -242,8 +248,9 @@ /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci6208_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -309,8 +316,8 @@ int i; for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) { for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) { if (pci6208_boards[i].dev_id == pci_dev->device) { @@ -318,9 +325,9 @@ if ((bus != 0) || (slot != 0)) { /* are we on the wrong bus/slot? */ if (pci_dev->bus->number - != bus || - PCI_SLOT(pci_dev->devfn) - != slot) { + != bus || + PCI_SLOT(pci_dev->devfn) + != slot) { continue; } } @@ -332,16 +339,16 @@ } printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + dev->minor, bus, slot); return -EIO; - found: +found: printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n", - dev->minor, - pci6208_boards[i].name, - pci_dev->bus->number, - PCI_SLOT(pci_dev->devfn), - PCI_FUNC(pci_dev->devfn), pci_dev->irq); + dev->minor, + pci6208_boards[i].name, + pci_dev->bus->number, + PCI_SLOT(pci_dev->devfn), + PCI_FUNC(pci_dev->devfn), pci_dev->irq); /* TODO: Warn about non-tested boards. */ /* switch(board->device_id) */ @@ -355,13 +362,15 @@ static int pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, - int dev_minor) + int dev_minor) { unsigned long io_base, io_range, lcr_io_base, lcr_io_range; /* Enable PCI device and request regions */ if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) { - printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor); + printk + ("comedi%d: Failed to enable PCI device and request regions\n", + dev_minor); return -EIO; } /* Read local configuration register base address [PCI_BASE_ADDRESS #1]. */ @@ -369,14 +378,14 @@ lcr_io_range = pci_resource_len(pci_dev, 1); printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n", - dev_minor, lcr_io_base, lcr_io_range); + dev_minor, lcr_io_base, lcr_io_range); /* Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */ io_base = pci_resource_start(pci_dev, 2); io_range = pci_resource_end(pci_dev, 2) - io_base + 1; printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n", - dev_minor, io_base, io_range); + dev_minor, io_base, io_range); *io_base_ptr = io_base; /* devpriv->io_range = io_range; */ diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci7296.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci7296.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci7296.c 2009-07-24 11:07:44.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci7296.c 2009-07-30 09:25:31.000000000 -0700 @@ -49,9 +49,10 @@ #define PCI_DEVICE_ID_PCI7296 0x7296 static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = { - {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, PCI_ANY_ID, 0, - 0, 0}, - {0} + { + PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table); @@ -61,10 +62,10 @@ struct pci_dev *pci_dev; }; - #define devpriv ((struct adl_pci7296_private *)dev->private) -static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci7296_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int adl_pci7296_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci7296 = { .driver_name = "adl_pci7296", @@ -73,7 +74,8 @@ .detach = adl_pci7296_detach, }; -static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int adl_pci7296_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -94,21 +96,23 @@ return -ENOMEM; for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pcidev != NULL; - pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && - pcidev->device == PCI_DEVICE_ID_PCI7296) { + pcidev->device == PCI_DEVICE_ID_PCI7296) { if (bus || slot) { /* requested particular bus/slot */ if (pcidev->bus->number != bus - || PCI_SLOT(pcidev->devfn) != slot) { + || PCI_SLOT(pcidev->devfn) != slot) { continue; } } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) { - printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); + printk + ("comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); return -EIO; } @@ -118,23 +122,26 @@ /* four 8255 digital io subdevices */ s = dev->subdevices + 0; subdev_8255_init(dev, s, NULL, - (unsigned long)(dev->iobase)); + (unsigned long)(dev->iobase)); s = dev->subdevices + 1; ret = subdev_8255_init(dev, s, NULL, - (unsigned long)(dev->iobase + PORT2A)); + (unsigned long)(dev->iobase + + PORT2A)); if (ret < 0) return ret; s = dev->subdevices + 2; ret = subdev_8255_init(dev, s, NULL, - (unsigned long)(dev->iobase + PORT3A)); + (unsigned long)(dev->iobase + + PORT3A)); if (ret < 0) return ret; s = dev->subdevices + 3; ret = subdev_8255_init(dev, s, NULL, - (unsigned long)(dev->iobase + PORT4A)); + (unsigned long)(dev->iobase + + PORT4A)); if (ret < 0) return ret; @@ -145,7 +152,7 @@ } printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + dev->minor, bus, slot); return -EIO; } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci7432.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci7432.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci7432.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci7432.c 2009-07-30 09:25:31.000000000 -0700 @@ -44,9 +44,10 @@ #define PCI_DEVICE_ID_PCI7432 0x7432 static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = { - {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, PCI_ANY_ID, 0, - 0, 0}, - {0} + { + PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table); @@ -58,7 +59,8 @@ #define devpriv ((struct adl_pci7432_private *)dev->private) -static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci7432_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int adl_pci7432_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci7432 = { .driver_name = "adl_pci7432", @@ -69,15 +71,20 @@ /* Digital IO */ -static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); - -static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci7432_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); + +static int adl_pci7432_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); /* */ -static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int adl_pci7432_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -97,21 +104,23 @@ return -ENOMEM; for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pcidev != NULL; - pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && - pcidev->device == PCI_DEVICE_ID_PCI7432) { + pcidev->device == PCI_DEVICE_ID_PCI7432) { if (bus || slot) { /* requested particular bus/slot */ if (pcidev->bus->number != bus - || PCI_SLOT(pcidev->devfn) != slot) { + || PCI_SLOT(pcidev->devfn) != slot) { continue; } } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) { - printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); + printk + ("comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); return -EIO; } dev->iobase = pci_resource_start(pcidev, 2); @@ -120,7 +129,7 @@ s = dev->subdevices + 0; s->type = COMEDI_SUBD_DI; s->subdev_flags = - SDF_READABLE | SDF_GROUND | SDF_COMMON; + SDF_READABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 32; s->maxdata = 1; s->len_chanlist = 32; @@ -131,7 +140,7 @@ s = dev->subdevices + 1; s->type = COMEDI_SUBD_DO; s->subdev_flags = - SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 32; s->maxdata = 1; s->len_chanlist = 32; @@ -146,7 +155,7 @@ } printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + dev->minor, bus, slot); return -EIO; } @@ -164,8 +173,10 @@ return 0; } -static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci7432_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { printk("comedi: pci7432_do_insn_bits called\n"); printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); @@ -178,14 +189,16 @@ s->state |= (data[0] & data[1]); printk("comedi: out: %8x on iobase %4lx\n", s->state, - dev->iobase + PCI7432_DO); + dev->iobase + PCI7432_DO); outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO); } return 2; } -static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci7432_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { printk("comedi: pci7432_di_insn_bits called\n"); printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci8164.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci8164.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci8164.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci8164.c 2009-07-30 09:25:31.000000000 -0700 @@ -56,9 +56,10 @@ #define PCI_DEVICE_ID_PCI8164 0x8164 static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = { - {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, PCI_ANY_ID, 0, - 0, 0}, - {0} + { + PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table); @@ -70,7 +71,8 @@ #define devpriv ((struct adl_pci8164_private *)dev->private) -static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adl_pci8164_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int adl_pci8164_detach(struct comedi_device *dev); static struct comedi_driver driver_adl_pci8164 = { .driver_name = "adl_pci8164", @@ -79,31 +81,48 @@ .detach = adl_pci8164_detach, }; -static int adl_pci8164_insn_read_msts(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_read_msts(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int adl_pci8164_insn_write_otp(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); static int adl_pci8164_insn_write_buf0(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int adl_pci8164_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct pci_dev *pcidev; struct comedi_subdevice *s; @@ -123,21 +142,23 @@ return -ENOMEM; for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pcidev != NULL; - pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && - pcidev->device == PCI_DEVICE_ID_PCI8164) { + pcidev->device == PCI_DEVICE_ID_PCI8164) { if (bus || slot) { /* requested particular bus/slot */ if (pcidev->bus->number != bus - || PCI_SLOT(pcidev->devfn) != slot) { + || PCI_SLOT(pcidev->devfn) != slot) { continue; } } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) { - printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); + printk + ("comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); return -EIO; } dev->iobase = pci_resource_start(pcidev, 2); @@ -190,7 +211,7 @@ } printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + dev->minor, bus, slot); return -EIO; } @@ -216,8 +237,7 @@ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data, - char *action, - unsigned short offset) + char *action, unsigned short offset) { int axis, axis_reg; char *axisname; @@ -247,8 +267,8 @@ } data[0] = inw(dev->iobase + axis_reg + offset); - printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, data[0], - data[1], axisname); + printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, + data[0], data[1], axisname); } static int adl_pci8164_insn_read_msts(struct comedi_device *dev, @@ -260,22 +280,28 @@ return 2; } -static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_read(dev, s, insn, data, "SSTS", PCI8164_SSTS); return 2; } -static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_read(dev, s, insn, data, "BUF0", PCI8164_BUF0); return 2; } -static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1); return 2; @@ -286,11 +312,10 @@ * const to the data for outw() */ static void adl_pci8164_insn_out(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data, - char *action, - unsigned short offset) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data, + char *action, unsigned short offset) { unsigned int axis, axis_reg; @@ -327,30 +352,37 @@ } - -static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD); return 2; } -static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adl_pci8164_insn_write_otp(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP); return 2; } static int adl_pci8164_insn_write_buf0(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_out(dev, s, insn, data, "BUF0", PCI8164_BUF0); return 2; } static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { adl_pci8164_insn_out(dev, s, insn, data, "BUF1", PCI8164_BUF1); return 2; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci9111.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci9111.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci9111.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci9111.c 2009-07-30 09:25:31.000000000 -0700 @@ -264,27 +264,32 @@ /* Function prototypes */ -static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci9111_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci9111_detach(struct comedi_device *dev); -static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, - void *data, unsigned int num_bytes, unsigned int start_chan_index); +static void pci9111_ai_munge(struct comedi_device *dev, + struct comedi_subdevice *s, void *data, + unsigned int num_bytes, + unsigned int start_chan_index); static const struct comedi_lrange pci9111_hr_ai_range = { 5, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625) - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + BIP_RANGE(0.625) + } }; static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = { - {PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, - 0, 0}, - /* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ - {0} + { + PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, + /* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */ + { + 0} }; MODULE_DEVICE_TABLE(pci, pci9111_pci_table); @@ -309,17 +314,17 @@ static const struct pci9111_board pci9111_boards[] = { { - .name = "pci9111_hr", - .device_id = PCI9111_HR_DEVICE_ID, - .ai_channel_nbr = PCI9111_AI_CHANNEL_NBR, - .ao_channel_nbr = PCI9111_AO_CHANNEL_NBR, - .ai_resolution = PCI9111_HR_AI_RESOLUTION, - .ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK, - .ao_resolution = PCI9111_AO_RESOLUTION, - .ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK, - .ai_range_list = &pci9111_hr_ai_range, - .ao_range_list = &range_bipolar10, - .ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS} + .name = "pci9111_hr", + .device_id = PCI9111_HR_DEVICE_ID, + .ai_channel_nbr = PCI9111_AI_CHANNEL_NBR, + .ao_channel_nbr = PCI9111_AO_CHANNEL_NBR, + .ai_resolution = PCI9111_HR_AI_RESOLUTION, + .ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK, + .ao_resolution = PCI9111_AO_RESOLUTION, + .ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK, + .ai_range_list = &pci9111_hr_ai_range, + .ao_range_list = &range_bipolar10, + .ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS} }; #define pci9111_board_nbr \ @@ -379,9 +384,11 @@ #define PLX9050_SOFTWARE_INTERRUPT (1 << 7) static void plx9050_interrupt_control(unsigned long io_base, - bool LINTi1_enable, - bool LINTi1_active_high, - bool LINTi2_enable, bool LINTi2_active_high, bool interrupt_enable) + bool LINTi1_enable, + bool LINTi1_active_high, + bool LINTi2_enable, + bool LINTi2_active_high, + bool interrupt_enable) { int flags = 0; @@ -409,16 +416,19 @@ static void pci9111_timer_set(struct comedi_device *dev) { pci9111_8254_control_set(PCI9111_8254_COUNTER_0 | - PCI9111_8254_READ_LOAD_LSB_MSB | - PCI9111_8254_MODE_0 | PCI9111_8254_BINARY_COUNTER); + PCI9111_8254_READ_LOAD_LSB_MSB | + PCI9111_8254_MODE_0 | + PCI9111_8254_BINARY_COUNTER); pci9111_8254_control_set(PCI9111_8254_COUNTER_1 | - PCI9111_8254_READ_LOAD_LSB_MSB | - PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER); + PCI9111_8254_READ_LOAD_LSB_MSB | + PCI9111_8254_MODE_2 | + PCI9111_8254_BINARY_COUNTER); pci9111_8254_control_set(PCI9111_8254_COUNTER_2 | - PCI9111_8254_READ_LOAD_LSB_MSB | - PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER); + PCI9111_8254_READ_LOAD_LSB_MSB | + PCI9111_8254_MODE_2 | + PCI9111_8254_BINARY_COUNTER); udelay(1); @@ -433,7 +443,7 @@ }; static void pci9111_trigger_source_set(struct comedi_device *dev, - enum pci9111_trigger_sources source) + enum pci9111_trigger_sources source) { int flags; @@ -491,7 +501,8 @@ }; static void pci9111_interrupt_source_set(struct comedi_device *dev, - enum pci9111_ISC0_sources irq_0_source, enum pci9111_ISC1_sources irq_1_source) + enum pci9111_ISC0_sources irq_0_source, + enum pci9111_ISC1_sources irq_1_source) { int flags; @@ -514,12 +525,13 @@ #undef AI_DO_CMD_DEBUG -static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci9111_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { /* Disable interrupts */ plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true, - true, false); + true, false); pci9111_trigger_source_set(dev, software); @@ -543,19 +555,19 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_cmd *cmd) + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int tmp; int error = 0; int range, reference; int i; - struct pci9111_board *board = (struct pci9111_board *) dev->board_ptr; + struct pci9111_board *board = (struct pci9111_board *)dev->board_ptr; /* Step 1 : check if trigger are trivialy valid */ pci9111_check_trigger_src(cmd->start_src, TRIG_NOW); pci9111_check_trigger_src(cmd->scan_begin_src, - TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT); + TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT); pci9111_check_trigger_src(cmd->convert_src, TRIG_TIMER | TRIG_EXT); pci9111_check_trigger_src(cmd->scan_end_src, TRIG_COUNT); pci9111_check_trigger_src(cmd->stop_src, TRIG_COUNT | TRIG_NONE); @@ -569,21 +581,21 @@ error++; if ((cmd->scan_begin_src != TRIG_TIMER) && - (cmd->scan_begin_src != TRIG_FOLLOW) && - (cmd->scan_begin_src != TRIG_EXT)) + (cmd->scan_begin_src != TRIG_FOLLOW) && + (cmd->scan_begin_src != TRIG_EXT)) error++; if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) { error++; } if ((cmd->convert_src == TRIG_TIMER) && - !((cmd->scan_begin_src == TRIG_TIMER) || - (cmd->scan_begin_src == TRIG_FOLLOW))) { + !((cmd->scan_begin_src == TRIG_TIMER) || + (cmd->scan_begin_src == TRIG_FOLLOW))) { error++; } if ((cmd->convert_src == TRIG_EXT) && - !((cmd->scan_begin_src == TRIG_EXT) || - (cmd->scan_begin_src == TRIG_FOLLOW))) { + !((cmd->scan_begin_src == TRIG_EXT) || + (cmd->scan_begin_src == TRIG_FOLLOW))) { error++; } @@ -613,7 +625,7 @@ } if ((cmd->convert_src == TRIG_TIMER) && - (cmd->convert_arg < board->ai_acquisition_period_min_ns)) { + (cmd->convert_arg < board->ai_acquisition_period_min_ns)) { cmd->convert_arg = board->ai_acquisition_period_min_ns; error++; } @@ -623,7 +635,7 @@ } if ((cmd->scan_begin_src == TRIG_TIMER) && - (cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) { + (cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) { cmd->scan_begin_arg = board->ai_acquisition_period_min_ns; error++; } @@ -637,7 +649,7 @@ } if ((cmd->scan_end_src == TRIG_COUNT) && - (cmd->scan_end_arg != cmd->chanlist_len)) { + (cmd->scan_end_arg != cmd->chanlist_len)) { cmd->scan_end_arg = cmd->chanlist_len; error++; } @@ -659,9 +671,10 @@ if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS, - &(dev_private->timer_divisor_1), - &(dev_private->timer_divisor_2), - &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK); + &(dev_private->timer_divisor_1), + &(dev_private->timer_divisor_2), + &(cmd->convert_arg), + cmd->flags & TRIG_ROUND_MASK); if (tmp != cmd->convert_arg) error++; } @@ -679,7 +692,7 @@ if (cmd->scan_begin_arg != scan_begin_min) { if (scan_begin_min < cmd->scan_begin_arg) { scan_factor = - cmd->scan_begin_arg / scan_begin_min; + cmd->scan_begin_arg / scan_begin_min; scan_begin_arg = scan_factor * scan_begin_min; if (cmd->scan_begin_arg != scan_begin_arg) { cmd->scan_begin_arg = scan_begin_arg; @@ -706,27 +719,27 @@ for (i = 0; i < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i]) != i) { comedi_error(dev, - "entries in chanlist must be consecutive " - "channels,counting upwards from 0\n"); + "entries in chanlist must be consecutive " + "channels,counting upwards from 0\n"); error++; } if (CR_RANGE(cmd->chanlist[i]) != range) { comedi_error(dev, - "entries in chanlist must all have the same gain\n"); + "entries in chanlist must all have the same gain\n"); error++; } if (CR_AREF(cmd->chanlist[i]) != reference) { comedi_error(dev, - "entries in chanlist must all have the same reference\n"); + "entries in chanlist must all have the same reference\n"); error++; } } } else { if ((CR_CHAN(cmd->chanlist[0]) > - (board->ai_channel_nbr - 1)) - || (CR_CHAN(cmd->chanlist[0]) < 0)) { + (board->ai_channel_nbr - 1)) + || (CR_CHAN(cmd->chanlist[0]) < 0)) { comedi_error(dev, - "channel number is out of limits\n"); + "channel number is out of limits\n"); error++; } } @@ -741,13 +754,14 @@ /* Analog input command */ -static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice) +static int pci9111_ai_do_cmd(struct comedi_device *dev, + struct comedi_subdevice *subdevice) { struct comedi_cmd *async_cmd = &subdevice->async->cmd; if (!dev->irq) { comedi_error(dev, - "no irq assigned for PCI9111, cannot do hardware conversion"); + "no irq assigned for PCI9111, cannot do hardware conversion"); return -1; } /* Set channel scan limit */ @@ -772,7 +786,7 @@ switch (async_cmd->stop_src) { case TRIG_COUNT: dev_private->stop_counter = - async_cmd->stop_arg * async_cmd->chanlist_len; + async_cmd->stop_arg * async_cmd->chanlist_len; dev_private->stop_is_none = 0; break; @@ -792,28 +806,29 @@ switch (async_cmd->convert_src) { case TRIG_TIMER: i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS, - &(dev_private->timer_divisor_1), - &(dev_private->timer_divisor_2), - &(async_cmd->convert_arg), - async_cmd->flags & TRIG_ROUND_MASK); + &(dev_private->timer_divisor_1), + &(dev_private->timer_divisor_2), + &(async_cmd->convert_arg), + async_cmd-> + flags & TRIG_ROUND_MASK); #ifdef AI_DO_CMD_DEBUG printk(PCI9111_DRIVER_NAME ": divisors = %d, %d\n", - dev_private->timer_divisor_1, - dev_private->timer_divisor_2); + dev_private->timer_divisor_1, + dev_private->timer_divisor_2); #endif pci9111_trigger_source_set(dev, software); pci9111_timer_set(dev); pci9111_fifo_reset(); pci9111_interrupt_source_set(dev, irq_on_fifo_half_full, - irq_on_timer_tick); + irq_on_timer_tick); pci9111_trigger_source_set(dev, timer_pacer); plx9050_interrupt_control(dev_private->lcr_io_base, true, true, - false, true, true); + false, true, true); dev_private->scan_delay = - (async_cmd->scan_begin_arg / (async_cmd->convert_arg * - async_cmd->chanlist_len)) - 1; + (async_cmd->scan_begin_arg / (async_cmd->convert_arg * + async_cmd->chanlist_len)) - 1; break; @@ -822,9 +837,9 @@ pci9111_trigger_source_set(dev, external); pci9111_fifo_reset(); pci9111_interrupt_source_set(dev, irq_on_fifo_half_full, - irq_on_timer_tick); + irq_on_timer_tick); plx9050_interrupt_control(dev_private->lcr_io_base, true, true, - false, true, true); + false, true, true); break; @@ -837,45 +852,47 @@ dev_private->chanlist_len = async_cmd->chanlist_len; dev_private->chunk_counter = 0; dev_private->chunk_num_samples = - dev_private->chanlist_len * (1 + dev_private->scan_delay); + dev_private->chanlist_len * (1 + dev_private->scan_delay); #ifdef AI_DO_CMD_DEBUG printk(PCI9111_DRIVER_NAME ": start interruptions!\n"); printk(PCI9111_DRIVER_NAME ": trigger source = %2x\n", - pci9111_trigger_and_autoscan_get()); + pci9111_trigger_and_autoscan_get()); printk(PCI9111_DRIVER_NAME ": irq source = %2x\n", - pci9111_interrupt_and_fifo_get()); + pci9111_interrupt_and_fifo_get()); printk(PCI9111_DRIVER_NAME ": ai_do_cmd\n"); printk(PCI9111_DRIVER_NAME ": stop counter = %d\n", - dev_private->stop_counter); + dev_private->stop_counter); printk(PCI9111_DRIVER_NAME ": scan delay = %d\n", - dev_private->scan_delay); + dev_private->scan_delay); printk(PCI9111_DRIVER_NAME ": chanlist_len = %d\n", - dev_private->chanlist_len); + dev_private->chanlist_len); printk(PCI9111_DRIVER_NAME ": chunk num samples = %d\n", - dev_private->chunk_num_samples); + dev_private->chunk_num_samples); #endif return 0; } -static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, - void *data, unsigned int num_bytes, unsigned int start_chan_index) +static void pci9111_ai_munge(struct comedi_device *dev, + struct comedi_subdevice *s, void *data, + unsigned int num_bytes, + unsigned int start_chan_index) { unsigned int i, num_samples = num_bytes / sizeof(short); short *array = data; int resolution = - ((struct pci9111_board *) dev->board_ptr)->ai_resolution; + ((struct pci9111_board *)dev->board_ptr)->ai_resolution; for (i = 0; i < num_samples; i++) { if (resolution == PCI9111_HR_AI_RESOLUTION) array[i] = - (array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^ - PCI9111_HR_AI_RESOLUTION_2_CMP_BIT; + (array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^ + PCI9111_HR_AI_RESOLUTION_2_CMP_BIT; else array[i] = - ((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^ - PCI9111_AI_RESOLUTION_2_CMP_BIT; + ((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^ + PCI9111_AI_RESOLUTION_2_CMP_BIT; } } @@ -905,18 +922,12 @@ /* Check if we are source of interrupt */ intcsr = inb(dev_private->lcr_io_base + - PLX9050_REGISTER_INTERRUPT_CONTROL); + PLX9050_REGISTER_INTERRUPT_CONTROL); if (!(((intcsr & PLX9050_PCI_INTERRUPT_ENABLE) != 0) - && (((intcsr & (PLX9050_LINTI1_ENABLE | - PLX9050_LINTI1_STATUS)) - == - (PLX9050_LINTI1_ENABLE | - PLX9050_LINTI1_STATUS)) - || ((intcsr & (PLX9050_LINTI2_ENABLE | - PLX9050_LINTI2_STATUS)) - == - (PLX9050_LINTI2_ENABLE | - PLX9050_LINTI2_STATUS))))) { + && (((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) + == (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) + || ((intcsr & (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS)) + == (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS))))) { /* Not the source of the interrupt. */ /* (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */ spin_unlock_irqrestore(&dev->spinlock, irq_flags); @@ -924,12 +935,11 @@ } if ((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) == - (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) { + (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) { /* Interrupt comes from fifo_half-full signal */ if (pci9111_is_fifo_full()) { - spin_unlock_irqrestore(&dev->spinlock, - irq_flags); + spin_unlock_irqrestore(&dev->spinlock, irq_flags); comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow"); pci9111_interrupt_clear(); pci9111_ai_cancel(dev, subdevice); @@ -948,73 +958,70 @@ #endif num_samples = - PCI9111_FIFO_HALF_SIZE > - dev_private->stop_counter - && !dev_private->stop_is_none ? dev_private-> - stop_counter : PCI9111_FIFO_HALF_SIZE; + PCI9111_FIFO_HALF_SIZE > + dev_private->stop_counter + && !dev_private-> + stop_is_none ? dev_private->stop_counter : + PCI9111_FIFO_HALF_SIZE; insw(PCI9111_IO_BASE + PCI9111_REGISTER_AD_FIFO_VALUE, - dev_private->ai_bounce_buffer, num_samples); + dev_private->ai_bounce_buffer, num_samples); if (dev_private->scan_delay < 1) { bytes_written = - cfc_write_array_to_buffer(subdevice, - dev_private->ai_bounce_buffer, - num_samples * sizeof(short)); + cfc_write_array_to_buffer(subdevice, + dev_private-> + ai_bounce_buffer, + num_samples * + sizeof(short)); } else { int position = 0; int to_read; while (position < num_samples) { if (dev_private->chunk_counter < - dev_private->chanlist_len) { + dev_private->chanlist_len) { to_read = - dev_private-> - chanlist_len - - dev_private-> - chunk_counter; + dev_private->chanlist_len - + dev_private->chunk_counter; if (to_read > - num_samples - position) + num_samples - position) to_read = - num_samples - - position; + num_samples - + position; bytes_written += - cfc_write_array_to_buffer - (subdevice, - dev_private-> - ai_bounce_buffer + - position, - to_read * - sizeof(short)); + cfc_write_array_to_buffer + (subdevice, + dev_private->ai_bounce_buffer + + position, + to_read * sizeof(short)); } else { to_read = - dev_private-> - chunk_num_samples - - dev_private-> - chunk_counter; + dev_private->chunk_num_samples + - + dev_private->chunk_counter; if (to_read > - num_samples - position) + num_samples - position) to_read = - num_samples - - position; + num_samples - + position; bytes_written += - sizeof(short) * - to_read; + sizeof(short) * to_read; } position += to_read; dev_private->chunk_counter += to_read; if (dev_private->chunk_counter >= - dev_private->chunk_num_samples) + dev_private->chunk_num_samples) dev_private->chunk_counter = 0; } } dev_private->stop_counter -= - bytes_written / sizeof(short); + bytes_written / sizeof(short); } } @@ -1044,17 +1051,18 @@ #undef AI_INSN_DEBUG static int pci9111_ai_insn_read(struct comedi_device *dev, - struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *subdevice, + struct comedi_insn *insn, unsigned int *data) { int resolution = - ((struct pci9111_board *) dev->board_ptr)->ai_resolution; + ((struct pci9111_board *)dev->board_ptr)->ai_resolution; int timeout, i; #ifdef AI_INSN_DEBUG printk(PCI9111_DRIVER_NAME ": ai_insn set c/r/n = %2x/%2x/%2x\n", - CR_CHAN((&insn->chanspec)[0]), - CR_RANGE((&insn->chanspec)[0]), insn->n); + CR_CHAN((&insn->chanspec)[0]), + CR_RANGE((&insn->chanspec)[0]), insn->n); #endif pci9111_ai_channel_set(CR_CHAN((&insn->chanspec)[0])); @@ -1080,7 +1088,7 @@ pci9111_fifo_reset(); return -ETIME; - conversion_done: +conversion_done: if (resolution == PCI9111_HR_AI_RESOLUTION) { data[i] = pci9111_hr_ai_get_data(); @@ -1091,8 +1099,8 @@ #ifdef AI_INSN_DEBUG printk(PCI9111_DRIVER_NAME ": ai_insn get c/r/t = %2x/%2x/%2x\n", - pci9111_ai_channel_get(), - pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get()); + pci9111_ai_channel_get(), + pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get()); #endif return i; @@ -1102,7 +1110,8 @@ static int pci9111_ao_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { int i; @@ -1117,7 +1126,8 @@ /* Analog output readback */ static int pci9111_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; @@ -1135,7 +1145,8 @@ /* Digital inputs */ static int pci9111_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *subdevice, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -1148,7 +1159,8 @@ /* Digital outputs */ static int pci9111_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *subdevice, + struct comedi_insn *insn, unsigned int *data) { unsigned int bits; @@ -1181,7 +1193,7 @@ /* Set trigger source to software */ plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true, - true, false); + true, false); pci9111_trigger_source_set(dev, software); pci9111_pretrigger_set(dev, false); @@ -1201,7 +1213,8 @@ /* - Register PCI device */ /* - Declare device driver capability */ -static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci9111_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *subdevice; unsigned long io_base, io_range, lcr_io_base, lcr_io_range; @@ -1217,29 +1230,29 @@ printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n", dev->minor); for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pci_device != NULL; - pci_device = - pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { + pci_device != NULL; + pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) { for (i = 0; i < pci9111_board_nbr; i++) { if (pci9111_boards[i].device_id == - pci_device->device) { + pci_device->device) { /* was a particular bus/slot requested? */ if ((it->options[0] != 0) - || (it->options[1] != 0)) { + || (it->options[1] != 0)) { /* are we on the wrong bus/slot? */ if (pci_device->bus->number != - it->options[0] - || PCI_SLOT(pci_device-> - devfn) != - it->options[1]) { + it->options[0] + || + PCI_SLOT(pci_device->devfn) + != it->options[1]) { continue; } } dev->board_ptr = pci9111_boards + i; - board = (struct pci9111_board *) dev-> - board_ptr; + board = + (struct pci9111_board *) + dev->board_ptr; dev_private->pci_device = pci_device; goto found; } @@ -1248,17 +1261,17 @@ } printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, it->options[0], it->options[1]); + dev->minor, it->options[0], it->options[1]); return -EIO; - found: +found: printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n", - dev->minor, - pci9111_boards[i].name, - pci_device->bus->number, - PCI_SLOT(pci_device->devfn), - PCI_FUNC(pci_device->devfn), pci_device->irq); + dev->minor, + pci9111_boards[i].name, + pci_device->bus->number, + PCI_SLOT(pci_device->devfn), + PCI_FUNC(pci_device->devfn), pci_device->irq); /* TODO: Warn about non-tested boards. */ @@ -1270,11 +1283,15 @@ lcr_io_base = pci_resource_start(pci_device, 1); lcr_io_range = pci_resource_len(pci_device, 1); - printk("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n", dev->minor, lcr_io_base, lcr_io_range); + printk + ("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n", + dev->minor, lcr_io_base, lcr_io_range); /* Enable PCI device and request regions */ if (comedi_pci_enable(pci_device, PCI9111_DRIVER_NAME) < 0) { - printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); + printk + ("comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); return -EIO; } /* Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. */ @@ -1283,7 +1300,7 @@ io_range = pci_resource_len(pci_device, 2); printk("comedi%d: 6503 registers at address 0x%4lx [0x%4lx]\n", - dev->minor, io_base, io_range); + dev->minor, io_base, io_range); dev->iobase = io_base; dev->board_name = board->name; @@ -1301,7 +1318,7 @@ if (request_irq(pci_device->irq, pci9111_interrupt, IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) { printk("comedi%d: unable to allocate irq %u\n", - dev->minor, pci_device->irq); + dev->minor, pci_device->irq); return -EINVAL; } } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci9118.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci9118.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adl_pci9118.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adl_pci9118.c 2009-07-30 09:25:31.000000000 -0700 @@ -154,32 +154,33 @@ #define EXTTRG_AI 0 /* ext trg is used by AI */ static const struct comedi_lrange range_pci9118dg_hr = { 8, { - 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) - } + 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_pci9118hg = { 8, { - BIP_RANGE(5), - BIP_RANGE(0.5), - BIP_RANGE(0.05), - BIP_RANGE(0.005), - UNI_RANGE(10), - UNI_RANGE(1), - UNI_RANGE(0.1), - UNI_RANGE(0.01) - } + BIP_RANGE(5), + BIP_RANGE(0.5), + BIP_RANGE(0.05), + BIP_RANGE(0.005), + UNI_RANGE(10), + UNI_RANGE(1), + UNI_RANGE(0.1), + UNI_RANGE(0.01) + } }; #define PCI9118_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */ -static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci9118_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci9118_detach(struct comedi_device *dev); struct boardtype { @@ -204,28 +205,29 @@ }; static DEFINE_PCI_DEVICE_TABLE(pci9118_pci_table) = { - {PCI_VENDOR_ID_AMCC, 0x80d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMCC, 0x80d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci9118_pci_table); static const struct boardtype boardtypes[] = { {"pci9118dg", PCI_VENDOR_ID_AMCC, 0x80d9, - AMCC_OP_REG_SIZE, IORANGE_9118, - 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff, - &range_pci9118dg_hr, &range_bipolar10, - 3000, 12, 512}, + AMCC_OP_REG_SIZE, IORANGE_9118, + 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff, + &range_pci9118dg_hr, &range_bipolar10, + 3000, 12, 512}, {"pci9118hg", PCI_VENDOR_ID_AMCC, 0x80d9, - AMCC_OP_REG_SIZE, IORANGE_9118, - 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff, - &range_pci9118hg, &range_bipolar10, - 3000, 12, 512}, + AMCC_OP_REG_SIZE, IORANGE_9118, + 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff, + &range_pci9118hg, &range_bipolar10, + 3000, 12, 512}, {"pci9118hr", PCI_VENDOR_ID_AMCC, 0x80d9, - AMCC_OP_REG_SIZE, IORANGE_9118, - 16, 8, 256, PCI9118_CHANLEN, 2, 0xffff, 0x0fff, - &range_pci9118dg_hr, &range_bipolar10, - 10000, 40, 512}, + AMCC_OP_REG_SIZE, IORANGE_9118, + 16, 8, 256, PCI9118_CHANLEN, 2, 0xffff, 0x0fff, + &range_pci9118dg_hr, &range_bipolar10, + 10000, 40, 512}, }; #define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype)) @@ -309,27 +311,34 @@ ============================================================================== */ -static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist, int frontadd, int backadd); -static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd, - int usedma, char eoshandle); -static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, - unsigned int divisor2); +static int check_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, int n_chan, + unsigned int *chanlist, int frontadd, + int backadd); +static int setup_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, int n_chan, + unsigned int *chanlist, int rot, int frontadd, + int backadd, int usedma, char eoshandle); +static void start_pacer(struct comedi_device *dev, int mode, + unsigned int divisor1, unsigned int divisor2); static int pci9118_reset(struct comedi_device *dev); static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source); static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source); -static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci9118_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s); static void pci9118_calc_divisors(char mode, struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2, - unsigned int flags, int chans, unsigned int *div1, unsigned int *div2, - char usessh, unsigned int chnsshfront); + struct comedi_subdevice *s, + unsigned int *tim1, unsigned int *tim2, + unsigned int flags, int chans, + unsigned int *div1, unsigned int *div2, + char usessh, unsigned int chnsshfront); /* ============================================================================== */ -static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci9118_insn_read_ai(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, timeout; @@ -358,15 +367,14 @@ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return -ETIME; - conv_finish: +conv_finish: if (devpriv->ai16bits) { data[n] = - (inl(dev->iobase + - PCI9118_AD_DATA) & 0xffff) ^ 0x8000; + (inl(dev->iobase + + PCI9118_AD_DATA) & 0xffff) ^ 0x8000; } else { data[n] = - (inw(dev->iobase + - PCI9118_AD_DATA) >> 4) & 0xfff; + (inw(dev->iobase + PCI9118_AD_DATA) >> 4) & 0xfff; } } @@ -378,8 +386,9 @@ /* ============================================================================== */ -static int pci9118_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci9118_insn_write_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chanreg, ch; @@ -401,8 +410,9 @@ /* ============================================================================== */ -static int pci9118_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci9118_insn_read_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -416,8 +426,9 @@ /* ============================================================================== */ -static int pci9118_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci9118_insn_bits_di(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inl(dev->iobase + PCI9118_DI) & 0xf; @@ -427,8 +438,9 @@ /* ============================================================================== */ -static int pci9118_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci9118_insn_bits_do(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -446,29 +458,31 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev) { devpriv->AdFunctionReg = - AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM; + AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM; outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); outl(0x30, dev->iobase + PCI9118_CNTCTRL); outl((devpriv->dmabuf_hw[1 - devpriv->dma_actbuf] >> 1) & 0xff, - dev->iobase + PCI9118_CNT0); + dev->iobase + PCI9118_CNT0); outl((devpriv->dmabuf_hw[1 - devpriv->dma_actbuf] >> 9) & 0xff, - dev->iobase + PCI9118_CNT0); + dev->iobase + PCI9118_CNT0); devpriv->AdFunctionReg |= AdFunction_Start; outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); } static unsigned int defragment_dma_buffer(struct comedi_device *dev, - struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) + struct comedi_subdevice *s, + short *dma_buffer, + unsigned int num_samples) { unsigned int i = 0, j = 0; unsigned int start_pos = devpriv->ai_add_front, - stop_pos = devpriv->ai_add_front + devpriv->ai_n_chan; + stop_pos = devpriv->ai_add_front + devpriv->ai_n_chan; unsigned int raw_scanlen = devpriv->ai_add_front + devpriv->ai_n_chan + - devpriv->ai_add_back; + devpriv->ai_add_back; for (i = 0; i < num_samples; i++) { if (devpriv->ai_act_dmapos >= start_pos && - devpriv->ai_act_dmapos < stop_pos) { + devpriv->ai_act_dmapos < stop_pos) { dma_buffer[j++] = dma_buffer[i]; } devpriv->ai_act_dmapos++; @@ -482,18 +496,20 @@ ============================================================================== */ static unsigned int move_block_from_dma(struct comedi_device *dev, - struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) + struct comedi_subdevice *s, + short *dma_buffer, + unsigned int num_samples) { unsigned int num_bytes; num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); devpriv->ai_act_scan += - (s->async->cur_chan + num_samples) / devpriv->ai_n_scanlen; + (s->async->cur_chan + num_samples) / devpriv->ai_n_scanlen; s->async->cur_chan += num_samples; s->async->cur_chan %= devpriv->ai_n_scanlen; num_bytes = - cfc_write_array_to_buffer(s, dma_buffer, - num_samples * sizeof(short)); + cfc_write_array_to_buffer(s, dma_buffer, + num_samples * sizeof(short)); if (num_bytes < num_samples * sizeof(short)) return -1; return 0; @@ -503,7 +519,8 @@ ============================================================================== */ static char pci9118_decode_error_status(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned char m) + struct comedi_subdevice *s, + unsigned char m) { if (m & 0x100) { comedi_error(dev, "A/D FIFO Full status (Fatal Error!)"); @@ -511,7 +528,7 @@ } if (m & 0x008) { comedi_error(dev, - "A/D Burst Mode Overrun Status (Fatal Error!)"); + "A/D Burst Mode Overrun Status (Fatal Error!)"); devpriv->ai_maskerr &= ~0x008L; } if (m & 0x004) { @@ -532,8 +549,10 @@ return 0; } -static void pci9118_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, - void *data, unsigned int num_bytes, unsigned int start_chan_index) +static void pci9118_ai_munge(struct comedi_device *dev, + struct comedi_subdevice *s, void *data, + unsigned int num_bytes, + unsigned int start_chan_index) { unsigned int i, num_samples = num_bytes / sizeof(short); short *array = data; @@ -553,8 +572,10 @@ ============================================================================== */ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned short int_adstat, unsigned int int_amcc, - unsigned short int_daq) + struct comedi_subdevice *s, + unsigned short int_adstat, + unsigned int int_amcc, + unsigned short int_daq) { register short sampl; @@ -570,9 +591,9 @@ if (devpriv->ai16bits == 0) { if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { /* data dropout! */ printk - ("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n", - sampl & 0x000f, - devpriv->chanlist[s->async->cur_chan]); + ("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n", + sampl & 0x000f, + devpriv->chanlist[s->async->cur_chan]); s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; pci9118_ai_cancel(dev, s); comedi_event(dev, s); @@ -599,9 +620,11 @@ /* ============================================================================== */ -static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned short int_adstat, unsigned int int_amcc, - unsigned short int_daq) +static void interrupt_pci9118_ai_dma(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned short int_adstat, + unsigned int int_amcc, + unsigned short int_daq) { unsigned int next_dma_buf, samplesinbuf, sampls, m; @@ -632,11 +655,11 @@ if (devpriv->dma_doublebuf) { /* switch DMA buffers if is used double buffering */ next_dma_buf = 1 - devpriv->dma_actbuf; outl(devpriv->dmabuf_hw[next_dma_buf], - devpriv->iobase_a + AMCC_OP_REG_MWAR); + devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[next_dma_buf], - devpriv->iobase_a + AMCC_OP_REG_MWTC); + devpriv->iobase_a + AMCC_OP_REG_MWTC); devpriv->dmabuf_used_size[next_dma_buf] = - devpriv->dmabuf_use_size[next_dma_buf]; + devpriv->dmabuf_use_size[next_dma_buf]; if (devpriv->ai_do == 4) interrupt_pci9118_ai_mode4_switch(dev); } @@ -646,8 +669,8 @@ /* DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); */ sampls = m; move_block_from_dma(dev, s, - devpriv->dmabuf_virt[devpriv->dma_actbuf], - samplesinbuf); + devpriv->dmabuf_virt[devpriv->dma_actbuf], + samplesinbuf); m = m - sampls; /* m= how many samples was transfered */ } /* DPRINTK("YYY\n"); */ @@ -662,9 +685,9 @@ devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; } else { /* restart DMA if is not used double buffering */ outl(devpriv->dmabuf_hw[0], - devpriv->iobase_a + AMCC_OP_REG_MWAR); + devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[0], - devpriv->iobase_a + AMCC_OP_REG_MWTC); + devpriv->iobase_a + AMCC_OP_REG_MWTC); if (devpriv->ai_do == 4) interrupt_pci9118_ai_mode4_switch(dev); } @@ -700,18 +723,18 @@ if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { /* start stop of measure */ if (devpriv->ai12_startstop & START_AI_EXT) { devpriv->ai12_startstop &= - ~START_AI_EXT; + ~START_AI_EXT; if (!(devpriv->ai12_startstop & - STOP_AI_EXT)) + STOP_AI_EXT)) pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); /* start pacer */ outl(devpriv->AdControlReg, - dev->iobase + PCI9118_ADCNTRL); + dev->iobase + PCI9118_ADCNTRL); } else { - if (devpriv-> - ai12_startstop & STOP_AI_EXT) { + if (devpriv->ai12_startstop & + STOP_AI_EXT) { devpriv->ai12_startstop &= - ~STOP_AI_EXT; + ~STOP_AI_EXT; pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ devpriv->ai_neverending = 0; /* well, on next interrupt from DMA/EOC measure will stop */ } @@ -719,7 +742,7 @@ } (devpriv->int_ai_func) (dev, dev->subdevices + 0, int_adstat, - int_amcc, int_daq); + int_amcc, int_daq); } return IRQ_HANDLED; @@ -728,8 +751,8 @@ /* ============================================================================== */ -static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int pci9118_ai_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned int trignum) { if (trignum != devpriv->ai_inttrig_start) return -EINVAL; @@ -741,7 +764,7 @@ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); if (devpriv->ai_do != 3) { start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + devpriv->ai_divisor2); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); @@ -752,8 +775,9 @@ /* ============================================================================== */ -static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pci9118_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; @@ -799,21 +823,21 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ if (cmd->start_src != TRIG_NOW && - cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) { + cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) { cmd->start_src = TRIG_NOW; err++; } if (cmd->scan_begin_src != TRIG_TIMER && - cmd->scan_begin_src != TRIG_EXT && - cmd->scan_begin_src != TRIG_INT && - cmd->scan_begin_src != TRIG_FOLLOW) { + cmd->scan_begin_src != TRIG_EXT && + cmd->scan_begin_src != TRIG_INT && + cmd->scan_begin_src != TRIG_FOLLOW) { cmd->scan_begin_src = TRIG_FOLLOW; err++; } if (cmd->convert_src != TRIG_TIMER && - cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) { + cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) { cmd->convert_src = TRIG_TIMER; err++; } @@ -824,8 +848,8 @@ } if (cmd->stop_src != TRIG_NONE && - cmd->stop_src != TRIG_COUNT && - cmd->stop_src != TRIG_INT && cmd->stop_src != TRIG_EXT) { + cmd->stop_src != TRIG_COUNT && + cmd->stop_src != TRIG_INT && cmd->stop_src != TRIG_EXT) { cmd->stop_src = TRIG_COUNT; err++; } @@ -841,13 +865,13 @@ } if ((cmd->scan_begin_src & (TRIG_TIMER | TRIG_EXT)) && - (!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW)))) { + (!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW)))) { cmd->convert_src = TRIG_TIMER; err++; } if ((cmd->scan_begin_src == TRIG_FOLLOW) && - (!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT)))) { + (!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT)))) { cmd->convert_src = TRIG_TIMER; err++; } @@ -875,7 +899,7 @@ } if ((cmd->scan_begin_src == TRIG_TIMER) && - (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) { + (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) { cmd->scan_begin_src = TRIG_FOLLOW; cmd->convert_arg = cmd->scan_begin_arg; cmd->scan_begin_arg = 0; @@ -938,8 +962,7 @@ if ((cmd->scan_end_arg % cmd->chanlist_len)) { cmd->scan_end_arg = - cmd->chanlist_len * (cmd->scan_end_arg / - cmd->chanlist_len); + cmd->chanlist_len * (cmd->scan_end_arg / cmd->chanlist_len); err++; } @@ -952,8 +975,8 @@ tmp = cmd->scan_begin_arg; /* printk("S1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, - &divisor2, &cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); + &divisor2, &cmd->scan_begin_arg, + cmd->flags & TRIG_ROUND_MASK); /* printk("S2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ if (cmd->scan_begin_arg < this_board->ai_ns_min) cmd->scan_begin_arg = this_board->ai_ns_min; @@ -964,31 +987,31 @@ if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, - &divisor2, &cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); + &divisor2, &cmd->convert_arg, + cmd->flags & TRIG_ROUND_MASK); /* printk("s1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ if (cmd->convert_arg < this_board->ai_ns_min) cmd->convert_arg = this_board->ai_ns_min; if (tmp != cmd->convert_arg) err++; if (cmd->scan_begin_src == TRIG_TIMER - && cmd->convert_src == TRIG_NOW) { + && cmd->convert_src == TRIG_NOW) { if (cmd->convert_arg == 0) { if (cmd->scan_begin_arg < - this_board->ai_ns_min * - (cmd->scan_end_arg + 2)) { + this_board->ai_ns_min * + (cmd->scan_end_arg + 2)) { cmd->scan_begin_arg = - this_board->ai_ns_min * - (cmd->scan_end_arg + 2); + this_board->ai_ns_min * + (cmd->scan_end_arg + 2); /* printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ err++; } } else { if (cmd->scan_begin_arg < - cmd->convert_arg * cmd->chanlist_len) { + cmd->convert_arg * cmd->chanlist_len) { cmd->scan_begin_arg = - cmd->convert_arg * - cmd->chanlist_len; + cmd->convert_arg * + cmd->chanlist_len; /* printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */ err++; } @@ -1001,7 +1024,7 @@ if (cmd->chanlist) if (!check_channel_list(dev, s, cmd->chanlist_len, - cmd->chanlist, 0, 0)) + cmd->chanlist, 0, 0)) return 5; /* incorrect channels list */ return 0; @@ -1034,19 +1057,22 @@ /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); printk - ("comedi%d: WAR: DMA0 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", - dev->minor, dmalen0, - devpriv->ai_n_realscanlen << 1); + ("comedi%d: WAR: DMA0 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", + dev->minor, dmalen0, + devpriv->ai_n_realscanlen << 1); } else { /* short first DMA buffer to one scan */ dmalen0 = devpriv->ai_n_realscanlen << 1; - DPRINTK("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen0, devpriv->ai_n_realscanlen, devpriv->useeoshandle); + DPRINTK + ("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", + dmalen0, devpriv->ai_n_realscanlen, + devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen0 += 2; if (dmalen0 < 4) { printk - ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n", - dev->minor, dmalen0); + ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n", + dev->minor, dmalen0); dmalen0 = 4; } } @@ -1056,19 +1082,22 @@ /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); printk - ("comedi%d: WAR: DMA1 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", - dev->minor, dmalen1, - devpriv->ai_n_realscanlen << 1); + ("comedi%d: WAR: DMA1 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", + dev->minor, dmalen1, + devpriv->ai_n_realscanlen << 1); } else { /* short second DMA buffer to one scan */ dmalen1 = devpriv->ai_n_realscanlen << 1; - DPRINTK("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen1, devpriv->ai_n_realscanlen, devpriv->useeoshandle); + DPRINTK + ("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", + dmalen1, devpriv->ai_n_realscanlen, + devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen1 -= 2; if (dmalen1 < 4) { printk - ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n", - dev->minor, dmalen1); + ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n", + dev->minor, dmalen1); dmalen1 = 4; } } @@ -1080,15 +1109,15 @@ /* if it's possible then allign DMA buffers to length of scan */ i = dmalen0; dmalen0 = - (dmalen0 / (devpriv->ai_n_realscanlen << 1)) * - (devpriv->ai_n_realscanlen << 1); + (dmalen0 / (devpriv->ai_n_realscanlen << 1)) * + (devpriv->ai_n_realscanlen << 1); dmalen0 &= ~3L; if (!dmalen0) dmalen0 = i; /* uff. very long scan? */ i = dmalen1; dmalen1 = - (dmalen1 / (devpriv->ai_n_realscanlen << 1)) * - (devpriv->ai_n_realscanlen << 1); + (dmalen1 / (devpriv->ai_n_realscanlen << 1)) * + (devpriv->ai_n_realscanlen << 1); dmalen1 &= ~3L; if (!dmalen1) dmalen1 = i; /* uff. very long scan? */ @@ -1096,23 +1125,25 @@ if (!devpriv->ai_neverending) { /* fits whole measure into one DMA buffer? */ if (dmalen0 > - ((devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans)) { - DPRINTK("3.0 ai_n_realscanlen=%d ai_scans=%d \n", devpriv->ai_n_realscanlen, devpriv->ai_scans); + ((devpriv->ai_n_realscanlen << 1) * + devpriv->ai_scans)) { + DPRINTK + ("3.0 ai_n_realscanlen=%d ai_scans=%d \n", + devpriv->ai_n_realscanlen, + devpriv->ai_scans); dmalen0 = - (devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans; + (devpriv->ai_n_realscanlen << 1) * + devpriv->ai_scans; DPRINTK("3.1 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); dmalen0 &= ~3L; } else { /* fits whole measure into two DMA buffer? */ if (dmalen1 > - ((devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans - dmalen0)) + ((devpriv->ai_n_realscanlen << 1) * + devpriv->ai_scans - dmalen0)) dmalen1 = - (devpriv-> - ai_n_realscanlen << 1) * - devpriv->ai_scans - dmalen0; + (devpriv->ai_n_realscanlen << 1) * + devpriv->ai_scans - dmalen0; DPRINTK("3.2 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); dmalen1 &= ~3L; @@ -1131,16 +1162,16 @@ #if 0 if (devpriv->ai_n_scanlen < this_board->half_fifo_size) { devpriv->dmabuf_panic_size[0] = - (this_board->half_fifo_size / devpriv->ai_n_scanlen + - 1) * devpriv->ai_n_scanlen * sizeof(short); + (this_board->half_fifo_size / devpriv->ai_n_scanlen + + 1) * devpriv->ai_n_scanlen * sizeof(short); devpriv->dmabuf_panic_size[1] = - (this_board->half_fifo_size / devpriv->ai_n_scanlen + - 1) * devpriv->ai_n_scanlen * sizeof(short); + (this_board->half_fifo_size / devpriv->ai_n_scanlen + + 1) * devpriv->ai_n_scanlen * sizeof(short); } else { devpriv->dmabuf_panic_size[0] = - (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[0]; + (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[0]; devpriv->dmabuf_panic_size[1] = - (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[1]; + (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[1]; } #endif @@ -1149,12 +1180,12 @@ outl(devpriv->dmabuf_use_size[0], devpriv->iobase_a + AMCC_OP_REG_MWTC); /* init DMA transfer */ outl(0x00000000 | AINT_WRITE_COMPL, - devpriv->iobase_a + AMCC_OP_REG_INTCSR); + devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); */ outl(inl(devpriv->iobase_a + - AMCC_OP_REG_MCSR) | RESET_A2P_FLAGS | A2P_HI_PRIORITY | - EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_MCSR); + AMCC_OP_REG_MCSR) | RESET_A2P_FLAGS | A2P_HI_PRIORITY | + EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_MCSR); outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow bus mastering */ DPRINTK("adl_pci9118 EDBG: END: Compute_and_setup_dma()\n"); @@ -1164,7 +1195,8 @@ /* ============================================================================== */ -static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci9118_ai_docmd_sampl(struct comedi_device *dev, + struct comedi_subdevice *s) { DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_sampl(%d,) [%d]\n", dev->minor, devpriv->ai_do); @@ -1183,7 +1215,7 @@ return -EIO; default: comedi_error(dev, - "pci9118_ai_docmd_sampl() mode number bug!\n"); + "pci9118_ai_docmd_sampl() mode number bug!\n"); return -EIO; }; @@ -1204,7 +1236,7 @@ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); if (devpriv->ai_do != 3) { start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + devpriv->ai_divisor2); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); @@ -1217,7 +1249,8 @@ /* ============================================================================== */ -static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci9118_ai_docmd_dma(struct comedi_device *dev, + struct comedi_subdevice *s) { DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_dma(%d,) [%d,%d]\n", dev->minor, devpriv->ai_do, devpriv->usedma); @@ -1226,34 +1259,34 @@ switch (devpriv->ai_do) { case 1: devpriv->AdControlReg |= - ((AdControl_TmrTr | AdControl_Dma) & 0xff); + ((AdControl_TmrTr | AdControl_Dma) & 0xff); break; case 2: devpriv->AdControlReg |= - ((AdControl_TmrTr | AdControl_Dma) & 0xff); + ((AdControl_TmrTr | AdControl_Dma) & 0xff); devpriv->AdFunctionReg = - AdFunction_PDTrg | AdFunction_PETrg | AdFunction_BM | - AdFunction_BS; + AdFunction_PDTrg | AdFunction_PETrg | AdFunction_BM | + AdFunction_BS; if (devpriv->usessh && (!devpriv->softsshdelay)) devpriv->AdFunctionReg |= AdFunction_BSSH; outl(devpriv->ai_n_realscanlen, dev->iobase + PCI9118_BURST); break; case 3: devpriv->AdControlReg |= - ((AdControl_ExtM | AdControl_Dma) & 0xff); + ((AdControl_ExtM | AdControl_Dma) & 0xff); devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; break; case 4: devpriv->AdControlReg |= - ((AdControl_TmrTr | AdControl_Dma) & 0xff); + ((AdControl_TmrTr | AdControl_Dma) & 0xff); devpriv->AdFunctionReg = - AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM; + AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM; outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); outl(0x30, dev->iobase + PCI9118_CNTCTRL); outl((devpriv->dmabuf_hw[0] >> 1) & 0xff, - dev->iobase + PCI9118_CNT0); + dev->iobase + PCI9118_CNT0); outl((devpriv->dmabuf_hw[0] >> 9) & 0xff, - dev->iobase + PCI9118_CNT0); + dev->iobase + PCI9118_CNT0); devpriv->AdFunctionReg |= AdFunction_Start; break; default: @@ -1268,14 +1301,14 @@ devpriv->int_ai_func = interrupt_pci9118_ai_dma; /* transfer function */ outl(0x02000000 | AINT_WRITE_COMPL, - devpriv->iobase_a + AMCC_OP_REG_INTCSR); + devpriv->iobase_a + AMCC_OP_REG_INTCSR); if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) { outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); if (devpriv->ai_do != 3) { start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + devpriv->ai_divisor2); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); @@ -1338,7 +1371,7 @@ /* use sample&hold signal? */ if (cmd->convert_src == TRIG_NOW) { devpriv->usessh = 1; - } /* yes */ + } /* yes */ else { devpriv->usessh = 0; } /* no */ @@ -1354,7 +1387,7 @@ if (devpriv->master) { devpriv->usedma = 1; if ((cmd->flags & TRIG_WAKE_EOS) && - (devpriv->ai_n_scanlen == 1)) { + (devpriv->ai_n_scanlen == 1)) { if (cmd->convert_src == TRIG_NOW) { devpriv->ai_add_back = 1; } @@ -1363,8 +1396,8 @@ } } if ((cmd->flags & TRIG_WAKE_EOS) && - (devpriv->ai_n_scanlen & 1) && - (devpriv->ai_n_scanlen > 1)) { + (devpriv->ai_n_scanlen & 1) && + (devpriv->ai_n_scanlen > 1)) { if (cmd->scan_begin_src == TRIG_FOLLOW) { /* vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call */ devpriv->usedma = 0; /* XXX maybe can be corrected to use 16 bit DMA */ @@ -1392,16 +1425,16 @@ devpriv->ai_add_front = addchans + 1; if (devpriv->usedma == 1) if ((devpriv->ai_add_front + - devpriv->ai_n_chan + - devpriv->ai_add_back) & 1) + devpriv->ai_n_chan + + devpriv->ai_add_back) & 1) devpriv->ai_add_front++; /* round up to 32 bit */ } - } /* well, we now know what must be all added */ - + } + /* well, we now know what must be all added */ devpriv->ai_n_realscanlen = /* what we must take from card in real to have ai_n_scanlen on output? */ - (devpriv->ai_add_front + devpriv->ai_n_chan + - devpriv->ai_add_back) * (devpriv->ai_n_scanlen / - devpriv->ai_n_chan); + (devpriv->ai_add_front + devpriv->ai_n_chan + + devpriv->ai_add_back) * (devpriv->ai_n_scanlen / + devpriv->ai_n_chan); DPRINTK("2 usedma=%d realscan=%d af=%u n_chan=%d ab=%d n_scanlen=%d\n", devpriv->usedma, @@ -1411,13 +1444,13 @@ /* check and setup channel list */ if (!check_channel_list(dev, s, devpriv->ai_n_chan, - devpriv->ai_chanlist, devpriv->ai_add_front, - devpriv->ai_add_back)) + devpriv->ai_chanlist, devpriv->ai_add_front, + devpriv->ai_add_back)) return -EINVAL; if (!setup_channel_list(dev, s, devpriv->ai_n_chan, - devpriv->ai_chanlist, 0, devpriv->ai_add_front, - devpriv->ai_add_back, devpriv->usedma, - devpriv->useeoshandle)) + devpriv->ai_chanlist, 0, devpriv->ai_add_front, + devpriv->ai_add_back, devpriv->usedma, + devpriv->useeoshandle)) return -EINVAL; /* compute timers settings */ @@ -1429,32 +1462,36 @@ devpriv->ai_do = 1; } pci9118_calc_divisors(devpriv->ai_do, dev, s, - &cmd->scan_begin_arg, &cmd->convert_arg, - devpriv->ai_flags, devpriv->ai_n_realscanlen, - &devpriv->ai_divisor1, &devpriv->ai_divisor2, - devpriv->usessh, devpriv->ai_add_front); + &cmd->scan_begin_arg, &cmd->convert_arg, + devpriv->ai_flags, + devpriv->ai_n_realscanlen, + &devpriv->ai_divisor1, + &devpriv->ai_divisor2, devpriv->usessh, + devpriv->ai_add_front); devpriv->ai_timer2 = cmd->convert_arg; } if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { /* double timed action */ if (!devpriv->usedma) { comedi_error(dev, - "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!"); + "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!"); return -EIO; } devpriv->ai_do = 2; pci9118_calc_divisors(devpriv->ai_do, dev, s, - &cmd->scan_begin_arg, &cmd->convert_arg, - devpriv->ai_flags, devpriv->ai_n_realscanlen, - &devpriv->ai_divisor1, &devpriv->ai_divisor2, - devpriv->usessh, devpriv->ai_add_front); + &cmd->scan_begin_arg, &cmd->convert_arg, + devpriv->ai_flags, + devpriv->ai_n_realscanlen, + &devpriv->ai_divisor1, + &devpriv->ai_divisor2, devpriv->usessh, + devpriv->ai_add_front); devpriv->ai_timer1 = cmd->scan_begin_arg; devpriv->ai_timer2 = cmd->convert_arg; } if ((cmd->scan_begin_src == TRIG_FOLLOW) - && (cmd->convert_src == TRIG_EXT)) { + && (cmd->convert_src == TRIG_EXT)) { devpriv->ai_do = 3; } @@ -1486,8 +1523,9 @@ /* ============================================================================== */ -static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist, int frontadd, int backadd) +static int check_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, int n_chan, + unsigned int *chanlist, int frontadd, int backadd) { unsigned int i, differencial = 0, bipolar = 0; @@ -1498,9 +1536,8 @@ } if ((frontadd + n_chan + backadd) > s->len_chanlist) { printk - ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!", - dev->minor, n_chan, - s->len_chanlist - frontadd - backadd); + ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!", + dev->minor, n_chan, s->len_chanlist - frontadd - backadd); return 0; } @@ -1511,22 +1548,21 @@ if (n_chan > 1) for (i = 1; i < n_chan; i++) { /* check S.E/diff */ if ((CR_AREF(chanlist[i]) == AREF_DIFF) != - (differencial)) { + (differencial)) { comedi_error(dev, - "Differencial and single ended inputs cann't be mixtured!"); + "Differencial and single ended inputs cann't be mixtured!"); return 0; } if ((CR_RANGE(chanlist[i]) < PCI9118_BIPOLAR_RANGES) != - (bipolar)) { + (bipolar)) { comedi_error(dev, - "Bipolar and unipolar ranges cann't be mixtured!"); + "Bipolar and unipolar ranges cann't be mixtured!"); return 0; } if ((!devpriv->usemux) & (differencial) & - (CR_CHAN(chanlist[i]) >= - this_board->n_aichand)) { + (CR_CHAN(chanlist[i]) >= this_board->n_aichand)) { comedi_error(dev, - "If AREF_DIFF is used then is available only first 8 channels!"); + "If AREF_DIFF is used then is available only first 8 channels!"); return 0; } } @@ -1537,14 +1573,17 @@ /* ============================================================================== */ -static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd, - int usedma, char useeos) +static int setup_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, int n_chan, + unsigned int *chanlist, int rot, int frontadd, + int backadd, int usedma, char useeos) { unsigned int i, differencial = 0, bipolar = 0; unsigned int scanquad, gain, ssh = 0x00; - DPRINTK("adl_pci9118 EDBG: BGN: setup_channel_list(%d,.,%d,.,%d,%d,%d,%d)\n", dev->minor, n_chan, rot, frontadd, backadd, usedma); + DPRINTK + ("adl_pci9118 EDBG: BGN: setup_channel_list(%d,.,%d,.,%d,%d,%d,%d)\n", + dev->minor, n_chan, rot, frontadd, backadd, usedma); if (usedma == 1) { rot = 8; @@ -1625,7 +1664,7 @@ if (useeos) { for (i = 1; i < n_chan; i++) { /* store range list to card */ devpriv->chanlist[(n_chan + i) ^ usedma] = - (CR_CHAN(chanlist[i]) & 0xf) << rot; + (CR_CHAN(chanlist[i]) & 0xf) << rot; } devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */ useeos = 2; @@ -1652,18 +1691,22 @@ calculate 8254 divisors if they are used for dual timing */ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2, - unsigned int flags, int chans, unsigned int *div1, unsigned int *div2, - char usessh, unsigned int chnsshfront) -{ - DPRINTK("adl_pci9118 EDBG: BGN: pci9118_calc_divisors(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n", mode, dev->minor, *tim1, *tim2, flags, chans, usessh, chnsshfront); + struct comedi_subdevice *s, + unsigned int *tim1, unsigned int *tim2, + unsigned int flags, int chans, + unsigned int *div1, unsigned int *div2, + char usessh, unsigned int chnsshfront) +{ + DPRINTK + ("adl_pci9118 EDBG: BGN: pci9118_calc_divisors(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n", + mode, dev->minor, *tim1, *tim2, flags, chans, usessh, chnsshfront); switch (mode) { case 1: case 4: if (*tim2 < this_board->ai_ns_min) *tim2 = this_board->ai_ns_min; i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, div1, div2, - tim2, flags & TRIG_ROUND_NEAREST); + tim2, flags & TRIG_ROUND_NEAREST); DPRINTK("OSC base=%u div1=%u div2=%u timer1=%u\n", devpriv->i8254_osc_base, *div1, *div2, *tim1); break; @@ -1710,8 +1753,8 @@ /* ============================================================================== */ -static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, - unsigned int divisor2) +static void start_pacer(struct comedi_device *dev, int mode, + unsigned int divisor1, unsigned int divisor2) { outl(0x74, dev->iobase + PCI9118_CNTCTRL); outl(0xb4, dev->iobase + PCI9118_CNTCTRL); @@ -1760,7 +1803,8 @@ /* ============================================================================== */ -static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci9118_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { if (devpriv->usedma) outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ @@ -1835,7 +1879,8 @@ /* ============================================================================== */ -static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci9118_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, pages, i; @@ -1848,8 +1893,7 @@ unsigned char pci_bus, pci_slot, pci_func; u16 u16w; - printk("comedi%d: adl_pci9118: board=%s", dev->minor, - this_board->name); + printk("comedi%d: adl_pci9118: board=%s", dev->minor, this_board->name); opt_bus = it->options[0]; opt_slot = it->options[1]; @@ -1869,12 +1913,13 @@ errstr = "not found!"; pcidev = NULL; while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_AMCC, - this_board->device_id, pcidev))) { + this_board->device_id, + pcidev))) { /* Found matching vendor/device. */ if (opt_bus || opt_slot) { /* Check bus/slot. */ if (opt_bus != pcidev->bus->number - || opt_slot != PCI_SLOT(pcidev->devfn)) + || opt_slot != PCI_SLOT(pcidev->devfn)) continue; /* no match */ } /* @@ -1882,7 +1927,8 @@ * Enable PCI device and request regions. */ if (comedi_pci_enable(pcidev, "adl_pci9118")) { - errstr = "failed to enable PCI device and request regions!"; + errstr = + "failed to enable PCI device and request regions!"; continue; } break; @@ -1891,7 +1937,7 @@ if (!pcidev) { if (opt_bus || opt_slot) { printk(" - Card at b:s %d:%d %s\n", - opt_bus, opt_slot, errstr); + opt_bus, opt_slot, errstr); } else { printk(" - Card %s\n", errstr); } @@ -1910,7 +1956,7 @@ iobase_9 = pci_resource_start(pcidev, 2); printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot, - pci_func, iobase_9, iobase_a); + pci_func, iobase_9, iobase_a); dev->iobase = iobase_9; dev->board_name = this_board->name; @@ -1926,7 +1972,7 @@ if (request_irq(irq, interrupt_pci9118, IRQF_SHARED, "ADLink PCI-9118", dev)) { printk(", unable to allocate IRQ %d, DISABLING IT", - irq); + irq); irq = 0; /* Can't use IRQ */ } else { printk(", irq=%u", irq); @@ -1942,8 +1988,8 @@ for (i = 0; i < 2; i++) { for (pages = 4; pages >= 0; pages--) { devpriv->dmabuf_virt[i] = - (short *) __get_free_pages(GFP_KERNEL, - pages); + (short *)__get_free_pages(GFP_KERNEL, + pages); if (devpriv->dmabuf_virt[i]) break; } @@ -1951,10 +1997,10 @@ devpriv->dmabuf_pages[i] = pages; devpriv->dmabuf_size[i] = PAGE_SIZE * pages; devpriv->dmabuf_samples[i] = - devpriv->dmabuf_size[i] >> 1; + devpriv->dmabuf_size[i] >> 1; devpriv->dmabuf_hw[i] = - virt_to_bus((void *)devpriv-> - dmabuf_virt[i]); + virt_to_bus((void *) + devpriv->dmabuf_virt[i]); } } if (!devpriv->dmabuf_virt[0]) { @@ -2090,10 +2136,10 @@ } if (devpriv->dmabuf_virt[0]) free_pages((unsigned long)devpriv->dmabuf_virt[0], - devpriv->dmabuf_pages[0]); + devpriv->dmabuf_pages[0]); if (devpriv->dmabuf_virt[1]) free_pages((unsigned long)devpriv->dmabuf_virt[1], - devpriv->dmabuf_pages[1]); + devpriv->dmabuf_pages[1]); } return 0; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adq12b.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adq12b.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adq12b.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adq12b.c 2009-07-30 09:25:31.000000000 -0700 @@ -62,7 +62,6 @@ single-ended 0 1-2 1-2 (factory default) differential 1 2-3 2-3 - written by jeremy theler instituto balseiro @@ -101,39 +100,39 @@ /* available ranges through the PGA gains */ static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, { - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1), - BIP_RANGE(0.5) -}}; + BIP_RANGE(5), + BIP_RANGE(2), + BIP_RANGE(1), + BIP_RANGE(0.5) + } +}; static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, { - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1), - UNI_RANGE(0.5) -}}; - - + UNI_RANGE(5), + UNI_RANGE(2), + UNI_RANGE(1), + UNI_RANGE + (0.5) + } +}; struct adq12b_board { - const char *name; - int ai_se_chans; - int ai_diff_chans; - int ai_bits; - int di_chans; - int do_chans; + const char *name; + int ai_se_chans; + int ai_diff_chans; + int ai_bits; + int di_chans; + int do_chans; }; static const struct adq12b_board adq12b_boards[] = { - { - .name = "adq12b", - .ai_se_chans = 16, - .ai_diff_chans = 8, - .ai_bits = 12, - .di_chans = 5, - .do_chans = 8 - } + { + .name = "adq12b", + .ai_se_chans = 16, + .ai_diff_chans = 8, + .ai_bits = 12, + .di_chans = 5, + .do_chans = 8} /* potentially, more adq-based deviced will be added */ /*, .name = "adq12b", @@ -147,11 +146,11 @@ #define thisboard ((const struct adq12b_board *)dev->board_ptr) struct adq12b_private { - int unipolar; /* option 2 of comedi_config (1 is iobase) */ - int differential; /* option 3 of comedi_config */ - int last_channel; - int last_range; - unsigned int digital_state; + int unipolar; /* option 2 of comedi_config (1 is iobase) */ + int differential; /* option 3 of comedi_config */ + int last_channel; + int last_range; + unsigned int digital_state; }; #define devpriv ((struct adq12b_private *)dev->private) @@ -162,21 +161,28 @@ * the board, and also about the kernel module that contains * the device code. */ -static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int adq12b_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int adq12b_detach(struct comedi_device *dev); -static struct comedi_driver driver_adq12b={ - driver_name: "adq12b", - module: THIS_MODULE, - attach: adq12b_attach, - detach: adq12b_detach, - board_name: &adq12b_boards[0].name, - offset: sizeof(struct adq12b_board), - num_names: ARRAY_SIZE(adq12b_boards), +static struct comedi_driver driver_adq12b = { +driver_name:"adq12b", +module:THIS_MODULE, +attach:adq12b_attach, +detach:adq12b_detach, +board_name:&adq12b_boards[0].name, +offset:sizeof(struct adq12b_board), +num_names:ARRAY_SIZE(adq12b_boards), }; -static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); +static int adq12b_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); +static int adq12b_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int adq12b_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * Attach is called by the Comedi core to configure the driver @@ -186,109 +192,108 @@ */ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - struct comedi_subdevice *s; - unsigned long iobase; - int unipolar, differential; - - iobase = it->options[0]; - unipolar = it->options[1]; - differential = it->options[2]; - - printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n", dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1) ? "differential" : "single-ended"); - - /* if no address was specified, try the default 0x300 */ - if (iobase == 0) { - printk("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n", dev->minor); - iobase = 0x300; - } - - printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase); - if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) { - printk("I/O port conflict\n"); - return -EIO; - } - dev->iobase = iobase; + struct comedi_subdevice *s; + unsigned long iobase; + int unipolar, differential; + + iobase = it->options[0]; + unipolar = it->options[1]; + differential = it->options[2]; + + printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n", + dev->minor, iobase, (unipolar == 1) ? "unipolar" : "bipolar", + (differential == 1) ? "differential" : "single-ended"); + + /* if no address was specified, try the default 0x300 */ + if (iobase == 0) { + printk + ("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n", + dev->minor); + iobase = 0x300; + } + + printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase); + if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) { + printk("I/O port conflict\n"); + return -EIO; + } + dev->iobase = iobase; /* * Initialize dev->board_name. Note that we can use the "thisboard" * macro now, since we just initialized it in the last line. */ - dev->board_name = thisboard->name; + dev->board_name = thisboard->name; /* * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. */ - if (alloc_private (dev, sizeof (struct adq12b_private)) < 0) - return -ENOMEM; + if (alloc_private(dev, sizeof(struct adq12b_private)) < 0) + return -ENOMEM; /* fill in devpriv structure */ - devpriv->unipolar = unipolar; - devpriv->differential = differential; + devpriv->unipolar = unipolar; + devpriv->differential = differential; devpriv->digital_state = 0; /* initialize channel and range to -1 so we make sure we always write at least once to the CTREG in the instruction */ - devpriv->last_channel = -1; - devpriv->last_range = -1; - + devpriv->last_channel = -1; + devpriv->last_range = -1; /* * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. */ - if (alloc_subdevices (dev, 3)<0) - return -ENOMEM; - - s = dev->subdevices+0; - /* analog input subdevice */ - s->type = COMEDI_SUBD_AI; - if (differential) { - s->subdev_flags = SDF_READABLE|SDF_GROUND|SDF_DIFF; - s->n_chan = thisboard->ai_diff_chans; - } else { - s->subdev_flags = SDF_READABLE|SDF_GROUND; - s->n_chan = thisboard->ai_se_chans; - } - - if (unipolar) { - s->range_table = &range_adq12b_ai_unipolar; - } else { - s->range_table = &range_adq12b_ai_bipolar; - } - - s->maxdata = (1 << thisboard->ai_bits)-1; - - - s->len_chanlist = 4; /* This is the maximum chanlist length that - the board can handle */ - s->insn_read = adq12b_ai_rinsn; - - - s = dev->subdevices+1; - /* digital input subdevice */ - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan=thisboard->di_chans; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = adq12b_di_insn_bits; - - s = dev->subdevices+2; - /* digital output subdevice */ - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = thisboard->do_chans; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = adq12b_do_insn_bits; + if (alloc_subdevices(dev, 3) < 0) + return -ENOMEM; + s = dev->subdevices + 0; + /* analog input subdevice */ + s->type = COMEDI_SUBD_AI; + if (differential) { + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF; + s->n_chan = thisboard->ai_diff_chans; + } else { + s->subdev_flags = SDF_READABLE | SDF_GROUND; + s->n_chan = thisboard->ai_se_chans; + } + + if (unipolar) { + s->range_table = &range_adq12b_ai_unipolar; + } else { + s->range_table = &range_adq12b_ai_bipolar; + } + + s->maxdata = (1 << thisboard->ai_bits) - 1; + + s->len_chanlist = 4; /* This is the maximum chanlist length that + the board can handle */ + s->insn_read = adq12b_ai_rinsn; + + s = dev->subdevices + 1; + /* digital input subdevice */ + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = thisboard->di_chans; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = adq12b_di_insn_bits; + + s = dev->subdevices + 2; + /* digital output subdevice */ + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = thisboard->do_chans; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = adq12b_do_insn_bits; - printk("attached\n"); + printk("attached\n"); - return 0; + return 0; } - /* * _detach is called to deconfigure a device. It should deallocate * resources. @@ -299,14 +304,14 @@ */ static int adq12b_detach(struct comedi_device *dev) { - if (dev->iobase) - release_region(dev->iobase, ADQ12B_SIZE); + if (dev->iobase) + release_region(dev->iobase, ADQ12B_SIZE); - kfree(devpriv); + kfree(devpriv); - printk("comedi%d: adq12b: removed\n", dev->minor); + printk("comedi%d: adq12b: removed\n", dev->minor); - return 0; + return 0; } /* @@ -314,79 +319,83 @@ * mode. */ -static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) +static int adq12b_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { - int n, i; - int range, channel; - unsigned char hi, lo, status; - - /* change channel and range only if it is different from the previous */ - range = CR_RANGE(insn->chanspec); - channel = CR_CHAN(insn->chanspec); - if (channel != devpriv->last_channel || range != devpriv->last_range) { - outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG); - udelay(50); /* wait for the mux to settle */ - } - - /* trigger conversion */ - status = inb(dev->iobase + ADQ12B_ADLOW); - - /* convert n samples */ - for (n=0; n < insn->n; n++){ - - /* wait for end of convertion */ - i = 0; - do { + int n, i; + int range, channel; + unsigned char hi, lo, status; + + /* change channel and range only if it is different from the previous */ + range = CR_RANGE(insn->chanspec); + channel = CR_CHAN(insn->chanspec); + if (channel != devpriv->last_channel || range != devpriv->last_range) { + outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG); + udelay(50); /* wait for the mux to settle */ + } + + /* trigger conversion */ + status = inb(dev->iobase + ADQ12B_ADLOW); + + /* convert n samples */ + for (n = 0; n < insn->n; n++) { + + /* wait for end of convertion */ + i = 0; + do { /* udelay(1); */ - status = inb(dev->iobase + ADQ12B_STINR); - status = status & ADQ12B_EOC; - } while (status == 0 && ++i < TIMEOUT); + status = inb(dev->iobase + ADQ12B_STINR); + status = status & ADQ12B_EOC; + } while (status == 0 && ++i < TIMEOUT); /* } while (++i < 10); */ - /* read data */ - hi = inb(dev->iobase + ADQ12B_ADHIG); - lo = inb(dev->iobase + ADQ12B_ADLOW); + /* read data */ + hi = inb(dev->iobase + ADQ12B_ADHIG); + lo = inb(dev->iobase + ADQ12B_ADLOW); - /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */ - data[n] = (hi << 8) | lo; + /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */ + data[n] = (hi << 8) | lo; - } + } - /* return the number of samples read/written */ - return n; + /* return the number of samples read/written */ + return n; } - -static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) +static int adq12b_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - /* only bits 0-4 have information about digital inputs */ - data[1] = (inb(dev->iobase+ADQ12B_STINR) & (0x1f)); + /* only bits 0-4 have information about digital inputs */ + data[1] = (inb(dev->iobase + ADQ12B_STINR) & (0x1f)); - return 2; + return 2; } - -static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) +static int adq12b_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - int channel; + int channel; for (channel = 0; channel < 8; channel++) - if (((data[0]>>channel) & 0x01) != 0) - outb((((data[1]>>channel)&0x01)<<3) | channel, dev->iobase + ADQ12B_OUTBR); - - /* store information to retrieve when asked for reading */ - if (data[0]) { - devpriv->digital_state &= ~data[0]; - devpriv->digital_state |= (data[0]&data[1]); - } + if (((data[0] >> channel) & 0x01) != 0) + outb((((data[1] >> channel) & 0x01) << 3) | channel, + dev->iobase + ADQ12B_OUTBR); + + /* store information to retrieve when asked for reading */ + if (data[0]) { + devpriv->digital_state &= ~data[0]; + devpriv->digital_state |= (data[0] & data[1]); + } - data[1] = devpriv->digital_state; + data[1] = devpriv->digital_state; - return 2; + return 2; } - /* * A convenient macro that defines init_module() and cleanup_module(), * as necessary. diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci1710.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci1710.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci1710.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci1710.c 2009-07-30 09:25:31.000000000 -0700 @@ -124,67 +124,69 @@ #define Syncont_SC0 1 /* set synchronous output mode */ static const struct comedi_lrange range_pci1710_3 = { 9, { - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625), - BIP_RANGE(10), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25) - } + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + BIP_RANGE(0.625), + BIP_RANGE(10), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25) + } }; static const char range_codes_pci1710_3[] = - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 }; + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 }; static const struct comedi_lrange range_pci1710hg = { 12, { - BIP_RANGE(5), - BIP_RANGE(0.5), - BIP_RANGE(0.05), - BIP_RANGE(0.005), - BIP_RANGE(10), - BIP_RANGE(1), - BIP_RANGE(0.1), - BIP_RANGE(0.01), - UNI_RANGE(10), - UNI_RANGE(1), - UNI_RANGE(0.1), - UNI_RANGE(0.01) - } + BIP_RANGE(5), + BIP_RANGE(0.5), + BIP_RANGE(0.05), + BIP_RANGE(0.005), + BIP_RANGE(10), + BIP_RANGE(1), + BIP_RANGE(0.1), + BIP_RANGE(0.01), + UNI_RANGE(10), + UNI_RANGE(1), + UNI_RANGE(0.1), + UNI_RANGE(0.01) + } }; static const char range_codes_pci1710hg[] = - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, - 0x13 }; + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, + 0x13 +}; static const struct comedi_lrange range_pci17x1 = { 5, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625) - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + BIP_RANGE(0.625) + } }; static const char range_codes_pci17x1[] = { 0x00, 0x01, 0x02, 0x03, 0x04 }; static const struct comedi_lrange range_pci1720 = { 4, { - UNI_RANGE(5), - UNI_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(10) - } + UNI_RANGE(5), + UNI_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(10) + } }; static const struct comedi_lrange range_pci171x_da = { 2, { - UNI_RANGE(5), - UNI_RANGE(10), - } + UNI_RANGE(5), + UNI_RANGE(10), + } }; -static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci1710_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci1710_detach(struct comedi_device *dev); struct boardtype { @@ -209,49 +211,50 @@ }; static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = { - {PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci1710_pci_table); static const struct boardtype boardtypes[] = { {"pci1710", 0x1710, - IORANGE_171x, 1, TYPE_PCI171X, - 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff, - &range_pci1710_3, range_codes_pci1710_3, - &range_pci171x_da, - 10000, 2048}, + IORANGE_171x, 1, TYPE_PCI171X, + 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff, + &range_pci1710_3, range_codes_pci1710_3, + &range_pci171x_da, + 10000, 2048}, {"pci1710hg", 0x1710, - IORANGE_171x, 1, TYPE_PCI171X, - 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff, - &range_pci1710hg, range_codes_pci1710hg, - &range_pci171x_da, - 10000, 2048}, + IORANGE_171x, 1, TYPE_PCI171X, + 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff, + &range_pci1710hg, range_codes_pci1710hg, + &range_pci171x_da, + 10000, 2048}, {"pci1711", 0x1711, - IORANGE_171x, 1, TYPE_PCI171X, - 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff, - &range_pci17x1, range_codes_pci17x1, &range_pci171x_da, - 10000, 512}, + IORANGE_171x, 1, TYPE_PCI171X, + 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff, + &range_pci17x1, range_codes_pci17x1, &range_pci171x_da, + 10000, 512}, {"pci1713", 0x1713, - IORANGE_171x, 1, TYPE_PCI1713, - 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000, - &range_pci1710_3, range_codes_pci1710_3, NULL, - 10000, 2048}, + IORANGE_171x, 1, TYPE_PCI1713, + 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000, + &range_pci1710_3, range_codes_pci1710_3, NULL, + 10000, 2048}, {"pci1720", 0x1720, - IORANGE_1720, 0, TYPE_PCI1720, - 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff, - NULL, NULL, &range_pci1720, - 0, 0}, + IORANGE_1720, 0, TYPE_PCI1720, + 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff, + NULL, NULL, &range_pci1720, + 0, 0}, {"pci1731", 0x1731, - IORANGE_171x, 1, TYPE_PCI171X, - 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000, - &range_pci17x1, range_codes_pci17x1, NULL, - 10000, 512}, + IORANGE_171x, 1, TYPE_PCI171X, + 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000, + &range_pci17x1, range_codes_pci17x1, NULL, + 10000, 512}, /* dummy entry corresponding to driver name */ {.name = DRV_NAME}, }; @@ -292,7 +295,7 @@ unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ - short *ai_data; /* data buffer */ + short *ai_data; /* data buffer */ unsigned int ai_timer1; /* timers */ unsigned int ai_timer2; short ao_data[4]; /* data output buffer */ @@ -306,14 +309,18 @@ ============================================================================== */ -static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int n_chan); -static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int n_chan, unsigned int seglen); -static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, - unsigned int divisor2); +static int check_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chanlist, unsigned int n_chan); +static void setup_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chanlist, unsigned int n_chan, + unsigned int seglen); +static void start_pacer(struct comedi_device *dev, int mode, + unsigned int divisor1, unsigned int divisor2); static int pci1710_reset(struct comedi_device *dev); -static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci171x_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s); static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707, /* used for gain list programming */ 0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f, @@ -324,8 +331,9 @@ /* ============================================================================== */ -static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_read_ai(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, timeout; #ifdef PCI171x_PARANOIDCHECK @@ -364,10 +372,12 @@ outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); data[n] = 0; - DPRINTK("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n", n); + DPRINTK + ("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n", + n); return -ETIME; - conv_finish: +conv_finish: #ifdef PCI171x_PARANOIDCHECK idata = inw(dev->iobase + PCI171x_AD_DATA); if (this_board->cardtype != TYPE_PCI1713) @@ -392,8 +402,9 @@ /* ============================================================================== */ -static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_write_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan, range, ofs; @@ -423,8 +434,9 @@ /* ============================================================================== */ -static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_read_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -438,8 +450,9 @@ /* ============================================================================== */ -static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_bits_di(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inw(dev->iobase + PCI171x_DI); @@ -449,8 +462,9 @@ /* ============================================================================== */ -static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_bits_do(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -465,8 +479,10 @@ /* ============================================================================== */ -static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_counter_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { unsigned int msb, lsb, ccntrl; int i; @@ -487,8 +503,10 @@ /* ============================================================================== */ -static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci171x_insn_counter_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { uint msb, lsb, ccntrl, status; @@ -515,7 +533,9 @@ ============================================================================== */ static int pci171x_insn_counter_config(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { #ifdef unused /* This doesn't work like a normal Comedi counter config */ @@ -550,8 +570,9 @@ /* ============================================================================== */ -static int pci1720_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1720_insn_write_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, rangereg, chan; @@ -596,8 +617,8 @@ } if (m & Status_FF) { printk - ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", - dev->minor, m); + ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", + dev->minor, m); pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); @@ -613,16 +634,17 @@ DPRINTK("%04x:", sampl); if (this_board->cardtype != TYPE_PCI1713) if ((sampl & 0xf000) != - devpriv->act_chanlist[s->async->cur_chan]) { + devpriv->act_chanlist[s->async->cur_chan]) { printk - ("comedi: A/D data dropout: received data from channel %d, expected %d!\n", - (sampl & 0xf000) >> 12, - (devpriv->act_chanlist[s->async-> - cur_chan] & 0xf000) >> - 12); + ("comedi: A/D data dropout: received data from channel %d, expected %d!\n", + (sampl & 0xf000) >> 12, + (devpriv-> + act_chanlist[s-> + async->cur_chan] & 0xf000) >> + 12); pci171x_ai_cancel(dev, s); s->async->events |= - COMEDI_CB_EOA | COMEDI_CB_ERROR; + COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return; } @@ -631,7 +653,7 @@ comedi_buf_put(s->async, sampl & 0x0fff); #else comedi_buf_put(s->async, - inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); + inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); #endif ++s->async->cur_chan; @@ -641,7 +663,10 @@ if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; - DPRINTK("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n", s->async->buf_int_count, s->async->buf_int_ptr, s->async->buf_user_count, s->async->buf_user_ptr); + DPRINTK + ("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n", + s->async->buf_int_count, s->async->buf_int_ptr, + s->async->buf_user_count, s->async->buf_user_ptr); DPRINTK("adv_pci1710 EDBG: EOS2\n"); if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { /* all data sampled */ pci171x_ai_cancel(dev, s); @@ -661,8 +686,8 @@ /* ============================================================================== */ -static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s, - int n, int turn) +static int move_block_from_fifo(struct comedi_device *dev, + struct comedi_subdevice *s, int n, int turn) { int i, j; #ifdef PCI171x_PARANOIDCHECK @@ -677,22 +702,21 @@ if (this_board->cardtype != TYPE_PCI1713) if ((sampl & 0xf000) != devpriv->act_chanlist[j]) { printk - ("comedi%d: A/D FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n", - dev->minor, (sampl & 0xf000) >> 12, - (devpriv-> - act_chanlist[j] & 0xf000) >> 12, - i, j, devpriv->ai_act_scan, n, turn, - sampl); + ("comedi%d: A/D FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n", + dev->minor, (sampl & 0xf000) >> 12, + (devpriv->act_chanlist[j] & 0xf000) >> 12, + i, j, devpriv->ai_act_scan, n, turn, + sampl); pci171x_ai_cancel(dev, s); s->async->events |= - COMEDI_CB_EOA | COMEDI_CB_ERROR; + COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return 1; } comedi_buf_put(s->async, sampl & 0x0fff); #else comedi_buf_put(s->async, - inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); + inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); #endif j++; if (j >= devpriv->ai_n_chan) { @@ -717,7 +741,7 @@ m = inw(dev->iobase + PCI171x_STATUS); if (!(m & Status_FH)) { printk("comedi%d: A/D FIFO not half full! (%4x)\n", - dev->minor, m); + dev->minor, m); pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); @@ -725,8 +749,8 @@ } if (m & Status_FF) { printk - ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", - dev->minor, m); + ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n", + dev->minor, m); pci171x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); @@ -804,7 +828,7 @@ ============================================================================== */ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, - struct comedi_subdevice *s) + struct comedi_subdevice *s) { unsigned int divisor1, divisor2; unsigned int seglen; @@ -814,11 +838,11 @@ start_pacer(dev, -1, 0, 0); /* stop pacer */ seglen = check_channel_list(dev, s, devpriv->ai_chanlist, - devpriv->ai_n_chan); + devpriv->ai_n_chan); if (seglen < 1) return -EINVAL; setup_channel_list(dev, s, devpriv->ai_chanlist, - devpriv->ai_n_chan, seglen); + devpriv->ai_n_chan, seglen); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); @@ -840,7 +864,7 @@ if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) { devpriv->neverending_ai = 1; - } /* well, user want neverending */ + } /* well, user want neverending */ else { devpriv->neverending_ai = 0; } @@ -853,16 +877,19 @@ if (mode == 2) { devpriv->ai_et_CntrlReg = devpriv->CntrlReg; devpriv->CntrlReg &= - ~(Control_PACER | Control_ONEFH | Control_GATE); + ~(Control_PACER | Control_ONEFH | Control_GATE); devpriv->CntrlReg |= Control_EXT; devpriv->ai_et = 1; } else { devpriv->ai_et = 0; } i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, - &divisor2, &devpriv->ai_timer1, - devpriv->ai_flags & TRIG_ROUND_MASK); - DPRINTK("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", devpriv->i8254_osc_base, divisor1, divisor2, devpriv->ai_timer1); + &divisor2, &devpriv->ai_timer1, + devpriv->ai_flags & TRIG_ROUND_MASK); + DPRINTK + ("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", + devpriv->i8254_osc_base, divisor1, divisor2, + devpriv->ai_timer1); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); if (mode != 2) { /* start pacer */ @@ -889,21 +916,22 @@ static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd) { printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, - cmd->start_src, cmd->scan_begin_src, cmd->convert_src); + cmd->start_src, cmd->scan_begin_src, cmd->convert_src); printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e, - cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); + cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, - cmd->scan_end_src); + cmd->scan_end_src); printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", - e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); + e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); } #endif /* ============================================================================== */ -static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pci171x_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp, divisor1, divisor2; @@ -943,7 +971,9 @@ #ifdef PCI171X_EXTDEBUG pci171x_cmdtest_out(1, cmd); #endif - DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n", err); + DPRINTK + ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n", + err); return 1; } @@ -974,7 +1004,9 @@ #ifdef PCI171X_EXTDEBUG pci171x_cmdtest_out(2, cmd); #endif - DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n", err); + DPRINTK + ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n", + err); return 2; } @@ -1030,7 +1062,9 @@ #ifdef PCI171X_EXTDEBUG pci171x_cmdtest_out(3, cmd); #endif - DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n", err); + DPRINTK + ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n", + err); return 3; } @@ -1039,8 +1073,8 @@ if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, - &divisor2, &cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); + &divisor2, &cmd->convert_arg, + cmd->flags & TRIG_ROUND_MASK); if (cmd->convert_arg < this_board->ai_ns_min) cmd->convert_arg = this_board->ai_ns_min; if (tmp != cmd->convert_arg) @@ -1048,7 +1082,9 @@ } if (err) { - DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n", err); + DPRINTK + ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n", + err); return 4; } @@ -1056,7 +1092,7 @@ if (cmd->chanlist) { if (!check_channel_list(dev, s, cmd->chanlist, - cmd->chanlist_len)) + cmd->chanlist_len)) return 5; /* incorrect channels list */ } @@ -1090,7 +1126,8 @@ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ devpriv->ai_timer1 = cmd->convert_arg; return pci171x_ai_docmd_and_mode(cmd->start_src == - TRIG_EXT ? 2 : 1, dev, s); + TRIG_EXT ? 2 : 1, dev, + s); } if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ return pci171x_ai_docmd_and_mode(3, dev, s); @@ -1106,8 +1143,9 @@ If it's ok, then program scan/gain logic. This works for all cards. */ -static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int n_chan) +static int check_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chanlist, unsigned int n_chan) { unsigned int chansegment[32]; unsigned int i, nowmustbechan, seglen, segpos; @@ -1128,18 +1166,18 @@ if (CR_CHAN(chanlist[i]) & 1) /* odd channel cann't by differencial */ if (CR_AREF(chanlist[i]) == AREF_DIFF) { comedi_error(dev, - "Odd channel can't be differential input!\n"); + "Odd channel can't be differential input!\n"); return 0; } nowmustbechan = - (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan; + (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan; if (CR_AREF(chansegment[i - 1]) == AREF_DIFF) nowmustbechan = (nowmustbechan + 1) % s->n_chan; if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */ printk - ("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", - i, CR_CHAN(chanlist[i]), nowmustbechan, - CR_CHAN(chanlist[0])); + ("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", + i, CR_CHAN(chanlist[i]), nowmustbechan, + CR_CHAN(chanlist[0])); return 0; } chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */ @@ -1149,13 +1187,13 @@ /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */ if (chanlist[i] != chansegment[i % seglen]) { printk - ("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", - i, CR_CHAN(chansegment[i]), - CR_RANGE(chansegment[i]), - CR_AREF(chansegment[i]), - CR_CHAN(chanlist[i % seglen]), - CR_RANGE(chanlist[i % seglen]), - CR_AREF(chansegment[i % seglen])); + ("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", + i, CR_CHAN(chansegment[i]), + CR_RANGE(chansegment[i]), + CR_AREF(chansegment[i]), + CR_CHAN(chanlist[i % seglen]), + CR_RANGE(chanlist[i % seglen]), + CR_AREF(chansegment[i % seglen])); return 0; /* chan/gain list is strange */ } } @@ -1165,8 +1203,10 @@ return seglen; } -static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int n_chan, unsigned int seglen) +static void setup_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chanlist, unsigned int n_chan, + unsigned int seglen) { unsigned int i, range, chanprog; @@ -1185,14 +1225,14 @@ outw(range, dev->iobase + PCI171x_RANGE); /* select gain */ #ifdef PCI171x_PARANOIDCHECK devpriv->act_chanlist[i] = - (CR_CHAN(chanlist[i]) << 12) & 0xf000; + (CR_CHAN(chanlist[i]) << 12) & 0xf000; #endif DPRINTK("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range, devpriv->act_chanlist[i]); } devpriv->ai_et_MuxVal = - CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8); + CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8); outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); /* select channel interval to scan */ DPRINTK("MUX: %4x L%4x.H%4x\n", CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8), @@ -1202,8 +1242,8 @@ /* ============================================================================== */ -static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, - unsigned int divisor2) +static void start_pacer(struct comedi_device *dev, int mode, + unsigned int divisor1, unsigned int divisor2) { DPRINTK("adv_pci1710 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1, divisor2); @@ -1222,7 +1262,8 @@ /* ============================================================================== */ -static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci171x_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cancel(...)\n"); @@ -1318,7 +1359,8 @@ /* ============================================================================== */ -static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci1710_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices; @@ -1347,36 +1389,35 @@ pcidev = NULL; board_index = this_board - boardtypes; while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH, - PCI_ANY_ID, pcidev))) { - if (strcmp (this_board->name, DRV_NAME) == 0) - { - for (i = 0; i < n_boardtypes; ++i) - { - if (pcidev->device == boardtypes[i].device_id) - { + PCI_ANY_ID, pcidev))) { + if (strcmp(this_board->name, DRV_NAME) == 0) { + for (i = 0; i < n_boardtypes; ++i) { + if (pcidev->device == boardtypes[i].device_id) { board_index = i; break; } } - if (i == n_boardtypes) continue; - }else - { - if (pcidev->device != boardtypes[board_index].device_id) continue; + if (i == n_boardtypes) + continue; + } else { + if (pcidev->device != boardtypes[board_index].device_id) + continue; } /* Found matching vendor/device. */ if (opt_bus || opt_slot) { /* Check bus/slot. */ if (opt_bus != pcidev->bus->number - || opt_slot != PCI_SLOT(pcidev->devfn)) + || opt_slot != PCI_SLOT(pcidev->devfn)) continue; /* no match */ } /* - * Look for device that isn't in use. - * Enable PCI device and request regions. - */ + * Look for device that isn't in use. + * Enable PCI device and request regions. + */ if (comedi_pci_enable(pcidev, DRV_NAME)) { - errstr = "failed to enable PCI device and request regions!"; + errstr = + "failed to enable PCI device and request regions!"; continue; } /* fixup board_ptr in case we were using the dummy entry with the driver name */ @@ -1387,7 +1428,7 @@ if (!pcidev) { if (opt_bus || opt_slot) { printk(" - Card at b:s %d:%d %s\n", - opt_bus, opt_slot, errstr); + opt_bus, opt_slot, errstr); } else { printk(" - Card %s\n", errstr); } @@ -1401,7 +1442,7 @@ iobase = pci_resource_start(pcidev, 2); printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func, - iobase); + iobase); dev->iobase = iobase; @@ -1434,8 +1475,8 @@ IRQF_SHARED, "Advantech PCI-1710", dev)) { printk - (", unable to allocate IRQ %d, DISABLING IT", - irq); + (", unable to allocate IRQ %d, DISABLING IT", + irq); irq = 0; /* Can't use IRQ */ } else { printk(", irq=%u", irq); diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci1723.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci1723.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci1723.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci1723.c 2009-07-30 09:25:31.000000000 -0700 @@ -95,8 +95,8 @@ /* static unsigned short pci_list_builded=0; =1 list of card is know */ static const struct comedi_lrange range_pci1723 = { 1, { - BIP_RANGE(10) - } + BIP_RANGE(10) + } }; /* @@ -116,23 +116,24 @@ static const struct pci1723_board boardtypes[] = { { - .name = "pci1723", - .vendor_id = ADVANTECH_VENDOR, - .device_id = 0x1723, - .iorange = IORANGE_1723, - .cardtype = TYPE_PCI1723, - .n_aochan = 8, - .n_diochan = 16, - .ao_maxdata = 0xffff, - .rangelist_ao = &range_pci1723, - }, + .name = "pci1723", + .vendor_id = ADVANTECH_VENDOR, + .device_id = 0x1723, + .iorange = IORANGE_1723, + .cardtype = TYPE_PCI1723, + .n_aochan = 8, + .n_diochan = 16, + .ao_maxdata = 0xffff, + .rangelist_ao = &range_pci1723, + }, }; /* This is used by modprobe to translate PCI IDs to drivers. Should * only be used for PCI and ISA-PnP devices */ static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = { - {PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci1723_pci_table); @@ -143,7 +144,8 @@ * the board, and also about the kernel module that contains * the device code. */ -static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci1723_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci1723_detach(struct comedi_device *dev); #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board)) @@ -189,7 +191,7 @@ /* set all ranges to +/- 10V */ devpriv->da_range[i] = 0; outw(((devpriv->da_range[i] << 4) | i), - PCI1723_RANGE_CALIBRATION_MODE); + PCI1723_RANGE_CALIBRATION_MODE); } outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); /* update ranges */ @@ -202,8 +204,9 @@ return 0; } -static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1723_insn_read_ao(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; @@ -218,8 +221,9 @@ /* analog data output; */ -static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1723_ao_write_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n, chan; chan = CR_CHAN(insn->chanspec); @@ -238,8 +242,9 @@ /* digital i/o config/query */ -static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1723_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { unsigned int mask; unsigned int bits; @@ -278,8 +283,9 @@ /* digital i/o bits read/write */ -static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1723_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (data[0]) { s->state &= ~data[0]; @@ -294,7 +300,8 @@ * Attach is called by the Comedi core to configure the driver * for a pci1723 board. */ -static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci1723_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices; @@ -304,8 +311,7 @@ int opt_bus, opt_slot; const char *errstr; - printk("comedi%d: adv_pci1723: board=%s", dev->minor, - this_board->name); + printk("comedi%d: adv_pci1723: board=%s", dev->minor, this_board->name); opt_bus = it->options[0]; opt_slot = it->options[1]; @@ -321,12 +327,12 @@ pcidev = NULL; while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH, - this_board->device_id, pcidev))) { + this_board->device_id, pcidev))) { /* Found matching vendor/device. */ if (opt_bus || opt_slot) { /* Check bus/slot. */ if (opt_bus != pcidev->bus->number - || opt_slot != PCI_SLOT(pcidev->devfn)) + || opt_slot != PCI_SLOT(pcidev->devfn)) continue; /* no match */ } /* @@ -334,7 +340,8 @@ * Enable PCI device and request regions. */ if (comedi_pci_enable(pcidev, "adv_pci1723")) { - errstr = "failed to enable PCI device and request regions!"; + errstr = + "failed to enable PCI device and request regions!"; continue; } break; @@ -343,7 +350,7 @@ if (!pcidev) { if (opt_bus || opt_slot) { printk(" - Card at b:s %d:%d %s\n", - opt_bus, opt_slot, errstr); + opt_bus, opt_slot, errstr); } else { printk(" - Card %s\n", errstr); } @@ -356,7 +363,7 @@ iobase = pci_resource_start(pcidev, 2); printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func, - iobase); + iobase); dev->iobase = iobase; @@ -416,7 +423,7 @@ s = dev->subdevices + subdev; s->type = COMEDI_SUBD_DIO; s->subdev_flags = - SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->n_diochan; s->maxdata = 1; s->len_chanlist = this_board->n_diochan; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci_dio.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci_dio.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/adv_pci_dio.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/adv_pci_dio.c 2009-07-30 09:25:31.000000000 -0700 @@ -84,13 +84,13 @@ #define PCI173x_BOARDID 4 /* R: Board I/D switch for 1730/3/4 */ /* Advantech PCI-1736UP */ -#define PCI1736_IDI 0 /* R: Isolated digital input 0-15 */ -#define PCI1736_IDO 0 /* W: Isolated digital output 0-15 */ -#define PCI1736_3_INT_EN 0x08 /* R/W: enable/disable interrupts */ -#define PCI1736_3_INT_RF 0x0c /* R/W: set falling/raising edge for interrupts */ -#define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ -#define PCI1736_BOARDID 4 /* R: Board I/D switch for 1736UP */ -#define PCI1736_MAINREG 0 /* Normal register (2) doesn't work */ +#define PCI1736_IDI 0 /* R: Isolated digital input 0-15 */ +#define PCI1736_IDO 0 /* W: Isolated digital output 0-15 */ +#define PCI1736_3_INT_EN 0x08 /* R/W: enable/disable interrupts */ +#define PCI1736_3_INT_RF 0x0c /* R/W: set falling/raising edge for interrupts */ +#define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ +#define PCI1736_BOARDID 4 /* R: Board I/D switch for 1736UP */ +#define PCI1736_MAINREG 0 /* Normal register (2) doesn't work */ /* Advantech PCI-1750 */ #define PCI1750_IDI 0 /* R: Isolated digital input 0-15 */ @@ -183,7 +183,8 @@ #define OMBCMD_RETRY 0x03 /* 3 times try request before error */ -static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci_dio_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci_dio_detach(struct comedi_device *dev); struct diosubd_data { @@ -207,117 +208,118 @@ }; static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = { - {PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci_dio_pci_table); static const struct dio_boardtype boardtypes[] = { {"pci1730", PCI_VENDOR_ID_ADVANTECH, 0x1730, PCIDIO_MAINREG, - TYPE_PCI1730, - {{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}}, - {{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, - IO_8b, - }, + TYPE_PCI1730, + {{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}}, + {{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, + IO_8b, + }, {"pci1733", PCI_VENDOR_ID_ADVANTECH, 0x1733, PCIDIO_MAINREG, - TYPE_PCI1733, - {{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, - IO_8b}, + TYPE_PCI1733, + {{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, + IO_8b}, {"pci1734", PCI_VENDOR_ID_ADVANTECH, 0x1734, PCIDIO_MAINREG, - TYPE_PCI1734, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, - IO_8b}, + TYPE_PCI1734, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI173x_BOARDID, 1, SDF_INTERNAL}, + IO_8b}, {"pci1736", PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI1736_MAINREG, - TYPE_PCI1736, - {{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}}, - {{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}}, - {{ 0, 0, 0, 0}, { 0, 0, 0, 0}}, - { 4, PCI1736_BOARDID, 1, SDF_INTERNAL}, - IO_8b, - }, + TYPE_PCI1736, + {{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}}, + {{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI1736_BOARDID, 1, SDF_INTERNAL}, + IO_8b, + }, {"pci1750", PCI_VENDOR_ID_ADVANTECH, 0x1750, PCIDIO_MAINREG, - TYPE_PCI1750, - {{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}}, - {{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {0, 0, 0, 0}, - IO_8b}, + TYPE_PCI1750, + {{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}}, + {{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {0, 0, 0, 0}, + IO_8b}, {"pci1751", PCI_VENDOR_ID_ADVANTECH, 0x1751, PCIDIO_MAINREG, - TYPE_PCI1751, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}}, - {0, 0, 0, 0}, - IO_8b}, + TYPE_PCI1751, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}}, + {0, 0, 0, 0}, + IO_8b}, {"pci1752", PCI_VENDOR_ID_ADVANTECH, 0x1752, PCIDIO_MAINREG, - TYPE_PCI1752, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, - IO_16b}, + TYPE_PCI1752, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, + IO_16b}, {"pci1753", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG, - TYPE_PCI1753, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}}, - {0, 0, 0, 0}, - IO_8b}, + TYPE_PCI1753, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}}, + {0, 0, 0, 0}, + IO_8b}, {"pci1753e", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG, - TYPE_PCI1753E, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}}, - {0, 0, 0, 0}, - IO_8b}, + TYPE_PCI1753E, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}}, + {0, 0, 0, 0}, + IO_8b}, {"pci1754", PCI_VENDOR_ID_ADVANTECH, 0x1754, PCIDIO_MAINREG, - TYPE_PCI1754, - {{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, - IO_16b}, + TYPE_PCI1754, + {{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, + IO_16b}, {"pci1756", PCI_VENDOR_ID_ADVANTECH, 0x1756, PCIDIO_MAINREG, - TYPE_PCI1756, - {{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}}, - {{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, - IO_16b}, + TYPE_PCI1756, + {{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}}, + {{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI175x_BOARDID, 1, SDF_INTERNAL}, + IO_16b}, {"pci1760", PCI_VENDOR_ID_ADVANTECH, 0x1760, 0, - TYPE_PCI1760, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, /* This card have own setup work */ - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {0, 0, 0, 0}, - IO_8b}, + TYPE_PCI1760, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, /* This card have own setup work */ + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {0, 0, 0, 0}, + IO_8b}, {"pci1762", PCI_VENDOR_ID_ADVANTECH, 0x1762, PCIDIO_MAINREG, - TYPE_PCI1762, - {{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}}, - {{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}}, - {{0, 0, 0, 0}, {0, 0, 0, 0}}, - {4, PCI1762_BOARDID, 1, SDF_INTERNAL}, - IO_16b} + TYPE_PCI1762, + {{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}}, + {{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}}, + {{0, 0, 0, 0}, {0, 0, 0, 0}}, + {4, PCI1762_BOARDID, 1, SDF_INTERNAL}, + IO_16b} }; #define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype)) @@ -357,8 +359,9 @@ /* ============================================================================== */ -static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci_dio_insn_bits_di_b(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -374,8 +377,9 @@ /* ============================================================================== */ -static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci_dio_insn_bits_di_w(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -390,8 +394,9 @@ /* ============================================================================== */ -static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci_dio_insn_bits_do_b(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -401,7 +406,7 @@ s->state |= (data[0] & data[1]); for (i = 0; i < d->regs; i++) outb((s->state >> (8 * i)) & 0xff, - dev->iobase + d->addr + i); + dev->iobase + d->addr + i); } data[1] = s->state; @@ -411,8 +416,9 @@ /* ============================================================================== */ -static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci_dio_insn_bits_do_w(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct diosubd_data *d = (const struct diosubd_data *)s->private; int i; @@ -422,7 +428,7 @@ s->state |= (data[0] & data[1]); for (i = 0; i < d->regs; i++) outw((s->state >> (16 * i)) & 0xffff, - dev->iobase + d->addr + 2 * i); + dev->iobase + d->addr + 2 * i); } data[1] = s->state; @@ -433,7 +439,8 @@ ============================================================================== */ static int pci1760_unchecked_mbxrequest(struct comedi_device *dev, - unsigned char *omb, unsigned char *imb, int repeats) + unsigned char *omb, unsigned char *imb, + int repeats) { int cnt, tout, ok = 0; @@ -472,11 +479,11 @@ } static int pci1760_mbxrequest(struct comedi_device *dev, - unsigned char *omb, unsigned char *imb) + unsigned char *omb, unsigned char *imb) { if (omb[2] == CMD_ClearIMB2) { comedi_error(dev, - "bug! this function should not be used for CMD_ClearIMB2 command"); + "bug! this function should not be used for CMD_ClearIMB2 command"); return -EINVAL; } if (inb(dev->iobase + IMB2) == omb[2]) { @@ -491,8 +498,9 @@ /* ============================================================================== */ -static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1760_insn_bits_di(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[1] = inb(dev->iobase + IMB3); @@ -502,8 +510,9 @@ /* ============================================================================== */ -static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1760_insn_bits_do(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret; unsigned char omb[4] = { @@ -530,8 +539,9 @@ /* ============================================================================== */ -static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1760_insn_cnt_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret, n; unsigned char omb[4] = { @@ -555,8 +565,9 @@ /* ============================================================================== */ -static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1760_insn_cnt_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int ret; unsigned char chan = CR_CHAN(insn->chanspec) & 0x07; @@ -570,7 +581,7 @@ unsigned char imb[4]; if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) { /* Set reset value if different */ - ret = pci1760_mbxrequest(dev, omb, imb); + ret = pci1760_mbxrequest(dev, omb, imb); if (!ret) return ret; devpriv->CntResValue[chan] = data[0] & 0xffff; @@ -697,11 +708,11 @@ break; case TYPE_PCI1736: - outb(0, dev->iobase+PCI1736_IDO); - outb(0, dev->iobase+PCI1736_IDO+1); - outb(0, dev->iobase+PCI1736_3_INT_EN); /* disable interrupts */ - outb(0x0f, dev->iobase+PCI1736_3_INT_CLR);/* clear interrupts */ - outb(0, dev->iobase+PCI1736_3_INT_RF); /* set rising edge trigger */ + outb(0, dev->iobase + PCI1736_IDO); + outb(0, dev->iobase + PCI1736_IDO + 1); + outb(0, dev->iobase + PCI1736_3_INT_EN); /* disable interrupts */ + outb(0x0f, dev->iobase + PCI1736_3_INT_CLR); /* clear interrupts */ + outb(0, dev->iobase + PCI1736_3_INT_RF); /* set rising edge trigger */ break; case TYPE_PCI1750: @@ -756,7 +767,8 @@ /* ============================================================================== */ -static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci1760_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int subdev = 0; @@ -809,7 +821,7 @@ ============================================================================== */ static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s, - const struct diosubd_data *d, int subdev) + const struct diosubd_data *d, int subdev) { s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags; @@ -836,7 +848,7 @@ ============================================================================== */ static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s, - const struct diosubd_data *d, int subdev) + const struct diosubd_data *d, int subdev) { s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; @@ -863,8 +875,9 @@ /* ============================================================================== */ -static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig *it, - struct pci_dev *pcidev) +static int CheckAndAllocCard(struct comedi_device *dev, + struct comedi_devconfig *it, + struct pci_dev *pcidev) { struct pci_dio_private *pr, *prev; @@ -889,7 +902,8 @@ /* ============================================================================== */ -static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int pci_dio_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct comedi_subdevice *s; int ret, subdev, n_subdevices, i, j; @@ -905,8 +919,8 @@ } for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pcidev != NULL; - pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { /* loop through cards supported by this driver */ for (i = 0; i < n_boardtypes; ++i) { if (boardtypes[i].vendor_id != pcidev->vendor) @@ -917,13 +931,13 @@ if (it->options[0] || it->options[1]) { /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || - PCI_SLOT(pcidev->devfn) != - it->options[1]) { + PCI_SLOT(pcidev->devfn) != it->options[1]) { continue; } } ret = CheckAndAllocCard(dev, it, pcidev); - if (ret != 1) continue; + if (ret != 1) + continue; dev->board_ptr = boardtypes + i; break; } @@ -932,20 +946,19 @@ } if (!dev->board_ptr) { - printk - (", Error: Requested type of the card was not found!\n"); + printk(", Error: Requested type of the card was not found!\n"); return -EIO; } if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) { printk - (", Error: Can't enable PCI device and request regions!\n"); + (", Error: Can't enable PCI device and request regions!\n"); return -EIO; } iobase = pci_resource_start(pcidev, this_board->main_pci_region); printk(", b:s:f=%d:%d:%d, io=0x%4lx", - pcidev->bus->number, PCI_SLOT(pcidev->devfn), - PCI_FUNC(pcidev->devfn), iobase); + pcidev->bus->number, PCI_SLOT(pcidev->devfn), + PCI_FUNC(pcidev->devfn), iobase); dev->iobase = iobase; dev->board_name = this_board->name; @@ -994,8 +1007,9 @@ for (j = 0; j < this_board->sdio[i].regs; j++) { s = dev->subdevices + subdev; subdev_8255_init(dev, s, NULL, - dev->iobase + this_board->sdio[i].addr + - SIZE_8255 * j); + dev->iobase + + this_board->sdio[i].addr + + SIZE_8255 * j); subdev++; } diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/aio_aio12_8.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/aio_aio12_8.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/aio_aio12_8.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/aio_aio12_8.c 2009-07-30 09:25:31.000000000 -0700 @@ -77,7 +77,7 @@ static const struct aio12_8_boardtype board_types[] = { { - .name = "aio_aio12_8"}, + .name = "aio_aio12_8"}, }; #define thisboard ((const struct aio12_8_boardtype *) dev->board_ptr) @@ -88,13 +88,14 @@ #define devpriv ((struct aio12_8_private *) dev->private) -static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int aio_aio12_8_ai_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int n; unsigned char control = - ADC_MODE_NORMAL | - (CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec); + ADC_MODE_NORMAL | + (CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec); /* read status to clear EOC latch */ inb(dev->iobase + AIO12_8_STATUS); @@ -107,7 +108,7 @@ /* Wait for conversion to complete */ while (timeout && - !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) { + !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) { timeout--; printk("timeout %d\n", timeout); udelay(1); @@ -122,8 +123,9 @@ return n; } -static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int aio_aio12_8_ao_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int val = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; @@ -133,8 +135,9 @@ return insn->n; } -static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int aio_aio12_8_ao_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -154,14 +157,15 @@ static const struct comedi_lrange range_aio_aio12_8 = { 4, { - UNI_RANGE(5), - BIP_RANGE(5), - UNI_RANGE(10), - BIP_RANGE(10), - } + UNI_RANGE(5), + BIP_RANGE(5), + UNI_RANGE(10), + BIP_RANGE(10), + } }; -static int aio_aio12_8_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int aio_aio12_8_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { int iobase; struct comedi_subdevice *s; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/aio_iiro_16.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/aio_iiro_16.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/aio_iiro_16.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/aio_iiro_16.c 2009-07-30 09:25:31.000000000 -0700 @@ -52,9 +52,9 @@ static const struct aio_iiro_16_board aio_iiro_16_boards[] = { { - .name = "aio_iiro_16", - .di = 16, - .do_ = 16}, + .name = "aio_iiro_16", + .di = 16, + .do_ = 16}, }; #define thisboard ((const struct aio_iiro_16_board *) dev->board_ptr) @@ -67,7 +67,8 @@ #define devpriv ((struct aio_iiro_16_private *) dev->private) -static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int aio_iiro_16_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int aio_iiro_16_detach(struct comedi_device *dev); @@ -82,12 +83,17 @@ }; static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); -static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int aio_iiro_16_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { int iobase; struct comedi_subdevice *s; @@ -143,7 +149,9 @@ } static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -153,7 +161,7 @@ s->state |= data[0] & data[1]; outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7); outb((s->state >> 8) & 0xff, - dev->iobase + AIO_IIRO_16_RELAY_8_15); + dev->iobase + AIO_IIRO_16_RELAY_8_15); } data[1] = s->state; @@ -162,7 +170,9 @@ } static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { if (insn->n != 2) return -EINVAL; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_dio200.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_dio200.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_dio200.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_dio200.c 2009-07-30 09:25:31.000000000 -0700 @@ -290,60 +290,60 @@ static const struct dio200_board dio200_boards[] = { { - .name = "pc212e", - .bustype = isa_bustype, - .model = pc212e_model, - .layout = pc212_layout, - }, + .name = "pc212e", + .bustype = isa_bustype, + .model = pc212e_model, + .layout = pc212_layout, + }, { - .name = "pc214e", - .bustype = isa_bustype, - .model = pc214e_model, - .layout = pc214_layout, - }, + .name = "pc214e", + .bustype = isa_bustype, + .model = pc214e_model, + .layout = pc214_layout, + }, { - .name = "pc215e", - .bustype = isa_bustype, - .model = pc215e_model, - .layout = pc215_layout, - }, + .name = "pc215e", + .bustype = isa_bustype, + .model = pc215e_model, + .layout = pc215_layout, + }, #ifdef CONFIG_COMEDI_PCI { - .name = "pci215", - .devid = PCI_DEVICE_ID_AMPLICON_PCI215, - .bustype = pci_bustype, - .model = pci215_model, - .layout = pc215_layout, - }, + .name = "pci215", + .devid = PCI_DEVICE_ID_AMPLICON_PCI215, + .bustype = pci_bustype, + .model = pci215_model, + .layout = pc215_layout, + }, #endif { - .name = "pc218e", - .bustype = isa_bustype, - .model = pc218e_model, - .layout = pc218_layout, - }, + .name = "pc218e", + .bustype = isa_bustype, + .model = pc218e_model, + .layout = pc218_layout, + }, { - .name = "pc272e", - .bustype = isa_bustype, - .model = pc272e_model, - .layout = pc272_layout, - }, + .name = "pc272e", + .bustype = isa_bustype, + .model = pc272e_model, + .layout = pc272_layout, + }, #ifdef CONFIG_COMEDI_PCI { - .name = "pci272", - .devid = PCI_DEVICE_ID_AMPLICON_PCI272, - .bustype = pci_bustype, - .model = pci272_model, - .layout = pc272_layout, - }, + .name = "pci272", + .devid = PCI_DEVICE_ID_AMPLICON_PCI272, + .bustype = pci_bustype, + .model = pci272_model, + .layout = pc272_layout, + }, #endif #ifdef CONFIG_COMEDI_PCI { - .name = DIO200_DRIVER_NAME, - .devid = PCI_DEVICE_ID_INVALID, - .bustype = pci_bustype, - .model = anypci_model, /* wildcard */ - }, + .name = DIO200_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ + }, #endif }; @@ -367,51 +367,51 @@ static const struct dio200_layout_struct dio200_layouts[] = { [pc212_layout] = { - .n_subdevs = 6, - .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254, - sd_8254, - sd_intr}, - .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14, - 0x3F}, - .has_int_sce = 1, - .has_clk_gat_sce = 1, - }, + .n_subdevs = 6, + .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254, + sd_8254, + sd_intr}, + .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14, + 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 1, + }, [pc214_layout] = { - .n_subdevs = 4, - .sdtype = {sd_8255, sd_8255, sd_8254, - sd_intr}, - .sdinfo = {0x00, 0x08, 0x10, 0x01}, - .has_int_sce = 0, - .has_clk_gat_sce = 0, - }, + .n_subdevs = 4, + .sdtype = {sd_8255, sd_8255, sd_8254, + sd_intr}, + .sdinfo = {0x00, 0x08, 0x10, 0x01}, + .has_int_sce = 0, + .has_clk_gat_sce = 0, + }, [pc215_layout] = { - .n_subdevs = 5, - .sdtype = {sd_8255, sd_8255, sd_8254, - sd_8254, - sd_intr}, - .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F}, - .has_int_sce = 1, - .has_clk_gat_sce = 1, - }, + .n_subdevs = 5, + .sdtype = {sd_8255, sd_8255, sd_8254, + sd_8254, + sd_intr}, + .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 1, + }, [pc218_layout] = { - .n_subdevs = 7, - .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254, - sd_8254, - sd_intr}, - .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10, - 0x14, - 0x3F}, - .has_int_sce = 1, - .has_clk_gat_sce = 1, - }, + .n_subdevs = 7, + .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254, + sd_8254, + sd_intr}, + .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10, + 0x14, + 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 1, + }, [pc272_layout] = { - .n_subdevs = 4, - .sdtype = {sd_8255, sd_8255, sd_8255, - sd_intr}, - .sdinfo = {0x00, 0x08, 0x10, 0x3F}, - .has_int_sce = 1, - .has_clk_gat_sce = 0, - }, + .n_subdevs = 4, + .sdtype = {sd_8255, sd_8255, sd_8255, + sd_intr}, + .sdinfo = {0x00, 0x08, 0x10, 0x3F}, + .has_int_sce = 1, + .has_clk_gat_sce = 0, + }, }; /* @@ -420,11 +420,12 @@ #ifdef CONFIG_COMEDI_PCI static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = { - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, dio200_pci_table); @@ -475,7 +476,8 @@ * the board, and also about the kernel module that contains * the device code. */ -static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int dio200_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int dio200_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_dio200 = { .driver_name = DIO200_DRIVER_NAME, @@ -500,7 +502,7 @@ #ifdef CONFIG_COMEDI_PCI static int dio200_find_pci(struct comedi_device *dev, int bus, int slot, - struct pci_dev **pci_dev_p) + struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -508,13 +510,13 @@ /* Look for matching PCI device. */ for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, - PCI_ANY_ID, pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, + PCI_ANY_ID, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number - || slot != PCI_SLOT(pci_dev->devfn)) + || slot != PCI_SLOT(pci_dev->devfn)) continue; } if (thisboard->model == anypci_model) { @@ -545,11 +547,11 @@ /* No match found. */ if (bus || slot) { printk(KERN_ERR - "comedi%d: error! no %s found at pci %02x:%02x!\n", - dev->minor, thisboard->name, bus, slot); + "comedi%d: error! no %s found at pci %02x:%02x!\n", + dev->minor, thisboard->name, bus, slot); } else { printk(KERN_ERR "comedi%d: error! no %s found!\n", - dev->minor, thisboard->name); + dev->minor, thisboard->name); } return -EIO; } @@ -564,7 +566,7 @@ { if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) { printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n", - minor, from, extent); + minor, from, extent); return -EIO; } return 0; @@ -574,8 +576,9 @@ * 'insn_bits' function for an 'INTERRUPT' subdevice. */ static int -dio200_subdev_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +dio200_subdev_intr_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_intr *subpriv = s->private; @@ -593,7 +596,8 @@ /* * Called to stop acquisition for an 'INTERRUPT' subdevice. */ -static void dio200_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s) +static void dio200_stop_intr(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -607,7 +611,8 @@ /* * Called to start acquisition for an 'INTERRUPT' subdevice. */ -static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice *s) +static int dio200_start_intr(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned int n; unsigned isn_bits; @@ -644,7 +649,7 @@ */ static int dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trignum) { struct dio200_subdev_intr *subpriv; unsigned long flags; @@ -673,7 +678,8 @@ * This is called from the interrupt service routine to handle a read * scan on an 'INTERRUPT' subdevice. */ -static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subdevice *s) +static int dio200_handle_read_intr(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; unsigned triggered; @@ -699,7 +705,7 @@ */ cur_enabled = subpriv->enabled_isns; while ((intstat = (inb(subpriv->iobase) & subpriv->valid_isns - & ~triggered)) != 0) { + & ~triggered)) != 0) { triggered |= intstat; cur_enabled &= ~triggered; outb(cur_enabled, subpriv->iobase); @@ -748,12 +754,12 @@ /* Write the scan to the buffer. */ if (comedi_buf_put(s->async, val)) { s->async->events |= (COMEDI_CB_BLOCK | - COMEDI_CB_EOS); + COMEDI_CB_EOS); } else { /* Error! Stop acquisition. */ dio200_stop_intr(dev, s); s->async->events |= COMEDI_CB_ERROR - | COMEDI_CB_OVERFLOW; + | COMEDI_CB_OVERFLOW; comedi_error(dev, "buffer overflow"); } @@ -764,9 +770,9 @@ subpriv->stopcount--; if (subpriv->stopcount == 0) { s->async->events |= - COMEDI_CB_EOA; + COMEDI_CB_EOA; dio200_stop_intr(dev, - s); + s); } } } @@ -785,7 +791,8 @@ /* * 'cancel' function for an 'INTERRUPT' subdevice. */ -static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int dio200_subdev_intr_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; unsigned long flags; @@ -803,8 +810,8 @@ * 'do_cmdtest' function for an 'INTERRUPT' subdevice. */ static int -dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +dio200_subdev_intr_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -909,7 +916,8 @@ /* * 'do_cmd' function for an 'INTERRUPT' subdevice. */ -static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) +static int dio200_subdev_intr_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; struct dio200_subdev_intr *subpriv = s->private; @@ -956,14 +964,15 @@ */ static int dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned long iobase, unsigned valid_isns, int has_int_sce) + unsigned long iobase, unsigned valid_isns, + int has_int_sce) { struct dio200_subdev_intr *subpriv; subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); if (!subpriv) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return -ENOMEM; } subpriv->iobase = iobase; @@ -1000,7 +1009,8 @@ * This function cleans up an 'INTERRUPT' subdevice. */ static void -dio200_subdev_intr_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) +dio200_subdev_intr_cleanup(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -1023,7 +1033,8 @@ if (devpriv->intr_sd >= 0) { handled = dio200_handle_read_intr(dev, - dev->subdevices + devpriv->intr_sd); + dev->subdevices + + devpriv->intr_sd); } else { handled = 0; } @@ -1036,7 +1047,7 @@ */ static int dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int chan = CR_CHAN(insn->chanspec); @@ -1051,7 +1062,7 @@ */ static int dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int chan = CR_CHAN(insn->chanspec); @@ -1065,8 +1076,8 @@ * Set gate source for an '8254' counter subdevice channel. */ static int -dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, - unsigned int gate_src) +dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, + unsigned int counter_number, unsigned int gate_src) { unsigned char byte; @@ -1088,7 +1099,8 @@ * Get gate source for an '8254' counter subdevice channel. */ static int -dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number) +dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, + unsigned int counter_number) { if (!subpriv->has_clk_gat_sce) return -1; @@ -1102,8 +1114,8 @@ * Set clock source for an '8254' counter subdevice channel. */ static int -dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, - unsigned int clock_src) +dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, + unsigned int counter_number, unsigned int clock_src) { unsigned char byte; @@ -1125,8 +1137,8 @@ * Get clock source for an '8254' counter subdevice channel. */ static int -dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number, - unsigned int *period_ns) +dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, + unsigned int counter_number, unsigned int *period_ns) { unsigned clock_src; @@ -1145,7 +1157,7 @@ */ static int dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { struct dio200_subdev_8254 *subpriv = s->private; int ret; @@ -1197,7 +1209,8 @@ */ static int dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned long iobase, unsigned offset, int has_clk_gat_sce) + unsigned long iobase, unsigned offset, + int has_clk_gat_sce) { struct dio200_subdev_8254 *subpriv; unsigned int chan; @@ -1205,7 +1218,7 @@ subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); if (!subpriv) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return -ENOMEM; } @@ -1224,16 +1237,16 @@ /* Derive CLK_SCE and GAT_SCE register offsets from * 8254 offset. */ subpriv->clk_sce_iobase = - DIO200_XCLK_SCE + (offset >> 3) + iobase; + DIO200_XCLK_SCE + (offset >> 3) + iobase; subpriv->gat_sce_iobase = - DIO200_XGAT_SCE + (offset >> 3) + iobase; + DIO200_XGAT_SCE + (offset >> 3) + iobase; subpriv->which = (offset >> 2) & 1; } /* Initialize channels. */ for (chan = 0; chan < 3; chan++) { i8254_set_mode(subpriv->iobase, 0, chan, - I8254_MODE0 | I8254_BINARY); + I8254_MODE0 | I8254_BINARY); if (subpriv->has_clk_gat_sce) { /* Gate source 0 is VCC (logic 1). */ dio200_set_gate_src(subpriv, chan, 0); @@ -1249,7 +1262,8 @@ * This function cleans up an '8254' counter subdevice. */ static void -dio200_subdev_8254_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) +dio200_subdev_8254_cleanup(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dio200_subdev_intr *subpriv = s->private; @@ -1280,12 +1294,12 @@ int ret; printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, - DIO200_DRIVER_NAME); + DIO200_DRIVER_NAME); ret = alloc_private(dev, sizeof(struct dio200_private)); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -1310,8 +1324,8 @@ #endif default: printk(KERN_ERR - "comedi%d: %s: BUG! cannot determine board type!\n", - dev->minor, DIO200_DRIVER_NAME); + "comedi%d: %s: BUG! cannot determine board type!\n", + dev->minor, DIO200_DRIVER_NAME); return -EINVAL; break; } @@ -1324,8 +1338,8 @@ ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME); if (ret < 0) { printk(KERN_ERR - "comedi%d: error! cannot enable PCI device and request regions!\n", - dev->minor); + "comedi%d: error! cannot enable PCI device and request regions!\n", + dev->minor); return ret; } iobase = pci_resource_start(pci_dev, 2); @@ -1345,7 +1359,7 @@ ret = alloc_subdevices(dev, layout->n_subdevs); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -1355,7 +1369,8 @@ case sd_8254: /* counter subdevice (8254) */ ret = dio200_subdev_8254_init(dev, s, iobase, - layout->sdinfo[n], layout->has_clk_gat_sce); + layout->sdinfo[n], + layout->has_clk_gat_sce); if (ret < 0) { return ret; } @@ -1363,7 +1378,7 @@ case sd_8255: /* digital i/o subdevice (8255) */ ret = subdev_8255_init(dev, s, 0, - iobase + layout->sdinfo[n]); + iobase + layout->sdinfo[n]); if (ret < 0) { return ret; } @@ -1372,8 +1387,11 @@ /* 'INTERRUPT' subdevice */ if (irq) { ret = dio200_subdev_intr_init(dev, s, - iobase + DIO200_INT_SCE, - layout->sdinfo[n], layout->has_int_sce); + iobase + + DIO200_INT_SCE, + layout->sdinfo[n], + layout-> + has_int_sce); if (ret < 0) { return ret; } @@ -1403,8 +1421,8 @@ dev->irq = irq; } else { printk(KERN_WARNING - "comedi%d: warning! irq %u unavailable!\n", - dev->minor, irq); + "comedi%d: warning! irq %u unavailable!\n", + dev->minor, irq); } } @@ -1441,7 +1459,7 @@ unsigned n; printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, - DIO200_DRIVER_NAME); + DIO200_DRIVER_NAME); if (dev->irq) { free_irq(dev->irq, dev); @@ -1482,7 +1500,7 @@ } if (dev->board_name) { printk(KERN_INFO "comedi%d: %s removed\n", - dev->minor, dev->board_name); + dev->minor, dev->board_name); } return 0; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pc236.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pc236.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pc236.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pc236.c 2009-07-30 09:25:31.000000000 -0700 @@ -107,36 +107,37 @@ }; static const struct pc236_board pc236_boards[] = { { - .name = "pc36at", - .fancy_name = "PC36AT", - .bustype = isa_bustype, - .model = pc36at_model, - }, + .name = "pc36at", + .fancy_name = "PC36AT", + .bustype = isa_bustype, + .model = pc36at_model, + }, #ifdef CONFIG_COMEDI_PCI { - .name = "pci236", - .fancy_name = "PCI236", - .devid = PCI_DEVICE_ID_AMPLICON_PCI236, - .bustype = pci_bustype, - .model = pci236_model, - }, + .name = "pci236", + .fancy_name = "PCI236", + .devid = PCI_DEVICE_ID_AMPLICON_PCI236, + .bustype = pci_bustype, + .model = pci236_model, + }, #endif #ifdef CONFIG_COMEDI_PCI { - .name = PC236_DRIVER_NAME, - .fancy_name = PC236_DRIVER_NAME, - .devid = PCI_DEVICE_ID_INVALID, - .bustype = pci_bustype, - .model = anypci_model, /* wildcard */ - }, + .name = PC236_DRIVER_NAME, + .fancy_name = PC236_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ + }, #endif }; #ifdef CONFIG_COMEDI_PCI static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = { - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pc236_pci_table); @@ -186,16 +187,20 @@ #endif static int pc236_request_region(unsigned minor, unsigned long from, - unsigned long extent); + unsigned long extent); static void pc236_intr_disable(struct comedi_device *dev); static void pc236_intr_enable(struct comedi_device *dev); static int pc236_intr_check(struct comedi_device *dev); -static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); -static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static int pc236_intr_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); +static int pc236_intr_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int pc236_intr_cmd(struct comedi_device *dev, + struct comedi_subdevice *s); +static int pc236_intr_cancel(struct comedi_device *dev, + struct comedi_subdevice *s); static irqreturn_t pc236_interrupt(int irq, void *d); /* @@ -205,7 +210,7 @@ #ifdef CONFIG_COMEDI_PCI static int pc236_find_pci(struct comedi_device *dev, int bus, int slot, - struct pci_dev **pci_dev_p) + struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -213,13 +218,13 @@ /* Look for matching PCI device. */ for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, - PCI_ANY_ID, pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, + PCI_ANY_ID, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number - || slot != PCI_SLOT(pci_dev->devfn)) + || slot != PCI_SLOT(pci_dev->devfn)) continue; } if (thisboard->model == anypci_model) { @@ -250,11 +255,11 @@ /* No match found. */ if (bus || slot) { printk(KERN_ERR - "comedi%d: error! no %s found at pci %02x:%02x!\n", - dev->minor, thisboard->name, bus, slot); + "comedi%d: error! no %s found at pci %02x:%02x!\n", + dev->minor, thisboard->name, bus, slot); } else { printk(KERN_ERR "comedi%d: error! no %s found!\n", - dev->minor, thisboard->name); + dev->minor, thisboard->name); } return -EIO; } @@ -279,7 +284,7 @@ int ret; printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, - PC236_DRIVER_NAME); + PC236_DRIVER_NAME); /* * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. @@ -287,7 +292,7 @@ ret = alloc_private(dev, sizeof(struct pc236_private)); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } /* Process options. */ @@ -311,8 +316,8 @@ #endif /* CONFIG_COMEDI_PCI */ default: printk(KERN_ERR - "comedi%d: %s: BUG! cannot determine board type!\n", - dev->minor, PC236_DRIVER_NAME); + "comedi%d: %s: BUG! cannot determine board type!\n", + dev->minor, PC236_DRIVER_NAME); return -EINVAL; break; } @@ -329,8 +334,8 @@ ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME); if (ret < 0) { printk(KERN_ERR - "comedi%d: error! cannot enable PCI device and request regions!\n", - dev->minor); + "comedi%d: error! cannot enable PCI device and request regions!\n", + dev->minor); return ret; } devpriv->lcr_iobase = pci_resource_start(pci_dev, 1); @@ -353,7 +358,7 @@ ret = alloc_subdevices(dev, 2); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -362,7 +367,7 @@ ret = subdev_8255_init(dev, s, NULL, iobase); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } s = dev->subdevices + 1; @@ -416,7 +421,7 @@ static int pc236_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, - PC236_DRIVER_NAME); + PC236_DRIVER_NAME); if (devpriv) { pc236_intr_disable(dev); } @@ -442,7 +447,7 @@ } if (dev->board_name) { printk(KERN_INFO "comedi%d: %s removed\n", - dev->minor, dev->board_name); + dev->minor, dev->board_name); } return 0; } @@ -452,11 +457,11 @@ * if there is a conflict. */ static int pc236_request_region(unsigned minor, unsigned long from, - unsigned long extent) + unsigned long extent) { if (!from || !request_region(from, extent, PC236_DRIVER_NAME)) { printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n", - minor, from, extent); + minor, from, extent); return -EIO; } return 0; @@ -516,13 +521,13 @@ #ifdef CONFIG_COMEDI_PCI if (devpriv->lcr_iobase) { if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR) - & PLX9052_INTCSR_LI1STAT_MASK) - == PLX9052_INTCSR_LI1STAT_INACTIVE) { + & PLX9052_INTCSR_LI1STAT_MASK) + == PLX9052_INTCSR_LI1STAT_INACTIVE) { retval = 0; } else { /* Clear interrupt and keep it enabled. */ outl(PCI236_INTR_ENABLE, - devpriv->lcr_iobase + PLX9052_INTCSR); + devpriv->lcr_iobase + PLX9052_INTCSR); } } #endif @@ -536,8 +541,9 @@ * Input from subdevice 1. * Copied from the comedi_parport driver. */ -static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pc236_intr_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { data[1] = 0; return 2; @@ -547,8 +553,9 @@ * Subdevice 1 command test. * Copied from the comedi_parport driver. */ -static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pc236_intr_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -635,7 +642,8 @@ /* * Subdevice 1 cancel command. */ -static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pc236_intr_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { pc236_intr_disable(dev); diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pc263.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pc263.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pc263.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pc263.c 2009-07-30 09:25:31.000000000 -0700 @@ -74,36 +74,37 @@ }; static const struct pc263_board pc263_boards[] = { { - .name = "pc263", - .fancy_name = "PC263", - .bustype = isa_bustype, - .model = pc263_model, - }, + .name = "pc263", + .fancy_name = "PC263", + .bustype = isa_bustype, + .model = pc263_model, + }, #ifdef CONFIG_COMEDI_PCI { - .name = "pci263", - .fancy_name = "PCI263", - .devid = PCI_DEVICE_ID_AMPLICON_PCI263, - .bustype = pci_bustype, - .model = pci263_model, - }, + .name = "pci263", + .fancy_name = "PCI263", + .devid = PCI_DEVICE_ID_AMPLICON_PCI263, + .bustype = pci_bustype, + .model = pci263_model, + }, #endif #ifdef CONFIG_COMEDI_PCI { - .name = PC263_DRIVER_NAME, - .fancy_name = PC263_DRIVER_NAME, - .devid = PCI_DEVICE_ID_INVALID, - .bustype = pci_bustype, - .model = anypci_model, /* wildcard */ - }, + .name = PC263_DRIVER_NAME, + .fancy_name = PC263_DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .bustype = pci_bustype, + .model = anypci_model, /* wildcard */ + }, #endif }; #ifdef CONFIG_COMEDI_PCI static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = { - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263, PCI_ANY_ID, - PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pc263_pci_table); @@ -145,11 +146,13 @@ }; static int pc263_request_region(unsigned minor, unsigned long from, - unsigned long extent); -static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + unsigned long extent); +static int pc263_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int pc263_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); /* * This function looks for a PCI device matching the requested board name, @@ -158,7 +161,7 @@ #ifdef CONFIG_COMEDI_PCI static int pc263_find_pci(struct comedi_device *dev, int bus, int slot, - struct pci_dev **pci_dev_p) + struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -166,13 +169,13 @@ /* Look for matching PCI device. */ for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, - PCI_ANY_ID, pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, + PCI_ANY_ID, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number - || slot != PCI_SLOT(pci_dev->devfn)) + || slot != PCI_SLOT(pci_dev->devfn)) continue; } if (thisboard->model == anypci_model) { @@ -203,11 +206,11 @@ /* No match found. */ if (bus || slot) { printk(KERN_ERR - "comedi%d: error! no %s found at pci %02x:%02x!\n", - dev->minor, thisboard->name, bus, slot); + "comedi%d: error! no %s found at pci %02x:%02x!\n", + dev->minor, thisboard->name, bus, slot); } else { printk(KERN_ERR "comedi%d: error! no %s found!\n", - dev->minor, thisboard->name); + dev->minor, thisboard->name); } return -EIO; } @@ -230,7 +233,7 @@ int ret; printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, - PC263_DRIVER_NAME); + PC263_DRIVER_NAME); /* * Allocate the private structure area. alloc_private() is a * convenient macro defined in comedidev.h. @@ -239,7 +242,7 @@ ret = alloc_private(dev, sizeof(struct pc263_private)); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } #endif @@ -261,8 +264,8 @@ #endif /* CONFIG_COMEDI_PCI */ default: printk(KERN_ERR - "comedi%d: %s: BUG! cannot determine board type!\n", - dev->minor, PC263_DRIVER_NAME); + "comedi%d: %s: BUG! cannot determine board type!\n", + dev->minor, PC263_DRIVER_NAME); return -EINVAL; break; } @@ -278,8 +281,8 @@ ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME); if (ret < 0) { printk(KERN_ERR - "comedi%d: error! cannot enable PCI device and request regions!\n", - dev->minor); + "comedi%d: error! cannot enable PCI device and request regions!\n", + dev->minor); return ret; } iobase = pci_resource_start(pci_dev, 2); @@ -300,7 +303,7 @@ ret = alloc_subdevices(dev, 1); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -344,7 +347,7 @@ static int pc263_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, - PC263_DRIVER_NAME); + PC263_DRIVER_NAME); #ifdef CONFIG_COMEDI_PCI if (devpriv) @@ -366,7 +369,7 @@ } if (dev->board_name) { printk(KERN_INFO "comedi%d: %s removed\n", - dev->minor, dev->board_name); + dev->minor, dev->board_name); } return 0; } @@ -376,11 +379,11 @@ * if there is a conflict. */ static int pc263_request_region(unsigned minor, unsigned long from, - unsigned long extent) + unsigned long extent) { if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) { printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n", - minor, from, extent); + minor, from, extent); return -EIO; } return 0; @@ -391,8 +394,9 @@ * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pc263_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -416,8 +420,9 @@ return 2; } -static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pc263_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 1) return -EINVAL; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pci224.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pci224.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pci224.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pci224.c 2009-07-30 09:25:31.000000000 -0700 @@ -283,15 +283,15 @@ static const struct comedi_lrange range_pci224_internal = { 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), - UNI_RANGE(1.25), - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25), + } }; static const unsigned short hwrange_pci224_internal[8] = { @@ -309,9 +309,9 @@ static const struct comedi_lrange range_pci224_external = { 2, { - RANGE_ext(-1, 1), /* bipolar [-Vref,+Vref] */ - RANGE_ext(0, 1), /* unipolar [0,+Vref] */ - } + RANGE_ext(-1, 1), /* bipolar [-Vref,+Vref] */ + RANGE_ext(0, 1), /* unipolar [0,+Vref] */ + } }; static const unsigned short hwrange_pci224_external[2] = { @@ -324,8 +324,8 @@ static const struct comedi_lrange range_pci234_ext2 = { 1, { - RANGE_ext(-2, 2), - } + RANGE_ext(-2, 2), + } }; /* The hardware selectable Vref external range for PCI234 @@ -333,8 +333,8 @@ static const struct comedi_lrange range_pci234_ext = { 1, { - RANGE_ext(-1, 1), - } + RANGE_ext(-1, 1), + } }; /* This serves for all the PCI234 ranges. */ @@ -358,24 +358,24 @@ static const struct pci224_board pci224_boards[] = { { - .name = "pci224", - .devid = PCI_DEVICE_ID_AMPLICON_PCI224, - .model = pci224_model, - .ao_chans = 16, - .ao_bits = 12, - }, + .name = "pci224", + .devid = PCI_DEVICE_ID_AMPLICON_PCI224, + .model = pci224_model, + .ao_chans = 16, + .ao_bits = 12, + }, { - .name = "pci234", - .devid = PCI_DEVICE_ID_AMPLICON_PCI234, - .model = pci234_model, - .ao_chans = 4, - .ao_bits = 16, - }, + .name = "pci234", + .devid = PCI_DEVICE_ID_AMPLICON_PCI234, + .model = pci234_model, + .ao_chans = 4, + .ao_bits = 16, + }, { - .name = DRIVER_NAME, - .devid = PCI_DEVICE_ID_INVALID, - .model = any_model, /* wildcard */ - }, + .name = DRIVER_NAME, + .devid = PCI_DEVICE_ID_INVALID, + .model = any_model, /* wildcard */ + }, }; /* @@ -383,11 +383,12 @@ */ static DEFINE_PCI_DEVICE_TABLE(pci224_pci_table) = { - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci224_pci_table); @@ -428,7 +429,8 @@ * the board, and also about the kernel module that contains * the device code. */ -static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci224_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci224_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pci224 = { .driver_name = DRIVER_NAME, @@ -446,7 +448,8 @@ * Called from the 'insn_write' function to perform a single write. */ static void -pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data) +pci224_ao_set_data(struct comedi_device *dev, int chan, int range, + unsigned int data) { unsigned short mangled; @@ -456,9 +459,10 @@ outw(1 << chan, dev->iobase + PCI224_DACCEN); /* Set range and reset FIFO. */ devpriv->daccon = COMBINE(devpriv->daccon, devpriv->hwrange[range], - (PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK)); + (PCI224_DACCON_POLAR_MASK | + PCI224_DACCON_VREF_MASK)); outw(devpriv->daccon | PCI224_DACCON_FIFORESET, - dev->iobase + PCI224_DACCON); + dev->iobase + PCI224_DACCON); /* * Mangle the data. The hardware expects: * - bipolar: 16-bit 2's complement @@ -466,7 +470,7 @@ */ mangled = (unsigned short)data << (16 - thisboard->ao_bits); if ((devpriv->daccon & PCI224_DACCON_POLAR_MASK) == - PCI224_DACCON_POLAR_BI) { + PCI224_DACCON_POLAR_BI) { mangled ^= 0x8000; } /* Write mangled data to the FIFO. */ @@ -480,7 +484,7 @@ */ static int pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { int i; int chan, range; @@ -507,7 +511,7 @@ */ static int pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -526,7 +530,7 @@ */ static void pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2, - unsigned int *nanosec, int round_mode) + unsigned int *nanosec, int round_mode) { i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode); } @@ -534,7 +538,8 @@ /* * Kills a command running on the AO subdevice. */ -static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci224_ao_stop(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long flags; @@ -565,16 +570,19 @@ /* Reconfigure DAC for insn_write usage. */ outw(0, dev->iobase + PCI224_DACCEN); /* Disable channels. */ devpriv->daccon = COMBINE(devpriv->daccon, - PCI224_DACCON_TRIG_SW | PCI224_DACCON_FIFOINTR_EMPTY, - PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK); + PCI224_DACCON_TRIG_SW | + PCI224_DACCON_FIFOINTR_EMPTY, + PCI224_DACCON_TRIG_MASK | + PCI224_DACCON_FIFOINTR_MASK); outw(devpriv->daccon | PCI224_DACCON_FIFORESET, - dev->iobase + PCI224_DACCON); + dev->iobase + PCI224_DACCON); } /* * Handles start of acquisition for the AO subdevice. */ -static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci224_ao_start(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; @@ -601,7 +609,8 @@ /* * Handles interrupts from the DAC FIFO. */ -static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci224_ao_handle_fifo(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int num_scans; @@ -630,8 +639,7 @@ switch (dacstat & PCI224_DACCON_FIFOFL_MASK) { case PCI224_DACCON_FIFOFL_EMPTY: room = PCI224_FIFO_ROOM_EMPTY; - if (!devpriv->ao_stop_continuous - && devpriv->ao_stop_count == 0) { + if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) { /* FIFO empty at end of counted acquisition. */ pci224_ao_stop(dev, s); s->async->events |= COMEDI_CB_EOA; @@ -656,7 +664,7 @@ pci224_ao_stop(dev, s); s->async->events |= COMEDI_CB_OVERFLOW; printk(KERN_ERR "comedi%d: " - "AO buffer underrun\n", dev->minor); + "AO buffer underrun\n", dev->minor); } } /* Determine how many new scans can be put in the FIFO. */ @@ -670,11 +678,10 @@ /* Process scans. */ for (n = 0; n < num_scans; n++) { cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0], - bytes_per_scan); + bytes_per_scan); for (i = 0; i < cmd->chanlist_len; i++) { - outw(devpriv->ao_scan_vals[devpriv-> - ao_scan_order[i]], - dev->iobase + PCI224_DACDATA); + outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]], + dev->iobase + PCI224_DACDATA); } } if (!devpriv->ao_stop_continuous) { @@ -685,14 +692,13 @@ * until FIFO is empty. */ devpriv->daccon = COMBINE(devpriv->daccon, - PCI224_DACCON_FIFOINTR_EMPTY, - PCI224_DACCON_FIFOINTR_MASK); - outw(devpriv->daccon, - dev->iobase + PCI224_DACCON); + PCI224_DACCON_FIFOINTR_EMPTY, + PCI224_DACCON_FIFOINTR_MASK); + outw(devpriv->daccon, dev->iobase + PCI224_DACCON); } } if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) == - PCI224_DACCON_TRIG_NONE) { + PCI224_DACCON_TRIG_NONE) { unsigned short trig; /* @@ -718,7 +724,7 @@ } } devpriv->daccon = COMBINE(devpriv->daccon, trig, - PCI224_DACCON_TRIG_MASK); + PCI224_DACCON_TRIG_MASK); outw(devpriv->daccon, dev->iobase + PCI224_DACCON); } if (s->async->events) { @@ -731,7 +737,7 @@ */ static int pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trignum) { if (trignum != 0) return -EINVAL; @@ -750,7 +756,8 @@ * 'do_cmdtest' function for AO subdevice. */ static int -pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) +pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -828,13 +835,13 @@ /* Force to external trigger 0. */ if ((cmd->start_arg & ~CR_FLAGS_MASK) != 0) { cmd->start_arg = COMBINE(cmd->start_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* The only flag allowed is CR_EDGE, which is ignored. */ if ((cmd->start_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) { cmd->start_arg = COMBINE(cmd->start_arg, 0, - CR_FLAGS_MASK & ~CR_EDGE); + CR_FLAGS_MASK & ~CR_EDGE); err++; } break; @@ -859,14 +866,16 @@ /* Force to external trigger 0. */ if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) { cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* Only allow flags CR_EDGE and CR_INVERT. Ignore CR_EDGE. */ if ((cmd->scan_begin_arg & CR_FLAGS_MASK & - ~(CR_EDGE | CR_INVERT)) != 0) { + ~(CR_EDGE | CR_INVERT)) != 0) { cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0, - CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT)); + CR_FLAGS_MASK & ~(CR_EDGE + | + CR_INVERT)); err++; } break; @@ -892,13 +901,13 @@ /* Force to external trigger 0. */ if ((cmd->stop_arg & ~CR_FLAGS_MASK) != 0) { cmd->stop_arg = COMBINE(cmd->stop_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* The only flag allowed is CR_EDGE, which is ignored. */ if ((cmd->stop_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) { cmd->stop_arg = COMBINE(cmd->stop_arg, 0, - CR_FLAGS_MASK & ~CR_EDGE); + CR_FLAGS_MASK & ~CR_EDGE); } break; case TRIG_NONE: @@ -935,14 +944,14 @@ /* Be careful to avoid overflow! */ div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ; div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) / - TIMEBASE_10MHZ; + TIMEBASE_10MHZ; if (div2 <= 0x10000) { /* A single timer will suffice. */ if (div2 < 2) div2 = 2; cmd->scan_begin_arg = div2 * TIMEBASE_10MHZ; if (cmd->scan_begin_arg < div2 || - cmd->scan_begin_arg < TIMEBASE_10MHZ) { + cmd->scan_begin_arg < TIMEBASE_10MHZ) { /* Overflow! */ cmd->scan_begin_arg = MAX_SCAN_PERIOD; } @@ -951,7 +960,8 @@ div1 = devpriv->cached_div1; div2 = devpriv->cached_div2; pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2, - &cmd->scan_begin_arg, round_mode); + &cmd->scan_begin_arg, + round_mode); devpriv->cached_div1 = div1; devpriv->cached_div2 = div2; } @@ -1061,12 +1071,15 @@ * N.B. DAC FIFO interrupts are currently disabled. */ devpriv->daccon = COMBINE(devpriv->daccon, - (devpriv->hwrange[range] | PCI224_DACCON_TRIG_NONE | - PCI224_DACCON_FIFOINTR_NHALF), - (PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK | - PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK)); + (devpriv-> + hwrange[range] | PCI224_DACCON_TRIG_NONE | + PCI224_DACCON_FIFOINTR_NHALF), + (PCI224_DACCON_POLAR_MASK | + PCI224_DACCON_VREF_MASK | + PCI224_DACCON_TRIG_MASK | + PCI224_DACCON_FIFOINTR_MASK)); outw(devpriv->daccon | PCI224_DACCON_FIFORESET, - dev->iobase + PCI224_DACCON); + dev->iobase + PCI224_DACCON); if (cmd->scan_begin_src == TRIG_TIMER) { unsigned int div1, div2, round; @@ -1089,7 +1102,7 @@ /* Be careful to avoid overflow! */ div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ; div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) / - TIMEBASE_10MHZ; + TIMEBASE_10MHZ; if (div2 <= 0x10000) { /* A single timer will suffice. */ if (div2 < 2) @@ -1101,7 +1114,7 @@ div1 = devpriv->cached_div1; div2 = devpriv->cached_div2; pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2, - &ns, round_mode); + &ns, round_mode); } /* @@ -1110,25 +1123,25 @@ */ /* Make sure Z2-0 is gated on. */ outb(GAT_CONFIG(0, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); + devpriv->iobase1 + PCI224_ZGAT_SCE); if (div1 == 1) { /* Not cascading. Z2-0 needs 10 MHz clock. */ outb(CLK_CONFIG(0, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); + devpriv->iobase1 + PCI224_ZCLK_SCE); } else { /* Cascading with Z2-2. */ /* Make sure Z2-2 is gated on. */ outb(GAT_CONFIG(2, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); + devpriv->iobase1 + PCI224_ZGAT_SCE); /* Z2-2 needs 10 MHz clock. */ outb(CLK_CONFIG(2, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); + devpriv->iobase1 + PCI224_ZCLK_SCE); /* Load Z2-2 mode (2) and counter (div1). */ i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, - 2, div1, 2); + 2, div1, 2); /* Z2-0 is clocked from Z2-2's output. */ outb(CLK_CONFIG(0, CLK_OUTNM1), - devpriv->iobase1 + PCI224_ZCLK_SCE); + devpriv->iobase1 + PCI224_ZCLK_SCE); } /* Load Z2-0 mode (2) and counter (div2). */ i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2); @@ -1174,7 +1187,8 @@ /* * 'cancel' function for AO subdevice. */ -static int pci224_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci224_ao_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { pci224_ao_stop(dev, s); return 0; @@ -1184,8 +1198,8 @@ * 'munge' data for AO command. */ static void -pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, - unsigned int num_bytes, unsigned int chan_index) +pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, + void *data, unsigned int num_bytes, unsigned int chan_index) { struct comedi_async *async = s->async; short *array = data; @@ -1198,7 +1212,7 @@ shift = 16 - thisboard->ao_bits; /* Channels will be all bipolar or all unipolar. */ if ((devpriv->hwrange[CR_RANGE(async->cmd.chanlist[0])] & - PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) { + PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) { /* Unipolar */ offset = 0; } else { @@ -1253,7 +1267,7 @@ spin_lock_irqsave(&devpriv->ao_spinlock, flags); if (curenab != devpriv->intsce) { outb(devpriv->intsce, - devpriv->iobase1 + PCI224_INT_SCE); + devpriv->iobase1 + PCI224_INT_SCE); } devpriv->intr_running = 0; spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); @@ -1267,7 +1281,7 @@ */ static int pci224_find_pci(struct comedi_device *dev, int bus, int slot, - struct pci_dev **pci_dev_p) + struct pci_dev **pci_dev_p) { struct pci_dev *pci_dev = NULL; @@ -1275,13 +1289,13 @@ /* Look for matching PCI device. */ for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, - pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, + pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number - || slot != PCI_SLOT(pci_dev->devfn)) + || slot != PCI_SLOT(pci_dev->devfn)) continue; } if (thisboard->model == any_model) { @@ -1310,11 +1324,11 @@ /* No match found. */ if (bus || slot) { printk(KERN_ERR "comedi%d: error! " - "no %s found at pci %02x:%02x!\n", - dev->minor, thisboard->name, bus, slot); + "no %s found at pci %02x:%02x!\n", + dev->minor, thisboard->name, bus, slot); } else { printk(KERN_ERR "comedi%d: error! no %s found!\n", - dev->minor, thisboard->name); + dev->minor, thisboard->name); } return -EIO; } @@ -1341,7 +1355,7 @@ ret = alloc_private(dev, sizeof(struct pci224_private)); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -1353,8 +1367,8 @@ ret = comedi_pci_enable(pci_dev, DRIVER_NAME); if (ret < 0) { printk(KERN_ERR - "comedi%d: error! cannot enable PCI device " - "and request regions!\n", dev->minor); + "comedi%d: error! cannot enable PCI device " + "and request regions!\n", dev->minor); return ret; } spin_lock_init(&devpriv->ao_spinlock); @@ -1365,21 +1379,21 @@ /* Allocate readback buffer for AO channels. */ devpriv->ao_readback = kmalloc(sizeof(devpriv->ao_readback[0]) * - thisboard->ao_chans, GFP_KERNEL); + thisboard->ao_chans, GFP_KERNEL); if (!devpriv->ao_readback) { return -ENOMEM; } /* Allocate buffer to hold values for AO channel scan. */ devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) * - thisboard->ao_chans, GFP_KERNEL); + thisboard->ao_chans, GFP_KERNEL); if (!devpriv->ao_scan_vals) { return -ENOMEM; } /* Allocate buffer to hold AO channel scan order. */ devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) * - thisboard->ao_chans, GFP_KERNEL); + thisboard->ao_chans, GFP_KERNEL); if (!devpriv->ao_scan_order) { return -ENOMEM; } @@ -1393,15 +1407,16 @@ outw(0, dev->iobase + PCI224_DACCEN); outw(0, dev->iobase + PCI224_FIFOSIZ); devpriv->daccon = (PCI224_DACCON_TRIG_SW | PCI224_DACCON_POLAR_BI | - PCI224_DACCON_FIFOENAB | PCI224_DACCON_FIFOINTR_EMPTY); + PCI224_DACCON_FIFOENAB | + PCI224_DACCON_FIFOINTR_EMPTY); outw(devpriv->daccon | PCI224_DACCON_FIFORESET, - dev->iobase + PCI224_DACCON); + dev->iobase + PCI224_DACCON); /* Allocate subdevices. There is only one! */ ret = alloc_subdevices(dev, 1); if (ret < 0) { printk(KERN_ERR "comedi%d: error! out of memory!\n", - dev->minor); + dev->minor); return ret; } @@ -1427,22 +1442,22 @@ const struct comedi_lrange **range_table_list; s->range_table_list = range_table_list = - kmalloc(sizeof(struct comedi_lrange *) * s->n_chan, - GFP_KERNEL); + kmalloc(sizeof(struct comedi_lrange *) * s->n_chan, + GFP_KERNEL); if (!s->range_table_list) { return -ENOMEM; } for (n = 2; n < 3 + s->n_chan; n++) { if (it->options[n] < 0 || it->options[n] > 1) { printk(KERN_WARNING "comedi%d: %s: warning! " - "bad options[%u]=%d\n", - dev->minor, DRIVER_NAME, n, - it->options[n]); + "bad options[%u]=%d\n", + dev->minor, DRIVER_NAME, n, + it->options[n]); } } for (n = 0; n < s->n_chan; n++) { if (n < COMEDI_NDEVCONFOPTS - 3 && - it->options[3 + n] == 1) { + it->options[3 + n] == 1) { if (it->options[2] == 1) { range_table_list[n] = &range_pci234_ext; } else { @@ -1451,7 +1466,7 @@ } else { if (it->options[2] == 1) { range_table_list[n] = - &range_pci234_ext2; + &range_pci234_ext2; } else { range_table_list[n] = &range_bipolar10; } @@ -1466,9 +1481,8 @@ } else { if (it->options[2] != 0) { printk(KERN_WARNING "comedi%d: %s: warning! " - "bad options[2]=%d\n", - dev->minor, DRIVER_NAME, - it->options[2]); + "bad options[2]=%d\n", + dev->minor, DRIVER_NAME, it->options[2]); } s->range_table = &range_pci224_internal; devpriv->hwrange = hwrange_pci224_internal; @@ -1482,7 +1496,7 @@ DRIVER_NAME, dev); if (ret < 0) { printk(KERN_ERR "comedi%d: error! " - "unable to allocate irq %u\n", dev->minor, irq); + "unable to allocate irq %u\n", dev->minor, irq); return ret; } else { dev->irq = irq; @@ -1545,7 +1559,7 @@ } if (dev->board_name) { printk(KERN_INFO "comedi%d: %s removed\n", - dev->minor, dev->board_name); + dev->minor, dev->board_name); } return 0; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pci230.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pci230.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/amplc_pci230.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/amplc_pci230.c 2009-07-30 09:25:44.000000000 -0700 @@ -457,62 +457,63 @@ }; static const struct pci230_board pci230_boards[] = { { - .name = "pci230+", - .id = PCI_DEVICE_ID_PCI230, - .ai_chans = 16, - .ai_bits = 16, - .ao_chans = 2, - .ao_bits = 12, - .have_dio = 1, - .min_hwver = 1, - }, + .name = "pci230+", + .id = PCI_DEVICE_ID_PCI230, + .ai_chans = 16, + .ai_bits = 16, + .ao_chans = 2, + .ao_bits = 12, + .have_dio = 1, + .min_hwver = 1, + }, { - .name = "pci260+", - .id = PCI_DEVICE_ID_PCI260, - .ai_chans = 16, - .ai_bits = 16, - .ao_chans = 0, - .ao_bits = 0, - .have_dio = 0, - .min_hwver = 1, - }, + .name = "pci260+", + .id = PCI_DEVICE_ID_PCI260, + .ai_chans = 16, + .ai_bits = 16, + .ao_chans = 0, + .ao_bits = 0, + .have_dio = 0, + .min_hwver = 1, + }, { - .name = "pci230", - .id = PCI_DEVICE_ID_PCI230, - .ai_chans = 16, - .ai_bits = 12, - .ao_chans = 2, - .ao_bits = 12, - .have_dio = 1, - }, + .name = "pci230", + .id = PCI_DEVICE_ID_PCI230, + .ai_chans = 16, + .ai_bits = 12, + .ao_chans = 2, + .ao_bits = 12, + .have_dio = 1, + }, { - .name = "pci260", - .id = PCI_DEVICE_ID_PCI260, - .ai_chans = 16, - .ai_bits = 12, - .ao_chans = 0, - .ao_bits = 0, - .have_dio = 0, - }, + .name = "pci260", + .id = PCI_DEVICE_ID_PCI260, + .ai_chans = 16, + .ai_bits = 12, + .ao_chans = 0, + .ao_bits = 0, + .have_dio = 0, + }, { - .name = "amplc_pci230", /* Wildcard matches any above */ - .id = PCI_DEVICE_ID_INVALID, - }, + .name = "amplc_pci230", /* Wildcard matches any above */ + .id = PCI_DEVICE_ID_INVALID, + }, }; static DEFINE_PCI_DEVICE_TABLE(pci230_pci_table) = { - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230, PCI_ANY_ID, PCI_ANY_ID, - 0, 0, 0}, - {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260, PCI_ANY_ID, PCI_ANY_ID, - 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, { + PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0}, { + 0} }; MODULE_DEVICE_TABLE(pci, pci230_pci_table); /* * Useful for shorthand access to the particular board structure */ -#define n_pci230_boards (sizeof(pci230_boards)/sizeof(pci230_boards[0])) +#define n_pci230_boards ARRAY_SIZE(pci230_boards) #define thisboard ((const struct pci230_board *)dev->board_ptr) /* this structure is for data unique to this hardware driver. If @@ -571,14 +572,14 @@ /* PCI230 analogue input range table */ static const struct comedi_lrange pci230_ai_range = { 7, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5) - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5) + } }; /* PCI230 analogue gain bits for each input range. */ @@ -589,9 +590,9 @@ /* PCI230 analogue output range table */ static const struct comedi_lrange pci230_ao_range = { 2, { - UNI_RANGE(10), - BIP_RANGE(10) - } + UNI_RANGE(10), + BIP_RANGE(10) + } }; /* PCI230 daccon bipolar flag for each analogue output range. */ @@ -603,7 +604,8 @@ * the board, and also about the kernel module that contains * the device code. */ -static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int pci230_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int pci230_detach(struct comedi_device *dev); static struct comedi_driver driver_amplc_pci230 = { .driver_name = "amplc_pci230", @@ -617,35 +619,48 @@ COMEDI_PCI_INITCLEANUP(driver_amplc_pci230, pci230_pci_table); -static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int pci230_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); +static int pci230_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); +static int pci230_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, - unsigned int mode, uint64_t ns, unsigned int round); + unsigned int mode, uint64_t ns, + unsigned int round); static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round); static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct); static irqreturn_t pci230_interrupt(int irq, void *d); -static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); +static int pci230_ao_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd); static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s); -static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s); -static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s); -static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); +static int pci230_ao_cancel(struct comedi_device *dev, + struct comedi_subdevice *s); +static void pci230_ao_stop(struct comedi_device *dev, + struct comedi_subdevice *s); +static void pci230_handle_ao_nofifo(struct comedi_device *dev, + struct comedi_subdevice *s); +static int pci230_handle_ao_fifo(struct comedi_device *dev, + struct comedi_subdevice *s); +static int pci230_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd); static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s); -static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s); +static int pci230_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s); +static void pci230_ai_stop(struct comedi_device *dev, + struct comedi_subdevice *s); +static void pci230_handle_ai(struct comedi_device *dev, + struct comedi_subdevice *s); static short pci230_ai_read(struct comedi_device *dev) { /* Read sample. */ - short data = (short) inw(dev->iobase + PCI230_ADCDATA); + short data = (short)inw(dev->iobase + PCI230_ADCDATA); /* PCI230 is 12 bit - stored in upper bits of 16 bit register (lower * four bits reserved for expansion). */ @@ -661,7 +676,7 @@ } static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev, - short datum) + short datum) { /* If a bipolar range was specified, mangle it (straight binary->twos * complement). */ @@ -676,26 +691,28 @@ return (unsigned short)datum; } -static inline void pci230_ao_write_nofifo(struct comedi_device *dev, short datum, - unsigned int chan) +static inline void pci230_ao_write_nofifo(struct comedi_device *dev, + short datum, unsigned int chan) { /* Store unmangled datum to be read back later. */ devpriv->ao_readback[chan] = datum; /* Write mangled datum to appropriate DACOUT register. */ outw(pci230_ao_mangle_datum(dev, datum), dev->iobase + (((chan) == 0) - ? PCI230_DACOUT1 : PCI230_DACOUT2)); + ? PCI230_DACOUT1 + : + PCI230_DACOUT2)); } static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum, - unsigned int chan) + unsigned int chan) { /* Store unmangled datum to be read back later. */ devpriv->ao_readback[chan] = datum; /* Write mangled datum to appropriate DACDATA register. */ outw(pci230_ao_mangle_datum(dev, datum), - dev->iobase + PCI230P2_DACDATA); + dev->iobase + PCI230P2_DACDATA); } /* @@ -713,7 +730,7 @@ int i = 0, irq_hdl, rc; printk("comedi%d: amplc_pci230: attach %s %d,%d\n", dev->minor, - thisboard->name, it->options[0], it->options[1]); + thisboard->name, it->options[0], it->options[1]); /* Allocate the private structure area using alloc_private(). * Macro defined in comedidev.h - memsets struct fields to 0. */ @@ -726,12 +743,12 @@ spin_lock_init(&devpriv->ao_stop_spinlock); /* Find card */ for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pci_dev != NULL; - pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { + pci_dev != NULL; + pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if (it->options[0] || it->options[1]) { /* Match against bus/slot options. */ if (it->options[0] != pci_dev->bus->number || - it->options[1] != PCI_SLOT(pci_dev->devfn)) + it->options[1] != PCI_SLOT(pci_dev->devfn)) continue; } if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON) @@ -748,7 +765,7 @@ * First check length of * registers. */ if (pci_resource_len(pci_dev, 3) - < 32) { + < 32) { /* Not a '+' model. */ continue; } @@ -790,7 +807,7 @@ } if (!pci_dev) { printk("comedi%d: No %s card found\n", dev->minor, - thisboard->name); + thisboard->name); return -EIO; } devpriv->pci_dev = pci_dev; @@ -803,7 +820,7 @@ /* Enable PCI device and reserve I/O spaces. */ if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) { printk("comedi%d: failed to enable PCI device " - "and request regions\n", dev->minor); + "and request regions\n", dev->minor); return -EIO; } @@ -813,7 +830,7 @@ iobase2 = pci_resource_start(pci_dev, 3); printk("comedi%d: %s I/O region 1 0x%04lx I/O region 2 0x%04lx\n", - dev->minor, dev->board_name, iobase1, iobase2); + dev->minor, dev->board_name, iobase1, iobase2); devpriv->iobase1 = iobase1; dev->iobase = iobase2; @@ -829,9 +846,9 @@ devpriv->hwver = inw(dev->iobase + PCI230P_HWVER); if (devpriv->hwver < thisboard->min_hwver) { printk("comedi%d: %s - bad hardware version " - "- got %u, need %u\n", dev->minor, - dev->board_name, devpriv->hwver, - thisboard->min_hwver); + "- got %u, need %u\n", dev->minor, + dev->board_name, devpriv->hwver, + thisboard->min_hwver); return -EIO; } if (devpriv->hwver > 0) { @@ -844,7 +861,7 @@ extfunc |= PCI230P_EXTFUNC_GAT_EXTTRIG; } if ((thisboard->ao_chans > 0) - && (devpriv->hwver >= 2)) { + && (devpriv->hwver >= 2)) { /* Enable DAC FIFO functionality. */ extfunc |= PCI230P2_EXTFUNC_DACFIFO; } @@ -854,8 +871,8 @@ /* Temporarily enable DAC FIFO, reset it and disable * FIFO wraparound. */ outw(devpriv->daccon | PCI230P2_DAC_FIFO_EN - | PCI230P2_DAC_FIFO_RESET, - dev->iobase + PCI230_DACCON); + | PCI230P2_DAC_FIFO_RESET, + dev->iobase + PCI230_DACCON); /* Clear DAC FIFO channel enable register. */ outw(0, dev->iobase + PCI230P2_DACEN); /* Disable DAC FIFO. */ @@ -869,23 +886,23 @@ /* Set ADC to a reasonable state. */ devpriv->adcg = 0; devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE - | PCI230_ADC_IR_BIP; + | PCI230_ADC_IR_BIP; outw(1 << 0, dev->iobase + PCI230_ADCEN); outw(devpriv->adcg, dev->iobase + PCI230_ADCG); outw(devpriv->adccon | PCI230_ADC_FIFO_RESET, - dev->iobase + PCI230_ADCCON); + dev->iobase + PCI230_ADCCON); /* Register the interrupt handler. */ irq_hdl = request_irq(devpriv->pci_dev->irq, pci230_interrupt, IRQF_SHARED, "amplc_pci230", dev); if (irq_hdl < 0) { printk("comedi%d: unable to register irq, " - "commands will not be available %d\n", dev->minor, - devpriv->pci_dev->irq); + "commands will not be available %d\n", dev->minor, + devpriv->pci_dev->irq); } else { dev->irq = devpriv->pci_dev->irq; printk("comedi%d: registered irq %u\n", dev->minor, - devpriv->pci_dev->irq); + devpriv->pci_dev->irq); } /* @@ -941,7 +958,7 @@ /* digital i/o subdevice */ if (thisboard->have_dio) { rc = subdev_8255_init(dev, s, NULL, - (devpriv->iobase1 + PCI230_PPI_X_BASE)); + (devpriv->iobase1 + PCI230_PPI_X_BASE)); if (rc < 0) return rc; } else { @@ -985,7 +1002,7 @@ } static int get_resources(struct comedi_device *dev, unsigned int res_mask, - unsigned char owner) + unsigned char owner) { int ok; unsigned int i; @@ -997,7 +1014,7 @@ claimed = 0; spin_lock_irqsave(&devpriv->res_spinlock, irqflags); for (b = 1, i = 0; (i < NUM_RESOURCES) - && (res_mask != 0); b <<= 1, i++) { + && (res_mask != 0); b <<= 1, i++) { if ((res_mask & b) != 0) { res_mask &= ~b; if (devpriv->res_owner[i] == OWNER_NONE) { @@ -1007,7 +1024,7 @@ for (b = 1, i = 0; claimed != 0; b <<= 1, i++) { if ((claimed & b) != 0) { devpriv->res_owner[i] - = OWNER_NONE; + = OWNER_NONE; claimed &= ~b; } } @@ -1020,14 +1037,14 @@ return ok; } -static inline int get_one_resource(struct comedi_device *dev, unsigned int resource, - unsigned char owner) +static inline int get_one_resource(struct comedi_device *dev, + unsigned int resource, unsigned char owner) { return get_resources(dev, (1U << resource), owner); } static void put_resources(struct comedi_device *dev, unsigned int res_mask, - unsigned char owner) + unsigned char owner) { unsigned int i; unsigned int b; @@ -1035,7 +1052,7 @@ spin_lock_irqsave(&devpriv->res_spinlock, irqflags); for (b = 1, i = 0; (i < NUM_RESOURCES) - && (res_mask != 0); b <<= 1, i++) { + && (res_mask != 0); b <<= 1, i++) { if ((res_mask & b) != 0) { res_mask &= ~b; if (devpriv->res_owner[i] == owner) { @@ -1046,13 +1063,14 @@ spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); } -static inline void put_one_resource(struct comedi_device *dev, unsigned int resource, - unsigned char owner) +static inline void put_one_resource(struct comedi_device *dev, + unsigned int resource, unsigned char owner) { put_resources(dev, (1U << resource), owner); } -static inline void put_all_resources(struct comedi_device *dev, unsigned char owner) +static inline void put_all_resources(struct comedi_device *dev, + unsigned char owner) { put_resources(dev, (1U << NUM_RESOURCES) - 1, owner); } @@ -1060,8 +1078,9 @@ /* * COMEDI_SUBD_AI instruction; */ -static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci230_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { unsigned int n, i; unsigned int chan, range, aref; @@ -1112,7 +1131,7 @@ adccon |= PCI230_ADC_IM_SE; } devpriv->adcg = (devpriv->adcg & ~(3 << gainshift)) - | (pci230_ai_gain[range] << gainshift); + | (pci230_ai_gain[range] << gainshift); if (devpriv->ai_bipolar) { adccon |= PCI230_ADC_IR_BIP; } else { @@ -1135,9 +1154,9 @@ /* Trigger conversion by toggling Z2-CT2 output (finish with * output high). */ i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, - I8254_MODE0); + I8254_MODE0); i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, - I8254_MODE1); + I8254_MODE1); #define TIMEOUT 100 /* wait for conversion to end */ @@ -1165,8 +1184,9 @@ /* * COMEDI_SUBD_AO instructions; */ -static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci230_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { int i; int chan, range; @@ -1193,8 +1213,9 @@ /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci230_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -1205,8 +1226,8 @@ return i; } -static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pci230_ao_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -1317,17 +1338,16 @@ /* Trigger number must be 0. */ if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) { cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* The only flags allowed are CR_EDGE and CR_INVERT. The * CR_EDGE flag is ignored. */ if ((cmd->scan_begin_arg - & (CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT))) != - 0) { + & (CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT))) != 0) { cmd->scan_begin_arg = - COMBINE(cmd->scan_begin_arg, 0, - CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT)); + COMBINE(cmd->scan_begin_arg, 0, + CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT)); err++; } break; @@ -1361,7 +1381,7 @@ if (cmd->scan_begin_src == TRIG_TIMER) { tmp = cmd->scan_begin_arg; pci230_ns_to_single_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); + cmd->flags & TRIG_ROUND_MASK); if (tmp != cmd->scan_begin_arg) err++; } @@ -1419,7 +1439,8 @@ } static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trig_num) + struct comedi_subdevice *s, + unsigned int trig_num) { unsigned long irqflags; @@ -1431,16 +1452,16 @@ /* Perform scan. */ if (devpriv->hwver < 2) { /* Not using DAC FIFO. */ - spin_unlock_irqrestore(&devpriv-> - ao_stop_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, + irqflags); pci230_handle_ao_nofifo(dev, s); comedi_event(dev, s); } else { /* Using DAC FIFO. */ /* Read DACSWTRIG register to trigger conversion. */ inw(dev->iobase + PCI230P2_DACSWTRIG); - spin_unlock_irqrestore(&devpriv-> - ao_stop_spinlock, irqflags); + spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, + irqflags); } /* Delay. Should driver be responsible for this? */ /* XXX TODO: See if DAC busy bit can be used. */ @@ -1450,7 +1471,8 @@ return 1; } -static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_ao_start(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -1499,7 +1521,8 @@ break; } devpriv->daccon = (devpriv->daccon - & ~PCI230P2_DAC_TRIG_MASK) | scantrig; + & ~PCI230P2_DAC_TRIG_MASK) | + scantrig; outw(devpriv->daccon, dev->iobase + PCI230_DACCON); } @@ -1509,17 +1532,17 @@ /* Not using DAC FIFO. */ /* Enable CT1 timer interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, - irqflags); + irqflags); devpriv->int_en |= PCI230_INT_ZCLK_CT1; devpriv->ier |= PCI230_INT_ZCLK_CT1; outb(devpriv->ier, - devpriv->iobase1 + PCI230_INT_SCE); - spin_unlock_irqrestore(&devpriv-> - isr_spinlock, irqflags); + devpriv->iobase1 + PCI230_INT_SCE); + spin_unlock_irqrestore(&devpriv->isr_spinlock, + irqflags); } /* Set CT1 gate high to start counting. */ outb(GAT_CONFIG(1, GAT_VCC), - devpriv->iobase1 + PCI230_ZGAT_SCE); + devpriv->iobase1 + PCI230_ZGAT_SCE); break; case TRIG_INT: async->inttrig = pci230_ao_inttrig_scan_begin; @@ -1527,19 +1550,19 @@ } if (devpriv->hwver >= 2) { /* Using DAC FIFO. Enable DAC FIFO interrupt. */ - spin_lock_irqsave(&devpriv->isr_spinlock, - irqflags); + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); devpriv->int_en |= PCI230P2_INT_DAC; devpriv->ier |= PCI230P2_INT_DAC; outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, - irqflags); + irqflags); } } } -static int pci230_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trig_num) +static int pci230_ao_inttrig_start(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { if (trig_num != 0) return -EINVAL; @@ -1600,24 +1623,25 @@ * N.B. DAC FIFO interrupts are currently disabled. */ daccon |= PCI230P2_DAC_FIFO_EN | PCI230P2_DAC_FIFO_RESET - | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR - | PCI230P2_DAC_TRIG_NONE | PCI230P2_DAC_INT_FIFO_NHALF; + | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR + | PCI230P2_DAC_TRIG_NONE | PCI230P2_DAC_INT_FIFO_NHALF; } /* Set DACCON. */ outw(daccon, dev->iobase + PCI230_DACCON); /* Preserve most of DACCON apart from write-only, transient bits. */ devpriv->daccon = daccon - & ~(PCI230P2_DAC_FIFO_RESET | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR); + & ~(PCI230P2_DAC_FIFO_RESET | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR); if (cmd->scan_begin_src == TRIG_TIMER) { /* Set the counter timer 1 to the specified scan frequency. */ /* cmd->scan_begin_arg is sampling period in ns */ /* gate it off for now. */ outb(GAT_CONFIG(1, GAT_GND), - devpriv->iobase1 + PCI230_ZGAT_SCE); + devpriv->iobase1 + PCI230_ZGAT_SCE); pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3, - cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); + cmd->scan_begin_arg, + cmd->flags & TRIG_ROUND_MASK); } /* N.B. cmd->start_src == TRIG_INT */ @@ -1637,7 +1661,7 @@ } min_scan_period = chanlist_len * cmd->convert_arg; if ((min_scan_period < chanlist_len) - || (min_scan_period < cmd->convert_arg)) { + || (min_scan_period < cmd->convert_arg)) { /* Arithmetic overflow. */ min_scan_period = UINT_MAX; err++; @@ -1650,8 +1674,8 @@ return !err; } -static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pci230_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; unsigned int tmp; @@ -1679,7 +1703,7 @@ * EXTTRIG/EXTCONVCLK input on pin 17 instead. */ if ((thisboard->have_dio) || (thisboard->min_hwver > 0)) { cmd->scan_begin_src &= TRIG_FOLLOW | TRIG_TIMER | TRIG_INT - | TRIG_EXT; + | TRIG_EXT; } else { cmd->scan_begin_src &= TRIG_FOLLOW | TRIG_TIMER | TRIG_INT; } @@ -1723,7 +1747,7 @@ /* If scan_begin_src is not TRIG_FOLLOW, then a monostable will be * set up to generate a fixed number of timed conversion pulses. */ if ((cmd->scan_begin_src != TRIG_FOLLOW) - && (cmd->convert_src != TRIG_TIMER)) + && (cmd->convert_src != TRIG_TIMER)) err++; if (err) @@ -1788,17 +1812,17 @@ /* Trigger number must be 0. */ if ((cmd->convert_arg & ~CR_FLAGS_MASK) != 0) { cmd->convert_arg = COMBINE(cmd->convert_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* The only flags allowed are CR_INVERT and CR_EDGE. * CR_EDGE is required. */ if ((cmd->convert_arg & (CR_FLAGS_MASK & ~CR_INVERT)) - != CR_EDGE) { + != CR_EDGE) { /* Set CR_EDGE, preserve CR_INVERT. */ cmd->convert_arg = - COMBINE(cmd->start_arg, (CR_EDGE | 0), - CR_FLAGS_MASK & ~CR_INVERT); + COMBINE(cmd->start_arg, (CR_EDGE | 0), + CR_FLAGS_MASK & ~CR_INVERT); err++; } } else { @@ -1836,13 +1860,13 @@ * of CT2 (sample convert trigger is CT2) */ if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) { cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0, - ~CR_FLAGS_MASK); + ~CR_FLAGS_MASK); err++; } /* The only flag allowed is CR_EDGE, which is ignored. */ if ((cmd->scan_begin_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) { cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0, - CR_FLAGS_MASK & ~CR_EDGE); + CR_FLAGS_MASK & ~CR_EDGE); err++; } } else if (cmd->scan_begin_src == TRIG_TIMER) { @@ -1867,7 +1891,7 @@ if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; pci230_ns_to_single_timer(&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); + cmd->flags & TRIG_ROUND_MASK); if (tmp != cmd->convert_arg) err++; } @@ -1876,11 +1900,11 @@ /* N.B. cmd->convert_arg is also TRIG_TIMER */ tmp = cmd->scan_begin_arg; pci230_ns_to_single_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); + cmd->flags & TRIG_ROUND_MASK); if (!pci230_ai_check_scan_period(cmd)) { /* Was below minimum required. Round up. */ pci230_ns_to_single_timer(&cmd->scan_begin_arg, - TRIG_ROUND_UP); + TRIG_ROUND_UP); pci230_ai_check_scan_period(cmd); } if (tmp != cmd->scan_begin_arg) @@ -1921,20 +1945,19 @@ * differential. (These are remapped in software. In * hardware, only the even channels are available.) */ if ((aref == AREF_DIFF) - && (chan >= (s->n_chan / 2))) { + && (chan >= (s->n_chan / 2))) { errors |= diffchan_err; } if (n > 0) { /* Channel numbers must strictly increase or * subsequence must repeat exactly. */ if ((chan <= prev_chan) - && (subseq_len == 0)) { + && (subseq_len == 0)) { subseq_len = n; } if ((subseq_len > 0) - && (cmd->chanlist[n] != - cmd->chanlist[n % - subseq_len])) { + && (cmd->chanlist[n] != + cmd->chanlist[n % subseq_len])) { errors |= seq_err; } /* Channels must have same AREF. */ @@ -1948,8 +1971,8 @@ /* Single-ended channel pairs must have same * range. */ if ((aref != AREF_DIFF) - && (((chan ^ prev_chan) & ~1) == 0) - && (range != prev_range)) { + && (((chan ^ prev_chan) & ~1) == 0) + && (range != prev_range)) { errors |= rangepair_err; } } @@ -1983,7 +2006,7 @@ * does, and we can't tell them apart! */ if ((subseq_len > 1) - && (CR_CHAN(cmd->chanlist[0]) != 0)) { + && (CR_CHAN(cmd->chanlist[0]) != 0)) { errors |= buggy_chan0_err; } } @@ -2021,11 +2044,11 @@ if ((errors & buggy_chan0_err) != 0) { /* Use printk instead of DPRINTK here. */ printk("comedi: comedi%d: amplc_pci230: " - "ai_cmdtest: Buggy PCI230+/260+ " - "h/w version %u requires first channel " - "of multi-channel sequence to be 0 " - "(corrected in h/w version 4)\n", - dev->minor, devpriv->hwver); + "ai_cmdtest: Buggy PCI230+/260+ " + "h/w version %u requires first channel " + "of multi-channel sequence to be 0 " + "(corrected in h/w version 4)\n", + dev->minor, devpriv->hwver); } } } @@ -2037,7 +2060,7 @@ } static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev, - struct comedi_subdevice *s) + struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int scanlen = cmd->scan_end_arg; @@ -2050,13 +2073,12 @@ wake = scanlen - devpriv->ai_scan_pos; } else { if (devpriv->ai_continuous - || (devpriv->ai_scan_count - >= PCI230_ADC_FIFOLEVEL_HALFFULL) - || (scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)) { + || (devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL) + || (scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)) { wake = PCI230_ADC_FIFOLEVEL_HALFFULL; } else { wake = (devpriv->ai_scan_count * scanlen) - - devpriv->ai_scan_pos; + - devpriv->ai_scan_pos; } } if (wake >= PCI230_ADC_FIFOLEVEL_HALFFULL) { @@ -2080,8 +2102,9 @@ } } -static int pci230_ai_inttrig_convert(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trig_num) +static int pci230_ai_inttrig_convert(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { unsigned long irqflags; @@ -2095,36 +2118,35 @@ /* Trigger conversion by toggling Z2-CT2 output. Finish * with output high. */ i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, - I8254_MODE0); + I8254_MODE0); i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, - I8254_MODE1); + I8254_MODE1); /* Delay. Should driver be responsible for this? An * alternative would be to wait until conversion is complete, * but we can't tell when it's complete because the ADC busy * bit has a different meaning when FIFO enabled (and when * FIFO not enabled, it only works for software triggers). */ if (((devpriv->adccon & PCI230_ADC_IM_MASK) - == PCI230_ADC_IM_DIF) - && (devpriv->hwver == 0)) { + == PCI230_ADC_IM_DIF) + && (devpriv->hwver == 0)) { /* PCI230/260 in differential mode */ delayus = 8; } else { /* single-ended or PCI230+/260+ */ delayus = 4; } - spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, - irqflags); + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); udelay(delayus); } else { - spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, - irqflags); + spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); } return 1; } static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trig_num) + struct comedi_subdevice *s, + unsigned int trig_num) { unsigned long irqflags; unsigned char zgat; @@ -2145,7 +2167,8 @@ return 1; } -static void pci230_ai_start(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_ai_start(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long irqflags; unsigned short conv; @@ -2203,7 +2226,7 @@ break; } devpriv->adccon = (devpriv->adccon & ~PCI230_ADC_TRIG_MASK) - | conv; + | conv; outw(devpriv->adccon, dev->iobase + PCI230_ADCCON); if (cmd->convert_src == TRIG_INT) { async->inttrig = pci230_ai_inttrig_convert; @@ -2267,11 +2290,11 @@ * gated on to start counting. */ zgat = GAT_CONFIG(1, GAT_VCC); outb(zgat, devpriv->iobase1 - + PCI230_ZGAT_SCE); + + PCI230_ZGAT_SCE); break; case TRIG_INT: async->inttrig = - pci230_ai_inttrig_scan_begin; + pci230_ai_inttrig_scan_begin; break; } } @@ -2282,8 +2305,9 @@ } } -static int pci230_ai_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trig_num) +static int pci230_ai_inttrig_start(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { if (trig_num != 0) return -EINVAL; @@ -2394,7 +2418,7 @@ adcen |= 1 << chan; } devpriv->adcg = (devpriv->adcg & ~(3 << gainshift)) - | (pci230_ai_gain[range] << gainshift); + | (pci230_ai_gain[range] << gainshift); } /* Set channel scan list. */ @@ -2439,7 +2463,7 @@ outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE); /* Set counter/timer 2 to the specified conversion period. */ pci230_ct_setup_ns_mode(dev, 2, I8254_MODE3, cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); + cmd->flags & TRIG_ROUND_MASK); if (cmd->scan_begin_src != TRIG_FOLLOW) { /* * Set up monostable on CT0 output for scan timing. A @@ -2456,8 +2480,9 @@ zgat = GAT_CONFIG(0, GAT_VCC); outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE); pci230_ct_setup_ns_mode(dev, 0, I8254_MODE1, - ((uint64_t) cmd->convert_arg - * cmd->scan_end_arg), TRIG_ROUND_UP); + ((uint64_t) cmd->convert_arg + * cmd->scan_end_arg), + TRIG_ROUND_UP); if (cmd->scan_begin_src == TRIG_TIMER) { /* * Monostable on CT0 will be triggered by @@ -2468,8 +2493,10 @@ zgat = GAT_CONFIG(1, GAT_GND); outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE); pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3, - cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); + cmd->scan_begin_arg, + cmd-> + flags & + TRIG_ROUND_MASK); } } } @@ -2485,7 +2512,7 @@ } static unsigned int divide_ns(uint64_t ns, unsigned int timebase, - unsigned int round_mode) + unsigned int round_mode) { uint64_t div; unsigned int rem; @@ -2510,7 +2537,7 @@ /* Given desired period in ns, returns the required internal clock source * and gets the initial count. */ static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count, - unsigned int round_mode) + unsigned int round_mode) { unsigned int clk_src, cnt; @@ -2535,7 +2562,8 @@ } static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, - unsigned int mode, uint64_t ns, unsigned int round) + unsigned int mode, uint64_t ns, + unsigned int round) { unsigned int clk_src; unsigned int count; @@ -2556,7 +2584,7 @@ static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct) { i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, - I8254_MODE1); + I8254_MODE1); /* Counter ct, 8254 mode 1, initial count not written. */ } @@ -2564,7 +2592,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d) { unsigned char status_int, valid_status_int; - struct comedi_device *dev = (struct comedi_device *) d; + struct comedi_device *dev = (struct comedi_device *)d; struct comedi_subdevice *s; unsigned long irqflags; @@ -2624,7 +2652,8 @@ return IRQ_HANDLED; } -static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_handle_ao_nofifo(struct comedi_device *dev, + struct comedi_subdevice *s) { short data; int i, ret; @@ -2661,7 +2690,8 @@ /* Loads DAC FIFO (if using it) from buffer. */ /* Returns 0 if AO finished due to completion or error, 1 if still going. */ -static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci230_handle_ao_fifo(struct comedi_device *dev, + struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -2699,7 +2729,7 @@ * (otherwise there will be loads of "DAC FIFO not half full" * interrupts). */ if ((num_scans == 0) - && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) { + && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) { comedi_error(dev, "AO buffer underrun"); events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } @@ -2728,7 +2758,7 @@ comedi_buf_get(async, &datum); pci230_ao_write_fifo(dev, datum, - CR_CHAN(cmd->chanlist[i])); + CR_CHAN(cmd->chanlist[i])); } } events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK; @@ -2739,10 +2769,11 @@ * to FIFO. Set FIFO interrupt trigger level * to 'empty'. */ devpriv->daccon = (devpriv->daccon - & ~PCI230P2_DAC_INT_FIFO_MASK) - | PCI230P2_DAC_INT_FIFO_EMPTY; + & + ~PCI230P2_DAC_INT_FIFO_MASK) + | PCI230P2_DAC_INT_FIFO_EMPTY; outw(devpriv->daccon, - dev->iobase + PCI230_DACCON); + dev->iobase + PCI230_DACCON); } } /* Check if FIFO underrun occurred while writing to FIFO. */ @@ -2753,7 +2784,7 @@ } } if ((events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) - != 0) { + != 0) { /* Stopping AO due to completion or error. */ pci230_ao_stop(dev, s); running = 0; @@ -2764,7 +2795,8 @@ return running; } -static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_handle_ai(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned int events = 0; unsigned int status_fifo; @@ -2780,11 +2812,11 @@ } else if (devpriv->ai_scan_count == 0) { todo = 0; } else if ((devpriv->ai_scan_count > PCI230_ADC_FIFOLEVEL_HALFFULL) - || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) { + || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) { todo = PCI230_ADC_FIFOLEVEL_HALFFULL; } else { todo = (devpriv->ai_scan_count * scanlen) - - devpriv->ai_scan_pos; + - devpriv->ai_scan_pos; if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) { todo = PCI230_ADC_FIFOLEVEL_HALFFULL; } @@ -2817,7 +2849,7 @@ if (devpriv->hwver > 0) { /* Read PCI230+/260+ ADC FIFO level. */ fifoamount = inw(dev->iobase - + PCI230P_ADCFFLEV); + + PCI230P_ADCFFLEV); if (fifoamount == 0) { /* Shouldn't happen. */ break; @@ -2854,7 +2886,7 @@ async->events |= events; if ((async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW)) != 0) { + COMEDI_CB_OVERFLOW)) != 0) { /* disable hardware conversions */ pci230_ai_stop(dev, s); } else { @@ -2863,7 +2895,8 @@ } } -static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_ao_stop(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long irqflags; unsigned char intsrc; @@ -2910,21 +2943,23 @@ * disable FIFO. */ devpriv->daccon &= PCI230_DAC_OR_MASK; outw(devpriv->daccon | PCI230P2_DAC_FIFO_RESET - | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR, - dev->iobase + PCI230_DACCON); + | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR, + dev->iobase + PCI230_DACCON); } /* Release resources. */ put_all_resources(dev, OWNER_AOCMD); } -static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci230_ao_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { pci230_ao_stop(dev, s); return 0; } -static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s) +static void pci230_ai_stop(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long irqflags; struct comedi_cmd *cmd; @@ -2964,15 +2999,17 @@ /* Reset FIFO, disable FIFO and set start conversion source to none. * Keep se/diff and bip/uni settings */ devpriv->adccon = (devpriv->adccon & (PCI230_ADC_IR_MASK - | PCI230_ADC_IM_MASK)) | PCI230_ADC_TRIG_NONE; + | PCI230_ADC_IM_MASK)) | + PCI230_ADC_TRIG_NONE; outw(devpriv->adccon | PCI230_ADC_FIFO_RESET, - dev->iobase + PCI230_ADCCON); + dev->iobase + PCI230_ADCCON); /* Release resources. */ put_all_resources(dev, OWNER_AICMD); } -static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci230_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { pci230_ai_stop(dev, s); return 0; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/c6xdigio.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/c6xdigio.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/c6xdigio.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/c6xdigio.c 2009-07-30 09:25:31.000000000 -0700 @@ -97,7 +97,8 @@ #define C6XDIGIO_TIME_OUT 20 -static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int c6xdigio_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int c6xdigio_detach(struct comedi_device *dev); struct comedi_driver driver_c6xdigio = { .driver_name = "c6xdigio", @@ -114,28 +115,28 @@ WriteByteToHwPort(baseAddr, 0x70); while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x74); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x70); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x0); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } @@ -315,38 +316,41 @@ WriteByteToHwPort(baseAddr, 0x68); while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x6C); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x68); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } WriteByteToHwPort(baseAddr, 0x0); timeout = 0; while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80) - && (timeout < C6XDIGIO_TIME_OUT)) { + && (timeout < C6XDIGIO_TIME_OUT)) { timeout++; } } static int c6xdigio_pwmo_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { printk("c6xdigio_pwmo_insn_read %x\n", insn->n); return insn->n; } static int c6xdigio_pwmo_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -375,12 +379,13 @@ /* { */ /* int i; */ /* int chan = CR_CHAN(insn->chanspec); */ -/* *//* C6X_encResetAll( dev->iobase ); */ -/* *//* return insn->n; */ + /* *//* C6X_encResetAll( dev->iobase ); */ + /* *//* return insn->n; */ /* } */ static int c6xdigio_ei_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { /* printk("c6xdigio_ei__insn_read %x\n", insn->n); */ int n; @@ -415,9 +420,9 @@ static const struct pnp_device_id c6xdigio_pnp_tbl[] = { /* Standard LPT Printer Port */ - {.id = "PNP0400", .driver_data = 0}, + {.id = "PNP0400",.driver_data = 0}, /* ECP Printer Port */ - {.id = "PNP0401", .driver_data = 0}, + {.id = "PNP0401",.driver_data = 0}, {} }; @@ -426,7 +431,8 @@ .id_table = c6xdigio_pnp_tbl, }; -static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int c6xdigio_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { int result = 0; unsigned long iobase; @@ -478,7 +484,7 @@ s->range_table = &range_unknown; /* s = dev->subdevices + 2; */ - /* pwm output subdevice */ + /* pwm output subdevice */ /* s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here */ /* s->subdev_flags = SDF_WRITEABLE; */ /* s->n_chan = 1; */ diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/cb_das16_cs.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/cb_das16_cs.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/cb_das16_cs.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/cb_das16_cs.c 2009-07-30 09:25:44.000000000 -0700 @@ -62,23 +62,23 @@ }; static const struct das16cs_board das16cs_boards[] = { { - .device_id = 0x0000,/* unknown */ - .name = "PC-CARD DAS16/16", - .n_ao_chans = 0, - }, + .device_id = 0x0000, /* unknown */ + .name = "PC-CARD DAS16/16", + .n_ao_chans = 0, + }, { - .device_id = 0x0039, - .name = "PC-CARD DAS16/16-AO", - .n_ao_chans = 2, - }, + .device_id = 0x0039, + .name = "PC-CARD DAS16/16-AO", + .n_ao_chans = 2, + }, { - .device_id = 0x4009, - .name = "PCM-DAS16s/16", - .n_ao_chans = 0, - }, + .device_id = 0x4009, + .name = "PCM-DAS16s/16", + .n_ao_chans = 0, + }, }; -#define n_boards (sizeof(das16cs_boards)/sizeof(das16cs_boards[0])) +#define n_boards ARRAY_SIZE(das16cs_boards) #define thisboard ((const struct das16cs_board *)dev->board_ptr) struct das16cs_private { @@ -90,7 +90,8 @@ }; #define devpriv ((struct das16cs_private *)dev->private) -static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int das16cs_attach(struct comedi_device *dev, + struct comedi_devconfig *it); static int das16cs_detach(struct comedi_device *dev); static struct comedi_driver driver_das16cs = { .driver_name = "cb_das16_cs", @@ -102,31 +103,43 @@ static struct pcmcia_device *cur_dev = NULL; static const struct comedi_lrange das16cs_ai_range = { 4, { - RANGE(-10, 10), - RANGE(-5, 5), - RANGE(-2.5, 2.5), - RANGE(-1.25, 1.25), - } + RANGE(-10, 10), + RANGE(-5, 5), + RANGE(-2.5, 2.5), + RANGE(-1.25, 1.25), + } }; static irqreturn_t das16cs_interrupt(int irq, void *d); -static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); -static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); +static int das16cs_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s); +static int das16cs_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int das16cs_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int das16cs_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); +static int das16cs_timer_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); +static int das16cs_timer_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link) { @@ -140,15 +153,15 @@ tuple.DesiredTuple = CISTPL_MANFID; tuple.Attributes = TUPLE_RETURN_COMMON; if ((pcmcia_get_first_tuple(link, &tuple) == 0) && - (pcmcia_get_tuple_data(link, &tuple) == 0)) { + (pcmcia_get_tuple_data(link, &tuple) == 0)) { prodid = le16_to_cpu(buf[1]); } return prodid; } -static const struct das16cs_board *das16cs_probe(struct comedi_device * dev, - struct pcmcia_device *link) +static const struct das16cs_board *das16cs_probe(struct comedi_device *dev, + struct pcmcia_device *link) { int id; int i; @@ -166,7 +179,8 @@ return NULL; } -static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int das16cs_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { struct pcmcia_device *link; struct comedi_subdevice *s; @@ -287,8 +301,9 @@ * "instructions" read/write data in "one-shot" or "software-triggered" * mode. */ -static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_ai_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int to; @@ -334,8 +349,9 @@ return -EINVAL; } -static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int das16cs_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -381,7 +397,7 @@ /* note that mutual compatiblity is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && - cmd->scan_begin_src != TRIG_EXT) + cmd->scan_begin_src != TRIG_EXT) err++; if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT) err++; @@ -463,7 +479,8 @@ tmp = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(100, &div1, &div2, - &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); + &cmd->scan_begin_arg, + cmd->flags & TRIG_ROUND_MASK); if (tmp != cmd->scan_begin_arg) err++; } @@ -472,14 +489,15 @@ tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(100, &div1, &div2, - &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); + &cmd->scan_begin_arg, + cmd->flags & TRIG_ROUND_MASK); if (tmp != cmd->convert_arg) err++; if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { + cmd->scan_begin_arg < + cmd->convert_arg * cmd->scan_end_arg) { cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; + cmd->convert_arg * cmd->scan_end_arg; err++; } } @@ -490,8 +508,9 @@ return 0; } -static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_ao_winsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -536,8 +555,9 @@ /* AO subdevices should have a read insn as well as a write insn. * Usually this means copying a value stored in devpriv. */ -static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_ao_rinsn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan = CR_CHAN(insn->chanspec); @@ -553,8 +573,9 @@ * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -573,8 +594,9 @@ return 2; } -static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); int bits; @@ -593,8 +615,7 @@ break; case INSN_CONFIG_DIO_QUERY: data[1] = - (s-> - io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; return insn->n; break; default: @@ -611,14 +632,17 @@ return insn->n; } -static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_timer_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { return -EINVAL; } -static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16cs_timer_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { return -EINVAL; } @@ -650,7 +674,7 @@ module_param(pc_debug, int, 0644); #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) static char *version = - "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)"; + "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)"; #else #define DEBUG(n, args...) #endif @@ -739,7 +763,7 @@ DEBUG(0, "das16cs_pcmcia_detach(0x%p)\n", link); if (link->dev_node) { - ((struct local_info_t *) link->priv)->stop = 1; + ((struct local_info_t *)link->priv)->stop = 1; das16cs_pcmcia_release(link); } /* This points to the parent struct local_info_t struct */ @@ -853,7 +877,7 @@ /* If we got this far, we're cool! */ break; - next_entry: +next_entry: last_fn = GetNextTuple; last_ret = pcmcia_get_next_tuple(link, &tuple); @@ -893,20 +917,20 @@ /* Finally, report what we've done */ printk(KERN_INFO "%s: index 0x%02x", - dev->node.dev_name, link->conf.ConfigIndex); + dev->node.dev_name, link->conf.ConfigIndex); if (link->conf.Attributes & CONF_ENABLE_IRQ) printk(", irq %u", link->irq.AssignedIRQ); if (link->io.NumPorts1) printk(", io 0x%04x-0x%04x", link->io.BasePort1, - link->io.BasePort1 + link->io.NumPorts1 - 1); + link->io.BasePort1 + link->io.NumPorts1 - 1); if (link->io.NumPorts2) printk(" & 0x%04x-0x%04x", link->io.BasePort2, - link->io.BasePort2 + link->io.NumPorts2 - 1); + link->io.BasePort2 + link->io.NumPorts2 - 1); printk("\n"); return; - cs_failed: +cs_failed: cs_error(link, last_fn, last_ret); das16cs_pcmcia_release(link); } /* das16cs_pcmcia_config */ @@ -953,7 +977,7 @@ .id_table = das16cs_id_table, .owner = THIS_MODULE, .drv = { - .name = dev_info, + .name = dev_info, }, }; diff -Naur -X linux-2.6.31-rc4-git2-usb/Documentation/dontdiff linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/cb_pcidas64.c linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/cb_pcidas64.c --- linux-2.6.31-rc4-git2-usb/drivers/staging/comedi/drivers/cb_pcidas64.c 2009-07-24 11:07:45.000000000 -0700 +++ linux-2.6.31-rc4-git2-staging/drivers/staging/comedi/drivers/cb_pcidas64.c 2009-07-30 09:25:31.000000000 -0700 @@ -152,10 +152,12 @@ { return 0x70 + (2 * (channel & 0x1)); } + static inline unsigned int dac_lsb_4020_reg(unsigned int channel) { return 0x70 + (4 * (channel & 0x1)); } + static inline unsigned int dac_msb_4020_reg(unsigned int channel) { return 0x72 + (4 * (channel & 0x1)); @@ -269,10 +271,12 @@ { return (channel & 0x3) << 8; }; + static inline uint16_t adc_hi_chan_4020_bits(unsigned int channel) { return (channel & 0x3) << 10; }; + static inline uint16_t adc_mode_bits(unsigned int mode) { return (mode & 0xf) << 12; @@ -370,10 +374,12 @@ { return (prepost_bits >> 6) & 0x3; } + static inline unsigned int adc_upper_read_ptr_code(uint16_t prepost_bits) { return (prepost_bits >> 12) & 0x3; } + static inline unsigned int adc_upper_write_ptr_code(uint16_t prepost_bits) { return (prepost_bits >> 14) & 0x3; @@ -394,6 +400,7 @@ { return (source << 4) & ADC_SRC_4020_MASK; }; + static inline uint8_t attenuate_bit(unsigned int channel) { /* attenuate channel (+-5V input range) */ @@ -404,90 +411,91 @@ static const struct comedi_lrange ai_ranges_64xx = { 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), - UNI_RANGE(1.25) - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25) + } }; /* analog input ranges for 60xx boards */ static const struct comedi_lrange ai_ranges_60xx = { 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(0.5), - BIP_RANGE(0.05), - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(0.5), + BIP_RANGE(0.05), + } }; /* analog input ranges for 6030, etc boards */ static const struct comedi_lrange ai_ranges_6030 = { 14, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1), - BIP_RANGE(0.5), - BIP_RANGE(0.2), - BIP_RANGE(0.1), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1), - UNI_RANGE(0.5), - UNI_RANGE(0.2), - UNI_RANGE(0.1), - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2), + BIP_RANGE(1), + BIP_RANGE(0.5), + BIP_RANGE(0.2), + BIP_RANGE(0.1), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2), + UNI_RANGE(1), + UNI_RANGE(0.5), + UNI_RANGE(0.2), + UNI_RANGE(0.1), + } }; /* analog input ranges for 6052, etc boards */ static const struct comedi_lrange ai_ranges_6052 = { 15, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1), - BIP_RANGE(0.5), - BIP_RANGE(0.25), - BIP_RANGE(0.1), - BIP_RANGE(0.05), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1), - UNI_RANGE(0.5), - UNI_RANGE(0.2), - UNI_RANGE(0.1), - } + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1), + BIP_RANGE(0.5), + BIP_RANGE(0.25), + BIP_RANGE(0.1), + BIP_RANGE(0.05), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2), + UNI_RANGE(1), + UNI_RANGE(0.5), + UNI_RANGE(0.2), + UNI_RANGE(0.1), + } }; /* analog input ranges for 4020 board */ static const struct comedi_lrange ai_ranges_4020 = { 2, { - BIP_RANGE(5), - BIP_RANGE(1), - } + BIP_RANGE(5), + BIP_RANGE(1), + } }; /* analog output ranges */ static const struct comedi_lrange ao_ranges_64xx = { 4, { - BIP_RANGE(5), - BIP_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(10), - } + BIP_RANGE(5), + BIP_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(10), + } }; + static const int ao_range_code_64xx[] = { 0x0, 0x1, @@ -498,9 +506,10 @@ static const struct comedi_lrange ao_ranges_60xx = { 1, { - BIP_RANGE(10), - } + BIP_RANGE(10), + } }; + static const int ao_range_code_60xx[] = { 0x0, }; @@ -508,10 +517,11 @@ static const struct comedi_lrange ao_ranges_6030 = { 2, { - BIP_RANGE(10), - UNI_RANGE(10), - } + BIP_RANGE(10), + UNI_RANGE(10), + } }; + static const int ao_range_code_6030[] = { 0x0, 0x2, @@ -520,10 +530,11 @@ static const struct comedi_lrange ao_ranges_4020 = { 2, { - BIP_RANGE(5), - BIP_RANGE(10), - } + BIP_RANGE(5), + BIP_RANGE(10), + } }; + static const int ao_range_code_4020[] = { 0x1, 0x0, @@ -597,458 +608,478 @@ static const struct pcidas64_board pcidas64_boards[] = { { - .name = "pci-das6402/16", - .device_id = 0x1d, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ao_range_table = &ao_ranges_64xx, - .ao_range_code = ao_range_code_64xx, - .ai_fifo = &ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das6402/12", /* XXX check */ - .device_id = 0x1e, - .ai_se_chans = 64, - .ai_bits = 12, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ao_range_table = &ao_ranges_64xx, - .ao_range_code = ao_range_code_64xx, - .ai_fifo = &ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m1/16", - .device_id = 0x35, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 1000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ao_range_table = &ao_ranges_64xx, - .ao_range_code = ao_range_code_64xx, - .ai_fifo = &ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m2/16", - .device_id = 0x36, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 500, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ao_range_table = &ao_ranges_64xx, - .ao_range_code = ao_range_code_64xx, - .ai_fifo = &ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m3/16", - .device_id = 0x37, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 333, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ao_range_table = &ao_ranges_64xx, - .ao_range_code = ao_range_code_64xx, - .ai_fifo = &ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das6013", - .device_id = 0x78, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 0, - .ao_bits = 16, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6014", - .device_id = 0x79, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 100000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6023", - .device_id = 0x5d, - .ai_se_chans = 16, - .ai_bits = 12, - .ai_speed = 5000, - .ao_nchan = 0, - .ao_scan_speed = 100000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 1, - }, - { - .name = "pci-das6025", - .device_id = 0x5e, - .ai_se_chans = 16, - .ai_bits = 12, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 100000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 1, - }, - { - .name = "pci-das6030", - .device_id = 0x5f, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 10000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6030, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6031", - .device_id = 0x60, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 10000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 10000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6030, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6032", - .device_id = 0x61, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 10000, - .ao_nchan = 0, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6033", - .device_id = 0x62, - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 10000, - .ao_nchan = 0, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6034", - .device_id = 0x63, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 0, - .ao_scan_speed = 0, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6035", - .device_id = 0x64, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 100000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6036", - .device_id = 0x6f, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 100000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_60xx, - .ao_range_table = &ao_ranges_60xx, - .ao_range_code = ao_range_code_60xx, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6040", - .device_id = 0x65, - .ai_se_chans = 16, - .ai_bits = 12, - .ai_speed = 2000, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 1000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6052, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6052", - .device_id = 0x66, - .ai_se_chans = 16, - .ai_bits = 16, - .ai_speed = 3333, - .ao_nchan = 2, - .ao_bits = 16, - .ao_scan_speed = 3333, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6052, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6070", - .device_id = 0x67, - .ai_se_chans = 16, - .ai_bits = 12, - .ai_speed = 800, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 1000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6052, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das6071", - .device_id = 0x68, - .ai_se_chans = 64, - .ai_bits = 12, - .ai_speed = 800, - .ao_nchan = 2, - .ao_bits = 12, - .ao_scan_speed = 1000, - .layout = LAYOUT_60XX, - .ai_range_table = &ai_ranges_6052, - .ao_range_table = &ao_ranges_6030, - .ao_range_code = ao_range_code_6030, - .ai_fifo = &ai_fifo_60xx, - .has_8255 = 0, - }, - { - .name = "pci-das4020/12", - .device_id = 0x52, - .ai_se_chans = 4, - .ai_bits = 12, - .ai_speed = 50, - .ao_bits = 12, - .ao_nchan = 2, - .ao_scan_speed = 0, /* no hardware pacing on ao */ - .layout = LAYOUT_4020, - .ai_range_table = &ai_ranges_4020, - .ao_range_table = &ao_ranges_4020, - .ao_range_code = ao_range_code_4020, - .ai_fifo = &ai_fifo_4020, - .has_8255 = 1, - }, + .name = "pci-das6402/16", + .device_id = 0x1d, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das6402/12", /* XXX check */ + .device_id = 0x1e, + .ai_se_chans = 64, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m1/16", + .device_id = 0x35, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 1000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m2/16", + .device_id = 0x36, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 500, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m3/16", + .device_id = 0x37, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 333, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ao_range_table = &ao_ranges_64xx, + .ao_range_code = ao_range_code_64xx, + .ai_fifo = &ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das6013", + .device_id = 0x78, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_bits = 16, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6014", + .device_id = 0x79, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6023", + .device_id = 0x5d, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 1, + }, + { + .name = "pci-das6025", + .device_id = 0x5e, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 1, + }, + { + .name = "pci-das6030", + .device_id = 0x5f, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6031", + .device_id = 0x60, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 10000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6032", + .device_id = 0x61, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6033", + .device_id = 0x62, + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 10000, + .ao_nchan = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6034", + .device_id = 0x63, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 0, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6035", + .device_id = 0x64, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6036", + .device_id = 0x6f, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 100000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_60xx, + .ao_range_table = &ao_ranges_60xx, + .ao_range_code = ao_range_code_60xx, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6040", + .device_id = 0x65, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 2000, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6052", + .device_id = 0x66, + .ai_se_chans = 16, + .ai_bits = 16, + .ai_speed = 3333, + .ao_nchan = 2, + .ao_bits = 16, + .ao_scan_speed = 3333, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6070", + .device_id = 0x67, + .ai_se_chans = 16, + .ai_bits = 12, + .ai_speed = 800, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das6071", + .device_id = 0x68, + .ai_se_chans = 64, + .ai_bits = 12, + .ai_speed = 800, + .ao_nchan = 2, + .ao_bits = 12, + .ao_scan_speed = 1000, + .layout = LAYOUT_60XX, + .ai_range_table = &ai_ranges_6052, + .ao_range_table = &ao_ranges_6030, + .ao_range_code = ao_range_code_6030, + .ai_fifo = &ai_fifo_60xx, + .has_8255 = 0, + }, + { + .name = "pci-das4020/12", + .device_id = 0x52, + .ai_se_chans = 4, + .ai_bits = 12, + .ai_speed = 50, + .ao_bits = 12, + .ao_nchan = 2, + .ao_scan_speed = 0, /* no hardware pacing on ao */ + .layout = LAYOUT_4020, + .ai_range_table = &ai_ranges_4020, + .ao_range_table = &ao_ranges_4020, + .ao_range_code = ao_range_code_4020, + .ai_fifo = &ai_fifo_4020, + .has_8255 = 1, + }, #if 0 { - .name = "pci-das6402/16/jr", - .device_id = 0 /* XXX, */ - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 5000, - .ao_nchan = 0, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m1/16/jr", - .device_id = 0 /* XXX, */ - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 1000, - .ao_nchan = 0, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m2/16/jr", - .device_id = 0 /* XXX, */ - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 500, - .ao_nchan = 0, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m3/16/jr", - .device_id = 0 /* XXX, */ - .ai_se_chans = 64, - .ai_bits = 16, - .ai_speed = 333, - .ao_nchan = 0, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m1/14", - .device_id = 0, /* XXX */ - .ai_se_chans = 64, - .ai_bits = 14, - .ai_speed = 1000, - .ao_nchan = 2, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m2/14", - .device_id = 0, /* XXX */ - .ai_se_chans = 64, - .ai_bits = 14, - .ai_speed = 500, - .ao_nchan = 2, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, - { - .name = "pci-das64/m3/14", - .device_id = 0, /* XXX */ - .ai_se_chans = 64, - .ai_bits = 14, - .ai_speed = 333, - .ao_nchan = 2, - .ao_scan_speed = 10000, - .layout = LAYOUT_64XX, - .ai_range_table = &ai_ranges_64xx, - .ai_fifo = ai_fifo_64xx, - .has_8255 = 1, - }, + .name = "pci-das6402/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 5000, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m1/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 1000, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m2/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 500, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m3/16/jr", + .device_id = 0 /* XXX, */ + .ai_se_chans = 64, + .ai_bits = 16, + .ai_speed = 333, + .ao_nchan = 0, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m1/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 1000, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m2/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 500, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, + { + .name = "pci-das64/m3/14", + .device_id = 0, /* XXX */ + .ai_se_chans = 64, + .ai_bits = 14, + .ai_speed = 333, + .ao_nchan = 2, + .ao_scan_speed = 10000, + .layout = LAYOUT_64XX, + .ai_range_table = &ai_ranges_64xx, + .ai_fifo = ai_fifo_64xx, + .has_8255 = 1, + }, #endif }; static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = { - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0} + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { + 0} }; MODULE_DEVICE_TABLE(pci, pcidas64_pci_table); -static inline struct pcidas64_board *board(const struct comedi_device * dev) +static inline struct pcidas64_board *board(const struct comedi_device *dev) { - return (struct pcidas64_board *) dev->board_ptr; + return (struct pcidas64_board *)dev->board_ptr; } static inline unsigned short se_diff_bit_6xxx(struct comedi_device *dev, - int use_differential) + int use_differential) { if ((board(dev)->layout == LAYOUT_64XX && !use_differential) || - (board(dev)->layout == LAYOUT_60XX && use_differential)) + (board(dev)->layout == LAYOUT_60XX && use_differential)) return ADC_SE_DIFF_BIT; else return 0; @@ -1107,11 +1138,10 @@ short ao_bounce_buffer[DAC_FIFO_SIZE]; }; - /* inline function that makes it easier to * access the private structure. */ -static inline struct pcidas64_private *priv(struct comedi_device * dev) +static inline struct pcidas64_private *priv(struct comedi_device *dev) { return dev->private; } @@ -1132,76 +1162,86 @@ }; static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); +static int ao_readback_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); + struct comedi_cmd *cmd); static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *subdev, - unsigned int trig_num); +static int ao_inttrig(struct comedi_device *dev, + struct comedi_subdevice *subdev, unsigned int trig_num); static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd); + struct comedi_cmd *cmd); static irqreturn_t handle_interrupt(int irq, void *d); static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int dio_callback(int dir, int port, int data, unsigned long arg); static int dio_callback_4020(int dir, int port, int data, unsigned long arg); static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); +static int dio_60xx_config_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int ad8402_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + struct comedi_insn *insn, unsigned int *data); +static int calib_read_insn(struct comedi_device *dev, + struct comedi_subdevice *s, struct comedi_insn *insn, + unsigned int *data); +static int calib_write_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int ad8402_read_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static void ad8402_write(struct comedi_device *dev, unsigned int channel, - unsigned int value); -static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + unsigned int value); +static int ad8402_write_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); +static int eeprom_read_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data); static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd); static unsigned int get_divisor(unsigned int ns, unsigned int flags); static void i2c_write(struct comedi_device *dev, unsigned int address, - const uint8_t *data, unsigned int length); + const uint8_t * data, unsigned int length); static void caldac_write(struct comedi_device *dev, unsigned int channel, - unsigned int value); + unsigned int value); static int caldac_8800_write(struct comedi_device *dev, unsigned int address, - uint8_t value); + uint8_t value); /* static int dac_1590_write(struct comedi_device *dev, unsigned int dac_a, unsigned int dac_b); */ -static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel, - unsigned int value); +static int caldac_i2c_write(struct comedi_device *dev, + unsigned int caldac_channel, unsigned int value); static void abort_dma(struct comedi_device *dev, unsigned int channel); static void disable_plx_interrupts(struct comedi_device *dev); -static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples); +static int set_ai_fifo_size(struct comedi_device *dev, + unsigned int num_samples); static unsigned int ai_fifo_size(struct comedi_device *dev); static int set_ai_fifo_segment_length(struct comedi_device *dev, - unsigned int num_entries); + unsigned int num_entries); static void disable_ai_pacing(struct comedi_device *dev); static void disable_ai_interrupts(struct comedi_device *dev); -static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd); +static void enable_ai_interrupts(struct comedi_device *dev, + const struct comedi_cmd *cmd); static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags); -static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd); +static void load_ao_dma(struct comedi_device *dev, + const struct comedi_cmd *cmd); COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, pcidas64_pci_table); static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev, - unsigned int range_index) + unsigned int range_index) { const struct comedi_krange *range = - &board(dev)->ai_range_table->range[range_index]; + &board(dev)->ai_range_table->range[range_index]; unsigned int bits = 0; switch (range->max) { @@ -1242,7 +1282,7 @@ } static unsigned int hw_revision(const struct comedi_device *dev, - uint16_t hw_status_bits) + uint16_t hw_status_bits) { if (board(dev)->layout == LAYOUT_4020) return (hw_status_bits >> 13) & 0x7; @@ -1250,8 +1290,9 @@ return (hw_status_bits >> 12) & 0xf; } -static void set_dac_range_bits(struct comedi_device *dev, volatile uint16_t *bits, - unsigned int channel, unsigned int range) +static void set_dac_range_bits(struct comedi_device *dev, + volatile uint16_t * bits, unsigned int channel, + unsigned int range) { unsigned int code = board(dev)->ao_range_code[range]; @@ -1276,38 +1317,38 @@ void *plx_iobase = priv(dev)->plx9080_iobase; priv(dev)->plx_control_bits = - readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG); + readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG); /* plx9080 dump */ DEBUG_PRINT(" plx interrupt status 0x%x\n", - readl(plx_iobase + PLX_INTRCS_REG)); + readl(plx_iobase + PLX_INTRCS_REG)); DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG)); DEBUG_PRINT(" plx control reg 0x%x\n", priv(dev)->plx_control_bits); DEBUG_PRINT(" plx mode/arbitration reg 0x%x\n", - readl(plx_iobase + PLX_MARB_REG)); + readl(plx_iobase + PLX_MARB_REG)); DEBUG_PRINT(" plx region0 reg 0x%x\n", - readl(plx_iobase + PLX_REGION0_REG)); + readl(plx_iobase + PLX_REGION0_REG)); DEBUG_PRINT(" plx region1 reg 0x%x\n", - readl(plx_iobase + PLX_REGION1_REG)); + readl(plx_iobase + PLX_REGION1_REG)); DEBUG_PRINT(" plx revision 0x%x\n", - readl(plx_iobase + PLX_REVISION_REG)); + readl(plx_iobase + PLX_REVISION_REG)); DEBUG_PRINT(" plx dma channel 0 mode 0x%x\n", - readl(plx_iobase + PLX_DMA0_MODE_REG)); + readl(plx_iobase + PLX_DMA0_MODE_REG)); DEBUG_PRINT(" plx dma channel 1 mode 0x%x\n", - readl(plx_iobase + PLX_DMA1_MODE_REG)); + readl(plx_iobase + PLX_DMA1_MODE_REG)); DEBUG_PRINT(" plx dma channel 0 pci address 0x%x\n", - readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG)); + readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG)); DEBUG_PRINT(" plx dma channel 0 local address 0x%x\n", - readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG)); + readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG)); DEBUG_PRINT(" plx dma channel 0 transfer size 0x%x\n", - readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG)); + readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG)); DEBUG_PRINT(" plx dma channel 0 descriptor 0x%x\n", - readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG)); + readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG)); DEBUG_PRINT(" plx dma channel 0 command status 0x%x\n", - readb(plx_iobase + PLX_DMA0_CS_REG)); + readb(plx_iobase + PLX_DMA0_CS_REG)); DEBUG_PRINT(" plx dma channel 0 threshold 0x%x\n", - readl(plx_iobase + PLX_DMA0_THRESHOLD_REG)); + readl(plx_iobase + PLX_DMA0_THRESHOLD_REG)); DEBUG_PRINT(" plx bigend 0x%x\n", readl(plx_iobase + PLX_BIGEND_REG)); #ifdef __BIG_ENDIAN @@ -1352,10 +1393,10 @@ /* enable interrupts on plx 9080 */ priv(dev)->plx_intcsr_bits |= - ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | - ICS_DMA0_E | ICS_DMA1_E; + ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | + ICS_DMA0_E | ICS_DMA1_E; writel(priv(dev)->plx_intcsr_bits, - priv(dev)->plx9080_iobase + PLX_INTRCS_REG); + priv(dev)->plx9080_iobase + PLX_INTRCS_REG); } /* Allocate and initialize the subdevice structures. @@ -1405,8 +1446,7 @@ if (board(dev)->ao_nchan) { s->type = COMEDI_SUBD_AO; s->subdev_flags = - SDF_READABLE | SDF_WRITABLE | SDF_GROUND | - SDF_CMD_WRITE; + SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; s->n_chan = board(dev)->ao_nchan; s->maxdata = (1 << board(dev)->ao_bits) - 1; s->range_table = board(dev)->ao_range_table; @@ -1452,14 +1492,14 @@ if (board(dev)->has_8255) { if (board(dev)->layout == LAYOUT_4020) { dio_8255_iobase = - priv(dev)->main_iobase + I8255_4020_REG; + priv(dev)->main_iobase + I8255_4020_REG; subdev_8255_init(dev, s, dio_callback_4020, - (unsigned long)dio_8255_iobase); + (unsigned long)dio_8255_iobase); } else { dio_8255_iobase = - priv(dev)->dio_counter_iobase + DIO_8255_OFFSET; + priv(dev)->dio_counter_iobase + DIO_8255_OFFSET; subdev_8255_init(dev, s, dio_callback, - (unsigned long)dio_8255_iobase); + (unsigned long)dio_8255_iobase); } } else s->type = COMEDI_SUBD_UNUSED; @@ -1527,7 +1567,7 @@ { priv(dev)->plx_intcsr_bits = 0; writel(priv(dev)->plx_intcsr_bits, - priv(dev)->plx9080_iobase + PLX_INTRCS_REG); + priv(dev)->plx9080_iobase + PLX_INTRCS_REG); } static void init_stc_registers(struct comedi_device *dev) @@ -1541,7 +1581,7 @@ if (1) priv(dev)->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT; writew(priv(dev)->adc_control1_bits, - priv(dev)->main_iobase + ADC_CONTROL1_REG); + priv(dev)->main_iobase + ADC_CONTROL1_REG); /* 6402/16 manual says this register must be initialized to 0xff? */ writew(0xff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); @@ -1551,7 +1591,7 @@ bits |= INTERNAL_CLOCK_4020_BITS; priv(dev)->hw_config_bits |= bits; writew(priv(dev)->hw_config_bits, - priv(dev)->main_iobase + HW_CONFIG_REG); + priv(dev)->main_iobase + HW_CONFIG_REG); writew(0, priv(dev)->main_iobase + DAQ_SYNC_REG); writew(0, priv(dev)->main_iobase + CALIBRATION_REG); @@ -1561,13 +1601,13 @@ /* set fifos to maximum size */ priv(dev)->fifo_size_bits |= DAC_FIFO_BITS; set_ai_fifo_segment_length(dev, - board(dev)->ai_fifo->max_segment_length); + board(dev)->ai_fifo->max_segment_length); priv(dev)->dac_control1_bits = DAC_OUTPUT_ENABLE_BIT; priv(dev)->intr_enable_bits = /* EN_DAC_INTR_SRC_BIT | DAC_INTR_QEMPTY_BITS | */ - EN_DAC_DONE_INTR_BIT | EN_DAC_UNDERRUN_BIT; + EN_DAC_DONE_INTR_BIT | EN_DAC_UNDERRUN_BIT; writew(priv(dev)->intr_enable_bits, - priv(dev)->main_iobase + INTR_ENABLE_REG); + priv(dev)->main_iobase + INTR_ENABLE_REG); disable_ai_pacing(dev); }; @@ -1579,8 +1619,8 @@ /* alocate pci dma buffers */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { priv(dev)->ai_buffer[i] = - pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE, - &priv(dev)->ai_buffer_bus_addr[i]); + pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE, + &priv(dev)->ai_buffer_bus_addr[i]); if (priv(dev)->ai_buffer[i] == NULL) { return -ENOMEM; } @@ -1588,9 +1628,10 @@ for (i = 0; i < AO_DMA_RING_COUNT; i++) { if (ao_cmd_is_supported(board(dev))) { priv(dev)->ao_buffer[i] = - pci_alloc_consistent(priv(dev)->hw_dev, - DMA_BUFFER_SIZE, - &priv(dev)->ao_buffer_bus_addr[i]); + pci_alloc_consistent(priv(dev)->hw_dev, + DMA_BUFFER_SIZE, + &priv(dev)-> + ao_buffer_bus_addr[i]); if (priv(dev)->ao_buffer[i] == NULL) { return -ENOMEM; } @@ -1598,61 +1639,65 @@ } /* allocate dma descriptors */ priv(dev)->ai_dma_desc = - pci_alloc_consistent(priv(dev)->hw_dev, - sizeof(struct plx_dma_desc) * ai_dma_ring_count(board(dev)), - &priv(dev)->ai_dma_desc_bus_addr); + pci_alloc_consistent(priv(dev)->hw_dev, + sizeof(struct plx_dma_desc) * + ai_dma_ring_count(board(dev)), + &priv(dev)->ai_dma_desc_bus_addr); if (priv(dev)->ai_dma_desc == NULL) { return -ENOMEM; } DEBUG_PRINT("ai dma descriptors start at bus addr 0x%x\n", - priv(dev)->ai_dma_desc_bus_addr); + priv(dev)->ai_dma_desc_bus_addr); if (ao_cmd_is_supported(board(dev))) { priv(dev)->ao_dma_desc = - pci_alloc_consistent(priv(dev)->hw_dev, - sizeof(struct plx_dma_desc) * AO_DMA_RING_COUNT, - &priv(dev)->ao_dma_desc_bus_addr); + pci_alloc_consistent(priv(dev)->hw_dev, + sizeof(struct plx_dma_desc) * + AO_DMA_RING_COUNT, + &priv(dev)->ao_dma_desc_bus_addr); if (priv(dev)->ao_dma_desc == NULL) { return -ENOMEM; } DEBUG_PRINT("ao dma descriptors start at bus addr 0x%x\n", - priv(dev)->ao_dma_desc_bus_addr); + priv(dev)->ao_dma_desc_bus_addr); } /* initialize dma descriptors */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { priv(dev)->ai_dma_desc[i].pci_start_addr = - cpu_to_le32(priv(dev)->ai_buffer_bus_addr[i]); + cpu_to_le32(priv(dev)->ai_buffer_bus_addr[i]); if (board(dev)->layout == LAYOUT_4020) priv(dev)->ai_dma_desc[i].local_start_addr = - cpu_to_le32(priv(dev)->local1_iobase + - ADC_FIFO_REG); + cpu_to_le32(priv(dev)->local1_iobase + + ADC_FIFO_REG); else priv(dev)->ai_dma_desc[i].local_start_addr = - cpu_to_le32(priv(dev)->local0_iobase + - ADC_FIFO_REG); + cpu_to_le32(priv(dev)->local0_iobase + + ADC_FIFO_REG); priv(dev)->ai_dma_desc[i].transfer_size = cpu_to_le32(0); priv(dev)->ai_dma_desc[i].next = - cpu_to_le32((priv(dev)->ai_dma_desc_bus_addr + ((i + - 1) % - ai_dma_ring_count(board(dev))) * - sizeof(priv(dev)-> - ai_dma_desc[0])) | PLX_DESC_IN_PCI_BIT | - PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI); + cpu_to_le32((priv(dev)->ai_dma_desc_bus_addr + ((i + + 1) % + ai_dma_ring_count + (board + (dev))) * + sizeof(priv(dev)->ai_dma_desc[0])) | + PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | + PLX_XFER_LOCAL_TO_PCI); } if (ao_cmd_is_supported(board(dev))) { for (i = 0; i < AO_DMA_RING_COUNT; i++) { priv(dev)->ao_dma_desc[i].pci_start_addr = - cpu_to_le32(priv(dev)->ao_buffer_bus_addr[i]); + cpu_to_le32(priv(dev)->ao_buffer_bus_addr[i]); priv(dev)->ao_dma_desc[i].local_start_addr = - cpu_to_le32(priv(dev)->local0_iobase + - DAC_FIFO_REG); + cpu_to_le32(priv(dev)->local0_iobase + + DAC_FIFO_REG); priv(dev)->ao_dma_desc[i].transfer_size = - cpu_to_le32(0); + cpu_to_le32(0); priv(dev)->ao_dma_desc[i].next = - cpu_to_le32((priv(dev)->ao_dma_desc_bus_addr + - ((i + 1) % (AO_DMA_RING_COUNT)) * - sizeof(priv(dev)-> - ao_dma_desc[0])) | - PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT); + cpu_to_le32((priv(dev)->ao_dma_desc_bus_addr + + ((i + 1) % (AO_DMA_RING_COUNT)) * + sizeof(priv(dev)->ao_dma_desc[0])) | + PLX_DESC_IN_PCI_BIT | + PLX_INTR_TERM_COUNT); } } return 0; @@ -1661,9 +1706,9 @@ static inline void warn_external_queue(struct comedi_device *dev) { comedi_error(dev, - "AO command and AI external channel queue cannot be used simultaneously."); + "AO command and AI external channel queue cannot be used simultaneously."); comedi_error(dev, - "Use internal AI channel queue (channels must be consecutive and use same range/aref)"); + "Use internal AI channel queue (channels must be consecutive and use same range/aref)"); } /* @@ -1690,8 +1735,8 @@ */ for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); - pcidev != NULL; - pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) continue; @@ -1703,8 +1748,7 @@ if (it->options[0] || it->options[1]) { /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || - PCI_SLOT(pcidev->devfn) != - it->options[1]) { + PCI_SLOT(pcidev->devfn) != it->options[1]) { continue; } } @@ -1717,16 +1761,17 @@ } if (dev->board_ptr == NULL) { - printk("No supported ComputerBoards/MeasurementComputing card found\n"); + printk + ("No supported ComputerBoards/MeasurementComputing card found\n"); return -EIO; } printk("Found %s on bus %i, slot %i\n", board(dev)->name, - pcidev->bus->number, PCI_SLOT(pcidev->devfn)); + pcidev->bus->number, PCI_SLOT(pcidev->devfn)); if (comedi_pci_enable(pcidev, driver_cb_pcidas.driver_name)) { printk(KERN_WARNING - " failed to enable PCI device and request regions\n"); + " failed to enable PCI device and request regions\n"); return -EIO; } pci_set_master(pcidev); @@ -1735,23 +1780,25 @@ dev->board_name = board(dev)->name; priv(dev)->plx9080_phys_iobase = - pci_resource_start(pcidev, PLX9080_BADDRINDEX); + pci_resource_start(pcidev, PLX9080_BADDRINDEX); priv(dev)->main_phys_iobase = - pci_resource_start(pcidev, MAIN_BADDRINDEX); + pci_resource_start(pcidev, MAIN_BADDRINDEX); priv(dev)->dio_counter_phys_iobase = - pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX); + pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX); /* remap, won't work with 2.0 kernels but who cares */ priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase, - pci_resource_len(pcidev, PLX9080_BADDRINDEX)); - priv(dev)->main_iobase = ioremap(priv(dev)->main_phys_iobase, - pci_resource_len(pcidev, MAIN_BADDRINDEX)); + pci_resource_len(pcidev, + PLX9080_BADDRINDEX)); + priv(dev)->main_iobase = + ioremap(priv(dev)->main_phys_iobase, + pci_resource_len(pcidev, MAIN_BADDRINDEX)); priv(dev)->dio_counter_iobase = - ioremap(priv(dev)->dio_counter_phys_iobase, - pci_resource_len(pcidev, DIO_COUNTER_BADDRINDEX)); + ioremap(priv(dev)->dio_counter_phys_iobase, + pci_resource_len(pcidev, DIO_COUNTER_BADDRINDEX)); if (!priv(dev)->plx9080_iobase || !priv(dev)->main_iobase - || !priv(dev)->dio_counter_iobase) { + || !priv(dev)->dio_counter_iobase) { printk(" failed to remap io memory\n"); return -ENOMEM; } @@ -1759,27 +1806,25 @@ DEBUG_PRINT(" plx9080 remapped to 0x%p\n", priv(dev)->plx9080_iobase); DEBUG_PRINT(" main remapped to 0x%p\n", priv(dev)->main_iobase); DEBUG_PRINT(" diocounter remapped to 0x%p\n", - priv(dev)->dio_counter_iobase); + priv(dev)->dio_counter_iobase); /* figure out what local addresses are */ local_range = - readl(priv(dev)->plx9080_iobase + - PLX_LAS0RNG_REG) & LRNG_MEM_MASK; + readl(priv(dev)->plx9080_iobase + PLX_LAS0RNG_REG) & LRNG_MEM_MASK; local_decode = - readl(priv(dev)->plx9080_iobase + - PLX_LAS0MAP_REG) & local_range & LMAP_MEM_MASK; + readl(priv(dev)->plx9080_iobase + + PLX_LAS0MAP_REG) & local_range & LMAP_MEM_MASK; priv(dev)->local0_iobase = - ((uint32_t) priv(dev)-> - main_phys_iobase & ~local_range) | local_decode; + ((uint32_t) priv(dev)->main_phys_iobase & ~local_range) | + local_decode; local_range = - readl(priv(dev)->plx9080_iobase + - PLX_LAS1RNG_REG) & LRNG_MEM_MASK; + readl(priv(dev)->plx9080_iobase + PLX_LAS1RNG_REG) & LRNG_MEM_MASK; local_decode = - readl(priv(dev)->plx9080_iobase + - PLX_LAS1MAP_REG) & local_range & LMAP_MEM_MASK; + readl(priv(dev)->plx9080_iobase + + PLX_LAS1MAP_REG) & local_range & LMAP_MEM_MASK; priv(dev)->local1_iobase = - ((uint32_t) priv(dev)-> - dio_counter_phys_iobase & ~local_range) | local_decode; + ((uint32_t) priv(dev)->dio_counter_phys_iobase & ~local_range) | + local_decode; DEBUG_PRINT(" local 0 io addr 0x%x\n", priv(dev)->local0_iobase); DEBUG_PRINT(" local 1 io addr 0x%x\n", priv(dev)->local1_iobase); @@ -1789,7 +1834,7 @@ return retval; priv(dev)->hw_revision = - hw_revision(dev, readw(priv(dev)->main_iobase + HW_STATUS_REG)); + hw_revision(dev, readw(priv(dev)->main_iobase + HW_STATUS_REG)); printk(" stc hardware revision %i\n", priv(dev)->hw_revision); init_plx9080(dev); init_stc_registers(dev); @@ -1840,32 +1885,40 @@ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) { if (priv(dev)->ai_buffer[i]) pci_free_consistent(priv(dev)->hw_dev, - DMA_BUFFER_SIZE, - priv(dev)->ai_buffer[i], - priv(dev)-> - ai_buffer_bus_addr[i]); + DMA_BUFFER_SIZE, + priv(dev)-> + ai_buffer[i], + priv + (dev)->ai_buffer_bus_addr + [i]); } for (i = 0; i < AO_DMA_RING_COUNT; i++) { if (priv(dev)->ao_buffer[i]) pci_free_consistent(priv(dev)->hw_dev, - DMA_BUFFER_SIZE, - priv(dev)->ao_buffer[i], - priv(dev)-> - ao_buffer_bus_addr[i]); + DMA_BUFFER_SIZE, + priv(dev)-> + ao_buffer[i], + priv + (dev)->ao_buffer_bus_addr + [i]); } /* free dma descriptors */ if (priv(dev)->ai_dma_desc) pci_free_consistent(priv(dev)->hw_dev, - sizeof(struct plx_dma_desc) * - ai_dma_ring_count(board(dev)), - priv(dev)->ai_dma_desc, - priv(dev)->ai_dma_desc_bus_addr); + sizeof(struct plx_dma_desc) + * + ai_dma_ring_count(board + (dev)), + priv(dev)->ai_dma_desc, + priv(dev)-> + ai_dma_desc_bus_addr); if (priv(dev)->ao_dma_desc) pci_free_consistent(priv(dev)->hw_dev, - sizeof(struct plx_dma_desc) * - AO_DMA_RING_COUNT, - priv(dev)->ao_dma_desc, - priv(dev)->ao_dma_desc_bus_addr); + sizeof(struct plx_dma_desc) + * AO_DMA_RING_COUNT, + priv(dev)->ao_dma_desc, + priv(dev)-> + ao_dma_desc_bus_addr); if (priv(dev)->main_phys_iobase) { comedi_pci_disable(priv(dev)->hw_dev); } @@ -1879,7 +1932,7 @@ } static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { unsigned int bits = 0, n, i; unsigned int channel, range, aref; @@ -1901,14 +1954,14 @@ else priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT; writew(priv(dev)->adc_control1_bits, - priv(dev)->main_iobase + ADC_CONTROL1_REG); + priv(dev)->main_iobase + ADC_CONTROL1_REG); spin_unlock_irqrestore(&dev->spinlock, flags); if (board(dev)->layout != LAYOUT_4020) { /* use internal queue */ priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT; writew(priv(dev)->hw_config_bits, - priv(dev)->main_iobase + HW_CONFIG_REG); + priv(dev)->main_iobase + HW_CONFIG_REG); /* ALT_SOURCE is internal calibration reference */ if (insn->chanspec & CR_ALT_SOURCE) { @@ -1920,9 +1973,9 @@ else cal_en_bit = CAL_EN_64XX_BIT; /* select internal reference source to connect to channel 0 */ - writew(cal_en_bit | adc_src_bits(priv(dev)-> - calibration_source), - priv(dev)->main_iobase + CALIBRATION_REG); + writew(cal_en_bit | + adc_src_bits(priv(dev)->calibration_source), + priv(dev)->main_iobase + CALIBRATION_REG); } else { /* make sure internal calibration source is turned off */ writew(0, priv(dev)->main_iobase + CALIBRATION_REG); @@ -1938,7 +1991,7 @@ bits |= adc_chan_bits(channel); /* set stop channel */ writew(adc_chan_bits(channel), - priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); + priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); /* set start channel, and rest of settings */ writew(bits, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); } else { @@ -1948,8 +2001,7 @@ if (insn->chanspec & CR_ALT_SOURCE) { DEBUG_PRINT("reading calibration source\n"); priv(dev)->i2c_cal_range_bits |= - adc_src_4020_bits(priv(dev)-> - calibration_source); + adc_src_4020_bits(priv(dev)->calibration_source); } else { /* select BNC inputs */ priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4); } @@ -1958,20 +2010,20 @@ priv(dev)->i2c_cal_range_bits |= attenuate_bit(channel); else priv(dev)->i2c_cal_range_bits &= - ~attenuate_bit(channel); + ~attenuate_bit(channel); /* update calibration/range i2c register only if necessary, as it is very slow */ if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) { uint8_t i2c_data = priv(dev)->i2c_cal_range_bits; i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data, - sizeof(i2c_data)); + sizeof(i2c_data)); } /* 4020 manual asks that sample interval register to be set before writing to convert register. * Using somewhat arbitrary setting of 4 master clock ticks = 0.1 usec */ writew(0, - priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); + priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); writew(2, - priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); + priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); } for (n = 0; n < insn->n; n++) { @@ -1981,7 +2033,7 @@ /* trigger conversion, bits sent only matter for 4020 */ writew(adc_convert_chan_4020_bits(CR_CHAN(insn->chanspec)), - priv(dev)->main_iobase + ADC_CONVERT_REG); + priv(dev)->main_iobase + ADC_CONVERT_REG); /* wait for data */ for (i = 0; i < timeout; i++) { @@ -1989,7 +2041,7 @@ DEBUG_PRINT(" pipe bits 0x%x\n", pipe_full_bits(bits)); if (board(dev)->layout == LAYOUT_4020) { if (readw(priv(dev)->main_iobase + - ADC_WRITE_PNTR_REG)) + ADC_WRITE_PNTR_REG)) break; } else { if (pipe_full_bits(bits)) @@ -2005,17 +2057,18 @@ } if (board(dev)->layout == LAYOUT_4020) data[n] = - readl(priv(dev)->dio_counter_iobase + - ADC_FIFO_REG) & 0xffff; + readl(priv(dev)->dio_counter_iobase + + ADC_FIFO_REG) & 0xffff; else data[n] = - readw(priv(dev)->main_iobase + PIPE1_READ_REG); + readw(priv(dev)->main_iobase + PIPE1_READ_REG); } return n; } -static int ai_config_calibration_source(struct comedi_device *dev, unsigned int *data) +static int ai_config_calibration_source(struct comedi_device *dev, + unsigned int *data) { unsigned int source = data[1]; int num_calibration_sources; @@ -2046,8 +2099,7 @@ if (requested_block_size) { fifo_size = - requested_block_size * fifo->num_segments / - bytes_in_sample; + requested_block_size * fifo->num_segments / bytes_in_sample; retval = set_ai_fifo_size(dev, fifo_size); if (retval < 0) @@ -2062,7 +2114,8 @@ return 2; } -static int ai_config_master_clock_4020(struct comedi_device *dev, unsigned int *data) +static int ai_config_master_clock_4020(struct comedi_device *dev, + unsigned int *data) { unsigned int divisor = data[4]; int retval = 0; @@ -2104,7 +2157,7 @@ } static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { int id = data[0]; @@ -2126,7 +2179,7 @@ } static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) + struct comedi_cmd *cmd) { int err = 0; int tmp; @@ -2181,21 +2234,21 @@ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) err++; if (cmd->scan_begin_src != TRIG_TIMER && - cmd->scan_begin_src != TRIG_OTHER && - cmd->scan_begin_src != TRIG_FOLLOW) + cmd->scan_begin_src != TRIG_OTHER && + cmd->scan_begin_src != TRIG_FOLLOW) err++; if (cmd->convert_src != TRIG_TIMER && - cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) + cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) err++; if (cmd->stop_src != TRIG_COUNT && - cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) + cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) err++; /* compatibility check */ if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER) err++; if (cmd->stop_src != TRIG_COUNT && - cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) + cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) err++; if (err) @@ -2217,10 +2270,10 @@ if (cmd->scan_begin_src == TRIG_TIMER) { /* if scans are timed faster than conversion rate allows */ if (cmd->convert_arg * cmd->chanlist_len > - cmd->scan_begin_arg) { + cmd->scan_begin_arg) { cmd->scan_begin_arg = - cmd->convert_arg * - cmd->chanlist_len; + cmd->convert_arg * + cmd->chanlist_len; err++; } } @@ -2279,7 +2332,7 @@ for (i = 1; i < cmd->chanlist_len; i++) { if (aref != CR_AREF(cmd->chanlist[i])) { comedi_error(dev, - "all elements in chanlist must use the same analog reference"); + "all elements in chanlist must use the same analog reference"); err++; break; } @@ -2289,16 +2342,16 @@ unsigned int first_channel = CR_CHAN(cmd->chanlist[0]); for (i = 1; i < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i]) != - first_channel + i) { + first_channel + i) { comedi_error(dev, - "chanlist must use consecutive channels"); + "chanlist must use consecutive channels"); err++; break; } } if (cmd->chanlist_len == 3) { comedi_error(dev, - "chanlist cannot be 3 channels long, use 1, 2, or 4 channels"); + "chanlist cannot be 3 channels long, use 1, 2, or 4 channels"); err++; } } @@ -2321,7 +2374,8 @@ return 0; } -static void setup_sample_counters(struct comedi_device *dev, struct comedi_cmd *cmd) +static void setup_sample_counters(struct comedi_device *dev, + struct comedi_cmd *cmd) { if (cmd->stop_src == TRIG_COUNT) { /* set software count */ @@ -2330,9 +2384,9 @@ /* load hardware conversion counter */ if (use_hw_sample_counter(cmd)) { writew(cmd->stop_arg & 0xffff, - priv(dev)->main_iobase + ADC_COUNT_LOWER_REG); + priv(dev)->main_iobase + ADC_COUNT_LOWER_REG); writew((cmd->stop_arg >> 16) & 0xff, - priv(dev)->main_iobase + ADC_COUNT_UPPER_REG); + priv(dev)->main_iobase + ADC_COUNT_UPPER_REG); } else { writew(1, priv(dev)->main_iobase + ADC_COUNT_LOWER_REG); } @@ -2343,8 +2397,8 @@ unsigned int num_samples; num_samples = - priv(dev)->ai_fifo_segment_length * - board(dev)->ai_fifo->sample_packing_ratio; + priv(dev)->ai_fifo_segment_length * + board(dev)->ai_fifo->sample_packing_ratio; if (num_samples > DMA_BUFFER_SIZE / sizeof(uint16_t)) num_samples = DMA_BUFFER_SIZE / sizeof(uint16_t); @@ -2360,12 +2414,12 @@ spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->adc_control1_bits &= ~ADC_SW_GATE_BIT; writew(priv(dev)->adc_control1_bits, - priv(dev)->main_iobase + ADC_CONTROL1_REG); + priv(dev)->main_iobase + ADC_CONTROL1_REG); spin_unlock_irqrestore(&dev->spinlock, flags); /* disable pacing, triggering, etc */ writew(ADC_DMA_DISABLE_BIT | ADC_SOFT_GATE_BITS | ADC_GATE_LEVEL_BIT, - priv(dev)->main_iobase + ADC_CONTROL0_REG); + priv(dev)->main_iobase + ADC_CONTROL0_REG); } static void disable_ai_interrupts(struct comedi_device *dev) @@ -2374,23 +2428,24 @@ spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->intr_enable_bits &= - ~EN_ADC_INTR_SRC_BIT & ~EN_ADC_DONE_INTR_BIT & - ~EN_ADC_ACTIVE_INTR_BIT & ~EN_ADC_STOP_INTR_BIT & - ~EN_ADC_OVERRUN_BIT & ~ADC_INTR_SRC_MASK; + ~EN_ADC_INTR_SRC_BIT & ~EN_ADC_DONE_INTR_BIT & + ~EN_ADC_ACTIVE_INTR_BIT & ~EN_ADC_STOP_INTR_BIT & + ~EN_ADC_OVERRUN_BIT & ~ADC_INTR_SRC_MASK; writew(priv(dev)->intr_enable_bits, - priv(dev)->main_iobase + INTR_ENABLE_REG); + priv(dev)->main_iobase + INTR_ENABLE_REG); spin_unlock_irqrestore(&dev->spinlock, flags); DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits); } -static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd) +static void enable_ai_interrupts(struct comedi_device *dev, + const struct comedi_cmd *cmd) { uint32_t bits; unsigned long flags; bits = EN_ADC_OVERRUN_BIT | EN_ADC_DONE_INTR_BIT | - EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT; + EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT; /* Use pio transfer and interrupt on end of conversion if TRIG_WAKE_EOS flag is set. */ if (cmd->flags & TRIG_WAKE_EOS) { /* 4020 doesn't support pio transfers except for fifo dregs */ @@ -2400,27 +2455,28 @@ spin_lock_irqsave(&dev->spinlock, flags); priv(dev)->intr_enable_bits |= bits; writew(priv(dev)->intr_enable_bits, - priv(dev)->main_iobase + INTR_ENABLE_REG); + priv(dev)->main_iobase + INTR_ENABLE_REG); DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits); spin_unlock_irqrestore(&dev->spinlock, flags); } static uint32_t ai_convert_counter_6xxx(const struct comedi_device *dev, - const struct comedi_cmd *cmd) + const struct comedi_cmd *cmd) { /* supposed to load counter with desired divisor minus 3 */ return cmd->convert_arg / TIMER_BASE - 3; } -static uint32_t ai_scan_counter_6xxx(struct comedi_device *dev, struct comedi_cmd *cmd) +static uint32_t ai_scan_counter_6xxx(struct comedi_device *dev, + struct comedi_cmd *cmd) { uint32_t count; /* figure out how long we need to delay at end of scan */ switch (cmd->scan_begin_src) { case TRIG_TIMER: count = (cmd->scan_begin_arg - - (cmd->convert_arg * (cmd->chanlist_len - 1))) - / TIMER_BASE; + (cmd->convert_arg * (cmd->chanlist_len - 1))) + / TIMER_BASE; break; case TRIG_FOLLOW: count = cmd->convert_arg / TIMER_BASE; @@ -2432,7 +2488,8 @@ return count - 3; } -static uint32_t ai_convert_counter_4020(struct comedi_device *dev, struct comedi_cmd *cmd) +static uint32_t ai_convert_counter_4020(struct comedi_device *dev, + struct comedi_cmd *cmd) { unsigned int divisor; @@ -2454,7 +2511,7 @@ } static void select_master_clock_4020(struct comedi_device *dev, - const struct comedi_cmd *cmd) + const struct comedi_cmd *cmd) { /* select internal/external master clock */ priv(dev)->hw_config_bits &= ~MASTER_CLOCK_4020_MASK; @@ -2469,10 +2526,11 @@ priv(dev)->hw_config_bits |= INTERNAL_CLOCK_4020_BITS; } writew(priv(dev)->hw_config_bits, - priv(dev)->main_iobase + HW_CONFIG_REG); + priv(dev)->main_iobase + HW_CONFIG_REG); } -static void select_master_clock(struct comedi_device *dev, const struct comedi_cmd *cmd) +static void select_master_clock(struct comedi_device *dev, + const struct comedi_cmd *cmd) { switch (board(dev)->layout) { case LAYOUT_4020: @@ -2483,7 +2541,8 @@ } } -static inline void dma_start_sync(struct comedi_device *dev, unsigned int channel) +static inline void dma_start_sync(struct comedi_device *dev, + unsigned int channel) { unsigned long flags; @@ -2491,12 +2550,12 @@ spin_lock_irqsave(&dev->spinlock, flags); if (channel) writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | - PLX_CLEAR_DMA_INTR_BIT, - priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); + PLX_CLEAR_DMA_INTR_BIT, + priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); else writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | - PLX_CLEAR_DMA_INTR_BIT, - priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); + PLX_CLEAR_DMA_INTR_BIT, + priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -2517,17 +2576,17 @@ /* load lower 16 bits of convert interval */ writew(convert_counter & 0xffff, - priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); + priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); DEBUG_PRINT("convert counter 0x%x\n", convert_counter); /* load upper 8 bits of convert interval */ writew((convert_counter >> 16) & 0xff, - priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); + priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); /* load lower 16 bits of scan delay */ writew(scan_counter & 0xffff, - priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG); + priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG); /* load upper 8 bits of scan delay */ writew((scan_counter >> 16) & 0xff, - priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG); + priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG); DEBUG_PRINT("scan counter 0x%x\n", scan_counter); } @@ -2536,10 +2595,10 @@ int i; for (i = 0; i + 1 < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i + 1]) != - CR_CHAN(cmd->chanlist[i]) + 1) + CR_CHAN(cmd->chanlist[i]) + 1) return 0; if (CR_RANGE(cmd->chanlist[i + 1]) != - CR_RANGE(cmd->chanlist[i])) + CR_RANGE(cmd->chanlist[i])) return 0; if (CR_AREF(cmd->chanlist[i + 1]) != CR_AREF(cmd->chanlist[i])) return 0; @@ -2547,7 +2606,8 @@ return 1; } -static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cmd *cmd) +static int setup_channel_queue(struct comedi_device *dev, + const struct comedi_cmd *cmd) { unsigned short bits; int i; @@ -2556,25 +2616,26 @@ if (use_internal_queue_6xxx(cmd)) { priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT; writew(priv(dev)->hw_config_bits, - priv(dev)->main_iobase + HW_CONFIG_REG); + priv(dev)->main_iobase + HW_CONFIG_REG); bits = 0; /* set channel */ bits |= adc_chan_bits(CR_CHAN(cmd->chanlist[0])); /* set gain */ bits |= ai_range_bits_6xxx(dev, - CR_RANGE(cmd->chanlist[0])); + CR_RANGE(cmd->chanlist[0])); /* set single-ended / differential */ bits |= se_diff_bit_6xxx(dev, - CR_AREF(cmd->chanlist[0]) == AREF_DIFF); + CR_AREF(cmd->chanlist[0]) == + AREF_DIFF); if (CR_AREF(cmd->chanlist[0]) == AREF_COMMON) bits |= ADC_COMMON_BIT; /* set stop channel */ - writew(adc_chan_bits(CR_CHAN(cmd->chanlist[cmd-> - chanlist_len - 1])), - priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); + writew(adc_chan_bits + (CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1])), + priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG); /* set start channel, and rest of settings */ writew(bits, - priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); + priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG); } else { /* use external queue */ if (dev->write_subdev && dev->write_subdev->busy) { @@ -2583,36 +2644,40 @@ } priv(dev)->hw_config_bits |= EXT_QUEUE_BIT; writew(priv(dev)->hw_config_bits, - priv(dev)->main_iobase + HW_CONFIG_REG); + priv(dev)->main_iobase + HW_CONFIG_REG); /* clear DAC buffer to prevent weird interactions */ writew(0, - priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG); + priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG); /* clear queue pointer */ writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG); /* load external queue */ for (i = 0; i < cmd->chanlist_len; i++) { bits = 0; /* set channel */ - bits |= adc_chan_bits(CR_CHAN(cmd-> - chanlist[i])); + bits |= + adc_chan_bits(CR_CHAN(cmd->chanlist[i])); /* set gain */ bits |= ai_range_bits_6xxx(dev, - CR_RANGE(cmd->chanlist[i])); + CR_RANGE(cmd-> + chanlist + [i])); /* set single-ended / differential */ bits |= se_diff_bit_6xxx(dev, - CR_AREF(cmd->chanlist[i]) == AREF_DIFF); + CR_AREF(cmd-> + chanlist[i]) == + AREF_DIFF); if (CR_AREF(cmd->chanlist[i]) == AREF_COMMON) bits |= ADC_COMMON_BIT; /* mark end of queue */ if (i == cmd->chanlist_len - 1) bits |= QUEUE_EOSCAN_BIT | - QUEUE_EOSEQ_BIT; + QUEUE_EOSEQ_BIT; writew(bits, - priv(dev)->main_iobase + - ADC_QUEUE_FIFO_REG); + priv(dev)->main_iobase + + ADC_QUEUE_FIFO_REG); DEBUG_PRINT - ("wrote 0x%x to external channel queue\n", - bits); + ("wrote 0x%x to external channel queue\n", + bits); } /* doing a queue clear is not specified in board docs, * but required for reliable operation */ @@ -2622,7 +2687,7 @@ } } else { unsigned short old_cal_range_bits = - priv(dev)->i2c_cal_range_bits; + priv(dev)->i2c_cal_range_bits; priv(dev)->i2c_cal_range_bits &= ~ADC_SRC_4020_MASK; /* select BNC inputs */ @@ -2634,23 +2699,24 @@ if (range == 0) priv(dev)->i2c_cal_range_bits |= - attenuate_bit(channel); + attenuate_bit(channel); else priv(dev)->i2c_cal_range_bits &= - ~attenuate_bit(channel); + ~attenuate_bit(channel); } /* update calibration/range i2c register only if necessary, as it is very slow */ if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) { uint8_t i2c_data = priv(dev)->i2c_cal_range_bits; i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data, - sizeof(i2c_data)); + sizeof(i2c_data)); } } return 0; } static inline void load_first_dma_descriptor(struct comedi_device *dev, - unsigned int dma_channel, unsigned int descriptor_bits) + unsigned int dma_channel, + unsigned int descriptor_bits) { /* The transfer size, pci address, and local address registers * are supposedly unused during chained dma, @@ -2659,20 +2725,20 @@ * block. Initializing them to zero seems to fix the problem. */ if (dma_channel) { writel(0, - priv(dev)->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG); + priv(dev)->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG); writel(0, priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG); writel(0, - priv(dev)->plx9080_iobase + PLX_DMA1_LOCAL_ADDRESS_REG); + priv(dev)->plx9080_iobase + PLX_DMA1_LOCAL_ADDRESS_REG); writel(descriptor_bits, - priv(dev)->plx9080_iobase + PLX_DMA1_DESCRIPTOR_REG); + priv(dev)->plx9080_iobase + PLX_DMA1_DESCRIPTOR_REG); } else { writel(0, - priv(dev)->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG); + priv(dev)->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG); writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); writel(0, - priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG); + priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG); writel(descriptor_bits, - priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG); + priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG); } } @@ -2719,14 +2785,15 @@ priv(dev)->adc_control1_bits |= TWO_CHANNEL_4020_BITS; priv(dev)->adc_control1_bits &= ~ADC_LO_CHANNEL_4020_MASK; priv(dev)->adc_control1_bits |= - adc_lo_chan_4020_bits(CR_CHAN(cmd->chanlist[0])); + adc_lo_chan_4020_bits(CR_CHAN(cmd->chanlist[0])); priv(dev)->adc_control1_bits &= ~ADC_HI_CHANNEL_4020_MASK; priv(dev)->adc_control1_bits |= - adc_hi_chan_4020_bits(CR_CHAN(cmd->chanlist[cmd-> - chanlist_len - 1])); + adc_hi_chan_4020_bits(CR_CHAN + (cmd-> + chanlist[cmd->chanlist_len - 1])); } writew(priv(dev)->adc_control1_bits, - priv(dev)->main_iobase + ADC_CONTROL1_REG); + priv(dev)->main_iobase + ADC_CONTROL1_REG); DEBUG_PRINT("control1 bits 0x%x\n", priv(dev)->adc_control1_bits); spin_unlock_irqrestore(&dev->spinlock, flags); @@ -2734,20 +2801,21 @@ writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG); if ((cmd->flags & TRIG_WAKE_EOS) == 0 || - board(dev)->layout == LAYOUT_4020) { + board(dev)->layout == LAYOUT_4020) { priv(dev)->ai_dma_index = 0; /* set dma transfer size */ for (i = 0; i < ai_dma_ring_count(board(dev)); i++) priv(dev)->ai_dma_desc[i].transfer_size = - cpu_to_le32(dma_transfer_size(dev) * - sizeof(uint16_t)); + cpu_to_le32(dma_transfer_size(dev) * + sizeof(uint16_t)); /* give location of first dma descriptor */ load_first_dma_descriptor(dev, 1, - priv(dev)-> - ai_dma_desc_bus_addr | PLX_DESC_IN_PCI_BIT | - PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI); + priv(dev)->ai_dma_desc_bus_addr | + PLX_DESC_IN_PCI_BIT | + PLX_INTR_TERM_COUNT | + PLX_XFER_LOCAL_TO_PCI); dma_start_sync(dev, 1); } @@ -2807,11 +2875,9 @@ do { /* get least significant 15 bits */ read_index = - readw(priv(dev)->main_iobase + - ADC_READ_PNTR_REG) & 0x7fff; + readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; write_index = - readw(priv(dev)->main_iobase + - ADC_WRITE_PNTR_REG) & 0x7fff; + readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff; /* Get most significant bits (grey code). Different boards use different code * so use a scheme that doesn't depend on encoding. This read must * occur after reading least significant 15 bits to avoid race @@ -2824,11 +2890,12 @@ write_segment = adc_upper_write_ptr_code(prepost_bits); DEBUG_PRINT(" rd seg %i, wrt seg %i, rd idx %i, wrt idx %i\n", - read_segment, write_segment, read_index, write_index); + read_segment, write_segment, read_index, + write_index); if (read_segment != write_segment) num_samples = - priv(dev)->ai_fifo_segment_length - read_index; + priv(dev)->ai_fifo_segment_length - read_index; else num_samples = write_index - read_index; @@ -2850,7 +2917,8 @@ for (i = 0; i < num_samples; i++) { cfc_write_to_buffer(s, - readw(priv(dev)->main_iobase + ADC_FIFO_REG)); + readw(priv(dev)->main_iobase + + ADC_FIFO_REG)); } } while (read_segment != write_segment); @@ -2870,9 +2938,9 @@ unsigned int max_transfer = 100000; uint32_t fifo_data; int write_code = - readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff; + readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff; int read_code = - readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; + readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; if (cmd->stop_src == TRIG_COUNT) { if (max_transfer > priv(dev)->ai_count) { @@ -2888,8 +2956,7 @@ i++; } read_code = - readw(priv(dev)->main_iobase + - ADC_READ_PNTR_REG) & 0x7fff; + readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; } priv(dev)->ai_count -= i; } @@ -2913,19 +2980,18 @@ if (channel) pci_addr_reg = - priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG; + priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG; else pci_addr_reg = - priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; + priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; /* loop until we have read all the full buffers */ for (j = 0, next_transfer_addr = readl(pci_addr_reg); - (next_transfer_addr < - priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] - || next_transfer_addr >= - priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] + - DMA_BUFFER_SIZE) && j < ai_dma_ring_count(board(dev)); - j++) { + (next_transfer_addr < + priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] + || next_transfer_addr >= + priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] + + DMA_BUFFER_SIZE) && j < ai_dma_ring_count(board(dev)); j++) { /* transfer data from dma buffer to comedi buffer */ num_samples = dma_transfer_size(dev); if (async->cmd.stop_src == TRIG_COUNT) { @@ -2934,15 +3000,16 @@ priv(dev)->ai_count -= num_samples; } cfc_write_array_to_buffer(dev->read_subdev, - priv(dev)->ai_buffer[priv(dev)->ai_dma_index], - num_samples * sizeof(uint16_t)); + priv(dev)->ai_buffer[priv(dev)-> + ai_dma_index], + num_samples * sizeof(uint16_t)); priv(dev)->ai_dma_index = - (priv(dev)->ai_dma_index + - 1) % ai_dma_ring_count(board(dev)); + (priv(dev)->ai_dma_index + + 1) % ai_dma_ring_count(board(dev)); DEBUG_PRINT("next buffer addr 0x%lx\n", - (unsigned long)priv(dev)->ai_buffer_bus_addr[priv(dev)-> - ai_dma_index]); + (unsigned long)priv(dev)-> + ai_buffer_bus_addr[priv(dev)->ai_dma_index]); DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr); } /* XXX check for dma ring buffer overrun (use end-of-chain bit to mark last @@ -2950,7 +3017,7 @@ } void handle_ai_interrupt(struct comedi_device *dev, unsigned short status, - unsigned int plx_status) + unsigned int plx_status) { struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; @@ -2968,7 +3035,7 @@ dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); if (plx_status & ICS_DMA1_A) { /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, - priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); + priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); DEBUG_PRINT("dma1 status 0x%x\n", dma1_status); if (dma1_status & PLX_DMA_EN_BIT) { @@ -2983,9 +3050,9 @@ /* drain fifo with pio */ if ((status & ADC_DONE_BIT) || - ((cmd->flags & TRIG_WAKE_EOS) && - (status & ADC_INTR_PENDING_BIT) && - (board(dev)->layout != LAYOUT_4020))) { + ((cmd->flags & TRIG_WAKE_EOS) && + (status & ADC_INTR_PENDING_BIT) && + (board(dev)->layout != LAYOUT_4020))) { DEBUG_PRINT("pio fifo drain\n"); spin_lock_irqsave(&dev->spinlock, flags); if (priv(dev)->ai_cmd_running) { @@ -2996,7 +3063,7 @@ } /* if we are have all the data, then quit */ if ((cmd->stop_src == TRIG_COUNT && priv(dev)->ai_count <= 0) || - (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) { + (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) { async->events |= COMEDI_CB_EOA; } @@ -3026,14 +3093,15 @@ return 0; transfer_address = - readl(priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); + readl(priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); if (transfer_address != priv(dev)->ao_buffer_bus_addr[buffer_