diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2014-05-14 14:58:55 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-14 19:40:08 -0400 |
commit | 70a26071f8552a0f193cf442f424decfe0f2e569 (patch) | |
tree | d6002f935f3727ad52fd7928a46c87a71c6d0d7f /drivers/input/misc | |
parent | 61616ed0ce2ed581df89be5d917f8d7e9fc3074f (diff) |
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>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r-- | drivers/input/misc/pmic8xxx-pwrkey.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c index 1cb8fda7a166..c91e3d33aea9 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c | |||
@@ -92,15 +92,15 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) | |||
92 | bool pull_up; | 92 | bool pull_up; |
93 | 93 | ||
94 | if (of_property_read_u32(pdev->dev.of_node, "debounce", &kpd_delay)) | 94 | if (of_property_read_u32(pdev->dev.of_node, "debounce", &kpd_delay)) |
95 | kpd_delay = 0; | 95 | kpd_delay = 15625; |
96 | 96 | ||
97 | pull_up = of_property_read_bool(pdev->dev.of_node, "pull-up"); | 97 | if (kpd_delay > 62500 || kpd_delay == 0) { |
98 | |||
99 | if (kpd_delay > 62500) { | ||
100 | dev_err(&pdev->dev, "invalid power key trigger delay\n"); | 98 | dev_err(&pdev->dev, "invalid power key trigger delay\n"); |
101 | return -EINVAL; | 99 | return -EINVAL; |
102 | } | 100 | } |
103 | 101 | ||
102 | pull_up = of_property_read_bool(pdev->dev.of_node, "pull-up"); | ||
103 | |||
104 | regmap = dev_get_regmap(pdev->dev.parent, NULL); | 104 | regmap = dev_get_regmap(pdev->dev.parent, NULL); |
105 | if (!regmap) { | 105 | if (!regmap) { |
106 | dev_err(&pdev->dev, "failed to locate regmap for the device\n"); | 106 | dev_err(&pdev->dev, "failed to locate regmap for the device\n"); |