mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabio <fabio@redaril.me>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Fabio Forni <development@redaril.me>,
	Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 3/3] ASoC: simple-card: Split alloc and init logics in probe function
Date: Sat, 24 Jan 2026 11:23:40 +0100	[thread overview]
Message-ID: <10a207cc-7a9b-4cb7-a76d-04dd0c5a55e1@redaril.me> (raw)
In-Reply-To: <87a4y8rdyp.wl-kuninori.morimoto.gx@renesas.com>

Hi, here I am.

> But I have thought that the style like below can easy for people ?
> (A) part checks something and return error, then indicate error reasons.
> (B) part returns error because the called function returns error.
> 
> 	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:

- In (A), are we letting child functions print the reason of their own error? If so,
   I like the idea! In C we only return errors codes without a message, so the actual
   reason of, say, EINVAL is only known where the error was thrown. Outside of the
   context of the function an EINVAL just means "something was invalid". So yeah, I'd choose
   option (A).
- In (B), I think it's the approach already being used for simple_parse_of(), isn't it?
   You cannot know the reason of the error for sure, again because of error codes without
   a message being carried together. The best you can do here is thinking of a generic error
   message like I did.

Option (A) requires more work, of course.

  reply	other threads:[~2026-01-24 10:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 23:12 [RFC 0/3] simple-card: Improve probe's error messages Fabio Forni
2026-01-12 23:12 ` [RFC 1/3] ASoC: simple-card: Do not print "parse error" twice Fabio Forni
2026-01-13  2:29   ` Kuninori Morimoto
2026-01-13  8:24     ` Fabio
2026-01-12 23:12 ` [RFC 2/3] ASoC: simple-card: Replace "parse error" with a more descriptive msg Fabio Forni
2026-01-12 23:12 ` [RFC 3/3] ASoC: simple-card: Split alloc and init logics in probe function Fabio Forni
2026-01-13  2:33   ` Kuninori Morimoto
2026-01-13 22:31     ` Fabio
2026-01-20  6:32       ` Kuninori Morimoto
2026-01-24 10:23         ` Fabio [this message]
2026-01-26  0:56           ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10a207cc-7a9b-4cb7-a76d-04dd0c5a55e1@redaril.me \
    --to=fabio@redaril.me \
    --cc=broonie@kernel.org \
    --cc=development@redaril.me \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®