device-notifier: add callback that can receive user_data 95/268895/5
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 4 Jan 2022 09:34:49 +0000 (18:34 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 5 Jan 2022 05:17:42 +0000 (14:17 +0900)
commitb3036eb10b5d5ec1820ff9b5e619a1081e629197
treea6d62badb66fc94d33bdf68d86081683e37d02e1
parentb3a235df18f12c75095ce9e5d099a2bf73f33d41
device-notifier: add callback that can receive user_data

typedef int (*notify_cb_udata)(void *data, void *user_data)
 >> The callback has an additional parameter, user_data, for receiving
    user data.

typedef void (*destroy_cb_udata)(void *user_data)
 >> The callback is invoked on removing notifier with parameter
    user_data.

int __register_notifier_udata(enum device_notifier_type type,
 notify_cb_udata func, void *user_data, destroy_cb_udata func_destroy,
 const char *caller)
 >> Returns negative errno on error occured. Otherwise positive integer
    that denotes notifier id, which can be used for unregistering the
    notifier.
 >> There are two additional parameters compared to the original
    register_notifier(). One is user_data, which is passed as the
    second parameter to callback and the other is func_destroy, which
    is invoked on removing notifier.
 >> It is allowed to register multiple notifier with same callback on a
    same type, because a user_data might differ even though they have
    same callback on a same type.

int __unregister_notifier_udata(int id, const char *caller)
 >> Receives notifier id and unregisters matching notifier.

Change-Id: I46d1fec98eae19dbd9aaed60dfd84f760d152b9e
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/shared/device-notifier.c
src/shared/device-notifier.h
tests/deviced-common-private-test/test-device-notifier.c