NFC: pn533: Add a new pn533_send_data_async iface
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Mon, 26 Nov 2012 13:18:35 +0000 (14:18 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 9 Jan 2013 23:44:28 +0000 (00:44 +0100)
This iface is intended to be used with DEP transfers. It differs
from pn533_send_cmd_async() in the way the response skb is allocated.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn533.c

index 89f747479a4f6d98f4b023e13546649483bc49b7..0e9bf9dfbbb543ee3d1099dc8cd43dd73c7498f8 100644 (file)
@@ -86,6 +86,12 @@ MODULE_DEVICE_TABLE(usb, pn533_table);
                                        + 2) /* data[0] TFI, data[1] CC */
 #define PN533_FRAME_TAIL_LEN 2 /* data[len] DCS, data[len + 1] postamble*/
 
+/*
+ * Max extended frame payload len, excluding TFI and CC
+ * which are already in PN533_FRAME_HEADER_LEN.
+ */
+#define PN533_FRAME_MAX_PAYLOAD_LEN 263
+
 #define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \
                                PN533_FRAME_TAIL_LEN)
 #define PN533_FRAME_ACK_SIZE (sizeof(struct pn533_frame) + 1)
@@ -807,6 +813,31 @@ unlock:
        return rc;
 }
 
+static int pn533_send_data_async(struct pn533 *dev, u8 cmd_code,
+                                struct sk_buff *req,
+                                pn533_send_async_complete_t complete_cb,
+                                void *complete_cb_context)
+{
+       struct sk_buff *resp;
+       int rc;
+       int  resp_len = PN533_FRAME_HEADER_LEN +
+                       PN533_FRAME_MAX_PAYLOAD_LEN +
+                       PN533_FRAME_TAIL_LEN;
+
+       nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
+
+       resp = nfc_alloc_recv_skb(resp_len, GFP_KERNEL);
+       if (!resp)
+               return -ENOMEM;
+
+       rc = __pn533_send_async(dev, cmd_code, req, resp, resp_len, complete_cb,
+                               complete_cb_context);
+       if (rc)
+               dev_kfree_skb(resp);
+
+       return rc;
+}
+
 static int pn533_send_cmd_async(struct pn533 *dev, u8 cmd_code,
                                struct sk_buff *req,
                                pn533_send_async_complete_t complete_cb,