aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>2012-12-10 08:42:44 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-01-09 18:51:34 -0500
commite487882345a80a17b534182ab1f259f2321e4fed (patch)
tree93cc5109ce024dfeca3fe708ac9bc05b22bd4b51 /drivers/nfc
parent1727cf937401945a590ebf25c7fa65a4853fe9bb (diff)
NFC: pn533: Del frame logic from TgGet/SetData cmd
Remove frame logic from TgSetData and TgGetData commands using the new iface for async send. Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c97
1 files changed, 33 insertions, 64 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index e5615f538aaa..9912824030f6 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -1450,65 +1450,46 @@ static int pn533_init_target_frame(struct pn533_frame *frame,
1450#define PN533_CMD_DATAEXCH_HEAD_LEN 1 1450#define PN533_CMD_DATAEXCH_HEAD_LEN 1
1451#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262 1451#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262
1452static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg, 1452static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg,
1453 u8 *params, int params_len) 1453 struct sk_buff *resp)
1454{ 1454{
1455 struct sk_buff *skb_resp = arg; 1455 u8 status;
1456 struct pn533_frame *in_frame = (struct pn533_frame *) skb_resp->data;
1457 1456
1458 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 1457 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
1459 1458
1460 if (params_len < 0) { 1459 if (IS_ERR(resp))
1461 nfc_dev_err(&dev->interface->dev, 1460 return PTR_ERR(resp);
1462 "Error %d when starting as a target",
1463 params_len);
1464 1461
1465 return params_len; 1462 status = resp->data[0];
1466 } 1463 skb_pull(resp, sizeof(status));
1467 1464
1468 if (params_len > 0 && params[0] != 0) { 1465 if (status != 0) {
1469 nfc_tm_deactivated(dev->nfc_dev); 1466 nfc_tm_deactivated(dev->nfc_dev);
1470
1471 dev->tgt_mode = 0; 1467 dev->tgt_mode = 0;
1472 1468 dev_kfree_skb(resp);
1473 kfree_skb(skb_resp);
1474 return 0; 1469 return 0;
1475 } 1470 }
1476 1471
1477 skb_put(skb_resp, PN533_FRAME_SIZE(in_frame)); 1472 return nfc_tm_data_received(dev->nfc_dev, resp);
1478 skb_pull(skb_resp,
1479 PN533_FRAME_HEADER_LEN + PN533_CMD_DATAEXCH_HEAD_LEN);
1480 skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_LEN);
1481
1482 return nfc_tm_data_received(dev->nfc_dev, skb_resp);
1483} 1473}
1484 1474
1485static void pn533_wq_tg_get_data(struct work_struct *work) 1475static void pn533_wq_tg_get_data(struct work_struct *work)
1486{ 1476{
1487 struct pn533 *dev = container_of(work, struct pn533, tg_work); 1477 struct pn533 *dev = container_of(work, struct pn533, tg_work);
1488 struct pn533_frame *in_frame;
1489 struct sk_buff *skb_resp;
1490 size_t skb_resp_len;
1491 1478
1492 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 1479 struct sk_buff *skb;
1480 int rc;
1493 1481
1494 skb_resp_len = PN533_FRAME_HEADER_LEN + 1482 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
1495 PN533_CMD_DATAEXCH_HEAD_LEN +
1496 PN533_CMD_DATAEXCH_DATA_MAXLEN +
1497 PN533_FRAME_TAIL_LEN;
1498 1483
1499 skb_resp = nfc_alloc_recv_skb(skb_resp_len, GFP_KERNEL); 1484 skb = pn533_alloc_skb(0);
1500 if (!skb_resp) 1485 if (!skb)
1501 return; 1486 return;
1502 1487
1503 in_frame = (struct pn533_frame *)skb_resp->data; 1488 rc = pn533_send_data_async(dev, PN533_CMD_TG_GET_DATA, skb,
1504 1489 pn533_tm_get_data_complete, NULL);
1505 pn533_tx_frame_init(dev->out_frame, PN533_CMD_TG_GET_DATA);
1506 pn533_tx_frame_finish(dev->out_frame);
1507 1490
1508 pn533_send_cmd_frame_async(dev, dev->out_frame, in_frame, 1491 if (rc < 0)
1509 skb_resp_len, 1492 dev_kfree_skb(skb);
1510 pn533_tm_get_data_complete,
1511 skb_resp);
1512 1493
1513 return; 1494 return;
1514} 1495}
@@ -2280,23 +2261,20 @@ error:
2280} 2261}
2281 2262
2282static int pn533_tm_send_complete(struct pn533 *dev, void *arg, 2263static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
2283 u8 *params, int params_len) 2264 struct sk_buff *resp)
2284{ 2265{
2285 struct sk_buff *skb_out = arg; 2266 u8 status;
2286 2267
2287 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 2268 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
2288 2269
2289 dev_kfree_skb(skb_out); 2270 if (IS_ERR(resp))
2271 return PTR_ERR(resp);
2290 2272
2291 if (params_len < 0) { 2273 status = resp->data[0];
2292 nfc_dev_err(&dev->interface->dev,
2293 "Error %d when sending data",
2294 params_len);
2295 2274
2296 return params_len; 2275 dev_kfree_skb(resp);
2297 }
2298 2276
2299 if (params_len > 0 && params[0] != 0) { 2277 if (status != 0) {
2300 nfc_tm_deactivated(dev->nfc_dev); 2278 nfc_tm_deactivated(dev->nfc_dev);
2301 2279
2302 dev->tgt_mode = 0; 2280 dev->tgt_mode = 0;
@@ -2312,30 +2290,21 @@ static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
2312static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) 2290static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
2313{ 2291{
2314 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 2292 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
2315 struct pn533_frame *out_frame;
2316 int rc; 2293 int rc;
2317 2294
2318 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 2295 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
2319 2296
2320 rc = pn533_build_tx_frame(dev, skb, false); 2297 if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
2321 if (rc)
2322 goto error;
2323
2324 out_frame = (struct pn533_frame *) skb->data;
2325
2326 rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame,
2327 PN533_NORMAL_FRAME_MAX_LEN,
2328 pn533_tm_send_complete, skb);
2329 if (rc) {
2330 nfc_dev_err(&dev->interface->dev, 2298 nfc_dev_err(&dev->interface->dev,
2331 "Error %d when trying to send data", rc); 2299 "Data length greater than the max allowed: %d",
2332 goto error; 2300 PN533_CMD_DATAEXCH_DATA_MAXLEN);
2301 return -ENOSYS;
2333 } 2302 }
2334 2303
2335 return 0; 2304 rc = pn533_send_data_async(dev, PN533_CMD_TG_SET_DATA, skb,
2336 2305 pn533_tm_send_complete, NULL);
2337error: 2306 if (rc < 0)
2338 kfree_skb(skb); 2307 dev_kfree_skb(skb);
2339 2308
2340 return rc; 2309 return rc;
2341} 2310}