[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJxaTdMFp0WAB3BBDPUztVvTtDGUt9=KyHTDpDOgAZ4ZEk2XUw@mail.gmail.com>
Date: Mon, 9 Jun 2025 15:06:56 +0100
From: Igor Korotin <igor.korotin.linux@...il.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Danilo Krummrich <dakr@...nel.org>, Benno Lossin <lossin@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, "Rafael J . Wysocki" <rafael@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-acpi@...r.kernel.org,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Len Brown <lenb@...nel.org>,
Wedson Almeida Filho <wedsonaf@...il.com>, Viresh Kumar <viresh.kumar@...aro.org>,
Alex Hung <alex.hung@....com>, Xiang Fei Ding <dingxiangfei2009@...il.com>
Subject: Re: [PATCH v3 2/4] rust: driver: Add ACPI id table support to Adapter trait
> <igor.korotin.linux@...il.com> wrote:
> >
> > Let me know if this pattern is acceptable. To my opinion it is not much
> > different from the original 2 functions conditioned by #[cfg] and
> > requires some nasty changes.
>
> In general, the more local a `cfg` can be made, the better, because we
> can share more, e.g. the docs and signature.
>
> But maybe in this case it doesn't work -- what would be the "nasty
> changes" required?
In particular on this example:
fn of_id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
#[cfg(not(CONFIG_OF))] {
None
}
#[cfg(CONFIG_OF))] {
// the rest of logic
}
}
The `dev` is marked as unused if `CONFIG_OF` is not set. So we have 3 options:
1. rename it to `_dev`. This is nasty to my opinion, because it is misleading.
2. add #[alloc(unused_variables)] on top of it. Also not good since it
will suppress
all other possible unused_variables as well.
3. The third option is `let _ = dev;` in `#[cfg(not(CONFIG_OF))]`
section. I came to
it while I was writing this reply. This looks like the best option of
three in my opinion.
Thanks
Igor
Powered by blists - more mailing lists