From c3aa46566bf93f9b08fb190098cf05e936e2a933 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 16 Sep 2020 15:54:09 +0200 Subject: globalvar: allow running actions on set with globalvar_add_bool() 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 Signed-off-by: Sascha Hauer --- common/globalvar.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'common/globalvar.c') diff --git a/common/globalvar.c b/common/globalvar.c index 98a028a68a..6ab4c1f68e 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -514,7 +514,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; @@ -523,8 +525,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); -- cgit v1.2.3