Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Dylan Reid <dgreid@chromium.org>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, lars@metafoo.de,
	lgirdwood@gmail.com, zhengxing@rock-chips.com
Subject: Re: [RFC 3/5] ASoC: Add GPIO based jack device
Date: Mon, 25 May 2015 13:11:20 +0100	[thread overview]
Message-ID: <20150525121120.GJ21391@sirena.org.uk> (raw)
In-Reply-To: <1432332563-15447-4-git-send-email-dgreid@chromium.org>


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

On Fri, May 22, 2015 at 03:09:21PM -0700, Dylan Reid wrote:

> Add a jack device that allows for separate headphone and mic detect
> GPIOs.  This device will be used as an aux device and will registered
> the jack with the card at init time.

This looks basically fine, a couple of things below but they're
nitpicks.

> +- gpio-audio-jack,debounce-times	: Debounce time for each sw-det-gpio
> +					  entry.

specified in...?

> +config SND_SOC_GPIO_AUDIO_JACK
> +        tristate "GPIO based audio jack detection"
> +

This should surely depend on GPIOLIB || COMPILE_TEST.

> +	gpio_names = devm_kzalloc(dev, sizeof(*gpio_names) * priv->gpio_count,
> +				  GFP_KERNEL);

We have devm_kcalloc() (not that it makes a huge difference but may as
well be clear about the intent).

> +	if (!gpio_names)
> +		return -ENOMEM;
> +	gpio_report = devm_kzalloc(dev, sizeof(*gpio_report) * priv->gpio_count,
> +				   GFP_KERNEL);

Blank lines between blocks please.

> +	snd_soc_card_jack_new(component->card, jack_name, report_mask,
> +			      &priv->jack, NULL, 0);

Ignoring the return value here (not likely to fail but...).

> +static void gpio_audio_component_remove(struct snd_soc_component *component)
> +{
> +	struct gpio_audio_jack *priv = container_of(component->driver,
> +			struct gpio_audio_jack, component_drv);
> +	int i;
> +
> +	for (i = 0; i < priv->gpio_count; i++) {
> +		if (!IS_ERR(priv->gpios[i].desc))
> +			gpiod_put(priv->gpios[i].desc);
> +	}

I would have expected us to be acquiring and releasing the GPIOs in the
platform device probe, not in the ASoC level probe - that way we handle
deferred probe better.

> +static int gpio_audio_jack_probe(struct platform_device *pdev)
> +{
> +	struct gpio_audio_jack *priv;
> +
> +	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	dev_set_drvdata(&pdev->dev, priv);
> +
> +	priv->component_drv.probe = gpio_audio_component_probe;
> +	priv->component_drv.remove = gpio_audio_component_remove;
> +
> +	return devm_snd_soc_register_component(&pdev->dev, &priv->component_drv,
> +					       NULL, 0);

Why do we allocate a component driver structure per device?

> +static const struct of_device_id gpio_audio_of_match[] = {
> +	{ .compatible = "gpio-audio-jack", },

linux,gpio-audio-jack possibly.  Not entirely sure what the current best
practice is on that.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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



  reply	other threads:[~2015-05-25 13:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 22:09 [RFC 0/5] Add a gpio jack device Dylan Reid
2015-05-22 22:09 ` [RFC 1/5] ALSA: Add jack types to dt-bindings Dylan Reid
2015-05-25 12:11   ` Mark Brown
2015-05-22 22:09 ` [RFC 2/5] ASoC: jack - add_gpiods accepts filled descriptors Dylan Reid
2015-05-25 12:12   ` Mark Brown
2015-05-22 22:09 ` [RFC 3/5] ASoC: Add GPIO based jack device Dylan Reid
2015-05-25 12:11   ` Mark Brown [this message]
2015-05-26  6:20     ` Dylan Reid
2015-05-22 22:09 ` [RFC 4/5] ASoC: tegra_max98090: Change nyan to use gpio-jack Dylan Reid
2015-05-22 22:09 ` [RFC 5/5] ARM: tegra: nyan: specify gpio-audio-jack device Dylan Reid
2015-05-25 15:17 ` [RFC 0/5] Add a gpio jack device Lars-Peter Clausen
2015-05-25 17:15   ` Mark Brown
2015-05-25 18:58     ` Dylan Reid
2015-05-26 18:43     ` Lars-Peter Clausen
2015-05-26 20:14       ` Mark Brown
2015-05-27  4:22         ` Dylan Reid
2015-05-27 11:15           ` Lars-Peter Clausen
2015-05-27 17:26           ` Mark Brown
2015-05-28  5:38             ` Dylan Reid
2015-05-28 10:17               ` Mark Brown
2015-05-27 11:12         ` Lars-Peter Clausen
2015-05-28 19:35           ` Mark Brown

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=20150525121120.GJ21391@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=dgreid@chromium.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.de \
    --cc=zhengxing@rock-chips.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