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

firmware: exynos-acpm: introduce devm_acpm_get_by_node()

To allow ACPM clients to simply be children of the ACPM node in DT,
they need to be able to get the ACPM handle based on that ACPM node
directly.

Add an API to allow them to do so, devm_acpm_get_by_node().

At the same time, the previous approach of acquiring the ACPM handle
via a DT phandle is now obsolete and we can remove
devm_acpm_get_by_phandle(), which was there to facilitate that. There
are no existing or anticipated upcoming users of that API, because all
clients should be children of the ACPM node going forward.

Note that no DTs have been merged that use the old approach, so doing
this API change in this driver now will not affect any existing DTs or
client drivers.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
Link: https://lore.kernel.org/r/20250327-acpm-children-v1-2-0afe15ee2ff7@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

authored by

André Draszik and committed by
Krzysztof Kozlowski
a8dc26a0 636baba9

+13 -16
+9 -14
drivers/firmware/samsung/exynos-acpm.c
··· 667 667 * 668 668 * Return: pointer to handle on success, ERR_PTR(-errno) otherwise. 669 669 */ 670 - static const struct acpm_handle *acpm_get_by_phandle(struct device *dev, 671 - const char *property) 670 + static const struct acpm_handle *acpm_get_by_node(struct device *dev, 671 + struct device_node *acpm_np) 672 672 { 673 673 struct platform_device *pdev; 674 - struct device_node *acpm_np; 675 674 struct device_link *link; 676 675 struct acpm_info *acpm; 677 676 678 - acpm_np = of_parse_phandle(dev->of_node, property, 0); 679 - if (!acpm_np) 680 - return ERR_PTR(-ENODEV); 681 - 682 677 pdev = of_find_device_by_node(acpm_np); 683 - of_node_put(acpm_np); 684 678 if (!pdev) 685 679 return ERR_PTR(-EPROBE_DEFER); 686 680 ··· 703 709 } 704 710 705 711 /** 706 - * devm_acpm_get_by_phandle() - managed get handle using phandle. 707 - * @dev: device pointer requesting ACPM handle. 708 - * @property: property name containing phandle on ACPM node. 712 + * devm_acpm_get_by_node() - managed get handle using node pointer. 713 + * @dev: device pointer requesting ACPM handle. 714 + * @np: ACPM device tree node. 709 715 * 710 716 * Return: pointer to handle on success, ERR_PTR(-errno) otherwise. 711 717 */ 712 - const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev, 713 - const char *property) 718 + const struct acpm_handle *devm_acpm_get_by_node(struct device *dev, 719 + struct device_node *np) 714 720 { 715 721 const struct acpm_handle **ptr, *handle; 716 722 ··· 718 724 if (!ptr) 719 725 return ERR_PTR(-ENOMEM); 720 726 721 - handle = acpm_get_by_phandle(dev, property); 727 + handle = acpm_get_by_node(dev, np); 722 728 if (!IS_ERR(handle)) { 723 729 *ptr = handle; 724 730 devres_add(dev, ptr); ··· 728 734 729 735 return handle; 730 736 } 737 + EXPORT_SYMBOL_GPL(devm_acpm_get_by_node); 731 738 732 739 static const struct acpm_match_data acpm_gs101 = { 733 740 .initdata_base = ACPM_GS101_INITDATA_BASE,
+4 -2
include/linux/firmware/samsung/exynos-acpm-protocol.h
··· 11 11 #include <linux/types.h> 12 12 13 13 struct acpm_handle; 14 + struct device_node; 14 15 15 16 struct acpm_pmic_ops { 16 17 int (*read_reg)(const struct acpm_handle *handle, ··· 45 44 46 45 struct device; 47 46 48 - const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev, 49 - const char *property); 47 + const struct acpm_handle *devm_acpm_get_by_node(struct device *dev, 48 + struct device_node *np); 49 + 50 50 #endif /* __EXYNOS_ACPM_PROTOCOL_H */