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] [day] [month] [year] [list]
Date:	Sun, 27 Jan 2013 14:06:36 +0800
From:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
To:	"Kim, Milo" <Milo.Kim@...com>
Cc:	Axel Lin <axel.lin@...ics.com>, "Girdwood, Liam" <lrg@...com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/4] regulator-core: manage enable GPIO list

On Tue, Jan 15, 2013 at 04:35:46AM +0000, Kim, Milo wrote:

> +/**
> + * Balance enable_count of each GPIO and actual GPIO pin control.
> + * GPIO is enabled in case of initial use. (enable_count is 0)
> + * GPIO is disabled when it is not shared any more. (enable_count is 1)
> + */
> +static void _do_ena_gpio_ctrl(struct regulator_enable_gpio *pin,
> +			struct regulator_dev *rdev, bool enable)
> +{
> +	if (enable) {
> +		/* Enable GPIO at initial use */
> +		if (pin->enable_count == 0)
> +			gpio_set_value_cansleep(rdev->ena_gpio,
> +						!rdev->ena_gpio_invert);
> +
> +		rdev->ena_gpio_state = 1;

ena_gpio_state is redundant with this patch, we can just replace
references to it with pin->enable_count.

We'll also need a request count to keep track of how many regulators are
using the GPIO for use in cleanup.

> +	} else {
> +		rdev->ena_gpio_state = 0;
> +		if (pin->enable_count > 1) {
> +			pin->enable_count--;
> +			return;
> +		}
> +
> +		/* Disable GPIO if not used */
> +		if (pin->enable_count == 1) {
> +			gpio_set_value_cansleep(rdev->ena_gpio,
> +						rdev->ena_gpio_invert);
> +			pin->enable_count = 0;
> +		}

Ideally we should also check if we're trying to take the enable count
below zero and complain about that.

> +static void regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
> +{
> +	struct regulator_enable_gpio *pin;
> +
> +	list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
> +		if (pin->gpio == rdev->ena_gpio) {
> +			_do_ena_gpio_ctrl(pin, rdev, enable);
> +			return;
> +		}
> +	}
> +}

This should return an error code as the users return errors, the GPIO
API won't give us errors but we can generate them internally.  It'd be
better to just add a pointer to the GPIO struct to the regulator_dev (in
place of the GPIO) so we don't need to scan through the list every time
we look for the GPIO.

Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