alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: srinivas.kandagatla@linaro.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Banajit Goswami <bgoswami@codeaurora.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-arm-msm@vger.kernel.org, Patrick Lai <plai@codeaurora.org>,
	sboyd@codeaurora.org, linux-kernel@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	David Brown <david.brown@linaro.org>,
	Mark Brown <broonie@kernel.org>,
	Andy Gross <andy.gross@linaro.org>,
	linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [RESEND PATCH v2 03/15] ASoC: qcom: qdsp6: Add common qdsp6 helper functions
Date: Mon, 1 Jan 2018 16:19:07 -0800	[thread overview]
Message-ID: <20180102001907.GL478@tuxbook> (raw)
In-Reply-To: <20171214173402.19074-4-srinivas.kandagatla@linaro.org>

On Thu 14 Dec 09:33 PST 2017, srinivas.kandagatla@linaro.org wrote:
> +static inline int q6dsp_map_channels(u8 *ch_map, int ch)
> +{
> +	memset(ch_map, 0, PCM_FORMAT_MAX_NUM_CHANNEL);

This implies that ch_map is always an array of
PCM_FORMAT_MAX_NUM_CHANNEL elements. As such it would be better to
express this in the prototype; i.e u8 ch_map[PCM_FORMAT_MAX_NUM_CHANNEL]

> +
> +	if (ch == 1) {

This is a switch statement.

> +		ch_map[0] = PCM_CHANNEL_FC;
> +	} else if (ch == 2) {
[..]
> +struct adsp_err_code {
> +	int		lnx_err_code;

Indentation, and these could be given more succinct names.

> +	char	*adsp_err_str;
> +};
> +
> +static struct adsp_err_code adsp_err_code_info[ADSP_ERR_MAX+1] = {
> +	{ 0, ADSP_EOK_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EFAILED_STR},
> +	{ -EINVAL, ADSP_EBADPARAM_STR},
> +	{ -ENOSYS, ADSP_EUNSUPPORTED_STR},
> +	{ -ENOPROTOOPT, ADSP_EVERSION_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EUNEXPECTED_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EPANIC_STR},
> +	{ -ENOSPC, ADSP_ENORESOURCE_STR},
> +	{ -EBADR, ADSP_EHANDLE_STR},
> +	{ -EALREADY, ADSP_EALREADY_STR},
> +	{ -EPERM, ADSP_ENOTREADY_STR},
> +	{ -EINPROGRESS, ADSP_EPENDING_STR},
> +	{ -EBUSY, ADSP_EBUSY_STR},
> +	{ -ECANCELED, ADSP_EABORTED_STR},
> +	{ -EAGAIN, ADSP_EPREEMPTED_STR},
> +	{ -EAGAIN, ADSP_ECONTINUE_STR},
> +	{ -EAGAIN, ADSP_EIMMEDIATE_STR},
> +	{ -EAGAIN, ADSP_ENOTIMPL_STR},
> +	{ -ENODATA, ADSP_ENEEDMORE_STR},
> +	{ -EADV, ADSP_ERR_MAX_STR},

This, element 0x13, is not listed among the defined errors. Is this a
placeholder?

How about making this even more descriptive by using the format

[ADSP_EBADPARAM] = { -EINVAL, ADSP_EBADPARAM_STR },

That way the mapping table is self-describing.

And you can use ARRAY_SIZE() instead of specifying the fixed size of
ADSP_ERR_MAX + 1...

> +	{ -ENOMEM, ADSP_ENOMEMORY_STR},
> +	{ -ENODEV, ADSP_ENOTEXIST_STR},
> +	{ -EADV, ADSP_ERR_MAX_STR},

"Advertise error"?

> +};
> +
> +static inline int adsp_err_get_lnx_err_code(u32 adsp_error)

Can this be made internal to some c-file? So that any third party deals
only with linux error codes?


How about renaming this q6dsp_errno()?

> +{
> +	if (adsp_error > ADSP_ERR_MAX)
> +		return adsp_err_code_info[ADSP_ERR_MAX].lnx_err_code;
> +	else
> +		return adsp_err_code_info[adsp_error].lnx_err_code;

I think this would look better if you assign a local variable and have a
single return. And just hard code the "invalid error code" errno, rather
than looking up ADSP_ERR_MAX in the list.

> +}
> +
> +static inline char *adsp_err_get_err_str(u32 adsp_error)

q6dsp_strerror(), to match strerror(3)?

> +{
> +	if (adsp_error > ADSP_ERR_MAX)
> +		return adsp_err_code_info[ADSP_ERR_MAX].adsp_err_str;
> +	else
> +		return adsp_err_code_info[adsp_error].adsp_err_str;

And I do think that, as with strerror, this should return a human
readable error, not the stringified define.

> +}


I'm puzzled to why these helper functions lives in a header file, at
least some aspects of this would better be hidden...

Regards,
Bjorn

  reply	other threads:[~2018-01-02  0:19 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 17:33 [RESEND PATCH v2 00/15] ASoC: qcom: Add support to QDSP6 based audio srinivas.kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 01/15] dt-bindings: soc: qcom: Add bindings for APR bus srinivas.kandagatla
     [not found]   ` <20171214173402.19074-2-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-12-16 17:27     ` Rob Herring
2017-12-18  9:50       ` Srinivas Kandagatla
2018-01-03  0:35   ` Bjorn Andersson
2018-01-03 16:26     ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 02/15] soc: qcom: add support to APR bus driver srinivas.kandagatla
     [not found]   ` <20171214173402.19074-3-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-01 23:29     ` Bjorn Andersson
2018-01-03 16:26       ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 03/15] ASoC: qcom: qdsp6: Add common qdsp6 helper functions srinivas.kandagatla
2018-01-02  0:19   ` Bjorn Andersson [this message]
2018-01-03 16:26     ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 04/15] ASoC: qcom: qdsp6: Add support to Q6AFE srinivas.kandagatla
2018-01-02  0:45   ` Bjorn Andersson
2018-01-03 16:26     ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 05/15] ASoC: qcom: qdsp6: Add support to Q6ADM srinivas.kandagatla
     [not found]   ` <20171214173402.19074-6-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-02  1:50     ` Bjorn Andersson
