aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn533.c
diff options
context:
space:
mode:
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>2012-12-10 08:42:56 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-01-09 18:51:43 -0500
commit5b5a4437ae078cbe35020e74eb0b66ebedc2a2c0 (patch)
treee32ba699b50d7e34f284f7c38fa3ebede221ba86 /drivers/nfc/pn533.c
parentfcfafc7690164d08dfd8133a860f25db8019ca2e (diff)
NFC: pn533: Don't use out_frame in pn533_send_ack
dev->out_frame buffer is much bigger for ACK frame needs. Use local buffer instead. Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn533.c')
-rw-r--r--drivers/nfc/pn533.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 5fb5b8f1ef3f..5bc0c7cfea9a 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -94,7 +94,8 @@ MODULE_DEVICE_TABLE(usb, pn533_table);
94 94
95#define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \ 95#define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \
96 PN533_FRAME_TAIL_LEN) 96 PN533_FRAME_TAIL_LEN)
97#define PN533_FRAME_ACK_SIZE (sizeof(struct pn533_frame) + 1) 97#define PN533_FRAME_ACK_SIZE 6 /* Preamble (1), SoPC (2), ACK Code (2),
98 Postamble (1) */
98#define PN533_FRAME_CHECKSUM(f) (f->data[f->datalen]) 99#define PN533_FRAME_CHECKSUM(f) (f->data[f->datalen])
99#define PN533_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1]) 100#define PN533_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1])
100 101
@@ -402,26 +403,6 @@ static u8 pn533_data_checksum(u8 *data, int datalen)
402 return pn533_checksum(sum); 403 return pn533_checksum(sum);
403} 404}
404 405
405/**
406 * pn533_tx_frame_ack - create a ack frame
407 * @frame: The frame to be set as ack
408 *
409 * Ack is different type of standard frame. As a standard frame, it has
410 * preamble and start_frame. However the checksum of this frame must fail,
411 * i.e. datalen + datalen_checksum must NOT be zero. When the checksum test
412 * fails and datalen = 0 and datalen_checksum = 0xFF, the frame is a ack.
413 * After datalen_checksum field, the postamble is placed.
414 */
415static void pn533_tx_frame_ack(struct pn533_frame *frame)
416{
417 frame->preamble = 0;
418 frame->start_frame = cpu_to_be16(PN533_SOF);
419 frame->datalen = 0;
420 frame->datalen_checksum = 0xFF;
421 /* data[0] is used as postamble */
422 frame->data[0] = 0;
423}
424
425static void pn533_tx_frame_init(struct pn533_frame *frame, u8 cmd) 406static void pn533_tx_frame_init(struct pn533_frame *frame, u8 cmd)
426{ 407{
427 frame->preamble = 0; 408 frame->preamble = 0;
@@ -612,14 +593,14 @@ static int pn533_submit_urb_for_ack(struct pn533 *dev, gfp_t flags)
612 593
613static int pn533_send_ack(struct pn533 *dev, gfp_t flags) 594static int pn533_send_ack(struct pn533 *dev, gfp_t flags)
614{ 595{
596 u8 ack[PN533_FRAME_ACK_SIZE] = {0x00, 0x00, 0xff, 0x00, 0xff, 0x00};
597 /* spec 7.1.1.3: Preamble, SoPC (2), ACK Code (2), Postamble */
615 int rc; 598 int rc;
616 599
617 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 600 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
618 601
619 pn533_tx_frame_ack(dev->out_frame); 602 dev->out_urb->transfer_buffer = ack;
620 603 dev->out_urb->transfer_buffer_length = sizeof(ack);
621 dev->out_urb->transfer_buffer = dev->out_frame;
622 dev->out_urb->transfer_buffer_length = PN533_FRAME_ACK_SIZE;
623 rc = usb_submit_urb(dev->out_urb, flags); 604 rc = usb_submit_urb(dev->out_urb, flags);
624 605
625 return rc; 606 return rc;