diff options
author | Mark A. Greer <mgreer@animalcreek.com> | 2014-09-23 19:38:03 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-11-28 06:37:58 -0500 |
commit | 6ce306682f7f07a5e9e51c655764ead214ef3869 (patch) | |
tree | 1805b58787ab94dea3e401d2e82e6b84ea35c480 /net/nfc | |
parent | b15829ba5e82b919513f8ac70e97b4e474fae641 (diff) |
NFC: digital: Rearrange NFC-DEP DEP_REQ/DEP_RES Code
Rearrange some of the code in digital_in_recv_dep_res()
and digital_tg_recv_dep_req() so the initial code looks
similar. The real reason is prepare the code for some
upcoming patches that require these changes.
Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/digital_dep.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c index 70fcce03e8a9..f3f2b61fb5da 100644 --- a/net/nfc/digital_dep.c +++ b/net/nfc/digital_dep.c | |||
@@ -400,10 +400,10 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, | |||
400 | goto exit; | 400 | goto exit; |
401 | } | 401 | } |
402 | 402 | ||
403 | size = sizeof(struct digital_dep_req_res); | ||
403 | dep_res = (struct digital_dep_req_res *)resp->data; | 404 | dep_res = (struct digital_dep_req_res *)resp->data; |
404 | 405 | ||
405 | if (resp->len < sizeof(struct digital_dep_req_res) || | 406 | if (resp->len < size || dep_res->dir != DIGITAL_NFC_DEP_FRAME_DIR_IN || |
406 | dep_res->dir != DIGITAL_NFC_DEP_FRAME_DIR_IN || | ||
407 | dep_res->cmd != DIGITAL_CMD_DEP_RES) { | 407 | dep_res->cmd != DIGITAL_CMD_DEP_RES) { |
408 | rc = -EIO; | 408 | rc = -EIO; |
409 | goto error; | 409 | goto error; |
@@ -411,6 +411,16 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, | |||
411 | 411 | ||
412 | pfb = dep_res->pfb; | 412 | pfb = dep_res->pfb; |
413 | 413 | ||
414 | if (DIGITAL_NFC_DEP_DID_BIT_SET(pfb)) | ||
415 | size++; | ||
416 | |||
417 | if (size > resp->len) { | ||
418 | rc = -EIO; | ||
419 | goto error; | ||
420 | } | ||
421 | |||
422 | skb_pull(resp, size); | ||
423 | |||
414 | switch (DIGITAL_NFC_DEP_PFB_TYPE(pfb)) { | 424 | switch (DIGITAL_NFC_DEP_PFB_TYPE(pfb)) { |
415 | case DIGITAL_NFC_DEP_PFB_I_PDU: | 425 | case DIGITAL_NFC_DEP_PFB_I_PDU: |
416 | if (DIGITAL_NFC_DEP_PFB_PNI(pfb) != ddev->curr_nfc_dep_pni) { | 426 | if (DIGITAL_NFC_DEP_PFB_PNI(pfb) != ddev->curr_nfc_dep_pni) { |
@@ -435,7 +445,7 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, | |||
435 | goto error; | 445 | goto error; |
436 | } | 446 | } |
437 | 447 | ||
438 | rc = digital_in_send_rtox(ddev, data_exch, resp->data[3]); | 448 | rc = digital_in_send_rtox(ddev, data_exch, resp->data[0]); |
439 | if (rc) | 449 | if (rc) |
440 | goto error; | 450 | goto error; |
441 | 451 | ||
@@ -449,18 +459,6 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, | |||
449 | goto error; | 459 | goto error; |
450 | } | 460 | } |
451 | 461 | ||
452 | size = sizeof(struct digital_dep_req_res); | ||
453 | |||
454 | if (DIGITAL_NFC_DEP_DID_BIT_SET(pfb)) | ||
455 | size++; | ||
456 | |||
457 | if (size > resp->len) { | ||
458 | rc = -EIO; | ||
459 | goto error; | ||
460 | } | ||
461 | |||
462 | skb_pull(resp, size); | ||
463 | |||
464 | exit: | 462 | exit: |
465 | data_exch->cb(data_exch->cb_context, resp, rc); | 463 | data_exch->cb(data_exch->cb_context, resp, rc); |
466 | 464 | ||
@@ -524,6 +522,7 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, | |||
524 | { | 522 | { |
525 | int rc; | 523 | int rc; |
526 | struct digital_dep_req_res *dep_req; | 524 | struct digital_dep_req_res *dep_req; |
525 | u8 pfb; | ||
527 | size_t size; | 526 | size_t size; |
528 | 527 | ||
529 | if (IS_ERR(resp)) { | 528 | if (IS_ERR(resp)) { |
@@ -553,18 +552,22 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, | |||
553 | goto exit; | 552 | goto exit; |
554 | } | 553 | } |
555 | 554 | ||
556 | if (DIGITAL_NFC_DEP_DID_BIT_SET(dep_req->pfb)) | 555 | pfb = dep_req->pfb; |
556 | |||
557 | if (DIGITAL_NFC_DEP_DID_BIT_SET(pfb)) | ||
557 | size++; | 558 | size++; |
558 | 559 | ||
559 | if (resp->len < size) { | 560 | if (size > resp->len) { |
560 | rc = -EIO; | 561 | rc = -EIO; |
561 | goto exit; | 562 | goto exit; |
562 | } | 563 | } |
563 | 564 | ||
564 | switch (DIGITAL_NFC_DEP_PFB_TYPE(dep_req->pfb)) { | 565 | skb_pull(resp, size); |
566 | |||
567 | switch (DIGITAL_NFC_DEP_PFB_TYPE(pfb)) { | ||
565 | case DIGITAL_NFC_DEP_PFB_I_PDU: | 568 | case DIGITAL_NFC_DEP_PFB_I_PDU: |
566 | pr_debug("DIGITAL_NFC_DEP_PFB_I_PDU\n"); | 569 | pr_debug("DIGITAL_NFC_DEP_PFB_I_PDU\n"); |
567 | ddev->curr_nfc_dep_pni = DIGITAL_NFC_DEP_PFB_PNI(dep_req->pfb); | 570 | ddev->curr_nfc_dep_pni = DIGITAL_NFC_DEP_PFB_PNI(pfb); |
568 | break; | 571 | break; |
569 | case DIGITAL_NFC_DEP_PFB_ACK_NACK_PDU: | 572 | case DIGITAL_NFC_DEP_PFB_ACK_NACK_PDU: |
570 | pr_err("Received a ACK/NACK PDU\n"); | 573 | pr_err("Received a ACK/NACK PDU\n"); |
@@ -576,8 +579,6 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, | |||
576 | goto exit; | 579 | goto exit; |
577 | } | 580 | } |
578 | 581 | ||
579 | skb_pull(resp, size); | ||
580 | |||
581 | rc = nfc_tm_data_received(ddev->nfc_dev, resp); | 582 | rc = nfc_tm_data_received(ddev->nfc_dev, resp); |
582 | 583 | ||
583 | exit: | 584 | exit: |