Skip to content

Commit 47975a8

Browse files
Nicolas FrattaroliYuryNorov
authored andcommitted
mmc: dw_mmc-rockchip: switch to FIELD_PREP_WM16 macro
The era of hand-rolled HIWORD_UPDATE macros is over, at least for those drivers that use constant masks. Switch to the new FIELD_PREP_WM16 macro in hw_bitfield.h, which has error checking. Instead of redefining the driver's HIWORD_UPDATE macro in this case, replace the two only instances of it with the new macro, as I could test that they result in an equivalent value. Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
1 parent 21368fc commit 47975a8

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/mmc/host/dw_mmc-rockchip.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/module.h>
77
#include <linux/platform_device.h>
88
#include <linux/clk.h>
9+
#include <linux/hw_bitfield.h>
910
#include <linux/mmc/host.h>
1011
#include <linux/of_address.h>
1112
#include <linux/mmc/slot-gpio.h>
@@ -24,8 +25,6 @@
2425
#define ROCKCHIP_MMC_DELAYNUM_OFFSET 2
2526
#define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET)
2627
#define ROCKCHIP_MMC_DELAY_ELEMENT_PSEC 60
27-
#define HIWORD_UPDATE(val, mask, shift) \
28-
((val) << (shift) | (mask) << ((shift) + 16))
2928

3029
static const unsigned int freqs[] = { 100000, 200000, 300000, 400000 };
3130

@@ -148,9 +147,11 @@ static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int
148147
raw_value |= nineties;
149148

150149
if (sample)
151-
mci_writel(host, TIMING_CON1, HIWORD_UPDATE(raw_value, 0x07ff, 1));
150+
mci_writel(host, TIMING_CON1,
151+
FIELD_PREP_WM16(GENMASK(11, 1), raw_value));
152152
else
153-
mci_writel(host, TIMING_CON0, HIWORD_UPDATE(raw_value, 0x07ff, 1));
153+
mci_writel(host, TIMING_CON0,
154+
FIELD_PREP_WM16(GENMASK(11, 1), raw_value));
154155

155156
dev_dbg(host->dev, "set %s_phase(%d) delay_nums=%u actual_degrees=%d\n",
156157
sample ? "sample" : "drv", degrees, delay_num,

0 commit comments

Comments
 (0)