Re: [patch] Re: Magic Alt-SysRq change in 2.6.18-rc1

Paulo Marques
2006-07-12T22:35:06Z

Bodo Eggert wrote:
> Paulo Marques <pmarques@grupopie.com> wrote:
>[...]
>>This allows for all the combinations mentioned before in this thread and
>>makes the logic simpler, IMHO.
>
> Why don't you use a bitmask?
> alt-sysrq down -> val = 0b11
> sysrq up -> val &= ~0b01
> alt up -> val &= ~0b10
>
> test is_sysrq == !!val

It can be done, but it doesn't seem to buy you much.

The sysrq_alt variable is used wether we use magic sysrq or not, so we
must keep it anyway. This var doesn't do what your high bit does,
because in the bit mask this bit only goes on when both are pressed (not
just alt).

alt up is actually 2 different keys (left and right). To detect it, we
either copy the same "if" that is outside the #ifdef or we try to follow
the state of sysrq_alt to detect the change from low to high :P

Anyway, I think the code can be simplified further, though, and it might
involve a similar trick. And it definitely needs some more comments in
there ;)

I'll play with it some more and try to produce a better patch.

--
Paulo Marques