All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Yury Norov <yury.norov@gmail.com>
Cc: Michal Schmidt <mschmidt@redhat.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org, Alex Elder <elder@linaro.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] bitfield.h: add FIELD_MAX_CONST
Date: Mon, 20 May 2024 15:26:37 -0700	[thread overview]
Message-ID: <20240520152637.065bb8a8@kernel.org> (raw)
In-Reply-To: <Zkuksm3K+pKugjgF@yury-ThinkPad>

On Mon, 20 May 2024 12:29:54 -0700 Yury Norov wrote:
> > A simplified example of what I actually want to use in a driver:
> >   #define DATA_SIZE_M GENMASK(3, 0)
> >   #define MAX_DATA_SIZE FIELD_MAX_CONST(DATA_SIZE_M)
> >   static void f(void) {
> >   	char buf[MAX_DATA_SIZE];

You need a "+ 1" somewhere here, right?

> >   }
> > 
> > In the implementation, reuse the existing compile-time checks from
> > FIELD_PREP_CONST.
> > 
> > Signed-off-by: Michal Schmidt <mschmidt@redhat.com>  
> 
> Hi Michal,
> 
> So... FIELD_MAX() already requires the _mask to be a const value.
> Now you add a FIELD_MAX_CONST(), which makes it more confusing.

+1, I think this is doing too much in general.

  reply	other threads:[~2024-05-20 22:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 17:27 [PATCH] bitfield.h: add FIELD_MAX_CONST Michal Schmidt
2024-05-20 19:29 ` Yury Norov
2024-05-20 22:26   ` Jakub Kicinski [this message]
2024-05-21 12:33   ` Alex Elder
2024-05-21 14:44     ` Michal Schmidt
2024-05-21 19:52       ` Yury Norov

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=20240520152637.065bb8a8@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=elder@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mschmidt@redhat.com \
    --cc=yury.norov@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.