Skip to content

Commit ab27225

Browse files
committed
[OFW] io ranges use list to storage without ofw data
ofw data is private data for every ofw node that the drivers of ofw node will use item. replace the ranges supported to list. Signed-off-by: GuEe-GUI <[email protected]>
1 parent 1a15146 commit ab27225

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

components/drivers/ofw/io.c

+18-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
#include "ofw_internal.h"
2222

23+
static struct rt_spinlock _bus_range_nodes_lock = {};
24+
static rt_list_t _bus_range_nodes = RT_LIST_OBJECT_INIT(_bus_range_nodes);
25+
2326
static int ofw_bus_addr_cells(struct rt_ofw_node *np)
2427
{
2528
int res = OFW_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -322,7 +325,12 @@ static struct bus_ranges *ofw_bus_ranges(struct rt_ofw_node *np, struct rt_ofw_p
322325
*child_size++ = rt_fdt_next_cell(&cell, child_size_cells);
323326
}
324327

325-
rt_ofw_data(np) = ranges;
328+
ranges->np = np;
329+
rt_list_init(&ranges->list);
330+
331+
rt_hw_spin_lock(&_bus_range_nodes_lock.lock);
332+
rt_list_insert_before(&_bus_range_nodes, &ranges->list);
333+
rt_hw_spin_unlock(&_bus_range_nodes_lock.lock);
326334
} while (0);
327335

328336
return ranges;
@@ -341,7 +349,7 @@ rt_uint64_t rt_ofw_translate_address(struct rt_ofw_node *np, const char *range_t
341349
{
342350
rt_ssize_t len;
343351
struct rt_ofw_prop *prop;
344-
struct bus_ranges *ranges;
352+
struct bus_ranges *ranges = RT_NULL, *ranges_tmp;
345353

346354
prop = rt_ofw_get_prop(np, range_type, &len);
347355

@@ -350,7 +358,14 @@ rt_uint64_t rt_ofw_translate_address(struct rt_ofw_node *np, const char *range_t
350358
continue;
351359
}
352360

353-
ranges = rt_ofw_data(np);
361+
rt_list_for_each_entry(ranges_tmp, &_bus_range_nodes, list)
362+
{
363+
if (ranges_tmp->np == np)
364+
{
365+
ranges = ranges_tmp;
366+
break;
367+
}
368+
}
354369

355370
if (!ranges)
356371
{

components/drivers/ofw/ofw_internal.h

+3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ struct alias_info
4949

5050
struct bus_ranges
5151
{
52+
rt_list_t list;
53+
5254
rt_size_t nr;
55+
struct rt_ofw_node *np;
5356

5457
rt_uint64_t *child_addr;
5558
rt_uint64_t *parent_addr;

0 commit comments

Comments
 (0)