* [PATCH] powerpc/xive: Remove (almost) unused macros
@ 2018-05-11 8:03 Russell Currey
2018-05-14 3:30 ` Michael Ellerman
2018-06-04 14:10 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Russell Currey @ 2018-05-11 8:03 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Russell Currey
The GETFIELD and SETFIELD macros in xive-regs.h aren't used except for a
single instance of GETFIELD, so replace that and remove them.
These macros are also defined in vas.h, so either those should be
eventually replaced or the macros moved into bitops.h.
Signed-off-by: Russell Currey <ruscur@russell.cc>
---
arch/powerpc/include/asm/xive-regs.h | 6 ------
arch/powerpc/sysdev/xive/native.c | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/arch/powerpc/include/asm/xive-regs.h b/arch/powerpc/include/asm/xive-regs.h
index fa4288822b68..6de989f8defd 100644
--- a/arch/powerpc/include/asm/xive-regs.h
+++ b/arch/powerpc/include/asm/xive-regs.h
@@ -123,10 +123,4 @@
#define TM_QW3_NSR_I PPC_BIT8(2)
#define TM_QW3_NSR_GRP_LVL PPC_BIT8(3,7)
-/* Utilities to manipulate these (originaly from OPAL) */
-#define MASK_TO_LSH(m) (__builtin_ffsl(m) - 1)
-#define GETFIELD(m, v) (((v) & (m)) >> MASK_TO_LSH(m))
-#define SETFIELD(m, v, val) \
- (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))
-
#endif /* _ASM_POWERPC_XIVE_REGS_H */
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
index b48454be5b98..3b471c0193ca 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -341,7 +341,7 @@ static void xive_native_update_pending(struct xive_cpu *xc)
* of the hypervisor interrupt (if any)
*/
cppr = ack & 0xff;
- he = GETFIELD(TM_QW3_NSR_HE, (ack >> 8));
+ he = ((ack >> 8) & TM_QW3_NSR_HE) >> (ffs(TM_QW3_NSR_HE) - 1);
switch(he) {
case TM_QW3_NSR_HE_NONE: /* Nothing to see here */
break;
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/xive: Remove (almost) unused macros
2018-05-11 8:03 [PATCH] powerpc/xive: Remove (almost) unused macros Russell Currey
@ 2018-05-14 3:30 ` Michael Ellerman
2018-06-04 14:10 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-05-14 3:30 UTC (permalink / raw)
To: Russell Currey, linuxppc-dev
Russell Currey <ruscur@russell.cc> writes:
> diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
> index b48454be5b98..3b471c0193ca 100644
> --- a/arch/powerpc/sysdev/xive/native.c
> +++ b/arch/powerpc/sysdev/xive/native.c
> @@ -341,7 +341,7 @@ static void xive_native_update_pending(struct xive_cpu *xc)
> * of the hypervisor interrupt (if any)
> */
> cppr = ack & 0xff;
> - he = GETFIELD(TM_QW3_NSR_HE, (ack >> 8));
> + he = ((ack >> 8) & TM_QW3_NSR_HE) >> (ffs(TM_QW3_NSR_HE) - 1);
Using the #defines and ffs() here doesn't make the code any more
readable or maintainable.
We can just write:
he = ack >> 14;
Or if we want to be more explicit about it being the top two bits of the
2nd byte:
he = (ack >> 8) >> 6;
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: powerpc/xive: Remove (almost) unused macros
2018-05-11 8:03 [PATCH] powerpc/xive: Remove (almost) unused macros Russell Currey
2018-05-14 3:30 ` Michael Ellerman
@ 2018-06-04 14:10 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-06-04 14:10 UTC (permalink / raw)
To: Russell Currey, linuxppc-dev
On Fri, 2018-05-11 at 08:03:13 UTC, Russell Currey wrote:
> The GETFIELD and SETFIELD macros in xive-regs.h aren't used except for a
> single instance of GETFIELD, so replace that and remove them.
>
> These macros are also defined in vas.h, so either those should be
> eventually replaced or the macros moved into bitops.h.
>
> Signed-off-by: Russell Currey <ruscur@russell.cc>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/8a792262f320245de0174e6bcb5513
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-04 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-11 8:03 [PATCH] powerpc/xive: Remove (almost) unused macros Russell Currey
2018-05-14 3:30 ` Michael Ellerman
2018-06-04 14:10 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).