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

Danilo Krummrich
2025-04-29T08:50:25Z

On Mon, Apr 28, 2025 at 11:50:19PM +0200, Remo Senekowitsch wrote:
> On Mon Apr 28, 2025 at 11:21 PM CEST, Danilo Krummrich wrote:
> > 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.
>
> Could it make sense to _replace_ `required` with `required_by` ?
> Otherwise `required` sits a little awkwardly between `optional` and
> `required_by`. I can't think of a situation where `required` would be
> preferred.

Fine with me; required() also seems not useful to implement required_by().

However, I think we should revisit those generic error prints once we tackled
the issue of ergonomics in finding the source of an error in general.