Re: [PATCH v3 3/7] rust: property: Introduce PropertyGuard

Danilo Krummrich
2025-04-28T21:21:28Z

On Mon, Apr 28, 2025 at 03:48:40PM -0500, Rob Herring wrote:
>
> One thing that's really hard to debug in C drivers is where an
> error came from. You can for example turn on initcall_debug and see that
> a driver probe returned an error. It's virtually impossible to tell
> where that originated from. The only way to tell is with prints. That is
> probably the root of why probe has so many error prints. I think we can
> do a lot better with rust given Result can hold more than just an int.

This I fully agree with, not sure if the solution is to put more stuff into the
Result type though. However, there are things like #[track_caller] (also
recently mentioned by Benno), which might be a good candidate for improving this
situation.

As mentioned, for now let's go with

pub fn required_by(self, dev: &Device) -> Result<T>

additional to required() for this purpose to get a proper dev_err() print.