Messages in this thread Patch in this message | | | Date | Mon, 29 Apr 2024 16:45:27 +0200 | Subject | [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns | From | Michał Mirosław <> |
| |
Remove unnecessary stores to `regulator`.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> --- drivers/regulator/core.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index dabac9772741..62dd3ac19e6d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2222,15 +2222,13 @@ struct regulator *_regulator_get(struct device *dev, const char *id, } if (rdev->exclusive) { - regulator = ERR_PTR(-EPERM); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPERM); } if (get_type == EXCLUSIVE_GET && rdev->open_count) { - regulator = ERR_PTR(-EBUSY); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EBUSY); } mutex_lock(®ulator_list_mutex); @@ -2238,32 +2236,28 @@ struct regulator *_regulator_get(struct device *dev, const char *id, mutex_unlock(®ulator_list_mutex); if (ret != 0) { - regulator = ERR_PTR(-EPROBE_DEFER); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPROBE_DEFER); } ret = regulator_resolve_supply(rdev); if (ret < 0) { - regulator = ERR_PTR(ret); put_device(&rdev->dev); - return regulator; + return ERR_PTR(ret); } if (!try_module_get(rdev->owner)) { - regulator = ERR_PTR(-EPROBE_DEFER); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPROBE_DEFER); } regulator_lock(rdev); regulator = create_regulator(rdev, dev, id); regulator_unlock(rdev); if (regulator == NULL) { - regulator = ERR_PTR(-ENOMEM); module_put(rdev->owner); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-ENOMEM); } rdev->open_count++; -- 2.39.2
| |