diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2015-10-25 17:54:43 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-10-26 22:55:12 -0400 |
commit | 96d4581f0b3712221d6ed4a765bb6b4ea40f2b2f (patch) | |
tree | 1d07dd46daa8b0b1c2aa0e3d3c7c4f9cd47b7fbe /net/nfc | |
parent | cde2aa99ba702ab8efa583495e54731b9f854e66 (diff) |
NFC: netlink: Add mode parameter to deactivate_target functions
In order to manage in a better way the nci poll mode state machine,
add mode parameter to deactivate_target functions.
This way we can manage different target state.
mode parameter make sense only in nci core.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/core.c | 4 | ||||
-rw-r--r-- | net/nfc/digital_core.c | 3 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 3 | ||||
-rw-r--r-- | net/nfc/nci/core.c | 15 | ||||
-rw-r--r-- | net/nfc/netlink.c | 2 | ||||
-rw-r--r-- | net/nfc/nfc.h | 5 | ||||
-rw-r--r-- | net/nfc/rawsock.c | 3 |
7 files changed, 24 insertions, 11 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c index cff3f1614ad4..1fe3d3b362c0 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -449,7 +449,7 @@ error: | |||
449 | * @dev: The nfc device that found the target | 449 | * @dev: The nfc device that found the target |
450 | * @target_idx: index of the target that must be deactivated | 450 | * @target_idx: index of the target that must be deactivated |
451 | */ | 451 | */ |
452 | int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) | 452 | int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode) |
453 | { | 453 | { |
454 | int rc = 0; | 454 | int rc = 0; |
455 | 455 | ||
@@ -476,7 +476,7 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) | |||
476 | if (dev->ops->check_presence) | 476 | if (dev->ops->check_presence) |
477 | del_timer_sync(&dev->check_pres_timer); | 477 | del_timer_sync(&dev->check_pres_timer); |
478 | 478 | ||
479 | dev->ops->deactivate_target(dev, dev->active_target); | 479 | dev->ops->deactivate_target(dev, dev->active_target, mode); |
480 | dev->active_target = NULL; | 480 | dev->active_target = NULL; |
481 | 481 | ||
482 | error: | 482 | error: |
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c index 009bcf317101..23c2a118ac9f 100644 --- a/net/nfc/digital_core.c +++ b/net/nfc/digital_core.c | |||
@@ -631,7 +631,8 @@ static int digital_activate_target(struct nfc_dev *nfc_dev, | |||
631 | } | 631 | } |
632 | 632 | ||
633 | static void digital_deactivate_target(struct nfc_dev *nfc_dev, | 633 | static void digital_deactivate_target(struct nfc_dev *nfc_dev, |
634 | struct nfc_target *target) | 634 | struct nfc_target *target, |
635 | u8 mode) | ||
635 | { | 636 | { |
636 | struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); | 637 | struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); |
637 | 638 | ||
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 6e061da2258a..2b0f0ac498d2 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -678,7 +678,8 @@ static int hci_activate_target(struct nfc_dev *nfc_dev, | |||
678 | } | 678 | } |
679 | 679 | ||
680 | static void hci_deactivate_target(struct nfc_dev *nfc_dev, | 680 | static void hci_deactivate_target(struct nfc_dev *nfc_dev, |
681 | struct nfc_target *target) | 681 | struct nfc_target *target, |
682 | u8 mode) | ||
682 | { | 683 | { |
683 | } | 684 | } |
684 | 685 | ||
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 75bda34fd8e4..ecf420d43a6d 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -835,9 +835,11 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, | |||
835 | } | 835 | } |
836 | 836 | ||
837 | static void nci_deactivate_target(struct nfc_dev *nfc_dev, | 837 | static void nci_deactivate_target(struct nfc_dev *nfc_dev, |
838 | struct nfc_target *target) | 838 | struct nfc_target *target, |
839 | __u8 mode) | ||
839 | { | 840 | { |
840 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 841 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
842 | u8 nci_mode = NCI_DEACTIVATE_TYPE_IDLE_MODE; | ||
841 | 843 | ||
842 | pr_debug("entry\n"); | 844 | pr_debug("entry\n"); |
843 | 845 | ||
@@ -848,9 +850,14 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, | |||
848 | 850 | ||
849 | ndev->target_active_prot = 0; | 851 | ndev->target_active_prot = 0; |
850 | 852 | ||
853 | switch (mode) { | ||
854 | case NFC_TARGET_MODE_SLEEP: | ||
855 | nci_mode = NCI_DEACTIVATE_TYPE_SLEEP_MODE; | ||
856 | break; | ||
857 | } | ||
858 | |||
851 | if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { | 859 | if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { |
852 | nci_request(ndev, nci_rf_deactivate_req, | 860 | nci_request(ndev, nci_rf_deactivate_req, nci_mode, |
853 | NCI_DEACTIVATE_TYPE_IDLE_MODE, | ||
854 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); | 861 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); |
855 | } | 862 | } |
856 | } | 863 | } |
@@ -884,7 +891,7 @@ static int nci_dep_link_down(struct nfc_dev *nfc_dev) | |||
884 | pr_debug("entry\n"); | 891 | pr_debug("entry\n"); |
885 | 892 | ||
886 | if (nfc_dev->rf_mode == NFC_RF_INITIATOR) { | 893 | if (nfc_dev->rf_mode == NFC_RF_INITIATOR) { |
887 | nci_deactivate_target(nfc_dev, NULL); | 894 | nci_deactivate_target(nfc_dev, NULL, NCI_DEACTIVATE_TYPE_IDLE_MODE); |
888 | } else { | 895 | } else { |
889 | if (atomic_read(&ndev->state) == NCI_LISTEN_ACTIVE || | 896 | if (atomic_read(&ndev->state) == NCI_LISTEN_ACTIVE || |
890 | atomic_read(&ndev->state) == NCI_DISCOVERY) { | 897 | atomic_read(&ndev->state) == NCI_DISCOVERY) { |
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index f04053295ff1..f58c1fba1026 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -885,7 +885,7 @@ static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info) | |||
885 | target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); | 885 | target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); |
886 | protocol = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]); | 886 | protocol = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]); |
887 | 887 | ||
888 | nfc_deactivate_target(dev, target_idx); | 888 | nfc_deactivate_target(dev, target_idx, NFC_TARGET_MODE_SLEEP); |
889 | rc = nfc_activate_target(dev, target_idx, protocol); | 889 | rc = nfc_activate_target(dev, target_idx, protocol); |
890 | 890 | ||
891 | nfc_put_device(dev); | 891 | nfc_put_device(dev); |
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 5c93e8412a26..c20b784ad720 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -25,6 +25,9 @@ | |||
25 | #include <net/nfc/nfc.h> | 25 | #include <net/nfc/nfc.h> |
26 | #include <net/sock.h> | 26 | #include <net/sock.h> |
27 | 27 | ||
28 | #define NFC_TARGET_MODE_IDLE 0 | ||
29 | #define NFC_TARGET_MODE_SLEEP 1 | ||
30 | |||
28 | struct nfc_protocol { | 31 | struct nfc_protocol { |
29 | int id; | 32 | int id; |
30 | struct proto *proto; | 33 | struct proto *proto; |
@@ -147,7 +150,7 @@ int nfc_dep_link_down(struct nfc_dev *dev); | |||
147 | 150 | ||
148 | int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); | 151 | int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); |
149 | 152 | ||
150 | int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx); | 153 | int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode); |
151 | 154 | ||
152 | int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, | 155 | int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, |
153 | data_exchange_cb_t cb, void *cb_context); | 156 | data_exchange_cb_t cb, void *cb_context); |
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index e9a91488fe3d..e386e6c90b17 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c | |||
@@ -321,7 +321,8 @@ static void rawsock_destruct(struct sock *sk) | |||
321 | 321 | ||
322 | if (sk->sk_state == TCP_ESTABLISHED) { | 322 | if (sk->sk_state == TCP_ESTABLISHED) { |
323 | nfc_deactivate_target(nfc_rawsock(sk)->dev, | 323 | nfc_deactivate_target(nfc_rawsock(sk)->dev, |
324 | nfc_rawsock(sk)->target_idx); | 324 | nfc_rawsock(sk)->target_idx, |
325 | NFC_TARGET_MODE_IDLE); | ||
325 | nfc_put_device(nfc_rawsock(sk)->dev); | 326 | nfc_put_device(nfc_rawsock(sk)->dev); |
326 | } | 327 | } |
327 | 328 | ||