summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn544/pn544.c
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@linux.intel.com>2012-12-04 16:43:24 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2013-01-10 00:51:49 +0100
commit40d06d3647ea872a7346be1f6859f18cd0fe08d3 (patch)
treed219fb5d6eeaa5c0ece6cb554c0cf5b39fb6137f /drivers/nfc/pn544/pn544.c
parent27c31191b3d7ff32c266a5dbea344b9aa96ebf14 (diff)
downloadlinux-40d06d3647ea872a7346be1f6859f18cd0fe08d3.tar.bz2
NFC: Changed event_received hci ops result semantic
Some chips use a standard HCI event code, destined to a proprietary gate, with a different meaning. Therefore, the HCI driver must always have a chance to intercept the event before standard processing is attempted. The new semantic specifies that the result value "1" means that the driver doesn't especially handle the event. result <= 0 means it was handled. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn544/pn544.c')
-rw-r--r--drivers/nfc/pn544/pn544.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c
index 4af70f9c01aa..9349c548e8dc 100644
--- a/drivers/nfc/pn544/pn544.c
+++ b/drivers/nfc/pn544/pn544.c
@@ -714,18 +714,23 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
return 0;
}
+/*
+ * Returns:
+ * <= 0: driver handled the event, skb consumed
+ * 1: driver does not handle the event, please do standard processing
+ */
static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
struct sk_buff *skb)
{
struct sk_buff *rgb_skb = NULL;
- int r = 0;
+ int r;
pr_debug("hci event %d", event);
switch (event) {
case PN544_HCI_EVT_ACTIVATED:
- if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE)
+ if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE) {
r = nfc_hci_target_discovered(hdev, gate);
- else if (gate == PN544_RF_READER_NFCIP1_TARGET_GATE) {
+ } else if (gate == PN544_RF_READER_NFCIP1_TARGET_GATE) {
r = nfc_hci_get_param(hdev, gate, PN544_DEP_ATR_REQ,
&rgb_skb);
if (r < 0)
@@ -736,6 +741,8 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
rgb_skb->len);
kfree_skb(rgb_skb);
+ } else {
+ r = -EINVAL;
}
break;
case PN544_HCI_EVT_DEACTIVATED:
@@ -757,8 +764,7 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
skb_pull(skb, 2);
return nfc_tm_data_received(hdev->ndev, skb);
default:
- pr_err("Discarded unknown event %x to gate %x\n", event, gate);
- break;
+ return 1;
}
exit: