lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111226110201.GA8722@opensource.wolfsonmicro.com>
Date:	Mon, 26 Dec 2011 11:02:01 +0000
From:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
To:	Janusz Krzysztofik <jkrzyszt@....icnet.pl>
Cc:	Tony Lindgren <tony@...mide.com>,
	Jarkko Nikula <jarkko.nikula@...mer.com>,
	Liam Girdwood <lrg@...com>, linux-omap@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	alsa-devel@...a-project.org
Subject: Re: [PATCH 2/4] ASoC: cx20442: add bias control over a platform
 provided regulator

On Sat, Dec 24, 2011 at 12:12:22AM +0100, Janusz Krzysztofik wrote:

> +	case SND_SOC_BIAS_ON:
> +	case SND_SOC_BIAS_PREPARE:
> +		if (IS_ERR(cx20442->por.regulator)) {
> +			err = PTR_ERR(cx20442->por.regulator);
> +		} else if (!cx20442->por.enabled) {
> +			err = regulator_enable(cx20442->por.regulator);
> +			if (!err)
> +				cx20442->por.enabled = true;
> +		}
> +		break;
> +	case SND_SOC_BIAS_STANDBY:
> +	case SND_SOC_BIAS_OFF:
> +		if (IS_ERR(cx20442->por.regulator)) {
> +			err = PTR_ERR(cx20442->por.regulator);
> +		} else if (cx20442->por.enabled) {
> +			err = regulator_disable(cx20442->por.regulator);
> +			if (!err)
> +				cx20442->por.enabled = false;
> +		}
> +	}
> +	mutex_unlock(&cx20442->por.lock);

You can avoid the mutex and simplify the code by relying on the fact
that the only possible transitions are:

   OFF <-> STANDBY <-> PREPARE <-> ON

which would look a lot more natural - you shouldn't need to remember if
the regulator is enabled, you should just turn it on in the STANDBY to
PREPARE transition and turn it off in the ON to PREPARE or PREPARE to
STANDBY transitions.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