fel: introduce get_next_soc()
At the moment we can search for a specific SoC in our supported SoC table by looking for its SoC ID, but we cannot otherwise enumerate all supported SoCs. Add a get_next_soc() function that allows iterating over our (internal) table: The first call will take NULL as an argument, subsequent calls pass in the pointer returned by the previous call. When we reach the end of the list, the function returns NULL. Signed-off-by: Andre Przywara <osp@andrep.de>
This commit is contained in:
parent
c336885f6a
commit
34c3150898
27
soc_info.c
27
soc_info.c
@ -590,6 +590,33 @@ soc_info_t *get_soc_info_from_version(struct aw_fel_version *buf)
|
||||
return get_soc_info_from_id(buf->soc_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Iterate through all supported SoCs. The first call will take NULL as
|
||||
* an argument, subsequent calls pass in the pointer returned by the
|
||||
* previous call. When we reach the end of the list, the function
|
||||
* returns NULL.
|
||||
*/
|
||||
const soc_info_t *get_next_soc(const soc_info_t *prev)
|
||||
{
|
||||
const soc_info_t *soc;
|
||||
|
||||
if (prev == NULL)
|
||||
return &soc_info_table[0];
|
||||
|
||||
for (soc = soc_info_table; soc->swap_buffers; soc++) {
|
||||
if (soc != prev)
|
||||
continue;
|
||||
|
||||
soc++;
|
||||
if (!soc->swap_buffers) /* end of list? */
|
||||
return NULL;
|
||||
|
||||
return soc;
|
||||
}
|
||||
|
||||
return NULL; /* prev entry not found */
|
||||
}
|
||||
|
||||
void get_soc_name_from_id(soc_name_t buffer, uint32_t soc_id)
|
||||
{
|
||||
soc_info_t *soc;
|
||||
|
||||
@ -143,5 +143,6 @@ typedef struct {
|
||||
void get_soc_name_from_id(soc_name_t buffer, uint32_t soc_id);
|
||||
soc_info_t *get_soc_info_from_id(uint32_t soc_id);
|
||||
soc_info_t *get_soc_info_from_version(struct aw_fel_version *buf);
|
||||
const soc_info_t *get_next_soc(const soc_info_t *prev);
|
||||
|
||||
#endif /* _SUNXI_TOOLS_SOC_INFO_H */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user