regulator: Add (devm_)of_regulator_get()

This introduces devm_of_regulator_get without the _optional suffix, since
 that is more sensible for the Rockchip usecase.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAme+BMIACgkQJNaLcl1U
 h9BsYwf/eZ6Wxm7m4Zyo7K4X+tcfPUWAp1gvT0Z9xR4gtsYHGRXGMoxv32skfTli
 HAHzjF+jmtRk+WZP5tnOSzBcUl6onGl2VsjhUVEU3JZVffok+jp+6JtPvwvo9YZF
 l2T3To8uxPoeVtflFtmL6RxPhj3pPglFxV8WOSqxq7fv4yHLq3LecacJcqzw8Obb
 0etTLJqElgPs5bKQ0Z0cSlAwf7r5904qZ9fU8UTE0SSUOWvFDpfa86KygPlkOnC8
 P5iGWzuchi+qhEHG2ulRrD9RjdB0x+VauPz464aigbU8tvZzBtpppk8fiVZOuUlT
 TMe+OEiBz/CvnrG81whMg+JzGvnqhw==
 =125E
 -----END PGP SIGNATURE-----

pmdomain: Merge tag regulator-devm-of-get into next

Merge the tag regulator-devm-of-get from
git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into next.

This introduces devm_of_regulator_get without the _optional suffix, since
that is more sensible for the Rockchip usecase.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Ulf Hansson 2025-02-28 12:39:40 +01:00
commit a8e9ef4c8f
3 changed files with 44 additions and 0 deletions

View File

@ -771,6 +771,23 @@ static struct regulator *_devm_of_regulator_get(struct device *dev, struct devic
return regulator;
}
/**
* devm_of_regulator_get - Resource managed of_regulator_get()
* @dev: device used for dev_printk() messages and resource lifetime management
* @node: device node for regulator "consumer"
* @id: supply name or regulator ID.
*
* Managed of_regulator_get(). Regulators returned from this
* function are automatically regulator_put() on driver detach. See
* of_regulator_get() for more information.
*/
struct regulator *devm_of_regulator_get(struct device *dev, struct device_node *node,
const char *id)
{
return _devm_of_regulator_get(dev, node, id, NORMAL_GET);
}
EXPORT_SYMBOL_GPL(devm_of_regulator_get);
/**
* devm_of_regulator_get_optional - Resource managed of_regulator_get_optional()
* @dev: device used for dev_printk() messages and resource lifetime management

View File

@ -697,6 +697,27 @@ struct regulator *_of_regulator_get(struct device *dev, struct device_node *node
return _regulator_get_common(r, dev, id, get_type);
}
/**
* of_regulator_get - get regulator via device tree lookup
* @dev: device used for dev_printk() messages
* @node: device node for regulator "consumer"
* @id: Supply name
*
* Return: pointer to struct regulator corresponding to the regulator producer,
* or PTR_ERR() encoded error number.
*
* This is intended for use by consumers that want to get a regulator
* supply directly from a device node. This will _not_ consider supply
* aliases. See regulator_dev_lookup().
*/
struct regulator *of_regulator_get(struct device *dev,
struct device_node *node,
const char *id)
{
return _of_regulator_get(dev, node, id, NORMAL_GET);
}
EXPORT_SYMBOL_GPL(of_regulator_get);
/**
* of_regulator_get_optional - get optional regulator via device tree lookup
* @dev: device used for dev_printk() messages

View File

@ -677,6 +677,12 @@ regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
#endif
#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_REGULATOR)
struct regulator *__must_check of_regulator_get(struct device *dev,
struct device_node *node,
const char *id);
struct regulator *__must_check devm_of_regulator_get(struct device *dev,
struct device_node *node,
const char *id);
struct regulator *__must_check of_regulator_get_optional(struct device *dev,
struct device_node *node,
const char *id);