From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76DFF1946DA; Thu, 25 Sep 2025 13:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758806970; cv=none; b=FkXGj7jK854fi26KbsgRTSGpyQMu9yptFgQ9GrVXRMw5/92nELfrMK2eIj+1yDmqQEbN6ZxmBAXBEB3a7rNqHywRiv0sQEPwW0Yfq/AItqPiiUbTnNhRRNocdeNin64e9Gk+iZDpkqx8sWQ5Aks60z9evTFU+eLaY2/RcQOaVEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758806970; c=relaxed/simple; bh=ntsP/lf0pDuf+6FSvu7I+awI1G4RPlugS0jioDccajE=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=RWjjPI3Y4dNN2rrVLN1/mv/hs7WHgQE99ILUo00ZJVeGIaBCNeJrQtPL5SmvAkW3+48nfz4p+h1IIqexbljUQ2ix7lNdMYKDL3eE/pTSbEbtP+43cKwEuKRCNMz2HK8eJLo8WuKMfkrPVS2dJL9y9AFydxaQp9Rv8rbXkN85kLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fPvEPnMC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fPvEPnMC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75094C4CEF0; Thu, 25 Sep 2025 13:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758806970; bh=ntsP/lf0pDuf+6FSvu7I+awI1G4RPlugS0jioDccajE=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=fPvEPnMCHdAYiWMVNJZ87TYkp+sBqu6O68tOjgl0rhUCt5YRNEqAdHcZNB7wVOjHa jQyjA3EfIOfNeo1CU92Kl+O9zYuTpVvDEews2bfhsl3lH+2JtMe/AqLKsJuG6CHa2O L0Sq4JxEIJ8WL+0bDVVSxSppYT3WmYzPhHNtdKQmuAoD9es0B5p8WkoUGxXVz0KFwM J4HUMJoTubLcM4DOYHNfVxyvenAsFWsup50spHkq4k90fc33xy0AvHWXYUSozIgoie GOW54VMxN4Gz28aMpKQ1KreBeF5SmTRwlbbO4sJOSApNMZCY5Tff6JCs19iWCClZr+ FMI/2azNJlJ5Q== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 25 Sep 2025 15:29:25 +0200 Message-Id: Subject: Re: [PATCH 0/2] rust: usb: add initial USB abstractions Cc: "Daniel Almeida" , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , , , To: "Greg Kroah-Hartman" From: "Danilo Krummrich" References: <20250825-b4-usb-v1-0-7aa024de7ae8@collabora.com> <2025092520-sharply-everyone-4a5d@gregkh> In-Reply-To: <2025092520-sharply-everyone-4a5d@gregkh> On Thu Sep 25, 2025 at 2:52 PM CEST, Greg Kroah-Hartman wrote: > Yes, this is not a normal way that bindings will probably be merged into > the tree, but as I consulted deeply with the USB maintainer about this > topic while eating some good Paris pizza and French wine this week while > at the Kernel Recipes conference, I think that this deserves an > exception as they agree this can be merged now and they will be > responsible for any fallout.[1] If you rather have it "staging" in-tree that's of course up to you. :) But, I'd prefer not to expose the incorrect conversion between a &usb::Interface and a &usb::Device for a full release in Linus' t= ree. Besides other implications, this conversation also implies that &usb::Device can be derived from &usb::Interface, which semanti= cally means that if the USB interface's device lock is held we infer that the dev= ice lock of the USB device is held as well. I know the code isn't even built, but I don't want people reading the code = to take wrong conclusions from that. Also, it's dead code anyways, so maybe just apply the following hunk? Thanks, Danilo diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs index 8899e7520b58..9bc3478cf561 100644 --- a/rust/kernel/usb.rs +++ b/rust/kernel/usb.rs @@ -340,18 +340,6 @@ fn as_ref(&self) -> &device::Device { } } -impl AsRef> for Interface { - fn as_ref(&self) -> &Device { - // SAFETY: `self.as_raw()` is valid by the type invariants. For a = valid interface, - // the helper should always return a valid USB device pointer. - let usb_dev =3D unsafe { bindings::interface_to_usbdev(self.as_raw= ()) }; - - // SAFETY: The helper returns a valid interface pointer that share= s the - // same `DeviceContext`. - unsafe { &*(usb_dev.cast()) } - } -} - // SAFETY: Instances of `Interface` are always reference-counted. unsafe impl AlwaysRefCounted for Interface { fn inc_ref(&self) {