diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2011-12-14 16:43:12 +0100 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-12-14 14:50:13 -0500 |
commit | d646960f7986fefb460a2b062d5ccc8ccfeacc3a (patch) | |
tree | 0624d338715a8d275a39fbfce074df5c5d2783f5 /net/nfc/core.c | |
parent | 361f3cb7f9cfdb82c80926d0e7843c098c034545 (diff) |
NFC: Initial LLCP support
This patch is an initial implementation for the NFC Logical Link Control
protocol. It's also known as NFC peer to peer mode.
This is a basic implementation as it lacks SDP (services Discovery
Protocol), frames aggregation support, and frame rejecion parsing.
Follow up patches will implement those missing features.
This code has been tested against a Nexus S phone implementing LLCP 1.0.
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 | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c index 3a45f21b3b97..3ddf6e698df0 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -240,6 +240,7 @@ int nfc_dep_link_down(struct nfc_dev *dev) rc = dev->ops->dep_link_down(dev); if (!rc) { dev->dep_link_up = false; + nfc_llcp_mac_is_down(dev); nfc_genl_dep_link_down_event(dev); } @@ -254,6 +255,8 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, dev->dep_link_up = true; dev->dep_rf_mode = rf_mode; + nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode); + return nfc_genl_dep_link_up_event(dev, target_idx, comm_mode, rf_mode); } EXPORT_SYMBOL(nfc_dep_link_is_up); @@ -360,13 +363,13 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) if (gb_len > NFC_MAX_GT_LEN) return -EINVAL; - return 0; + return nfc_llcp_set_remote_gb(dev, gb, gb_len); } EXPORT_SYMBOL(nfc_set_remote_general_bytes); u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len) { - return NULL; + return nfc_llcp_general_bytes(dev, gt_len); } EXPORT_SYMBOL(nfc_get_local_general_bytes); @@ -560,6 +563,10 @@ int nfc_register_device(struct nfc_dev *dev) if (rc < 0) return rc; + rc = nfc_llcp_register_device(dev); + if (rc) + pr_err("Could not register llcp device\n"); + rc = nfc_genl_device_added(dev); if (rc) pr_debug("The userspace won't be notified that the device %s was added\n", @@ -591,6 +598,8 @@ void nfc_unregister_device(struct nfc_dev *dev) mutex_unlock(&nfc_devlist_mutex); + nfc_llcp_unregister_device(dev); + rc = nfc_genl_device_removed(dev); if (rc) pr_debug("The userspace won't be notified that the device %s was removed\n", @@ -620,6 +629,10 @@ static int __init nfc_init(void) if (rc) goto err_rawsock; + rc = nfc_llcp_init(); + if (rc) + goto err_llcp_sock; + rc = af_nfc_init(); if (rc) goto err_af_nfc; @@ -627,6 +640,8 @@ static int __init nfc_init(void) return 0; err_af_nfc: + nfc_llcp_exit(); +err_llcp_sock: rawsock_exit(); err_rawsock: nfc_genl_exit(); @@ -638,6 +653,7 @@ err_genl: static void __exit nfc_exit(void) { af_nfc_exit(); + nfc_llcp_exit(); rawsock_exit(); nfc_genl_exit(); class_unregister(&nfc_class); |