Thread (38 messages) 38 messages, 4 authors, 2021-02-06

Re: [net-next PATCH v4 09/15] device property: Introduce fwnode_get_id()

From: Andy Shevchenko <hidden>
Date: 2021-01-22 16:27:52
Also in: linux-acpi, lkml, netdev

On Fri, Jan 22, 2021 at 09:12:54PM +0530, Calvin Johnson wrote:
Using fwnode_get_id(), get the reg property value for DT node
or get the _ADR object value for ACPI node.
...
+/**
+ * fwnode_get_id - Get the id of a fwnode.
+ * @fwnode: firmware node
+ * @id: id of the fwnode
+ *
+ * This function provides the id of a fwnode which can be either
+ * DT or ACPI node. For ACPI, "reg" property value, if present will
+ * be provided or else _ADR value will be provided.
+ * Returns 0 on success or a negative errno.
+ */
+int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id)
+{
+#ifdef CONFIG_ACPI
+	unsigned long long adr;
+	acpi_status status;
+#endif
Instead you may do...
+	int ret;
+
+	ret = fwnode_property_read_u32(fwnode, "reg", id);
+	if (ret) {
+#ifdef CONFIG_ACPI
...it here like

		unsigned long long adr;
		acpi_status status;
+		status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode),
+					       METHOD_NAME__ADR, NULL, &adr);
+		if (ACPI_FAILURE(status))
+			return -EINVAL;
+		*id = (u32)adr;
+#else
+		return ret;
+#endif
+	}
+	return 0;
+}
-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help