regulator: core: Don't try to remove device links if add failed
PATCH 1/1 regulator: core: Don't try to remove device links if add failed
device_link_add() might not always succeed depending on the type of device link and the rest of the dependencies in the system. If device_link_add() didn't succeed, then we shouldn't try to remove the link later on as it might remove a link someone else created.
--- drivers/regulator/core.c | 8 ++++++-- drivers/regulator/internal.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/regulator/core.c +6 -2
@@ -1844,6 +1844,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,struct regulator_dev *rdev;struct regulator *regulator;const char *devname = dev ?dev_name (dev) :"deviceless" ; +struct device_link *link;int ret;if (get_type >=MAX_GET_TYPE ) {
@@ -1951,7 +1952,9 @@ struct regulator *_regulator_get(struct device *dev, const char *id, rdev->use_count =0 ; } -device_link_add (dev, &rdev->dev,DL_FLAG_STATELESS ); + link =device_link_add (dev, &rdev->dev,DL_FLAG_STATELESS ); +if (!IS_ERR_OR_NULL (link)) + regulator->device_link = true;return regulator; }
@@ -2046,7 +2049,8 @@ static void _regulator_put(struct regulator *regulator)debugfs_remove_recursive (regulator->debugfs);if (regulator->dev) { -device_link_remove (regulator->dev, &rdev->dev); +if (regulator->device_link) +device_link_remove (regulator->dev, &rdev->dev);/* remove any sysfs entries */ sysfs_remove_link (&rdev->dev.kobj, regulator->supply_name);
drivers/regulator/internal.h +1 -0
@@ -36,6 +36,7 @@ struct regulator {struct list_head list; unsigned int always_on:1; unsigned int bypass:1; + unsigned int device_link:1;int uA_load;unsigned int enable_count;unsigned int deferred_disables;
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog
Mark Brown
maintainerApplied "regulator: core: Don't try to remove device links if add failed" to the regulator tree
The patch
regulator: core: Don't try to remove device links if add failed
has been applied to the regulator tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
From b59b654478093fa429ad4c7897ae29f201146a00 Mon Sep 17 00:00:00 2001
From: Saravana Kannan <[email protected]>
Date: Thu, 14 Nov 2019 16:04:38 -0800
Subject: [PATCH] regulator: core: Don't try to remove device links if add
failed
device_link_add() might not always succeed depending on the type of device link and the rest of the dependencies in the system. If device_link_add() didn't succeed, then we shouldn't try to remove the link later on as it might remove a link someone else created.
--- drivers/regulator/core.c | 8 ++++++-- drivers/regulator/internal.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/regulator/core.c +6 -2
@@ -1844,6 +1844,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,struct regulator_dev *rdev;struct regulator *regulator;const char *devname = dev ?dev_name (dev) :"deviceless" ; +struct device_link *link;int ret;if (get_type >=MAX_GET_TYPE ) {
@@ -1951,7 +1952,9 @@ struct regulator *_regulator_get(struct device *dev, const char *id, rdev->use_count =0 ; } -device_link_add (dev, &rdev->dev,DL_FLAG_STATELESS ); + link =device_link_add (dev, &rdev->dev,DL_FLAG_STATELESS ); +if (!IS_ERR_OR_NULL (link)) + regulator->device_link = true;return regulator; }
@@ -2046,7 +2049,8 @@ static void _regulator_put(struct regulator *regulator)debugfs_remove_recursive (regulator->debugfs);if (regulator->dev) { -device_link_remove (regulator->dev, &rdev->dev); +if (regulator->device_link) +device_link_remove (regulator->dev, &rdev->dev);/* remove any sysfs entries */ sysfs_remove_link (&rdev->dev.kobj, regulator->supply_name);
drivers/regulator/internal.h +1 -0
@@ -36,6 +36,7 @@ struct regulator {struct list_head list; unsigned int always_on:1; unsigned int bypass:1; + unsigned int device_link:1;int uA_load;unsigned int enable_count;unsigned int deferred_disables;
Signature · 1 line
2.20.1