2018-01-03 16:26       ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 06/15] ASoC: qcom: qdsp6: Add support to Q6ASM srinivas.kandagatla
     [not found]   ` <20171214173402.19074-7-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-02  4:43     ` Bjorn Andersson
2018-01-03 16:26       ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 08/15] ASoC: qcom: q6asm: add support to audio stream apis srinivas.kandagatla
2018-01-02 20:08   ` Bjorn Andersson
2018-01-03 16:26     ` Srinivas Kandagatla
2018-01-13  8:42   ` Rohit Kumar
2017-12-14 17:33 ` [RESEND PATCH v2 09/15] ASoC: qcom: qdsp6: Add support to Q6CORE srinivas.kandagatla
2018-01-02 22:15   ` Bjorn Andersson
2018-01-03 16:27     ` Srinivas Kandagatla
2018-02-07 12:15   ` [alsa-devel] " Rohit Kumar
2017-12-14 17:33 ` [RESEND PATCH v2 10/15] ASoC: qcom: qdsp6: Add support to q6routing driver srinivas.kandagatla
2018-01-02 23:00   ` Bjorn Andersson
2018-01-03 16:27     ` Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 11/15] ASoC: qcom: qdsp6: Add support to q6afe dai driver srinivas.kandagatla
     [not found]   ` <20171214173402.19074-12-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-02 23:28     ` Bjorn Andersson
2018-01-03 16:27       ` Srinivas Kandagatla
2018-02-07 11:34   ` Rohit Kumar
2018-02-07 11:40     ` [alsa-devel] " Srinivas Kandagatla
2017-12-14 17:33 ` [RESEND PATCH v2 12/15] ASoC: qcom: qdsp6: Add support to q6asm " srinivas.kandagatla
2018-01-03  0:03   ` Bjorn Andersson
2018-01-03 16:27     ` Srinivas Kandagatla
2018-01-13  8:45   ` [alsa-devel] " Rohit Kumar
     [not found] ` <20171214173402.19074-1-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-12-14 17:33   ` [RESEND PATCH v2 07/15] ASoC: qcom: q6asm: Add support to memory map and unmap srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
2018-01-02  5:48     ` Bjorn Andersson
2018-01-03 16:26       ` Srinivas Kandagatla
     [not found]         ` <4d1d17df-71a4-2896-29c1-9d033a2f3711-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-03 19:39           ` Bjorn Andersson
2017-12-14 17:34   ` [RESEND PATCH v2 13/15] dt-bindings: sound: qcom: Add devicetree bindings for apq8096 srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
2017-12-16 17:44     ` Rob Herring
2017-12-18  9:49       ` Srinivas Kandagatla
2018-01-03  0:28     ` Bjorn Andersson
2018-01-03 16:27       ` Srinivas Kandagatla
     [not found]         ` <787ecdc5-66d8-23ee-7136-2a8759c86536-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-03 19:49           ` Bjorn Andersson
2017-12-14 17:34   ` [RESEND PATCH v2 14/15] ASoC: qcom: apq8096: Add db820c machine driver srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
2018-01-03  0:16     ` Bjorn Andersson
2018-01-03 16:27       ` Srinivas Kandagatla
2018-01-03 20:04         ` Bjorn Andersson
2018-01-03 17:20     ` Stephen Boyd
2018-01-03 18:36       ` Srinivas Kandagatla
2018-01-03 19:41         ` Stephen Boyd
2018-01-04  9:25           ` Srinivas Kandagatla
2018-01-04 12:02       ` Mark Brown
2018-01-04 13:44         ` Srinivas Kandagatla
2018-01-04 14:03           ` Mark Brown
2017-12-14 17:34 ` [RESEND PATCH v2 15/15] arm64: dts: msm8996: db820c: Add sound card support srinivas.kandagatla
     [not found]   ` <20171214173402.19074-16-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2018-01-03  0:22     ` Bjorn Andersson
2018-01-03 16:27       ` Srinivas Kandagatla
2018-01-03 20:01         ` Bjorn Andersson

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=20180102001907.GL478@tuxbook \
    --to=bjorn.andersson@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy.gross@linaro.org \
    --cc=bgoswami@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=plai@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.org \
    --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;
as well as URLs for NNTP newsgroup(s).