Commit 43a35276 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: s526: rename local var used for CR_CHAN() value

Rename the local variable used to hold the unpacked CR_CHAN() value
to help keep the lines < 80 chars.

Also, since the insn->chanspec variable is an unsigned int, change
the type of the local variable to match.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d9083b2
...@@ -148,15 +148,15 @@ static int s526_gpct_rinsn(struct comedi_device *dev, ...@@ -148,15 +148,15 @@ static int s526_gpct_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)
{ {
int i; /* counts the Data */ unsigned int chan = CR_CHAN(insn->chanspec);
int counter_channel = CR_CHAN(insn->chanspec);
unsigned short datalow; unsigned short datalow;
unsigned short datahigh; unsigned short datahigh;
int i;
/* Read the low word first */ /* Read the low word first */
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
datalow = inw(dev->iobase + REG_C0L + counter_channel * 8); datalow = inw(dev->iobase + REG_C0L + chan * 8);
datahigh = inw(dev->iobase + REG_C0H + counter_channel * 8); datahigh = inw(dev->iobase + REG_C0H + chan * 8);
data[i] = (int)(datahigh & 0x00FF); data[i] = (int)(datahigh & 0x00FF);
data[i] = (data[i] << 16) | (datalow & 0xFFFF); data[i] = (data[i] << 16) | (datalow & 0xFFFF);
} }
...@@ -168,13 +168,13 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -168,13 +168,13 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */ unsigned int chan = CR_CHAN(insn->chanspec);
int i; int i;
short value; short value;
union cmReg cmReg; union cmReg cmReg;
for (i = 0; i < MAX_GPCT_CONFIG_DATA; i++) for (i = 0; i < MAX_GPCT_CONFIG_DATA; i++)
devpriv->s526_gpct_config[subdev_channel].data[i] = data[i]; devpriv->s526_gpct_config[chan].data[i] = data[i];
/* Check what type of Counter the user requested, data[0] contains */ /* Check what type of Counter the user requested, data[0] contains */
/* the Application type */ /* the Application type */
...@@ -186,8 +186,7 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -186,8 +186,7 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
data[2]: Pre-load Register Value data[2]: Pre-load Register Value
data[3]: Conter Control Register data[3]: Conter Control Register
*/ */
devpriv->s526_gpct_config[subdev_channel].app = devpriv->s526_gpct_config[chan].app = PositionMeasurement;
PositionMeasurement;
#if 0 #if 0
/* Example of Counter Application */ /* Example of Counter Application */
...@@ -204,32 +203,32 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -204,32 +203,32 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.preloadRegSel = 0; /* PR0 */
cmReg.reg.reserved = 0; cmReg.reg.reserved = 0;
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
outw(0x0001, dev->iobase + REG_C0H + subdev_channel * 8); outw(0x0001, dev->iobase + REG_C0H + chan * 8);
outw(0x3C68, dev->iobase + REG_C0L + subdev_channel * 8); outw(0x3C68, dev->iobase + REG_C0L + chan * 8);
/* Reset the counter */ /* Reset the counter */
outw(0x8000, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x8000, dev->iobase + REG_C0C + chan * 8);
/* Load the counter from PR0 */ /* Load the counter from PR0 */
outw(0x4000, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x4000, dev->iobase + REG_C0C + chan * 8);
/* Reset RCAP (fires one-shot) */ /* Reset RCAP (fires one-shot) */
outw(0x0008, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x0008, dev->iobase + REG_C0C + chan * 8);
#endif #endif
#if 1 #if 1
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = data[1] & 0xFFFF; cmReg.value = data[1] & 0xFFFF;
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Reset the counter if it is software preload */ /* Reset the counter if it is software preload */
if (cmReg.reg.autoLoadResetRcap == 0) { if (cmReg.reg.autoLoadResetRcap == 0) {
/* Reset the counter */ /* Reset the counter */
outw(0x8000, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x8000, dev->iobase + REG_C0C + chan * 8);
/* Load the counter from PR0 /* Load the counter from PR0
* outw(0x4000, dev->iobase + REG_C0C + subdev_channel * 8); * outw(0x4000, dev->iobase + REG_C0C + chan * 8);
*/ */
} }
#else #else
...@@ -257,27 +256,27 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -257,27 +256,27 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = (short)(data[1] & 0xFFFF); cmReg.value = (short)(data[1] & 0xFFFF);
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Load the pre-load register high word */ /* Load the pre-load register high word */
value = (short)((data[2] >> 16) & 0xFFFF); value = (short)((data[2] >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
/* Load the pre-load register low word */ /* Load the pre-load register low word */
value = (short)(data[2] & 0xFFFF); value = (short)(data[2] & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
/* Write the Counter Control Register */ /* Write the Counter Control Register */
if (data[3] != 0) { if (data[3] != 0) {
value = (short)(data[3] & 0xFFFF); value = (short)(data[3] & 0xFFFF);
outw(value, dev->iobase + REG_C0C + subdev_channel * 8); outw(value, dev->iobase + REG_C0C + chan * 8);
} }
/* Reset the counter if it is software preload */ /* Reset the counter if it is software preload */
if (cmReg.reg.autoLoadResetRcap == 0) { if (cmReg.reg.autoLoadResetRcap == 0) {
/* Reset the counter */ /* Reset the counter */
outw(0x8000, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x8000, dev->iobase + REG_C0C + chan * 8);
/* Load the counter from PR0 */ /* Load the counter from PR0 */
outw(0x4000, dev->iobase + REG_C0C + subdev_channel * 8); outw(0x4000, dev->iobase + REG_C0C + chan * 8);
} }
#endif #endif
break; break;
...@@ -290,39 +289,38 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -290,39 +289,38 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
data[3]: Pre-load Register 1 Value data[3]: Pre-load Register 1 Value
data[4]: Conter Control Register data[4]: Conter Control Register
*/ */
devpriv->s526_gpct_config[subdev_channel].app = devpriv->s526_gpct_config[chan].app = SinglePulseGeneration;
SinglePulseGeneration;
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = (short)(data[1] & 0xFFFF); cmReg.value = (short)(data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Load the pre-load register 0 high word */ /* Load the pre-load register 0 high word */
value = (short)((data[2] >> 16) & 0xFFFF); value = (short)((data[2] >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
/* Load the pre-load register 0 low word */ /* Load the pre-load register 0 low word */
value = (short)(data[2] & 0xFFFF); value = (short)(data[2] & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = (short)(data[1] & 0xFFFF); cmReg.value = (short)(data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; /* PR1 */ cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Load the pre-load register 1 high word */ /* Load the pre-load register 1 high word */
value = (short)((data[3] >> 16) & 0xFFFF); value = (short)((data[3] >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
/* Load the pre-load register 1 low word */ /* Load the pre-load register 1 low word */
value = (short)(data[3] & 0xFFFF); value = (short)(data[3] & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
/* Write the Counter Control Register */ /* Write the Counter Control Register */
if (data[4] != 0) { if (data[4] != 0) {
value = (short)(data[4] & 0xFFFF); value = (short)(data[4] & 0xFFFF);
outw(value, dev->iobase + REG_C0C + subdev_channel * 8); outw(value, dev->iobase + REG_C0C + chan * 8);
} }
break; break;
...@@ -334,39 +332,38 @@ static int s526_gpct_insn_config(struct comedi_device *dev, ...@@ -334,39 +332,38 @@ static int s526_gpct_insn_config(struct comedi_device *dev,
data[3]: Pre-load Register 1 Value data[3]: Pre-load Register 1 Value
data[4]: Conter Control Register data[4]: Conter Control Register
*/ */
devpriv->s526_gpct_config[subdev_channel].app = devpriv->s526_gpct_config[chan].app = PulseTrainGeneration;
PulseTrainGeneration;
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = (short)(data[1] & 0xFFFF); cmReg.value = (short)(data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; /* PR0 */ cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Load the pre-load register 0 high word */ /* Load the pre-load register 0 high word */
value = (short)((data[2] >> 16) & 0xFFFF); value = (short)((data[2] >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
/* Load the pre-load register 0 low word */ /* Load the pre-load register 0 low word */
value = (short)(data[2] & 0xFFFF); value = (short)(data[2] & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
/* Set Counter Mode Register */ /* Set Counter Mode Register */
cmReg.value = (short)(data[1] & 0xFFFF); cmReg.value = (short)(data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; /* PR1 */ cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, dev->iobase + REG_C0M + subdev_channel * 8); outw(cmReg.value, dev->iobase + REG_C0M + chan * 8);
/* Load the pre-load register 1 high word */ /* Load the pre-load register 1 high word */
value = (short)((data[3] >> 16) & 0xFFFF); value = (short)((data[3] >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
/* Load the pre-load register 1 low word */ /* Load the pre-load register 1 low word */
value = (short)(data[3] & 0xFFFF); value = (short)(data[3] & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
/* Write the Counter Control Register */ /* Write the Counter Control Register */
if (data[4] != 0) { if (data[4] != 0) {
value = (short)(data[4] & 0xFFFF); value = (short)(data[4] & 0xFFFF);
outw(value, dev->iobase + REG_C0C + subdev_channel * 8); outw(value, dev->iobase + REG_C0C + chan * 8);
} }
break; break;
...@@ -383,23 +380,21 @@ static int s526_gpct_winsn(struct comedi_device *dev, ...@@ -383,23 +380,21 @@ static int s526_gpct_winsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */ unsigned int chan = CR_CHAN(insn->chanspec);
short value; short value;
union cmReg cmReg; union cmReg cmReg;
cmReg.value = inw(dev->iobase + REG_C0M + subdev_channel * 8); cmReg.value = inw(dev->iobase + REG_C0M + chan * 8);
/* Check what Application of Counter this channel is configured for */ /* Check what Application of Counter this channel is configured for */
switch (devpriv->s526_gpct_config[subdev_channel].app) { switch (devpriv->s526_gpct_config[chan].app) {
case PositionMeasurement: case PositionMeasurement:
outw(0xFFFF & ((*data) >> 16), dev->iobase + REG_C0H + outw(0xFFFF & ((*data) >> 16), dev->iobase + REG_C0H + chan * 8);
subdev_channel * 8); outw(0xFFFF & (*data), dev->iobase + REG_C0L + chan * 8);
outw(0xFFFF & (*data), dev->iobase + REG_C0L + subdev_channel * 8);
break; break;
case SinglePulseGeneration: case SinglePulseGeneration:
outw(0xFFFF & ((*data) >> 16), dev->iobase + REG_C0H + outw(0xFFFF & ((*data) >> 16), dev->iobase + REG_C0H + chan * 8);
subdev_channel * 8); outw(0xFFFF & (*data), dev->iobase + REG_C0L + chan * 8);
outw(0xFFFF & (*data), dev->iobase + REG_C0L + subdev_channel * 8);
break; break;
case PulseTrainGeneration: case PulseTrainGeneration:
...@@ -410,18 +405,16 @@ static int s526_gpct_winsn(struct comedi_device *dev, ...@@ -410,18 +405,16 @@ static int s526_gpct_winsn(struct comedi_device *dev,
pulse frequency on the selected source pulse frequency on the selected source
*/ */
if ((data[1] > data[0]) && (data[0] > 0)) { if ((data[1] > data[0]) && (data[0] > 0)) {
(devpriv->s526_gpct_config[subdev_channel]).data[0] = (devpriv->s526_gpct_config[chan]).data[0] = data[0];
data[0]; (devpriv->s526_gpct_config[chan]).data[1] = data[1];
(devpriv->s526_gpct_config[subdev_channel]).data[1] =
data[1];
} else { } else {
return -EINVAL; return -EINVAL;
} }
value = (short)((*data >> 16) & 0xFFFF); value = (short)((*data >> 16) & 0xFFFF);
outw(value, dev->iobase + REG_C0H + subdev_channel * 8); outw(value, dev->iobase + REG_C0H + chan * 8);
value = (short)(*data & 0xFFFF); value = (short)(*data & 0xFFFF);
outw(value, dev->iobase + REG_C0L + subdev_channel * 8); outw(value, dev->iobase + REG_C0L + chan * 8);
break; break;
default: /* Impossible */ default: /* Impossible */
return -EINVAL; return -EINVAL;
...@@ -466,8 +459,8 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -466,8 +459,8 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int n, i; int n, i;
int chan = CR_CHAN(insn->chanspec);
unsigned short value; unsigned short value;
unsigned int d; unsigned int d;
unsigned int status; unsigned int status;
...@@ -509,9 +502,9 @@ static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -509,9 +502,9 @@ static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
int i; unsigned int chan = CR_CHAN(insn->chanspec);
int chan = CR_CHAN(insn->chanspec);
unsigned short val; unsigned short val;
int i;
val = chan << 1; val = chan << 1;
outw(val, dev->iobase + REG_DAC); outw(val, dev->iobase + REG_DAC);
...@@ -530,8 +523,8 @@ static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -530,8 +523,8 @@ static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int i; int i;
int chan = CR_CHAN(insn->chanspec);
for (i = 0; i < insn->n; i++) for (i = 0; i < insn->n; i++)
data[i] = devpriv->ao_readback[chan]; data[i] = devpriv->ao_readback[chan];
...@@ -559,7 +552,7 @@ static int s526_dio_insn_config(struct comedi_device *dev, ...@@ -559,7 +552,7 @@ static int s526_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
int group, mask; int group, mask;
group = chan >> 2; group = chan >> 2;
......
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