lkml.org 
[lkml]   [2024]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns
From
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(&regulator_list_mutex);
@@ -2238,32 +2236,28 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
mutex_unlock(&regulator_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

\
 
 \ /
  Last update: 2024-05-27 18:08    [W:0.111 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site