On Tue, Mar 03, 2009 at 12:39:17PM -0600, Lopez Cruz, Misael wrote:
I prefer GPIO stuff built in conditionally. The jack layer is used also for non-ASoC codes, and GPIO isn't always present.
Is it ok if I enclose all gpio functionality with #ifdef CONFIG_GPIOLIB?
Yes, that's fine.
This error path doesn't look good. It seems leaking / keeping some resources.
Changed to:
int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios) { int i, ret;
for (i = 0; i < count; i++) { if (!gpio_is_valid(gpios[i].gpio)) { printk(KERN_ERR "Invalid gpio %d\n", gpios[i].gpio); return -EINVAL; }
This still leaks GPIOs and interrupts if one of these tests fails on a GPIO after the first.