All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	alsa-devel@alsa-project.org, bgoswami@codeaurora.org,
	linux-kernel@vger.kernel.org, lgirdwood@gmail.com,
	tiwai@suse.com, vkoul@kernel.org, robh+dt@kernel.org,
	lee.jones@linaro.org
Subject: Re: [PATCH 07/12] ASoC: wcd9335: add CLASS-H Controller support
Date: Tue, 24 Jul 2018 12:59:08 +0100	[thread overview]
Message-ID: <20180724115908.GC2414@sirena.org.uk> (raw)
In-Reply-To: <20180723155410.9494-8-srinivas.kandagatla@linaro.org>


[-- Attachment #1.1: Type: text/plain, Size: 2156 bytes --]

On Mon, Jul 23, 2018 at 04:54:05PM +0100, Srinivas Kandagatla wrote:

> +static inline int wcd_clsh_get_int_mode(struct wcd_clsh_ctrl *ctrl,
> +					int clsh_state)
> +{
> +	int mode;
> +
> +	if ((clsh_state != WCD_CLSH_STATE_EAR) &&
> +	    (clsh_state != WCD_CLSH_STATE_HPHL) &&
> +	    (clsh_state != WCD_CLSH_STATE_HPHR) &&
> +	    (clsh_state != WCD_CLSH_STATE_LO))
> +		mode = CLS_NONE;
> +	else
> +		mode = ctrl->interpolator_modes[ffs(clsh_state)];
> +
> +	return mode;

This looks like it wants to be a switch statement.

> +static void wcd_clsh_state_hph_lo(struct wcd_clsh_ctrl *ctrl, int req_state,
> +				  bool is_enable, int mode)
> +{
> +	struct snd_soc_component *comp = ctrl->comp;
> +	int hph_mode = 0;
> +
> +	if (is_enable) {
> +		/*
> +		 * If requested state is LO, put regulator
> +		 * in class-AB or if requested state is HPH,
> +		 * which means LO is already enabled, keep
> +		 * the regulator config the same at class-AB
> +		 * and just set the power modes for flyback
> +		 * and buck.
> +		 */
> +		if (req_state == WCD_CLSH_STATE_LO)
> +			wcd_clsh_set_buck_regulator_mode(comp, CLS_AB);

This seems like there's a pretty confusing state machine, or possibly
that we might end up in different states depending on how we transition.
Whatever is going on it really feels like this code is more complex than
it needs to be.  Some of this is the use of lots of nested if statements,
some of it is the lack of any clear description of what we're trying to
achieve.  It's hard to tell if the code is doing what's expected because
it's hard to tell what it is expected to do.

> +		else {

If there's braces on one side of an if/else there should be braces on
both sides.

> +			if (req_state == WCD_CLSH_STATE_HPHL)
> +				snd_soc_component_update_bits(comp,
> +					WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_EN_MASK,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_ENABLE);
> +			if (req_state == WCD_CLSH_STATE_HPHR)
> +				snd_soc_component_update_bits(comp,
> +					WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_EN_MASK,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_ENABLE);
> +		}

Switch statement?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,
	lgirdwood@gmail.com, tiwai@suse.com, bgoswami@codeaurora.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	vkoul@kernel.org, alsa-devel@alsa-project.org
Subject: Re: [PATCH 07/12] ASoC: wcd9335: add CLASS-H Controller support
Date: Tue, 24 Jul 2018 12:59:08 +0100	[thread overview]
Message-ID: <20180724115908.GC2414@sirena.org.uk> (raw)
In-Reply-To: <20180723155410.9494-8-srinivas.kandagatla@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

On Mon, Jul 23, 2018 at 04:54:05PM +0100, Srinivas Kandagatla wrote:

> +static inline int wcd_clsh_get_int_mode(struct wcd_clsh_ctrl *ctrl,
> +					int clsh_state)
> +{
> +	int mode;
> +
> +	if ((clsh_state != WCD_CLSH_STATE_EAR) &&
> +	    (clsh_state != WCD_CLSH_STATE_HPHL) &&
> +	    (clsh_state != WCD_CLSH_STATE_HPHR) &&
> +	    (clsh_state != WCD_CLSH_STATE_LO))
> +		mode = CLS_NONE;
> +	else
> +		mode = ctrl->interpolator_modes[ffs(clsh_state)];
> +
> +	return mode;

This looks like it wants to be a switch statement.

> +static void wcd_clsh_state_hph_lo(struct wcd_clsh_ctrl *ctrl, int req_state,
> +				  bool is_enable, int mode)
> +{
> +	struct snd_soc_component *comp = ctrl->comp;
> +	int hph_mode = 0;
> +
> +	if (is_enable) {
> +		/*
> +		 * If requested state is LO, put regulator
> +		 * in class-AB or if requested state is HPH,
> +		 * which means LO is already enabled, keep
> +		 * the regulator config the same at class-AB
> +		 * and just set the power modes for flyback
> +		 * and buck.
> +		 */
> +		if (req_state == WCD_CLSH_STATE_LO)
> +			wcd_clsh_set_buck_regulator_mode(comp, CLS_AB);

This seems like there's a pretty confusing state machine, or possibly
that we might end up in different states depending on how we transition.
Whatever is going on it really feels like this code is more complex than
it needs to be.  Some of this is the use of lots of nested if statements,
some of it is the lack of any clear description of what we're trying to
achieve.  It's hard to tell if the code is doing what's expected because
it's hard to tell what it is expected to do.

> +		else {

If there's braces on one side of an if/else there should be braces on
both sides.

> +			if (req_state == WCD_CLSH_STATE_HPHL)
> +				snd_soc_component_update_bits(comp,
> +					WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_EN_MASK,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_ENABLE);
> +			if (req_state == WCD_CLSH_STATE_HPHR)
> +				snd_soc_component_update_bits(comp,
> +					WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_EN_MASK,
> +					WCD9XXX_A_CDC_RX_PATH_CLSH_ENABLE);
> +		}

Switch statement?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2018-07-24 11:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 15:53 [PATCH 00/12] mfd: Add support to WCD9335 Audio Codec Srinivas Kandagatla
2018-07-23 15:53 ` [PATCH 01/12] mfd: dt-bindings: Add wcd9335 mfd bindings Srinivas Kandagatla
2018-07-23 15:53   ` Srinivas Kandagatla
2018-07-24  5:56   ` Vinod
2018-07-24  5:56     ` Vinod
2018-07-24 11:50     ` Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 02/12] mfd: wcd9335: add support to wcd9335 core Srinivas Kandagatla
2018-07-23 15:54   ` Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 03/12] mfd: wcd9335: add wcd irq support Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 04/12] ASoC: dt-bindings: add dt bindings for wcd9335 audio codec Srinivas Kandagatla
2018-07-23 15:54   ` Srinivas Kandagatla
2018-07-24 11:06   ` Mark Brown
2018-07-24 11:06     ` Mark Brown
2018-07-24 11:48     ` Srinivas Kandagatla
2018-07-24 11:48       ` Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 05/12] ASoC: core: add support to snd_soc_dai_get_channel_map() Srinivas Kandagatla
2018-07-24 11:50   ` Applied "ASoC: core: add support to snd_soc_dai_get_channel_map()" to the asoc tree Mark Brown
2018-07-24 11:50     ` Mark Brown
2018-07-23 15:54 ` [PATCH 06/12] ASoC: wcd9335: add support to wcd9335 codec Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 07/12] ASoC: wcd9335: add CLASS-H Controller support Srinivas Kandagatla
2018-07-24 11:59   ` Mark Brown [this message]
2018-07-24 11:59     ` Mark Brown
2018-07-24 12:05     ` Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 08/12] ASoC: wcd9335: add basic controls Srinivas Kandagatla
2018-07-25 12:04   ` Vinod
2018-07-27  9:55     ` Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 09/12] ASoC: wcd9335: add playback dapm widgets Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 10/12] ASoC: wcd9335: add capture " Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 11/12] ASoC: wcd9335: add audio routings Srinivas Kandagatla
2018-07-23 15:54 ` [PATCH 12/12] ASoC: apq8096: Add support to Analog audio via WCD9335 slim Srinivas Kandagatla
2018-07-25 16:24   ` Mark Brown
2018-07-25 16:24     ` Mark Brown
2018-07-24  5:53 ` [PATCH 00/12] mfd: Add support to WCD9335 Audio Codec Vinod

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=20180724115908.GC2414@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.