> +/**
> + * 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to