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

Staging: comedi: Fix Checkpatch.pl issues in mpc624.c

This patch resolves all checkpatch.pl issues in the mpc624.c file
Signed-off-by: default avatarIain Churcher <iain.linux.coding@googlemail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3b87d0aa
...@@ -115,18 +115,21 @@ Configuration Options: ...@@ -115,18 +115,21 @@ Configuration Options:
#define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2) #define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2)
#define MPC624_SPEED_220_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR0) #define MPC624_SPEED_220_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR0)
#define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1) #define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1)
#define MPC624_SPEED_55_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0) #define MPC624_SPEED_55_Hz \
(MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
#define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3) #define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3)
#define MPC624_SPEED_13_75_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR0) #define MPC624_SPEED_13_75_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR0)
#define MPC624_SPEED_6_875_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0) #define MPC624_SPEED_6_875_Hz \
/* ---------------------------------------------------------------------------- */ (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
/* -------------------------------------------------------------------------- */
struct skel_private { struct skel_private {
unsigned long int ulConvertionRate; /* set by mpc624_attach() from driver's parameters */ /* set by mpc624_attach() from driver's parameters */
unsigned long int ulConvertionRate;
}; };
#define devpriv ((struct skel_private *)dev->private) #define devpriv ((struct skel_private *)dev->private)
/* ---------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static const struct comedi_lrange range_mpc624_bipolar1 = { static const struct comedi_lrange range_mpc624_bipolar1 = {
1, 1,
{ {
...@@ -145,11 +148,11 @@ static const struct comedi_lrange range_mpc624_bipolar10 = { ...@@ -145,11 +148,11 @@ static const struct comedi_lrange range_mpc624_bipolar10 = {
} }
}; };
/* ---------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static int mpc624_attach(struct comedi_device *dev, static int mpc624_attach(struct comedi_device *dev,
struct comedi_devconfig *it); struct comedi_devconfig *it);
static int mpc624_detach(struct comedi_device *dev); static int mpc624_detach(struct comedi_device *dev);
/* ---------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static struct comedi_driver driver_mpc624 = { static struct comedi_driver driver_mpc624 = {
.driver_name = "mpc624", .driver_name = "mpc624",
.module = THIS_MODULE, .module = THIS_MODULE,
...@@ -157,20 +160,20 @@ static struct comedi_driver driver_mpc624 = { ...@@ -157,20 +160,20 @@ static struct comedi_driver driver_mpc624 = {
.detach = mpc624_detach .detach = mpc624_detach
}; };
/* ---------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static int mpc624_ai_rinsn(struct comedi_device *dev, static int mpc624_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn, struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data); unsigned int *data);
/* ---------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{ {
struct comedi_subdevice *s; struct comedi_subdevice *s;
unsigned long iobase; unsigned long iobase;
iobase = it->options[0]; iobase = it->options[0];
printk("comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase); printk(KERN_INFO "comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase);
if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) { if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) {
printk("I/O port(s) in use\n"); printk(KERN_ERR "I/O port(s) in use\n");
return -EIO; return -EIO;
} }
...@@ -184,47 +187,48 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -184,47 +187,48 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
switch (it->options[1]) { switch (it->options[1]) {
case 0: case 0:
devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz; devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
printk("3.52 kHz, "); printk(KERN_INFO "3.52 kHz, ");
break; break;
case 1: case 1:
devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz; devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz;
printk("1.76 kHz, "); printk(KERN_INFO "1.76 kHz, ");
break; break;
case 2: case 2:
devpriv->ulConvertionRate = MPC624_SPEED_880_Hz; devpriv->ulConvertionRate = MPC624_SPEED_880_Hz;
printk("880 Hz, "); printk(KERN_INFO "880 Hz, ");
break; break;
case 3: case 3:
devpriv->ulConvertionRate = MPC624_SPEED_440_Hz; devpriv->ulConvertionRate = MPC624_SPEED_440_Hz;
printk("440 Hz, "); printk(KERN_INFO "440 Hz, ");
break; break;
case 4: case 4:
devpriv->ulConvertionRate = MPC624_SPEED_220_Hz; devpriv->ulConvertionRate = MPC624_SPEED_220_Hz;
printk("220 Hz, "); printk(KERN_INFO "220 Hz, ");
break; break;
case 5: case 5:
devpriv->ulConvertionRate = MPC624_SPEED_110_Hz; devpriv->ulConvertionRate = MPC624_SPEED_110_Hz;
printk("110 Hz, "); printk(KERN_INFO "110 Hz, ");
break; break;
case 6: case 6:
devpriv->ulConvertionRate = MPC624_SPEED_55_Hz; devpriv->ulConvertionRate = MPC624_SPEED_55_Hz;
printk("55 Hz, "); printk(KERN_INFO "55 Hz, ");
break; break;
case 7: case 7:
devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz; devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz;
printk("27.5 Hz, "); printk(KERN_INFO "27.5 Hz, ");
break; break;
case 8: case 8:
devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz; devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz;
printk("13.75 Hz, "); printk(KERN_INFO "13.75 Hz, ");
break; break;
case 9: case 9:
devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz; devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz;
printk("6.875 Hz, "); printk(KERN_INFO "6.875 Hz, ");
break; break;
default: default:
printk printk
("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, "); (KERN_ERR "illegal convertion rate setting!"
" Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz; devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
} }
...@@ -239,29 +243,29 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -239,29 +243,29 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
switch (it->options[1]) { switch (it->options[1]) {
default: default:
s->maxdata = 0x3FFFFFFF; s->maxdata = 0x3FFFFFFF;
printk("30 bit, "); printk(KERN_INFO "30 bit, ");
} }
switch (it->options[1]) { switch (it->options[1]) {
case 0: case 0:
s->range_table = &range_mpc624_bipolar1; s->range_table = &range_mpc624_bipolar1;
printk("1.01V]: "); printk(KERN_INFO "1.01V]: ");
break; break;
default: default:
s->range_table = &range_mpc624_bipolar10; s->range_table = &range_mpc624_bipolar10;
printk("10.1V]: "); printk(KERN_INFO "10.1V]: ");
} }
s->len_chanlist = 1; s->len_chanlist = 1;
s->insn_read = mpc624_ai_rinsn; s->insn_read = mpc624_ai_rinsn;
printk("attached\n"); printk(KERN_INFO "attached\n");
return 1; return 1;
} }
static int mpc624_detach(struct comedi_device *dev) static int mpc624_detach(struct comedi_device *dev)
{ {
printk("comedi%d: mpc624: remove\n", dev->minor); printk(KERN_INFO "comedi%d: mpc624: remove\n", dev->minor);
if (dev->iobase) if (dev->iobase)
release_region(dev->iobase, MPC624_SIZE); release_region(dev->iobase, MPC624_SIZE);
...@@ -280,11 +284,14 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, ...@@ -280,11 +284,14 @@ static int mpc624_ai_rinsn(struct comedi_device *dev,
unsigned long int data_in, data_out; unsigned long int data_in, data_out;
unsigned char ucPort; unsigned char ucPort;
/* WARNING: We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc */ /*
* WARNING:
* We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc
*/
outb(insn->chanspec, dev->iobase + MPC624_GNMUXCH); outb(insn->chanspec, dev->iobase + MPC624_GNMUXCH);
/* printk("Channel %d: \n", insn->chanspec); */ /* printk("Channel %d:\n", insn->chanspec); */
if (!insn->n) { if (!insn->n) {
printk("MPC624: Warning, no data to acquire\n"); printk(KERN_INFO "MPC624: Warning, no data to acquire\n");
return 0; return 0;
} }
...@@ -306,7 +313,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, ...@@ -306,7 +313,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev,
break; break;
} }
if (i == TIMEOUT) { if (i == TIMEOUT) {
printk("MPC624: timeout (%dms)\n", TIMEOUT); printk(KERN_ERR "MPC624: timeout (%dms)\n", TIMEOUT);
data[n] = 0; data[n] = 0;
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -344,31 +351,47 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, ...@@ -344,31 +351,47 @@ static int mpc624_ai_rinsn(struct comedi_device *dev,
data_out <<= 1; data_out <<= 1;
} }
/* Received 32-bit long value consist of: */ /*
/* 31: EOC (End Of Transmission) bit - should be 0 */ * Received 32-bit long value consist of:
/* 30: DMY (Dummy) bit - should be 0 */ * 31: EOC -
/* 29: SIG (Sign) bit - 1 if the voltage is positive, 0 if negative */ * (End Of Transmission) bit - should be 0
/* 28: MSB (Most Significant Bit) - the first bit of convertion result */ * 30: DMY
/* .... */ * (Dummy) bit - should be 0
/* 05: LSB (Least Significant Bit) - the last bit of convertion result */ * 29: SIG
/* 04: sub-LSB - sub-LSBs are basically noise, but when */ * (Sign) bit- 1 if the voltage is positive,
/* 03: sub-LSB averaged properly, they can increase convertion */ * 0 if negative
/* 02: sub-LSB precision up to 29 bits; they can be discarded */ * 28: MSB
/* 01: sub-LSB without loss of resolution. */ * (Most Significant Bit) - the first bit of
/* 00: sub-LSB */ * the conversion result
* ....
* 05: LSB
* (Least Significant Bit)- the last bit of the
* conversion result
* 04-00: sub-LSB
* - sub-LSBs are basically noise, but when
* averaged properly, they can increase conversion
* precision up to 29 bits; they can be discarded
* without loss of resolution.
*/
if (data_in & MPC624_EOC_BIT) if (data_in & MPC624_EOC_BIT)
printk("MPC624: EOC bit is set (data_in=%lu)!", printk(KERN_INFO "MPC624:EOC bit is set (data_in=%lu)!",
data_in); data_in);
if (data_in & MPC624_DMY_BIT) if (data_in & MPC624_DMY_BIT)
printk("MPC624: DMY bit is set (data_in=%lu)!", printk(KERN_INFO "MPC624:DMY bit is set (data_in=%lu)!",
data_in); data_in);
if (data_in & MPC624_SGN_BIT) { /* check the sign bit *//* The voltage is positive */ if (data_in & MPC624_SGN_BIT) { /* Volatge is positive */
data_in &= 0x3FFFFFFF; /* EOC and DMY should be 0, but we will mask them out just to be sure */ /*
data[n] = data_in; /* comedi operates on unsigned numbers, so we don't clear the SGN bit */ * comedi operates on unsigned numbers, so mask off EOC
/* SGN bit is still set! It's correct, since we're converting to unsigned. */ * and DMY and don't clear the SGN bit
*/
data_in &= 0x3FFFFFFF;
data[n] = data_in;
} else { /* The voltage is negative */ } else { /* The voltage is negative */
/* data_in contains a number in 30-bit two's complement code and we must deal with it */ /*
* data_in contains a number in 30-bit two's complement
* code and we must deal with it
*/
data_in |= MPC624_SGN_BIT; data_in |= MPC624_SGN_BIT;
data_in = ~data_in; data_in = ~data_in;
data_in += 1; data_in += 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