lkml.org 
[lkml]   [2013]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v3 2/4] regulator: core: manage enable GPIO list
From
> +/**
> + * 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 <= 1)
I think you mean "GPIO is disabled when it is not used any more."
"It is not shared" sounds like it can has one user.

> + */
> +static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
> +{
> + struct regulator_enable_gpio *pin = rdev->ena_pin;
> +
> + if (!pin)
> + return -EINVAL;
> +
> + if (enable) {
> + /* Enable GPIO at initial use */
> + if (pin->enable_count == 0)
> + gpio_set_value_cansleep(pin->gpio,
> + !pin->ena_gpio_invert);
> +
> + pin->enable_count++;
> + } else {
> + if (pin->enable_count > 1) {
> + pin->enable_count--;
> + return 0;
> + }
> +
> + /* Disable GPIO if not used */
> + if (pin->enable_count <= 1) {
> + gpio_set_value_cansleep(pin->gpio,
> + pin->ena_gpio_invert);
> + pin->enable_count = 0;
> + }
How about:

/* No action to disable if enable_count is already 0 */
if (pin->enable_count == 0)
return 0;

/* Disable GPIO if not used */
if (--pin->enable_count == 0)
gpio_set_value_cansleep(pin->gpio, pin->ena_gpio_invert);


\
 
 \ /
  Last update: 2013-02-19 03:41    [W:0.064 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site