Commit 61129d8f authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Carles Cufi
Browse files

input: longpress, keymap: use an explicit callback name



Use an explicit callback name so that multiple instances of this do not
result in a:

redefinition of '_input_callback__longpress_cb'

error. This used to work when it was using unique generated wrappers,
but now it needs an index in the callback name.

Use it in one of the API tests as well, just in case.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 6d1b880f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -99,8 +99,8 @@ static int keymap_init(const struct device *dev)
		KEYMAP_ENTRY_CODE(DT_PROP_BY_IDX(node_id, prop, idx)),

#define INPUT_KEYMAP_DEFINE(inst)								\
	INPUT_CALLBACK_DEFINE(DEVICE_DT_GET(DT_INST_PARENT(inst)), keymap_cb,			\
			      (void *)DEVICE_DT_INST_GET(inst));				\
	INPUT_CALLBACK_DEFINE_NAMED(DEVICE_DT_GET(DT_INST_PARENT(inst)), keymap_cb,		\
				    (void *)DEVICE_DT_INST_GET(inst), keymap_cb_##inst);	\
												\
	DT_INST_FOREACH_PROP_ELEM(inst, keymap, KEYMAP_ENTRY_VALIDATE)				\
												\
+3 −2
Original line number Diff line number Diff line
@@ -109,8 +109,9 @@ static int longpress_init(const struct device *dev)
		      !DT_INST_NODE_HAS_PROP(inst, short_codes));                                  \
	BUILD_ASSERT(DT_INST_PROP_LEN(inst, input_codes) == DT_INST_PROP_LEN(inst, long_codes));   \
	                                                                                           \
	INPUT_CALLBACK_DEFINE(DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, input)),                 \
			      longpress_cb, (void *)DEVICE_DT_INST_GET(inst));                     \
	INPUT_CALLBACK_DEFINE_NAMED(DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, input)),           \
				    longpress_cb, (void *)DEVICE_DT_INST_GET(inst),                \
				    longpress_cb_##inst);                                          \
	                                                                                           \
	static const uint16_t longpress_input_codes_##inst[] = DT_INST_PROP(inst, input_codes);    \
	                                                                                           \
+2 −1
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ static void input_cb_unfiltered(struct input_event *evt, void *user_data)
		k_sem_give(&cb_done);
	}
}
INPUT_CALLBACK_DEFINE(NULL, input_cb_unfiltered, NULL);
INPUT_CALLBACK_DEFINE_NAMED(NULL, input_cb_unfiltered, NULL,
			    input_cb_unfiltered_custom_name);

ZTEST(input_api, test_sequence_thread)
{