Re: [PATCH v2 3/4] input: misc: pm8941-pwrkey: add software key press debouncing support

From: Stephen Boyd
Date: Thu Jan 27 2022 - 17:44:18 EST


Quoting Anjelique Melendez (2022-01-27 13:00:27)
> diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
> index 7005aede4f81..bcdbe260b684 100644
> --- a/drivers/input/misc/pm8941-pwrkey.c
> +++ b/drivers/input/misc/pm8941-pwrkey.c
[...]
>
> +static int pm8941_pwrkey_sw_debounce_init(struct pm8941_pwrkey *pwrkey)
> +{
> + unsigned int val, addr, mask;
> + int error;
> +
> + if (pwrkey->data->has_pon_pbs && !pwrkey->pon_pbs_baseaddr) {
> + dev_err(pwrkey->dev, "PON_PBS address missing, can't read HW debounce time\n");
> + return 0;
> + }
> +
> + if (pwrkey->pon_pbs_baseaddr)
> + addr = pwrkey->pon_pbs_baseaddr + PON_DBC_CTL;
> + else
> + addr = pwrkey->baseaddr + PON_DBC_CTL;
> + error = regmap_read(pwrkey->regmap, addr, &val);
> + if (error)
> + return error;
> +
> + if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY)
> + mask = 0xf;
> + else
> + mask = 0x7;
> +
> + pwrkey->sw_debounce_time_us = 2 * USEC_PER_SEC /
> + (1 << (mask - (val & mask)));

pwrkey->sw_debounce_time_us = 2 * USEC_PER_SEC / (1 << (mask
- (val & mask)));

Nitpick: Put this one one line?

> +
> + dev_dbg(pwrkey->dev, "SW debounce time = %u us\n",
> + pwrkey->sw_debounce_time_us);
> +
> + return 0;
> +}
> +
> static int __maybe_unused pm8941_pwrkey_suspend(struct device *dev)
> {
> struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev);