diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2011-12-14 16:43:09 +0100 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-12-14 14:50:12 -0500 |
commit | 1ed28f610653e9b18433c6d87e9d333b7e3e886e (patch) | |
tree | 176dbd0bfee9c16ef615d6178a26cd1b125e7527 /net/nfc/core.c | |
parent | db81a62451b24eaef59f41e6fb312a88e1a83454 (diff) | |
download | linux-1ed28f610653e9b18433c6d87e9d333b7e3e886e.tar.gz linux-1ed28f610653e9b18433c6d87e9d333b7e3e886e.tar.bz2 linux-1ed28f610653e9b18433c6d87e9d333b7e3e886e.zip |
NFC: Add a DEP link control netlink command
NFC-DEP (Data Exchange Protocol) is an NFC MAC layer.
This command allows to enable and disable the DEP link on to which e.g.
LLCP can run.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/nfc/core.c')
-rw-r--r-- | net/nfc/core.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c index f53f88ada687..785f1f20c7ba 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -181,6 +181,83 @@ error: return rc; } +int nfc_dep_link_up(struct nfc_dev *dev, int target_index, + u8 comm_mode, u8 rf_mode) +{ + int rc = 0; + + pr_debug("dev_name=%s comm:%d rf:%d\n", + dev_name(&dev->dev), comm_mode, rf_mode); + + if (!dev->ops->dep_link_up) + return -EOPNOTSUPP; + + device_lock(&dev->dev); + + if (!device_is_registered(&dev->dev)) { + rc = -ENODEV; + goto error; + } + + if (dev->dep_link_up == true) { + rc = -EALREADY; + goto error; + } + + rc = dev->ops->dep_link_up(dev, target_index, comm_mode, rf_mode); + +error: + device_unlock(&dev->dev); + return rc; +} + +int nfc_dep_link_down(struct nfc_dev *dev) +{ + int rc = 0; + + pr_debug("dev_name=%s\n", dev_name(&dev->dev)); + + if (!dev->ops->dep_link_down) + return -EOPNOTSUPP; + + device_lock(&dev->dev); + + if (!device_is_registered(&dev->dev)) { + rc = -ENODEV; + goto error; + } + + if (dev->dep_link_up == false) { + rc = -EALREADY; + goto error; + } + + if (dev->dep_rf_mode == NFC_RF_TARGET) { + rc = -EOPNOTSUPP; + goto error; + } + + rc = dev->ops->dep_link_down(dev); + if (!rc) { + dev->dep_link_up = false; + nfc_genl_dep_link_down_event(dev); + } + +error: + device_unlock(&dev->dev); + return rc; +} + +int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, + u8 comm_mode, u8 rf_mode) +{ + dev->dep_link_up = true; + dev->dep_rf_mode = rf_mode; + + return nfc_genl_dep_link_up_event(dev, target_idx, comm_mode, rf_mode); +} +EXPORT_SYMBOL(nfc_dep_link_is_up); + /** * nfc_activate_target - prepare the target for data exchange * |