summaryrefslogtreecommitdiff
path: root/drivers/button
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2024-01-31 10:09:15 +0300
committerCaleb Connolly <caleb.connolly@linaro.org>2024-02-14 17:16:52 +0000
commit6b929e9f3c16bbddeffb85351e93db13eaa9b57d (patch)
tree46378f512b80a03d6c18c1c492161b8ae530f5d2 /drivers/button
parent37345abb97ef0dd9c50a03b2a72617612dcae585 (diff)
downloadu-boot-6b929e9f3c16bbddeffb85351e93db13eaa9b57d.tar.gz
u-boot-6b929e9f3c16bbddeffb85351e93db13eaa9b57d.tar.bz2
u-boot-6b929e9f3c16bbddeffb85351e93db13eaa9b57d.zip
button: qcom-pmic: fix some error checking
The pmic_reg_read() function can return errors. Add a check for that. Fixes: 4e8aa0065d4b ("button: qcom-pmic: introduce Qualcomm PMIC button driver") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Diffstat (limited to 'drivers/button')
-rw-r--r--drivers/button/button-qcom-pmic.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/button/button-qcom-pmic.c b/drivers/button/button-qcom-pmic.c
index 34a976d1e6..e778e51a4f 100644
--- a/drivers/button/button-qcom-pmic.c
+++ b/drivers/button/button-qcom-pmic.c
@@ -86,7 +86,7 @@ static int qcom_pwrkey_probe(struct udevice *dev)
}
ret = pmic_reg_read(priv->pmic, priv->base + REG_SUBTYPE);
- if ((ret & 0x7) == 0) {
+ if (ret < 0 || (ret & 0x7) == 0) {
printf("%s: unexpected PMCI function subtype %d\n", dev->name, ret);
return -ENXIO;
}