Skip to content

Commit be9ae4c

Browse files
author
Samuel Ortiz
committed
NFC: Introduce target mode tx ops
And rename the initiator mode data exchange ops for consistency sake. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent f212ad5 commit be9ae4c

5 files changed

Lines changed: 34 additions & 30 deletions

File tree

‎drivers/nfc/pn533.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,9 +1691,9 @@ static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg,
16911691
return 0;
16921692
}
16931693

1694-
static int pn533_data_exchange(struct nfc_dev *nfc_dev,
1695-
struct nfc_target *target, struct sk_buff *skb,
1696-
data_exchange_cb_t cb, void *cb_context)
1694+
static int pn533_transceive(struct nfc_dev *nfc_dev,
1695+
struct nfc_target *target, struct sk_buff *skb,
1696+
data_exchange_cb_t cb, void *cb_context)
16971697
{
16981698
struct pn533 *dev = nfc_get_drvdata(nfc_dev);
16991699
struct pn533_frame *out_frame, *in_frame;
@@ -1853,7 +1853,7 @@ struct nfc_ops pn533_nfc_ops = {
18531853
.stop_poll = pn533_stop_poll,
18541854
.activate_target = pn533_activate_target,
18551855
.deactivate_target = pn533_deactivate_target,
1856-
.data_exchange = pn533_data_exchange,
1856+
.im_transceive = pn533_transceive,
18571857
};
18581858

18591859
static int pn533_probe(struct usb_interface *interface,

‎include/net/nfc/nfc.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ struct nfc_ops {
6363
u32 protocol);
6464
void (*deactivate_target)(struct nfc_dev *dev,
6565
struct nfc_target *target);
66-
int (*data_exchange)(struct nfc_dev *dev, struct nfc_target *target,
66+
int (*im_transceive)(struct nfc_dev *dev, struct nfc_target *target,
6767
struct sk_buff *skb, data_exchange_cb_t cb,
6868
void *cb_context);
69+
int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb);
6970
int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target);
7071
};
7172

‎net/nfc/core.c‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -413,27 +413,30 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
413413
goto error;
414414
}
415415

416-
if (dev->active_target == NULL) {
417-
rc = -ENOTCONN;
418-
kfree_skb(skb);
419-
goto error;
420-
}
416+
if (dev->rf_mode == NFC_RF_INITIATOR && dev->active_target != NULL) {
417+
if (dev->active_target->idx != target_idx) {
418+
rc = -EADDRNOTAVAIL;
419+
kfree_skb(skb);
420+
goto error;
421+
}
421422

422-
if (dev->active_target->idx != target_idx) {
423-
rc = -EADDRNOTAVAIL;
423+
if (dev->ops->check_presence)
424+
del_timer_sync(&dev->check_pres_timer);
425+
426+
rc = dev->ops->im_transceive(dev, dev->active_target, skb, cb,
427+
cb_context);
428+
429+
if (!rc && dev->ops->check_presence)
430+
mod_timer(&dev->check_pres_timer, jiffies +
431+
msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
432+
} else if (dev->rf_mode == NFC_RF_TARGET && dev->ops->tm_send != NULL) {
433+
rc = dev->ops->tm_send(dev, skb);
434+
} else {
435+
rc = -ENOTCONN;
424436
kfree_skb(skb);
425437
goto error;
426438
}
427439

428-
if (dev->ops->check_presence)
429-
del_timer_sync(&dev->check_pres_timer);
430-
431-
rc = dev->ops->data_exchange(dev, dev->active_target, skb, cb,
432-
cb_context);
433-
434-
if (!rc && dev->ops->check_presence)
435-
mod_timer(&dev->check_pres_timer, jiffies +
436-
msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
437440

438441
error:
439442
device_unlock(&dev->dev);
@@ -727,7 +730,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
727730
struct nfc_dev *dev;
728731

729732
if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
730-
!ops->deactivate_target || !ops->data_exchange)
733+
!ops->deactivate_target || !ops->im_transceive)
731734
return NULL;
732735

733736
if (!supported_protocols)

‎net/nfc/hci/core.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ static void hci_deactivate_target(struct nfc_dev *nfc_dev,
512512
{
513513
}
514514

515-
static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
516-
struct sk_buff *skb, data_exchange_cb_t cb,
517-
void *cb_context)
515+
static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
516+
struct sk_buff *skb, data_exchange_cb_t cb,
517+
void *cb_context)
518518
{
519519
struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
520520
int r;
@@ -580,7 +580,7 @@ static struct nfc_ops hci_nfc_ops = {
580580
.stop_poll = hci_stop_poll,
581581
.activate_target = hci_activate_target,
582582
.deactivate_target = hci_deactivate_target,
583-
.data_exchange = hci_data_exchange,
583+
.im_transceive = hci_transceive,
584584
.check_presence = hci_check_presence,
585585
};
586586

‎net/nfc/nci/core.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev,
522522
}
523523
}
524524

525-
static int nci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
526-
struct sk_buff *skb,
527-
data_exchange_cb_t cb, void *cb_context)
525+
static int nci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
526+
struct sk_buff *skb,
527+
data_exchange_cb_t cb, void *cb_context)
528528
{
529529
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
530530
int rc;
@@ -557,7 +557,7 @@ static struct nfc_ops nci_nfc_ops = {
557557
.stop_poll = nci_stop_poll,
558558
.activate_target = nci_activate_target,
559559
.deactivate_target = nci_deactivate_target,
560-
.data_exchange = nci_data_exchange,
560+
.im_transceive = nci_transceive,
561561
};
562562

563563
/* ---- Interface to NCI drivers ---- */

0 commit comments

Comments
 (0)