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 /net/nfc | |
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 'net/nfc')
-rw-r--r-- | net/nfc/hci/shdlc.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/net/nfc/hci/shdlc.c b/net/nfc/hci/shdlc.c index 824fb09384ed..ed8796b78f39 100644 --- a/net/nfc/hci/shdlc.c +++ b/net/nfc/hci/shdlc.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/export.h> | 23 | #include <linux/export.h> |
24 | #include <linux/wait.h> | 24 | #include <linux/wait.h> |
25 | #include <linux/crc-ccitt.h> | ||
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
28 | 27 | ||
@@ -30,7 +29,6 @@ | |||
30 | #include <net/nfc/shdlc.h> | 29 | #include <net/nfc/shdlc.h> |
31 | 30 | ||
32 | #define SHDLC_LLC_HEAD_ROOM 2 | 31 | #define SHDLC_LLC_HEAD_ROOM 2 |
33 | #define SHDLC_LLC_TAIL_ROOM 2 | ||
34 | 32 | ||
35 | #define SHDLC_MAX_WINDOW 4 | 33 | #define SHDLC_MAX_WINDOW 4 |
36 | #define SHDLC_SREJ_SUPPORT false | 34 | #define SHDLC_SREJ_SUPPORT false |
@@ -94,28 +92,13 @@ static struct sk_buff *nfc_shdlc_alloc_skb(struct nfc_shdlc *shdlc, | |||
94 | struct sk_buff *skb; | 92 | struct sk_buff *skb; |
95 | 93 | ||
96 | skb = alloc_skb(shdlc->client_headroom + SHDLC_LLC_HEAD_ROOM + | 94 | skb = alloc_skb(shdlc->client_headroom + SHDLC_LLC_HEAD_ROOM + |
97 | shdlc->client_tailroom + SHDLC_LLC_TAIL_ROOM + | 95 | shdlc->client_tailroom + payload_len, GFP_KERNEL); |
98 | payload_len, GFP_KERNEL); | ||
99 | if (skb) | 96 | if (skb) |
100 | skb_reserve(skb, shdlc->client_headroom + SHDLC_LLC_HEAD_ROOM); | 97 | skb_reserve(skb, shdlc->client_headroom + SHDLC_LLC_HEAD_ROOM); |
101 | 98 | ||
102 | return skb; | 99 | return skb; |
103 | } | 100 | } |
104 | 101 | ||
105 | static void nfc_shdlc_add_len_crc(struct sk_buff *skb) | ||
106 | { | ||
107 | u16 crc; | ||
108 | int len; | ||
109 | |||
110 | len = skb->len + 2; | ||
111 | *skb_push(skb, 1) = len; | ||
112 | |||
113 | crc = crc_ccitt(0xffff, skb->data, skb->len); | ||
114 | crc = ~crc; | ||
115 | *skb_put(skb, 1) = crc & 0xff; | ||
116 | *skb_put(skb, 1) = crc >> 8; | ||
117 | } | ||
118 | |||
119 | /* immediately sends an S frame. */ | 102 | /* immediately sends an S frame. */ |
120 | static int nfc_shdlc_send_s_frame(struct nfc_shdlc *shdlc, | 103 | static int nfc_shdlc_send_s_frame(struct nfc_shdlc *shdlc, |
121 | enum sframe_type sframe_type, int nr) | 104 | enum sframe_type sframe_type, int nr) |
@@ -131,8 +114,6 @@ static int nfc_shdlc_send_s_frame(struct nfc_shdlc *shdlc, | |||
131 | 114 | ||
132 | *skb_push(skb, 1) = SHDLC_CONTROL_HEAD_S | (sframe_type << 3) | nr; | 115 | *skb_push(skb, 1) = SHDLC_CONTROL_HEAD_S | (sframe_type << 3) | nr; |
133 | 116 | ||
134 | nfc_shdlc_add_len_crc(skb); | ||
135 | |||
136 | r = shdlc->ops->xmit(shdlc, skb); | 117 | r = shdlc->ops->xmit(shdlc, skb); |
137 | 118 | ||
138 | kfree_skb(skb); | 119 | kfree_skb(skb); |
@@ -151,8 +132,6 @@ static int nfc_shdlc_send_u_frame(struct nfc_shdlc *shdlc, | |||
151 | 132 | ||
152 | *skb_push(skb, 1) = SHDLC_CONTROL_HEAD_U | uframe_modifier; | 133 | *skb_push(skb, 1) = SHDLC_CONTROL_HEAD_U | uframe_modifier; |
153 | 134 | ||
154 | nfc_shdlc_add_len_crc(skb); | ||
155 | |||
156 | r = shdlc->ops->xmit(shdlc, skb); | 135 | r = shdlc->ops->xmit(shdlc, skb); |
157 | 136 | ||
158 | kfree_skb(skb); | 137 | kfree_skb(skb); |
@@ -509,8 +488,6 @@ static void nfc_shdlc_handle_send_queue(struct nfc_shdlc *shdlc) | |||
509 | shdlc->nr); | 488 | shdlc->nr); |
510 | /* SHDLC_DUMP_SKB("shdlc frame written", skb); */ | 489 | /* SHDLC_DUMP_SKB("shdlc frame written", skb); */ |
511 | 490 | ||
512 | nfc_shdlc_add_len_crc(skb); | ||
513 | |||
514 | r = shdlc->ops->xmit(shdlc, skb); | 491 | r = shdlc->ops->xmit(shdlc, skb); |
515 | if (r < 0) { | 492 | if (r < 0) { |
516 | shdlc->hard_fault = r; | 493 | shdlc->hard_fault = r; |
@@ -880,7 +857,7 @@ struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops, | |||
880 | 857 | ||
881 | shdlc->hdev = nfc_hci_allocate_device(&shdlc_ops, init_data, protocols, | 858 | shdlc->hdev = nfc_hci_allocate_device(&shdlc_ops, init_data, protocols, |
882 | tx_headroom + SHDLC_LLC_HEAD_ROOM, | 859 | tx_headroom + SHDLC_LLC_HEAD_ROOM, |
883 | tx_tailroom + SHDLC_LLC_TAIL_ROOM, | 860 | tx_tailroom, |
884 | max_link_payload); | 861 | max_link_payload); |
885 | if (shdlc->hdev == NULL) | 862 | if (shdlc->hdev == NULL) |
886 | goto err_allocdev; | 863 | goto err_allocdev; |