Browse Source

Input: pmic8xxx-pwrkey - set sane default for debounce time

If the debounce time is 0 our usage of ilog2() later on in this driver will
cause undefined behavior. If CONFIG_OF=n this fact is evident to the
compiler, and it emits a call to ____ilog2_NaN() which doesn't exist. Fix
this by setting a sane default for debounce and failing to probe if
debounce is 0 in the DT.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Stephen Boyd 11 years ago
parent
commit
70a26071f8
1 changed files with 4 additions and 4 deletions
  1. 4 4
      drivers/input/misc/pmic8xxx-pwrkey.c

+ 4 - 4
drivers/input/misc/pmic8xxx-pwrkey.c

@@ -92,15 +92,15 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
 	bool pull_up;
 	bool pull_up;
 
 
 	if (of_property_read_u32(pdev->dev.of_node, "debounce", &kpd_delay))
 	if (of_property_read_u32(pdev->dev.of_node, "debounce", &kpd_delay))
-		kpd_delay = 0;
+		kpd_delay = 15625;
 
 
-	pull_up = of_property_read_bool(pdev->dev.of_node, "pull-up");
-
-	if (kpd_delay > 62500) {
+	if (kpd_delay > 62500 || kpd_delay == 0) {
 		dev_err(&pdev->dev, "invalid power key trigger delay\n");
 		dev_err(&pdev->dev, "invalid power key trigger delay\n");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
+	pull_up = of_property_read_bool(pdev->dev.of_node, "pull-up");
+
 	regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!regmap) {
 	if (!regmap) {
 		dev_err(&pdev->dev, "failed to locate regmap for the device\n");
 		dev_err(&pdev->dev, "failed to locate regmap for the device\n");