scriptic: Support searching by name
Rather than hardcoding scriptic scripts, we can look through all known script names.
This commit is contained in:
parent
72f92b7fd2
commit
50dc503837
2 changed files with 23 additions and 5 deletions
|
@ -163,7 +163,7 @@ struct scriptic {
|
||||||
|
|
||||||
int scriptic_execute(const struct scriptic *script);
|
int scriptic_execute(const struct scriptic *script);
|
||||||
const struct scriptic *scriptic_get(const char *name);
|
const struct scriptic *scriptic_get(const char *name);
|
||||||
|
int scriptic_run(const char *name);
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
|
|
26
scriptic.c
26
scriptic.c
|
@ -6,6 +6,11 @@
|
||||||
extern struct scriptic set_plls;
|
extern struct scriptic set_plls;
|
||||||
extern struct scriptic enable_psram;
|
extern struct scriptic enable_psram;
|
||||||
|
|
||||||
|
static struct scriptic *scripts[] = {
|
||||||
|
&set_plls,
|
||||||
|
&enable_psram,
|
||||||
|
};
|
||||||
|
|
||||||
static int sc_header_command(struct scriptic_header *header)
|
static int sc_header_command(struct scriptic_header *header)
|
||||||
{
|
{
|
||||||
return header->command;
|
return header->command;
|
||||||
|
@ -170,14 +175,27 @@ int scriptic_execute(const struct scriptic *script)
|
||||||
const struct scriptic *scriptic_get(const char *name)
|
const struct scriptic *scriptic_get(const char *name)
|
||||||
{
|
{
|
||||||
struct scriptic *script = NULL;
|
struct scriptic *script = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!_strcasecmp(name, "set_plls"))
|
for (i = 0; i < sizeof(scripts) / sizeof(*scripts); i++) {
|
||||||
script = &set_plls;
|
if (!_strcasecmp(name, scripts[i]->name)) {
|
||||||
else if (!_strcasecmp(name, "enable_psram"))
|
script = scripts[i];
|
||||||
script = &enable_psram;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (script && script->command_count == 0)
|
if (script && script->command_count == 0)
|
||||||
script->command_count = sc_command_count(script);
|
script->command_count = sc_command_count(script);
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scriptic_run(const char *name)
|
||||||
|
{
|
||||||
|
const struct scriptic *script;
|
||||||
|
|
||||||
|
script = scriptic_get(name);
|
||||||
|
if (!script)
|
||||||
|
return -1;
|
||||||
|
return scriptic_execute(script);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue