Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe Ricard and committed by
Samuel Ortiz
96d4581f cde2aa99

+27 -14
+1 -1
drivers/nfc/nfcsim.c
··· 246 246 } 247 247 248 248 static void nfcsim_deactivate_target(struct nfc_dev *nfc_dev, 249 - struct nfc_target *target) 249 + struct nfc_target *target, u8 mode) 250 250 { 251 251 struct nfcsim *dev = nfc_get_drvdata(nfc_dev); 252 252
+1 -1
drivers/nfc/pn533.c
··· 2263 2263 } 2264 2264 2265 2265 static void pn533_deactivate_target(struct nfc_dev *nfc_dev, 2266 - struct nfc_target *target) 2266 + struct nfc_target *target, u8 mode) 2267 2267 { 2268 2268 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 2269 2269 struct sk_buff *skb;
+1 -1
include/net/nfc/nfc.h
··· 68 68 int (*activate_target)(struct nfc_dev *dev, struct nfc_target *target, 69 69 u32 protocol); 70 70 void (*deactivate_target)(struct nfc_dev *dev, 71 - struct nfc_target *target); 71 + struct nfc_target *target, u8 mode); 72 72 int (*im_transceive)(struct nfc_dev *dev, struct nfc_target *target, 73 73 struct sk_buff *skb, data_exchange_cb_t cb, 74 74 void *cb_context);
+2 -2
net/nfc/core.c
··· 449 449 * @dev: The nfc device that found the target 450 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 454 int rc = 0; 455 455 ··· 476 476 if (dev->ops->check_presence) 477 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 480 dev->active_target = NULL; 481 481 482 482 error:
+2 -1
net/nfc/digital_core.c
··· 631 631 } 632 632 633 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 637 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 637 638
+2 -1
net/nfc/hci/core.c
··· 678 678 } 679 679 680 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
+11 -4
net/nfc/nci/core.c
··· 835 835 } 836 836 837 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 841 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 842 + u8 nci_mode = NCI_DEACTIVATE_TYPE_IDLE_MODE; 841 843 842 844 pr_debug("entry\n"); 843 845 ··· 850 848 851 849 ndev->target_active_prot = 0; 852 850 851 + switch (mode) { 852 + case NFC_TARGET_MODE_SLEEP: 853 + nci_mode = NCI_DEACTIVATE_TYPE_SLEEP_MODE; 854 + break; 855 + } 856 + 853 857 if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { 854 - nci_request(ndev, nci_rf_deactivate_req, 855 - NCI_DEACTIVATE_TYPE_IDLE_MODE, 858 + nci_request(ndev, nci_rf_deactivate_req, nci_mode, 856 859 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); 857 860 } 858 861 } ··· 891 884 pr_debug("entry\n"); 892 885 893 886 if (nfc_dev->rf_mode == NFC_RF_INITIATOR) { 894 - nci_deactivate_target(nfc_dev, NULL); 887 + nci_deactivate_target(nfc_dev, NULL, NCI_DEACTIVATE_TYPE_IDLE_MODE); 895 888 } else { 896 889 if (atomic_read(&ndev->state) == NCI_LISTEN_ACTIVE || 897 890 atomic_read(&ndev->state) == NCI_DISCOVERY) {
+1 -1
net/nfc/netlink.c
··· 885 885 target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); 886 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 889 rc = nfc_activate_target(dev, target_idx, protocol); 890 890 891 891 nfc_put_device(dev);
+4 -1
net/nfc/nfc.h
··· 25 25 #include <net/nfc/nfc.h> 26 26 #include <net/sock.h> 27 27 28 + #define NFC_TARGET_MODE_IDLE 0 29 + #define NFC_TARGET_MODE_SLEEP 1 30 + 28 31 struct nfc_protocol { 29 32 int id; 30 33 struct proto *proto; ··· 150 147 151 148 int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); 152 149 153 - int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx); 150 + int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode); 154 151 155 152 int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, 156 153 data_exchange_cb_t cb, void *cb_context);
+2 -1
net/nfc/rawsock.c
··· 321 321 322 322 if (sk->sk_state == TCP_ESTABLISHED) { 323 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 326 nfc_put_device(nfc_rawsock(sk)->dev); 326 327 } 327 328