nfctool: polling: Fix netlink event handler

With this patch, the netlink event handler for poll operations now only
treats messages from the device specified with the -d command line

This fixes an issue when used with nfcsim (the loopback driver) for
which you have 2 instances of nfctool running simultaneously in poll
mode. Both instances were receiving the TARGETS_FOUND and TM_ACTIVATED
events which could lead to prematurely stop the poll operation for the
target device.

Signed-off-by: Samuel Ortiz <>
diff --git a/tools/nfctool/main.c b/tools/nfctool/main.c
index 00b099f..c9a236f 100644
--- a/tools/nfctool/main.c
+++ b/tools/nfctool/main.c
@@ -305,6 +305,9 @@
 	int err = 0;
+	if (idx != opts.adapter_idx)
+		return 0;
 	DBG("cmd: %d, idx: %d", cmd, idx);
 	switch (cmd) {