Re: [RFC 3/3] ASoC: simple-card: Split alloc and init logics in probe function

From: Kuninori Morimoto

Date: Sun Jan 25 2026 - 19:57:03 EST



Hi Fabio

> > func () {
> > ...
> > (A) if (...)
> > error("indicate error reason1")
> > (A) if (...)
> > error("indicate error reason2")
> > ...
> > }
> >
> >
> > main() {
> > ...
> > ret = func();
> > (B) if (ret < 0)
> > error("func() error")
> > ...
> > }
>
> Hm, I think you're being too abstract for my comprehension, sorry about that.
> Let me assume main() is the probe function, and func() is whatever function
> that probe() calls. If my assumptions are correct, then:

Sorry for my not good explanation, indeed it is too abstract.
Above (A) and (B) exists in the same time, I meant.

> - In (A), are we letting child functions print the reason of their own error?

Yes. indicate why it become error in each function.
Because size is too small, memory alloc failed, etc, etc...

> - In (B), I think it's the approach already being used for
> simple_parse_of(), isn't it?

(B) indicates func() returns error. I think this can indicate error path,
like below

xxx size failed (error reason) // (A)
funcB() error // (B)
funcA() error // (B)

Developer can understand that funcA() calls funcB() and funcB() returns
error from this message.
But this is not mandatory, just an idea.

I think simple_ret() can help you, but I'm not sure whether you can use it
on probe function.

Thank you for your help !!

Best regards
---
Kuninori Morimoto