Skip to content

Commit

Permalink
Regulator: core: Unregister when gpio request fails.
Browse files Browse the repository at this point in the history
If the gpio_request_one() fails, or returns EPROBE_DEFER, the
regulator must be device_unregister()ed. When this is not done,
there are WARNING: from sysfs:

WARNING: at fs/sysfs/file.c:343 sysfs_open_file+0x238/0x268()

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Andrew Lunn authored and Mark Brown committed Oct 28, 2012
1 parent 6f0c058 commit b2da55d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3365,7 +3365,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
if (ret != 0) {
rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
config->ena_gpio, ret);
goto clean;
goto wash;
}

rdev->ena_gpio = config->ena_gpio;
Expand Down Expand Up @@ -3449,6 +3449,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
if (rdev->ena_gpio)
gpio_free(rdev->ena_gpio);
kfree(rdev->constraints);
wash:
device_unregister(&rdev->dev);
/* device core frees rdev */
rdev = ERR_PTR(ret);
Expand Down

0 comments on commit b2da55d

Please sign in to comment.