* [PATCH] globalvar: allow running actions on set with globalvar_add_bool()
@ 2020-09-16 13:54 Ahmad Fatoum
2020-09-18 9:44 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2020-09-16 13:54 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
globalvar_add_simple_bool() and the other family of globalvars don't allow
running a callback when the variable is set. This is a useful thing
to have however for things like global.usbgadget.autostart=1.
Provide a globalvar_add_bool() that accommodates this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/globalvar.c | 8 +++++---
include/globalvar.h | 14 +++++++++++---
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 83f61366a201..5bde86aad08a 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -569,7 +569,9 @@ int globalvar_add_simple_int(const char *name, int *value,
return 0;
}
-int globalvar_add_simple_bool(const char *name, int *value)
+int globalvar_add_bool(const char *name,
+ int (*set)(struct param_d *, void *),
+ int *value, void *priv)
{
struct param_d *p;
int ret;
@@ -578,8 +580,8 @@ int globalvar_add_simple_bool(const char *name, int *value)
if (ret)
return ret;
- p = dev_add_param_bool(&global_device, name, NULL, NULL,
- value, NULL);
+ p = dev_add_param_bool(&global_device, name, set, NULL,
+ value, priv);
if (IS_ERR(p))
return PTR_ERR(p);
diff --git a/include/globalvar.h b/include/globalvar.h
index d798fa815c5a..84bee9102cf3 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -20,7 +20,9 @@ void globalvar_set(const char *name, const char *val);
int globalvar_add_simple_string(const char *name, char **value);
int globalvar_add_simple_int(const char *name, int *value,
const char *format);
-int globalvar_add_simple_bool(const char *name, int *value);
+int globalvar_add_bool(const char *name,
+ int (*set)(struct param_d *, void *),
+ int *value, void *priv);
int globalvar_add_simple_enum(const char *name, int *value,
const char * const *names, int max);
int globalvar_add_simple_bitmask(const char *name, unsigned long *value,
@@ -53,8 +55,9 @@ static inline int globalvar_add_simple_int(const char *name,
return 0;
}
-static inline int globalvar_add_simple_bool(const char *name,
- int *value)
+static inline int globalvar_add_bool(const char *name,
+ int (*set)(struct param_d *, void *),
+ int *value, void *priv)
{
return 0;
}
@@ -127,4 +130,9 @@ int nvvar_save(void);
int nv_complete(struct string_list *sl, char *instr);
int global_complete(struct string_list *sl, char *instr);
+static inline int globalvar_add_simple_bool(const char *name, int *value)
+{
+ return globalvar_add_bool(name, NULL, value, NULL);
+}
+
#endif /* __GLOBALVAR_H */
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] globalvar: allow running actions on set with globalvar_add_bool()
2020-09-16 13:54 [PATCH] globalvar: allow running actions on set with globalvar_add_bool() Ahmad Fatoum
@ 2020-09-18 9:44 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-09-18 9:44 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Sep 16, 2020 at 03:54:09PM +0200, Ahmad Fatoum wrote:
> globalvar_add_simple_bool() and the other family of globalvars don't allow
> running a callback when the variable is set. This is a useful thing
> to have however for things like global.usbgadget.autostart=1.
> Provide a globalvar_add_bool() that accommodates this.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> common/globalvar.c | 8 +++++---
> include/globalvar.h | 14 +++++++++++---
> 2 files changed, 16 insertions(+), 6 deletions(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-18 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 13:54 [PATCH] globalvar: allow running actions on set with globalvar_add_bool() Ahmad Fatoum
2020-09-18 9:44 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox