mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-05 06:08:22 +00:00
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>
This commit is contained in:
parent
27c31191b3
commit
40d06d3647
2 changed files with 19 additions and 11 deletions
|
@ -714,18 +714,23 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
|
||||||
return 0;
|
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,
|
static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct sk_buff *rgb_skb = NULL;
|
struct sk_buff *rgb_skb = NULL;
|
||||||
int r = 0;
|
int r;
|
||||||
|
|
||||||
pr_debug("hci event %d", event);
|
pr_debug("hci event %d", event);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case PN544_HCI_EVT_ACTIVATED:
|
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);
|
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,
|
r = nfc_hci_get_param(hdev, gate, PN544_DEP_ATR_REQ,
|
||||||
&rgb_skb);
|
&rgb_skb);
|
||||||
if (r < 0)
|
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);
|
rgb_skb->len);
|
||||||
|
|
||||||
kfree_skb(rgb_skb);
|
kfree_skb(rgb_skb);
|
||||||
|
} else {
|
||||||
|
r = -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PN544_HCI_EVT_DEACTIVATED:
|
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);
|
skb_pull(skb, 2);
|
||||||
return nfc_tm_data_received(hdev->ndev, skb);
|
return nfc_tm_data_received(hdev->ndev, skb);
|
||||||
default:
|
default:
|
||||||
pr_err("Discarded unknown event %x to gate %x\n", event, gate);
|
return 1;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
|
@ -297,6 +297,12 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hdev->ops->event_received) {
|
||||||
|
r = hdev->ops->event_received(hdev, gate, event, skb);
|
||||||
|
if (r <= 0)
|
||||||
|
goto exit_noskb;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case NFC_HCI_EVT_TARGET_DISCOVERED:
|
case NFC_HCI_EVT_TARGET_DISCOVERED:
|
||||||
if (skb->len < 1) { /* no status data? */
|
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,
|
||||||
r = nfc_hci_target_discovered(hdev, gate);
|
r = nfc_hci_target_discovered(hdev, gate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (hdev->ops->event_received) {
|
pr_info("Discarded unknown event %x to gate %x\n", event, gate);
|
||||||
r = hdev->ops->event_received(hdev, gate, event, skb);
|
r = -EINVAL;
|
||||||
goto exit_noskb;
|
|
||||||
} else {
|
|
||||||
r = -EINVAL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue