staging: comedi: remove unneeded sanity check in insn_bits functions

The comedi core does the sanity check to make sure that the data length
the INSN_BITS instruction is 2. There is no need for the drivers to do
this check. Remove all the sanity checks in the drivers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2012-06-18 11:18:25 -07:00 committed by Greg Kroah-Hartman
parent 60ff461067
commit 520706607b
43 changed files with 3 additions and 199 deletions

View File

@ -139,9 +139,6 @@ static int subdev_8255_insn(struct comedi_device *dev,
unsigned int bits;
unsigned int v;
if (insn->n != 2)
return -EINVAL;
mask = data[0];
bits = data[1];

View File

@ -31,9 +31,6 @@ static int acl7225b_do_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -53,9 +50,6 @@ static int acl7225b_di_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + (unsigned long)s->private) |
(inb(dev->iobase + (unsigned long)s->private + 1) << 8);

View File

@ -141,8 +141,6 @@ static int pci6208_ao_rinsn(struct comedi_device *dev,
* struct comedi_subdevice *s, */
/* struct comedi_insn *insn,unsigned int *data) */
/* { */
/* if(insn->n!=2)return -EINVAL; */
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
/* if(data[0]){ */

View File

@ -54,9 +54,6 @@ static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -72,9 +69,6 @@ static int adl_pci7230_di_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff;
return 2;

View File

@ -57,9 +57,6 @@ static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -79,9 +76,6 @@ static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff;
printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]);

View File

@ -70,9 +70,6 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@ -91,9 +88,6 @@ static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = 0;
data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;

View File

@ -185,9 +185,6 @@ static int pc263_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -549,9 +549,6 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -133,8 +133,6 @@ static int bonding_dio_insn_bits(struct comedi_device *dev,
{
#define LSAMPL_BITS (sizeof(unsigned int)*8)
unsigned nchans = LSAMPL_BITS, num_done = 0, i;
if (insn->n != 2)
return -EINVAL;
if (devpriv->nchans < nchans)
nchans = devpriv->nchans;

View File

@ -162,9 +162,6 @@ static int parport_intr_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
data[1] = 0;
return 2;
}

View File

@ -74,9 +74,6 @@ static int contec_do_insn_bits(struct comedi_device *dev,
dev_dbg(dev->class_dev, "contec_do_insn_bits called\n");
dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@ -95,9 +92,6 @@ static int contec_di_insn_bits(struct comedi_device *dev,
dev_dbg(dev->class_dev, "contec_di_insn_bits called\n");
dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
data[1] = inw(dev->iobase + thisboard->in_offs);
return 2;

View File

@ -914,9 +914,6 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev,
{
unsigned char diobits;
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -535,8 +535,6 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev,
if (s == dev->subdevices + 4)
which = 1;
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);

View File

@ -352,9 +352,6 @@ static int dt2811_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + DT2811_DIO);
return 2;
@ -364,9 +361,6 @@ static int dt2811_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
s->state &= ~data[0];
s->state |= data[0] & data[1];
outb(s->state, dev->iobase + DT2811_DIO);

View File

@ -745,9 +745,6 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[1] & data[0];

View File

@ -189,9 +189,6 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
{
u16 d = 0;
if (insn->n != 2)
return -EINVAL;
mutex_lock(&devpriv->mutex);
smp_mb();
d = inw_p(devpriv->BADR3);
@ -209,9 +206,6 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit.
* s->state contains the previous write data

View File

@ -1643,17 +1643,6 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
/* Length of data must be 2 (mask and new data, see below) */
if (insn->n == 0)
return 0;
if (insn->n != 2) {
printk
("comedi%d: me4000: me4000_dio_insn_bits(): "
"Invalid instruction length\n", dev->minor);
return -EINVAL;
}
/*
* The insn data consists of a mask in data[0] and the new data
* in data[1]. The mask defines which bits we are concerning about.

View File

@ -161,9 +161,6 @@ static int multiq3_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inw(dev->iobase + MULTIQ3_DIGIN_PORT);
return 2;
@ -173,9 +170,6 @@ static int multiq3_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outw(s->state, dev->iobase + MULTIQ3_DIGOUT_PORT);

View File

@ -174,9 +174,6 @@ static int ni6527_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = readb(devpriv->mite->daq_io_addr + Port_Register(0));
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(1)) << 8;
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(2)) << 16;
@ -188,8 +185,6 @@ static int ni6527_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -339,9 +334,6 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
data[1] = 0;
return 2;
}

View File

@ -415,8 +415,7 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
const unsigned max_ports_per_bitfield = 5;
unsigned read_bits = 0;
unsigned j;
if (insn->n != 2)
return -EINVAL;
base_bitfield_channel = CR_CHAN(insn->chanspec);
for (j = 0; j < max_ports_per_bitfield; ++j) {
const unsigned port_offset =
@ -602,9 +601,6 @@ static int ni_65xx_intr_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
data[1] = 0;
return 2;
}

View File

@ -306,9 +306,6 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -239,9 +239,6 @@ static int atao_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -599,9 +599,6 @@ static int atmio16d_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] | data[1]);

View File

@ -3567,8 +3567,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev,
#ifdef DEBUG_DIO
printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
#endif
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
/* Perform check to make sure we're not using the
serial part of the dio */
@ -3629,8 +3628,7 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
data[1]);
#endif
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -5485,9 +5483,6 @@ static int ni_rtsi_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = 0;
return 2;

View File

@ -745,8 +745,6 @@ static int ni_pcidio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);

View File

@ -449,9 +449,6 @@ static int pcl711_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + PCL711_DI_LO) |
(inb(dev->iobase + PCL711_DI_HI) << 8);
@ -463,9 +460,6 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -23,9 +23,6 @@ Devices: [Advantech] PCL-725 (pcl725)
static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -40,9 +37,6 @@ static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
static int pcl725_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + PCL725_DI);
return 2;

