Commit 632c016a authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

NFC: HCI check presence must not fail when driver doesn't support it

When the driver does not support checking the tag is still present, it
must return -EOPNOTSUPP. The NFC Core will then stop asking and not
report a tag lost event to user space.
Signed-off-by: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent da052850
...@@ -986,7 +986,7 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev, ...@@ -986,7 +986,7 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
} else if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) { } else if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) {
if (target->nfcid1_len != 4 && target->nfcid1_len != 7 && if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
target->nfcid1_len != 10) target->nfcid1_len != 10)
return -EPROTO; return -EOPNOTSUPP;
return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE, return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
PN544_RF_READER_CMD_ACTIVATE_NEXT, PN544_RF_READER_CMD_ACTIVATE_NEXT,
......
...@@ -697,6 +697,8 @@ static void nfc_check_pres_work(struct work_struct *work) ...@@ -697,6 +697,8 @@ static void nfc_check_pres_work(struct work_struct *work)
if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) { if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) {
rc = dev->ops->check_presence(dev, dev->active_target); rc = dev->ops->check_presence(dev, dev->active_target);
if (rc == -EOPNOTSUPP)
goto exit;
if (!rc) { if (!rc) {
mod_timer(&dev->check_pres_timer, jiffies + mod_timer(&dev->check_pres_timer, jiffies +
msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
...@@ -708,6 +710,7 @@ static void nfc_check_pres_work(struct work_struct *work) ...@@ -708,6 +710,7 @@ static void nfc_check_pres_work(struct work_struct *work)
} }
} }
exit:
device_unlock(&dev->dev); device_unlock(&dev->dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment