From: Yury Norov <yury.norov@gmail.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] bits: Introduce fixed-type BIT
Date: Fri, 9 Feb 2024 08:48:31 -0800 [thread overview]
Message-ID: <ZcZXXzEBxvyH470g@yury-ThinkPad> (raw)
In-Reply-To: <20240124050205.3646390-3-lucas.demarchi@intel.com>
On Tue, Jan 23, 2024 at 09:02:04PM -0800, Lucas De Marchi wrote:
> Implement fixed-type BIT() to help drivers add stricter checks, like was
> done for GENMASK.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Yury Norov <yury.norov@gmail.com>
> ---
> include/linux/bits.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/bits.h b/include/linux/bits.h
> index cb94128171b2..5754a1251078 100644
> --- a/include/linux/bits.h
> +++ b/include/linux/bits.h
> @@ -24,12 +24,16 @@
> #define GENMASK_INPUT_CHECK(h, l) \
> (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> __is_constexpr((l) > (h)), (l) > (h), 0)))
> +#define BIT_INPUT_CHECK(type, b) \
> + ((BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> + __is_constexpr(b), (b) >= BITS_PER_TYPE(type), 0))))
> #else
> /*
> * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
> * disable the input check if that is the case.
> */
> #define GENMASK_INPUT_CHECK(h, l) 0
> +#define BIT_INPUT_CHECK(type, b) 0
> #endif
>
> #define __GENMASK(t, h, l) \
> @@ -44,4 +48,9 @@
> #define GENMASK_U32(h, l) __GENMASK(u32, h, l)
> #define GENMASK_U64(h, l) __GENMASK(u64, h, l)
>
> +#define BIT_U8(b) ((u8)(BIT_INPUT_CHECK(u8, b) + BIT(b)))
> +#define BIT_U16(b) ((u16)(BIT_INPUT_CHECK(u16, b) + BIT(b)))
> +#define BIT_U32(b) ((u32)(BIT_INPUT_CHECK(u32, b) + BIT(b)))
> +#define BIT_U64(b) ((u64)(BIT_INPUT_CHECK(u64, b) + BIT(b)))
> +
> #endif /* __LINUX_BITS_H */
> --
> 2.43.0
next prev parent reply other threads:[~2024-02-09 16:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 5:02 [PATCH 0/3] Fixed-type GENMASK/BIT Lucas De Marchi
2024-01-24 5:02 ` [PATCH 1/3] bits: introduce fixed-type genmasks Lucas De Marchi
2024-01-24 7:58 ` Jani Nikula
2024-01-24 14:03 ` Lucas De Marchi
2024-01-24 15:27 ` Yury Norov
2024-01-24 15:49 ` Gustavo Sousa
2024-01-25 9:56 ` Jani Nikula
2024-01-29 14:49 ` Lucas De Marchi
2024-01-29 15:11 ` Yury Norov
2024-01-24 5:02 ` [PATCH 2/3] bits: Introduce fixed-type BIT Lucas De Marchi
2024-02-09 16:48 ` Yury Norov [this message]
2024-01-24 5:02 ` [PATCH 3/3] drm/i915: Convert REG_GENMASK* to fixed-width GENMASK_* Lucas De Marchi
2024-01-24 8:04 ` Jani Nikula
2024-01-24 6:16 ` ✓ CI.Patch_applied: success for Fixed-type GENMASK/BIT Patchwork
2024-01-24 6:16 ` ✗ CI.checkpatch: warning " Patchwork
2024-01-24 6:17 ` ✓ CI.KUnit: success " Patchwork
2024-01-24 6:24 ` ✓ CI.Build: " Patchwork
2024-01-24 6:25 ` ✓ CI.Hooks: " Patchwork
2024-01-24 6:26 ` ✗ CI.checksparse: warning " Patchwork
2024-01-24 6:49 ` ✓ CI.BAT: success " Patchwork
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=ZcZXXzEBxvyH470g@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
/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