Skip to content

Commit df7926f

Browse files
Tim Krygerbroonie
authored andcommitted
regulator: core: Return error in get optional stub
Drivers that call regulator_get_optional are tolerant to the absence of that regulator. By modifying the value returned from the stub function to match that seen when a regulator isn't present, callers can wrap the regulator logic with an IS_ERR based conditional even if they happen to call regulator_is_supported_voltage. This improves efficiency as well as eliminates the possibility for a very subtle bug. Signed-off-by: Tim Kryger <tim.kryger@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent c9eaa44 commit df7926f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎include/linux/regulator/consumer.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id)
258258
static inline struct regulator *__must_check
259259
regulator_get_optional(struct device *dev, const char *id)
260260
{
261-
return NULL;
261+
return ERR_PTR(-ENODEV);
262262
}
263263

264264

265265
static inline struct regulator *__must_check
266266
devm_regulator_get_optional(struct device *dev, const char *id)
267267
{
268-
return NULL;
268+
return ERR_PTR(-ENODEV);
269269
}
270270

271271
static inline void regulator_put(struct regulator *regulator)

0 commit comments

Comments
 (0)