* [PATCH] rust: simplify `Adapter::id_info`
@ 2025-06-25 4:36 Onur Özkan
2025-06-25 8:22 ` Danilo Krummrich
0 siblings, 1 reply; 8+ messages in thread
From: Onur Özkan @ 2025-06-25 4:36 UTC (permalink / raw)
To: rust-for-linux, linux-kernel
Cc: gregkh, rafael, dakr, ojeda, alex.gaynor, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross,
Onur Özkan
It was obviously unnecessary to check if `id` is `Some`.
Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
rust/kernel/driver.rs | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
index ec9166cedfa7..1036755cb27d 100644
--- a/rust/kernel/driver.rs
+++ b/rust/kernel/driver.rs
@@ -178,11 +178,6 @@ fn of_id_info(_dev: &device::Device) -> Option<&'static Self::IdInfo> {
/// If this returns `None`, it means that there is no match in any of the ID tables directly
/// associated with a [`device::Device`].
fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
- let id = Self::of_id_info(dev);
- if id.is_some() {
- return id;
- }
-
- None
+ Self::of_id_info(dev)
}
}
--
2.50.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-25 4:36 [PATCH] rust: simplify `Adapter::id_info` Onur Özkan
@ 2025-06-25 8:22 ` Danilo Krummrich
2025-06-25 8:36 ` Onur
0 siblings, 1 reply; 8+ messages in thread
From: Danilo Krummrich @ 2025-06-25 8:22 UTC (permalink / raw)
To: Onur Özkan
Cc: rust-for-linux, linux-kernel, gregkh, rafael, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
On Wed, Jun 25, 2025 at 07:36:30AM +0300, Onur Özkan wrote:
> It was obviously unnecessary to check if `id` is `Some`.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
> rust/kernel/driver.rs | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
> index ec9166cedfa7..1036755cb27d 100644
> --- a/rust/kernel/driver.rs
> +++ b/rust/kernel/driver.rs
> @@ -178,11 +178,6 @@ fn of_id_info(_dev: &device::Device) -> Option<&'static Self::IdInfo> {
> /// If this returns `None`, it means that there is no match in any of the ID tables directly
> /// associated with a [`device::Device`].
> fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
> - let id = Self::of_id_info(dev);
> - if id.is_some() {
> - return id;
> - }
> -
> - None
This was intentional, since I anticipated we'll get [1] eventually. :)
[1] https://lore.kernel.org/lkml/20250620153914.295679-1-igor.korotin.linux@gmail.com/
> + Self::of_id_info(dev)
> }
> }
> --
> 2.50.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-25 8:22 ` Danilo Krummrich
@ 2025-06-25 8:36 ` Onur
2025-06-25 8:39 ` Danilo Krummrich
0 siblings, 1 reply; 8+ messages in thread
From: Onur @ 2025-06-25 8:36 UTC (permalink / raw)
To: Danilo Krummrich
Cc: rust-for-linux, linux-kernel, gregkh, rafael, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
On Wed, 25 Jun 2025 10:22:48 +0200
Danilo Krummrich <dakr@kernel.org> wrote:
> On Wed, Jun 25, 2025 at 07:36:30AM +0300, Onur Özkan wrote:
> > It was obviously unnecessary to check if `id` is `Some`.
> >
> > Signed-off-by: Onur Özkan <work@onurozkan.dev>
> > ---
> > rust/kernel/driver.rs | 7 +------
> > 1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
> > index ec9166cedfa7..1036755cb27d 100644
> > --- a/rust/kernel/driver.rs
> > +++ b/rust/kernel/driver.rs
> > @@ -178,11 +178,6 @@ fn of_id_info(_dev: &device::Device) ->
> > Option<&'static Self::IdInfo> { /// If this returns `None`, it
> > means that there is no match in any of the ID tables directly ///
> > associated with a [`device::Device`]. fn id_info(dev:
> > &device::Device) -> Option<&'static Self::IdInfo> {
> > - let id = Self::of_id_info(dev);
> > - if id.is_some() {
> > - return id;
> > - }
> > -
> > - None
>
> This was intentional, since I anticipated we'll get [1] eventually. :)
>
> [1]
> https://lore.kernel.org/lkml/20250620153914.295679-1-igor.korotin.linux@gmail.com/
>
> > + Self::of_id_info(dev)
> > }
> > }
> > --
> > 2.50.0
> >
Even with that, it can be something like this:
fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
let id = Self::acpi_id_info(dev);
if id.is_some() {
return id;
}
Self::of_id_info(dev)
}
or maybe even this:
fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
Self::acpi_id_info(dev).or_else(|| Self::of_id_info(dev))
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-25 8:36 ` Onur
@ 2025-06-25 8:39 ` Danilo Krummrich
2025-06-26 8:10 ` Onur
0 siblings, 1 reply; 8+ messages in thread
From: Danilo Krummrich @ 2025-06-25 8:39 UTC (permalink / raw)
To: Onur
Cc: rust-for-linux, linux-kernel, gregkh, rafael, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
On Wed, Jun 25, 2025 at 11:36:04AM +0300, Onur wrote:
> Even with that, it can be something like this:
>
> fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
> let id = Self::acpi_id_info(dev);
> if id.is_some() {
> return id;
> }
>
> Self::of_id_info(dev)
> }
>
> or maybe even this:
>
> fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
> Self::acpi_id_info(dev).or_else(|| Self::of_id_info(dev))
> }
That's fair, can you please rebase your patch onto [1]?
[1] https://lore.kernel.org/lkml/20250620153914.295679-1-igor.korotin.linux@gmail.com/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-25 8:39 ` Danilo Krummrich
@ 2025-06-26 8:10 ` Onur
2025-06-26 9:41 ` Miguel Ojeda
0 siblings, 1 reply; 8+ messages in thread
From: Onur @ 2025-06-26 8:10 UTC (permalink / raw)
To: Danilo Krummrich
Cc: rust-for-linux, linux-kernel, gregkh, rafael, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
On Wed, 25 Jun 2025 10:39:47 +0200
Danilo Krummrich <dakr@kernel.org> wrote:
> On Wed, Jun 25, 2025 at 11:36:04AM +0300, Onur wrote:
> > Even with that, it can be something like this:
> >
> > fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
> > let id = Self::acpi_id_info(dev);
> > if id.is_some() {
> > return id;
> > }
> >
> > Self::of_id_info(dev)
> > }
> >
> > or maybe even this:
> >
> > fn id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
> > Self::acpi_id_info(dev).or_else(|| Self::of_id_info(dev))
> > }
>
> That's fair, can you please rebase your patch onto [1]?
>
> [1]
> https://lore.kernel.org/lkml/20250620153914.295679-1-igor.korotin.linux@gmail.com/
HEAD: e0b49ca268d4a0d2b97d5820420d5a78b67d2537 currently doesn't pass
clippy. Should I send an additional change for the clippy fix or would
you prefer to fix it yourself first?
Here is the output of `make LLVM=1 -j $(nproc) CLIPPY=1`:
```
DESCEND objtool
CALL scripts/checksyscalls.sh
INSTALL libsubcmd_headers
CLIPPY L rust/kernel.o
error: unneeded `return` statement
--> rust/kernel/driver.rs:188:13
|
188 | return None;
| ^^^^^^^^^^^
|
= help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `-D clippy::needless-return` implied by `-D warnings` = help:
to override `-D warnings` add `#[allow(clippy::needless_return)]` help:
remove `return` |
188 - return None;
188 + None
|
error: aborting due to 1 previous error
make[2]: *** [rust/Makefile:538: rust/kernel.o] Error 1
make[1]: *** [/home/nimda/devspace/onur-ozkan/linux/Makefile:1280:
prepare] Error 2 make: *** [Makefile:248: __sub-make] Error 2
```
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-26 8:10 ` Onur
@ 2025-06-26 9:41 ` Miguel Ojeda
2025-06-26 9:48 ` Danilo Krummrich
0 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2025-06-26 9:41 UTC (permalink / raw)
To: Onur
Cc: Danilo Krummrich, rust-for-linux, linux-kernel, gregkh, rafael,
ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
a.hindborg, aliceryhl, tmgross
On Thu, Jun 26, 2025 at 10:11 AM Onur <work@onurozkan.dev> wrote:
>
> HEAD: e0b49ca268d4a0d2b97d5820420d5a78b67d2537 currently doesn't pass
> clippy. Should I send an additional change for the clippy fix or would
> you prefer to fix it yourself first?
Where is that commit coming from?
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-26 9:41 ` Miguel Ojeda
@ 2025-06-26 9:48 ` Danilo Krummrich
2025-06-26 9:59 ` Miguel Ojeda
0 siblings, 1 reply; 8+ messages in thread
From: Danilo Krummrich @ 2025-06-26 9:48 UTC (permalink / raw)
To: Miguel Ojeda, Onur
Cc: rust-for-linux, linux-kernel, gregkh, rafael, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
On Thu, Jun 26, 2025 at 11:41:33AM +0200, Miguel Ojeda wrote:
> On Thu, Jun 26, 2025 at 10:11 AM Onur <work@onurozkan.dev> wrote:
> >
> > HEAD: e0b49ca268d4a0d2b97d5820420d5a78b67d2537 currently doesn't pass
> > clippy. Should I send an additional change for the clippy fix or would
> > you prefer to fix it yourself first?
Indeed, this is the case for #[cfg(not(CONFIG_OF))], I'm going to fix this up at
my end when I apply the series. Don't worry about it.
> Where is that commit coming from?
https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/acpi
It's a temporary branch containing patches that are staged for applying them to
the driver-core tree.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: simplify `Adapter::id_info`
2025-06-26 9:48 ` Danilo Krummrich
@ 2025-06-26 9:59 ` Miguel Ojeda
0 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2025-06-26 9:59 UTC (permalink / raw)
To: Danilo Krummrich
Cc: Onur, rust-for-linux, linux-kernel, gregkh, rafael, ojeda,
alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross
On Thu, Jun 26, 2025 at 11:48 AM Danilo Krummrich <dakr@kernel.org> wrote:
>
> It's a temporary branch containing patches that are staged for applying them to
> the driver-core tree.
Ah, that explains it -- I checked driver-core but didn't see anything there.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-26 9:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 4:36 [PATCH] rust: simplify `Adapter::id_info` Onur Özkan
2025-06-25 8:22 ` Danilo Krummrich
2025-06-25 8:36 ` Onur
2025-06-25 8:39 ` Danilo Krummrich
2025-06-26 8:10 ` Onur
2025-06-26 9:41 ` Miguel Ojeda
2025-06-26 9:48 ` Danilo Krummrich
2025-06-26 9:59 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).