mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
regulator: Add (devm_)of_regulator_get()
The Rockchip power-domain controller also plans to make use of per-domain regulators similar to the MediaTek power-domain controller. Since existing DTs are missing the regulator information, the kernel should fallback to the automatically created dummy regulator if necessary. Thus the version without the _optional suffix is needed. The Rockchip driver plans to use the managed version, but to be consistent with existing code the unmanaged version is added at the same time. Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Link: https://patch.msgid.link/20250220-rk3588-gpu-pwr-domain-regulator-v6-1-a4f9c24e5b81@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
0ad2507d5d
commit
0dffacbbf8
3 changed files with 44 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue