Re: [net-next PATCH v2 10/14] device property: Introduce fwnode_get_id()
From: Andy Shevchenko <hidden>
Date: 2020-12-15 17:45:52
Also in:
linux-acpi, lkml, netdev
From: Andy Shevchenko <hidden>
Date: 2020-12-15 17:45:52
Also in:
linux-acpi, lkml, netdev
On Tue, Dec 15, 2020 at 6:44 PM Calvin Johnson [off-list ref] wrote:
Using fwnode_get_id(), get the reg property value for DT node and get the _ADR object value for ACPI node.
and -> or ...
+/**
+ * fwnode_get_id - Get the id of a fwnode.
+ * @fwnode: firmware node
+ * @id: id of the fwnode
+ *
+ * Returns 0 on success or a negative errno.
+ */
+int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id)
+{
+ unsigned long long adr;
+ acpi_status status;
+
+ if (is_of_node(fwnode)) {
+ return of_property_read_u32(to_of_node(fwnode), "reg", id);ACPI nodes can hold reg property as well. I would rather think about ret = fwnode_property_read_u32(fwnode, "reg", id) if (!(ret && is_acpi_node(fwnode))) return ret;
+ } else if (is_acpi_node(fwnode)) {Redundant 'else'
+ status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), + METHOD_NAME__ADR, NULL, &adr); + if (ACPI_FAILURE(status)) + return -ENODATA;
I'm wondering if it compiles when CONFIG_ACPI=n.
+ *id = (u32)adr; + return 0; + }
+ return -EINVAL; +}
-- 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