]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: sdhci: use FIELD_GET for preset value bit masks
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 12 Mar 2020 11:00:50 +0000 (20:00 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:23:06 +0000 (11:23 +0100)
commit 8473ebd56ddaca5dff15b963ae24c1df272d094b upstream.

Use the FIELD_GET macro to get access to the register fields.
Delete the shift macros.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/r/20200312110050.21732-1-yamada.masahiro@socionext.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h

index deafcc56adee6dd881044e9585bd694e5972f885..f56b279d8e32c33da540f3c9ef79fa055cc4ba17 100644 (file)
@@ -9,6 +9,7 @@
  *     - JMicron (hardware and technical support)
  */
 
+#include <linux/bitfield.h>
 #include <linux/delay.h>
 #include <linux/ktime.h>
 #include <linux/highmem.h>
@@ -1570,10 +1571,9 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock,
 
                        clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
                        pre_val = sdhci_get_preset_value(host);
-                       div = (pre_val & SDHCI_PRESET_SDCLK_FREQ_MASK)
-                               >> SDHCI_PRESET_SDCLK_FREQ_SHIFT;
+                       div = FIELD_GET(SDHCI_PRESET_SDCLK_FREQ_MASK, pre_val);
                        if (host->clk_mul &&
-                               (pre_val & SDHCI_PRESET_CLKGEN_SEL_MASK)) {
+                               (pre_val & SDHCI_PRESET_CLKGEN_SEL)) {
                                clk = SDHCI_PROG_CLOCK_MODE;
                                real_div = div + 1;
                                clk_mul = host->clk_mul;
@@ -2048,8 +2048,8 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
                        sdhci_enable_preset_value(host, true);
                        preset = sdhci_get_preset_value(host);
-                       ios->drv_type = (preset & SDHCI_PRESET_DRV_MASK)
-                               >> SDHCI_PRESET_DRV_SHIFT;
+                       ios->drv_type = FIELD_GET(SDHCI_PRESET_DRV_MASK,
+                                                 preset);
                }
 
                /* Re-enable SD Clock */
index 54f9d6720f1323fd18faf61d6370bf60c9f95392..bd74a3ae129908914663619028bd530b1e46643a 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef __SDHCI_HW_H
 #define __SDHCI_HW_H
 
+#include <linux/bits.h>
 #include <linux/scatterlist.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
 #define SDHCI_PRESET_FOR_SDR104        0x6C
 #define SDHCI_PRESET_FOR_DDR50 0x6E
 #define SDHCI_PRESET_FOR_HS400 0x74 /* Non-standard */
-#define SDHCI_PRESET_DRV_MASK  0xC000
-#define SDHCI_PRESET_DRV_SHIFT  14
-#define SDHCI_PRESET_CLKGEN_SEL_MASK   0x400
-#define SDHCI_PRESET_CLKGEN_SEL_SHIFT  10
-#define SDHCI_PRESET_SDCLK_FREQ_MASK   0x3FF
-#define SDHCI_PRESET_SDCLK_FREQ_SHIFT  0
+#define SDHCI_PRESET_DRV_MASK          GENMASK(15, 14)
+#define SDHCI_PRESET_CLKGEN_SEL                BIT(10)
+#define SDHCI_PRESET_SDCLK_FREQ_MASK   GENMASK(9, 0)
 
 #define SDHCI_SLOT_INT_STATUS  0xFC