OSDN Git Service

regulator: Add ena_gpio_initialized to regulator_config
authorMarkus Pargmann <mpa@pengutronix.de>
Wed, 8 Oct 2014 13:47:05 +0000 (15:47 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 20 Oct 2014 11:23:45 +0000 (12:23 +0100)
commit76f439df50aba1838e06dd01e5f20dada7473f57
treea35a98029f817fa4663b71dc62db7d4fe5ca1f4f
parentf114040e3ea6e07372334ade75d1ee0775c355e1
regulator: Add ena_gpio_initialized to regulator_config

Most drivers do not set the ena_gpio field of struct regulator_config
before passing it to the regulator core. This is fine as long as the
gpio identifier that is passed is a positive integer. But the gpio
identifier 0 is also valid. So we are not able to decide wether we got a
real gpio identifier or not based on a 0 in ena_gpio.

To be able to decide if it is a valid gpio that got passed, this patch
adds a ena_gpio_initialized field that should be set if was initialized
with a correct value, either a gpio >= 0 or a negative error number. The
core then checks if ena_gpio or ena_gpio_initialized before handling it
as a gpio. This way we maintain backwards compatibility and fix the
behaviour for gpio number 0.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c
include/linux/regulator/driver.h