#define PN533_NORMAL_FRAME_MAX_LEN 262 /* 6 (PREAMBLE, SOF, LEN, LCS, TFI)
254 (DATA)
2 (DCS, postamble) */
+#define PN533_FRAME_HEADER_LEN (sizeof(struct pn533_frame) \
+ + 2) /* data[0] TFI, data[1] CC */
+#define PN533_FRAME_TAIL_LEN 2 /* data[len] DCS, data[len + 1] postamble*/
-#define PN533_FRAME_TAIL_SIZE 2
#define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \
- PN533_FRAME_TAIL_SIZE)
+ PN533_FRAME_TAIL_LEN)
#define PN533_FRAME_ACK_SIZE (sizeof(struct pn533_frame) + 1)
#define PN533_FRAME_CHECKSUM(f) (f->data[f->datalen])
#define PN533_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1])
return 0;
}
-#define PN533_CMD_DATAEXCH_HEAD_LEN (sizeof(struct pn533_frame) + 3)
+#define PN533_CMD_DATAEXCH_HEAD_LEN 1
#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262
static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg,
u8 *params, int params_len)
}
skb_put(skb_resp, PN533_FRAME_SIZE(in_frame));
- skb_pull(skb_resp, PN533_CMD_DATAEXCH_HEAD_LEN);
- skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_SIZE);
+ skb_pull(skb_resp,
+ PN533_FRAME_HEADER_LEN + PN533_CMD_DATAEXCH_HEAD_LEN);
+ skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_LEN);
return nfc_tm_data_received(dev->nfc_dev, skb_resp);
}
nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
- skb_resp_len = PN533_CMD_DATAEXCH_HEAD_LEN +
- PN533_CMD_DATAEXCH_DATA_MAXLEN +
- PN533_FRAME_TAIL_SIZE;
+ skb_resp_len = PN533_FRAME_HEADER_LEN +
+ PN533_CMD_DATAEXCH_HEAD_LEN +
+ PN533_CMD_DATAEXCH_DATA_MAXLEN +
+ PN533_FRAME_TAIL_LEN;
skb_resp = nfc_alloc_recv_skb(skb_resp_len, GFP_KERNEL);
if (!skb_resp)
return -ENOSYS;
}
+ skb_push(skb, PN533_FRAME_HEADER_LEN);
+
if (target == true) {
switch (dev->device_type) {
case PN533_DEVICE_PASORI:
if (dev->tgt_active_prot == NFC_PROTO_FELICA) {
- skb_push(skb, PN533_CMD_DATAEXCH_HEAD_LEN - 1);
out_frame = (struct pn533_frame *) skb->data;
pn533_tx_frame_init(out_frame,
PN533_CMD_IN_COMM_THRU);
out_frame->datalen += payload_len;
pn533_tx_frame_finish(out_frame);
- skb_put(skb, PN533_FRAME_TAIL_SIZE);
+ skb_put(skb, PN533_FRAME_TAIL_LEN);
return 0;
}
}
skb_put(skb_resp, PN533_FRAME_SIZE(in_frame));
+ skb_pull(skb_resp, PN533_FRAME_HEADER_LEN);
skb_pull(skb_resp, PN533_CMD_DATAEXCH_HEAD_LEN);
- skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_SIZE);
+ skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_LEN);
skb_queue_tail(&dev->resp_q, skb_resp);
if (status & PN533_CMD_MI_MASK) {
if (rc)
goto error;
- skb_resp_len = PN533_CMD_DATAEXCH_HEAD_LEN +
- PN533_CMD_DATAEXCH_DATA_MAXLEN +
- PN533_FRAME_TAIL_SIZE;
+ skb_resp_len = PN533_FRAME_HEADER_LEN +
+ PN533_CMD_DATAEXCH_HEAD_LEN +
+ PN533_CMD_DATAEXCH_DATA_MAXLEN +
+ PN533_FRAME_TAIL_LEN;
skb_resp = nfc_alloc_recv_skb(skb_resp_len, GFP_KERNEL);
if (!skb_resp) {
nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
/* This is a zero payload size skb */
- skb_cmd = alloc_skb(PN533_CMD_DATAEXCH_HEAD_LEN + PN533_FRAME_TAIL_SIZE,
+ skb_cmd = alloc_skb(PN533_FRAME_HEADER_LEN +
+ PN533_CMD_DATAEXCH_HEAD_LEN +
+ PN533_FRAME_TAIL_LEN,
GFP_KERNEL);
if (skb_cmd == NULL)
goto error_cmd;
- skb_reserve(skb_cmd, PN533_CMD_DATAEXCH_HEAD_LEN);
+ skb_reserve(skb_cmd,
+ PN533_FRAME_HEADER_LEN + PN533_CMD_DATAEXCH_HEAD_LEN);
rc = pn533_build_tx_frame(dev, skb_cmd, true);
if (rc)
goto error_frame;
- skb_resp_len = PN533_CMD_DATAEXCH_HEAD_LEN +
- PN533_CMD_DATAEXCH_DATA_MAXLEN +
- PN533_FRAME_TAIL_SIZE;
+ skb_resp_len = PN533_FRAME_HEADER_LEN +
+ PN533_CMD_DATAEXCH_HEAD_LEN +
+ PN533_CMD_DATAEXCH_DATA_MAXLEN +
+ PN533_FRAME_TAIL_LEN;
+
skb_resp = alloc_skb(skb_resp_len, GFP_KERNEL);
if (!skb_resp) {
rc = -ENOMEM;
}
dev->nfc_dev = nfc_allocate_device(&pn533_nfc_ops, protocols,
+ PN533_FRAME_HEADER_LEN +
PN533_CMD_DATAEXCH_HEAD_LEN,
- PN533_FRAME_TAIL_SIZE);
+ PN533_FRAME_TAIL_LEN);
if (!dev->nfc_dev)
goto destroy_wq;