Skip to content

Commit e1bf80c

Browse files
Vincent CuissardSamuel Ortiz
authored andcommitted
NFC: nfcmrvl: update nci recv frame API
Update internal nci recv frame API to use skbuff phy management to generic part of the driver. Signed-off-by: Vincent Cuissard <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent f1f1a7d commit e1bf80c

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

drivers/nfc/nfcmrvl/main.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,8 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)
153153
}
154154
EXPORT_SYMBOL_GPL(nfcmrvl_nci_unregister_dev);
155155

156-
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, void *data, int count)
156+
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb)
157157
{
158-
struct sk_buff *skb;
159-
160-
skb = nci_skb_alloc(priv->ndev, count, GFP_ATOMIC);
161-
if (!skb)
162-
return -ENOMEM;
163-
164-
memcpy(skb_put(skb, count), data, count);
165-
166158
if (priv->hci_muxed) {
167159
if (skb->data[0] == NFCMRVL_HCI_EVENT_CODE &&
168160
skb->data[1] == NFCMRVL_HCI_NFC_EVENT_CODE) {
@@ -175,9 +167,15 @@ int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, void *data, int count)
175167
}
176168
}
177169

178-
nci_recv_frame(priv->ndev, skb);
170+
if (test_bit(NFCMRVL_NCI_RUNNING, &priv->flags))
171+
nci_recv_frame(priv->ndev, skb);
172+
else {
173+
/* Drop this packet since nobody wants it */
174+
kfree_skb(skb);
175+
return 0;
176+
}
179177

180-
return count;
178+
return 0;
181179
}
182180
EXPORT_SYMBOL_GPL(nfcmrvl_nci_recv_frame);
183181

drivers/nfc/nfcmrvl/nfcmrvl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct nfcmrvl_if_ops {
5858
};
5959

6060
void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv);
61-
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, void *data, int count);
61+
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
6262
struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
6363
struct nfcmrvl_if_ops *ops,
6464
struct device *dev,

drivers/nfc/nfcmrvl/usb.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,27 @@ static int nfcmrvl_inc_tx(struct nfcmrvl_usb_drv_data *drv_data)
6969
static void nfcmrvl_bulk_complete(struct urb *urb)
7070
{
7171
struct nfcmrvl_usb_drv_data *drv_data = urb->context;
72+
struct sk_buff *skb;
7273
int err;
7374

74-
dev_dbg(&drv_data->udev->dev, "urb %p status %d count %d",
75+
dev_dbg(&drv_data->udev->dev, "urb %p status %d count %d\n",
7576
urb, urb->status, urb->actual_length);
7677

7778
if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags))
7879
return;
7980

8081
if (!urb->status) {
81-
if (nfcmrvl_nci_recv_frame(drv_data->priv, urb->transfer_buffer,
82-
urb->actual_length) < 0)
83-
nfc_err(&drv_data->udev->dev, "corrupted Rx packet\n");
82+
skb = nci_skb_alloc(drv_data->priv->ndev, urb->actual_length,
83+
GFP_ATOMIC);
84+
if (!skb) {
85+
nfc_err(&drv_data->udev->dev, "failed to alloc mem\n");
86+
} else {
87+
memcpy(skb_put(skb, urb->actual_length),
88+
urb->transfer_buffer, urb->actual_length);
89+
if (nfcmrvl_nci_recv_frame(drv_data->priv, skb) < 0)
90+
nfc_err(&drv_data->udev->dev,
91+
"corrupted Rx packet\n");
92+
}
8493
}
8594

8695
if (!test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags))

0 commit comments

Comments
 (0)