[alsa-devel] [PATCH v2 07/10] ASoC: upd9976: add jack detection function

Mark Brown broonie at opensource.wolfsonmicro.com
Fri May 6 14:53:11 CEST 2011


On Fri, May 06, 2011 at 01:46:34PM +0800, Lu Guanqun wrote:

> +	if (interrupt_status & 0x1 && value == 0x1)
> +		status |= SND_JACK_HEADSET;
> +
> +	if (interrupt_status & 0x2 && value == 0x2)
> +		status |= SND_JACK_HEADPHONE;
> +
> +	if (interrupt_status & 0x4)
> +		status |= SND_JACK_HEADSET | SND_JACK_BTN_0;
> +
> +	if (interrupt_status & 0x8)
> +		status |= SND_JACK_HEADSET | SND_JACK_BTN_1;

It's very strange that you do a mix of checks with and without the == -
it doesn't matter either way but it'd be clearer to be consistent.

> +	if (upd9976->irq < 0 || !upd9976->irq_mem)
> +		return 0;

It'd seem better to have this condition the other way around so if you
need to add more conditional stuff things will be clearer.


More information about the Alsa-devel mailing list