summaryrefslogtreecommitdiff
path: root/drivers/pci/pcie
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2023-09-15 18:57:49 +0300
committerBjorn Helgaas <bhelgaas@google.com>2023-10-10 16:03:51 -0500
commite13b72b819245027f960ce7a3735c4fe24fab024 (patch)
tree49a3fd6349a4426d4a426890fb21692c2bba1c22 /drivers/pci/pcie
parent69bb38b77486b114b56b1174d74bb97d66045697 (diff)
PCI/ASPM: Use time constants
Use defined constants to convert between time units. Link: https://lore.kernel.org/r/20230915155752.84640-5-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r--drivers/pci/pcie/aspm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 4cd11ab27233..60135fc7281a 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -21,6 +21,8 @@
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/delay.h>
+#include <linux/time.h>
+
#include "../pci.h"
#ifdef MODULE_PARAM_PREFIX
@@ -272,7 +274,7 @@ static u32 calc_l0s_latency(u32 lnkcap)
u32 encoding = FIELD_GET(PCI_EXP_LNKCAP_L0SEL, lnkcap);
if (encoding == 0x7)
- return (5 * 1000); /* > 4us */
+ return 5 * NSEC_PER_USEC; /* > 4us */
return (64 << encoding);
}
@@ -290,8 +292,8 @@ static u32 calc_l1_latency(u32 lnkcap)
u32 encoding = FIELD_GET(PCI_EXP_LNKCAP_L1EL, lnkcap);
if (encoding == 0x7)
- return (65 * 1000); /* > 64us */
- return (1000 << encoding);
+ return 65 * NSEC_PER_USEC; /* > 64us */
+ return NSEC_PER_USEC << encoding;
}
/* Convert L1 acceptable latency encoding to ns */
@@ -299,7 +301,7 @@ static u32 calc_l1_acceptable(u32 encoding)
{
if (encoding == 0x7)
return U32_MAX;
- return (1000 << encoding);
+ return NSEC_PER_USEC << encoding;
}
/* Convert L1SS T_pwr encoding to usec */
@@ -327,7 +329,7 @@ static u32 calc_l12_pwron(struct pci_dev *pdev, u32 scale, u32 val)
*/
static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value)
{
- u64 threshold_ns = (u64) threshold_us * 1000;
+ u64 threshold_ns = (u64)threshold_us * NSEC_PER_USEC;
/*
* LTR_L1.2_THRESHOLD_Value ("value") is a 10-bit field with max
@@ -419,7 +421,7 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint)
if ((link->aspm_capable & ASPM_STATE_L1) &&
(latency + l1_switch_latency > acceptable_l1))
link->aspm_capable &= ~ASPM_STATE_L1;
- l1_switch_latency += 1000;
+ l1_switch_latency += NSEC_PER_USEC;
link = link->parent;
}