]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Staging: comedi: ni_mio_common: Fix endian sparse warning
authorKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Sat, 31 Oct 2015 13:34:29 +0000 (06:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Nov 2015 04:02:47 +0000 (20:02 -0800)
Fix following sparse warnings:
warning: cast to restricted __le32
warning: cast to restricted __le16
warning: incorrect type in assignment (different base types)
expected unsigned short [unsigned] [assigned] val
got restricted __le16 [usertype] <noident>

Data is pointer of type void and can be used to store any type of data.
In function ni_ai_munge:
barray and array have the same 16 bit offset.
blarray and larray have the same 32 bit offset.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_mio_common.c

index 6cc304a4c59bfca17a6055d99631424ebeafa09f..cbb44fc6940bc6f57a49b5ce07521ac2f037144d 100644 (file)
@@ -1516,13 +1516,17 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
        unsigned short *array = data;
        unsigned int *larray = data;
        unsigned int i;
+#ifdef PCIDMA
+       __le16 *barray = data;
+       __le32 *blarray = data;
+#endif
 
        for (i = 0; i < nsamples; i++) {
 #ifdef PCIDMA
                if (s->subdev_flags & SDF_LSAMPL)
-                       larray[i] = le32_to_cpu(larray[i]);
+                       larray[i] = le32_to_cpu(blarray[i]);
                else
-                       array[i] = le16_to_cpu(array[i]);
+                       array[i] = le16_to_cpu(barray[i]);
 #endif
                if (s->subdev_flags & SDF_LSAMPL)
                        larray[i] += devpriv->ai_offset[chan_index];
@@ -2574,6 +2578,9 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
        unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes);
        unsigned short *array = data;
        unsigned int i;
+#ifdef PCIDMA
+       __le16 buf, *barray = data;
+#endif
 
        for (i = 0; i < nsamples; i++) {
                unsigned int range = CR_RANGE(cmd->chanlist[chan_index]);
@@ -2586,10 +2593,11 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
                if (comedi_range_is_bipolar(s, range))
                        val = comedi_offset_munge(s, val);
 #ifdef PCIDMA
-               val = cpu_to_le16(val);
-#endif
+               buf = cpu_to_le16(val);
+               barray[i] = buf;
+#else
                array[i] = val;
-
+#endif
                chan_index++;
                chan_index %= cmd->chanlist_len;
        }