Bug 206516 - [patch] Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list
Summary: [patch] Teach ofw_bus_parse_xref_list_alloc to be able to return the length o...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-01-23 06:28 UTC by Stanislav Galabov
Modified: 2016-03-01 12:39 UTC (History)
2 users (show)

See Also:


Attachments
Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list (1.13 KB, patch)
2016-01-23 06:28 UTC, Stanislav Galabov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Galabov 2016-01-23 06:28:24 UTC
Created attachment 165990 [details]
Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list

Currently, there is no easy way to know in advance how many entries a list parsed by ofw_bus_parse_xref_list_alloc() in sys/dev/ofw/ofw_bus_subr.c has.

The attached patch allows us to pass an idx of -1 to ofw_bus_parse_xref_list_alloc(), in which case it would either return an error (negative) or the number of entries in the parsed list (non-negative).

This would be useful if we don't know in advance how many entries such a list has, but we need to get them (and store them) all - we can call ofw_bus_parse_xref_list_alloc with idx = -1, see how many entries to allocate memory for, and then loop through the entries to get each one of them.
Comment 1 Stanislav Galabov 2016-01-24 09:41:15 UTC
This bug is now followed at:
https://reviews.freebsd.org/D5043

Will continue work there.