Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sebastian Reichel and committed by
Mark Brown
0dffacbb 0ad2507d

+44
+17
drivers/regulator/devres.c
··· 772 772 } 773 773 774 774 /** 775 + * devm_of_regulator_get - Resource managed of_regulator_get() 776 + * @dev: device used for dev_printk() messages and resource lifetime management 777 + * @node: device node for regulator "consumer" 778 + * @id: supply name or regulator ID. 779 + * 780 + * Managed of_regulator_get(). Regulators returned from this 781 + * function are automatically regulator_put() on driver detach. See 782 + * of_regulator_get() for more information. 783 + */ 784 + struct regulator *devm_of_regulator_get(struct device *dev, struct device_node *node, 785 + const char *id) 786 + { 787 + return _devm_of_regulator_get(dev, node, id, NORMAL_GET); 788 + } 789 + EXPORT_SYMBOL_GPL(devm_of_regulator_get); 790 + 791 + /** 775 792 * devm_of_regulator_get_optional - Resource managed of_regulator_get_optional() 776 793 * @dev: device used for dev_printk() messages and resource lifetime management 777 794 * @node: device node for regulator "consumer"
+21
drivers/regulator/of_regulator.c
··· 698 698 } 699 699 700 700 /** 701 + * of_regulator_get - get regulator via device tree lookup 702 + * @dev: device used for dev_printk() messages 703 + * @node: device node for regulator "consumer" 704 + * @id: Supply name 705 + * 706 + * Return: pointer to struct regulator corresponding to the regulator producer, 707 + * or PTR_ERR() encoded error number. 708 + * 709 + * This is intended for use by consumers that want to get a regulator 710 + * supply directly from a device node. This will _not_ consider supply 711 + * aliases. See regulator_dev_lookup(). 712 + */ 713 + struct regulator *of_regulator_get(struct device *dev, 714 + struct device_node *node, 715 + const char *id) 716 + { 717 + return _of_regulator_get(dev, node, id, NORMAL_GET); 718 + } 719 + EXPORT_SYMBOL_GPL(of_regulator_get); 720 + 721 + /** 701 722 * of_regulator_get_optional - get optional regulator via device tree lookup 702 723 * @dev: device used for dev_printk() messages 703 724 * @node: device node for regulator "consumer"
+6
include/linux/regulator/consumer.h
··· 677 677 #endif 678 678 679 679 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_REGULATOR) 680 + struct regulator *__must_check of_regulator_get(struct device *dev, 681 + struct device_node *node, 682 + const char *id); 683 + struct regulator *__must_check devm_of_regulator_get(struct device *dev, 684 + struct device_node *node, 685 + const char *id); 680 686 struct regulator *__must_check of_regulator_get_optional(struct device *dev, 681 687 struct device_node *node, 682 688 const char *id);