]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: exynos-acpm: introduce devm_acpm_get_by_node()
authorAndré Draszik <andre.draszik@linaro.org>
Thu, 27 Mar 2025 12:54:28 +0000 (12:54 +0000)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 22 Apr 2025 07:50:06 +0000 (09:50 +0200)
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>
drivers/firmware/samsung/exynos-acpm.c
include/linux/firmware/samsung/exynos-acpm-protocol.h

index b379f2d9cad0dc31bd7991952d2b8b38581179a1..93f87cd90f24938a469dbcf014034ae3e9176df4 100644 (file)
@@ -667,20 +667,14 @@ static void devm_acpm_release(struct device *dev, void *res)
  *
  * Return: pointer to handle on success, ERR_PTR(-errno) otherwise.
  */
-static const struct acpm_handle *acpm_get_by_phandle(struct device *dev,
-                                                    const char *property)
+static const struct acpm_handle *acpm_get_by_node(struct device *dev,
+                                                 struct device_node *acpm_np)
 {
        struct platform_device *pdev;
-       struct device_node *acpm_np;
        struct device_link *link;
        struct acpm_info *acpm;
 
-       acpm_np = of_parse_phandle(dev->of_node, property, 0);
-       if (!acpm_np)
-               return ERR_PTR(-ENODEV);
-
        pdev = of_find_device_by_node(acpm_np);
-       of_node_put(acpm_np);
        if (!pdev)
                return ERR_PTR(-EPROBE_DEFER);
 
@@ -709,14 +703,14 @@ static const struct acpm_handle *acpm_get_by_phandle(struct device *dev,
 }
 
 /**
- * devm_acpm_get_by_phandle() - managed get handle using phandle.
- * @dev:        device pointer requesting ACPM handle.
- * @property:   property name containing phandle on ACPM node.
+ * devm_acpm_get_by_node() - managed get handle using node pointer.
+ * @dev: device pointer requesting ACPM handle.
+ * @np:  ACPM device tree node.
  *
  * Return: pointer to handle on success, ERR_PTR(-errno) otherwise.
  */
-const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
-                                                  const char *property)
+const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
+                                               struct device_node *np)
 {
        const struct acpm_handle **ptr, *handle;
 
@@ -724,7 +718,7 @@ const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
        if (!ptr)
                return ERR_PTR(-ENOMEM);
 
-       handle = acpm_get_by_phandle(dev, property);
+       handle = acpm_get_by_node(dev, np);
        if (!IS_ERR(handle)) {
                *ptr = handle;
                devres_add(dev, ptr);
@@ -734,6 +728,7 @@ const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
 
        return handle;
 }
+EXPORT_SYMBOL_GPL(devm_acpm_get_by_node);
 
 static const struct acpm_match_data acpm_gs101 = {
        .initdata_base = ACPM_GS101_INITDATA_BASE,
index 76255b5d06b1228bb8579d32aaa478036a5c344e..f628bf1862c25fa018a2fe5e7e123bf05c5254b9 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 
 struct acpm_handle;
+struct device_node;
 
 struct acpm_pmic_ops {
        int (*read_reg)(const struct acpm_handle *handle,
@@ -44,6 +45,7 @@ struct acpm_handle {
 
 struct device;
 
-const struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev,
-                                                  const char *property);
+const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
+                                               struct device_node *np);
+
 #endif /* __EXYNOS_ACPM_PROTOCOL_H */