From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 963D63314CB for ; Thu, 6 Nov 2025 16:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762444906; cv=none; b=PRXfaqnW1SdlvBoHvMjTFTZgG4janKtcLIrDHBTnOqQIzIL1Q+W+CeY7RdmeboWQIsVk8n4Jou3aFqHN9F48a96nhw65XkZY1jk5Y+Z1sGuDUOesgUBYBtFenBg7v+vPhJL3idvgHaqTmuybnljkjwZ67ihHHL4XOziJIN9Fxes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762444906; c=relaxed/simple; bh=T9dOCjt5CSMA8b/M7JLaYkgOskmgR2ygjFafGQfTcfE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O7pb317hSHgkQY5ySS8NvpDjB4WpZPI99sbV6bgTRK7uOdXpKr0tSVodgTEjgWM24GX4OViUMRIo2c9bvMv/YSpBBesAcP6a4rs11NBbv7enw4qa3Vwd19igL508mTku0b0onwl/YL66XsBGN/14utOaCF9u1mlbs8GP30F2s1M= 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=TqFUfg9s; arc=none smtp.client-ip=209.85.128.177 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="TqFUfg9s" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-787ab220b1cso18293897b3.0 for ; Thu, 06 Nov 2025 08:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762444902; x=1763049702; 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=uDqvdpSXd7EVG4K3GSPuN1+lwa+x8rxJ7aM50JiFwXE=; b=TqFUfg9sdXxypsXTeE5BSr5Qkw8tO2/cIJTGInEFiTFfU5cxawi9hpV918beskopTK /6SnOKWCg0fYbXrnhClN6h/ZIDJ4hKq5K80QFj6VxjsZGVVErM0AHnnIBpSHYHq1r1pS 8Yxk9b6xcmhTp/sTdYFZaoEoARZJ8pcFux2xGerbAVMQqtK8XqjLNHMhF4PzVwrtHAdm R+CiwBInxL+6ZNI3IyjxHEyzQQMDawko9u6NiKv8LZfJbo+iN8UPF14mSG3wTNjFoQoz v26N7sZ2QU8jlslhMel0AWHK42O5moBUO2mtG/6vNATPQxCZ2Y2TIM2PntMcOdpJXv3F /zpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762444902; x=1763049702; 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=uDqvdpSXd7EVG4K3GSPuN1+lwa+x8rxJ7aM50JiFwXE=; b=exHKQNip8FpdlXBBp1tvv6aKg9kMKfwmnCG60SJFbKVECsDooOzATa/AnYSpHfRkG7 LW4yI4Dioq3ajhx7ITuCZ5wLhSDVDe4QCjjGs+OB4xvyR/AubJ8mo6DphzJGFnas307a 5eig9GS/UJJ31YP+gq/juSbLW7nfjMFOn9liZ7fY1Wc2qaU5tEflIXvRQcC7pL6Sfc5b 8bpJ13P4nnErI15Ggd9/bYLLJO8dtT2Xtv38h/q/dSaXl06ao3IQqIZVzZuuR5gPdwws k18IsM2IXg1uXo72h7MDm5YGpfXfWREt/6RoIolqXkJJbHSEF729yxru/57tFZH2BoU9 gCJA== X-Forwarded-Encrypted: i=1; AJvYcCWWOmVIivlNVJs7f9h8++AjjjCo44JHOP7l8M7jb0d8JqlfrSu5y5xLzfiO2hI26vzdtoE8s/zQAN8P@vger.kernel.org X-Gm-Message-State: AOJu0Yz9a92dhqgYOvKVN5qKDUm50yetHoz2Nl8Hjm7AHTd4FzU4dEjU Ca53hDcxgXT0npCGpPGeaaqEm936iUvtOw6/IiXphJfAetxg3gX4W3W1 X-Gm-Gg: ASbGncvwbU5VjnUm9LDk4uXW1KI8Yd8b0ZDRJsbZdu2jVKcWvpYG9NZk4c3DsEr9GjC E8032IPcatHRJqXqbdV80sWJw/J6SCrnb4fIHylgww8aBrlMMAwSsuY2OrQH+zoBAkDKwA4nyY/ 5gDxbCGUlb91OOKcAekCfO1cJBt0Ny25JLd0hobzjBEN2XtaPtMH37Oodg3w9E/ecNGi7zDKk43 pLvd+/E6RnDoyeAeX029vqHoRzDpWRY24rlGSB+Oeh5s/+V281J5AkJDRf9v9UJbrmsUfuqzY3Q C3tb5lMF4IusjixUgx+BXtrOry+mLp5ojFRFQXbnT6kmBa30Dkc5e7nMaUDWFy5khqF2nRPN5xB gJWh6l89WnIa5fBMQFsQh3Yb5yIP3mbKND5IcVPCphfJGLWdNw4NueWGvJCpCGbkUD8Tu6qjE30 ghPjca14GLwPSMkP/e7IAKQks/jvrQQakg X-Google-Smtp-Source: AGHT+IHH1OiCGEbzPId419SmPeowjgjZvd2uwuBPgu14uOeMTfnhF3EzyBaZ3Vf1fe9K5qAqRN9gOQ== X-Received: by 2002:a05:690e:2405:b0:63f:b1fd:3850 with SMTP id 956f58d0204a3-640c3b56ae5mr33952d50.33.1762444901924; Thu, 06 Nov 2025 08:01:41 -0800 (PST) Received: from localhost (c-73-105-0-253.hsd1.fl.comcast.net. [73.105.0.253]) by smtp.gmail.com with ESMTPSA id 00721157ae682-787b15d6379sm9121887b3.45.2025.11.06.08.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 08:01:40 -0800 (PST) Date: Thu, 6 Nov 2025 11:01:39 -0500 From: Yury Norov To: Andy Shevchenko Cc: Geert Uytterhoeven , Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Giovanni Cabiddu , Herbert Xu , David Miller , Linus Walleij , Bartosz Golaszewski , Joel Stanley , Andrew Jeffery , Crt Mori , Jonathan Cameron , Lars-Peter Clausen , Jacky Huang , Shan-Chun Hung , Rasmus Villemoes , Jaroslav Kysela , Takashi Iwai , Johannes Berg , Jakub Kicinski , Alex Elder , David Laight , Vincent Mailhol , Jason Baron , Borislav Petkov , Tony Luck , Michael Hennerich , Kim Seer Paller , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Richard Genoud , Cosmin Tanislav , Biju Das , Jianping Shen , Nathan Chancellor , Nick Desaulniers , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-crypto@vger.kernel.org, linux-edac@vger.kernel.org, qat-linux@intel.com, linux-gpio@vger.kernel.org, linux-aspeed@lists.ozlabs.org, linux-iio@vger.kernel.org, linux-sound@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 12/26] bitfield: Add less-checking __FIELD_{GET,PREP}() Message-ID: References: Precedence: bulk X-Mailing-List: linux-edac@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 Thu, Nov 06, 2025 at 04:44:31PM +0200, Andy Shevchenko wrote: > On Thu, Nov 06, 2025 at 02:34:00PM +0100, Geert Uytterhoeven wrote: > > The BUILD_BUG_ON_MSG() check against "~0ull" works only with "unsigned > > (long) long" _mask types. For constant masks, that condition is usually > > met, as GENMASK() yields an UL value. The few places where the > > constant mask is stored in an intermediate variable were fixed by > > changing the variable type to u64 (see e.g. [1] and [2]). > > > > However, for non-constant masks, smaller unsigned types should be valid, > > too, but currently lead to "result of comparison of constant > > 18446744073709551615 with expression of type ... is always > > false"-warnings with clang and W=1. > > > > Hence refactor the __BF_FIELD_CHECK() helper, and factor out > > __FIELD_{GET,PREP}(). The later lack the single problematic check, but > > are otherwise identical to FIELD_{GET,PREP}(), and are intended to be > > used in the fully non-const variants later. > > > > [1] commit 5c667d5a5a3ec166 ("clk: sp7021: Adjust width of _m in > > HWM_FIELD_PREP()") > > [2] commit cfd6fb45cfaf46fa ("crypto: ccree - avoid out-of-range > > warnings from clang") > > > Also can be made as > > Link: https://git.kernel.org/torvalds/c/5c667d5a5a3ec166 [1] > > The positive effect that one may click that on Git Web. > Ideally, of course, would be an additional parses on Git Web kernel.org uses to > parse that standard "commit ...()" notation to add the respective HREF link. Those flying over Atlantic or cruising cross Caribbean would disagree. :) > > Signed-off-by: Geert Uytterhoeven > > ... > > > + BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) > \ > > + __bf_cast_unsigned(reg, ~0ull), \ > > + pfx "type of reg too small for mask") > > Perhaps we may convert this (and others?) to static_assert():s at some point? > > > -- > With Best Regards, > Andy Shevchenko >