From: Mark Brown <broonie@kernel.org>
To: wangweidong.a@awinic.com
Cc: alsa-devel@alsa-project.org, steve@sk2.org,
tanureal@opensource.cirrus.com, lgirdwood@gmail.com,
cezary.rojewski@intel.com, tiwai@suse.com,
srinivas.kandagatla@linaro.org,
krzysztof.kozlowski+dt@linaro.org, zhuning0077@gmail.com,
pierre-louis.bossart@linux.intel.com, povik+lin@cutebit.org,
flatmax@flatmax.com, devicetree@vger.kernel.org,
ckeepax@opensource.cirrus.com, stephan@gerhold.net,
duanyibo@awinic.com, zhaolei@awinic.com,
james.schulman@cirrus.com, rf@opensource.cirrus.com,
robh+dt@kernel.org, shumingf@realtek.com, liweilei@awinic.com,
linux-kernel@vger.kernel.org, yijiangtao@awinic.com
Subject: Re: [PATCH V8 1/5] ASoC: codecs: Add i2c and codec registration for aw883xx and their associated operation functions
Date: Tue, 3 Jan 2023 20:17:58 +0000 [thread overview]
Message-ID: <Y7SNdgU6b5r+YsWK@sirena.org.uk> (raw)
In-Reply-To: <20221230093454.190579-2-wangweidong.a@awinic.com>
[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]
On Fri, Dec 30, 2022 at 05:34:50PM +0800, wangweidong.a@awinic.com wrote:
This looks mostly good, there's a few small nits below but nothing too
huge:
> +++ b/sound/soc/codecs/aw883xx/aw883xx.c
> @@ -0,0 +1,667 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * aw883xx.c -- ALSA SoC AW883XX codec support
Please make the entire comment a C++ one so things look more
intentional.
> +static int aw883xx_startup(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> + struct snd_soc_component *codec = dai->component;
> + struct aw883xx *aw883xx = snd_soc_component_get_drvdata(codec);
> +
> + mutex_lock(&aw883xx->lock);
> + aw883xx_start(aw883xx, AW_ASYNC_START);
> + mutex_unlock(&aw883xx->lock);
> +
> + return 0;
> +}
I would not expect power management to be done in the startup and
shutdown callbacks, this should be done in set_bias_level() or DAPM like
with other drivers.
> +static int aw883xx_set_fade_in_time(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + time = ucontrol->value.integer.value[0];
> +
> + if (time < mc->min || time > mc->max)
> + return 0;
That's in spec, but it's a bit nicer to return an error so that people
are more likely to notice that their attempt to set a value didn't do
what they asked.
> +static int aw883xx_switch_get(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
> + struct aw883xx *aw883xx = snd_soc_component_get_drvdata(codec);
> +
> + ucontrol->value.integer.value[0] = aw883xx->allow_power;
> +
> + return 0;
> +}
Let the system deal with adding a control that lets the output path be
powered off if that's needed, the driver shouldn't be open coding that -
it's just extra and redundant complexity. If users do need this then
DAPM is probably a better fit than set_bias_level().
> + dev_info(aw883xx->aw_pa->dev, "%s : bin load success\n", __func__);
Lower this to a dev_dbg()
> +static void aw883xx_i2c_remove(struct i2c_client *i2c)
> +{
> + struct aw883xx *aw883xx = i2c_get_clientdata(i2c);
> +
> + aw883xx_deinit(aw883xx->aw_pa);
> + snd_soc_unregister_component(&i2c->dev);
I'd expect these to be in the other order, otherwise something could be
using the device while it's partially initialised which probably won't
go well. Unregistering the component will detach userspace and the card
avoiding that problem.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-01-03 20:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 9:34 [PATCH V8 0/5] ASoC: codecs: Add Awinic AW883XX audio amplifier driver wangweidong.a
2022-12-30 9:34 ` [PATCH V8 1/5] ASoC: codecs: Add i2c and codec registration for aw883xx and their associated operation functions wangweidong.a
2022-12-30 12:32 ` Christophe JAILLET
2023-01-03 20:17 ` Mark Brown [this message]
2022-12-30 9:34 ` [PATCH V8 2/5] ASoC: codecs: Aw883xx function for ACF file parse and check wangweidong.a
2022-12-30 9:34 ` [PATCH V8 3/5] ASoC: codecs: Aw883xx common function for ALSA Audio Driver wangweidong.a
2022-12-30 9:34 ` [PATCH V8 4/5] ASoC: codecs: Aw883xx chip register file, data type file and Kconfig Makefile wangweidong.a
2022-12-31 3:06 ` kernel test robot
2023-01-06 7:09 ` Dan Carpenter
2022-12-30 9:34 ` [PATCH V8 5/5] ASoC: dt-bindings: Add schema for "awinic,aw883xx" wangweidong.a
2022-12-30 10:34 ` [PATCH V8 5/5] ASoC: dt-bindings: Add schema for "awinic, aw883xx" Krzysztof Kozlowski
2023-01-03 11:27 ` wangweidong.a
2023-01-03 12:03 ` Krzysztof Kozlowski
2022-12-30 12:00 ` Stephan Gerhold
2022-12-30 16:34 ` Rob Herring
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=Y7SNdgU6b5r+YsWK@sirena.org.uk \
--to=broonie@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=cezary.rojewski@intel.com \
--cc=ckeepax@opensource.cirrus.com \
--cc=devicetree@vger.kernel.org \
--cc=duanyibo@awinic.com \
--cc=flatmax@flatmax.com \
--cc=james.schulman@cirrus.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liweilei@awinic.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=povik+lin@cutebit.org \
--cc=rf@opensource.cirrus.com \
--cc=robh+dt@kernel.org \
--cc=shumingf@realtek.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=stephan@gerhold.net \
--cc=steve@sk2.org \
--cc=tanureal@opensource.cirrus.com \
--cc=tiwai@suse.com \
--cc=wangweidong.a@awinic.com \
--cc=yijiangtao@awinic.com \
--cc=zhaolei@awinic.com \
--cc=zhuning0077@gmail.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