mmi_info: provide check dynamic device status interface

To avoid uncessary register driver, a dynamic check device status
interface can be used to judge before register driver.

Change-Id: I07d61a80ca46b955110c37588a1a466b0b4f2922
Reviewed-on: https://gerrit.mot.com/2074097
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: litong <litong20@motorola.com>
Reviewed-by: Jichao Zou <zoujc@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
xizx 2021-09-23 14:23:38 +08:00 • committed by Zhenxin Xi
commit 4717829e9a
2 changed files with 30 additions and 0 deletions

View file

@ -93,6 +93,35 @@ bool mmi_device_is_available(struct device_node *np)
}
EXPORT_SYMBOL(mmi_device_is_available);
struct device_node *mmi_check_dynamic_device_node(char *dev_name)
{
struct property *prop;
struct device_node *node, *dst_node;
int len;
char *val = NULL;
node = of_find_node_by_path("/chosen");
if (node == NULL)
return NULL;
prop = of_find_property(node, "mmi,dynamic_devices", &len);
if (prop == NULL || len < 0) {
pr_err("%s: cannot find mmi,dynamic_devices property\n", __func__);
return NULL;
}
while ((val = (char *)of_prop_next_string(prop, val))) {
if (strstr(val, dev_name)) {
pr_info("%s: find matched dev name string %s\n", __func__, val);
dst_node = of_find_node_by_path(val);
return dst_node;
}
}
pr_err("%s: cannot find any node with dev_name %s\n", __func__, dev_name);
return NULL;
}
EXPORT_SYMBOL(mmi_check_dynamic_device_node);
static int mmi_get_bootarg_dt(char *key, char **value, char *prop, char *spl_flag)
{
const char *bootargs_tmp = NULL;

View file

@ -14,5 +14,6 @@
#define __MMI_DEVICE_H_INCLUDED
bool mmi_device_is_available(struct device_node *np);
struct device_node *mmi_check_dynamic_device_node(char *dev_name);
#endif /* __MMI_DEVICE_H_INCLUDED */