gpio: omap: return error if requested debounce time is not possible
authorDavid Rivshin <DRivshin@allworx.com>
Mon, 24 Apr 2017 22:56:50 +0000 (18:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 13:44:36 +0000 (15:44 +0200)
commit198ab4031873b5511d6ef9b4777cabc4eebcaf18
treeaedf7e7ceb7fcb4a4cb2f98ab776c03c9bdd06b5
parentb77adf29b85687fd593d4dc294fb5cb946b3c0e2
gpio: omap: return error if requested debounce time is not possible

commit 83977443938122baeed28dc9f078db3da9855f7c upstream.

omap_gpio_debounce() does not validate that the requested debounce
is within a range it can handle. Instead it lets the register value
wrap silently, and always returns success.

This can lead to all sorts of unexpected behavior, such as gpio_keys
asking for a too-long debounce, but getting a very short debounce in
practice.

Fix this by returning -EINVAL if the requested value does not fit into
the register field. If there is no debounce clock available at all,
return -ENOTSUPP.

Fixes: e85ec6c3047b ("gpio: omap: fix omap2_set_gpio_debounce")
Signed-off-by: David Rivshin <drivshin@allworx.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpio/gpio-omap.c