Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337720
b: refs/heads/master
c: 2b70a4f
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Nov 13, 2012
1 parent bea786c commit 0cc5342
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 287 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 10f71c7845686b7f93113f1fe6dbc3718d8a8673
refs/heads/master: 2b70a4f4f97b70e8cd9d8a16983758aa4fc3450b
257 changes: 13 additions & 244 deletions trunk/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,257 +1288,26 @@ static int apci3xxx_di_insn_bits(struct comedi_device *dev,
return insn->n;
}

/*
+----------------------------------------------------------------------------+
| DIGITAL OUTPUT SUBDEVICE |
+----------------------------------------------------------------------------+
*/

/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3XXX_InsnBitsDigitalOutput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Write the selected output mask and read the status from|
| all digital output channles |
+----------------------------------------------------------------------------+
| Input Parameters : dw_ChannelMask = data [0]; |
| dw_BitMask = data [1]; |
+----------------------------------------------------------------------------+
| Output Parameters : data[1] : All digital output channles states |
+----------------------------------------------------------------------------+
| Return Value : >0 : No error |
| -4 : Channel mask error |
| -101 : Data size error |
+----------------------------------------------------------------------------+
*/
static int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = insn->n;
unsigned char b_ChannelCpt = 0;
unsigned int dw_ChannelMask = 0;
unsigned int dw_BitMask = 0;
unsigned int dw_Status = 0;

/************************/
/* Test the buffer size */
/************************/

if (insn->n >= 2) {
/*******************************/
/* Get the channe and bit mask */
/*******************************/

dw_ChannelMask = data[0];
dw_BitMask = data[1];

/*************************/
/* Test the channel mask */
/*************************/

if ((dw_ChannelMask & 0XFFFFFFF0) == 0) {
/*********************************/
/* Test if set/reset any channel */
/*********************************/

if (dw_ChannelMask & 0xF) {
/********************************/
/* Read the digital output port */
/********************************/

dw_Status = inl(devpriv->iobase + 48);

for (b_ChannelCpt = 0; b_ChannelCpt < 4;
b_ChannelCpt++) {
if ((dw_ChannelMask >> b_ChannelCpt) &
1) {
dw_Status =
(dw_Status & (0xF -
(1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
}
}

outl(dw_Status, devpriv->iobase + 48);
}

/********************************/
/* Read the digital output port */
/********************************/

data[1] = inl(devpriv->iobase + 48);
} else {
/************************/
/* Config command error */
/************************/

printk("Channel mask error\n");
i_ReturnValue = -4;
}
} else {
/*******************/
/* Data size error */
/*******************/

printk("Buffer size error\n");
i_ReturnValue = -101;
}

return i_ReturnValue;
}

/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3XXX_InsnWriteDigitalOutput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Set the state from digital output channel |
+----------------------------------------------------------------------------+
| Input Parameters : b_Channel = CR_CHAN(insn->chanspec) |
| b_State = data [0] |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
| Return Value : >0 : No error |
| -3 : Channel selection error |
| -101 : Data size error |
+----------------------------------------------------------------------------+
*/

static int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
static int apci3xxx_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = insn->n;
unsigned char b_Channel = CR_CHAN(insn->chanspec);
unsigned char b_State = 0;
unsigned int dw_Status = 0;

/************************/
/* Test the buffer size */
/************************/
unsigned int mask = data[0];
unsigned int bits = data[1];

if (insn->n >= 1) {
/***************************/
/* Test the channel number */
/***************************/

if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
/*******************/
/* Get the command */
/*******************/

b_State = (unsigned char) data[0];
s->state = inl(devpriv->iobase + 48) & 0xf;
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);

/********************************/
/* Read the digital output port */
/********************************/

dw_Status = inl(devpriv->iobase + 48);

dw_Status =
(dw_Status & (0xF -
(1 << b_Channel))) | ((b_State & 1) <<
b_Channel);
outl(dw_Status, devpriv->iobase + 48);
} else {
/***************************/
/* Channel selection error */
/***************************/

printk("Channel selection error\n");
i_ReturnValue = -3;
}
} else {
/*******************/
/* Data size error */
/*******************/

printk("Buffer size error\n");
i_ReturnValue = -101;
outl(s->state, devpriv->iobase + 48);
}

return i_ReturnValue;
}
data[1] = s->state;

/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3XXX_InsnReadDigitalOutput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Read the state from digital output channel |
+----------------------------------------------------------------------------+
| Input Parameters : b_Channel = CR_CHAN(insn->chanspec) |
+----------------------------------------------------------------------------+
| Output Parameters : b_State = data [0] |
+----------------------------------------------------------------------------+
| Return Value : >0 : No error |
| -3 : Channel selection error |
| -101 : Data size error |
+----------------------------------------------------------------------------+
*/

static int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = insn->n;
unsigned char b_Channel = CR_CHAN(insn->chanspec);
unsigned int dw_Status = 0;

/************************/
/* Test the buffer size */
/************************/

if (insn->n >= 1) {
/***************************/
/* Test the channel number */
/***************************/

if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
/********************************/
/* Read the digital output port */
/********************************/

dw_Status = inl(devpriv->iobase + 48);

dw_Status = (dw_Status >> b_Channel) & 1;
*data = dw_Status;
} else {
/***************************/
/* Channel selection error */
/***************************/

printk("Channel selection error\n");
i_ReturnValue = -3;
}
} else {
/*******************/
/* Data size error */
/*******************/

printk("Buffer size error\n");
i_ReturnValue = -101;
}

return i_ReturnValue;
return insn->n;
}

/*
Expand Down
Loading

0 comments on commit 0cc5342

Please sign in to comment.