]> git.itanic.dy.fi Git - linux-stable/commitdiff
PCI/ASPM: Use FIELD_MAX() instead of literals
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 15 Sep 2023 15:57:50 +0000 (18:57 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 10 Oct 2023 21:03:51 +0000 (16:03 -0500)
Convert 0x3ff literals in encode_l12_threshold() to
FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE) that explains the purpose of
the literal.

Link: https://lore.kernel.org/r/20230915155752.84640-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pcie/aspm.c

index 60135fc7281a8695a11a8528976c4453cce2c561..fac6c5a0be26aad6ebb5a18803948541e6fcfcdb 100644 (file)
@@ -335,27 +335,27 @@ static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value)
         * LTR_L1.2_THRESHOLD_Value ("value") is a 10-bit field with max
         * value of 0x3ff.
         */
-       if (threshold_ns <= 0x3ff * 1) {
+       if (threshold_ns <= 1 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 0;             /* Value times 1ns */
                *value = threshold_ns;
-       } else if (threshold_ns <= 0x3ff * 32) {
+       } else if (threshold_ns <= 32 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 1;             /* Value times 32ns */
                *value = roundup(threshold_ns, 32) / 32;
-       } else if (threshold_ns <= 0x3ff * 1024) {
+       } else if (threshold_ns <= 1024 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 2;             /* Value times 1024ns */
                *value = roundup(threshold_ns, 1024) / 1024;
-       } else if (threshold_ns <= 0x3ff * 32768) {
+       } else if (threshold_ns <= 32768 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 3;             /* Value times 32768ns */
                *value = roundup(threshold_ns, 32768) / 32768;
-       } else if (threshold_ns <= 0x3ff * 1048576) {
+       } else if (threshold_ns <= 1048576 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 4;             /* Value times 1048576ns */
                *value = roundup(threshold_ns, 1048576) / 1048576;
-       } else if (threshold_ns <= 0x3ff * (u64) 33554432) {
+       } else if (threshold_ns <= (u64)33554432 * FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE)) {
                *scale = 5;             /* Value times 33554432ns */
                *value = roundup(threshold_ns, 33554432) / 33554432;
        } else {
                *scale = 5;
-               *value = 0x3ff;         /* Max representable value */
+               *value = FIELD_MAX(PCI_L1SS_CTL1_LTR_L12_TH_VALUE);
        }
 }