From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 455E525F78F for ; Thu, 11 Dec 2025 18:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765479205; cv=none; b=qPZv8ltwwB+bs3eQIQoqiCFYy6tscDJwg9T1S3MJqIy8FdusM5BaHNHSBrucpyM2ol17elZvv2pWkUk+yc7KMzEBDjQv6f3CBkQWdQUaJocWLOOs71k0DZVJKVrvR3oCyTqUyldHpS2FVhkQaUZRWm24xVo1uegOS7sGv4a7tcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765479205; c=relaxed/simple; bh=VkB+6zy76nPRjdv7lnMqbpoc024KlOHN88aqW2VQG5M=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MU8yMw2cGF390MWK8rd1aHDhee/Ffy5fX+H3yaQuzS6So+pKpdsxLfKsaTkc6q9bZFn3ivICsgO6rbj9ziteOacHreTn3B/7109B/Ln8DGt35ty+hl5kPHIbh51R4k7adfdH29xSAFKojWrQdlzx0OvK3qiTEAL/qqnlE5nYkRE= 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=O2NZt5Wz; arc=none smtp.client-ip=209.85.221.45 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="O2NZt5Wz" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-42e2d02a3c9so304696f8f.3 for ; Thu, 11 Dec 2025 10:53:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765479201; x=1766084001; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=SnAKCx6pcJwqau2tXcc6tEiu3zuLgufxgOh3790LZMo=; b=O2NZt5WzIlniranqt6WtnuPmJ1hcOenLizUkQLDaUPkLqwiaZ/YW2FxhOdxig3iuyt Y5cVmLeqrp+oJP5OZFjO+C/A/xBt8hKY+Mob5rWjq5E08T6wRqJYdfO4EZlVVoW4igC8 uQtmr9yfzpvsnhp7qc0gYbCRVzEcRiGn+AJcoFsRPfGVQ5RWN21Zxkq2JJf4je4qJD1u bKX5CsYsQ2oqsas17VXnVdLmp1pYszetPB0Wh50t5O81yDg92GE3Wu7M64CK2DTwyxr3 NlMcuBRFXOwmp45aQ5k1lLXVU4qC/k/vlx9si4d0vNWw6h0P08j2+wdYngUFQG5Q5mMx 1F4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765479201; x=1766084001; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SnAKCx6pcJwqau2tXcc6tEiu3zuLgufxgOh3790LZMo=; b=MR66pl/dplw9mX1QYH65vsMRz1kzbQ1GYW2p+jL4HfxPO7ZGiIAph/+T0fvSvFcuKM wT2F69xVJyCQ6Ix6pFbrqqDPLSMZAk9VD2iKFJlvBd88tZJ0LuyEUiPWQBUvb3TOXe5k sKLXQIZuzWlpkUYVv+ibG6Zljoyh6tD9LaUI39wVWDZGJ+uUHJXklE2GsToBOgyB+yky 36VmHwZm2v2w3ib9COuBqRJLywJ6ZLnkFvbnIwKBj/Ea/jqW7INRZbaKGq+CzjExUWvj wwchxORarAvpZ0/NBK25b/pPscguZ3OIuogTZEte5sgj3JMKKXTLPf/LQBRp5TEQyy7s obsA== X-Forwarded-Encrypted: i=1; AJvYcCU7n0GR+my8NRiFxCTODn7Dm7LFXL91VTLWjlFwpngcBxYduhq2KPGVNZgN/ctwJc19qjZEfggJU5tif7g=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3X6fy2SPA1fhbI08ztcR36TGnZluGtXAkcWAOby80g/Pzgitp uN0HFOjT2b6IVtP6W/VZ7+gjASP6+VhhpYYw5zCgs2X7u5yaadDxbsll X-Gm-Gg: AY/fxX47zeBm3ekpLr5RCPP8WCIqALcYrz7BT+fFBjQMvGkRNPyiquSMMwI8bmxumip Qp78QuDvqC00JWPjBmBxlUe66xWH5z668VAPLSXV3QUf7mw2aD/r//Rq9PwLzN5DRjJmjdl1GdJ +m21dksQt0Od2odn0N+QYSv5aY+vdXq53o5xDNW2wllZ9bhONgeqm/udkkdMdWeigLoQf/qMeAd QREDmonP/YQTd87Q+W26qfSBtI6X3R0z9fdBaY6YC2DeTE/zGeMpsAkgP/lbw/8ZzdhhLjtMssh 36gZZrHUaRKIjxIAy68EK0vlYtVpQS769M55vigWx7tXDgqZbTSXqzeVQdOqEWr0ciwbSwLLCgO kGcjEZO6d9dgyIYf2Ymvzfl8ghHO5MYHiSlwx1daAeudQ7SO/RlYTs/ZvxJQ1S4JRq6NCDS5TbA 6CRAs34rHRtKgpjHvZtuucOrRSMxvDCAdvcPRdOYJ2fdTgi2VUcP1V5RmOBLHMqeE= X-Google-Smtp-Source: AGHT+IGOoJHbwGg7uIW+U8a9VenNXQ/ylQ3MqrCzzXMSwYQ+hNbjIYNLEepLtruEb4GMCFkRWKX2Hw== X-Received: by 2002:a05:6000:420b:b0:42b:3701:c4c0 with SMTP id ffacd0b85a97d-42fa39ca093mr8176360f8f.5.1765479201402; Thu, 11 Dec 2025 10:53:21 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a70665sm7773345f8f.17.2025.12.11.10.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 10:53:21 -0800 (PST) Date: Thu, 11 Dec 2025 18:53:19 +0000 From: David Laight To: Yury Norov Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Geert Uytterhoeven , Nicolas Frattaroli Subject: Re: [PATCH 3/9] bitmap: Use FIELD_PREP() in expansion of FIELD_PREP_WM16() Message-ID: <20251211185319.4daf6e4f@pumpkin> In-Reply-To: References: <20251208224250.536159-1-david.laight.linux@gmail.com> <20251208224250.536159-4-david.laight.linux@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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, 8 Dec 2025 19:54:37 -0500 Yury Norov wrote: > + Nicolas Frattaroli > > It's always good to CC an author of the original implementation, > isn't? > > On Mon, Dec 08, 2025 at 10:42:44PM +0000, david.laight.linux@gmail.com wrote: > > From: David Laight > > > > Instead of directly expanding __BF_FIELD_CHECK() (which really ought > > not be used outside bitfield) and open-coding the generation of the > > masked value, just call FIELD_PREP() > > That's fair. > > > and add an extra check for > > the mask being at most 16 bits. > > Maybe it's time to introduce FIELD_PREP16()? > > > Signed-off-by: David Laight > > --- > > include/linux/hw_bitfield.h | 17 ++++++++--------- > > 1 file changed, 8 insertions(+), 9 deletions(-) > > > > diff --git a/include/linux/hw_bitfield.h b/include/linux/hw_bitfield.h > > index df202e167ce4..d7f21b60449b 100644 > > --- a/include/linux/hw_bitfield.h > > +++ b/include/linux/hw_bitfield.h > > @@ -23,15 +23,14 @@ > > * register, a bit in the lower half is only updated if the corresponding bit > > * in the upper half is high. > > */ > > -#define FIELD_PREP_WM16(_mask, _val) \ > > - ({ \ > > - typeof(_val) __val = _val; \ > > - typeof(_mask) __mask = _mask; \ > > - __BF_FIELD_CHECK(__mask, ((u16)0U), __val, \ > > - "HWORD_UPDATE: "); \ > > - (((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) | \ > > - ((__mask) << 16); \ > > - }) > > +#define FIELD_PREP_WM16(mask, val) \ > > +({ \ > > + __auto_type _mask = mask; \ > > Is __auto_type any better than typeof()? There is likely to be pressure for a global change soon. 6.19 contains '#define auto __auto_type' to match C23. > > > + u32 _val = FIELD_PREP(_mask, val); \ > > + BUILD_BUG_ON_MSG(_mask > 0xffffu, \ > > + "FIELD_PREP_WM16: mask too large"); \ > > Not necessary to split this line. Only because I removed a level on indentation. > > > + _val | (_mask << 16); \ > > +}) > > Can you share bloat-o-meter and code generation examples? > > For the next version please try to keep as much history > untouched as possible. Even the minimal changes (not moving the continuation markers) change pretty much all the lines. So It really isn't worth trying to keep it. David