Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFC: Export target lost function

NFC drivers will call this routine when they detect that a tag leaves the
RF field. This will eventually lead to the corresponding netlink event
to be sent.

Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Eric Lapuyade and committed by
John W. Linville
e1da0efa 8112a5c9

+40
+1
include/net/nfc/nfc.h
··· 181 181 182 182 int nfc_targets_found(struct nfc_dev *dev, 183 183 struct nfc_target *targets, int ntargets); 184 + int nfc_target_lost(struct nfc_dev *dev, u32 target_idx); 184 185 185 186 int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, 186 187 u8 comm_mode, u8 rf_mode);
+39
net/nfc/core.c
··· 455 455 } 456 456 EXPORT_SYMBOL(nfc_targets_found); 457 457 458 + int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) 459 + { 460 + struct nfc_target *tg; 461 + int i; 462 + 463 + pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx); 464 + 465 + spin_lock_bh(&dev->targets_lock); 466 + 467 + for (i = 0; i < dev->n_targets; i++) { 468 + tg = &dev->targets[i]; 469 + if (tg->idx == target_idx) 470 + break; 471 + } 472 + 473 + if (i == dev->n_targets) { 474 + spin_unlock_bh(&dev->targets_lock); 475 + return -EINVAL; 476 + } 477 + 478 + dev->targets_generation++; 479 + dev->n_targets--; 480 + 481 + if (dev->n_targets) { 482 + memcpy(&dev->targets[i], &dev->targets[i + 1], 483 + (dev->n_targets - i) * sizeof(struct nfc_target)); 484 + } else { 485 + kfree(dev->targets); 486 + dev->targets = NULL; 487 + } 488 + 489 + spin_unlock_bh(&dev->targets_lock); 490 + 491 + nfc_genl_target_lost(dev, target_idx); 492 + 493 + return 0; 494 + } 495 + EXPORT_SYMBOL(nfc_target_lost); 496 + 458 497 static void nfc_release(struct device *d) 459 498 { 460 499 struct nfc_dev *dev = to_nfc_dev(d);