Skip to content
Permalink
Browse files
device property: Introduce fwnode_get_id()
Using fwnode_get_id(), get the reg property value for DT node
and get the _ADR object value for ACPI node.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
  • Loading branch information
calvinjolinux authored and intel-lab-lkp committed Dec 15, 2020
1 parent 36eaab3 commit b093f5463658b3a513d5b95ef208ee3264f1db08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
@@ -580,6 +580,32 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode)
return fwnode_call_ptr_op(fwnode, get_name_prefix);
}

/**
* 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);
} else if (is_acpi_node(fwnode)) {
status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode),
METHOD_NAME__ADR, NULL, &adr);
if (ACPI_FAILURE(status))
return -ENODATA;
*id = (u32)adr;
return 0;
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(fwnode_get_id);

/**
* fwnode_get_parent - Return parent firwmare node
* @fwnode: Firmware whose parent is retrieved
@@ -82,6 +82,7 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,

const char *fwnode_get_name(const struct fwnode_handle *fwnode);
const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id);
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_get_next_parent(
struct fwnode_handle *fwnode);

0 comments on commit b093f54

Please sign in to comment.