]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: sdhci: use FIELD_GET/PREP for current capabilities bit masks
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 11 May 2020 06:28:27 +0000 (15:28 +0900)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 28 May 2020 09:22:14 +0000 (11:22 +0200)
Use FIELD_GET and FIELD_PREP to get access to the register fields. Delete
the shift macros and use GENMASK() for the touched macros.

Note that, this has the side-effect of changing the constants to 64-bit on
64-bit platforms.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/r/20200511062828.1791484-1-yamada.masahiro@socionext.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h

index 38cd8311808235dbbe6124f2de051d84bc0fdd97..9896e03fce711bb9e3524d665017a9eebba8cde0 100644 (file)
@@ -419,9 +419,9 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
 
        if (unlikely(reg == SDHCI_MAX_CURRENT) && esdhc_is_usdhc(imx_data)) {
                val = 0;
-               val |= 0xFF << SDHCI_MAX_CURRENT_330_SHIFT;
-               val |= 0xFF << SDHCI_MAX_CURRENT_300_SHIFT;
-               val |= 0xFF << SDHCI_MAX_CURRENT_180_SHIFT;
+               val |= FIELD_PREP(SDHCI_MAX_CURRENT_330_MASK, 0xFF);
+               val |= FIELD_PREP(SDHCI_MAX_CURRENT_300_MASK, 0xFF);
+               val |= FIELD_PREP(SDHCI_MAX_CURRENT_180_MASK, 0xFF);
        }
 
        if (unlikely(reg == SDHCI_INT_STATUS)) {
index 95cc08c1fed953f06a8431ebce2f3ae5e9376b6e..9864e877e105c5b6d35d39e853dfa793ab9e2628 100644 (file)
@@ -4486,35 +4486,32 @@ int sdhci_setup_host(struct sdhci_host *host)
 
                        curr = min_t(u32, curr, SDHCI_MAX_CURRENT_LIMIT);
                        max_current_caps =
-                               (curr << SDHCI_MAX_CURRENT_330_SHIFT) |
-                               (curr << SDHCI_MAX_CURRENT_300_SHIFT) |
-                               (curr << SDHCI_MAX_CURRENT_180_SHIFT);
+                               FIELD_PREP(SDHCI_MAX_CURRENT_330_MASK, curr) |
+                               FIELD_PREP(SDHCI_MAX_CURRENT_300_MASK, curr) |
+                               FIELD_PREP(SDHCI_MAX_CURRENT_180_MASK, curr);
                }
        }
 
        if (host->caps & SDHCI_CAN_VDD_330) {
                ocr_avail |= MMC_VDD_32_33 | MMC_VDD_33_34;
 
-               mmc->max_current_330 = ((max_current_caps &
-                                  SDHCI_MAX_CURRENT_330_MASK) >>
-                                  SDHCI_MAX_CURRENT_330_SHIFT) *
-                                  SDHCI_MAX_CURRENT_MULTIPLIER;
+               mmc->max_current_330 = FIELD_GET(SDHCI_MAX_CURRENT_330_MASK,
+                                                max_current_caps) *
+                                               SDHCI_MAX_CURRENT_MULTIPLIER;
        }
        if (host->caps & SDHCI_CAN_VDD_300) {
                ocr_avail |= MMC_VDD_29_30 | MMC_VDD_30_31;
 
-               mmc->max_current_300 = ((max_current_caps &
-                                  SDHCI_MAX_CURRENT_300_MASK) >>
-                                  SDHCI_MAX_CURRENT_300_SHIFT) *
-                                  SDHCI_MAX_CURRENT_MULTIPLIER;
+               mmc->max_current_300 = FIELD_GET(SDHCI_MAX_CURRENT_300_MASK,
+                                                max_current_caps) *
+                                               SDHCI_MAX_CURRENT_MULTIPLIER;
        }
        if (host->caps & SDHCI_CAN_VDD_180) {
                ocr_avail |= MMC_VDD_165_195;
 
-               mmc->max_current_180 = ((max_current_caps &
-                                  SDHCI_MAX_CURRENT_180_MASK) >>
-                                  SDHCI_MAX_CURRENT_180_SHIFT) *
-                                  SDHCI_MAX_CURRENT_MULTIPLIER;
+               mmc->max_current_180 = FIELD_GET(SDHCI_MAX_CURRENT_180_MASK,
+                                                max_current_caps) *
+                                               SDHCI_MAX_CURRENT_MULTIPLIER;
        }
 
        /* If OCR set by host, use it instead. */
index 8d2a096fdfb1cdece2eb0b6d90023ee15b3f7099..257213a94d89d626d7de80a90a55fcd43e369619 100644 (file)
 #define  SDHCI_SUPPORT_HS400   0x80000000 /* Non-standard */
 
 #define SDHCI_MAX_CURRENT              0x48
-#define  SDHCI_MAX_CURRENT_LIMIT       0xFF
-#define  SDHCI_MAX_CURRENT_330_MASK    0x0000FF
-#define  SDHCI_MAX_CURRENT_330_SHIFT   0
-#define  SDHCI_MAX_CURRENT_300_MASK    0x00FF00
-#define  SDHCI_MAX_CURRENT_300_SHIFT   8
-#define  SDHCI_MAX_CURRENT_180_MASK    0xFF0000
-#define  SDHCI_MAX_CURRENT_180_SHIFT   16
+#define  SDHCI_MAX_CURRENT_LIMIT       GENMASK(7, 0)
+#define  SDHCI_MAX_CURRENT_330_MASK    GENMASK(7, 0)
+#define  SDHCI_MAX_CURRENT_300_MASK    GENMASK(15, 8)
+#define  SDHCI_MAX_CURRENT_180_MASK    GENMASK(23, 16)
 #define   SDHCI_MAX_CURRENT_MULTIPLIER 4
 
 /* 4C-4F reserved for more max current */