mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: alexandru.elisei@arm.com, catalin.marinas@arm.com,
	linux-kernel@vger.kernel.org, mark.rutland@arm.com,
	maz@kernel.org, tglx@linutronix.de, will@kernel.org
Subject: [PATCH v2 1/5] wordpart.h: Add REPEAT_BYTE_U32()
Date: Mon, 17 Jun 2024 12:18:37 +0100	[thread overview]
Message-ID: <20240617111841.2529370-2-mark.rutland@arm.com> (raw)
In-Reply-To: <20240617111841.2529370-1-mark.rutland@arm.com>

In some cases it's necessary to replicate a byte across a u32 value, for
which REPEAT_BYTE() would be helpful. Currently this requires explicit
masking of the result to avoid sparse warnings, as e.g.

    (u32)REPEAT_BYTE(0xa0))

... will result in a warning:

    cast truncates bits from constant value (a0a0a0a0a0a0a0a0 becomes a0a0a0a0)

Add a new REPEAT_BYTE_U32() which does the necessary masking internally,
so that we don't need to duplicate this for every usage.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
---
 include/linux/wordpart.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/wordpart.h b/include/linux/wordpart.h
index 4ca1ba66d2f07..5a7b97bb7c956 100644
--- a/include/linux/wordpart.h
+++ b/include/linux/wordpart.h
@@ -39,6 +39,14 @@
  */
 #define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
 
+/**
+ * REPEAT_BYTE_U32 - repeat the value @x multiple times as a u32 value
+ * @x: value to repeat
+ *
+ * NOTE: @x is not checked for > 0xff; larger values produce odd results.
+ */
+#define REPEAT_BYTE_U32(x)	lower_32_bits(REPEAT_BYTE(x))
+
 /* Set bits in the first 'n' bytes when loaded from memory */
 #ifdef __LITTLE_ENDIAN
 #  define aligned_byte_mask(n) ((1UL << 8*(n))-1)
-- 
2.30.2


  reply	other threads:[~2024-06-17 11:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 11:18 [PATCH v2 0/5] arm64: irqchip/gic-v3: Use compiletime constant PMR values Mark Rutland
2024-06-17 11:18 ` Mark Rutland [this message]
2024-06-17 11:18 ` [PATCH v2 2/5] irqchip/gic-common: Remove sync_access callback Mark Rutland
2024-06-21  2:22   ` Jinjie Ruan
2024-06-21 11:17     ` Mark Rutland
2024-06-17 11:18 ` [PATCH v2 3/5] irqchip/gic-v3: Make distributor priorities variables Mark Rutland
2024-06-17 11:18 ` [PATCH v2 4/5] irqchip/gic-v3: Detect GICD_CTRL.DS and SCR_EL3.FIQ earlier Mark Rutland
2024-06-17 11:18 ` [PATCH v2 5/5] arm64: irqchip/gic-v3: Select priorities at boot time Mark Rutland
2024-06-21  6:23   ` Liao, Chang
2024-06-21  7:48     ` Marc Zyngier
2024-06-21  8:14       ` Liao, Chang
2024-06-21 17:26 ` [PATCH v2 0/5] arm64: irqchip/gic-v3: Use compiletime constant PMR values Catalin Marinas
2024-06-22 21:29   ` Thomas Gleixner
2024-06-24 18:22     ` Catalin Marinas
2024-06-24 18:12 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240617111841.2529370-2-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®