[PATCH 1/3] MSI driver for Freescale 83xx/85xx/86xx cpu

Segher Boessenkool segher at kernel.crashing.org
Thu Apr 24 02:05:47 EST 2008


>>> data = ((hwirq / 32) << 5) | ((hwirq % 32) & 0x1F)
>>>
>>> Which doesn't seem to actually do anything?
>>
>> It's not a no-op, because hwirq is signed.  It probably should be
>> unsigned, like most things.
>
> You'll have to draw me a picture.

In C, signed division is round-towards-zero, while unsigned division
is round-towards-negative-infinity.  Suppose hwirq is -1, then
hwirq/32 is 0 and hwirq%32 is -1, so that the full expression above
will be 0x1f, not -1.  There is no such problem if hwirq would be
unsigned; the compiler can generate better code in that case.


Segher




More information about the Linuxppc-dev mailing list