Skip to content

Commit

Permalink
Drivers:OFW:replace new rt_str* to string.h
Browse files Browse the repository at this point in the history
Now, we only use STD string if possible.

Signed-off-by: GuEe-GUI <[email protected]>
  • Loading branch information
GuEe-GUI committed Aug 1, 2023
1 parent 3e49b6a commit 7bf542b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions components/drivers/ofw/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <rtthread.h>

#include <string.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
#include <drivers/ofw_fdt.h>
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions components/drivers/ofw/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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')
{
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion components/drivers/ofw/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <rtthread.h>

#include <string.h>
#include <drivers/pic.h>
#include <drivers/ofw.h>
#include <drivers/ofw_io.h>
Expand Down Expand Up @@ -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, amost no SoC will be use multi ic to implemented INTx.
* before call ofw_parse_irq_map(np, &args):
*
* args.data = addr;
Expand Down

0 comments on commit 7bf542b

Please sign in to comment.