diff options
author | Eric Lapuyade <eric.lapuyade@linux.intel.com> | 2012-12-04 10:43:24 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-01-09 18:51:49 -0500 |
commit | 40d06d3647ea872a7346be1f6859f18cd0fe08d3 (patch) | |
tree | d219fb5d6eeaa5c0ece6cb554c0cf5b39fb6137f | |
parent | 27c31191b3d7ff32c266a5dbea344b9aa96ebf14 (diff) |
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>
-rw-r--r-- | drivers/nfc/pn544/pn544.c | 16 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 14 |
2 files changed, 19 insertions, 11 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, | |||
714 | return 0; | 714 | return 0; |
715 | } | 715 | } |
716 | 716 | ||
717 | /* | ||
718 | * Returns: | ||
719 | * <= 0: driver handled the event, skb consumed | ||
720 | * 1: driver does not handle the event, please do standard processing | ||
721 | */ | ||
717 | static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, | 722 | static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, |
718 | struct sk_buff *skb) | 723 | struct sk_buff *skb) |
719 | { | 724 | { |
720 | struct sk_buff *rgb_skb = NULL; | 725 | struct sk_buff *rgb_skb = NULL; |
721 | int r = 0; | 726 | int r; |
722 | 727 | ||
723 | pr_debug("hci event %d", event); | 728 | pr_debug("hci event %d", event); |
724 | switch (event) { | 729 | switch (event) { |
725 | case PN544_HCI_EVT_ACTIVATED: | 730 | case PN544_HCI_EVT_ACTIVATED: |
726 | if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE) | 731 | if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE) { |
727 | r = nfc_hci_target_discovered(hdev, gate); | 732 | r = nfc_hci_target_discovered(hdev, gate); |
728 | else if (gate == PN544_RF_READER_NFCIP1_TARGET_GATE) { | 733 | } else if (gate == PN544_RF_READER_NFCIP1_TARGET_GATE) { |
729 | r = nfc_hci_get_param(hdev, gate, PN544_DEP_ATR_REQ, | 734 | r = nfc_hci_get_param(hdev, gate, PN544_DEP_ATR_REQ, |
730 | &rgb_skb); | 735 | &rgb_skb); |
731 | if (r < 0) | 736 | if (r < 0) |
@@ -736,6 +741,8 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, | |||
736 | rgb_skb->len); | 741 | rgb_skb->len); |
737 | 742 | ||
738 | kfree_skb(rgb_skb); | 743 | kfree_skb(rgb_skb); |
744 | } else { | ||
745 | r = -EINVAL; | ||
739 | } | 746 | } |
740 | break; | 747 | break; |
741 | case PN544_HCI_EVT_DEACTIVATED: | 748 | case PN544_HCI_EVT_DEACTIVATED: |
@@ -757,8 +764,7 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, | |||
757 | skb_pull(skb, 2); | 764 | skb_pull(skb, 2); |
758 | return nfc_tm_data_received(hdev->ndev, skb); | 765 | return nfc_tm_data_received(hdev->ndev, skb); |
759 | default: | 766 | default: |
760 | pr_err("Discarded unknown event %x to gate %x\n", event, gate); | 767 | return 1; |
761 | break; | ||
762 | } | 768 | } |
763 | 769 | ||
764 | exit: | 770 | exit: |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index f30f6fe815b4..0430f3086e41 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -297,6 +297,12 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | |||
297 | goto exit; | 297 | goto exit; |
298 | } | 298 | } |
299 | 299 | ||
300 | if (hdev->ops->event_received) { | ||
301 | r = hdev->ops->event_received(hdev, gate, event, skb); | ||
302 | if (r <= 0) | ||
303 | goto exit_noskb; | ||
304 | } | ||
305 | |||
300 | switch (event) { | 306 | switch (event) { |
301 | case NFC_HCI_EVT_TARGET_DISCOVERED: | 307 | case NFC_HCI_EVT_TARGET_DISCOVERED: |
302 | if (skb->len < 1) { /* no status data? */ | 308 | if (skb->len < 1) { /* no status data? */ |
@@ -322,12 +328,8 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | |||
322 | r = nfc_hci_target_discovered(hdev, gate); | 328 | r = nfc_hci_target_discovered(hdev, gate); |
323 | break; | 329 | break; |
324 | default: | 330 | default: |
325 | if (hdev->ops->event_received) { | 331 | pr_info("Discarded unknown event %x to gate %x\n", event, gate); |
326 | r = hdev->ops->event_received(hdev, gate, event, skb); | 332 | r = -EINVAL; |
327 | goto exit_noskb; | ||
328 | } else { | ||
329 | r = -EINVAL; | ||
330 | } | ||
331 | break; | 333 | break; |
332 | } | 334 | } |
333 | 335 | ||