mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
expo: Allow setting the start of the dynamic-ID range
Provide a way to set this value so that it is easy to separate the statically allocated IDs (generated by the caller) from those generated dynamically by expo itself. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b828ed7d79
commit
9af341502c
4 changed files with 37 additions and 10 deletions
15
boot/expo.c
15
boot/expo.c
|
@ -56,6 +56,21 @@ void expo_destroy(struct expo *exp)
|
||||||
free(exp);
|
free(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint resolve_id(struct expo *exp, uint id)
|
||||||
|
{
|
||||||
|
if (!id)
|
||||||
|
id = exp->next_id++;
|
||||||
|
else if (id >= exp->next_id)
|
||||||
|
exp->next_id = id + 1;
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void expo_set_dynamic_start(struct expo *exp, uint dyn_start)
|
||||||
|
{
|
||||||
|
exp->next_id = dyn_start;
|
||||||
|
}
|
||||||
|
|
||||||
int expo_str(struct expo *exp, const char *name, uint id, const char *str)
|
int expo_str(struct expo *exp, const char *name, uint id, const char *str)
|
||||||
{
|
{
|
||||||
struct expo_string *estr;
|
struct expo_string *estr;
|
||||||
|
|
10
boot/scene.c
10
boot/scene.c
|
@ -18,16 +18,6 @@
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include "scene_internal.h"
|
#include "scene_internal.h"
|
||||||
|
|
||||||
uint resolve_id(struct expo *exp, uint id)
|
|
||||||
{
|
|
||||||
if (!id)
|
|
||||||
id = exp->next_id++;
|
|
||||||
else if (id >= exp->next_id)
|
|
||||||
exp->next_id = id + 1;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp)
|
int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp)
|
||||||
{
|
{
|
||||||
struct scene *scn;
|
struct scene *scn;
|
||||||
|
|
|
@ -85,6 +85,9 @@ or even the IDs of objects. Programmatic creation of many items in a loop can be
|
||||||
handled by allocating space in the enum for a maximum number of items, then
|
handled by allocating space in the enum for a maximum number of items, then
|
||||||
adding the loop count to the enum values to obtain unique IDs.
|
adding the loop count to the enum values to obtain unique IDs.
|
||||||
|
|
||||||
|
Where dynamic IDs are need, use expo_set_dynamic_start() to set the start value,
|
||||||
|
so that they are allocated above the starting (enum) IDs.
|
||||||
|
|
||||||
All text strings are stored in a structure attached to the expo, referenced by
|
All text strings are stored in a structure attached to the expo, referenced by
|
||||||
a text ID. This makes it easier at some point to implement multiple languages or
|
a text ID. This makes it easier at some point to implement multiple languages or
|
||||||
to support Unicode strings.
|
to support Unicode strings.
|
||||||
|
|
|
@ -257,6 +257,25 @@ int expo_new(const char *name, void *priv, struct expo **expp);
|
||||||
*/
|
*/
|
||||||
void expo_destroy(struct expo *exp);
|
void expo_destroy(struct expo *exp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* expo_set_dynamic_start() - Set the start of the 'dynamic' IDs
|
||||||
|
*
|
||||||
|
* It is common for a set of 'static' IDs to be used to refer to objects in the
|
||||||
|
* expo. These typically use an enum so that they are defined in sequential
|
||||||
|
* order.
|
||||||
|
*
|
||||||
|
* Dynamic IDs (for objects not in the enum) are intended to be used for
|
||||||
|
* objects to which the code does not need to refer. These are ideally located
|
||||||
|
* above the static IDs.
|
||||||
|
*
|
||||||
|
* Use this function to set the start of the dynamic range, making sure that the
|
||||||
|
* value is higher than all the statically allocated IDs.
|
||||||
|
*
|
||||||
|
* @exp: Expo to update
|
||||||
|
* @dyn_start: Start ID that expo should use for dynamic allocation
|
||||||
|
*/
|
||||||
|
void expo_set_dynamic_start(struct expo *exp, uint dyn_start);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expo_str() - add a new string to an expo
|
* expo_str() - add a new string to an expo
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue