raspberrypi/linux — pull request #240 by Sagittarii (2013-03-02 15:02:43+00:00)
Title: fix missing modulo for bit in bank computation, in bcm2708 gpio irq mask

Spotted this bug while searching something else.

I never had an error because of this myself, but this would happen for irq on GPIO numbers greater than 32, where the mask function has no effect.

If you compare the code of the mask and unmask function, you can see two variables "gn" (gpio number?) and "gb" (gpio bank ?).
The principle is that each bank seems to contains only 32 bits, so bits higher than 32 are in the second bank. For example, bit 50 should be decomposed as : bank 1 (means 32) + bit 18.
However, the line

gn = gn % 32;

is missing in the "mask" function, but present is the "unmask" one.

With the bit 50 example above, it would request bit 50 in bank 1, but bank 1 is only 32 bits wide. So 1<<50 would result in 0 => no effect.