diff options
author | Krzysztof Adamski <krzysztof.adamski@tieto.com> | 2016-02-22 03:24:00 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-02-22 05:51:05 -0500 |
commit | daad134d66492a9f641163c94510549770b39657 (patch) | |
tree | 3ac745f3cbc2b851ba6186667634ec0770cd2478 /drivers/regulator | |
parent | 92e963f50fc74041b5e9e744c330dca48e04f08d (diff) |
regulator: core: Request GPIO before creating sysfs entries
regulator_attr_is_visible (which is a .is_visible callback of
regulator_dev_group attribute_grpup) checks rdev->ena_pin to decide if
"status" file should be present in sysfs. This field is set at the end
of regulator_ena_gpio_request so it has to be called before
device_register() otherwise this test will always fail, causing "status"
file to not be visible.
Since regulator_attr_is_visible also tests for is_enabled() op, this
problem is only visible for regulators that does not define this
callback, like regulator-fixed.c.
Signed-off-by: Krzysztof Adamski <krzysztof.adamski@tieto.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 744c9889f88d..3c987d76e684 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -3918,6 +3918,16 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3918 | goto clean; | 3918 | goto clean; |
3919 | } | 3919 | } |
3920 | 3920 | ||
3921 | if ((config->ena_gpio || config->ena_gpio_initialized) && | ||
3922 | gpio_is_valid(config->ena_gpio)) { | ||
3923 | ret = regulator_ena_gpio_request(rdev, config); | ||
3924 | if (ret != 0) { | ||
3925 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", | ||
3926 | config->ena_gpio, ret); | ||
3927 | goto wash; | ||
3928 | } | ||
3929 | } | ||
3930 | |||
3921 | /* register with sysfs */ | 3931 | /* register with sysfs */ |
3922 | rdev->dev.class = ®ulator_class; | 3932 | rdev->dev.class = ®ulator_class; |
3923 | rdev->dev.parent = dev; | 3933 | rdev->dev.parent = dev; |
@@ -3931,16 +3941,6 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3931 | 3941 | ||
3932 | dev_set_drvdata(&rdev->dev, rdev); | 3942 | dev_set_drvdata(&rdev->dev, rdev); |
3933 | 3943 | ||
3934 | if ((config->ena_gpio || config->ena_gpio_initialized) && | ||
3935 | gpio_is_valid(config->ena_gpio)) { | ||
3936 | ret = regulator_ena_gpio_request(rdev, config); | ||
3937 | if (ret != 0) { | ||
3938 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", | ||
3939 | config->ena_gpio, ret); | ||
3940 | goto wash; | ||
3941 | } | ||
3942 | } | ||
3943 | |||
3944 | /* set regulator constraints */ | 3944 | /* set regulator constraints */ |
3945 | if (init_data) | 3945 | if (init_data) |
3946 | constraints = &init_data->constraints; | 3946 | constraints = &init_data->constraints; |