linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org
Subject: Re: [PATCH v1] pinctrl: intel: Use NSEC_PER_USEC for debounce calculus
Date: Tue, 6 Aug 2019 13:14:12 +0300	[thread overview]
Message-ID: <20190806101412.GJ2548@lahna.fi.intel.com> (raw)
In-Reply-To: <20190723155431.65095-1-andriy.shevchenko@linux.intel.com>

On Tue, Jul 23, 2019 at 06:54:31PM +0300, Andy Shevchenko wrote:
> Replace hard coded constants with self-explanatory names, i.e.
> use NSEC_PER_USEC for debounce calculus.
> 
> While here, add a unit suffix to debounce period constant.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-intel.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index 3a7876efd4a6..99c5bca789eb 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -8,12 +8,13 @@
>   */
>  
>  #include <linux/acpi.h>
> -#include <linux/module.h>
>  #include <linux/interrupt.h>
>  #include <linux/gpio/driver.h>
>  #include <linux/log2.h>
> +#include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
> +#include <linux/time.h>
>  
>  #include <linux/pinctrl/pinctrl.h>
>  #include <linux/pinctrl/pinmux.h>
> @@ -71,7 +72,7 @@
>  #define PADCFG2_DEBOUNCE_SHIFT		1
>  #define PADCFG2_DEBOUNCE_MASK		GENMASK(4, 1)
>  
> -#define DEBOUNCE_PERIOD			31250 /* ns */
> +#define DEBOUNCE_PERIOD_NS		31250

Should this be called DEBOUNCE_PERIOD_NSEC to be consistent with
NSEC_PER_USEC?

Otherwise looks good.

>  
>  struct intel_pad_context {
>  	u32 padcfg0;
> @@ -566,7 +567,7 @@ static int intel_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
>  			return -EINVAL;
>  
>  		v = (v & PADCFG2_DEBOUNCE_MASK) >> PADCFG2_DEBOUNCE_SHIFT;
> -		arg = BIT(v) * DEBOUNCE_PERIOD / 1000;
> +		arg = BIT(v) * DEBOUNCE_PERIOD_NS / NSEC_PER_USEC;
>  
>  		break;
>  	}
> @@ -683,7 +684,7 @@ static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
>  	if (debounce) {
>  		unsigned long v;
>  
> -		v = order_base_2(debounce * 1000 / DEBOUNCE_PERIOD);
> +		v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NS);
>  		if (v < 3 || v > 15) {
>  			ret = -EINVAL;
>  			goto exit_unlock;
> -- 
> 2.20.1

  reply	other threads:[~2019-08-06 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 15:54 [PATCH v1] pinctrl: intel: Use NSEC_PER_USEC for debounce calculus Andy Shevchenko
2019-08-06 10:14 ` Mika Westerberg [this message]
2019-08-06 11:39   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190806101412.GJ2548@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).