Commit 27c31191 authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

NFC: Added error handling in event_received hci ops

There is no use to return an error if the caller doesn't get it.
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent f0c91038
...@@ -714,8 +714,8 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev, ...@@ -714,8 +714,8 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
return 0; return 0;
} }
static void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
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 = 0;
...@@ -724,25 +724,23 @@ static void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, ...@@ -724,25 +724,23 @@ static void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
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)
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)
goto exit; goto exit;
nfc_tm_activated(hdev->ndev, NFC_PROTO_NFC_DEP_MASK, r = nfc_tm_activated(hdev->ndev, NFC_PROTO_NFC_DEP_MASK,
NFC_COMM_PASSIVE, rgb_skb->data, NFC_COMM_PASSIVE, rgb_skb->data,
rgb_skb->len); rgb_skb->len);
kfree_skb(rgb_skb); kfree_skb(rgb_skb);
} }
break; break;
case PN544_HCI_EVT_DEACTIVATED: case PN544_HCI_EVT_DEACTIVATED:
nfc_hci_send_event(hdev, gate, r = nfc_hci_send_event(hdev, gate, NFC_HCI_EVT_END_OPERATION,
NFC_HCI_EVT_END_OPERATION, NULL, 0); NULL, 0);
break; break;
case PN544_HCI_EVT_RCV_DATA: case PN544_HCI_EVT_RCV_DATA:
if (skb->len < 2) { if (skb->len < 2) {
...@@ -757,15 +755,16 @@ static void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, ...@@ -757,15 +755,16 @@ static void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
} }
skb_pull(skb, 2); skb_pull(skb, 2);
nfc_tm_data_received(hdev->ndev, skb); return nfc_tm_data_received(hdev->ndev, skb);
return;
default: default:
pr_err("Discarded unknown event %x to gate %x\n", event, gate);
break; break;
} }
exit: exit:
kfree_skb(skb); kfree_skb(skb);
return r;
} }
static struct nfc_hci_ops pn544_hci_ops = { static struct nfc_hci_ops pn544_hci_ops = {
......
...@@ -57,8 +57,8 @@ struct nfc_hci_ops { ...@@ -57,8 +57,8 @@ struct nfc_hci_ops {
int (*tm_send)(struct nfc_hci_dev *hdev, struct sk_buff *skb); int (*tm_send)(struct nfc_hci_dev *hdev, struct sk_buff *skb);
int (*check_presence)(struct nfc_hci_dev *hdev, int (*check_presence)(struct nfc_hci_dev *hdev,
struct nfc_target *target); struct nfc_target *target);
void (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event,
struct sk_buff *skb); struct sk_buff *skb);
}; };
/* Pipes */ /* Pipes */
......
...@@ -323,16 +323,18 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, ...@@ -323,16 +323,18 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event,
break; break;
default: default:
if (hdev->ops->event_received) { if (hdev->ops->event_received) {
hdev->ops->event_received(hdev, gate, event, skb); r = hdev->ops->event_received(hdev, gate, event, skb);
return; goto exit_noskb;
} else {
r = -EINVAL;
} }
break; break;
} }
exit: exit:
kfree_skb(skb); kfree_skb(skb);
exit_noskb:
if (r) { if (r) {
/* TODO: There was an error dispatching the event, /* TODO: There was an error dispatching the event,
* how to propagate up to nfc core? * how to propagate up to nfc core?
......
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