Prepare some api for DM (#7894)

Signed-off-by: GuEe-GUI <GuEe-GUI@github.com>
This commit is contained in:
GUI
2023-08-02 12:48:24 +08:00
committed by GitHub
parent f5fe1a5d7b
commit d3417aa0d7
10 changed files with 65 additions and 36 deletions
+4 -3
View File
@@ -10,6 +10,7 @@
#include <rtthread.h>
#include <string.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
#include <drivers/ofw_fdt.h>
@@ -249,7 +250,7 @@ rt_bool_t rt_ofw_node_tag_equ(const struct rt_ofw_node *np, const char *tag)
if (np && tag)
{
const char *node_name = rt_fdt_node_name(np->full_name);
rt_size_t tag_len = rt_strchrnul(node_name, '@') - node_name;
rt_size_t tag_len = strchrnul(node_name, '@') - node_name;
ret = (rt_strlen(tag) == tag_len && !rt_strncmp(node_name, tag, tag_len));
}
@@ -569,7 +570,7 @@ struct rt_ofw_node *rt_ofw_find_node_by_ids_r(struct rt_ofw_node *from, const st
struct rt_ofw_node *rt_ofw_find_node_by_path(const char *path)
{
struct rt_ofw_node *np, *parent, *tmp;
struct rt_ofw_node *np = RT_NULL, *parent, *tmp = RT_NULL;
if (path)
{
@@ -584,7 +585,7 @@ struct rt_ofw_node *rt_ofw_find_node_by_path(const char *path)
while (*path)
{
const char *next = rt_strchrnul(path, '/');
const char *next = strchrnul(path, '/');
rt_size_t len = next - path;
tmp = RT_NULL;
+5 -4
View File
@@ -11,6 +11,7 @@
#include <rthw.h>
#include <rtthread.h>
#include <string.h>
#include <drivers/ofw_fdt.h>
#include <drivers/ofw_raw.h>
#include <drivers/core/dm.h>
@@ -40,7 +41,7 @@ static rt_size_t _root_addr_cells;
const char *rt_fdt_node_name(const char *full_name)
{
const char *node_name = rt_strrchr(full_name, '/');
const char *node_name = strrchr(full_name, '/');
return node_name ? node_name + 1 : full_name;
}
@@ -701,7 +702,7 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)
if (stdout_path && len)
{
const char *path_split = rt_strchrnul(stdout_path, ':');
const char *path_split = strchrnul(stdout_path, ':');
if (*path_split != '\0')
{
@@ -780,13 +781,13 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)
if (*options)
{
type_len = rt_strchrnul(options, ',') - options;
type_len = strchrnul(options, ',') - options;
}
}
if (options && *options && *options != ' ')
{
options_len = rt_strchrnul(options, ' ') - options;
options_len = strchrnul(options, ' ') - options;
}
/* console > stdout-path */
+2 -1
View File
@@ -10,6 +10,7 @@
#include <rtthread.h>
#include <string.h>
#include <drivers/pic.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
@@ -130,7 +131,7 @@ static rt_err_t ofw_parse_irq_map(struct rt_ofw_node *np, struct rt_ofw_cell_arg
* <0x1800 0 0 4 &gic 0 0 GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>; // INTD
* };
*
* In fact, basically no SoC will be use multi ic to implemented INTx.
* In fact, almost no SoC will be use multi IC to implement INTx.
* before call ofw_parse_irq_map(np, &args):
*
* args.data = addr;