[<prev] [next>] [day] [month] [year] [list]
Message-Id: <b72856c9d2d3f9938ce7f3124a466754534981d9.1708002102.git.geert+renesas@glider.be>
Date: Thu, 15 Feb 2024 14:03:50 +0100
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: x86@...nel.org,
linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH resend] intel_th: Use bitfield helpers
Use the FIELD_{GET,PREP}() helpers, instead of open-coding the same
operations.
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
---
Compile-tested only.
---
drivers/hwtracing/intel_th/msu.c | 8 ++++----
drivers/hwtracing/intel_th/pti.c | 13 +++++++------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 9621efe0e95c4df8..b6e76c5f8d2f38ea 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -7,6 +7,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/bitfield.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/device.h>
@@ -787,8 +788,8 @@ static int msc_configure(struct msc *msc)
reg &= ~(MSC_MODE | MSC_WRAPEN | MSC_EN | MSC_RD_HDR_OVRD);
reg |= MSC_EN;
- reg |= msc->mode << __ffs(MSC_MODE);
- reg |= msc->burst_len << __ffs(MSC_LEN);
+ reg |= FIELD_PREP(MSC_MODE, msc->mode);
+ reg |= FIELD_PREP(MSC_LEN, msc->burst_len);
if (msc->wrap)
reg |= MSC_WRAPEN;
@@ -1699,8 +1700,7 @@ static int intel_th_msc_init(struct msc *msc)
INIT_LIST_HEAD(&msc->iter_list);
msc->burst_len =
- (ioread32(msc->reg_base + REG_MSU_MSC0CTL) & MSC_LEN) >>
- __ffs(MSC_LEN);
+ FIELD_GET(MSC_LEN, ioread32(msc->reg_base + REG_MSU_MSC0CTL));
return 0;
}
diff --git a/drivers/hwtracing/intel_th/pti.c b/drivers/hwtracing/intel_th/pti.c
index 09132ab8bc23265a..eadc236ec43e0ad3 100644
--- a/drivers/hwtracing/intel_th/pti.c
+++ b/drivers/hwtracing/intel_th/pti.c
@@ -7,6 +7,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/bitfield.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/device.h>
@@ -152,12 +153,12 @@ static int intel_th_pti_activate(struct intel_th_device *thdev)
u32 ctl = PTI_EN;
if (pti->patgen)
- ctl |= pti->patgen << __ffs(PTI_PATGENMODE);
+ ctl |= FIELD_PREP(PTI_PATGENMODE, pti->patgen);
if (pti->freeclk)
ctl |= PTI_FCEN;
- ctl |= pti->mode << __ffs(PTI_MODE);
- ctl |= pti->clkdiv << __ffs(PTI_CLKDIV);
- ctl |= pti->lpp_dest << __ffs(LPP_DEST);
+ ctl |= FIELD_PREP(PTI_MODE, pti->mode);
+ ctl |= FIELD_PREP(PTI_CLKDIV, pti->clkdiv);
+ ctl |= FIELD_PREP(LPP_DEST, pti->lpp_dest);
iowrite32(ctl, pti->base + REG_PTI_CTL);
@@ -179,8 +180,8 @@ static void read_hw_config(struct pti_device *pti)
{
u32 ctl = ioread32(pti->base + REG_PTI_CTL);
- pti->mode = (ctl & PTI_MODE) >> __ffs(PTI_MODE);
- pti->clkdiv = (ctl & PTI_CLKDIV) >> __ffs(PTI_CLKDIV);
+ pti->mode = FIELD_GET(PTI_MODE, ctl);
+ pti->clkdiv = FIELD_GET(PTI_CLKDIV, ctl);
pti->freeclk = !!(ctl & PTI_FCEN);
if (!pti_mode[pti->mode])
--
2.34.1
Powered by blists - more mailing lists