[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DFUTZA4N567I.3S2CCXS3FR95L@nvidia.com>
Date: Thu, 22 Jan 2026 13:25:02 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Zhi Wang" <zhiw@...dia.com>
Cc: <rust-for-linux@...r.kernel.org>, <linux-pci@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <dakr@...nel.org>, <aliceryhl@...gle.com>,
<bhelgaas@...gle.com>, <kwilczynski@...nel.org>, <ojeda@...nel.org>,
<alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, <lossin@...nel.org>, <a.hindborg@...nel.org>,
<tmgross@...ch.edu>, <markus.probst@...teo.de>, <helgaas@...nel.org>,
<cjia@...dia.com>, <smitra@...dia.com>, <ankita@...dia.com>,
<aniketa@...dia.com>, <kwankhede@...dia.com>, <targupta@...dia.com>,
<joelagnelf@...dia.com>, <jhubbard@...dia.com>, <zhiwang@...nel.org>,
<daniel.almeida@...labora.com>
Subject: Re: [PATCH v12 4/5] rust: pci: add config space read/write support
On Thu Jan 22, 2026 at 5:22 AM JST, Zhi Wang wrote:
<snip>
> + /// Return an initialized normal (256-byte) config space object.
> + pub fn config_space<'a>(&'a self) -> Result<ConfigSpace<'a, Normal>> {
> + Ok(ConfigSpace {
> + pdev: self,
> + _marker: PhantomData,
> + })
> + }
> +
> + /// Return an initialized extended (4096-byte) config space object.
> + pub fn config_space_extended<'a>(&'a self) -> Result<ConfigSpace<'a, Extended>> {
> + Ok(ConfigSpace {
> + pdev: self,
> + _marker: PhantomData,
> + })
> + }
Why are we returning a `Result` given that none of these methods can
ever fail? I mentioned that in earlier revisions too [1], but it looks
like we should invoke `cfg_size` to validate the size first, lest we
return a `ConfigSpace` that is larger than what is actually supported.
[1] https://lore.kernel.org/all/DEHUBNKNSNXH.14A4OGQKY5KZR@nvidia.com/#t
Powered by blists - more mailing lists