[alsa-devel] [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional

Lars-Peter Clausen lars at metafoo.de
Sun Jul 12 12:31:01 CEST 2015


On 07/12/2015 08:56 AM, Anatol Pomozov wrote:
[...]
> @@ -61,7 +64,7 @@ static int max98357a_codec_probe(struct snd_soc_codec *codec)
>   	struct gpio_desc *sdmode;
>
>   	sdmode = devm_gpiod_get(codec->dev, "sdmode", GPIOD_OUT_LOW);
> -	if (IS_ERR(sdmode)) {
> +	if (IS_ERR(sdmode) && (PTR_ERR(sdmode) != -ENOENT)) {

There is is devm_gpiod_get_optional() exactly for this use case. It will 
return NULL if no GPIO is specified.

>   		dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n",
>   				__func__, PTR_ERR(sdmode));
>   		return PTR_ERR(sdmode);
>



More information about the Alsa-devel mailing list