All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Staging: comedi: Fix sparse warnings
@ 2015-10-30  5:07 Ksenija Stanojevic
  2015-10-30  5:22 ` [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning Ksenija Stanojevic
  2015-10-30  5:26 ` [PATCH 2/2] Staging: comedi: adl_pci9118: " Ksenija Stanojevic
  0 siblings, 2 replies; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-30  5:07 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Ksenija Stanojevic

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.

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 | 14 +++++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning
  2015-10-30  5:07 [PATCH 0/2] Staging: comedi: Fix sparse warnings Ksenija Stanojevic
@ 2015-10-30  5:22 ` Ksenija Stanojevic
  2015-10-30  7:15   ` [Outreachy kernel] " Sudip Mukherjee
  2015-10-30  5:26 ` [PATCH 2/2] Staging: comedi: adl_pci9118: " Ksenija Stanojevic
  1 sibling, 1 reply; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-30  5:22 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Ksenija Stanojevic

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>
---
Note:
This function even before my changes had a lot of build warnings.
I think it's because some config options are not enabled, but I 
might be wrong.
Also I think I introduced new warnings because PCIDMA is not set:
drivers/staging/comedi/drivers/ni_mio_common.c:1520:10: warning: unused variable ‘blarray’ [-Wunused-variable]
  __le32 *blarray = data;
          ^
drivers/staging/comedi/drivers/ni_mio_common.c:1519:10: warning: unused variable ‘barray’ [-Wunused-variable]
  __le16 *barray = data;

 drivers/staging/comedi/drivers/ni_mio_common.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index 6cc304a..0c034f2 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1516,13 +1516,15 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
 	unsigned short *array = data;
 	unsigned int *larray = data;
 	unsigned int i;
+	__le16 *barray = data;
+	__le32 *blarray = data;
 
 	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 +2576,7 @@ 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;
+	__le16 buf, *barray = data;
 
 	for (i = 0; i < nsamples; i++) {
 		unsigned int range = CR_RANGE(cmd->chanlist[chan_index]);
@@ -2586,10 +2589,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;
 	}
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] Staging: comedi: adl_pci9118: Fix endian sparse warning
  2015-10-30  5:07 [PATCH 0/2] Staging: comedi: Fix sparse warnings Ksenija Stanojevic
  2015-10-30  5:22 ` [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning Ksenija Stanojevic
@ 2015-10-30  5:26 ` Ksenija Stanojevic
  1 sibling, 0 replies; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-30  5:26 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Ksenija Stanojevic

Fix 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.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
 drivers/staging/comedi/drivers/adl_pci9118.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 0dff1db..4437ea3 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -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
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Outreachy kernel] [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning
  2015-10-30  5:22 ` [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning Ksenija Stanojevic
@ 2015-10-30  7:15   ` Sudip Mukherjee
  2015-10-30 15:01     ` Ksenija Stanojević
  0 siblings, 1 reply; 7+ messages in thread
From: Sudip Mukherjee @ 2015-10-30  7:15 UTC (permalink / raw)
  To: Ksenija Stanojevic; +Cc: outreachy-kernel

On Thu, Oct 29, 2015 at 10:22:45PM -0700, Ksenija Stanojevic wrote:
> 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>
> ---

Yes, it introduces build warning. You will have to do the change in such
a way that it does not introduce any new warnings.

regards
sudip


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Outreachy kernel] [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning
  2015-10-30  7:15   ` [Outreachy kernel] " Sudip Mukherjee
@ 2015-10-30 15:01     ` Ksenija Stanojević
  2015-10-31  6:41       ` Sudip Mukherjee
  0 siblings, 1 reply; 7+ messages in thread
From: Ksenija Stanojević @ 2015-10-30 15:01 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: outreachy-kernel

HI Sudip,

On Fri, Oct 30, 2015 at 12:15 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Thu, Oct 29, 2015 at 10:22:45PM -0700, Ksenija Stanojevic wrote:
>> 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>
>> ---
>
> Yes, it introduces build warning. You will have to do the change in such
> a way that it does not introduce any new warnings.

My idea was to place declaration of buf and barray within #ifdef PCIDMA
but in that case I have a new warning:
warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   __le16 buf, *barray = data;
   ^

So, I'm not sure what to do and if it's possible to avoid introducing warnings.

Ksenija


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Outreachy kernel] [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning
  2015-10-30 15:01     ` Ksenija Stanojević
@ 2015-10-31  6:41       ` Sudip Mukherjee
  2015-10-31 13:39         ` Ksenija Stanojević
  0 siblings, 1 reply; 7+ messages in thread
From: Sudip Mukherjee @ 2015-10-31  6:41 UTC (permalink / raw)
  To: Ksenija Stanojević; +Cc: outreachy-kernel

On Fri, Oct 30, 2015 at 08:01:27AM -0700, Ksenija Stanojević wrote:
> HI Sudip,
> 
> On Fri, Oct 30, 2015 at 12:15 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Thu, Oct 29, 2015 at 10:22:45PM -0700, Ksenija Stanojevic wrote:
> >> 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>
> >> ---
> >
> > Yes, it introduces build warning. You will have to do the change in such
> > a way that it does not introduce any new warnings.
> 
> My idea was to place declaration of buf and barray within #ifdef PCIDMA
> but in that case I have a new warning:
> warning: ISO C90 forbids mixed declarations and code
> [-Wdeclaration-after-statement]
>    __le16 buf, *barray = data;
>    ^
> 
> So, I'm not sure what to do and if it's possible to avoid introducing warnings.

Keep the declaration where you have kept it, add another #ifdef PCIDMA
just before the declaration of buf and barray and #endif just after
the declaration.

regards
sudip


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Outreachy kernel] [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning
  2015-10-31  6:41       ` Sudip Mukherjee
@ 2015-10-31 13:39         ` Ksenija Stanojević
  0 siblings, 0 replies; 7+ messages in thread
From: Ksenija Stanojević @ 2015-10-31 13:39 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: outreachy-kernel

On Fri, Oct 30, 2015 at 11:41 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Fri, Oct 30, 2015 at 08:01:27AM -0700, Ksenija Stanojević wrote:
>> HI Sudip,
>>
>> On Fri, Oct 30, 2015 at 12:15 AM, Sudip Mukherjee
>> <sudipm.mukherjee@gmail.com> wrote:
>> > On Thu, Oct 29, 2015 at 10:22:45PM -0700, Ksenija Stanojevic wrote:
>> >> 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>
>> >> ---
>> >
>> > Yes, it introduces build warning. You will have to do the change in such
>> > a way that it does not introduce any new warnings.
>>
>> My idea was to place declaration of buf and barray within #ifdef PCIDMA
>> but in that case I have a new warning:
>> warning: ISO C90 forbids mixed declarations and code
>> [-Wdeclaration-after-statement]
>>    __le16 buf, *barray = data;
>>    ^
>>
>> So, I'm not sure what to do and if it's possible to avoid introducing warnings.
>
> Keep the declaration where you have kept it, add another #ifdef PCIDMA
> just before the declaration of buf and barray and #endif just after
> the declaration.

Thanks!

Ksenija


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-31 13:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-30  5:07 [PATCH 0/2] Staging: comedi: Fix sparse warnings Ksenija Stanojevic
2015-10-30  5:22 ` [PATCH 1/2] Staging: comedi: ni_mio_common: Fix endian sparse warning Ksenija Stanojevic
2015-10-30  7:15   ` [Outreachy kernel] " Sudip Mukherjee
2015-10-30 15:01     ` Ksenija Stanojević
2015-10-31  6:41       ` Sudip Mukherjee
2015-10-31 13:39         ` Ksenija Stanojević
2015-10-30  5:26 ` [PATCH 2/2] Staging: comedi: adl_pci9118: " Ksenija Stanojevic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.