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
| ||
|
Date: Tue, 19 Feb 2013 10:07:10 +0800 From: Axel Lin <axel.lin@...ics.com> To: "Kim, Milo" <Milo.Kim@...com> Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org> Subject: Re: [PATCH v3 2/4] regulator: core: manage enable GPIO list > +/** > + * 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 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