Commit 6d1b880f authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Carles Cufi
Browse files

input: add a INPUT_CALLBACK_DEFINE_NAMED macro



Add a INPUT_CALLBACK_DEFINE_NAMED macro, same as INPUT_CALLBACK_DEFINE
but with custom struct name, useful for declaring multiple callbacks
with different user_data on the same callback function.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 716fa268
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -129,6 +129,20 @@ struct input_callback {
	void *user_data;
};

/**
 * @brief Register a callback structure for input events with a custom name.
 *
 * Same as @ref INPUT_CALLBACK_DEFINE but allows specifying a custom name
 * for the callback structure. Useful if multiple callbacks are used for the
 * same callback function.
 */
#define INPUT_CALLBACK_DEFINE_NAMED(_dev, _callback, _user_data, name)         \
	static const STRUCT_SECTION_ITERABLE(input_callback, name) = {         \
		.dev = _dev,                                                   \
		.callback = _callback,                                         \
		.user_data = _user_data,                                       \
	}

/**
 * @brief Register a callback structure for input events.
 *
@@ -141,12 +155,8 @@ struct input_callback {
 * @param _user_data Pointer to user specified data.
 */
#define INPUT_CALLBACK_DEFINE(_dev, _callback, _user_data)                     \
	static const STRUCT_SECTION_ITERABLE(input_callback,                   \
					     _input_callback__##_callback) = { \
		.dev = _dev,                                                   \
		.callback = _callback,                                         \
		.user_data = _user_data,                                       \
	}
	INPUT_CALLBACK_DEFINE_NAMED(_dev, _callback, _user_data,               \
				    _input_callback__##_callback)

#ifdef __cplusplus
}