Skip to content

Commit

Permalink
fel: introduce get_next_soc()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
apritzel committed Oct 24, 2023
1 parent c336885 commit fb0d890
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions soc_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions soc_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit fb0d890

Please sign in to comment.