From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 2433B27A462 for ; Mon, 16 Feb 2026 08:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771232213; cv=none; b=ubOgyH9KLWOOhu+zZqIv7CG8KoyIGhmoPPVlpbF5hDj3ACgb8f7rPSJv2LuJIGmlAEHcNPpmLmej+e2YOjZe9HPTqXv21ez9Sr0TkI2ZEpMVedOFbRLoqVNc5ZO/yOrW0P6TVX41BtmFUqTX2jiK0zIzGqEcxJclieOHbMaL1EA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771232213; c=relaxed/simple; bh=RRworO0e0jB2L++N8t+MaRtV5KDsytl9rjBp2wDeAQ0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jXgCH8BF3QPDegrHXARiX16VB/7o45CDA7HhTsD8PB8taU8jdrDNumny8Paw7Ofi7Txk6O9zFIvgvjDk5CpyhkgaNMwViRN/5EXOLH64UOmtwphgeEVs4Q1IxtKlPGoA3vsqBnt/mmsZ1sNgXPbYsKJRLYco+ysHp5N+1WmzpUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YCnDzinu; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YCnDzinu" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837107e0a9so25897585e9.0 for ; Mon, 16 Feb 2026 00:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771232210; x=1771837010; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/g4FBr0hx+U1hrupB09478t2hk2gU/mPpH49qC+dJe0=; b=YCnDzinuapXPS7/JjZzst5cUB8vkI9G4nv+6zH2CI8jkGeKsCQekswlMqsgYXObtDw ZFALackEriP7bkXqc8jW0oolr3t7NQZsy8LGQxzQRlB9B0x3Tt/ulBNcLBnJDMOpXMCc 7+XlFdAZaLa4gQj47fThujX4VFI0Ki/Fotj2LsjgMnLNVW7+Of28nF4TrdMfqjSlxE4T WNs68f+TCVnSkDwZ9yaM9Rp5QSXBlqywCbpovA1FMOlcV7Y6cNmelSGj6HUoQSlPH0vJ JORdvGX//s322vgh2fTRf5GjETg1r43HsJ9cG4F7So5w8fRoJIWvn8g5a3AD8XiY/GV/ UrOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771232210; x=1771837010; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/g4FBr0hx+U1hrupB09478t2hk2gU/mPpH49qC+dJe0=; b=pw5wm6Vy63VpDu+rCmSjZfdSqA9eaFoMpiJr1lXJBvg1xhwbUJ78Pq1e7EYN+bkdSk aDY6ysXq8ywfz+x4KfMOu1ooUR1n2Nveq0o0ByJF/Ywd8+wx+eApq8XltpwPeMA6Kzse WRiCTiIcDoMpsdHkfaJ+nz43H+XKJAUuKUCYn9P5PrNHMT+zQmZ0mHxlmBXqqf+GA0W0 XA+1KhYJMPb3Xi5PF27WDdrShP9InWlsR2qRnyaL6HSO+Y6yNIe4R8pnWGWvxFm/i/AE dmag/OKiIA9DENqgvWPv/Tlz+Adzm1/OKYGSizEKeDnkV8zGlo30XqVqY+BBSskPU08+ qzeQ== X-Forwarded-Encrypted: i=1; AJvYcCV/PoYk61RiY+ad5COIpobol10CqcaNF9ufp0NvIumn53+Ny+votUKy4kl1zBa+nGH7/3qtluHu92jk1wU=@vger.kernel.org X-Gm-Message-State: AOJu0YzMyS+6tontekNV7ZFD5lJQaXZvaRPXWa0iiLMYZrud2dAVqnrN 1hxWN9HJZ73LkaXttduYke7Fgy4+arHQdSKZLBFZj1g5VoA5iRwF8Rmp8nL76b3urCDy8RZsuYA 3B4D9Q3zmioZ/3gZa5A== X-Received: from wmqy18.prod.google.com ([2002:a05:600c:3652:b0:483:6e28:c1a5]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c172:b0:480:3a72:524a with SMTP id 5b1f17b1804b1-48373a5d591mr154526285e9.19.1771232210394; Mon, 16 Feb 2026 00:56:50 -0800 (PST) Date: Mon, 16 Feb 2026 08:56:49 +0000 In-Reply-To: <20260216-register-v6-4-eec9a4de9e9e@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260216-register-v6-0-eec9a4de9e9e@nvidia.com> <20260216-register-v6-4-eec9a4de9e9e@nvidia.com> Message-ID: Subject: Re: [PATCH v6 4/9] rust: num: make Bounded::get const From: Alice Ryhl To: Alexandre Courbot Cc: Danilo Krummrich , Daniel Almeida , Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Boqun Feng , Yury Norov , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , Eliot Courtney , Dirk Behme , Steven Price , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Mon, Feb 16, 2026 at 05:04:40PM +0900, Alexandre Courbot wrote: > There is a need to access the inner value of a `Bounded` in const > context, notably for bitfields and registers. Remove the invariant check > of `Bounded::get`, which allows us to make it const. > > Signed-off-by: Alexandre Courbot > --- > rust/kernel/num/bounded.rs | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs > index 8e4c08924d96..b09b93cd0c5c 100644 > --- a/rust/kernel/num/bounded.rs > +++ b/rust/kernel/num/bounded.rs > @@ -379,6 +379,9 @@ pub fn from_expr(expr: T) -> Self { > > /// Returns the wrapped value as the backing type. > /// > + /// This is similar to the [`Deref`] implementation, but doesn't enforce the size invariant of > + /// the [`Bounded`], which might produce slightly less optimal code. The unreachable_unchecked() hint is const, so I see no reason you couldn't add the same call in `fn get`. Alice