rust/kernel/driver.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
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
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
>
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))
}
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/
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
```
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
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.
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
© 2016 - 2026 Red Hat, Inc.