Commit 18e7e78e authored by Iain Churcher's avatar Iain Churcher Committed by Greg Kroah-Hartman

Staging: comedi: numerous checkpatch.pl issues in dt282x.c

This patch cleans up numerous WARNINGS and ERRORS listed by the
checkpatch.pl tool
Signed-off-by: default avatarIain Churcher <iain.linux.coding@googlemail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6cbfa625
...@@ -155,78 +155,57 @@ Configuration options: ...@@ -155,78 +155,57 @@ Configuration options:
#define DT2821_XCLK 0x0002 /* (R/W) external clock enable */ #define DT2821_XCLK 0x0002 /* (R/W) external clock enable */
#define DT2821_BDINIT 0x0001 /* (W) initialize board */ #define DT2821_BDINIT 0x0001 /* (W) initialize board */
static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_lo_bipolar = {
RANGE(-10, 4, {
10), RANGE(-10, 10),
RANGE(-5, RANGE(-5, 5),
5), RANGE(-2.5, 2.5),
RANGE(-2.5, RANGE(-1.25, 1.25)
2.5),
RANGE
(-1.25,
1.25)
} }
}; };
static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_lo_unipolar = {
RANGE(0, 4, {
10), RANGE(0, 10),
RANGE(0, RANGE(0, 5),
5), RANGE(0, 2.5),
RANGE(0, RANGE(0, 1.25)
2.5),
RANGE(0,
1.25)
} }
}; };
static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_5_bipolar = {
RANGE(-5, 4, {
5), RANGE(-5, 5),
RANGE(-2.5, RANGE(-2.5, 2.5),
2.5), RANGE(-1.25, 1.25),
RANGE(-1.25, RANGE(-0.625, 0.625)
1.25),
RANGE
(-0.625,
0.625),
} }
}; };
static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_5_unipolar = {
RANGE(0, 4, {
5), RANGE(0, 5),
RANGE(0, RANGE(0, 2.5),
2.5), RANGE(0, 1.25),
RANGE(0, RANGE(0, 0.625),
1.25),
RANGE(0,
0.625),
} }
}; };
static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_hi_bipolar = {
RANGE(-10, 4, {
10), RANGE(-10, 10),
RANGE(-1, RANGE(-1, 1),
1), RANGE(-0.1, 0.1),
RANGE(-0.1, RANGE(-0.02, 0.02)
0.1),
RANGE
(-0.02,
0.02)
} }
}; };
static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, { static const struct comedi_lrange range_dt282x_ai_hi_unipolar = {
RANGE(0, 4, {
10), RANGE(0, 10),
RANGE(0, RANGE(0, 1),
1), RANGE(0, 0.1),
RANGE(0, RANGE(0, 0.02)
0.1),
RANGE(0,
0.02)
} }
}; };
...@@ -370,7 +349,7 @@ static const struct dt282x_board boardtypes[] = { ...@@ -370,7 +349,7 @@ static const struct dt282x_board boardtypes[] = {
}, },
}; };
#define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board) #define n_boardtypes (sizeof(boardtypes)/sizeof(struct dt282x_board))
#define this_board ((const struct dt282x_board *)dev->board_ptr) #define this_board ((const struct dt282x_board *)dev->board_ptr)
struct dt282x_private { struct dt282x_private {
...@@ -418,14 +397,18 @@ struct dt282x_private { ...@@ -418,14 +397,18 @@ struct dt282x_private {
* the statement(s) to execute if it doesn't happen. * the statement(s) to execute if it doesn't happen.
*/ */
#define wait_for(a, b) \ #define wait_for(a, b) \
do{ \ do { \
int _i; \ int _i; \
for (_i=0;_i<DT2821_TIMEOUT;_i++){ \ for (_i = 0; _i < DT2821_TIMEOUT; _i++) { \
if (a){_i=0;break;} \ if (a) { \
_i = 0; \
break; \
} \
udelay(5); \ udelay(5); \
} \ } \
if (_i){b} \ if (_i) \
}while (0) b \
} while (0)
static int dt282x_attach(struct comedi_device *dev, static int dt282x_attach(struct comedi_device *dev,
struct comedi_devconfig *it); struct comedi_devconfig *it);
...@@ -462,18 +445,16 @@ static void dt282x_munge(struct comedi_device *dev, short *buf, ...@@ -462,18 +445,16 @@ static void dt282x_munge(struct comedi_device *dev, short *buf,
unsigned short sign = 1 << (boardtype.adbits - 1); unsigned short sign = 1 << (boardtype.adbits - 1);
int n; int n;
if (devpriv->ad_2scomp) { if (devpriv->ad_2scomp)
sign = 1 << (boardtype.adbits - 1); sign = 1 << (boardtype.adbits - 1);
} else { else
sign = 0; sign = 0;
}
if (nbytes % 2) if (nbytes % 2)
comedi_error(dev, "bug! odd number of bytes from dma xfer"); comedi_error(dev, "bug! odd number of bytes from dma xfer");
n = nbytes / 2; n = nbytes / 2;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++)
buf[i] = (buf[i] & mask) ^ sign; buf[i] = (buf[i] & mask) ^ sign;
}
} }
static void dt282x_ao_dma_interrupt(struct comedi_device *dev) static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
...@@ -486,7 +467,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev) ...@@ -486,7 +467,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
update_supcsr(DT2821_CLRDMADNE); update_supcsr(DT2821_CLRDMADNE);
if (!s->async->prealloc_buf) { if (!s->async->prealloc_buf) {
printk("async->data disappeared. dang!\n"); printk(KERN_ERR "async->data disappeared. dang!\n");
return; return;
} }
...@@ -499,7 +480,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev) ...@@ -499,7 +480,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize); size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
if (size == 0) { if (size == 0) {
printk("dt282x: AO underrun\n"); printk(KERN_ERR "dt282x: AO underrun\n");
dt282x_ao_cancel(dev, s); dt282x_ao_cancel(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
return; return;
...@@ -519,7 +500,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) ...@@ -519,7 +500,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
update_supcsr(DT2821_CLRDMADNE); update_supcsr(DT2821_CLRDMADNE);
if (!s->async->prealloc_buf) { if (!s->async->prealloc_buf) {
printk("async->data disappeared. dang!\n"); printk(KERN_ERR "async->data disappeared. dang!\n");
return; return;
} }
...@@ -540,7 +521,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) ...@@ -540,7 +521,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
devpriv->nread -= size / 2; devpriv->nread -= size / 2;
if (devpriv->nread < 0) { if (devpriv->nread < 0) {
printk("dt282x: off by one\n"); printk(KERN_INFO "dt282x: off by one\n");
devpriv->nread = 0; devpriv->nread = 0;
} }
if (!devpriv->nread) { if (!devpriv->nread) {
...@@ -651,7 +632,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) ...@@ -651,7 +632,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
static int warn = 5; static int warn = 5;
if (--warn <= 0) { if (--warn <= 0) {
disable_irq(dev->irq); disable_irq(dev->irq);
printk("disabling irq\n"); printk(KERN_INFO "disabling irq\n");
} }
#endif #endif
comedi_error(dev, "D/A error"); comedi_error(dev, "D/A error");
...@@ -666,13 +647,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) ...@@ -666,13 +647,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
data = (short)inw(dev->iobase + DT2821_ADDAT); data = (short)inw(dev->iobase + DT2821_ADDAT);
data &= (1 << boardtype.adbits) - 1; data &= (1 << boardtype.adbits) - 1;
if (devpriv->ad_2scomp) {
if (devpriv->ad_2scomp)
data ^= 1 << (boardtype.adbits - 1); data ^= 1 << (boardtype.adbits - 1);
}
ret = comedi_buf_put(s->async, data); ret = comedi_buf_put(s->async, data);
if (ret == 0) {
if (ret == 0)
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
}
devpriv->nread--; devpriv->nread--;
if (!devpriv->nread) { if (!devpriv->nread) {
...@@ -685,7 +666,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) ...@@ -685,7 +666,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
} }
#endif #endif
comedi_event(dev, s); comedi_event(dev, s);
/* printk("adcsr=0x%02x dacsr-0x%02x supcsr=0x%02x\n", adcsr, dacsr, supcsr); */ /* printk("adcsr=0x%02x dacsr-0x%02x supcsr=0x%02x\n",
adcsr, dacsr, supcsr); */
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
...@@ -776,7 +758,10 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, ...@@ -776,7 +758,10 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
if (err) if (err)
return 1; return 1;
/* step 2: make sure trigger sources are unique and mutually compatible */ /*
* step 2: make sure trigger sources are unique
* and mutually compatible
*/
/* note that mutual compatibility is not an issue here */ /* note that mutual compatibility is not an issue here */
if (cmd->scan_begin_src != TRIG_FOLLOW && if (cmd->scan_begin_src != TRIG_FOLLOW &&
...@@ -859,7 +844,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -859,7 +844,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) { if (devpriv->usedma == 0) {
comedi_error(dev, comedi_error(dev,
"driver requires 2 dma channels to execute command"); "driver requires 2 dma channels"
" to execute command");
return -EIO; return -EIO;
} }
...@@ -1049,7 +1035,10 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, ...@@ -1049,7 +1035,10 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
if (err) if (err)
return 1; return 1;
/* step 2: make sure trigger sources are unique and mutually compatible */ /*
* step 2: make sure trigger sources are unique
* and mutually compatible
*/
/* note that mutual compatibility is not an issue here */ /* note that mutual compatibility is not an issue here */
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
...@@ -1064,7 +1053,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, ...@@ -1064,7 +1053,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
cmd->start_arg = 0; cmd->start_arg = 0;
err++; err++;
} }
if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) { if (cmd->scan_begin_arg < 5000 /* XXX unknown */) {
cmd->scan_begin_arg = 5000; cmd->scan_begin_arg = 5000;
err++; err++;
} }
...@@ -1115,7 +1104,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, ...@@ -1115,7 +1104,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf, size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
devpriv->dma_maxsize); devpriv->dma_maxsize);
if (size == 0) { if (size == 0) {
printk("dt282x: AO underrun\n"); printk(KERN_ERR "dt282x: AO underrun\n");
return -EPIPE; return -EPIPE;
} }
prep_ao_dma(dev, 0, size); prep_ao_dma(dev, 0, size);
...@@ -1123,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, ...@@ -1123,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf, size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
devpriv->dma_maxsize); devpriv->dma_maxsize);
if (size == 0) { if (size == 0) {
printk("dt282x: AO underrun\n"); printk(KERN_ERR "dt282x: AO underrun\n");
return -EPIPE; return -EPIPE;
} }
prep_ao_dma(dev, 1, size); prep_ao_dma(dev, 1, size);
...@@ -1141,7 +1130,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1141,7 +1130,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) { if (devpriv->usedma == 0) {
comedi_error(dev, comedi_error(dev,
"driver requires 2 dma channels to execute command"); "driver requires 2 dma channels"
" to execute command");
return -EIO; return -EIO;
} }
...@@ -1262,7 +1252,8 @@ static const struct comedi_lrange *opt_ao_range_lkup(int x) ...@@ -1262,7 +1252,8 @@ static const struct comedi_lrange *opt_ao_range_lkup(int x)
return ao_range_table[x]; return ao_range_table[x];
} }
enum { opt_iobase = 0, opt_irq, opt_dma1, opt_dma2, /* i/o base, irq, dma channels */ enum { /* i/o base, irq, dma channels */
opt_iobase = 0, opt_irq, opt_dma1, opt_dma2,
opt_diff, /* differential */ opt_diff, /* differential */
opt_ai_twos, opt_ao0_twos, opt_ao1_twos, /* twos comp */ opt_ai_twos, opt_ao0_twos, opt_ao1_twos, /* twos comp */
opt_ai_range, opt_ao0_range, opt_ao1_range, /* range */ opt_ai_range, opt_ao0_range, opt_ao1_range, /* range */
...@@ -1295,9 +1286,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1295,9 +1286,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!iobase) if (!iobase)
iobase = 0x240; iobase = 0x240;
printk("comedi%d: dt282x: 0x%04lx", dev->minor, iobase); printk(KERN_INFO "comedi%d: dt282x: 0x%04lx", dev->minor, iobase);
if (!request_region(iobase, DT2821_SIZE, "dt282x")) { if (!request_region(iobase, DT2821_SIZE, "dt282x")) {
printk(" I/O port conflict\n"); printk(KERN_INFO " I/O port conflict\n");
return -EBUSY; return -EBUSY;
} }
dev->iobase = iobase; dev->iobase = iobase;
...@@ -1305,7 +1296,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1305,7 +1296,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
outw(DT2821_BDINIT, dev->iobase + DT2821_SUPCSR); outw(DT2821_BDINIT, dev->iobase + DT2821_SUPCSR);
i = inw(dev->iobase + DT2821_ADCSR); i = inw(dev->iobase + DT2821_ADCSR);
#ifdef DEBUG #ifdef DEBUG
printk(" fingerprint=%x,%x,%x,%x,%x", printk(KERN_DEBUG " fingerprint=%x,%x,%x,%x,%x",
inw(dev->iobase + DT2821_ADCSR), inw(dev->iobase + DT2821_ADCSR),
inw(dev->iobase + DT2821_CHANCSR), inw(dev->iobase + DT2821_CHANCSR),
inw(dev->iobase + DT2821_DACSR), inw(dev->iobase + DT2821_DACSR),
...@@ -1323,7 +1314,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1323,7 +1314,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
!= DT2821_SUPCSR_VAL) || != DT2821_SUPCSR_VAL) ||
((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK) ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
!= DT2821_TMRCTR_VAL)) { != DT2821_TMRCTR_VAL)) {
printk(" board not found"); printk(KERN_ERR " board not found");
return -EIO; return -EIO;
} }
/* should do board test */ /* should do board test */
...@@ -1344,26 +1335,25 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1344,26 +1335,25 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = probe_irq_off(irqs); irq = probe_irq_off(irqs);
restore_flags(flags); restore_flags(flags);
if (0 /* error */ ) { if (0 /* error */)
printk(" error probing irq (bad)"); printk(KERN_ERR " error probing irq (bad)");
}
} }
#endif #endif
if (irq > 0) { if (irq > 0) {
printk(" ( irq = %d )", irq); printk(KERN_INFO " ( irq = %d )", irq);
ret = request_irq(irq, dt282x_interrupt, 0, "dt282x", dev); ret = request_irq(irq, dt282x_interrupt, 0, "dt282x", dev);
if (ret < 0) { if (ret < 0) {
printk(" failed to get irq\n"); printk(KERN_ERR " failed to get irq\n");
return -EIO; return -EIO;
} }
dev->irq = irq; dev->irq = irq;
} else if (irq == 0) { } else if (irq == 0) {
printk(" (no irq)"); printk(KERN_INFO " (no irq)");
} else { } else {
#if 0 #if 0
printk(" (probe returned multiple irqs--bad)"); printk(KERN_INFO " (probe returned multiple irqs--bad)");
#else #else
printk(" (irq probe not implemented)"); printk(KERN_INFO " (irq probe not implemented)");
#endif #endif
} }
...@@ -1435,16 +1425,15 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1435,16 +1425,15 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = 1; s->maxdata = 1;
s->range_table = &range_digital; s->range_table = &range_digital;
printk("\n"); printk(KERN_INFO "\n");
return 0; return 0;
} }
static void free_resources(struct comedi_device *dev) static void free_resources(struct comedi_device *dev)
{ {
if (dev->irq) { if (dev->irq)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
}
if (dev->iobase) if (dev->iobase)
release_region(dev->iobase, DT2821_SIZE); release_region(dev->iobase, DT2821_SIZE);
if (dev->private) { if (dev->private) {
...@@ -1461,7 +1450,7 @@ static void free_resources(struct comedi_device *dev) ...@@ -1461,7 +1450,7 @@ static void free_resources(struct comedi_device *dev)
static int dt282x_detach(struct comedi_device *dev) static int dt282x_detach(struct comedi_device *dev)
{ {
printk("comedi%d: dt282x: remove\n", dev->minor); printk(KERN_INFO "comedi%d: dt282x: remove\n", dev->minor);
free_resources(dev); free_resources(dev);
...@@ -1475,7 +1464,7 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) ...@@ -1475,7 +1464,7 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
devpriv->usedma = 0; devpriv->usedma = 0;
if (!dma1 && !dma2) { if (!dma1 && !dma2) {
printk(" (no dma)"); printk(KERN_ERR " (no dma)");
return 0; return 0;
} }
...@@ -1503,11 +1492,11 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) ...@@ -1503,11 +1492,11 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
devpriv->dma[0].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA); devpriv->dma[0].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
devpriv->dma[1].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA); devpriv->dma[1].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
if (!devpriv->dma[0].buf || !devpriv->dma[1].buf) { if (!devpriv->dma[0].buf || !devpriv->dma[1].buf) {
printk(" can't get DMA memory"); printk(KERN_ERR " can't get DMA memory");
return -ENOMEM; return -ENOMEM;
} }
printk(" (dma=%d,%d)", dma1, dma2); printk(KERN_INFO " (dma=%d,%d)", dma1, dma2);
devpriv->usedma = 1; devpriv->usedma = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment