From: Lars-Peter Clausen <lars@metafoo.de>
To: Daniel Mack <zonque@gmail.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com
Subject: Re: [PATCH 2/2] ASoC: codecs: adau1701: add DT bindings
Date: Thu, 23 May 2013 15:20:50 +0200 [thread overview]
Message-ID: <519E17B2.7020304@metafoo.de> (raw)
In-Reply-To: <1369310281-4323-2-git-send-email-zonque@gmail.com>
On 05/23/2013 01:58 PM, Daniel Mack wrote:
[...]
> +#ifdef CONFIG_OF
> +static const struct of_device_id adau1701_dt_ids[] = {
> + { .compatible = "adi,adau1701", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
> +#endif
> +
> static int adau1701_probe(struct snd_soc_codec *codec)
> {
> int ret;
> + struct device *dev = codec->dev;
> struct i2c_client *client = to_i2c_client(codec->dev);
> + int gpio_nreset = -EINVAL;
>
> codec->control_data = client;
>
> + if (of_match_device(of_match_ptr(adau1701_dt_ids), dev))
I think just checking for dev->of_node should be simpler.
> + gpio_nreset = of_get_named_gpio(dev->of_node,
> + "reset-gpio", 0);
This should check for errors. E.g. we definitely want to handle
-EPROBE_DEFER, but it makes sense to also return an error if the property is
present but something is wrong.
E.g something like
if (gpio_nreset < 0 && gpio_nreset != -ENOENT)
return gpio_nreset;
> +
> + if (gpio_is_valid(gpio_nreset)) {
> + if (devm_gpio_request_one(codec->dev, gpio_nreset,
> + GPIOF_OUT_INIT_LOW,
> + "ADAU1701 Reset") < 0)
> + return -EINVAL;
> +
> + /* minimum reset time is 20ns */
> + udelay(1);
> + gpio_set_value(gpio_nreset, 1);
> + /* power-up time may be as long as 85ms */
> + mdelay(85);
> + }
I think it is better to request the gpio and reset the device in the i2c
probe function.
> +
> ret = adau1701_load_firmware(client);
> if (ret)
> dev_warn(codec->dev, "Failed to load firmware\n");
> @@ -522,6 +552,7 @@ static struct i2c_driver adau1701_i2c_driver = {
> .driver = {
> .name = "adau1701",
> .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(adau1701_dt_ids),
> },
> .probe = adau1701_i2c_probe,
> .remove = adau1701_i2c_remove,
next prev parent reply other threads:[~2013-05-23 13:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 11:58 [PATCH 1/2] ASoC: codecs: adau1701: refactor firmware loading function Daniel Mack
2013-05-23 11:58 ` [PATCH 2/2] ASoC: codecs: adau1701: add DT bindings Daniel Mack
2013-05-23 13:20 ` Lars-Peter Clausen [this message]
2013-05-23 13:13 ` [PATCH 1/2] ASoC: codecs: adau1701: refactor firmware loading function Lars-Peter Clausen
2013-05-23 14:00 ` 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=519E17B2.7020304@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=zonque@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 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.