aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-11-18 17:23:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-06 16:52:21 -0500
commite54fb9c184a250fc80c48110ae42068bb0237a13 (patch)
treecccdd34ed23769916b3f4f8ac8940f1db6dc3a32
parent8fa07567bf5d824537839e6984a571daeed2c7fc (diff)
Staging: comedi: usbdux: remove // comments
This converts all // comments to be /* */ Cc: Bernd Porr <BerndPorr@f2s.com> Cc: David Schleef <ds@schleef.org> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c713
1 files changed, 364 insertions, 349 deletions
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 3c51607a2e0..ba4e3fdc9bf 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -78,8 +78,8 @@ sampling rate. If you sample two channels you get 4kHz and so on.
78 * 78 *
79 */ 79 */
80 80
81// generates loads of debug info 81/* generates loads of debug info */
82// #define NOISY_DUX_DEBUGBUG 82/* #define NOISY_DUX_DEBUGBUG */
83 83
84#include <linux/kernel.h> 84#include <linux/kernel.h>
85#include <linux/module.h> 85#include <linux/module.h>
@@ -96,111 +96,117 @@ sampling rate. If you sample two channels you get 4kHz and so on.
96 96
97#define BOARDNAME "usbdux" 97#define BOARDNAME "usbdux"
98 98
99// timeout for the USB-transfer 99/* timeout for the USB-transfer */
100#define EZTIMEOUT 30 100#define EZTIMEOUT 30
101 101
102// constants for "firmware" upload and download 102/* constants for "firmware" upload and download */
103#define USBDUXSUB_FIRMWARE 0xA0 103#define USBDUXSUB_FIRMWARE 0xA0
104#define VENDOR_DIR_IN 0xC0 104#define VENDOR_DIR_IN 0xC0
105#define VENDOR_DIR_OUT 0x40 105#define VENDOR_DIR_OUT 0x40
106 106
107// internal adresses of the 8051 processor 107/* internal adresses of the 8051 processor */
108#define USBDUXSUB_CPUCS 0xE600 108#define USBDUXSUB_CPUCS 0xE600
109 109
110// the minor device number, major is 180 110/*
111// only for debugging purposes and to 111 * the minor device number, major is 180 only for debugging purposes and to
112// upload special firmware (programming the 112 * upload special firmware (programming the eeprom etc) which is not compatible
113// eeprom etc) which is not compatible with 113 * with the comedi framwork
114// the comedi framwork 114 */
115#define USBDUXSUB_MINOR 32 115#define USBDUXSUB_MINOR 32
116 116
117// max lenghth of the transfer-buffer for software upload 117/* max lenghth of the transfer-buffer for software upload */
118#define TB_LEN 0x2000 118#define TB_LEN 0x2000
119 119
120// Input endpoint number: ISO/IRQ 120/* Input endpoint number: ISO/IRQ */
121#define ISOINEP 6 121#define ISOINEP 6
122 122
123// Output endpoint number: ISO/IRQ 123/* Output endpoint number: ISO/IRQ */
124#define ISOOUTEP 2 124#define ISOOUTEP 2
125 125
126// This EP sends DUX commands to USBDUX 126/* This EP sends DUX commands to USBDUX */
127#define COMMAND_OUT_EP 1 127#define COMMAND_OUT_EP 1
128 128
129// This EP receives the DUX commands from USBDUX 129/* This EP receives the DUX commands from USBDUX */
130#define COMMAND_IN_EP 8 130#define COMMAND_IN_EP 8
131 131
132// Output endpoint for PWM 132/* Output endpoint for PWM */
133#define PWM_EP 4 133#define PWM_EP 4
134 134
135// 300Hz max frequ under PWM 135/* 300Hz max frequ under PWM */
136#define MIN_PWM_PERIOD ((long)(1E9/300)) 136#define MIN_PWM_PERIOD ((long)(1E9/300))
137 137
138// Default PWM frequency 138/* Default PWM frequency */
139#define PWM_DEFAULT_PERIOD ((long)(1E9/100)) 139#define PWM_DEFAULT_PERIOD ((long)(1E9/100))
140 140
141// Number of channels 141/* Number of channels */
142#define NUMCHANNELS 8 142#define NUMCHANNELS 8
143 143
144// Size of one A/D value 144/* Size of one A/D value */
145#define SIZEADIN ((sizeof(int16_t))) 145#define SIZEADIN ((sizeof(int16_t)))
146 146
147// Size of the input-buffer IN BYTES 147/* Size of the input-buffer IN BYTES */
148// Always multiple of 8 for 8 microframes which is needed in the highspeed mode 148/* Always multiple of 8 for 8 microframes which is needed in the highspeed mode */
149#define SIZEINBUF ((8*SIZEADIN)) 149#define SIZEINBUF ((8*SIZEADIN))
150 150
151// 16 bytes. 151/* 16 bytes. */
152#define SIZEINSNBUF 16 152#define SIZEINSNBUF 16
153 153
154// Number of DA channels 154/* Number of DA channels */
155#define NUMOUTCHANNELS 8 155#define NUMOUTCHANNELS 8
156 156
157// size of one value for the D/A converter: channel and value 157/* size of one value for the D/A converter: channel and value */
158#define SIZEDAOUT ((sizeof(int8_t)+sizeof(int16_t))) 158#define SIZEDAOUT ((sizeof(int8_t)+sizeof(int16_t)))
159 159
160// Size of the output-buffer in bytes 160/*
161// Actually only the first 4 triplets are used but for the 161 * Size of the output-buffer in bytes
162// high speed mode we need to pad it to 8 (microframes). 162 * Actually only the first 4 triplets are used but for the
163 * high speed mode we need to pad it to 8 (microframes).
164 */
163#define SIZEOUTBUF ((8*SIZEDAOUT)) 165#define SIZEOUTBUF ((8*SIZEDAOUT))
164 166
165// Size of the buffer for the dux commands: just now max size is determined 167/*
166// by the analogue out + command byte + panic bytes... 168 * Size of the buffer for the dux commands: just now max size is determined
169 * by the analogue out + command byte + panic bytes...
170 */
167#define SIZEOFDUXBUFFER ((8*SIZEDAOUT+2)) 171#define SIZEOFDUXBUFFER ((8*SIZEDAOUT+2))
168 172
169// Number of in-URBs which receive the data: min=2 173/* Number of in-URBs which receive the data: min=2 */
170#define NUMOFINBUFFERSFULL 5 174#define NUMOFINBUFFERSFULL 5
171 175
172// Number of out-URBs which send the data: min=2 176/* Number of out-URBs which send the data: min=2 */
173#define NUMOFOUTBUFFERSFULL 5 177#define NUMOFOUTBUFFERSFULL 5
174 178
175// Number of in-URBs which receive the data: min=5 179/* Number of in-URBs which receive the data: min=5 */
176#define NUMOFINBUFFERSHIGH 10 // must have more buffers due to buggy USB ctr 180/* must have more buffers due to buggy USB ctr */
181#define NUMOFINBUFFERSHIGH 10
177 182
178// Number of out-URBs which send the data: min=5 183/* Number of out-URBs which send the data: min=5 */
179#define NUMOFOUTBUFFERSHIGH 10 // must have more buffers due to buggy USB ctr 184/* must have more buffers due to buggy USB ctr */
185#define NUMOFOUTBUFFERSHIGH 10
180 186
181// Total number of usbdux devices 187/* Total number of usbdux devices */
182#define NUMUSBDUX 16 188#define NUMUSBDUX 16
183 189
184// Analogue in subdevice 190/* Analogue in subdevice */
185#define SUBDEV_AD 0 191#define SUBDEV_AD 0
186 192
187// Analogue out subdevice 193/* Analogue out subdevice */
188#define SUBDEV_DA 1 194#define SUBDEV_DA 1
189 195
190// Digital I/O 196/* Digital I/O */
191#define SUBDEV_DIO 2 197#define SUBDEV_DIO 2
192 198
193// counter 199/* counter */
194#define SUBDEV_COUNTER 3 200#define SUBDEV_COUNTER 3
195 201
196// timer aka pwm output 202/* timer aka pwm output */
197#define SUBDEV_PWM 4 203#define SUBDEV_PWM 4
198 204
199// number of retries to get the right dux command 205/* number of retries to get the right dux command */
200#define RETRIES 10 206#define RETRIES 10
201 207
202///////////////////////////////////////////// 208/**************************************************/
203// comedi constants 209/* comedi constants */
204static const comedi_lrange range_usbdux_ai_range = { 4, { 210static const comedi_lrange range_usbdux_ai_range = { 4, {
205 BIP_RANGE(4.096), 211 BIP_RANGE(4.096),
206 BIP_RANGE(4.096 / 2), 212 BIP_RANGE(4.096 / 2),
@@ -219,83 +225,87 @@ static const comedi_lrange range_usbdux_ao_range = { 2, {
219 * private structure of one subdevice 225 * private structure of one subdevice
220 */ 226 */
221 227
222// This is the structure which holds all the data of this driver 228/*
223// one sub device just now: A/D 229 * This is the structure which holds all the data of
230 * this driver one sub device just now: A/D
231 */
224typedef struct { 232typedef struct {
225 // attached? 233 /* attached? */
226 int attached; 234 int attached;
227 // is it associated with a subdevice? 235 /* is it associated with a subdevice? */
228 int probed; 236 int probed;
229 // pointer to the usb-device 237 /* pointer to the usb-device */
230 struct usb_device *usbdev; 238 struct usb_device *usbdev;
231 // actual number of in-buffers 239 /* actual number of in-buffers */
232 int numOfInBuffers; 240 int numOfInBuffers;
233 // actual number of out-buffers 241 /* actual number of out-buffers */
234 int numOfOutBuffers; 242 int numOfOutBuffers;
235 // ISO-transfer handling: buffers 243 /* ISO-transfer handling: buffers */
236 struct urb **urbIn; 244 struct urb **urbIn;
237 struct urb **urbOut; 245 struct urb **urbOut;
238 // pwm-transfer handling 246 /* pwm-transfer handling */
239 struct urb *urbPwm; 247 struct urb *urbPwm;
240 // PWM period 248 /* PWM period */
241 lsampl_t pwmPeriod; 249 lsampl_t pwmPeriod;
242 // PWM internal delay for the GPIF in the FX2 250 /* PWM internal delay for the GPIF in the FX2 */
243 int8_t pwmDelay; 251 int8_t pwmDelay;
244 // size of the PWM buffer which holds the bit pattern 252 /* size of the PWM buffer which holds the bit pattern */
245 int sizePwmBuf; 253 int sizePwmBuf;
246 // input buffer for the ISO-transfer 254 /* input buffer for the ISO-transfer */
247 int16_t *inBuffer; 255 int16_t *inBuffer;
248 // input buffer for single insn 256 /* input buffer for single insn */
249 int16_t *insnBuffer; 257 int16_t *insnBuffer;
250 // output buffer for single DA outputs 258 /* output buffer for single DA outputs */
251 int16_t *outBuffer; 259 int16_t *outBuffer;
252 // interface number 260 /* interface number */
253 int ifnum; 261 int ifnum;
254 // interface structure in 2.6 262 /* interface structure in 2.6 */
255 struct usb_interface *interface; 263 struct usb_interface *interface;
256 // comedi device for the interrupt context 264 /* comedi device for the interrupt context */
257 comedi_device *comedidev; 265 comedi_device *comedidev;
258 // is it USB_SPEED_HIGH or not? 266 /* is it USB_SPEED_HIGH or not? */
259 short int high_speed; 267 short int high_speed;
260 // asynchronous command is running 268 /* asynchronous command is running */
261 short int ai_cmd_running; 269 short int ai_cmd_running;
262 short int ao_cmd_running; 270 short int ao_cmd_running;
263 // pwm is running 271 /* pwm is running */
264 short int pwm_cmd_running; 272 short int pwm_cmd_running;
265 // continous aquisition 273 /* continous aquisition */
266 short int ai_continous; 274 short int ai_continous;
267 short int ao_continous; 275 short int ao_continous;
268 // number of samples to aquire 276 /* number of samples to aquire */
269 int ai_sample_count; 277 int ai_sample_count;
270 int ao_sample_count; 278 int ao_sample_count;
271 // time between samples in units of the timer 279 /* time between samples in units of the timer */
272 unsigned int ai_timer; 280 unsigned int ai_timer;
273 unsigned int ao_timer; 281 unsigned int ao_timer;
274 // counter between aquisitions 282 /* counter between aquisitions */
275 unsigned int ai_counter; 283 unsigned int ai_counter;
276 unsigned int ao_counter; 284 unsigned int ao_counter;
277 // interval in frames/uframes 285 /* interval in frames/uframes */
278 unsigned int ai_interval; 286 unsigned int ai_interval;
279 // D/A commands 287 /* D/A commands */
280 int8_t *dac_commands; 288 int8_t *dac_commands;
281 // commands 289 /* commands */
282 int8_t *dux_commands; 290 int8_t *dux_commands;
283 struct semaphore sem; 291 struct semaphore sem;
284} usbduxsub_t; 292} usbduxsub_t;
285 293
286// The pointer to the private usb-data of the driver 294/*
287// is also the private data for the comedi-device. 295 * The pointer to the private usb-data of the driver is also the private data
288// This has to be global as the usb subsystem needs 296 * for the comedi-device. This has to be global as the usb subsystem needs
289// global variables. The other reason is that this 297 * global variables. The other reason is that this structure must be there
290// structure must be there _before_ any comedi 298 * _before_ any comedi command is issued. The usb subsystem must be initialised
291// command is issued. The usb subsystem must be 299 * before comedi can access it.
292// initialised before comedi can access it. 300 */
293static usbduxsub_t usbduxsub[NUMUSBDUX]; 301static usbduxsub_t usbduxsub[NUMUSBDUX];
294 302
295static DECLARE_MUTEX(start_stop_sem); 303static DECLARE_MUTEX(start_stop_sem);
296 304
297// Stops the data acquision 305/*
298// It should be safe to call this function from any context 306 * Stops the data acquision
307 * It should be safe to call this function from any context
308 */
299static int usbduxsub_unlink_InURBs(usbduxsub_t *usbduxsub_tmp) 309static int usbduxsub_unlink_InURBs(usbduxsub_t *usbduxsub_tmp)
300{ 310{
301 int i = 0; 311 int i = 0;
@@ -304,8 +314,8 @@ static int usbduxsub_unlink_InURBs(usbduxsub_t *usbduxsub_tmp)
304 if (usbduxsub_tmp && usbduxsub_tmp->urbIn) { 314 if (usbduxsub_tmp && usbduxsub_tmp->urbIn) {
305 for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) { 315 for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) {
306 if (usbduxsub_tmp->urbIn[i]) { 316 if (usbduxsub_tmp->urbIn[i]) {
307 // We wait here until all transfers 317 /* We wait here until all transfers have been
308 // have been cancelled. 318 * cancelled. */
309 usb_kill_urb(usbduxsub_tmp->urbIn[i]); 319 usb_kill_urb(usbduxsub_tmp->urbIn[i]);
310 } 320 }
311#ifdef NOISY_DUX_DEBUGBUG 321#ifdef NOISY_DUX_DEBUGBUG
@@ -335,7 +345,7 @@ static int usbdux_ai_stop(usbduxsub_t *this_usbduxsub, int do_unlink)
335#endif 345#endif
336 346
337 if (do_unlink) { 347 if (do_unlink) {
338 // stop aquistion 348 /* stop aquistion */
339 ret = usbduxsub_unlink_InURBs(this_usbduxsub); 349 ret = usbduxsub_unlink_InURBs(this_usbduxsub);
340 } 350 }
341 351
@@ -344,15 +354,16 @@ static int usbdux_ai_stop(usbduxsub_t *this_usbduxsub, int do_unlink)
344 return ret; 354 return ret;
345} 355}
346 356
347// This will cancel a running acquisition operation. 357/*
348// This is called by comedi but never from inside the 358 * This will cancel a running acquisition operation.
349// driver. 359 * This is called by comedi but never from inside the driver.
360 */
350static int usbdux_ai_cancel(comedi_device * dev, comedi_subdevice * s) 361static int usbdux_ai_cancel(comedi_device * dev, comedi_subdevice * s)
351{ 362{
352 usbduxsub_t *this_usbduxsub; 363 usbduxsub_t *this_usbduxsub;
353 int res = 0; 364 int res = 0;
354 365
355 // force unlink of all urbs 366 /* force unlink of all urbs */
356#ifdef NOISY_DUX_DEBUGBUG 367#ifdef NOISY_DUX_DEBUGBUG
357 printk("comedi: usbdux_ai_cancel\n"); 368 printk("comedi: usbdux_ai_cancel\n");
358#endif 369#endif
@@ -361,20 +372,19 @@ static int usbdux_ai_cancel(comedi_device * dev, comedi_subdevice * s)
361 printk("comedi: usbdux_ai_cancel: this_usbduxsub=NULL\n"); 372 printk("comedi: usbdux_ai_cancel: this_usbduxsub=NULL\n");
362 return -EFAULT; 373 return -EFAULT;
363 } 374 }
364 // prevent other CPUs from submitting new commands just now 375 /* prevent other CPUs from submitting new commands just now */
365 down(&this_usbduxsub->sem); 376 down(&this_usbduxsub->sem);
366 if (!(this_usbduxsub->probed)) { 377 if (!(this_usbduxsub->probed)) {
367 up(&this_usbduxsub->sem); 378 up(&this_usbduxsub->sem);
368 return -ENODEV; 379 return -ENODEV;
369 } 380 }
370 // unlink only if the urb really has been submitted 381 /* unlink only if the urb really has been submitted */
371 res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); 382 res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running);
372 up(&this_usbduxsub->sem); 383 up(&this_usbduxsub->sem);
373 return res; 384 return res;
374} 385}
375 386
376// analogue IN 387/* analogue IN - interrupt service routine */
377// interrupt service routine
378static void usbduxsub_ai_IsocIrq(struct urb *urb) 388static void usbduxsub_ai_IsocIrq(struct urb *urb)
379{ 389{
380 int i, err, n; 390 int i, err, n;
@@ -382,38 +392,38 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
382 comedi_device *this_comedidev; 392 comedi_device *this_comedidev;
383 comedi_subdevice *s; 393 comedi_subdevice *s;
384 394
385 // sanity checks 395 /* sanity checks */
386 // is the urb there? 396 /* is the urb there? */
387 if (!urb) { 397 if (!urb) {
388 printk("comedi_: usbdux_: ao int-handler called with urb=NULL!\n"); 398 printk("comedi_: usbdux_: ao int-handler called with urb=NULL!\n");
389 return; 399 return;
390 } 400 }
391 // the context variable points to the subdevice 401 /* the context variable points to the subdevice */
392 this_comedidev = urb->context; 402 this_comedidev = urb->context;
393 if (unlikely(!this_comedidev)) { 403 if (unlikely(!this_comedidev)) {
394 printk("comedi_: usbdux_: BUG! urb context is a NULL pointer!\n"); 404 printk("comedi_: usbdux_: BUG! urb context is a NULL pointer!\n");
395 return; 405 return;
396 } 406 }
397 // the private structure of the subdevice is usbduxsub_t 407 /* the private structure of the subdevice is usbduxsub_t */
398 this_usbduxsub = this_comedidev->private; 408 this_usbduxsub = this_comedidev->private;
399 if (unlikely(!this_usbduxsub)) { 409 if (unlikely(!this_usbduxsub)) {
400 printk("comedi_: usbdux_: BUG! private of comedi subdev is a NULL pointer!\n"); 410 printk("comedi_: usbdux_: BUG! private of comedi subdev is a NULL pointer!\n");
401 return; 411 return;
402 } 412 }
403 // subdevice which is the AD converter 413 /* subdevice which is the AD converter */
404 s = this_comedidev->subdevices + SUBDEV_AD; 414 s = this_comedidev->subdevices + SUBDEV_AD;
405 415
406 // first we test if something unusual has just happened 416 /* first we test if something unusual has just happened */
407 switch (urb->status) { 417 switch (urb->status) {
408 case 0: 418 case 0:
409 // copy the result in the transfer buffer 419 /* copy the result in the transfer buffer */
410 memcpy(this_usbduxsub->inBuffer, 420 memcpy(this_usbduxsub->inBuffer,
411 urb->transfer_buffer, SIZEINBUF); 421 urb->transfer_buffer, SIZEINBUF);
412 break; 422 break;
413 case -EILSEQ: 423 case -EILSEQ:
414 // error in the ISOchronous data 424 /* error in the ISOchronous data */
415 // we don't copy the data into the transfer buffer 425 /* we don't copy the data into the transfer buffer */
416 // and recycle the last data byte 426 /* and recycle the last data byte */
417#ifdef CONFIG_COMEDI_DEBUG 427#ifdef CONFIG_COMEDI_DEBUG
418 printk("comedi%d: usbdux: CRC error in ISO IN stream.\n", 428 printk("comedi%d: usbdux: CRC error in ISO IN stream.\n",
419 this_usbduxsub->comedidev->minor); 429 this_usbduxsub->comedidev->minor);
@@ -421,42 +431,43 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
421 431
422 break; 432 break;
423 433
424 // happens after an unlink command
425 case -ECONNRESET: 434 case -ECONNRESET:
426 case -ENOENT: 435 case -ENOENT:
427 case -ESHUTDOWN: 436 case -ESHUTDOWN:
428 case -ECONNABORTED: 437 case -ECONNABORTED:
438 /* happens after an unlink command */
429 if (this_usbduxsub->ai_cmd_running) { 439 if (this_usbduxsub->ai_cmd_running) {
430 // we are still running a command 440 /* we are still running a command */
431 // tell this comedi 441 /* tell this comedi */
432 s->async->events |= COMEDI_CB_EOA; 442 s->async->events |= COMEDI_CB_EOA;
433 s->async->events |= COMEDI_CB_ERROR; 443 s->async->events |= COMEDI_CB_ERROR;
434 comedi_event(this_usbduxsub->comedidev, s); 444 comedi_event(this_usbduxsub->comedidev, s);
435 // stop the transfer w/o unlink 445 /* stop the transfer w/o unlink */
436 usbdux_ai_stop(this_usbduxsub, 0); 446 usbdux_ai_stop(this_usbduxsub, 0);
437 } 447 }
438 return; 448 return;
439 449
440 // a real error on the bus
441 default: 450 default:
442 // pass error to comedi if we are really running a command 451 /* a real error on the bus */
452 /* pass error to comedi if we are really running a command */
443 if (this_usbduxsub->ai_cmd_running) { 453 if (this_usbduxsub->ai_cmd_running) {
444 printk("Non-zero urb status received in ai intr context: %d\n", urb->status); 454 printk("Non-zero urb status received in ai intr context: %d\n", urb->status);
445 s->async->events |= COMEDI_CB_EOA; 455 s->async->events |= COMEDI_CB_EOA;
446 s->async->events |= COMEDI_CB_ERROR; 456 s->async->events |= COMEDI_CB_ERROR;
447 comedi_event(this_usbduxsub->comedidev, s); 457 comedi_event(this_usbduxsub->comedidev, s);
448 // don't do an unlink here 458 /* don't do an unlink here */
449 usbdux_ai_stop(this_usbduxsub, 0); 459 usbdux_ai_stop(this_usbduxsub, 0);
450 } 460 }
451 return; 461 return;
452 } 462 }
453 463
454 // at this point we are reasonably sure that nothing dodgy has happened 464 /* at this point we are reasonably sure that nothing dodgy has happened */
455 // are we running a command? 465 /* are we running a command? */
456 if (unlikely((!(this_usbduxsub->ai_cmd_running)))) { 466 if (unlikely((!(this_usbduxsub->ai_cmd_running)))) {
457 // not running a command 467 /*
458 // do not continue execution if no asynchronous command is running 468 * not running a command, do not continue execution if no
459 // in particular not resubmit 469 * asynchronous command is running in particular not resubmit
470 */
460 return; 471 return;
461 } 472 }
462 473
@@ -482,28 +493,27 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
482 if (likely(this_usbduxsub->ai_counter > 0)) 493 if (likely(this_usbduxsub->ai_counter > 0))
483 return; 494 return;
484 495
485 // timer zero, transfer measurements to comedi 496 /* timer zero, transfer measurements to comedi */
486 this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; 497 this_usbduxsub->ai_counter = this_usbduxsub->ai_timer;
487 498
488 // test, if we transmit only a fixed number of samples 499 /* test, if we transmit only a fixed number of samples */
489 if (!(this_usbduxsub->ai_continous)) { 500 if (!(this_usbduxsub->ai_continous)) {
490 // not continous, fixed number of samples 501 /* not continous, fixed number of samples */
491 this_usbduxsub->ai_sample_count--; 502 this_usbduxsub->ai_sample_count--;
492 // all samples received? 503 /* all samples received? */
493 if (this_usbduxsub->ai_sample_count < 0) { 504 if (this_usbduxsub->ai_sample_count < 0) {
494 // prevent a resubmit next time 505 /* prevent a resubmit next time */
495 usbdux_ai_stop(this_usbduxsub, 0); 506 usbdux_ai_stop(this_usbduxsub, 0);
496 // say comedi that the acquistion is over 507 /* say comedi that the acquistion is over */
497 s->async->events |= COMEDI_CB_EOA; 508 s->async->events |= COMEDI_CB_EOA;
498 comedi_event(this_usbduxsub->comedidev, s); 509 comedi_event(this_usbduxsub->comedidev, s);
499 return; 510 return;
500 } 511 }
501 } 512 }
502 // get the data from the USB bus and hand it over 513 /* get the data from the USB bus and hand it over to comedi */
503 // to comedi
504 n = s->async->cmd.chanlist_len; 514 n = s->async->cmd.chanlist_len;
505 for (i = 0; i < n; i++) { 515 for (i = 0; i < n; i++) {
506 // transfer data 516 /* transfer data */
507 if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { 517 if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) {
508 comedi_buf_put 518 comedi_buf_put
509 (s->async, 519 (s->async,
@@ -515,7 +525,7 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
515 le16_to_cpu(this_usbduxsub->inBuffer[i])); 525 le16_to_cpu(this_usbduxsub->inBuffer[i]));
516 } 526 }
517 } 527 }
518 // tell comedi that data is there 528 /* tell comedi that data is there */
519 comedi_event(this_usbduxsub->comedidev, s); 529 comedi_event(this_usbduxsub->comedidev, s);
520} 530}
521 531
@@ -572,13 +582,13 @@ static int usbdux_ao_cancel(comedi_device *dev, comedi_subdevice *s)
572 printk("comedi: usbdux_ao_cancel: this_usbduxsub=NULL\n"); 582 printk("comedi: usbdux_ao_cancel: this_usbduxsub=NULL\n");
573 return -EFAULT; 583 return -EFAULT;
574 } 584 }
575 // prevent other CPUs from submitting a command just now 585 /* prevent other CPUs from submitting a command just now */
576 down(&this_usbduxsub->sem); 586 down(&this_usbduxsub->sem);
577 if (!(this_usbduxsub->probed)) { 587 if (!(this_usbduxsub->probed)) {
578 up(&this_usbduxsub->sem); 588 up(&this_usbduxsub->sem);
579 return -ENODEV; 589 return -ENODEV;
580 } 590 }
581 // unlink only if it is really running 591 /* unlink only if it is really running */
582 res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running); 592 res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running);
583 up(&this_usbduxsub->sem); 593 up(&this_usbduxsub->sem);
584 return res; 594 return res;
@@ -596,13 +606,13 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
596 printk("comedi_: usbdux_: ao urb handler called with NULL ptr.\n"); 606 printk("comedi_: usbdux_: ao urb handler called with NULL ptr.\n");
597 return; 607 return;
598 } 608 }
599 // the context variable points to the subdevice 609 /* the context variable points to the subdevice */
600 this_comedidev = urb->context; 610 this_comedidev = urb->context;
601 if (!this_comedidev) { 611 if (!this_comedidev) {
602 printk("comedi_: usbdux_: ao urb int-context is a NULL pointer.\n"); 612 printk("comedi_: usbdux_: ao urb int-context is a NULL pointer.\n");
603 return; 613 return;
604 } 614 }
605 // the private structure of the subdevice is usbduxsub_t 615 /* the private structure of the subdevice is usbduxsub_t */
606 this_usbduxsub = this_comedidev->private; 616 this_usbduxsub = this_comedidev->private;
607 if (!this_usbduxsub) { 617 if (!this_usbduxsub) {
608 printk("comedi_: usbdux_: private data structure of ao subdev is NULL p.\n"); 618 printk("comedi_: usbdux_: private data structure of ao subdev is NULL p.\n");
@@ -620,8 +630,8 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
620 case -ENOENT: 630 case -ENOENT:
621 case -ESHUTDOWN: 631 case -ESHUTDOWN:
622 case -ECONNABORTED: 632 case -ECONNABORTED:
623 // after an unlink command, unplug, ... etc 633 /* after an unlink command, unplug, ... etc */
624 // no unlink needed here. Already shutting down. 634 /* no unlink needed here. Already shutting down. */
625 if (this_usbduxsub->ao_cmd_running) { 635 if (this_usbduxsub->ao_cmd_running) {
626 s->async->events |= COMEDI_CB_EOA; 636 s->async->events |= COMEDI_CB_EOA;
627 comedi_event(this_usbduxsub->comedidev, s); 637 comedi_event(this_usbduxsub->comedidev, s);
@@ -630,42 +640,42 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
630 return; 640 return;
631 641
632 default: 642 default:
633 // a real error 643 /* a real error */
634 if (this_usbduxsub->ao_cmd_running) { 644 if (this_usbduxsub->ao_cmd_running) {
635 printk("comedi_: usbdux_: Non-zero urb status received in ao intr context: %d\n", urb->status); 645 printk("comedi_: usbdux_: Non-zero urb status received in ao intr context: %d\n", urb->status);
636 s->async->events |= COMEDI_CB_ERROR; 646 s->async->events |= COMEDI_CB_ERROR;
637 s->async->events |= COMEDI_CB_EOA; 647 s->async->events |= COMEDI_CB_EOA;
638 comedi_event(this_usbduxsub->comedidev, s); 648 comedi_event(this_usbduxsub->comedidev, s);
639 // we do an unlink if we are in the high speed mode 649 /* we do an unlink if we are in the high speed mode */
640 usbdux_ao_stop(this_usbduxsub, 0); 650 usbdux_ao_stop(this_usbduxsub, 0);
641 } 651 }
642 return; 652 return;
643 } 653 }
644 654
645 // are we actually running? 655 /* are we actually running? */
646 if (!(this_usbduxsub->ao_cmd_running)) 656 if (!(this_usbduxsub->ao_cmd_running))
647 return; 657 return;
648 658
649 // normal operation: executing a command in this subdevice 659 /* normal operation: executing a command in this subdevice */
650 this_usbduxsub->ao_counter--; 660 this_usbduxsub->ao_counter--;
651 if (this_usbduxsub->ao_counter <= 0) { 661 if (this_usbduxsub->ao_counter <= 0) {
652 // timer zero 662 /* timer zero */
653 this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; 663 this_usbduxsub->ao_counter = this_usbduxsub->ao_timer;
654 664
655 // handle non continous aquisition 665 /* handle non continous aquisition */
656 if (!(this_usbduxsub->ao_continous)) { 666 if (!(this_usbduxsub->ao_continous)) {
657 // fixed number of samples 667 /* fixed number of samples */
658 this_usbduxsub->ao_sample_count--; 668 this_usbduxsub->ao_sample_count--;
659 if (this_usbduxsub->ao_sample_count < 0) { 669 if (this_usbduxsub->ao_sample_count < 0) {
660 // all samples transmitted 670 /* all samples transmitted */
661 usbdux_ao_stop(this_usbduxsub, 0); 671 usbdux_ao_stop(this_usbduxsub, 0);
662 s->async->events |= COMEDI_CB_EOA; 672 s->async->events |= COMEDI_CB_EOA;
663 comedi_event(this_usbduxsub->comedidev, s); 673 comedi_event(this_usbduxsub->comedidev, s);
664 // no resubmit of the urb 674 /* no resubmit of the urb */
665 return; 675 return;
666 } 676 }
667 } 677 }
668 // transmit data to the USB bus 678 /* transmit data to the USB bus */
669 ((uint8_t *) (urb->transfer_buffer))[0] = 679 ((uint8_t *) (urb->transfer_buffer))[0] =
670 s->async->cmd.chanlist_len; 680 s->async->cmd.chanlist_len;
671 for (i = 0; i < s->async->cmd.chanlist_len; i++) { 681 for (i = 0; i < s->async->cmd.chanlist_len; i++) {
@@ -673,21 +683,21 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
673 if (i >= NUMOUTCHANNELS) 683 if (i >= NUMOUTCHANNELS)
674 break; 684 break;
675 685
676 // pointer to the DA 686 /* pointer to the DA */
677 datap = (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1])); 687 datap = (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1]));
678 // get the data from comedi 688 /* get the data from comedi */
679 ret = comedi_buf_get(s->async, &temp); 689 ret = comedi_buf_get(s->async, &temp);
680 datap[0] = temp; 690 datap[0] = temp;
681 datap[1] = temp >> 8; 691 datap[1] = temp >> 8;
682 datap[2] = this_usbduxsub->dac_commands[i]; 692 datap[2] = this_usbduxsub->dac_commands[i];
683 // printk("data[0]=%x, data[1]=%x, data[2]=%x\n", 693 /* printk("data[0]=%x, data[1]=%x, data[2]=%x\n", */
684 // datap[0],datap[1],datap[2]); 694 /* datap[0],datap[1],datap[2]); */
685 if (ret < 0) { 695 if (ret < 0) {
686 printk("comedi: usbdux: buffer underflow\n"); 696 printk("comedi: usbdux: buffer underflow\n");
687 s->async->events |= COMEDI_CB_EOA; 697 s->async->events |= COMEDI_CB_EOA;
688 s->async->events |= COMEDI_CB_OVERFLOW; 698 s->async->events |= COMEDI_CB_OVERFLOW;
689 } 699 }
690 // transmit data to comedi 700 /* transmit data to comedi */
691 s->async->events |= COMEDI_CB_BLOCK; 701 s->async->events |= COMEDI_CB_BLOCK;
692 comedi_event(this_usbduxsub->comedidev, s); 702 comedi_event(this_usbduxsub->comedidev, s);
693 } 703 }
@@ -697,10 +707,10 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
697 urb->status = 0; 707 urb->status = 0;
698 if (this_usbduxsub->ao_cmd_running) { 708 if (this_usbduxsub->ao_cmd_running) {
699 if (this_usbduxsub->high_speed) { 709 if (this_usbduxsub->high_speed) {
700 // uframes 710 /* uframes */
701 urb->interval = 8; 711 urb->interval = 8;
702 } else { 712 } else {
703 // frames 713 /* frames */
704 urb->interval = 1; 714 urb->interval = 1;
705 } 715 }
706 urb->number_of_packets = 1; 716 urb->number_of_packets = 1;
@@ -718,7 +728,7 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
718 s->async->events |= COMEDI_CB_EOA; 728 s->async->events |= COMEDI_CB_EOA;
719 s->async->events |= COMEDI_CB_ERROR; 729 s->async->events |= COMEDI_CB_ERROR;
720 comedi_event(this_usbduxsub->comedidev, s); 730 comedi_event(this_usbduxsub->comedidev, s);
721 // don't do an unlink here 731 /* don't do an unlink here */
722 usbdux_ao_stop(this_usbduxsub, 0); 732 usbdux_ao_stop(this_usbduxsub, 0);
723 } 733 }
724 } 734 }
@@ -730,24 +740,24 @@ static int usbduxsub_start(usbduxsub_t *usbduxsub)
730 uint8_t local_transfer_buffer[16]; 740 uint8_t local_transfer_buffer[16];
731 741
732 if (usbduxsub->probed) { 742 if (usbduxsub->probed) {
733 // 7f92 to zero 743 /* 7f92 to zero */
734 local_transfer_buffer[0] = 0; 744 local_transfer_buffer[0] = 0;
735 errcode = USB_CONTROL_MSG(usbduxsub->usbdev, 745 errcode = USB_CONTROL_MSG(usbduxsub->usbdev,
736 // create a pipe for a control transfer 746 /* create a pipe for a control transfer */
737 usb_sndctrlpipe(usbduxsub->usbdev, 0), 747 usb_sndctrlpipe(usbduxsub->usbdev, 0),
738 // bRequest, "Firmware" 748 /* bRequest, "Firmware" */
739 USBDUXSUB_FIRMWARE, 749 USBDUXSUB_FIRMWARE,
740 // bmRequestType 750 /* bmRequestType */
741 VENDOR_DIR_OUT, 751 VENDOR_DIR_OUT,
742 // Value 752 /* Value */
743 USBDUXSUB_CPUCS, 753 USBDUXSUB_CPUCS,
744 // Index 754 /* Index */
745 0x0000, 755 0x0000,
746 // address of the transfer buffer 756 /* address of the transfer buffer */
747 local_transfer_buffer, 757 local_transfer_buffer,
748 // Length 758 /* Length */
749 1, 759 1,
750 // Timeout 760 /* Timeout */
751 EZTIMEOUT); 761 EZTIMEOUT);
752 if (errcode < 0) { 762 if (errcode < 0) {
753 printk("comedi_: usbdux_: control msg failed (start)\n"); 763 printk("comedi_: usbdux_: control msg failed (start)\n");
@@ -763,22 +773,22 @@ static int usbduxsub_stop(usbduxsub_t *usbduxsub)
763 773
764 uint8_t local_transfer_buffer[16]; 774 uint8_t local_transfer_buffer[16];
765 if (usbduxsub->probed) { 775 if (usbduxsub->probed) {
766 // 7f92 to one 776 /* 7f92 to one */
767 local_transfer_buffer[0] = 1; 777 local_transfer_buffer[0] = 1;
768 errcode = USB_CONTROL_MSG 778 errcode = USB_CONTROL_MSG
769 (usbduxsub->usbdev, 779 (usbduxsub->usbdev,
770 usb_sndctrlpipe(usbduxsub->usbdev, 0), 780 usb_sndctrlpipe(usbduxsub->usbdev, 0),
771 // bRequest, "Firmware" 781 /* bRequest, "Firmware" */
772 USBDUXSUB_FIRMWARE, 782 USBDUXSUB_FIRMWARE,
773 // bmRequestType 783 /* bmRequestType */
774 VENDOR_DIR_OUT, 784 VENDOR_DIR_OUT,
775 // Value 785 /* Value */
776 USBDUXSUB_CPUCS, 786 USBDUXSUB_CPUCS,
777 // Index 787 /* Index */
778 0x0000, local_transfer_buffer, 788 0x0000, local_transfer_buffer,
779 // Length 789 /* Length */
780 1, 790 1,
781 // Timeout 791 /* Timeout */
782 EZTIMEOUT); 792 EZTIMEOUT);
783 if (errcode < 0) { 793 if (errcode < 0) {
784 printk("comedi_: usbdux: control msg failed (stop)\n"); 794 printk("comedi_: usbdux: control msg failed (stop)\n");
@@ -804,19 +814,19 @@ static int usbduxsub_upload(usbduxsub_t *usbduxsub,
804 errcode = USB_CONTROL_MSG 814 errcode = USB_CONTROL_MSG
805 (usbduxsub->usbdev, 815 (usbduxsub->usbdev,
806 usb_sndctrlpipe(usbduxsub->usbdev, 0), 816 usb_sndctrlpipe(usbduxsub->usbdev, 0),
807 // brequest, firmware 817 /* brequest, firmware */
808 USBDUXSUB_FIRMWARE, 818 USBDUXSUB_FIRMWARE,
809 // bmRequestType 819 /* bmRequestType */
810 VENDOR_DIR_OUT, 820 VENDOR_DIR_OUT,
811 // value 821 /* value */
812 startAddr, 822 startAddr,
813 // index 823 /* index */
814 0x0000, 824 0x0000,
815 // our local safe buffer 825 /* our local safe buffer */
816 local_transfer_buffer, 826 local_transfer_buffer,
817 // length 827 /* length */
818 len, 828 len,
819 // timeout 829 /* timeout */
820 EZTIMEOUT); 830 EZTIMEOUT);
821#ifdef NOISY_DUX_DEBUGBUG 831#ifdef NOISY_DUX_DEBUGBUG
822 printk("comedi_: usbdux: result=%d\n", errcode); 832 printk("comedi_: usbdux: result=%d\n", errcode);
@@ -826,7 +836,7 @@ static int usbduxsub_upload(usbduxsub_t *usbduxsub,
826 return errcode; 836 return errcode;
827 } 837 }
828 } else { 838 } else {
829 // no device on the bus for this index 839 /* no device on the bus for this index */
830 return -EFAULT; 840 return -EFAULT;
831 } 841 }
832 return 0; 842 return 0;
@@ -898,7 +908,7 @@ static int usbduxsub_submit_OutURBs(usbduxsub_t *usbduxsub)
898#ifdef NOISY_DUX_DEBUGBUG 908#ifdef NOISY_DUX_DEBUGBUG
899 printk("comedi_: usbdux: submitting out-urb[%d]\n", i); 909 printk("comedi_: usbdux: submitting out-urb[%d]\n", i);
900#endif 910#endif
901 // in case of a resubmission after an unlink... 911 /* in case of a resubmission after an unlink... */
902 usbduxsub->urbOut[i]->context = usbduxsub->comedidev; 912 usbduxsub->urbOut[i]->context = usbduxsub->comedidev;
903 usbduxsub->urbOut[i]->dev = usbduxsub->usbdev; 913 usbduxsub->urbOut[i]->dev = usbduxsub->usbdev;
904 usbduxsub->urbOut[i]->status = 0; 914 usbduxsub->urbOut[i]->status = 0;
@@ -927,32 +937,32 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
927 printk("comedi%d: usbdux_ai_cmdtest\n", dev->minor); 937 printk("comedi%d: usbdux_ai_cmdtest\n", dev->minor);
928#endif 938#endif
929 /* make sure triggers are valid */ 939 /* make sure triggers are valid */
930 // Only immediate triggers are allowed 940 /* Only immediate triggers are allowed */
931 tmp = cmd->start_src; 941 tmp = cmd->start_src;
932 cmd->start_src &= TRIG_NOW | TRIG_INT; 942 cmd->start_src &= TRIG_NOW | TRIG_INT;
933 if (!cmd->start_src || tmp != cmd->start_src) 943 if (!cmd->start_src || tmp != cmd->start_src)
934 err++; 944 err++;
935 945
936 // trigger should happen timed 946 /* trigger should happen timed */
937 tmp = cmd->scan_begin_src; 947 tmp = cmd->scan_begin_src;
938 // start a new _scan_ with a timer 948 /* start a new _scan_ with a timer */
939 cmd->scan_begin_src &= TRIG_TIMER; 949 cmd->scan_begin_src &= TRIG_TIMER;
940 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) 950 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
941 err++; 951 err++;
942 952
943 // scanning is continous 953 /* scanning is continous */
944 tmp = cmd->convert_src; 954 tmp = cmd->convert_src;
945 cmd->convert_src &= TRIG_NOW; 955 cmd->convert_src &= TRIG_NOW;
946 if (!cmd->convert_src || tmp != cmd->convert_src) 956 if (!cmd->convert_src || tmp != cmd->convert_src)
947 err++; 957 err++;
948 958
949 // issue a trigger when scan is finished and start a new scan 959 /* issue a trigger when scan is finished and start a new scan */
950 tmp = cmd->scan_end_src; 960 tmp = cmd->scan_end_src;
951 cmd->scan_end_src &= TRIG_COUNT; 961 cmd->scan_end_src &= TRIG_COUNT;
952 if (!cmd->scan_end_src || tmp != cmd->scan_end_src) 962 if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
953 err++; 963 err++;
954 964
955 // trigger at the end of count events or not, stop condition or not 965 /* trigger at the end of count events or not, stop condition or not */
956 tmp = cmd->stop_src; 966 tmp = cmd->stop_src;
957 cmd->stop_src &= TRIG_COUNT | TRIG_NONE; 967 cmd->stop_src &= TRIG_COUNT | TRIG_NONE;
958 if (!cmd->stop_src || tmp != cmd->stop_src) 968 if (!cmd->stop_src || tmp != cmd->stop_src)
@@ -990,12 +1000,14 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
990 1000
991 if (cmd->scan_begin_src == TRIG_TIMER) { 1001 if (cmd->scan_begin_src == TRIG_TIMER) {
992 if (this_usbduxsub->high_speed) { 1002 if (this_usbduxsub->high_speed) {
993 // In high speed mode microframes are possible. 1003 /*
994 // However, during one microframe we can roughly 1004 * In high speed mode microframes are possible.
995 // sample one channel. Thus, the more channels 1005 * However, during one microframe we can roughly
996 // are in the channel list the more time we need. 1006 * sample one channel. Thus, the more channels
1007 * are in the channel list the more time we need.
1008 */
997 i = 1; 1009 i = 1;
998 // find a power of 2 for the number of channels 1010 /* find a power of 2 for the number of channels */
999 while (i < (cmd->chanlist_len)) { 1011 while (i < (cmd->chanlist_len)) {
1000 i = i * 2; 1012 i = i * 2;
1001 } 1013 }
@@ -1003,7 +1015,8 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
1003 cmd->scan_begin_arg = 1000000 / 8 * i; 1015 cmd->scan_begin_arg = 1000000 / 8 * i;
1004 err++; 1016 err++;
1005 } 1017 }
1006 // now calc the real sampling rate with all the rounding errors 1018 /* now calc the real sampling rate with all the
1019 * rounding errors */
1007 tmpTimer = 1020 tmpTimer =
1008 ((unsigned int)(cmd->scan_begin_arg / 125000)) * 1021 ((unsigned int)(cmd->scan_begin_arg / 125000)) *
1009 125000; 1022 125000;
@@ -1011,13 +1024,14 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
1011 cmd->scan_begin_arg = tmpTimer; 1024 cmd->scan_begin_arg = tmpTimer;
1012 err++; 1025 err++;
1013 } 1026 }
1014 } else { // full speed 1027 } else {
1015 // 1kHz scans every USB frame 1028 /* full speed */
1029 /* 1kHz scans every USB frame */
1016 if (cmd->scan_begin_arg < 1000000) { 1030 if (cmd->scan_begin_arg < 1000000) {
1017 cmd->scan_begin_arg = 1000000; 1031 cmd->scan_begin_arg = 1000000;
1018 err++; 1032 err++;
1019 } 1033 }
1020 // calc the real sampling rate with the rounding errors 1034 /* calc the real sampling rate with the rounding errors */
1021 tmpTimer = 1035 tmpTimer =
1022 ((unsigned int)(cmd->scan_begin_arg / 1036 ((unsigned int)(cmd->scan_begin_arg /
1023 1000000)) * 1000000; 1037 1000000)) * 1000000;
@@ -1027,7 +1041,7 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
1027 } 1041 }
1028 } 1042 }
1029 } 1043 }
1030 // the same argument 1044 /* the same argument */
1031 if (cmd->scan_end_arg != cmd->chanlist_len) { 1045 if (cmd->scan_end_arg != cmd->chanlist_len) {
1032 cmd->scan_end_arg = cmd->chanlist_len; 1046 cmd->scan_end_arg = cmd->chanlist_len;
1033 err++; 1047 err++;
@@ -1049,8 +1063,10 @@ static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
1049 return 0; 1063 return 0;
1050} 1064}
1051 1065
1052// creates the ADC command for the MAX1271 1066/*
1053// range is the range value from comedi 1067 * creates the ADC command for the MAX1271
1068 * range is the range value from comedi
1069 */
1054static int8_t create_adc_command(unsigned int chan, int range) 1070static int8_t create_adc_command(unsigned int chan, int range)
1055{ 1071{
1056 int8_t p = (range <= 1); 1072 int8_t p = (range <= 1);
@@ -1058,7 +1074,7 @@ static int8_t create_adc_command(unsigned int chan, int range)
1058 return (chan << 4) | ((p == 1) << 2) | ((r == 1) << 3); 1074 return (chan << 4) | ((p == 1) << 2) | ((r == 1) << 3);
1059} 1075}
1060 1076
1061// bulk transfers to usbdux 1077/* bulk transfers to usbdux */
1062 1078
1063#define SENDADCOMMANDS 0 1079#define SENDADCOMMANDS 0
1064#define SENDDACOMMANDS 1 1080#define SENDDACOMMANDS 1
@@ -1112,7 +1128,7 @@ static int receive_dux_commands(usbduxsub_t *this_usbduxsub, int command)
1112 return result; 1128 return result;
1113 } 1129 }
1114 } 1130 }
1115 // this is only reached if the data has been requested a couple of times 1131 /* this is only reached if the data has been requested a couple of times */
1116 printk("comedi%d: insn: wrong data returned from firmware: want cmd %d, got cmd %d.\n", this_usbduxsub->comedidev->minor, command, le16_to_cpu(this_usbduxsub->insnBuffer[0])); 1132 printk("comedi%d: insn: wrong data returned from firmware: want cmd %d, got cmd %d.\n", this_usbduxsub->comedidev->minor, command, le16_to_cpu(this_usbduxsub->insnBuffer[0]));
1117 return -EFAULT; 1133 return -EFAULT;
1118} 1134}
@@ -1235,30 +1251,30 @@ static int usbdux_ai_cmd(comedi_device *dev, comedi_subdevice *s)
1235 this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; 1251 this_usbduxsub->ai_counter = this_usbduxsub->ai_timer;
1236 1252
1237 if (cmd->stop_src == TRIG_COUNT) { 1253 if (cmd->stop_src == TRIG_COUNT) {
1238 // data arrives as one packet 1254 /* data arrives as one packet */
1239 this_usbduxsub->ai_sample_count = cmd->stop_arg; 1255 this_usbduxsub->ai_sample_count = cmd->stop_arg;
1240 this_usbduxsub->ai_continous = 0; 1256 this_usbduxsub->ai_continous = 0;
1241 } else { 1257 } else {
1242 // continous aquisition 1258 /* continous aquisition */
1243 this_usbduxsub->ai_continous = 1; 1259 this_usbduxsub->ai_continous = 1;
1244 this_usbduxsub->ai_sample_count = 0; 1260 this_usbduxsub->ai_sample_count = 0;
1245 } 1261 }
1246 1262
1247 if (cmd->start_src == TRIG_NOW) { 1263 if (cmd->start_src == TRIG_NOW) {
1248 // enable this acquisition operation 1264 /* enable this acquisition operation */
1249 this_usbduxsub->ai_cmd_running = 1; 1265 this_usbduxsub->ai_cmd_running = 1;
1250 ret = usbduxsub_submit_InURBs(this_usbduxsub); 1266 ret = usbduxsub_submit_InURBs(this_usbduxsub);
1251 if (ret < 0) { 1267 if (ret < 0) {
1252 this_usbduxsub->ai_cmd_running = 0; 1268 this_usbduxsub->ai_cmd_running = 0;
1253 // fixme: unlink here?? 1269 /* fixme: unlink here?? */
1254 up(&this_usbduxsub->sem); 1270 up(&this_usbduxsub->sem);
1255 return ret; 1271 return ret;
1256 } 1272 }
1257 s->async->inttrig = NULL; 1273 s->async->inttrig = NULL;
1258 } else { 1274 } else {
1259 /* TRIG_INT */ 1275 /* TRIG_INT */
1260 // don't enable the acquision operation 1276 /* don't enable the acquision operation */
1261 // wait for an internal signal 1277 /* wait for an internal signal */
1262 s->async->inttrig = usbdux_ai_inttrig; 1278 s->async->inttrig = usbdux_ai_inttrig;
1263 } 1279 }
1264 up(&this_usbduxsub->sem); 1280 up(&this_usbduxsub->sem);
@@ -1294,13 +1310,13 @@ static int usbdux_ai_insn_read(comedi_device *dev, comedi_subdevice *s,
1294 return 0; 1310 return 0;
1295 } 1311 }
1296 1312
1297 // sample one channel 1313 /* sample one channel */
1298 chan = CR_CHAN(insn->chanspec); 1314 chan = CR_CHAN(insn->chanspec);
1299 range = CR_RANGE(insn->chanspec); 1315 range = CR_RANGE(insn->chanspec);
1300 // set command for the first channel 1316 /* set command for the first channel */
1301 this_usbduxsub->dux_commands[1] = create_adc_command(chan, range); 1317 this_usbduxsub->dux_commands[1] = create_adc_command(chan, range);
1302 1318
1303 // adc commands 1319 /* adc commands */
1304 if ((err = send_dux_commands(this_usbduxsub, SENDSINGLEAD)) < 0) { 1320 if ((err = send_dux_commands(this_usbduxsub, SENDSINGLEAD)) < 0) {
1305 up(&this_usbduxsub->sem); 1321 up(&this_usbduxsub->sem);
1306 return err; 1322 return err;
@@ -1322,8 +1338,8 @@ static int usbdux_ai_insn_read(comedi_device *dev, comedi_subdevice *s,
1322 return i; 1338 return i;
1323} 1339}
1324 1340
1325////////////////// 1341/************************************/
1326// analog out 1342/* analog out */
1327 1343
1328static int usbdux_ao_insn_read(comedi_device *dev, comedi_subdevice *s, 1344static int usbdux_ao_insn_read(comedi_device *dev, comedi_subdevice *s,
1329 comedi_insn *insn, lsampl_t *data) 1345 comedi_insn *insn, lsampl_t *data)
@@ -1376,13 +1392,13 @@ static int usbdux_ao_insn_write(comedi_device *dev, comedi_subdevice *s,
1376 printk("comedi%d: ao_insn_write: data[chan=%d,i=%d]=%d\n", 1392 printk("comedi%d: ao_insn_write: data[chan=%d,i=%d]=%d\n",
1377 dev->minor, chan, i, data[i]); 1393 dev->minor, chan, i, data[i]);
1378#endif 1394#endif
1379 // number of channels: 1 1395 /* number of channels: 1 */
1380 this_usbduxsub->dux_commands[1] = 1; 1396 this_usbduxsub->dux_commands[1] = 1;
1381 // one 16 bit value 1397 /* one 16 bit value */
1382 *((int16_t *) (this_usbduxsub->dux_commands + 2)) = 1398 *((int16_t *) (this_usbduxsub->dux_commands + 2)) =
1383 cpu_to_le16(data[i]); 1399 cpu_to_le16(data[i]);
1384 this_usbduxsub->outBuffer[chan] = data[i]; 1400 this_usbduxsub->outBuffer[chan] = data[i];
1385 // channel number 1401 /* channel number */
1386 this_usbduxsub->dux_commands[4] = (chan << 6); 1402 this_usbduxsub->dux_commands[4] = (chan << 6);
1387 if ((err = send_dux_commands(this_usbduxsub, 1403 if ((err = send_dux_commands(this_usbduxsub,
1388 SENDDACOMMANDS)) < 0) { 1404 SENDDACOMMANDS)) < 0) {
@@ -1448,47 +1464,47 @@ static int usbdux_ao_cmdtest(comedi_device *dev, comedi_subdevice *s,
1448 printk("comedi%d: usbdux_ao_cmdtest\n", dev->minor); 1464 printk("comedi%d: usbdux_ao_cmdtest\n", dev->minor);
1449#endif 1465#endif
1450 /* make sure triggers are valid */ 1466 /* make sure triggers are valid */
1451 // Only immediate triggers are allowed 1467 /* Only immediate triggers are allowed */
1452 tmp = cmd->start_src; 1468 tmp = cmd->start_src;
1453 cmd->start_src &= TRIG_NOW | TRIG_INT; 1469 cmd->start_src &= TRIG_NOW | TRIG_INT;
1454 if (!cmd->start_src || tmp != cmd->start_src) 1470 if (!cmd->start_src || tmp != cmd->start_src)
1455 err++; 1471 err++;
1456 1472
1457 // trigger should happen timed 1473 /* trigger should happen timed */
1458 tmp = cmd->scan_begin_src; 1474 tmp = cmd->scan_begin_src;
1459 // just now we scan also in the high speed mode every frame 1475 /* just now we scan also in the high speed mode every frame */
1460 // this is due to ehci driver limitations 1476 /* this is due to ehci driver limitations */
1461 if (0) { /* (this_usbduxsub->high_speed) */ 1477 if (0) { /* (this_usbduxsub->high_speed) */
1462 // start immidiately a new scan 1478 /* start immidiately a new scan */
1463 // the sampling rate is set by the coversion rate 1479 /* the sampling rate is set by the coversion rate */
1464 cmd->scan_begin_src &= TRIG_FOLLOW; 1480 cmd->scan_begin_src &= TRIG_FOLLOW;
1465 } else { 1481 } else {
1466 // start a new scan (output at once) with a timer 1482 /* start a new scan (output at once) with a timer */
1467 cmd->scan_begin_src &= TRIG_TIMER; 1483 cmd->scan_begin_src &= TRIG_TIMER;
1468 } 1484 }
1469 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) 1485 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
1470 err++; 1486 err++;
1471 1487
1472 // scanning is continous 1488 /* scanning is continous */
1473 tmp = cmd->convert_src; 1489 tmp = cmd->convert_src;
1474 // we always output at 1kHz just now all channels at once 1490 /* we always output at 1kHz just now all channels at once */
1475 if (0) { /* (this_usbduxsub->high_speed) */ 1491 if (0) { /* (this_usbduxsub->high_speed) */
1476 // in usb-2.0 only one conversion it tranmitted but with 8kHz/n 1492 /* in usb-2.0 only one conversion it tranmitted but with 8kHz/n */
1477 cmd->convert_src &= TRIG_TIMER; 1493 cmd->convert_src &= TRIG_TIMER;
1478 } else { 1494 } else {
1479 // all conversion events happen simultaneously with a rate of 1kHz/n 1495 /* all conversion events happen simultaneously with a rate of 1kHz/n */
1480 cmd->convert_src &= TRIG_NOW; 1496 cmd->convert_src &= TRIG_NOW;
1481 } 1497 }
1482 if (!cmd->convert_src || tmp != cmd->convert_src) 1498 if (!cmd->convert_src || tmp != cmd->convert_src)
1483 err++; 1499 err++;
1484 1500
1485 // issue a trigger when scan is finished and start a new scan 1501 /* issue a trigger when scan is finished and start a new scan */
1486 tmp = cmd->scan_end_src; 1502 tmp = cmd->scan_end_src;
1487 cmd->scan_end_src &= TRIG_COUNT; 1503 cmd->scan_end_src &= TRIG_COUNT;
1488 if (!cmd->scan_end_src || tmp != cmd->scan_end_src) 1504 if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
1489 err++; 1505 err++;
1490 1506
1491 // trigger at the end of count events or not, stop condition or not 1507 /* trigger at the end of count events or not, stop condition or not */
1492 tmp = cmd->stop_src; 1508 tmp = cmd->stop_src;
1493 cmd->stop_src &= TRIG_COUNT | TRIG_NONE; 1509 cmd->stop_src &= TRIG_COUNT | TRIG_NONE;
1494 if (!cmd->stop_src || tmp != cmd->stop_src) 1510 if (!cmd->stop_src || tmp != cmd->stop_src)
@@ -1531,7 +1547,7 @@ static int usbdux_ao_cmdtest(comedi_device *dev, comedi_subdevice *s,
1531 err++; 1547 err++;
1532 } 1548 }
1533 } 1549 }
1534 // not used now, is for later use 1550 /* not used now, is for later use */
1535 if (cmd->convert_src == TRIG_TIMER) { 1551 if (cmd->convert_src == TRIG_TIMER) {
1536 if (cmd->convert_arg < 125000) { 1552 if (cmd->convert_arg < 125000) {
1537 cmd->convert_arg = 125000; 1553 cmd->convert_arg = 125000;
@@ -1539,7 +1555,7 @@ static int usbdux_ao_cmdtest(comedi_device *dev, comedi_subdevice *s,
1539 } 1555 }
1540 } 1556 }
1541 1557
1542 // the same argument 1558 /* the same argument */
1543 if (cmd->scan_end_arg != cmd->chanlist_len) { 1559 if (cmd->scan_end_arg != cmd->chanlist_len) {
1544 cmd->scan_end_arg = cmd->chanlist_len; 1560 cmd->scan_end_arg = cmd->chanlist_len;
1545 err++; 1561 err++;
@@ -1584,7 +1600,7 @@ static int usbdux_ao_cmd(comedi_device *dev, comedi_subdevice *s)
1584 printk("comedi%d: usbdux_ao_cmd\n", dev->minor); 1600 printk("comedi%d: usbdux_ao_cmd\n", dev->minor);
1585#endif 1601#endif
1586 1602
1587 // set current channel of the running aquisition to zero 1603 /* set current channel of the running aquisition to zero */
1588 s->async->cur_chan = 0; 1604 s->async->cur_chan = 0;
1589 for (i = 0; i < cmd->chanlist_len; ++i) { 1605 for (i = 0; i < cmd->chanlist_len; ++i) {
1590 chan = CR_CHAN(cmd->chanlist[i]); 1606 chan = CR_CHAN(cmd->chanlist[i]);
@@ -1600,15 +1616,15 @@ static int usbdux_ao_cmd(comedi_device *dev, comedi_subdevice *s)
1600#endif 1616#endif
1601 } 1617 }
1602 1618
1603 // we count in steps of 1ms (125us) 1619 /* we count in steps of 1ms (125us) */
1604 // 125us mode not used yet 1620 /* 125us mode not used yet */
1605 if (0) { /* (this_usbduxsub->high_speed) */ 1621 if (0) { /* (this_usbduxsub->high_speed) */
1606 // 125us 1622 /* 125us */
1607 // timing of the conversion itself: every 125 us 1623 /* timing of the conversion itself: every 125 us */
1608 this_usbduxsub->ao_timer = cmd->convert_arg / 125000; 1624 this_usbduxsub->ao_timer = cmd->convert_arg / 125000;
1609 } else { 1625 } else {
1610 // 1ms 1626 /* 1ms */
1611 // timing of the scan: we get all channels at once 1627 /* timing of the scan: we get all channels at once */
1612 this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000; 1628 this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000;
1613#ifdef NOISY_DUX_DEBUGBUG 1629#ifdef NOISY_DUX_DEBUGBUG
1614 printk("comedi%d: usbdux: scan_begin_src=%d, scan_begin_arg=%d, convert_src=%d, convert_arg=%d\n", dev->minor, cmd->scan_begin_src, cmd->scan_begin_arg, cmd->convert_src, cmd->convert_arg); 1630 printk("comedi%d: usbdux: scan_begin_src=%d, scan_begin_arg=%d, convert_src=%d, convert_arg=%d\n", dev->minor, cmd->scan_begin_src, cmd->scan_begin_arg, cmd->convert_src, cmd->convert_arg);
@@ -1624,40 +1640,40 @@ static int usbdux_ao_cmd(comedi_device *dev, comedi_subdevice *s)
1624 this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; 1640 this_usbduxsub->ao_counter = this_usbduxsub->ao_timer;
1625 1641
1626 if (cmd->stop_src == TRIG_COUNT) { 1642 if (cmd->stop_src == TRIG_COUNT) {
1627 // not continous 1643 /* not continous */
1628 // counter 1644 /* counter */
1629 // high speed also scans everything at once 1645 /* high speed also scans everything at once */
1630 if (0) { /* (this_usbduxsub->high_speed) */ 1646 if (0) { /* (this_usbduxsub->high_speed) */
1631 this_usbduxsub->ao_sample_count = 1647 this_usbduxsub->ao_sample_count =
1632 (cmd->stop_arg) * (cmd->scan_end_arg); 1648 (cmd->stop_arg) * (cmd->scan_end_arg);
1633 } else { 1649 } else {
1634 // there's no scan as the scan has been 1650 /* there's no scan as the scan has been */
1635 // perf inside the FX2 1651 /* perf inside the FX2 */
1636 // data arrives as one packet 1652 /* data arrives as one packet */
1637 this_usbduxsub->ao_sample_count = cmd->stop_arg; 1653 this_usbduxsub->ao_sample_count = cmd->stop_arg;
1638 } 1654 }
1639 this_usbduxsub->ao_continous = 0; 1655 this_usbduxsub->ao_continous = 0;
1640 } else { 1656 } else {
1641 // continous aquisition 1657 /* continous aquisition */
1642 this_usbduxsub->ao_continous = 1; 1658 this_usbduxsub->ao_continous = 1;
1643 this_usbduxsub->ao_sample_count = 0; 1659 this_usbduxsub->ao_sample_count = 0;
1644 } 1660 }
1645 1661
1646 if (cmd->start_src == TRIG_NOW) { 1662 if (cmd->start_src == TRIG_NOW) {
1647 // enable this acquisition operation 1663 /* enable this acquisition operation */
1648 this_usbduxsub->ao_cmd_running = 1; 1664 this_usbduxsub->ao_cmd_running = 1;
1649 ret = usbduxsub_submit_OutURBs(this_usbduxsub); 1665 ret = usbduxsub_submit_OutURBs(this_usbduxsub);
1650 if (ret < 0) { 1666 if (ret < 0) {
1651 this_usbduxsub->ao_cmd_running = 0; 1667 this_usbduxsub->ao_cmd_running = 0;
1652 // fixme: unlink here?? 1668 /* fixme: unlink here?? */
1653 up(&this_usbduxsub->sem); 1669 up(&this_usbduxsub->sem);
1654 return ret; 1670 return ret;
1655 } 1671 }
1656 s->async->inttrig = NULL; 1672 s->async->inttrig = NULL;
1657 } else { 1673 } else {
1658 /* TRIG_INT */ 1674 /* TRIG_INT */
1659 // submit the urbs later 1675 /* submit the urbs later */
1660 // wait for an internal signal 1676 /* wait for an internal signal */
1661 s->async->inttrig = usbdux_ao_inttrig; 1677 s->async->inttrig = usbdux_ao_inttrig;
1662 } 1678 }
1663 1679
@@ -1691,8 +1707,8 @@ static int usbdux_dio_insn_config(comedi_device *dev, comedi_subdevice *s,
1691 return -EINVAL; 1707 return -EINVAL;
1692 break; 1708 break;
1693 } 1709 }
1694 // we don't tell the firmware here as it would take 8 frames 1710 /* we don't tell the firmware here as it would take 8 frames */
1695 // to submit the information. We do it in the insn_bits. 1711 /* to submit the information. We do it in the insn_bits. */
1696 return insn->n; 1712 return insn->n;
1697} 1713}
1698 1714
@@ -1724,8 +1740,8 @@ static int usbdux_dio_insn_bits(comedi_device *dev, comedi_subdevice *s,
1724 this_usbduxsub->dux_commands[1] = s->io_bits; 1740 this_usbduxsub->dux_commands[1] = s->io_bits;
1725 this_usbduxsub->dux_commands[2] = s->state; 1741 this_usbduxsub->dux_commands[2] = s->state;
1726 1742
1727 // This command also tells the firmware to return 1743 /* This command also tells the firmware to return */
1728 // the digital input lines 1744 /* the digital input lines */
1729 if ((err = send_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND)) < 0) { 1745 if ((err = send_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND)) < 0) {
1730 up(&this_usbduxsub->sem); 1746 up(&this_usbduxsub->sem);
1731 return err; 1747 return err;
@@ -1807,12 +1823,12 @@ static int usbdux_counter_write(comedi_device *dev, comedi_subdevice *s,
1807static int usbdux_counter_config(comedi_device *dev, comedi_subdevice *s, 1823static int usbdux_counter_config(comedi_device *dev, comedi_subdevice *s,
1808 comedi_insn *insn, lsampl_t *data) 1824 comedi_insn *insn, lsampl_t *data)
1809{ 1825{
1810 // nothing to do so far 1826 /* nothing to do so far */
1811 return 2; 1827 return 2;
1812} 1828}
1813 1829
1814///////////////////////////// 1830/***********************************/
1815// PWM 1831/* PWM */
1816 1832
1817static int usbduxsub_unlink_PwmURBs(usbduxsub_t *usbduxsub_tmp) 1833static int usbduxsub_unlink_PwmURBs(usbduxsub_t *usbduxsub_tmp)
1818{ 1834{
@@ -1879,19 +1895,19 @@ static void usbduxsub_pwm_irq(struct urb *urb)
1879 comedi_device *this_comedidev; 1895 comedi_device *this_comedidev;
1880 comedi_subdevice *s; 1896 comedi_subdevice *s;
1881 1897
1882 // printk("PWM: IRQ\n"); 1898 /* printk("PWM: IRQ\n"); */
1883 1899
1884 if (!urb) { 1900 if (!urb) {
1885 printk("comedi_: usbdux_: pwm urb handler called with NULL ptr.\n"); 1901 printk("comedi_: usbdux_: pwm urb handler called with NULL ptr.\n");
1886 return; 1902 return;
1887 } 1903 }
1888 // the context variable points to the subdevice 1904 /* the context variable points to the subdevice */
1889 this_comedidev = urb->context; 1905 this_comedidev = urb->context;
1890 if (!this_comedidev) { 1906 if (!this_comedidev) {
1891 printk("comedi_: usbdux_: pwm urb int-context is a NULL pointer.\n"); 1907 printk("comedi_: usbdux_: pwm urb int-context is a NULL pointer.\n");
1892 return; 1908 return;
1893 } 1909 }
1894 // the private structure of the subdevice is usbduxsub_t 1910 /* the private structure of the subdevice is usbduxsub_t */
1895 this_usbduxsub = this_comedidev->private; 1911 this_usbduxsub = this_comedidev->private;
1896 if (!this_usbduxsub) { 1912 if (!this_usbduxsub) {
1897 printk("comedi_: usbdux_: private data structure of pwm subdev is NULL p.\n"); 1913 printk("comedi_: usbdux_: private data structure of pwm subdev is NULL p.\n");
@@ -1959,7 +1975,7 @@ static int usbduxsub_submit_PwmURBs(usbduxsub_t *usbduxsub)
1959#ifdef NOISY_DUX_DEBUGBUG 1975#ifdef NOISY_DUX_DEBUGBUG
1960 printk("comedi_: usbdux: submitting pwm-urb\n"); 1976 printk("comedi_: usbdux: submitting pwm-urb\n");
1961#endif 1977#endif
1962 // in case of a resubmission after an unlink... 1978 /* in case of a resubmission after an unlink... */
1963 1979
1964 usb_fill_bulk_urb(usbduxsub->urbPwm, 1980 usb_fill_bulk_urb(usbduxsub->urbPwm,
1965 usbduxsub->usbdev, 1981 usbduxsub->usbdev,
@@ -2003,7 +2019,7 @@ static int usbdux_pwm_period(comedi_device *dev, comedi_subdevice *s,
2003} 2019}
2004 2020
2005 2021
2006// is called from insn so there's no need to do all the sanity checks 2022/* is called from insn so there's no need to do all the sanity checks */
2007static int usbdux_pwm_start(comedi_device * dev, comedi_subdevice * s) 2023static int usbdux_pwm_start(comedi_device * dev, comedi_subdevice * s)
2008{ 2024{
2009 int ret, i; 2025 int ret, i;
@@ -2013,7 +2029,7 @@ static int usbdux_pwm_start(comedi_device * dev, comedi_subdevice * s)
2013 printk("comedi%d: usbdux_pwm_start\n", dev->minor); 2029 printk("comedi%d: usbdux_pwm_start\n", dev->minor);
2014#endif 2030#endif
2015 if (this_usbduxsub->pwm_cmd_running) { 2031 if (this_usbduxsub->pwm_cmd_running) {
2016 // already running 2032 /* already running */
2017 return 0; 2033 return 0;
2018 } 2034 }
2019 2035
@@ -2021,7 +2037,7 @@ static int usbdux_pwm_start(comedi_device * dev, comedi_subdevice * s)
2021 if ((ret = send_dux_commands(this_usbduxsub, SENDPWMON)) < 0) { 2037 if ((ret = send_dux_commands(this_usbduxsub, SENDPWMON)) < 0) {
2022 return ret; 2038 return ret;
2023 } 2039 }
2024 // initalise the buffer 2040 /* initalise the buffer */
2025 for (i = 0; i < this_usbduxsub->sizePwmBuf; i++) { 2041 for (i = 0; i < this_usbduxsub->sizePwmBuf; i++) {
2026 ((char *)(this_usbduxsub->urbPwm->transfer_buffer))[i] = 0; 2042 ((char *)(this_usbduxsub->urbPwm->transfer_buffer))[i] = 0;
2027 } 2043 }
@@ -2036,7 +2052,7 @@ static int usbdux_pwm_start(comedi_device * dev, comedi_subdevice * s)
2036} 2052}
2037 2053
2038 2054
2039// generates the bit pattern for PWM with the optional sign bit 2055/* generates the bit pattern for PWM with the optional sign bit */
2040static int usbdux_pwm_pattern(comedi_device * dev, comedi_subdevice * s, 2056static int usbdux_pwm_pattern(comedi_device * dev, comedi_subdevice * s,
2041 int channel, lsampl_t value, lsampl_t sign) 2057 int channel, lsampl_t value, lsampl_t sign)
2042{ 2058{
@@ -2048,27 +2064,27 @@ static int usbdux_pwm_pattern(comedi_device * dev, comedi_subdevice * s,
2048 if (!this_usbduxsub) { 2064 if (!this_usbduxsub) {
2049 return -EFAULT; 2065 return -EFAULT;
2050 } 2066 }
2051 // this is the DIO bit which carries the PWM data 2067 /* this is the DIO bit which carries the PWM data */
2052 pwm_mask = (1 << channel); 2068 pwm_mask = (1 << channel);
2053 // this is the DIO bit which carries the optional direction bit 2069 /* this is the DIO bit which carries the optional direction bit */
2054 sgn_mask = (16 << channel); 2070 sgn_mask = (16 << channel);
2055 // this is the buffer which will be filled with the with bit 2071 /* this is the buffer which will be filled with the with bit */
2056 // pattern for one period 2072 /* pattern for one period */
2057 szbuf = this_usbduxsub->sizePwmBuf; 2073 szbuf = this_usbduxsub->sizePwmBuf;
2058 pBuf = (char *)(this_usbduxsub->urbPwm->transfer_buffer); 2074 pBuf = (char *)(this_usbduxsub->urbPwm->transfer_buffer);
2059 for (i = 0; i < szbuf; i++) { 2075 for (i = 0; i < szbuf; i++) {
2060 c = *pBuf; 2076 c = *pBuf;
2061 // reset bits 2077 /* reset bits */
2062 c = c & (~pwm_mask); 2078 c = c & (~pwm_mask);
2063 // set the bit as long as the index is lower than the value 2079 /* set the bit as long as the index is lower than the value */
2064 if (i < value) 2080 if (i < value)
2065 c = c | pwm_mask; 2081 c = c | pwm_mask;
2066 // set the optional sign bit for a relay 2082 /* set the optional sign bit for a relay */
2067 if (!sign) { 2083 if (!sign) {
2068 // positive value 2084 /* positive value */
2069 c = c & (~sgn_mask); 2085 c = c & (~sgn_mask);
2070 } else { 2086 } else {
2071 // negative value 2087 /* negative value */
2072 c = c | sgn_mask; 2088 c = c | sgn_mask;
2073 } 2089 }
2074 *(pBuf++) = c; 2090 *(pBuf++) = c;
@@ -2086,14 +2102,14 @@ static int usbdux_pwm_write(comedi_device * dev, comedi_subdevice * s,
2086 } 2102 }
2087 2103
2088 if ((insn->n)!=1) { 2104 if ((insn->n)!=1) {
2089 // doesn't make sense to have more than one value here 2105 /* doesn't make sense to have more than one value here */
2090 // because it would just overwrite the PWM buffer a couple of times 2106 /* because it would just overwrite the PWM buffer a couple of times */
2091 return -EINVAL; 2107 return -EINVAL;
2092 } 2108 }
2093 2109
2094 // the sign is set via a special INSN only, this gives us 8 bits for 2110 /* the sign is set via a special INSN only, this gives us 8 bits for */
2095 // normal operation 2111 /* normal operation */
2096 // relay sign 0 by default 2112 /* relay sign 0 by default */
2097 return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec), 2113 return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec),
2098 data[0], 0); 2114 data[0], 0);
2099} 2115}
@@ -2290,7 +2306,7 @@ static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
2290 int idx, off; 2306 int idx, off;
2291 int j = 0; 2307 int j = 0;
2292 2308
2293 // get one line 2309 /* get one line */
2294 while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) { 2310 while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) {
2295 buf[j] = fp[i]; 2311 buf[j] = fp[i];
2296 i++; 2312 i++;
@@ -2300,14 +2316,14 @@ static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
2300 return -1; 2316 return -1;
2301 } 2317 }
2302 } 2318 }
2303 // get rid of LF/CR/... 2319 /* get rid of LF/CR/... */
2304 while ((i < size) && ((fp[i] == 13) || (fp[i] == 10) 2320 while ((i < size) && ((fp[i] == 13) || (fp[i] == 10)
2305 || (fp[i] == 0))) { 2321 || (fp[i] == 0))) {
2306 i++; 2322 i++;
2307 } 2323 }
2308 2324
2309 buf[j] = 0; 2325 buf[j] = 0;
2310 //printk("comedi_: buf=%s\n",buf); 2326 /*printk("comedi_: buf=%s\n",buf); */
2311 2327
2312 /* EXTENSION: "# comment-till-end-of-line", for copyrights etc */ 2328 /* EXTENSION: "# comment-till-end-of-line", for copyrights etc */
2313 if (buf[0] == '#') 2329 if (buf[0] == '#')
@@ -2332,7 +2348,7 @@ static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
2332 printk("comedi_: usbdux: firmware upload goes beyond FX2 RAM boundaries."); 2348 printk("comedi_: usbdux: firmware upload goes beyond FX2 RAM boundaries.");
2333 return -EFAULT; 2349 return -EFAULT;
2334 } 2350 }
2335 //printk("comedi_: usbdux: off=%x, len=%x:",off,len); 2351 /*printk("comedi_: usbdux: off=%x, len=%x:",off,len); */
2336 2352
2337 /* Read the record type */ 2353 /* Read the record type */
2338 type = hex2unsigned(buf + 7); 2354 type = hex2unsigned(buf + 7);
@@ -2350,9 +2366,9 @@ static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
2350 2366
2351 for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) { 2367 for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) {
2352 firmwareBinary[idx + off] = hex2unsigned(cp); 2368 firmwareBinary[idx + off] = hex2unsigned(cp);
2353 //printk("%02x ",firmwareBinary[idx+off]); 2369 /*printk("%02x ",firmwareBinary[idx+off]); */
2354 } 2370 }
2355 //printk("\n"); 2371 /*printk("\n"); */
2356 2372
2357 if (i >= size) { 2373 if (i >= size) {
2358 printk("comedi_: usbdux: unexpected end of hex file\n"); 2374 printk("comedi_: usbdux: unexpected end of hex file\n");
@@ -2365,7 +2381,7 @@ static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
2365 return res; 2381 return res;
2366} 2382}
2367 2383
2368// allocate memory for the urbs and initialise them 2384/* allocate memory for the urbs and initialise them */
2369static int usbduxsub_probe(struct usb_interface *uinterf, 2385static int usbduxsub_probe(struct usb_interface *uinterf,
2370 const struct usb_device_id *id) 2386 const struct usb_device_id *id)
2371{ 2387{
@@ -2377,7 +2393,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2377 printk("comedi_: usbdux_: finding a free structure for the usb-device\n"); 2393 printk("comedi_: usbdux_: finding a free structure for the usb-device\n");
2378#endif 2394#endif
2379 down(&start_stop_sem); 2395 down(&start_stop_sem);
2380 // look for a free place in the usbdux array 2396 /* look for a free place in the usbdux array */
2381 index = -1; 2397 index = -1;
2382 for (i = 0; i < NUMUSBDUX; i++) { 2398 for (i = 0; i < NUMUSBDUX; i++) {
2383 if (!(usbduxsub[i].probed)) { 2399 if (!(usbduxsub[i].probed)) {
@@ -2386,7 +2402,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2386 } 2402 }
2387 } 2403 }
2388 2404
2389 // no more space 2405 /* no more space */
2390 if (index == -1) { 2406 if (index == -1) {
2391 printk("Too many usbdux-devices connected.\n"); 2407 printk("Too many usbdux-devices connected.\n");
2392 up(&start_stop_sem); 2408 up(&start_stop_sem);
@@ -2397,25 +2413,25 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2397#endif 2413#endif
2398 2414
2399 init_MUTEX(&(usbduxsub[index].sem)); 2415 init_MUTEX(&(usbduxsub[index].sem));
2400 // save a pointer to the usb device 2416 /* save a pointer to the usb device */
2401 usbduxsub[index].usbdev = udev; 2417 usbduxsub[index].usbdev = udev;
2402 2418
2403 // 2.6: save the interface itself 2419 /* 2.6: save the interface itself */
2404 usbduxsub[index].interface = uinterf; 2420 usbduxsub[index].interface = uinterf;
2405 // get the interface number from the interface 2421 /* get the interface number from the interface */
2406 usbduxsub[index].ifnum = uinterf->altsetting->desc.bInterfaceNumber; 2422 usbduxsub[index].ifnum = uinterf->altsetting->desc.bInterfaceNumber;
2407 // hand the private data over to the usb subsystem 2423 /* hand the private data over to the usb subsystem */
2408 // will be needed for disconnect 2424 /* will be needed for disconnect */
2409 usb_set_intfdata(uinterf, &(usbduxsub[index])); 2425 usb_set_intfdata(uinterf, &(usbduxsub[index]));
2410 2426
2411#ifdef CONFIG_COMEDI_DEBUG 2427#ifdef CONFIG_COMEDI_DEBUG
2412 printk("comedi_: usbdux: ifnum=%d\n", usbduxsub[index].ifnum); 2428 printk("comedi_: usbdux: ifnum=%d\n", usbduxsub[index].ifnum);
2413#endif 2429#endif
2414 // test if it is high speed (USB 2.0) 2430 /* test if it is high speed (USB 2.0) */
2415 usbduxsub[index].high_speed = 2431 usbduxsub[index].high_speed =
2416 (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH); 2432 (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH);
2417 2433
2418 // create space for the commands of the DA converter 2434 /* create space for the commands of the DA converter */
2419 usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); 2435 usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL);
2420 if (!usbduxsub[index].dac_commands) { 2436 if (!usbduxsub[index].dac_commands) {
2421 printk("comedi_: usbdux: error alloc space for dac commands\n"); 2437 printk("comedi_: usbdux: error alloc space for dac commands\n");
@@ -2423,7 +2439,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2423 up(&start_stop_sem); 2439 up(&start_stop_sem);
2424 return PROBE_ERR_RETURN(-ENOMEM); 2440 return PROBE_ERR_RETURN(-ENOMEM);
2425 } 2441 }
2426 // create space for the commands going to the usb device 2442 /* create space for the commands going to the usb device */
2427 usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); 2443 usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
2428 if (!usbduxsub[index].dux_commands) { 2444 if (!usbduxsub[index].dux_commands) {
2429 printk("comedi_: usbdux: error alloc space for dac commands\n"); 2445 printk("comedi_: usbdux: error alloc space for dac commands\n");
@@ -2431,7 +2447,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2431 up(&start_stop_sem); 2447 up(&start_stop_sem);
2432 return PROBE_ERR_RETURN(-ENOMEM); 2448 return PROBE_ERR_RETURN(-ENOMEM);
2433 } 2449 }
2434 // create space for the in buffer and set it to zero 2450 /* create space for the in buffer and set it to zero */
2435 usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); 2451 usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL);
2436 if (!(usbduxsub[index].inBuffer)) { 2452 if (!(usbduxsub[index].inBuffer)) {
2437 printk("comedi_: usbdux: could not alloc space for inBuffer\n"); 2453 printk("comedi_: usbdux: could not alloc space for inBuffer\n");
@@ -2439,7 +2455,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2439 up(&start_stop_sem); 2455 up(&start_stop_sem);
2440 return PROBE_ERR_RETURN(-ENOMEM); 2456 return PROBE_ERR_RETURN(-ENOMEM);
2441 } 2457 }
2442 // create space of the instruction buffer 2458 /* create space of the instruction buffer */
2443 usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); 2459 usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL);
2444 if (!(usbduxsub[index].insnBuffer)) { 2460 if (!(usbduxsub[index].insnBuffer)) {
2445 printk("comedi_: usbdux: could not alloc space for insnBuffer\n"); 2461 printk("comedi_: usbdux: could not alloc space for insnBuffer\n");
@@ -2447,7 +2463,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2447 up(&start_stop_sem); 2463 up(&start_stop_sem);
2448 return PROBE_ERR_RETURN(-ENOMEM); 2464 return PROBE_ERR_RETURN(-ENOMEM);
2449 } 2465 }
2450 // create space for the outbuffer 2466 /* create space for the outbuffer */
2451 usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); 2467 usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL);
2452 if (!(usbduxsub[index].outBuffer)) { 2468 if (!(usbduxsub[index].outBuffer)) {
2453 printk("comedi_: usbdux: could not alloc space for outBuffer\n"); 2469 printk("comedi_: usbdux: could not alloc space for outBuffer\n");
@@ -2479,7 +2495,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2479 return PROBE_ERR_RETURN(-ENOMEM); 2495 return PROBE_ERR_RETURN(-ENOMEM);
2480 } 2496 }
2481 for (i = 0; i < usbduxsub[index].numOfInBuffers; i++) { 2497 for (i = 0; i < usbduxsub[index].numOfInBuffers; i++) {
2482 // one frame: 1ms 2498 /* one frame: 1ms */
2483 usbduxsub[index].urbIn[i] = USB_ALLOC_URB(1); 2499 usbduxsub[index].urbIn[i] = USB_ALLOC_URB(1);
2484 if (usbduxsub[index].urbIn[i] == NULL) { 2500 if (usbduxsub[index].urbIn[i] == NULL) {
2485 printk("comedi_: usbdux%d: Could not alloc. urb(%d)\n", 2501 printk("comedi_: usbdux%d: Could not alloc. urb(%d)\n",
@@ -2489,8 +2505,8 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2489 return PROBE_ERR_RETURN(-ENOMEM); 2505 return PROBE_ERR_RETURN(-ENOMEM);
2490 } 2506 }
2491 usbduxsub[index].urbIn[i]->dev = usbduxsub[index].usbdev; 2507 usbduxsub[index].urbIn[i]->dev = usbduxsub[index].usbdev;
2492 // will be filled later with a pointer to the comedi-device 2508 /* will be filled later with a pointer to the comedi-device */
2493 // and ONLY then the urb should be submitted 2509 /* and ONLY then the urb should be submitted */
2494 usbduxsub[index].urbIn[i]->context = NULL; 2510 usbduxsub[index].urbIn[i]->context = NULL;
2495 usbduxsub[index].urbIn[i]->pipe = 2511 usbduxsub[index].urbIn[i]->pipe =
2496 usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP); 2512 usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP);
@@ -2527,7 +2543,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2527 return PROBE_ERR_RETURN(-ENOMEM); 2543 return PROBE_ERR_RETURN(-ENOMEM);
2528 } 2544 }
2529 for (i = 0; i < usbduxsub[index].numOfOutBuffers; i++) { 2545 for (i = 0; i < usbduxsub[index].numOfOutBuffers; i++) {
2530 // one frame: 1ms 2546 /* one frame: 1ms */
2531 usbduxsub[index].urbOut[i] = USB_ALLOC_URB(1); 2547 usbduxsub[index].urbOut[i] = USB_ALLOC_URB(1);
2532 if (usbduxsub[index].urbOut[i] == NULL) { 2548 if (usbduxsub[index].urbOut[i] == NULL) {
2533 printk("comedi_: usbdux%d: Could not alloc. urb(%d)\n", 2549 printk("comedi_: usbdux%d: Could not alloc. urb(%d)\n",
@@ -2537,8 +2553,8 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2537 return PROBE_ERR_RETURN(-ENOMEM); 2553 return PROBE_ERR_RETURN(-ENOMEM);
2538 } 2554 }
2539 usbduxsub[index].urbOut[i]->dev = usbduxsub[index].usbdev; 2555 usbduxsub[index].urbOut[i]->dev = usbduxsub[index].usbdev;
2540 // will be filled later with a pointer to the comedi-device 2556 /* will be filled later with a pointer to the comedi-device */
2541 // and ONLY then the urb should be submitted 2557 /* and ONLY then the urb should be submitted */
2542 usbduxsub[index].urbOut[i]->context = NULL; 2558 usbduxsub[index].urbOut[i]->context = NULL;
2543 usbduxsub[index].urbOut[i]->pipe = 2559 usbduxsub[index].urbOut[i]->pipe =
2544 usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP); 2560 usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP);
@@ -2559,17 +2575,17 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2559 usbduxsub[index].urbOut[i]->iso_frame_desc[0].length = 2575 usbduxsub[index].urbOut[i]->iso_frame_desc[0].length =
2560 SIZEOUTBUF; 2576 SIZEOUTBUF;
2561 if (usbduxsub[index].high_speed) { 2577 if (usbduxsub[index].high_speed) {
2562 // uframes 2578 /* uframes */
2563 usbduxsub[index].urbOut[i]->interval = 8; 2579 usbduxsub[index].urbOut[i]->interval = 8;
2564 } else { 2580 } else {
2565 // frames 2581 /* frames */
2566 usbduxsub[index].urbOut[i]->interval = 1; 2582 usbduxsub[index].urbOut[i]->interval = 1;
2567 } 2583 }
2568 } 2584 }
2569 2585
2570 // pwm 2586 /* pwm */
2571 if (usbduxsub[index].high_speed) { 2587 if (usbduxsub[index].high_speed) {
2572 usbduxsub[index].sizePwmBuf = 512; // max bulk ep size in high speed 2588 usbduxsub[index].sizePwmBuf = 512; /* max bulk ep size in high speed */
2573 usbduxsub[index].urbPwm = USB_ALLOC_URB(0); 2589 usbduxsub[index].urbPwm = USB_ALLOC_URB(0);
2574 if (usbduxsub[index].urbPwm == NULL) { 2590 if (usbduxsub[index].urbPwm == NULL) {
2575 printk("comedi_: usbdux%d: Could not alloc. pwm urb\n", 2591 printk("comedi_: usbdux%d: Could not alloc. pwm urb\n",
@@ -2595,11 +2611,11 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
2595 usbduxsub[index].ao_cmd_running = 0; 2611 usbduxsub[index].ao_cmd_running = 0;
2596 usbduxsub[index].pwm_cmd_running = 0; 2612 usbduxsub[index].pwm_cmd_running = 0;
2597 2613
2598 // we've reached the bottom of the function 2614 /* we've reached the bottom of the function */
2599 usbduxsub[index].probed = 1; 2615 usbduxsub[index].probed = 1;
2600 up(&start_stop_sem); 2616 up(&start_stop_sem);
2601 printk("comedi_: usbdux%d has been successfully initialised.\n", index); 2617 printk("comedi_: usbdux%d has been successfully initialised.\n", index);
2602 // success 2618 /* success */
2603 return 0; 2619 return 0;
2604} 2620}
2605 2621
@@ -2636,7 +2652,7 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2636 dev->private = NULL; 2652 dev->private = NULL;
2637 2653
2638 down(&start_stop_sem); 2654 down(&start_stop_sem);
2639 // find a valid device which has been detected by the probe function of the usb 2655 /* find a valid device which has been detected by the probe function of the usb */
2640 index = -1; 2656 index = -1;
2641 for (i = 0; i < NUMUSBDUX; i++) { 2657 for (i = 0; i < NUMUSBDUX; i++) {
2642 if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) { 2658 if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) {
@@ -2652,10 +2668,10 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2652 } 2668 }
2653 2669
2654 down(&(usbduxsub[index].sem)); 2670 down(&(usbduxsub[index].sem));
2655 // pointer back to the corresponding comedi device 2671 /* pointer back to the corresponding comedi device */
2656 usbduxsub[index].comedidev = dev; 2672 usbduxsub[index].comedidev = dev;
2657 2673
2658 // trying to upload the firmware into the chip 2674 /* trying to upload the firmware into the chip */
2659 if (comedi_aux_data(it->options, 0) && 2675 if (comedi_aux_data(it->options, 0) &&
2660 it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { 2676 it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
2661 read_firmware(usbduxsub + index, 2677 read_firmware(usbduxsub + index,
@@ -2667,14 +2683,14 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2667 2683
2668 /* set number of subdevices */ 2684 /* set number of subdevices */
2669 if (usbduxsub[index].high_speed) { 2685 if (usbduxsub[index].high_speed) {
2670 // with pwm 2686 /* with pwm */
2671 dev->n_subdevices = 5; 2687 dev->n_subdevices = 5;
2672 } else { 2688 } else {
2673 // without pwm 2689 /* without pwm */
2674 dev->n_subdevices = 4; 2690 dev->n_subdevices = 4;
2675 } 2691 }
2676 2692
2677 // allocate space for the subdevices 2693 /* allocate space for the subdevices */
2678 if ((ret = alloc_subdevices(dev, dev->n_subdevices)) < 0) { 2694 if ((ret = alloc_subdevices(dev, dev->n_subdevices)) < 0) {
2679 printk("comedi%d: usbdux: error alloc space for subdev\n", 2695 printk("comedi%d: usbdux: error alloc space for subdev\n",
2680 dev->minor); 2696 dev->minor);
@@ -2684,64 +2700,63 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2684 2700
2685 printk("comedi%d: usbdux: usb-device %d is attached to comedi.\n", 2701 printk("comedi%d: usbdux: usb-device %d is attached to comedi.\n",
2686 dev->minor, index); 2702 dev->minor, index);
2687 // private structure is also simply the usb-structure 2703 /* private structure is also simply the usb-structure */
2688 dev->private = usbduxsub + index; 2704 dev->private = usbduxsub + index;
2689 2705
2690 // the first subdevice is the A/D converter 2706 /* the first subdevice is the A/D converter */
2691 s = dev->subdevices + SUBDEV_AD; 2707 s = dev->subdevices + SUBDEV_AD;
2692 // the URBs get the comedi subdevice 2708 /* the URBs get the comedi subdevice */
2693 // which is responsible for reading 2709 /* which is responsible for reading */
2694 // this is the subdevice which reads data 2710 /* this is the subdevice which reads data */
2695 dev->read_subdev = s; 2711 dev->read_subdev = s;
2696 // the subdevice receives as private structure the 2712 /* the subdevice receives as private structure the */
2697 // usb-structure 2713 /* usb-structure */
2698 s->private = NULL; 2714 s->private = NULL;
2699 // analog input 2715 /* analog input */
2700 s->type = COMEDI_SUBD_AI; 2716 s->type = COMEDI_SUBD_AI;
2701 // readable and ref is to ground 2717 /* readable and ref is to ground */
2702 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; 2718 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
2703 // 8 channels 2719 /* 8 channels */
2704 s->n_chan = 8; 2720 s->n_chan = 8;
2705 // length of the channellist 2721 /* length of the channellist */
2706 s->len_chanlist = 8; 2722 s->len_chanlist = 8;
2707 // callback functions 2723 /* callback functions */
2708 s->insn_read = usbdux_ai_insn_read; 2724 s->insn_read = usbdux_ai_insn_read;
2709 s->do_cmdtest = usbdux_ai_cmdtest; 2725 s->do_cmdtest = usbdux_ai_cmdtest;
2710 s->do_cmd = usbdux_ai_cmd; 2726 s->do_cmd = usbdux_ai_cmd;
2711 s->cancel = usbdux_ai_cancel; 2727 s->cancel = usbdux_ai_cancel;
2712 // max value from the A/D converter (12bit) 2728 /* max value from the A/D converter (12bit) */
2713 s->maxdata = 0xfff; 2729 s->maxdata = 0xfff;
2714 // range table to convert to physical units 2730 /* range table to convert to physical units */
2715 s->range_table = (&range_usbdux_ai_range); 2731 s->range_table = (&range_usbdux_ai_range);
2716 //
2717 2732
2718 // analog out 2733 /* analog out */
2719 s = dev->subdevices + SUBDEV_DA; 2734 s = dev->subdevices + SUBDEV_DA;
2720 // analog out 2735 /* analog out */
2721 s->type = COMEDI_SUBD_AO; 2736 s->type = COMEDI_SUBD_AO;
2722 // backward pointer 2737 /* backward pointer */
2723 dev->write_subdev = s; 2738 dev->write_subdev = s;
2724 // the subdevice receives as private structure the 2739 /* the subdevice receives as private structure the */
2725 // usb-structure 2740 /* usb-structure */
2726 s->private = NULL; 2741 s->private = NULL;
2727 // are writable 2742 /* are writable */
2728 s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; 2743 s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
2729 // 4 channels 2744 /* 4 channels */
2730 s->n_chan = 4; 2745 s->n_chan = 4;
2731 // length of the channellist 2746 /* length of the channellist */
2732 s->len_chanlist = 4; 2747 s->len_chanlist = 4;
2733 // 12 bit resolution 2748 /* 12 bit resolution */
2734 s->maxdata = 0x0fff; 2749 s->maxdata = 0x0fff;
2735 // bipolar range 2750 /* bipolar range */
2736 s->range_table = (&range_usbdux_ao_range); 2751 s->range_table = (&range_usbdux_ao_range);
2737 // callback 2752 /* callback */
2738 s->do_cmdtest = usbdux_ao_cmdtest; 2753 s->do_cmdtest = usbdux_ao_cmdtest;
2739 s->do_cmd = usbdux_ao_cmd; 2754 s->do_cmd = usbdux_ao_cmd;
2740 s->cancel = usbdux_ao_cancel; 2755 s->cancel = usbdux_ao_cancel;
2741 s->insn_read = usbdux_ao_insn_read; 2756 s->insn_read = usbdux_ao_insn_read;
2742 s->insn_write = usbdux_ao_insn_write; 2757 s->insn_write = usbdux_ao_insn_write;
2743 2758
2744 // digital I/O 2759 /* digital I/O */
2745 s = dev->subdevices + SUBDEV_DIO; 2760 s = dev->subdevices + SUBDEV_DIO;
2746 s->type = COMEDI_SUBD_DIO; 2761 s->type = COMEDI_SUBD_DIO;
2747 s->subdev_flags = SDF_READABLE | SDF_WRITABLE; 2762 s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
@@ -2750,10 +2765,10 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2750 s->range_table = (&range_digital); 2765 s->range_table = (&range_digital);
2751 s->insn_bits = usbdux_dio_insn_bits; 2766 s->insn_bits = usbdux_dio_insn_bits;
2752 s->insn_config = usbdux_dio_insn_config; 2767 s->insn_config = usbdux_dio_insn_config;
2753 // we don't use it 2768 /* we don't use it */
2754 s->private = NULL; 2769 s->private = NULL;
2755 2770
2756 //counter 2771 /* counter */
2757 s = dev->subdevices + SUBDEV_COUNTER; 2772 s = dev->subdevices + SUBDEV_COUNTER;
2758 s->type = COMEDI_SUBD_COUNTER; 2773 s->type = COMEDI_SUBD_COUNTER;
2759 s->subdev_flags = SDF_WRITABLE | SDF_READABLE; 2774 s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
@@ -2764,19 +2779,19 @@ static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
2764 s->insn_config = usbdux_counter_config; 2779 s->insn_config = usbdux_counter_config;
2765 2780
2766 if (usbduxsub[index].high_speed) { 2781 if (usbduxsub[index].high_speed) {
2767 //timer / pwm 2782 /* timer / pwm */
2768 s = dev->subdevices + SUBDEV_PWM; 2783 s = dev->subdevices + SUBDEV_PWM;
2769 s->type = COMEDI_SUBD_PWM; 2784 s->type = COMEDI_SUBD_PWM;
2770 s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; 2785 s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
2771 s->n_chan = 8; 2786 s->n_chan = 8;
2772 // this defines the max duty cycle resolution 2787 /* this defines the max duty cycle resolution */
2773 s->maxdata = usbduxsub[index].sizePwmBuf; 2788 s->maxdata = usbduxsub[index].sizePwmBuf;
2774 s->insn_write = usbdux_pwm_write; 2789 s->insn_write = usbdux_pwm_write;
2775 s->insn_read = usbdux_pwm_read; 2790 s->insn_read = usbdux_pwm_read;
2776 s->insn_config = usbdux_pwm_config; 2791 s->insn_config = usbdux_pwm_config;
2777 usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); 2792 usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
2778 } 2793 }
2779 // finally decide that it's attached 2794 /* finally decide that it's attached */
2780 usbduxsub[index].attached = 1; 2795 usbduxsub[index].attached = 1;
2781 2796
2782 up(&(usbduxsub[index].sem)); 2797 up(&(usbduxsub[index].sem));
@@ -2808,8 +2823,8 @@ static int usbdux_detach(comedi_device *dev)
2808 } 2823 }
2809 2824
2810 down(&usbduxsub_tmp->sem); 2825 down(&usbduxsub_tmp->sem);
2811 // Don't allow detach to free the private structure 2826 /* Don't allow detach to free the private structure */
2812 // It's one entry of of usbduxsub[] 2827 /* It's one entry of of usbduxsub[] */
2813 dev->private = NULL; 2828 dev->private = NULL;
2814 usbduxsub_tmp->attached = 0; 2829 usbduxsub_tmp->attached = 0;
2815 usbduxsub_tmp->comedidev = NULL; 2830 usbduxsub_tmp->comedidev = NULL;
@@ -2834,9 +2849,9 @@ static void init_usb_devices(void)
2834#ifdef CONFIG_COMEDI_DEBUG 2849#ifdef CONFIG_COMEDI_DEBUG
2835 printk("comedi_: usbdux: setting all possible devs to invalid\n"); 2850 printk("comedi_: usbdux: setting all possible devs to invalid\n");
2836#endif 2851#endif
2837 // all devices entries are invalid to begin with 2852 /* all devices entries are invalid to begin with */
2838 // they will become valid by the probe function 2853 /* they will become valid by the probe function */
2839 // and then finally by the attach-function 2854 /* and then finally by the attach-function */
2840 for (index = 0; index < NUMUSBDUX; index++) { 2855 for (index = 0; index < NUMUSBDUX; index++) {
2841 memset(&(usbduxsub[index]), 0x00, sizeof(usbduxsub[index])); 2856 memset(&(usbduxsub[index]), 0x00, sizeof(usbduxsub[index]));
2842 init_MUTEX(&(usbduxsub[index].sem)); 2857 init_MUTEX(&(usbduxsub[index].sem));
@@ -2860,9 +2875,9 @@ static struct usb_driver usbduxsub_driver = {
2860 .id_table = usbduxsub_table, 2875 .id_table = usbduxsub_table,
2861}; 2876};
2862 2877
2863// Can't use the nice macro as I have also to initialise the USB 2878/* Can't use the nice macro as I have also to initialise the USB */
2864// subsystem: 2879/* subsystem: */
2865// registering the usb-system _and_ the comedi-driver 2880/* registering the usb-system _and_ the comedi-driver */
2866static int init_usbdux(void) 2881static int init_usbdux(void)
2867{ 2882{
2868 printk(KERN_INFO KBUILD_MODNAME ": " 2883 printk(KERN_INFO KBUILD_MODNAME ": "
@@ -2873,7 +2888,7 @@ static int init_usbdux(void)
2873 return 0; 2888 return 0;
2874} 2889}
2875 2890
2876// deregistering the comedi driver and the usb-subsystem 2891/* deregistering the comedi driver and the usb-subsystem */
2877static void exit_usbdux(void) 2892static void exit_usbdux(void)
2878{ 2893{
2879 comedi_driver_unregister(&driver_usbdux); 2894 comedi_driver_unregister(&driver_usbdux);