linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: ppc405_dma warnings
  2002-03-14  2:21 ppc405_dma warnings David Gibson
@ 2002-03-13 21:04 ` Armin
  2002-03-14  6:17   ` David Gibson
  0 siblings, 1 reply; 3+ messages in thread
From: Armin @ 2002-03-13 21:04 UTC (permalink / raw)
  To: David Gibson; +Cc: Armin Kuster, linuxppc-embedded


David Gibson wrote:
> Armin,
>
> ppc405_dma.c has several constructs like:
> 	p_dma_ch->polarity = polarity & GET_DMA_POLARITY(0);
> where GET_DMA_POLARITY() is defined:
> 	#define GET_DMA_POLARITY(chan) DMAReq##chan##_ActiveLow | \
> 		DMAAck##chan##_ActiveLow | EOT##chan##_ActiveLow
>
> Note the macro has no parentheses around its definition, which is
> unusual.  IIRC C precedence will mean this code turns out as:
> 	p_dma_ch->polarity = (polarity & DMAReq0_ActiveLow) | \
> 		DMAAck0_ActiveLow | EOT0_ActiveLow
> which looks wrong to me and if correct is an insane use of a macro.
> It's also giving compiler warnings.
>
> I'm guessing that the macro should just get parentheses, but that's a
> semantic change so I don't want to make it without knowing for sure.
> Could you check this?
>
> --
> David Gibson			| For every complex problem there is a
> david@gibson.dropbear.id.au	| solution which is simple, neat and
> 				| wrong.  -- H.L. Mencken
> http://www.ozlabs.org/people/dgibson
>
>
>
>
>

Thanks.. I missed the parentheses.  The macro is there to allow me to
use the same driver for the 405gp dma and the stb0xxxx cpu since the the
stbxxxx does not have a polarity.  I could have poluted the driver with
#ifdefs or mask the deltas with a few macros.  I went with macros.

armin

PS I am insane


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* ppc405_dma warnings
@ 2002-03-14  2:21 David Gibson
  2002-03-13 21:04 ` Armin
  0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2002-03-14  2:21 UTC (permalink / raw)
  To: Armin Kuster; +Cc: linuxppc-embedded


Armin,

ppc405_dma.c has several constructs like:
	p_dma_ch->polarity = polarity & GET_DMA_POLARITY(0);
where GET_DMA_POLARITY() is defined:
	#define GET_DMA_POLARITY(chan) DMAReq##chan##_ActiveLow | \
		DMAAck##chan##_ActiveLow | EOT##chan##_ActiveLow

Note the macro has no parentheses around its definition, which is
unusual.  IIRC C precedence will mean this code turns out as:
	p_dma_ch->polarity = (polarity & DMAReq0_ActiveLow) | \
		DMAAck0_ActiveLow | EOT0_ActiveLow
which looks wrong to me and if correct is an insane use of a macro.
It's also giving compiler warnings.

I'm guessing that the macro should just get parentheses, but that's a
semantic change so I don't want to make it without knowing for sure.
Could you check this?

--
David Gibson			| For every complex problem there is a
david@gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.  -- H.L. Mencken
http://www.ozlabs.org/people/dgibson


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: ppc405_dma warnings
  2002-03-13 21:04 ` Armin
@ 2002-03-14  6:17   ` David Gibson
  0 siblings, 0 replies; 3+ messages in thread
From: David Gibson @ 2002-03-14  6:17 UTC (permalink / raw)
  To: linuxppc-embedded


On Wed, Mar 13, 2002 at 09:04:02PM +0000, Armin wrote:
> David Gibson wrote:
> >Armin,
> >
> >ppc405_dma.c has several constructs like:
> >	p_dma_ch->polarity = polarity & GET_DMA_POLARITY(0);
> >where GET_DMA_POLARITY() is defined:
> >	#define GET_DMA_POLARITY(chan) DMAReq##chan##_ActiveLow | \
> >		DMAAck##chan##_ActiveLow | EOT##chan##_ActiveLow
> >
> >Note the macro has no parentheses around its definition, which is
> >unusual.  IIRC C precedence will mean this code turns out as:
> >	p_dma_ch->polarity = (polarity & DMAReq0_ActiveLow) | \
> >		DMAAck0_ActiveLow | EOT0_ActiveLow
> >which looks wrong to me and if correct is an insane use of a macro.
> >It's also giving compiler warnings.
> >
> >I'm guessing that the macro should just get parentheses, but that's a
> >semantic change so I don't want to make it without knowing for sure.
> >Could you check this?
>
> Thanks.. I missed the parentheses.  The macro is there to allow me to
> use the same driver for the 405gp dma and the stb0xxxx cpu since the the
> stbxxxx does not have a polarity.  I could have poluted the driver with
> #ifdefs or mask the deltas with a few macros.  I went with macros.

Seems reasonable.  Will you put in the missing parentheses, or should
I?

> armin
>
> PS I am insane

That may be true, but accidentally missing the () doesn't prove it.
Deliberately missing the () would :-)

--
David Gibson			| For every complex problem there is a
david@gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.  -- H.L. Mencken
http://www.ozlabs.org/people/dgibson


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

end of thread, other threads:[~2002-03-14  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-14  2:21 ppc405_dma warnings David Gibson
2002-03-13 21:04 ` Armin
2002-03-14  6:17   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).