hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/of/base.c
....@@ -628,6 +628,28 @@
628628 EXPORT_SYMBOL(of_device_is_available);
629629
630630 /**
631
+ * __of_device_is_fail - check if a device has status "fail" or "fail-..."
632
+ *
633
+ * @device: Node to check status for, with locks already held
634
+ *
635
+ * Return: True if the status property is set to "fail" or "fail-..." (for any
636
+ * error code suffix), false otherwise
637
+ */
638
+static bool __of_device_is_fail(const struct device_node *device)
639
+{
640
+ const char *status;
641
+
642
+ if (!device)
643
+ return false;
644
+
645
+ status = __of_get_property(device, "status", NULL);
646
+ if (status == NULL)
647
+ return false;
648
+
649
+ return !strcmp(status, "fail") || !strncmp(status, "fail-", 5);
650
+}
651
+
652
+/**
631653 * of_device_is_big_endian - check if a device has BE registers
632654 *
633655 * @device: Node to check for endianness
....@@ -775,6 +797,9 @@
775797 * of_get_next_cpu_node - Iterate on cpu nodes
776798 * @prev: previous child of the /cpus node, or NULL to get first
777799 *
800
+ * Unusable CPUs (those with the status property set to "fail" or "fail-...")
801
+ * will be skipped.
802
+ *
778803 * Returns a cpu node pointer with refcount incremented, use of_node_put()
779804 * on it when done. Returns NULL when prev is the last child. Decrements
780805 * the refcount of prev.
....@@ -796,6 +821,8 @@
796821 of_node_put(node);
797822 }
798823 for (; next; next = next->sibling) {
824
+ if (__of_device_is_fail(next))
825
+ continue;
799826 if (!(of_node_name_eq(next, "cpu") ||
800827 __of_node_is_type(next, "cpu")))
801828 continue;