Message ID | 20250612-byeword-update-v1-2-f4afb8f6313f@collabora.com |
---|---|
State | New |
Headers | show |
Series | BYEWORD_UPDATE: unifying (most) HIWORD_UPDATE macros | expand |
On Thu, 12 Jun 2025 at 20:57, Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote: > > The era of hand-rolled HIWORD_UPDATE macros is over, at least for those > drivers that use constant masks. > > Switch to the new HWORD_UPDATE macro in 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. > > Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe > --- > drivers/mmc/host/dw_mmc-rockchip.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c > index baa23b51773127b4137f472581259b61649273a5..9e3d17becf65ffb60fe3d32d2cdec341fbd30b1e 100644 > --- a/drivers/mmc/host/dw_mmc-rockchip.c > +++ b/drivers/mmc/host/dw_mmc-rockchip.c > @@ -5,6 +5,7 @@ > > #include <linux/module.h> > #include <linux/platform_device.h> > +#include <linux/bitfield.h> > #include <linux/clk.h> > #include <linux/mmc/host.h> > #include <linux/of_address.h> > @@ -24,8 +25,6 @@ > #define ROCKCHIP_MMC_DELAYNUM_OFFSET 2 > #define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET) > #define ROCKCHIP_MMC_DELAY_ELEMENT_PSEC 60 > -#define HIWORD_UPDATE(val, mask, shift) \ > - ((val) << (shift) | (mask) << ((shift) + 16)) > > static const unsigned int freqs[] = { 100000, 200000, 300000, 400000 }; > > @@ -148,9 +147,9 @@ static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int > raw_value |= nineties; > > if (sample) > - mci_writel(host, TIMING_CON1, HIWORD_UPDATE(raw_value, 0x07ff, 1)); > + mci_writel(host, TIMING_CON1, HWORD_UPDATE(GENMASK(11, 1), raw_value)); > else > - mci_writel(host, TIMING_CON0, HIWORD_UPDATE(raw_value, 0x07ff, 1)); > + mci_writel(host, TIMING_CON0, HWORD_UPDATE(GENMASK(11, 1), raw_value)); > > dev_dbg(host->dev, "set %s_phase(%d) delay_nums=%u actual_degrees=%d\n", > sample ? "sample" : "drv", degrees, delay_num, > > -- > 2.49.0 >
diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c index baa23b51773127b4137f472581259b61649273a5..9e3d17becf65ffb60fe3d32d2cdec341fbd30b1e 100644 --- a/drivers/mmc/host/dw_mmc-rockchip.c +++ b/drivers/mmc/host/dw_mmc-rockchip.c @@ -5,6 +5,7 @@ #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/mmc/host.h> #include <linux/of_address.h> @@ -24,8 +25,6 @@ #define ROCKCHIP_MMC_DELAYNUM_OFFSET 2 #define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET) #define ROCKCHIP_MMC_DELAY_ELEMENT_PSEC 60 -#define HIWORD_UPDATE(val, mask, shift) \ - ((val) << (shift) | (mask) << ((shift) + 16)) static const unsigned int freqs[] = { 100000, 200000, 300000, 400000 }; @@ -148,9 +147,9 @@ static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int raw_value |= nineties; if (sample) - mci_writel(host, TIMING_CON1, HIWORD_UPDATE(raw_value, 0x07ff, 1)); + mci_writel(host, TIMING_CON1, HWORD_UPDATE(GENMASK(11, 1), raw_value)); else - mci_writel(host, TIMING_CON0, HIWORD_UPDATE(raw_value, 0x07ff, 1)); + mci_writel(host, TIMING_CON0, HWORD_UPDATE(GENMASK(11, 1), raw_value)); dev_dbg(host->dev, "set %s_phase(%d) delay_nums=%u actual_degrees=%d\n", sample ? "sample" : "drv", degrees, delay_num,
The era of hand-rolled HIWORD_UPDATE macros is over, at least for those drivers that use constant masks. Switch to the new HWORD_UPDATE macro in 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. Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> --- drivers/mmc/host/dw_mmc-rockchip.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)