diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-11-19 13:21:17 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 16:52:24 -0500 |
commit | 1be0e3ed76188c9dd879f421953f5cbf5d9cee58 (patch) | |
tree | cd012ba14cdfe855d0e32d8e891fd028d1132b91 | |
parent | 246c541822cd6251aa38862f8f13412e5147a1ad (diff) |
Staging: comedi: fix checkpatch.pl issues in comedi_test.c
This fixes almost all checkpatch.pl issues with the comedi_test.c
file.
Hint, volatile doesn't do what you think it does, it has been removed
from the structure...
Cc: Joachim Wuttke <Joachim.Wuttke@icn.siemens.de>
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/comedi_test.c | 173 |
1 files changed, 87 insertions, 86 deletions
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 356a9e9c3abd..b8911374dcdd 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c | |||
@@ -68,11 +68,11 @@ typedef struct waveform_board_struct { | |||
68 | 68 | ||
69 | static const waveform_board waveform_boards[] = { | 69 | static const waveform_board waveform_boards[] = { |
70 | { | 70 | { |
71 | name: "comedi_test", | 71 | .name = "comedi_test", |
72 | ai_chans:N_CHANS, | 72 | .ai_chans = N_CHANS, |
73 | ai_bits: 16, | 73 | .ai_bits = 16, |
74 | have_dio:0, | 74 | .have_dio = 0, |
75 | }, | 75 | }, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | #define thisboard ((const waveform_board *)dev->board_ptr) | 78 | #define thisboard ((const waveform_board *)dev->board_ptr) |
@@ -80,53 +80,54 @@ static const waveform_board waveform_boards[] = { | |||
80 | /* Data unique to this driver */ | 80 | /* Data unique to this driver */ |
81 | typedef struct { | 81 | typedef struct { |
82 | struct timer_list timer; | 82 | struct timer_list timer; |
83 | struct timeval last; // time at which last timer interrupt occured | 83 | struct timeval last; /* time at which last timer interrupt occured */ |
84 | unsigned int uvolt_amplitude; // waveform amplitude in microvolts | 84 | unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */ |
85 | unsigned long usec_period; // waveform period in microseconds | 85 | unsigned long usec_period; /* waveform period in microseconds */ |
86 | volatile unsigned long usec_current; // current time (modulo waveform period) | 86 | unsigned long usec_current; /* current time (modulo waveform period) */ |
87 | volatile unsigned long usec_remainder; // usec since last scan; | 87 | unsigned long usec_remainder; /* usec since last scan; */ |
88 | volatile unsigned long ai_count; // number of conversions remaining | 88 | unsigned long ai_count; /* number of conversions remaining */ |
89 | unsigned int scan_period; // scan period in usec | 89 | unsigned int scan_period; /* scan period in usec */ |
90 | unsigned int convert_period; // conversion period in usec | 90 | unsigned int convert_period; /* conversion period in usec */ |
91 | volatile unsigned timer_running:1; | 91 | unsigned timer_running:1; |
92 | volatile lsampl_t ao_loopbacks[N_CHANS]; | 92 | lsampl_t ao_loopbacks[N_CHANS]; |
93 | } waveform_private; | 93 | } waveform_private; |
94 | #define devpriv ((waveform_private *)dev->private) | 94 | #define devpriv ((waveform_private *)dev->private) |
95 | 95 | ||
96 | static int waveform_attach(comedi_device * dev, comedi_devconfig * it); | 96 | static int waveform_attach(comedi_device *dev, comedi_devconfig *it); |
97 | static int waveform_detach(comedi_device * dev); | 97 | static int waveform_detach(comedi_device *dev); |
98 | static comedi_driver driver_waveform = { | 98 | static comedi_driver driver_waveform = { |
99 | driver_name:"comedi_test", | 99 | .driver_name = "comedi_test", |
100 | module:THIS_MODULE, | 100 | .module = THIS_MODULE, |
101 | attach:waveform_attach, | 101 | .attach = waveform_attach, |
102 | detach:waveform_detach, | 102 | .detach = waveform_detach, |
103 | board_name:&waveform_boards[0].name, | 103 | .board_name = &waveform_boards[0].name, |
104 | offset:sizeof(waveform_board), | 104 | .offset = sizeof(waveform_board), |
105 | num_names:sizeof(waveform_boards) / sizeof(waveform_board), | 105 | .num_names = sizeof(waveform_boards) / sizeof(waveform_board), |
106 | }; | 106 | }; |
107 | 107 | ||
108 | COMEDI_INITCLEANUP(driver_waveform); | 108 | COMEDI_INITCLEANUP(driver_waveform); |
109 | 109 | ||
110 | static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | 110 | static int waveform_ai_cmdtest(comedi_device *dev, comedi_subdevice *s, |
111 | comedi_cmd * cmd); | 111 | comedi_cmd *cmd); |
112 | static int waveform_ai_cmd(comedi_device * dev, comedi_subdevice * s); | 112 | static int waveform_ai_cmd(comedi_device *dev, comedi_subdevice *s); |
113 | static int waveform_ai_cancel(comedi_device * dev, comedi_subdevice * s); | 113 | static int waveform_ai_cancel(comedi_device *dev, comedi_subdevice *s); |
114 | static int waveform_ai_insn_read(comedi_device * dev, comedi_subdevice * s, | 114 | static int waveform_ai_insn_read(comedi_device *dev, comedi_subdevice *s, |
115 | comedi_insn * insn, lsampl_t * data); | 115 | comedi_insn *insn, lsampl_t *data); |
116 | static int waveform_ao_insn_write(comedi_device * dev, comedi_subdevice * s, | 116 | static int waveform_ao_insn_write(comedi_device *dev, comedi_subdevice *s, |
117 | comedi_insn * insn, lsampl_t * data); | 117 | comedi_insn *insn, lsampl_t *data); |
118 | static sampl_t fake_sawtooth(comedi_device * dev, unsigned int range, | 118 | static sampl_t fake_sawtooth(comedi_device *dev, unsigned int range, |
119 | unsigned long current_time); | 119 | unsigned long current_time); |
120 | static sampl_t fake_squarewave(comedi_device * dev, unsigned int range, | 120 | static sampl_t fake_squarewave(comedi_device *dev, unsigned int range, |
121 | unsigned long current_time); | 121 | unsigned long current_time); |
122 | static sampl_t fake_flatline(comedi_device * dev, unsigned int range, | 122 | static sampl_t fake_flatline(comedi_device *dev, unsigned int range, |
123 | unsigned long current_time); | 123 | unsigned long current_time); |
124 | static sampl_t fake_waveform(comedi_device * dev, unsigned int channel, | 124 | static sampl_t fake_waveform(comedi_device *dev, unsigned int channel, |
125 | unsigned int range, unsigned long current_time); | 125 | unsigned int range, unsigned long current_time); |
126 | 126 | ||
127 | static const int nano_per_micro = 1000; // 1000 nanosec in a microsec | 127 | /* 1000 nanosec in a microsec */ |
128 | 128 | static const int nano_per_micro = 1000; | |
129 | // fake analog input ranges | 129 | |
130 | /* fake analog input ranges */ | ||
130 | static const comedi_lrange waveform_ai_ranges = { | 131 | static const comedi_lrange waveform_ai_ranges = { |
131 | 2, | 132 | 2, |
132 | { | 133 | { |
@@ -146,7 +147,7 @@ static void waveform_ai_interrupt(unsigned long arg) | |||
146 | comedi_async *async = dev->read_subdev->async; | 147 | comedi_async *async = dev->read_subdev->async; |
147 | comedi_cmd *cmd = &async->cmd; | 148 | comedi_cmd *cmd = &async->cmd; |
148 | unsigned int i, j; | 149 | unsigned int i, j; |
149 | // all times in microsec | 150 | /* all times in microsec */ |
150 | unsigned long elapsed_time; | 151 | unsigned long elapsed_time; |
151 | unsigned int num_scans; | 152 | unsigned int num_scans; |
152 | struct timeval now; | 153 | struct timeval now; |
@@ -191,30 +192,27 @@ static void waveform_ai_interrupt(unsigned long arg) | |||
191 | comedi_event(dev, dev->read_subdev); | 192 | comedi_event(dev, dev->read_subdev); |
192 | } | 193 | } |
193 | 194 | ||
194 | static int waveform_attach(comedi_device * dev, comedi_devconfig * it) | 195 | static int waveform_attach(comedi_device *dev, comedi_devconfig *it) |
195 | { | 196 | { |
196 | comedi_subdevice *s; | 197 | comedi_subdevice *s; |
197 | int amplitude = it->options[0]; | 198 | int amplitude = it->options[0]; |
198 | int period = it->options[1]; | 199 | int period = it->options[1]; |
199 | 200 | int i; | |
200 | printk("comedi%d: comedi_test: ", dev->minor); | ||
201 | 201 | ||
202 | dev->board_name = thisboard->name; | 202 | dev->board_name = thisboard->name; |
203 | 203 | ||
204 | if (alloc_private(dev, sizeof(waveform_private)) < 0) | 204 | if (alloc_private(dev, sizeof(waveform_private)) < 0) |
205 | return -ENOMEM; | 205 | return -ENOMEM; |
206 | 206 | ||
207 | // set default amplitude and period | 207 | /* set default amplitude and period */ |
208 | if (amplitude <= 0) | 208 | if (amplitude <= 0) |
209 | amplitude = 1000000; // 1 volt | 209 | amplitude = 1000000; /* 1 volt */ |
210 | if (period <= 0) | 210 | if (period <= 0) |
211 | period = 100000; // 0.1 sec | 211 | period = 100000; /* 0.1 sec */ |
212 | 212 | ||
213 | devpriv->uvolt_amplitude = amplitude; | 213 | devpriv->uvolt_amplitude = amplitude; |
214 | devpriv->usec_period = period; | 214 | devpriv->usec_period = period; |
215 | 215 | ||
216 | printk("%i microvolt, %li microsecond waveform ", | ||
217 | devpriv->uvolt_amplitude, devpriv->usec_period); | ||
218 | dev->n_subdevices = 2; | 216 | dev->n_subdevices = 2; |
219 | if (alloc_subdevices(dev, dev->n_subdevices) < 0) | 217 | if (alloc_subdevices(dev, dev->n_subdevices) < 0) |
220 | return -ENOMEM; | 218 | return -ENOMEM; |
@@ -246,35 +244,33 @@ static int waveform_attach(comedi_device * dev, comedi_devconfig * it) | |||
246 | s->do_cmd = 0; | 244 | s->do_cmd = 0; |
247 | s->do_cmdtest = 0; | 245 | s->do_cmdtest = 0; |
248 | s->cancel = 0; | 246 | s->cancel = 0; |
249 | { | 247 | |
250 | /* Our default loopback value is just a 0V flatline */ | 248 | /* Our default loopback value is just a 0V flatline */ |
251 | int i; | 249 | for (i = 0; i < s->n_chan; i++) |
252 | for (i = 0; i < s->n_chan; i++) | 250 | devpriv->ao_loopbacks[i] = s->maxdata / 2; |
253 | devpriv->ao_loopbacks[i] = s->maxdata / 2; | ||
254 | } | ||
255 | 251 | ||
256 | init_timer(&(devpriv->timer)); | 252 | init_timer(&(devpriv->timer)); |
257 | devpriv->timer.function = waveform_ai_interrupt; | 253 | devpriv->timer.function = waveform_ai_interrupt; |
258 | devpriv->timer.data = (unsigned long)dev; | 254 | devpriv->timer.data = (unsigned long)dev; |
259 | 255 | ||
260 | printk("attached\n"); | 256 | printk(KERN_INFO "comedi%d: comedi_test: " |
261 | 257 | "%i microvolt, %li microsecond waveform attached\n", dev->minor, | |
258 | devpriv->uvolt_amplitude, devpriv->usec_period); | ||
262 | return 1; | 259 | return 1; |
263 | } | 260 | } |
264 | 261 | ||
265 | static int waveform_detach(comedi_device * dev) | 262 | static int waveform_detach(comedi_device *dev) |
266 | { | 263 | { |
267 | printk("comedi%d: comedi_test: remove\n", dev->minor); | 264 | printk("comedi%d: comedi_test: remove\n", dev->minor); |
268 | 265 | ||
269 | if (dev->private) { | 266 | if (dev->private) |
270 | waveform_ai_cancel(dev, dev->read_subdev); | 267 | waveform_ai_cancel(dev, dev->read_subdev); |
271 | } | ||
272 | 268 | ||
273 | return 0; | 269 | return 0; |
274 | } | 270 | } |
275 | 271 | ||
276 | static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | 272 | static int waveform_ai_cmdtest(comedi_device *dev, comedi_subdevice *s, |
277 | comedi_cmd * cmd) | 273 | comedi_cmd *cmd) |
278 | { | 274 | { |
279 | int err = 0; | 275 | int err = 0; |
280 | int tmp; | 276 | int tmp; |
@@ -309,7 +305,9 @@ static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | |||
309 | if (err) | 305 | if (err) |
310 | return 1; | 306 | return 1; |
311 | 307 | ||
312 | /* step 2: make sure trigger sources are unique and mutually compatible */ | 308 | /* |
309 | * step 2: make sure trigger sources are unique and mutually compatible | ||
310 | */ | ||
313 | 311 | ||
314 | if (cmd->convert_src != TRIG_NOW && cmd->convert_src != TRIG_TIMER) | 312 | if (cmd->convert_src != TRIG_NOW && cmd->convert_src != TRIG_TIMER) |
315 | err++; | 313 | err++; |
@@ -344,7 +342,10 @@ static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | |||
344 | err++; | 342 | err++; |
345 | } | 343 | } |
346 | } | 344 | } |
347 | // XXX these checks are generic and should go in core if not there already | 345 | /* |
346 | * XXX these checks are generic and should go in core if not there | ||
347 | * already | ||
348 | */ | ||
348 | if (!cmd->chanlist_len) { | 349 | if (!cmd->chanlist_len) { |
349 | cmd->chanlist_len = 1; | 350 | cmd->chanlist_len = 1; |
350 | err++; | 351 | err++; |
@@ -373,7 +374,7 @@ static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | |||
373 | 374 | ||
374 | if (cmd->scan_begin_src == TRIG_TIMER) { | 375 | if (cmd->scan_begin_src == TRIG_TIMER) { |
375 | tmp = cmd->scan_begin_arg; | 376 | tmp = cmd->scan_begin_arg; |
376 | // round to nearest microsec | 377 | /* round to nearest microsec */ |
377 | cmd->scan_begin_arg = | 378 | cmd->scan_begin_arg = |
378 | nano_per_micro * ((tmp + | 379 | nano_per_micro * ((tmp + |
379 | (nano_per_micro / 2)) / nano_per_micro); | 380 | (nano_per_micro / 2)) / nano_per_micro); |
@@ -382,7 +383,7 @@ static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | |||
382 | } | 383 | } |
383 | if (cmd->convert_src == TRIG_TIMER) { | 384 | if (cmd->convert_src == TRIG_TIMER) { |
384 | tmp = cmd->convert_arg; | 385 | tmp = cmd->convert_arg; |
385 | // round to nearest microsec | 386 | /* round to nearest microsec */ |
386 | cmd->convert_arg = | 387 | cmd->convert_arg = |
387 | nano_per_micro * ((tmp + | 388 | nano_per_micro * ((tmp + |
388 | (nano_per_micro / 2)) / nano_per_micro); | 389 | (nano_per_micro / 2)) / nano_per_micro); |
@@ -396,7 +397,7 @@ static int waveform_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, | |||
396 | return 0; | 397 | return 0; |
397 | } | 398 | } |
398 | 399 | ||
399 | static int waveform_ai_cmd(comedi_device * dev, comedi_subdevice * s) | 400 | static int waveform_ai_cmd(comedi_device *dev, comedi_subdevice *s) |
400 | { | 401 | { |
401 | comedi_cmd *cmd = &s->async->cmd; | 402 | comedi_cmd *cmd = &s->async->cmd; |
402 | 403 | ||
@@ -428,15 +429,15 @@ static int waveform_ai_cmd(comedi_device * dev, comedi_subdevice * s) | |||
428 | return 0; | 429 | return 0; |
429 | } | 430 | } |
430 | 431 | ||
431 | static int waveform_ai_cancel(comedi_device * dev, comedi_subdevice * s) | 432 | static int waveform_ai_cancel(comedi_device *dev, comedi_subdevice *s) |
432 | { | 433 | { |
433 | devpriv->timer_running = 0; | 434 | devpriv->timer_running = 0; |
434 | del_timer(&devpriv->timer); | 435 | del_timer(&devpriv->timer); |
435 | return 0; | 436 | return 0; |
436 | } | 437 | } |
437 | 438 | ||
438 | static sampl_t fake_sawtooth(comedi_device * dev, unsigned int range_index, | 439 | static sampl_t fake_sawtooth(comedi_device *dev, unsigned int range_index, |
439 | unsigned long current_time) | 440 | unsigned long current_time) |
440 | { | 441 | { |
441 | comedi_subdevice *s = dev->read_subdev; | 442 | comedi_subdevice *s = dev->read_subdev; |
442 | unsigned int offset = s->maxdata / 2; | 443 | unsigned int offset = s->maxdata / 2; |
@@ -452,12 +453,12 @@ static sampl_t fake_sawtooth(comedi_device * dev, unsigned int range_index, | |||
452 | value = current_time; | 453 | value = current_time; |
453 | value *= binary_amplitude * 2; | 454 | value *= binary_amplitude * 2; |
454 | do_div(value, devpriv->usec_period); | 455 | do_div(value, devpriv->usec_period); |
455 | value -= binary_amplitude; // get rid of sawtooth's dc offset | 456 | value -= binary_amplitude; /* get rid of sawtooth's dc offset */ |
456 | 457 | ||
457 | return offset + value; | 458 | return offset + value; |
458 | } | 459 | } |
459 | static sampl_t fake_squarewave(comedi_device * dev, unsigned int range_index, | 460 | static sampl_t fake_squarewave(comedi_device *dev, unsigned int range_index, |
460 | unsigned long current_time) | 461 | unsigned long current_time) |
461 | { | 462 | { |
462 | comedi_subdevice *s = dev->read_subdev; | 463 | comedi_subdevice *s = dev->read_subdev; |
463 | unsigned int offset = s->maxdata / 2; | 464 | unsigned int offset = s->maxdata / 2; |
@@ -475,15 +476,15 @@ static sampl_t fake_squarewave(comedi_device * dev, unsigned int range_index, | |||
475 | return offset + value; | 476 | return offset + value; |
476 | } | 477 | } |
477 | 478 | ||
478 | static sampl_t fake_flatline(comedi_device * dev, unsigned int range_index, | 479 | static sampl_t fake_flatline(comedi_device *dev, unsigned int range_index, |
479 | unsigned long current_time) | 480 | unsigned long current_time) |
480 | { | 481 | { |
481 | return dev->read_subdev->maxdata / 2; | 482 | return dev->read_subdev->maxdata / 2; |
482 | } | 483 | } |
483 | 484 | ||
484 | // generates a different waveform depending on what channel is read | 485 | /* generates a different waveform depending on what channel is read */ |
485 | static sampl_t fake_waveform(comedi_device * dev, unsigned int channel, | 486 | static sampl_t fake_waveform(comedi_device *dev, unsigned int channel, |
486 | unsigned int range, unsigned long current_time) | 487 | unsigned int range, unsigned long current_time) |
487 | { | 488 | { |
488 | enum { | 489 | enum { |
489 | SAWTOOTH_CHAN, | 490 | SAWTOOTH_CHAN, |
@@ -503,8 +504,8 @@ static sampl_t fake_waveform(comedi_device * dev, unsigned int channel, | |||
503 | return fake_flatline(dev, range, current_time); | 504 | return fake_flatline(dev, range, current_time); |
504 | } | 505 | } |
505 | 506 | ||
506 | static int waveform_ai_insn_read(comedi_device * dev, comedi_subdevice * s, | 507 | static int waveform_ai_insn_read(comedi_device *dev, comedi_subdevice *s, |
507 | comedi_insn * insn, lsampl_t * data) | 508 | comedi_insn *insn, lsampl_t *data) |
508 | { | 509 | { |
509 | int i, chan = CR_CHAN(insn->chanspec); | 510 | int i, chan = CR_CHAN(insn->chanspec); |
510 | 511 | ||
@@ -514,8 +515,8 @@ static int waveform_ai_insn_read(comedi_device * dev, comedi_subdevice * s, | |||
514 | return insn->n; | 515 | return insn->n; |
515 | } | 516 | } |
516 | 517 | ||
517 | static int waveform_ao_insn_write(comedi_device * dev, comedi_subdevice * s, | 518 | static int waveform_ao_insn_write(comedi_device *dev, comedi_subdevice *s, |
518 | comedi_insn * insn, lsampl_t * data) | 519 | comedi_insn *insn, lsampl_t *data) |
519 | { | 520 | { |
520 | int i, chan = CR_CHAN(insn->chanspec); | 521 | int i, chan = CR_CHAN(insn->chanspec); |
521 | 522 | ||