From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 50A163D79E2 for ; Tue, 16 Jun 2026 22:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781649393; cv=none; b=rbndWxemgqJBOzI/HgxTkVAwZg6tq8MoRhSLW+VONLUpxnYhdM6LecvmqRtnUI/zPApRnF4zIrbVMcXAuFpjHHe69yTDGq6IMLy3ShF9c8CYuDBRgypr3nPdVO/Ve4z69WJY9Rm/cspd2Ldj6CVRyCzF7Pgsa6eVbXnEgAnupaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781649393; c=relaxed/simple; bh=NACjCW4uUizcEdB6sSH9ZQ3fbHHJa6g3OJEVl5rRkRQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bt0Aaop4hQuJWz8KGH1+8pdfApq0vjf+q8FU3+q+rGVeUZwwOCO5IVO/h6Ii4OkzGCG1edB075VE77Hg6r+bBxFCJOETFo43/ALjlIOl7xaoKtF0/omP4iFY+B65C578qJcdi3R+d8c0S8phyieXHz31Rb1Gw9MNzK5SbcFy5EI= 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=f65rhk5Q; arc=none smtp.client-ip=209.85.222.180 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="f65rhk5Q" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-91ae31bbaa9so229029885a.1 for ; Tue, 16 Jun 2026 15:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781649391; x=1782254191; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5IoJP3ySdUx4DkxskDKQ8frRVgBTvEGDGFX0mngUY5c=; b=f65rhk5Qpxy6hBTeYsoyvqHDyWSd//OWnTEB4KaOB60Uy0d0BkPW3C0AvHuKwkPvqA Wrp121pKktWSnArwb3RTeLPFrR0sR5LrksdS3LardpfqG2OIXooEXO3d07R+vVuUEbPC otu3BfH5YutDu+jm4eR2ggK8PrAbZI7tg2Y/ogeXwRK106h0uG3Yci3j9HVnACM0FkVe cIa9roNp/jLSW2jtOAWYCAKquRat6hlkqv18LeyrkswxwFROe1TPVoeZI/XxCe3bVQno g8nzebm2B5yGwNKGWjcOzVIBe49lzlqMHQ3xN6l5GeHz+Gs9TWUIMRCer13cJZNAXXhb Ntaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781649391; x=1782254191; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5IoJP3ySdUx4DkxskDKQ8frRVgBTvEGDGFX0mngUY5c=; b=dy6Evnrclmq2XNpDHqZMwOfQB9zlfWy/C2rSBF6waVK9FYnf+wpQVn5qV3h3WREQGP gvTcMNEMeOss+puY1PclL3taYNwKN0qxu0f6ZuqLX+JQDSuaZqKQJcUVOeahXiHecqhx R8tSkXDgKs9/W6uKOMhnZHEIQ6NX99vVyHeQBK9S91uyGIDu88xGiJyBa5IlSC0TyvQs fKPldWDbZ+TyKIgsLe5+6GvnqNiDCHJVHU1obx0wFJBSerZzVTw42INJn8yjI7QxdFrG ys2nBoQX0qDVrryeSOU3gAYa5rvN/J3QgpzAlC4z7t+fkk91SqPJnNCkPyk4m6Rn5Sfb I6Qw== X-Forwarded-Encrypted: i=1; AFNElJ8XDBhdWXRUHsBtirqm7MKdaXeY++Io7NSX28o+qp86wJRpg8B5pUdJHp/5XgraVvFqkvU0iD7FAcI8zWw=@vger.kernel.org X-Gm-Message-State: AOJu0YzqKwWTmObsYTsVr1226+mo71dNJ40c/U3l+0EgeWnSKp5ER7ea +MvgmHEkoircTva7J8upACJZad9Ngb0jMBQd9oyFcT/gW9bmaYY5eu4= X-Gm-Gg: Acq92OFpQRAzS3Ieb/4XxmJcfprLDHvuBsWgJl85of3GzXe5sR26FlfHn4VTHWZJgqK 2sKYearhXRKuWQFw6xen3yTSdhMRc6nnN6TvnRGjzx6BJ4bb/BdWgEvNeIdGZZtUy9Ag3iBGIxA 5hnZ/yDFwcvaroIyPBXWxkumpnOrjRfe6QpFIca33w0HkYIHiadBRsQwSjPIvYKi+klVXsKDhWQ MAyYhXkBwLgD7O8n/1OugKLUVG0RzDIcb1GKF3YMTvjoMvrXtySDpHG/ZrLZLVX1A5RLMrtRVTr QHEG3tWnwNfJZDrlxYWCe9qjKIUfIU7x731lRMYy+V6V9uFciXk2+CvckpjTlOossazc11NPI6K 9UOCHkGcNR5RR1q0Ud4H9F4/Fzctcd2QFn/vg5b9+JzhTOLjMSPxer8vDX6sRTuxKdpR6Momtze JI84MMUW3Ncgm1mbkRtoV5fsEaqXq2K4SJSyI7eKZLbAmNhcYB9A8SdWiOo2vsk9eZj55IzlQ1Q es= X-Received: by 2002:a05:620a:2908:b0:915:d32a:1cba with SMTP id af79cd13be357-91dbc52c4damr140872385a.27.1781649391215; Tue, 16 Jun 2026 15:36:31 -0700 (PDT) Received: from localhost.localdomain ([186.158.238.108]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9161a006ef0sm1524236585a.24.2026.06.16.15.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 15:36:30 -0700 (PDT) From: =?UTF-8?q?Nicol=C3=A1s=20Antinori?= To: Miguel Ojeda Cc: =?UTF-8?q?Nicol=C3=A1s=20Antinori?= , Alexandre Courbot , Alice Ryhl , Andreas Hindborg , Benno Lossin , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Boqun Feng , Daniel Almeida , Danilo Krummrich , Gary Guo , =?UTF-8?q?Onur=20=C3=96zkan?= , Shuah Khan , Tamir Duberstein , Trevor Gross , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel-mentees@lists.linux.dev Subject: [PATCH] usb: rust: mark Device and Interface methods as inline Date: Tue, 16 Jun 2026 19:36:06 -0300 Message-ID: <20260616223614.16444-1-nico.antinori.7@gmail.com> X-Mailer: git-send-email 2.47.3 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=UTF-8 Content-Transfer-Encoding: 8bit When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the following symbols are generated: $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt ... ffffffff823f2490 T ::dec_ref ffffffff823f2470 T ::inc_ref ... $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt ffffffff823f2450 T ::dec_ref ffffffff823f2430 T ::inc_ref ... However, these Rust symbols are trivial wrappers around the `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf` functions. It doesn't make sense to go through a trivial wrapper for these functions. Link: https://github.com/Rust-for-Linux/linux/issues/1145 Suggested-by: Alice Ryhl Signed-off-by: Nicolás Antinori --- rust/kernel/usb.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs index 7aff0c82d0af..efbbee319b1a 100644 --- a/rust/kernel/usb.rs +++ b/rust/kernel/usb.rs @@ -393,6 +393,7 @@ fn as_ref(&self) -> &Device { // SAFETY: Instances of `Interface` are always reference-counted. unsafe impl AlwaysRefCounted for Interface { + #[inline] fn inc_ref(&self) { // SAFETY: The invariants of `Interface` guarantee that `self.as_raw()` // returns a valid `struct usb_interface` pointer, for which we will @@ -400,6 +401,7 @@ fn inc_ref(&self) { unsafe { bindings::usb_get_intf(self.as_raw()) }; } + #[inline] unsafe fn dec_ref(obj: NonNull) { // SAFETY: The safety requirements guarantee that the refcount is non-zero. unsafe { bindings::usb_put_intf(obj.cast().as_ptr()) } @@ -444,6 +446,7 @@ fn as_raw(&self) -> *mut bindings::usb_device { // SAFETY: Instances of `Device` are always reference-counted. unsafe impl AlwaysRefCounted for Device { + #[inline] fn inc_ref(&self) { // SAFETY: The invariants of `Device` guarantee that `self.as_raw()` // returns a valid `struct usb_device` pointer, for which we will @@ -451,6 +454,7 @@ fn inc_ref(&self) { unsafe { bindings::usb_get_dev(self.as_raw()) }; } + #[inline] unsafe fn dec_ref(obj: NonNull) { // SAFETY: The safety requirements guarantee that the refcount is non-zero. unsafe { bindings::usb_put_dev(obj.cast().as_ptr()) } -- 2.47.3