summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorOlivier Guiter <olivier.guiter@linux.intel.com>2013-06-13 13:43:29 +0000
committerSamuel Ortiz <sameo@linux.intel.com>2013-08-14 00:35:18 +0200
commit56a63c82cf82eb491af05759d9e9f9b97ca36bc2 (patch)
treea0bf4e03a0fe2fd8cfea02434ce397af3912fd8e /drivers/nfc
parent963a82e07d4e1f95fc423d53912ac0a7fe643b1c (diff)
downloadop-kernel-dev-56a63c82cf82eb491af05759d9e9f9b97ca36bc2.zip
op-kernel-dev-56a63c82cf82eb491af05759d9e9f9b97ca36bc2.tar.gz
NFC: pn533: Store the correct frame size (normal vs ext)
The extended information frame are sent by PN533 to exchange frames larger than 255 bytes. These extended frame are very close from the standard ones except for the header size length. On each incoming frame, we set the correct header length, and we do that only for the standard pn533 chipsets as the acr122 does not seem to support extended frames properly. Signed-off-by: Olivier Guiter <olivier.guiter@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index f06ef7c..2f1ebbd 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -435,7 +435,7 @@ struct pn533_frame_ops {
int tx_header_len;
int tx_tail_len;
- bool (*rx_is_frame_valid)(void *frame);
+ bool (*rx_is_frame_valid)(void *frame, struct pn533 *dev);
int (*rx_frame_size)(void *frame);
int rx_header_len;
int rx_tail_len;
@@ -510,7 +510,7 @@ static void pn533_acr122_tx_update_payload_len(void *_frame, int len)
frame->datalen += len;
}
-static bool pn533_acr122_is_rx_frame_valid(void *_frame)
+static bool pn533_acr122_is_rx_frame_valid(void *_frame, struct pn533 *dev)
{
struct pn533_acr122_rx_frame *frame = _frame;
@@ -608,7 +608,7 @@ static void pn533_std_tx_update_payload_len(void *_frame, int len)
frame->datalen += len;
}
-static bool pn533_std_rx_frame_is_valid(void *_frame)
+static bool pn533_std_rx_frame_is_valid(void *_frame, struct pn533 *dev)
{
u8 checksum;
struct pn533_std_frame *stdf = _frame;
@@ -618,6 +618,7 @@ static bool pn533_std_rx_frame_is_valid(void *_frame)
if (likely(!PN533_STD_IS_EXTENDED(stdf))) {
/* Standard frame code */
+ dev->ops->rx_header_len = PN533_STD_FRAME_HEADER_LEN;
checksum = pn533_std_checksum(stdf->datalen);
if (checksum != stdf->datalen_checksum)
@@ -630,6 +631,8 @@ static bool pn533_std_rx_frame_is_valid(void *_frame)
/* Extended */
struct pn533_ext_frame *eif = _frame;
+ dev->ops->rx_header_len = PN533_EXT_FRAME_HEADER_LEN;
+
checksum = pn533_ext_checksum(be16_to_cpu(eif->datalen));
if (checksum != eif->datalen_checksum)
return false;
@@ -734,7 +737,7 @@ static void pn533_recv_response(struct urb *urb)
print_hex_dump_debug("PN533 RX: ", DUMP_PREFIX_NONE, 16, 1, in_frame,
dev->ops->rx_frame_size(in_frame), false);
- if (!dev->ops->rx_is_frame_valid(in_frame)) {
+ if (!dev->ops->rx_is_frame_valid(in_frame, dev)) {
nfc_dev_err(&dev->interface->dev, "Received an invalid frame");
cmd->status = -EIO;
goto sched_wq;
@@ -747,11 +750,6 @@ static void pn533_recv_response(struct urb *urb)
goto sched_wq;
}
- if (PN533_STD_IS_EXTENDED((struct pn533_std_frame *)in_frame))
- dev->ops->rx_header_len = PN533_EXT_FRAME_HEADER_LEN;
- else
- dev->ops->rx_header_len = PN533_STD_FRAME_HEADER_LEN;
-
sched_wq:
queue_work(dev->wq, &dev->cmd_complete_work);
}
OpenPOWER on IntegriCloud