From: Andy Shevchenko Date: Wed, 7 Aug 2019 13:41:50 +0000 (+0300) Subject: pinctrl: intel: Use NSEC_PER_USEC for debounce calculus X-Git-Tag: v5.4-rc1~107^2~8^2~5 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=6a33a1d6d66a46157951388ce4c5f2674b251982;p=linux.git pinctrl: intel: Use NSEC_PER_USEC for debounce calculus 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 Acked-by: Mika Westerberg --- diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 5c7348caac36..28eaa1e5dc1f 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -8,12 +8,13 @@ */ #include -#include #include #include #include +#include #include #include +#include #include #include @@ -70,7 +71,7 @@ #define PADCFG2_DEBOUNCE_SHIFT 1 #define PADCFG2_DEBOUNCE_MASK GENMASK(4, 1) -#define DEBOUNCE_PERIOD 31250 /* ns */ +#define DEBOUNCE_PERIOD_NSEC 31250 struct intel_pad_context { u32 padcfg0; @@ -565,7 +566,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_NSEC / NSEC_PER_USEC; break; } @@ -682,7 +683,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_NSEC); if (v < 3 || v > 15) { ret = -EINVAL; goto exit_unlock;