diff options
author | Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> | 2012-09-07 05:08:29 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-24 18:17:24 -0400 |
commit | ade672082dd35aaaf7c8630d16c9f795c30459c4 (patch) | |
tree | bd0c438012bbf4006f63b3f13faddf0d5803d357 /drivers/nfc/pn544_hci.c | |
parent | 52da2449e10039d3bb04c598d24cb1a34530b716 (diff) |
NFC: Remove crc generation from shdlc layer
Checksum is specific for a chip spcification and it varies
(in size and type) between different hardware. It should be
handled in the driver then.
Moreover, shdlc spec doesn't mention crc as a part of the frame.
Update pn544_hci driver as well.
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Acked-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn544_hci.c')
-rw-r--r-- | drivers/nfc/pn544_hci.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c index 9458d53cdb59..d90aecfce739 100644 --- a/drivers/nfc/pn544_hci.c +++ b/drivers/nfc/pn544_hci.c | |||
@@ -128,6 +128,8 @@ static struct nfc_hci_gate pn544_gates[] = { | |||
128 | 128 | ||
129 | /* Largest headroom needed for outgoing custom commands */ | 129 | /* Largest headroom needed for outgoing custom commands */ |
130 | #define PN544_CMDS_HEADROOM 2 | 130 | #define PN544_CMDS_HEADROOM 2 |
131 | #define PN544_FRAME_HEADROOM 1 | ||
132 | #define PN544_FRAME_TAILROOM 2 | ||
131 | 133 | ||
132 | struct pn544_hci_info { | 134 | struct pn544_hci_info { |
133 | struct i2c_client *i2c_dev; | 135 | struct i2c_client *i2c_dev; |
@@ -576,15 +578,40 @@ static int pn544_hci_ready(struct nfc_shdlc *shdlc) | |||
576 | return 0; | 578 | return 0; |
577 | } | 579 | } |
578 | 580 | ||
581 | static void pn544_hci_add_len_crc(struct sk_buff *skb) | ||
582 | { | ||
583 | u16 crc; | ||
584 | int len; | ||
585 | |||
586 | len = skb->len + 2; | ||
587 | *skb_push(skb, 1) = len; | ||
588 | |||
589 | crc = crc_ccitt(0xffff, skb->data, skb->len); | ||
590 | crc = ~crc; | ||
591 | *skb_put(skb, 1) = crc & 0xff; | ||
592 | *skb_put(skb, 1) = crc >> 8; | ||
593 | } | ||
594 | |||
595 | static void pn544_hci_remove_len_crc(struct sk_buff *skb) | ||
596 | { | ||
597 | skb_pull(skb, PN544_FRAME_HEADROOM); | ||
598 | skb_trim(skb, PN544_FRAME_TAILROOM); | ||
599 | } | ||
600 | |||
579 | static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb) | 601 | static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb) |
580 | { | 602 | { |
581 | struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); | 603 | struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); |
582 | struct i2c_client *client = info->i2c_dev; | 604 | struct i2c_client *client = info->i2c_dev; |
605 | int r; | ||
583 | 606 | ||
584 | if (info->hard_fault != 0) | 607 | if (info->hard_fault != 0) |
585 | return info->hard_fault; | 608 | return info->hard_fault; |
586 | 609 | ||
587 | return pn544_hci_i2c_write(client, skb->data, skb->len); | 610 | pn544_hci_add_len_crc(skb); |
611 | r = pn544_hci_i2c_write(client, skb->data, skb->len); | ||
612 | pn544_hci_remove_len_crc(skb); | ||
613 | |||
614 | return r; | ||
588 | } | 615 | } |
589 | 616 | ||
590 | static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, | 617 | static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, |
@@ -874,7 +901,8 @@ static int __devinit pn544_hci_probe(struct i2c_client *client, | |||
874 | 901 | ||
875 | info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops, | 902 | info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops, |
876 | &init_data, protocols, | 903 | &init_data, protocols, |
877 | PN544_CMDS_HEADROOM, 0, | 904 | PN544_FRAME_HEADROOM + PN544_CMDS_HEADROOM, |
905 | PN544_FRAME_TAILROOM, | ||
878 | PN544_HCI_LLC_MAX_PAYLOAD, | 906 | PN544_HCI_LLC_MAX_PAYLOAD, |
879 | dev_name(&client->dev)); | 907 | dev_name(&client->dev)); |
880 | if (!info->shdlc) { | 908 | if (!info->shdlc) { |