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 80AE625CC75; Wed, 2 Jul 2025 10:36:19 +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=1751452579; cv=none; b=aFkcfP+Th5ALbWOvQALl8FntSJ1kDlL51bbvUMvWahZ/Ik3lIo9MIK0sF3F/WE8DkasHcCx7QxE3KW/UpXCuK0SLrhfn6ApQffKHC7b44qb7Gn/McOXvh5oYknJW+sLDEcPl8bxezvCyilU0RqEu8GW8IudUPBvceNoYWjXjPOM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751452579; c=relaxed/simple; bh=KDfQy2Js+DDupyUNw5tCWwVU8Kf4ZX6Tyd3TY+aYtPI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qkWHQNDqev6ZxBCg/K7AoiYU9UkAwdawNL1Q+zgc1jDCDXq/Q29zSsEfd+9JBRD2/ePNdzUEEKeYtj2hWrkZ5/t6FcfLsSmf07mqMbTh4Tze4Q5TlVY/kVPXEbrGGbYalhKm5JZrI14OLOcb8dQFczyWpVpYGK+UPOPtGET9mAw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HeaxcCEo; 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="HeaxcCEo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B121C4CEF3; Wed, 2 Jul 2025 10:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751452579; bh=KDfQy2Js+DDupyUNw5tCWwVU8Kf4ZX6Tyd3TY+aYtPI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HeaxcCEof/T5tcjSpfypJYjUjeO0YqCVP4CNbnzkBfi/8EW4+iA+03FfhUuoxhUMP oDmlxWB0Orbb9aMq8e6LYookLN5S2N4ThYY8TKOMNmO525atV2yJkQuCuk9+6gFv4J wqknRS7wd4b6Pz409E0QewhRivdiU30piaxQqHPN+uluIrZuaRV46PmZSAPa1g1Csd 8EsekOzoIRr/j4Pjpe3u2XzXaBF3HjV6tITQT4cvPJyAqU007CgIfiYpRHdew24JmO 3jFPg8DT9s1RX5fGVzbzdb6BXMf1hkNwfoqxXyPR32Kgvfsm3CucnB17w3L99LNSvh nSA5mKnMJXk8Q== Message-ID: Date: Wed, 2 Jul 2025 12:36:13 +0200 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 4/4] rust: platform: allow ioremap of platform resources To: Daniel Almeida Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Andy Shevchenko , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Bjorn Helgaas , Mika Westerberg , Ying Huang , Benno Lossin , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org References: <20250701-topics-tyr-platform_iomem-v11-0-6cd5d5061151@collabora.com> <20250701-topics-tyr-platform_iomem-v11-4-6cd5d5061151@collabora.com> From: Danilo Krummrich Content-Language: en-US In-Reply-To: <20250701-topics-tyr-platform_iomem-v11-4-6cd5d5061151@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/1/25 4:34 PM, Daniel Almeida wrote: > +impl Device { > + pub fn iomap_resource_sized( > + &self, > + resource: &Resource, > + ) -> Result>, Error> + '_> { > + IoMem::new(resource, self.as_ref()) > + } Sorry that I did not catch this earlier, but what if I supply a Resource here that has *not* been obtained by any of the platform::Device methods and from the same platform::Device as you call this function for? I think this also needs something similar to what we do in the IRQ abstraction, e.g.: /// # Invariants /// /// `res` has been obtained from `dev`. pub struct IoRequest<'a> { dev: &'a Device, res: &'a Resource, } Such that IoMem::new() can take an IoRequest instance instead.