Staging: comedi: Fix sparse warnings
v2 cover Staging: comedi: Fix sparse warnings
Fix sparse endian warnings in ni_mio_common and adl_pci9118.
I didn't fix warnings of ni_pcimio driver because it seems more complex and one solution that I see is to change struct ni_private with adding a new field (unsigned int), but I don't know if that's a valid solution.
Changes in v2:
-fix build warnings caused by changes in v1
Ksenija Stanojevic (2):
Staging: comedi: ni_mio_common: Fix endian sparse warning
Staging: comedi: adl_pci9118: Fix endian sparse warning
drivers/staging/comedi/drivers/adl_pci9118.c | 3 ++- drivers/staging/comedi/drivers/ni_mio_common.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/2 Staging: comedi: ni_mio_common: Fix endian sparse warning
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.
---
Changes in v2:
- fix build warning caused by changes in v1.
drivers/staging/comedi/drivers/ni_mio_common.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/staging/comedi/drivers/ni_mio_common.c +13 -5
@@ -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; }
Signature · 1 line
1.9.1
PATCH v2 2/2 Staging: comedi: adl_pci9118: Fix endian sparse warning
In reply to Ksenija StanojevicFix following sparse warning:
warning: cast to restricted __be16
data is pointer of type void and can be used to store any type of data. barray and array have the same 16 bit offset.
---
Changes in v2:
- none
drivers/staging/comedi/drivers/adl_pci9118.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/adl_pci9118.c +2 -1
@@ -603,10 +603,11 @@ static void pci9118_ai_munge(struct comedi_device *dev,unsigned short *array = data;unsigned int num_samples =comedi_bytes_to_samples (s, num_bytes);unsigned int i; +__be16 *barray = data;for (i =0 ; i < num_samples; i++) {if (devpriv->usedma) - array[i] =be16_to_cpu (array[i]); + array[i] =be16_to_cpu (barray[i]);if (s->maxdata ==0xffff ) array[i] ^=0x8000 ;else
Signature · 1 line
1.9.1