diff options
Diffstat (limited to 'net/nfc/nci/data.c')
-rw-r--r-- | net/nfc/nci/data.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index e5ed90fc1a9c..e5756b30e602 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ | ||
25 | |||
24 | #include <linux/types.h> | 26 | #include <linux/types.h> |
25 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
26 | #include <linux/wait.h> | 28 | #include <linux/wait.h> |
@@ -40,7 +42,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, | |||
40 | data_exchange_cb_t cb = ndev->data_exchange_cb; | 42 | data_exchange_cb_t cb = ndev->data_exchange_cb; |
41 | void *cb_context = ndev->data_exchange_cb_context; | 43 | void *cb_context = ndev->data_exchange_cb_context; |
42 | 44 | ||
43 | nfc_dbg("entry, len %d, err %d", ((skb) ? (skb->len) : (0)), err); | 45 | pr_debug("len %d, err %d\n", skb ? skb->len : 0, err); |
44 | 46 | ||
45 | if (cb) { | 47 | if (cb) { |
46 | ndev->data_exchange_cb = NULL; | 48 | ndev->data_exchange_cb = NULL; |
@@ -49,7 +51,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, | |||
49 | /* forward skb to nfc core */ | 51 | /* forward skb to nfc core */ |
50 | cb(cb_context, skb, err); | 52 | cb(cb_context, skb, err); |
51 | } else if (skb) { | 53 | } else if (skb) { |
52 | nfc_err("no rx callback, dropping rx data..."); | 54 | pr_err("no rx callback, dropping rx data...\n"); |
53 | 55 | ||
54 | /* no waiting callback, free skb */ | 56 | /* no waiting callback, free skb */ |
55 | kfree_skb(skb); | 57 | kfree_skb(skb); |
@@ -90,12 +92,13 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev, | |||
90 | int frag_len; | 92 | int frag_len; |
91 | int rc = 0; | 93 | int rc = 0; |
92 | 94 | ||
93 | nfc_dbg("entry, conn_id 0x%x, total_len %d", conn_id, total_len); | 95 | pr_debug("conn_id 0x%x, total_len %d\n", conn_id, total_len); |
94 | 96 | ||
95 | __skb_queue_head_init(&frags_q); | 97 | __skb_queue_head_init(&frags_q); |
96 | 98 | ||
97 | while (total_len) { | 99 | while (total_len) { |
98 | frag_len = min_t(int, total_len, ndev->max_pkt_payload_size); | 100 | frag_len = |
101 | min_t(int, total_len, ndev->max_data_pkt_payload_size); | ||
99 | 102 | ||
100 | skb_frag = nci_skb_alloc(ndev, | 103 | skb_frag = nci_skb_alloc(ndev, |
101 | (NCI_DATA_HDR_SIZE + frag_len), | 104 | (NCI_DATA_HDR_SIZE + frag_len), |
@@ -118,8 +121,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev, | |||
118 | data += frag_len; | 121 | data += frag_len; |
119 | total_len -= frag_len; | 122 | total_len -= frag_len; |
120 | 123 | ||
121 | nfc_dbg("frag_len %d, remaining total_len %d", | 124 | pr_debug("frag_len %d, remaining total_len %d\n", |
122 | frag_len, total_len); | 125 | frag_len, total_len); |
123 | } | 126 | } |
124 | 127 | ||
125 | /* queue all fragments atomically */ | 128 | /* queue all fragments atomically */ |
@@ -148,10 +151,10 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb) | |||
148 | { | 151 | { |
149 | int rc = 0; | 152 | int rc = 0; |
150 | 153 | ||
151 | nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len); | 154 | pr_debug("conn_id 0x%x, plen %d\n", conn_id, skb->len); |
152 | 155 | ||
153 | /* check if the packet need to be fragmented */ | 156 | /* check if the packet need to be fragmented */ |
154 | if (skb->len <= ndev->max_pkt_payload_size) { | 157 | if (skb->len <= ndev->max_data_pkt_payload_size) { |
155 | /* no need to fragment packet */ | 158 | /* no need to fragment packet */ |
156 | nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); | 159 | nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); |
157 | 160 | ||
@@ -160,7 +163,7 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb) | |||
160 | /* fragment packet and queue the fragments */ | 163 | /* fragment packet and queue the fragments */ |
161 | rc = nci_queue_tx_data_frags(ndev, conn_id, skb); | 164 | rc = nci_queue_tx_data_frags(ndev, conn_id, skb); |
162 | if (rc) { | 165 | if (rc) { |
163 | nfc_err("failed to fragment tx data packet"); | 166 | pr_err("failed to fragment tx data packet\n"); |
164 | goto free_exit; | 167 | goto free_exit; |
165 | } | 168 | } |
166 | } | 169 | } |
@@ -190,7 +193,7 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, | |||
190 | 193 | ||
191 | /* first, make enough room for the already accumulated data */ | 194 | /* first, make enough room for the already accumulated data */ |
192 | if (skb_cow_head(skb, reassembly_len)) { | 195 | if (skb_cow_head(skb, reassembly_len)) { |
193 | nfc_err("error adding room for accumulated rx data"); | 196 | pr_err("error adding room for accumulated rx data\n"); |
194 | 197 | ||
195 | kfree_skb(skb); | 198 | kfree_skb(skb); |
196 | skb = 0; | 199 | skb = 0; |
@@ -227,19 +230,19 @@ void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb) | |||
227 | { | 230 | { |
228 | __u8 pbf = nci_pbf(skb->data); | 231 | __u8 pbf = nci_pbf(skb->data); |
229 | 232 | ||
230 | nfc_dbg("entry, len %d", skb->len); | 233 | pr_debug("len %d\n", skb->len); |
231 | 234 | ||
232 | nfc_dbg("NCI RX: MT=data, PBF=%d, conn_id=%d, plen=%d", | 235 | pr_debug("NCI RX: MT=data, PBF=%d, conn_id=%d, plen=%d\n", |
233 | nci_pbf(skb->data), | 236 | nci_pbf(skb->data), |
234 | nci_conn_id(skb->data), | 237 | nci_conn_id(skb->data), |
235 | nci_plen(skb->data)); | 238 | nci_plen(skb->data)); |
236 | 239 | ||
237 | /* strip the nci data header */ | 240 | /* strip the nci data header */ |
238 | skb_pull(skb, NCI_DATA_HDR_SIZE); | 241 | skb_pull(skb, NCI_DATA_HDR_SIZE); |
239 | 242 | ||
240 | if (ndev->target_active_prot == NFC_PROTO_MIFARE) { | 243 | if (ndev->target_active_prot == NFC_PROTO_MIFARE) { |
241 | /* frame I/F => remove the status byte */ | 244 | /* frame I/F => remove the status byte */ |
242 | nfc_dbg("NFC_PROTO_MIFARE => remove the status byte"); | 245 | pr_debug("NFC_PROTO_MIFARE => remove the status byte\n"); |
243 | skb_trim(skb, (skb->len - 1)); | 246 | skb_trim(skb, (skb->len - 1)); |
244 | } | 247 | } |
245 | 248 | ||