]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/comedi/drivers/ni_mio_common.c
arm: imx6: defconfig: update tx6 defconfigs
[karo-tx-linux.git] / drivers / staging / comedi / drivers / ni_mio_common.c
index 4e02770e834bd7df20e8f015c92750ba4efb05a1..5113397bfecf4c864a48aeca9ccd7cd7f718b60c 100644 (file)
@@ -1292,7 +1292,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
        struct comedi_cmd *cmd = &async->cmd;
        int chan;
        int i;
-       short d;
+       unsigned short d;
        u32 packed_data;
        int range;
        int err = 1;
@@ -1403,7 +1403,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
        int i;
 
        if (board->reg_type == ni_reg_611x) {
-               short data[2];
+               unsigned short data[2];
                u32 dl;
 
                for (i = 0; i < n / 2; i++) {
@@ -1420,7 +1420,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                        cfc_write_to_buffer(s, data[0]);
                }
        } else if (board->reg_type == ni_reg_6143) {
-               short data[2];
+               unsigned short data[2];
                u32 dl;
 
                /*  This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */
@@ -1511,9 +1511,9 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
        struct comedi_subdevice *s = &dev->subdevices[NI_AI_SUBDEV];
-       short data[2];
+       unsigned short data[2];
        u32 dl;
-       short fifo_empty;
+       unsigned short fifo_empty;
        int i;
 
        if (board->reg_type == ni_reg_611x) {
@@ -1577,7 +1577,7 @@ static void get_last_sample_611x(struct comedi_device *dev)
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv __maybe_unused = dev->private;
        struct comedi_subdevice *s = &dev->subdevices[NI_AI_SUBDEV];
-       short data;
+       unsigned short data;
        u32 dl;
 
        if (board->reg_type != ni_reg_611x)
@@ -1596,7 +1596,7 @@ static void get_last_sample_6143(struct comedi_device *dev)
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv __maybe_unused = dev->private;
        struct comedi_subdevice *s = &dev->subdevices[NI_AI_SUBDEV];
-       short data;
+       unsigned short data;
        u32 dl;
 
        if (board->reg_type != ni_reg_6143)
@@ -1621,7 +1621,7 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
        struct comedi_async *async = s->async;
        unsigned int i;
        unsigned int length = num_bytes / bytes_per_sample(s);
-       short *array = data;
+       unsigned short *array = data;
        unsigned int *larray = data;
 
        for (i = 0; i < length; i++) {
@@ -2873,7 +2873,7 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
        unsigned int i;
        unsigned int offset;
        unsigned int length = num_bytes / sizeof(short);
-       short *array = data;
+       unsigned short *array = data;
 
        offset = 1 << (board->aobits - 1);
        for (i = 0; i < length; i++) {
@@ -3547,28 +3547,22 @@ static int ni_dio_insn_config(struct comedi_device *dev,
 
 static int ni_dio_insn_bits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
-                           struct comedi_insn *insn, unsigned int *data)
+                           struct comedi_insn *insn,
+                           unsigned int *data)
 {
        struct ni_private *devpriv = dev->private;
 
-#ifdef DEBUG_DIO
-       printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
-#endif
-
-       if (data[0]) {
-               /* Perform check to make sure we're not using the
-                  serial part of the dio */
-               if ((data[0] & (DIO_SDIN | DIO_SDOUT))
-                   && devpriv->serial_interval_ns)
-                       return -EBUSY;
+       /* Make sure we're not using the serial part of the dio */
+       if ((data[0] & (DIO_SDIN | DIO_SDOUT)) && devpriv->serial_interval_ns)
+               return -EBUSY;
 
-               s->state &= ~data[0];
-               s->state |= (data[0] & data[1]);
+       if (comedi_dio_update_state(s, data)) {
                devpriv->dio_output &= ~DIO_Parallel_Data_Mask;
                devpriv->dio_output |= DIO_Parallel_Data_Out(s->state);
                devpriv->stc_writew(dev, devpriv->dio_output,
                                    DIO_Output_Register);
        }
+
        data[1] = devpriv->stc_readw(dev, DIO_Parallel_Input_Register);
 
        return insn->n;
@@ -3598,16 +3592,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
 {
        struct ni_private *devpriv __maybe_unused = dev->private;
 
-#ifdef DEBUG_DIO
-       printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
-              data[1]);
-#endif
-
-       if (data[0]) {
-               s->state &= ~data[0];
-               s->state |= (data[0] & data[1]);
+       if (comedi_dio_update_state(s, data))
                ni_writel(s->state, M_Offset_Static_Digital_Output);
-       }
+
        data[1] = ni_readl(M_Offset_Static_Digital_Input);
 
        return insn->n;
@@ -5355,20 +5342,20 @@ static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel,
 
 static int ni_pfi_insn_bits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
-                           struct comedi_insn *insn, unsigned int *data)
+                           struct comedi_insn *insn,
+                           unsigned int *data)
 {
        const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv __maybe_unused = dev->private;
 
-       if ((board->reg_type & ni_reg_m_series_mask) == 0) {
+       if (!(board->reg_type & ni_reg_m_series_mask))
                return -ENOTSUPP;
-       }
-       if (data[0]) {
-               s->state &= ~data[0];
-               s->state |= (data[0] & data[1]);
+
+       if (comedi_dio_update_state(s, data))
                ni_writew(s->state, M_Offset_PFI_DO);
-       }
+
        data[1] = ni_readw(M_Offset_PFI_DI);
+
        return insn->n;
 }