Bug in keyboard driver
Andy Green
andy at openmoko.com
Thu May 8 10:17:51 CEST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Somebody in the thread at some point said:
| On Thu, May 8, 2008 09:08, Sean McNeil wrote:
|> the KEY_PHONE is backwards. It returns up when pushed and down when
|> released. The following change fixes it:
|>
|> static irqreturn_t neo1973kbd_aux_irq(int irq, void *dev_id)
|> {
|> struct neo1973kbd *neo1973kbd_data = dev_id;
|>
|> - int key_pressed = !gpio_get_value(irq_to_gpio(irq));
|> + int key_pressed = !!gpio_get_value(irq_to_gpio(irq));
|
| Pardon my ignorance, but... double negative? It wouldn't be better:
!! is a neat trick I only saw in Linux kernel code... ! alone converts
any nonzero value to 0 and 0 to 1, then the second one re-inverts to
back to normal. The end result is that you leave 0 alone and convert
any non-zero number to 1. This is very useful if you later want to
shift it as a bitfield.
- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkgity4ACgkQOjLpvpq7dMpSLACZAdTXMH4Cm+HOvV968f50GJzs
d/gAn2zcenLLSYYMDVD9HH/5mbOLZP/G
=B2Wu
-----END PGP SIGNATURE-----
More information about the openmoko-kernel
mailing list