From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f51.google.com (mail-yx1-f51.google.com [74.125.224.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C85B71E1A3B for ; Wed, 10 Dec 2025 18:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765392345; cv=none; b=g3flVtwITQSweD39HXlPXoilEFPERVgNHEF0z5516DirhwpdL88a021FbwoNFlTe46dbSRI3fm/QeP8vppQ7R9k6952lrW1cqNp9OxzNV4PPXy3T2Yp7Jl2G92Re8XEb+SuQSughSL3BKbZL4RLWC4Iq2NFiQ72IHCNtYq/XvTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765392345; c=relaxed/simple; bh=t7/Putf0iwaHC3Fwy9HCNAfeymtD9y6WUelPzXFP2Qk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R6mTawHIoXDoqqqPUlnsQyeqzfkbFh6NXH9C5zIXEuCYcl9WFZiEBfDKwhVWQvX4X8guvdgGj7Lm/DgZ5C961i9sI0Qyj5EisjUQK/lG9/6hl9gWvEOpdIwPpnezDetCOY7Wv3wo5NU2iF+Coaj/sKjmF/s9eQN90n1zL2IB3NA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iURLgJFw; arc=none smtp.client-ip=74.125.224.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iURLgJFw" Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-6433f99eb15so127159d50.3 for ; Wed, 10 Dec 2025 10:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765392343; x=1765997143; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NKWMAGHjySPur4SPWNwyNpZjWd2mvX3sGd2Im7efoPw=; b=iURLgJFwEw+KnLSa2GZhP0G/xmhccY5qWJms2ru00fJkOUgqcDZyRN1QfCocYf5sBR wPOEmvWDEi9fpx0rgvERrdp86G8LpbrpG8Dz5rqYCEcxluZn7/Yz3hrKz+nHzNZMsYcS gpN2zIFqZ7/ZKsDNpVZBQ94irhagXStbGHFw4UviJhN6HO5q2Wg6bLQPalsrWiw1IcH5 bKuGG1zezDdJ84PQYY8ri6tZfxwCuGKpPgvT205kitRACOjzYoqGqwyBte71P/znlo0b JC3GxODOV4VeKfM5Kw/dtUm90mnnC2JxVABWRFGZhFXz2bWLDljGAc4trnuAq37vuWBG N/rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765392343; x=1765997143; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NKWMAGHjySPur4SPWNwyNpZjWd2mvX3sGd2Im7efoPw=; b=DNB2XjD7p14w9FFveOBiZqCLdojIrJSViubHVPlO6uX3is2Ujoq8G+Gkktjs66p+jZ Gr0mX/kfBzAWIfnD82SxKgxDQ9cLctnl/fmJcGWPF7+COk30C7VdR/Rg5nuscUz92q0w tAyhS4rFMurUc4txFwPl1hw3JPjhhktNz7jl++qVe5F2Lr51W/PlKH/c5TodywOhtSqG Lon+SNmZM8+HOrkxihLaT7bgUEVUvsTfMfTOOb+zXSVxfB786Ce9M/9+kZSrbjGADuFE 40xTf+kfa5TW7qaddh1JEZi7zd+AQiCKuS+LI4QaoJ2GI+IRsTajbOBCrjguWHiIjg5A L4tw== X-Forwarded-Encrypted: i=1; AJvYcCUxFtTMt+ebS7CEopIkG63hNo6Alxrba2DmaygoC6IZn3KVhqLduIwIh12xvBtzhNlO5tL6vnxRi/T29f8=@vger.kernel.org X-Gm-Message-State: AOJu0YwgUbOXJ1Dik9GNtOOL3y/J1SuUgzC+wQlsDi+iysEkvJWzV5j0 cE1j7H4IcWxDMSR+yTjgqzQHN5wZQkrfk748vrnm4qkG9No/M98vji2a X-Gm-Gg: AY/fxX53+Z5VcGkr8xtkYhlMS5RcTES+57EJhg6AdlUes+/hAclvNm1qhx4Yjj3HVdn p8ZfVqsnVTMifuKuSJn+/aNnxwYPE8YFXeBD8+ooaYyOsy3y7CAih5QNWVGKLjx2+oJZUunKTFi TLBIFc9Qek8it0/nT/G1iNemDt7DD20lRtnkvK5HfBr4nINLxnuLIpmBa2t3vC60zoIcJjPjZ+e q2UBIyHqXD2rW2fwXCePu+1q1UxlplV7zuemOi/WrJuFIIphNwYdm0Kte+Fr5QVSfLOC3wHWNce pMGpeM1pAOSzD2jNyXILGvegOp+Gc+J9p719t4hvScuffIKuIjxLZUHSkxoh/2zVgmCUC/857DF Yvf/i44G1dArcYosFtsS3xRLW9v0MB9XTZREtAL/cSDqV3Kg20VU/Z9FXaZ7w4eoxWyd3oPZk7M VsGH8Kti8= X-Google-Smtp-Source: AGHT+IHq6bwat4MhwQe1AguHAFxnp5U2Bs8TJxUWtTtn0EtgRmStw4pjkxRdMxlyDvVig7YOr1+nUQ== X-Received: by 2002:a05:690e:4284:20b0:644:6c79:62d7 with SMTP id 956f58d0204a3-6446eafb7acmr2315073d50.63.1765392342590; Wed, 10 Dec 2025 10:45:42 -0800 (PST) Received: from localhost ([2601:346:0:79bd:74ed:2211:108a:e77a]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64477d3a336sm189571d50.3.2025.12.10.10.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Dec 2025 10:45:42 -0800 (PST) Date: Wed, 10 Dec 2025 13:45:41 -0500 From: Yury Norov To: Andy Shevchenko Cc: david.laight.linux@gmail.com, Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Geert Uytterhoeven , Alexandre Belloni , Jonathan Cameron , Crt Mori , Richard Genoud , Luo Jie , Peter Zijlstra , Jakub Kicinski , netdev@vger.kernel.org, "David S . Miller" , Simon Horman , Mika Westerberg , Andreas Noever , Yehezkel Bernat , Nicolas Frattaroli Subject: Re: [PATCH 4/9] bitfield: Copy #define parameters to locals Message-ID: References: <20251209100313.2867-1-david.laight.linux@gmail.com> <20251209100313.2867-5-david.laight.linux@gmail.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-Disposition: inline In-Reply-To: On Tue, Dec 09, 2025 at 05:51:48PM +0200, Andy Shevchenko wrote: > On Tue, Dec 09, 2025 at 10:03:08AM +0000, david.laight.linux@gmail.com wrote: > > > Use __auto_type to take copies of parameters to both ensure they are > > evaluated only once and to avoid bloating the pre-processor output. > > In particular 'mask' is likely to be GENMASK() and the expension > > of FIELD_GET() is then about 18KB. > > > > Remove any extra (), update kerneldoc. > > > Consistently use xxx for #define formal parameters and _xxx for > > local variables. > > Okay, I commented below, and I think this is too huge to be in this commit. > Can we make it separate? I'm next to Andy. The commit message covers 6 or 7 independent changes, and patch body itself seems to be above my abilities to review. This should look like a series if nice cleanups, now it looks like a patch bomb. > > Rather than use (typeof(mask))(val) to ensure bits aren't lost when > > val is shifted left, use '__auto_type _val = 1 ? (val) : _mask;' > > relying on the ?: operator to generate a type that is large enough. > > > > Remove the (typeof(mask)) cast from __FIELD_GET(), it can only make > > a difference if 'reg' is larger than 'mask' and the caller cares about > > the actual type. > > Note that mask usually comes from GENMASK() and is then 'unsigned long'. > > > > Rename the internal defines __FIELD_PREP to __BF_FIELD_PREP and > > __FIELD_GET to __BF_FIELD_GET. > > > > Now that field_prep() and field_get() copy their parameters there is > > no need for the __field_prep() and __field_get() defines. > > But add a define to generate the required 'shift' to use in both defines. > > ... > > > -#define __BF_FIELD_CHECK_MASK(_mask, _val, _pfx) \ > > +#define __BF_FIELD_CHECK_MASK(mask, val, pfx) \ > > ({ \ > > - BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ > > - _pfx "mask is not constant"); \ > > - BUILD_BUG_ON_MSG((_mask) == 0, _pfx "mask is zero"); \ > > - BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ > > - ~((_mask) >> __bf_shf(_mask)) & \ > > - (0 + (_val)) : 0, \ > > - _pfx "value too large for the field"); \ > > - __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \ > > - (1ULL << __bf_shf(_mask))); \ > > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), \ > > + pfx "mask is not constant"); \ > > + BUILD_BUG_ON_MSG((mask) == 0, _pfx "mask is zero"); \ > > + BUILD_BUG_ON_MSG(__builtin_constant_p(val) ? \ > > + ~((mask) >> __bf_shf(mask)) & \ > > + (0 + (val)) : 0, \ > > + pfx "value too large for the field"); \ > > + __BUILD_BUG_ON_NOT_POWER_OF_2((mask) + \ > > + (1ULL << __bf_shf(mask))); \ > > }) > > I looks like renaming parameters without any benefit, actually the opposite > it's very hard to see if there is any interesting change here. Please, drop > this or make it clear to focus only on the things that needs to be changed. > > -- > With Best Regards, > Andy Shevchenko >