Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2739322lqo; Mon, 20 May 2024 15:26:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyXEH6zWw9CATIJXnZs79c3SkYiE7Kp8RddkmGE3jLR66VqxNJ75vTdppSuz8YcfJT5233+IYfNU3Y5syiLnrMn2wXRWj19EyxI9ofMQ== X-Google-Smtp-Source: AGHT+IFPUUcujBUc65woojV9mTNJxE3mgJqvwly4DJpPEMuGMWDKUnrKvFcfM91I3OPVxAEYZOoM X-Received: by 2002:a17:903:110f:b0:1ea:b125:81a2 with SMTP id d9443c01a7336-1ef44161e50mr349194605ad.53.1716244005432; Mon, 20 May 2024 15:26:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716244005; cv=pass; d=google.com; s=arc-20160816; b=kqnx/DcvYYlLDQ5AYPAyr8SSOQBN9rS2kh4N45c5gZFIkFavleNEco5Q5Tle31YQ3e exN0VWb83afvqPX2eD94TnQWTjytdSuW7xmPuNUGt8xSwiwAiXOgr7XBPdogUZs4cywh MOs32QA18bxWKu6oHYfWp0X2/3ty0iIveRasuP2m0j2lZXqtLyIqy/Yeq4NAHaEPXOD+ czfkWFU98lBDNATExYY80DJd9rWFN9h3ys0Sqyu+SWUh6bwSo0am+EIsyi6+X5ttMj8M iMpPAo/oZnR+Lp3zfeGu+TF6kq8Qa1YnAp/vTcK1a9tY8JaKgXQgqkGJafZW2MBQ++7X 3fag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=5Yi8wdHN7toJPT0QdT4JG1Ij9ei+EezEkD4gYX3ccew=; fh=HYqRkqZH8nFyj/s5dJz9nqDFWKm43RN76P6dUDHS9e0=; b=C4RCy20Heab1ZuCx7UOdJLNYb4IZxzXhzFG274JfBz5IBd2AANlNSWVgJR00ARXH6X 2bxGYd/XCESK0s/n5vYPVkaI57x1lSt5TtXDjs27xaBTPLg/Qic8LcwFxA6yb+DyGCWk 7if9MuJGCyfogwAoAl83fcDgRCRR9gns9lkUcaSmbxY+JT4nOU5hjP1oyVYDgHB8Vt6c S8KT8cL0439JmS9g7QWdTmHNwaUbILCzz74mO1EqjiHmi11l5ElW0ZOe7f9pYkR1w/Ft g8fH2RBbMRqnneocCeg+qoj8joJcMjnL61lp1mWA0arWH+5/xRa/Kl0h2glJrLIwqg3U habg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rGlturNP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184213-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0bf316ecsi238022375ad.231.2024.05.20.15.26.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 15:26:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184213-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rGlturNP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184213-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BF7F6281B28 for ; Mon, 20 May 2024 22:26:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA00374D4; Mon, 20 May 2024 22:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rGlturNP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7C4E1C2A3 for ; Mon, 20 May 2024 22:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716243999; cv=none; b=fFBLBXQ14S590o/yt7xqmRs1WZXCfy/ohUjv9aYce33WrgMF52wa/l3fOxSuc9kCFI45PSVtJAXhvQ1mdg1DZ/3hWNrqoa4qa3jqsnc0cFsepLIh4eFMY4PbMrDoSRrMC64HPpw6YAs4XAhoK8q4UpRQP+5lG0tJHBq4uk8WmWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716243999; c=relaxed/simple; bh=gwu5FyuHCMVc0xOUkh/7L7e4biABQM4vpY8lMwY95hI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=chtd2po3gC+h0jJzKsPg2jETZln6nYElXhmesQpnOGZfYDCVF9ha7sbaSIJnIRsQYsvQ8CwqQySVQmiXCz2VeN0S2InD0TNJlpAKECybRt6F1nzCIdQMkbms6oY24Pg9OoAwIuHi7e0lkXANJBtg8jLyVv0HQIzWJp7sE+DONvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rGlturNP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 407CDC2BD10; Mon, 20 May 2024 22:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716243998; bh=gwu5FyuHCMVc0xOUkh/7L7e4biABQM4vpY8lMwY95hI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rGlturNPkIfEQkNGjboR3s1nlMNlWitEe+OG65p+glP+HdFP/APv8SitdF2f1GGiy 40P/lOQ713wfV+7TX1S3s4cfhJaVcMA796P/pQLWXWK+BpKP+BiBpjpFCdQH+F4H6J LAZtn6snog+QfuyCMB1BDPyZmkHBoY7Nxd+d0RKNes2b98kLhH10KJ40+J2gCsVP6s YT5XRFJyuhKbuSmIJ1LoCpgOd9Kkgjv5EwDEyRntfSCSaE7VhsPqIi8lESCbn+7Koq hf6P0JEeyF6FaDJa8qaBIevcN+u0nuMSFpO6rPtPDgHxUyQNPmpyTDLJ3pbOa771mT xTDJU1ZRKzNNA== Date: Mon, 20 May 2024 15:26:37 -0700 From: Jakub Kicinski To: Yury Norov Cc: Michal Schmidt , Rasmus Villemoes , linux-kernel@vger.kernel.org, Alex Elder , "David S. Miller" Subject: Re: [PATCH] bitfield.h: add FIELD_MAX_CONST Message-ID: <20240520152637.065bb8a8@kernel.org> In-Reply-To: References: <20240515172732.288391-1-mschmidt@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 > > 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.