From nobody Mon Feb 9 01:21:22 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 288103BFE3C for ; Tue, 3 Feb 2026 15:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770133609; cv=none; b=RMxHGp0rlHn7L0/yBhFproLp9jaBqsCOjLSSLEcsFb4jiVsuIWpIN37Zy+wda+vtNan4SJK8sulcmyZv4G5d2SMz4i8EGXudafq7L94fXi2+U71+vi5VV7m1RADIRbkCRKZfhjRiWYcZnbuTPjYPCe4oqrh64Tr4wm/5Oce7p3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770133609; c=relaxed/simple; bh=WtZdKvjX12D2Jmn1kMkn/+vs+NvlqXqrgcd1O83Ixd4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TV3IJfpk6bVetBqrH+02k8WAoJ3pdytjQrwsV3yvsvuRLwu/6JRHkIwsOovo/sDF7cYg9B6OuwcOmUqdVbfSJ3cagv8vh38q/n6e/pO9jCCMCbnfT5VfBXf+7lN4fYYjVpICv9pQ9/BNUHtv5S/ITyrc/KdVO9woF5YxtsKlx6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JMhDliBQ; arc=none smtp.client-ip=74.125.82.202 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--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JMhDliBQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2b71d3ac508so5518403eec.0 for ; Tue, 03 Feb 2026 07:46:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770133604; x=1770738404; 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=Wdhof5UcFa0LauNDEG7A5hw9JfGF2S2FIbHiIBJlkVI=; b=JMhDliBQdB401m4c4C0KNuAymBVfVm7HIC3RuXQTEm/8bbPFzsTTksVSBFYkqmOyas TXkhkwlbVMspSvdCp5nC0BM718ZtxV7B48osVyq9e1zAuefYTAuJogGA5DHYFgwoxQ6w xcMWnRMmRdSShoDOXPoQLtJ+C+H2dnQr6FndrE1wF7Ql7lTZ/kYzmsVGqNdTLUxlo0Ja a7QdvpZKPZnEUyFzXIvct+1HAHp+4atlbE5lFJJbF2SIgOCQ4MS5BAqTvbO1Q8VxgH4z u4EbCQjPrPxXbgmM+oVuRXGuHU84jceziqxUbHg2fIGaFLSa0+mB+oiPSypwmS2vmRCU MKmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770133604; x=1770738404; 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=Wdhof5UcFa0LauNDEG7A5hw9JfGF2S2FIbHiIBJlkVI=; b=h/6gaAYBzXMCLojhcAymgZUsFhbTgBrnJmXUFRGXXjkfNeYk3l2tX6n2ymPULntZBY cz+tb2Mdh/M2HcOAG1l3iQOB9veJ3cK6D3DmxQjt806DhQ2W5qo8/T6lZaZvPXQ8NZJM licEvyktkcGrO+lS24VV+f0kTjutXwoJg453yOWN1SmDpXYnxPTAYYdQonCOh9S19lNj i5sr5gUGQzpybidTa4b2zaEKOeJiOHg+uNe8iRtu9+2OMuHu3Dg1praGb0MSeD7OQOm9 ERsLBsjbTlyXXi8AGDFmV1SZcH9UBrt55YDn0hb6T9tZ1W1dDLHkq6X/9IQxLI+BPx8o 6RpQ== X-Forwarded-Encrypted: i=1; AJvYcCVaTNvQgcd8WTAjLbSQWlrt/KJFHTG/vz9jquctdx2G0rX37yjnxNxGJ5cJZoJis+a7nJfqVThctyKJ83M=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6Y1mVUIcs1TI6+jCAIDBH72ZVhRtvr72AYr3txTvlEpAHzqir 9Yj4XjNba+JAuJ3WQbiX6D+Vh6m5OAD3wAdfyW0fIca9Qj6kZxUVjhMJoqsc34fvtCUbVQOXn4G MLy6JMmaX4w== X-Received: from dlcip4.prod.google.com ([2002:a05:7023:c084:b0:124:a6e8:e9eb]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6281:b0:11b:9386:8271 with SMTP id a92af1059eb24-125c10081bamr8120436c88.46.1770133603693; Tue, 03 Feb 2026 07:46:43 -0800 (PST) Date: Tue, 03 Feb 2026 15:46:34 +0000 In-Reply-To: <20260203-qcom-socinfo-v2-0-d6719db85637@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260203-qcom-socinfo-v2-0-d6719db85637@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1770133593; l=2442; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=WtZdKvjX12D2Jmn1kMkn/+vs+NvlqXqrgcd1O83Ixd4=; b=y1zunl2p/I9o6cmWUb2NnYfAPstnO8iv9BQaW1CxpWleUmklNBei8N2Of6dN4lKwNKIrkORJy w7+q2IWbzENDidaJ41cve7e/37dXsY/YHczM8JnE76IbaJ4tUPyi7qM X-Mailer: b4 0.14.2 Message-ID: <20260203-qcom-socinfo-v2-5-d6719db85637@google.com> Subject: [PATCH v2 5/6] rust: debugfs: Allow access to device in Devres-wrapped scopes From: Matthew Maurer To: Bjorn Andersson , Konrad Dybcio , Satya Durga Srinivasu Prabhala , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Greg Kroah-Hartman , "Rafael J. Wysocki" , David Airlie , Simona Vetter , Michal Wilczynski , Dave Ertman , Ira Weiny , Leon Romanovsky Cc: Trilok Soni , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-pwm@vger.kernel.org, Matthew Maurer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This adds support for creating a DebugFS directory which is aware that it is bound to a device. As a result, callbacks under that directory have access to a bound device which gives them efficient access to other Devres, ability to use dev_err! and friends, etc. Signed-off-by: Matthew Maurer Acked-by: Danilo Krummrich Suggested-by: Danilo Krummrich --- rust/kernel/debugfs.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs index d7b8014a6474698235203f2b7d8fec96f2bb43f8..ac614d693fa73929d095b669e9b= a61958bec609e 100644 --- a/rust/kernel/debugfs.rs +++ b/rust/kernel/debugfs.rs @@ -11,6 +11,11 @@ #[cfg(CONFIG_DEBUG_FS)] use crate::sync::Arc; use crate::{ + device::{ + Bound, + Device, // + }, + devres::Devres, fmt, prelude::*, str::CStr, @@ -722,3 +727,38 @@ fn new(name: &CStr) -> ScopedDir<'data, 'static> { } } } + +impl<'a, T: 'a + Send> Devres> { + /// Creates a new scope, which is a directory at the root of the debug= fs filesystem, + /// associated with some data `T`, enclosed in a [`Devres`] for the pr= ovided device. + /// + /// The `init` closure is called to populate the directory with files = and subdirectories. These + /// files can reference the data stored in the scope. Because it is st= ored inside a `Devres`, + /// the init method is granted access to a `&Device`. + /// + /// This can be used for cheaply accessing device-protected data insid= e DebugFS methods or + /// accessing device-specific methods (e.g. [`dev_err!`]). + /// + /// The entire directory tree created within the scope will be removed= when the returned + /// `Scope` handle is dropped. + pub fn dir( + dev: &'a Device, + data: impl PinInit + 'a, + name: &'a CStr, + init: F, + ) -> impl PinInit + 'a + where + F: for<'data, 'dir> FnOnce(&'data T, &'data Device, &'dir S= copedDir<'data, 'dir>) + + 'a, + Error: From, + { + Devres::new( + dev, + Scope::new(data, |data| { + let scoped =3D ScopedDir::new(name); + init(data, dev, &scoped); + scoped.into_entry() + }), + ) + } +} --=20 2.53.0.rc2.204.g2597b5adb4-goog