* [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone
@ 2018-01-16 11:43 Dan Carpenter
2018-01-16 12:47 ` Arnaud Pouliquen
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2018-01-16 11:43 UTC (permalink / raw)
To: arnaud.pouliquen
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Arnaud Pouliquen, linux-iio
Hello Arnaud Pouliquen,
The patch eca949800d2d: "IIO: ADC: add stm32 DFSDM support for PDM
microphone" from Jan 10, 2018, leads to the following static checker
warning:
drivers/iio/adc/stm32-dfsdm-adc.c:555 stm32_dfsdm_audio_dma_buffer_done()
warn: potential shift truncation. '0xffffff00 (0,256-4294967040) << 8'
drivers/iio/adc/stm32-dfsdm-adc.c
551 while (available >= indio_dev->scan_bytes) {
552 u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
553
554 /* Mask 8 LSB that contains the channel ID */
555 *buffer = (*buffer & 0xFFFFFF00) << 8;
Is this shift, correct? The comment just mentions that we're masking
out the low bits.
556 available -= indio_dev->scan_bytes;
557 adc->bufi += indio_dev->scan_bytes;
558 if (adc->bufi >= adc->buf_sz) {
559 if (adc->cb)
560 adc->cb(&adc->rx_buf[old_pos],
561 adc->buf_sz - old_pos, adc->cb_priv);
562 adc->bufi = 0;
563 old_pos = 0;
564 }
565 }
566 if (adc->cb)
567 adc->cb(&adc->rx_buf[old_pos], adc->bufi - old_pos,
568 adc->cb_priv);
569 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone
2018-01-16 11:43 [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone Dan Carpenter
@ 2018-01-16 12:47 ` Arnaud Pouliquen
2018-01-16 12:50 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Arnaud Pouliquen @ 2018-01-16 12:47 UTC (permalink / raw)
To: Dan Carpenter
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio
Hello Dan
On 01/16/2018 12:43 PM, Dan Carpenter wrote:
> Hello Arnaud Pouliquen,
>
> The patch eca949800d2d: "IIO: ADC: add stm32 DFSDM support for PDM
> microphone" from Jan 10, 2018, leads to the following static checker
> warning:
>
> drivers/iio/adc/stm32-dfsdm-adc.c:555 stm32_dfsdm_audio_dma_buffer_done()
> warn: potential shift truncation. '0xffffff00 (0,256-4294967040) << 8'
>
> drivers/iio/adc/stm32-dfsdm-adc.c
> 551 while (available >= indio_dev->scan_bytes) {
> 552 u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
> 553
> 554 /* Mask 8 LSB that contains the channel ID */
> 555 *buffer = (*buffer & 0xFFFFFF00) << 8;
>
> Is this shift, correct? The comment just mentions that we're masking
> out the low bits.
Yes mask and shift are not correlated.
The Mask suppresses the 8 LSB that contain ID of the channel scanned
The shift is used for the 24 to 32 bits sample conversion.
Regards,
Arnaud
>
> 556 available -= indio_dev->scan_bytes;
> 557 adc->bufi += indio_dev->scan_bytes;
> 558 if (adc->bufi >= adc->buf_sz) {
> 559 if (adc->cb)
> 560 adc->cb(&adc->rx_buf[old_pos],
> 561 adc->buf_sz - old_pos, adc->cb_priv);
> 562 adc->bufi = 0;
> 563 old_pos = 0;
> 564 }
> 565 }
> 566 if (adc->cb)
> 567 adc->cb(&adc->rx_buf[old_pos], adc->bufi - old_pos,
> 568 adc->cb_priv);
> 569 }
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone
2018-01-16 12:47 ` Arnaud Pouliquen
@ 2018-01-16 12:50 ` Dan Carpenter
2018-01-16 13:03 ` Arnaud Pouliquen
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2018-01-16 12:50 UTC (permalink / raw)
To: Arnaud Pouliquen
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio
On Tue, Jan 16, 2018 at 01:47:29PM +0100, Arnaud Pouliquen wrote:
> Hello Dan
>
> On 01/16/2018 12:43 PM, Dan Carpenter wrote:
> > Hello Arnaud Pouliquen,
> >
> > The patch eca949800d2d: "IIO: ADC: add stm32 DFSDM support for PDM
> > microphone" from Jan 10, 2018, leads to the following static checker
> > warning:
> >
> > drivers/iio/adc/stm32-dfsdm-adc.c:555 stm32_dfsdm_audio_dma_buffer_done()
> > warn: potential shift truncation. '0xffffff00 (0,256-4294967040) << 8'
> >
> > drivers/iio/adc/stm32-dfsdm-adc.c
> > 551 while (available >= indio_dev->scan_bytes) {
> > 552 u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
> > 553
> > 554 /* Mask 8 LSB that contains the channel ID */
> > 555 *buffer = (*buffer & 0xFFFFFF00) << 8;
> >
> > Is this shift, correct? The comment just mentions that we're masking
> > out the low bits.
> Yes mask and shift are not correlated.
> The Mask suppresses the 8 LSB that contain ID of the channel scanned
> The shift is used for the 24 to 32 bits sample conversion.
>
If you wanted to silence the static checker warning you could change the
mask to:
*buffer = (*buffer & 0x00FFFF00) << 8;
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone
2018-01-16 12:50 ` Dan Carpenter
@ 2018-01-16 13:03 ` Arnaud Pouliquen
2018-01-16 13:08 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Arnaud Pouliquen @ 2018-01-16 13:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio
On 01/16/2018 01:50 PM, Dan Carpenter wrote:
> On Tue, Jan 16, 2018 at 01:47:29PM +0100, Arnaud Pouliquen wrote:
>> Hello Dan
>>
>> On 01/16/2018 12:43 PM, Dan Carpenter wrote:
>>> Hello Arnaud Pouliquen,
>>>
>>> The patch eca949800d2d: "IIO: ADC: add stm32 DFSDM support for PDM
>>> microphone" from Jan 10, 2018, leads to the following static checker
>>> warning:
>>>
>>> drivers/iio/adc/stm32-dfsdm-adc.c:555 stm32_dfsdm_audio_dma_buffer_done()
>>> warn: potential shift truncation. '0xffffff00 (0,256-4294967040) << 8'
>>>
>>> drivers/iio/adc/stm32-dfsdm-adc.c
>>> 551 while (available >= indio_dev->scan_bytes) {
>>> 552 u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
>>> 553
>>> 554 /* Mask 8 LSB that contains the channel ID */
>>> 555 *buffer = (*buffer & 0xFFFFFF00) << 8;
>>>
>>> Is this shift, correct? The comment just mentions that we're masking
>>> out the low bits.
>> Yes mask and shift are not correlated.
>> The Mask suppresses the 8 LSB that contain ID of the channel scanned
>> The shift is used for the 24 to 32 bits sample conversion.
>>
>
> If you wanted to silence the static checker warning you could change the
> mask to:
>
> *buffer = (*buffer & 0x00FFFF00) << 8;
Thanks for the proposal, fill free to send the patch, otherwise i will
add it in next patch series.
For my personal information which static checker warns on this line?
Regards
Arnaud
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone
2018-01-16 13:03 ` Arnaud Pouliquen
@ 2018-01-16 13:08 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-01-16 13:08 UTC (permalink / raw)
To: Arnaud Pouliquen
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio
On Tue, Jan 16, 2018 at 02:03:49PM +0100, Arnaud Pouliquen wrote:
>
>
> On 01/16/2018 01:50 PM, Dan Carpenter wrote:
> > On Tue, Jan 16, 2018 at 01:47:29PM +0100, Arnaud Pouliquen wrote:
> >> Hello Dan
> >>
> >> On 01/16/2018 12:43 PM, Dan Carpenter wrote:
> >>> Hello Arnaud Pouliquen,
> >>>
> >>> The patch eca949800d2d: "IIO: ADC: add stm32 DFSDM support for PDM
> >>> microphone" from Jan 10, 2018, leads to the following static checker
> >>> warning:
> >>>
> >>> drivers/iio/adc/stm32-dfsdm-adc.c:555 stm32_dfsdm_audio_dma_buffer_done()
> >>> warn: potential shift truncation. '0xffffff00 (0,256-4294967040) << 8'
> >>>
> >>> drivers/iio/adc/stm32-dfsdm-adc.c
> >>> 551 while (available >= indio_dev->scan_bytes) {
> >>> 552 u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
> >>> 553
> >>> 554 /* Mask 8 LSB that contains the channel ID */
> >>> 555 *buffer = (*buffer & 0xFFFFFF00) << 8;
> >>>
> >>> Is this shift, correct? The comment just mentions that we're masking
> >>> out the low bits.
> >> Yes mask and shift are not correlated.
> >> The Mask suppresses the 8 LSB that contain ID of the channel scanned
> >> The shift is used for the 24 to 32 bits sample conversion.
> >>
> >
> > If you wanted to silence the static checker warning you could change the
> > mask to:
> >
> > *buffer = (*buffer & 0x00FFFF00) << 8;
>
> Thanks for the proposal, fill free to send the patch, otherwise i will
> add it in next patch series.
> For my personal information which static checker warns on this line?
It's some Smatch stuff that has too many false positives so I review it
but haven't published it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-16 13:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 11:43 [bug report] IIO: ADC: add stm32 DFSDM support for PDM microphone Dan Carpenter
2018-01-16 12:47 ` Arnaud Pouliquen
2018-01-16 12:50 ` Dan Carpenter
2018-01-16 13:03 ` Arnaud Pouliquen
2018-01-16 13:08 ` Dan Carpenter
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.