From cb050f2c3011b25dbad5090a147a7417eee44f8d Mon Sep 17 00:00:00 2001 From: nirenjan Date: Sat, 18 Apr 2020 01:28:12 -0700 Subject: [PATCH] Allow NULL cb_handle in libx52_hotplug_register_callback This allows the caller to register a callback and forget about it. This is useful in cases where a particular callback needs to be run everytime, and there is no point in deregistering it until the application terminates, at which point `libx52_hotplug_exit` will take care of the cleanup. --- lib/libx52/x52_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libx52/x52_core.c b/lib/libx52/x52_core.c index 7560c8c..be42d8e 100644 --- a/lib/libx52/x52_core.c +++ b/lib/libx52/x52_core.c @@ -328,7 +328,10 @@ int libx52_hotplug_register_callback(libx52_hotplug_service *svc, /* Insert the node into the callbacks list */ svc->callbacks[i] = hdl; - *cb_handle = hdl; + if (cb_handle != NULL) { + *cb_handle = hdl; + } + return LIBX52_SUCCESS; }