Staging: comedi: das16: Fix sparse endian warning
authorKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Fri, 30 Oct 2015 04:58:16 +0000 (21:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Nov 2015 04:02:47 +0000 (20:02 -0800)
Fix following sparse warning:
warning: cast to restricted __le16

This change is safe because array is pointer of type void and can
be used to store any type of data, also offset of the array would
be the same since unsigned short and __le16 are both 16 bits in size.

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

index 056bca9c67d5d637885073a3b635e625c1f392dd..fd8e0b76f7646362f2ba90a2ca9760f79d0a4069 100644 (file)
@@ -801,9 +801,10 @@ static void das16_ai_munge(struct comedi_device *dev,
        unsigned short *data = array;
        unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes);
        unsigned int i;
+       __le16 *buf = array;
 
        for (i = 0; i < num_samples; i++) {
-               data[i] = le16_to_cpu(data[i]);
+               data[i] = le16_to_cpu(buf[i]);
                if (s->maxdata == 0x0fff)
                        data[i] >>= 4;
                data[i] &= s->maxdata;