View File

@ -197,9 +197,6 @@ static int pcl726_di_insn_bits(struct comedi_device *dev,
{
const struct pcl726_board *board = comedi_board(dev);
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + board->di_lo) |
(inb(dev->iobase + board->di_hi) << 8);
@ -212,9 +209,6 @@ static int pcl726_do_insn_bits(struct comedi_device *dev,
{
const struct pcl726_board *board = comedi_board(dev);
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -35,9 +35,6 @@ struct pcl730_board {
static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -57,9 +54,6 @@ static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
static int pcl730_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + ((unsigned long)s->private)) |
(inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);

View File

@ -501,9 +501,6 @@ static int pcl812_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + PCL812_DI_LO);
data[1] |= inb(dev->iobase + PCL812_DI_HI) << 8;
@ -517,9 +514,6 @@ static int pcl812_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -442,9 +442,6 @@ static int pcl818_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + PCL818_DI_LO) |
(inb(dev->iobase + PCL818_DI_HI) << 8);
@ -461,9 +458,6 @@ static int pcl818_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
s->state &= ~data[0];
s->state |= (data[0] & data[1]);

View File

@ -32,8 +32,6 @@ static int pcm3730_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@ -48,8 +46,6 @@ static int pcm3730_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + (unsigned long)(s->private));
return 2;
}

View File

@ -275,8 +275,6 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
if (insn->n != 2)
return -EINVAL;
/* NOTE:
reading a 0 means this channel was high

View File

@ -211,8 +211,6 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
if (insn->n != 2)
return -EINVAL;
/* NOTE:
reading a 0 means this channel was high

View File

@ -99,9 +99,6 @@ static int pcl733_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + 0);
data[1] |= (inb(dev->iobase + 1) << 8);
data[1] |= (inb(dev->iobase + 2) << 16);
@ -114,8 +111,6 @@ static int pcl734_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);

View File

@ -1811,9 +1811,6 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -263,8 +263,6 @@ static int rti800_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + RTI800_DI);
return 2;
}
@ -273,9 +271,6 @@ static int rti800_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];

View File

@ -678,9 +678,6 @@ static int s526_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -2140,18 +2140,6 @@ static int s626_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
/* Length of data must be 2 (mask and new data, see below) */
if (insn->n == 0)
return 0;
if (insn->n != 2) {
printk
("comedi%d: s626: s626_dio_insn_bits(): Invalid instruction length\n",
dev->minor);
return -EINVAL;
}
/*
* The insn data consists of a mask in data[0] and the new data in
* data[1]. The mask defines which bits we are concerning about.

View File

@ -561,9 +561,6 @@ static int skel_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {

View File

@ -77,10 +77,6 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL; /* insn uses data[0] and data[1] */
/* The insn data is a mask in data[0] and the new data in data[1], */
/* each channel cooresponding to a bit. */

View File

@ -1780,9 +1780,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
if (!this_usbduxsub)
return -EFAULT;
if (insn->n != 2)
return -EINVAL;
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {

View File

@ -1845,9 +1845,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
if (!this_usbduxsub)
return -EFAULT;
if (insn->n != 2)
return -EINVAL;
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {