]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI/pwrctrl: Move pci_pwrctrl_is_required() earlier in file
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Tue, 21 Apr 2026 10:41:01 +0000 (16:11 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 27 Apr 2026 14:47:15 +0000 (09:47 -0500)
Move pci_pwrctrl_is_required() earlier in the file so it can be used by
pci_pwrctrl_power_off_device() and pci_pwrctrl_power_on_device().

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
[bhelgaas: split to its own patch]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260421104102.12322-1-manivannan.sadhasivam@oss.qualcomm.com
drivers/pci/pwrctrl/core.c

index 97cff5b8ca88525b092447cbfe2b588350b896af..a692aeaee81a0acc97f4966b608032f44c4c47be 100644 (file)
@@ -139,6 +139,48 @@ int devm_pci_pwrctrl_device_set_ready(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_pci_pwrctrl_device_set_ready);
 
+/*
+ * Check whether the pwrctrl device really needs to be created or not. The
+ * pwrctrl device will only be created if the node satisfies below requirements:
+ *
+ * 1. Presence of compatible property with "pci" prefix to match against the
+ *    pwrctrl driver (AND)
+ * 2. At least one of the power supplies defined in the devicetree node of the
+ *    device (OR) in the remote endpoint parent node to indicate pwrctrl
+ *    requirement.
+ */
+static bool pci_pwrctrl_is_required(struct device_node *np)
+{
+       struct device_node *endpoint;
+       const char *compat;
+       int ret;
+
+       ret = of_property_read_string(np, "compatible", &compat);
+       if (ret < 0)
+               return false;
+
+       if (!strstarts(compat, "pci"))
+               return false;
+
+       if (of_pci_supply_present(np))
+               return true;
+
+       if (of_graph_is_present(np)) {
+               for_each_endpoint_of_node(np, endpoint) {
+                       struct device_node *remote __free(device_node) =
+                               of_graph_get_remote_port_parent(endpoint);
+                       if (remote) {
+                               if (of_pci_supply_present(remote)) {
+                                       of_node_put(endpoint);
+                                       return true;
+                               }
+                       }
+               }
+       }
+
+       return false;
+}
+
 static int __pci_pwrctrl_power_off_device(struct device *dev)
 {
        struct pci_pwrctrl *pwrctrl = dev_get_drvdata(dev);
@@ -268,48 +310,6 @@ err_power_off:
 }
 EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
 
-/*
- * Check whether the pwrctrl device really needs to be created or not. The
- * pwrctrl device will only be created if the node satisfies below requirements:
- *
- * 1. Presence of compatible property with "pci" prefix to match against the
- *    pwrctrl driver (AND)
- * 2. At least one of the power supplies defined in the devicetree node of the
- *    device (OR) in the remote endpoint parent node to indicate pwrctrl
- *    requirement.
- */
-static bool pci_pwrctrl_is_required(struct device_node *np)
-{
-       struct device_node *endpoint;
-       const char *compat;
-       int ret;
-
-       ret = of_property_read_string(np, "compatible", &compat);
-       if (ret < 0)
-               return false;
-
-       if (!strstarts(compat, "pci"))
-               return false;
-
-       if (of_pci_supply_present(np))
-               return true;
-
-       if (of_graph_is_present(np)) {
-               for_each_endpoint_of_node(np, endpoint) {
-                       struct device_node *remote __free(device_node) =
-                               of_graph_get_remote_port_parent(endpoint);
-                       if (remote) {
-                               if (of_pci_supply_present(remote)) {
-                                       of_node_put(endpoint);
-                                       return true;
-                               }
-                       }
-               }
-       }
-
-       return false;
-}
-
 static int pci_pwrctrl_create_device(struct device_node *np,
                                     struct device *parent)
 {