[PATCH] button: qcom-pmic: fix some error checking

Sumit Garg sumit.garg at linaro.org
Fri Feb 2 09:51:25 CET 2024


On Wed, 31 Jan 2024 at 12:39, Dan Carpenter <dan.carpenter at linaro.org> wrote:
>
> 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 at linaro.org>
> ---
> This patch is mostly to make static checkers happy but it's obvious and
> harmless.
>
>  drivers/button/button-qcom-pmic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Sumit Garg <sumit.garg at linaro.org>

-Sumit

> diff --git a/drivers/button/button-qcom-pmic.c b/drivers/button/button-qcom-pmic.c
> index 34a976d1e6c6..e778e51a4f36 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;
>         }
> --
> 2.43.0
>


More information about the U-Boot mailing list