diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2015-02-01 16:26:11 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-02-02 15:50:39 -0500 |
commit | f7f793f31378d5e83276871339c2a8374b0e8657 (patch) | |
tree | fbb5d1fe808f5a5ef1626e929cdc17717448420a | |
parent | af9c8aa67d07adcd3b41fb2934af7af056eabecf (diff) |
NFC: nci: Add NFCEE enabling and disabling support
NFCEEs can be enabled or disabled by sending the
NCI_OP_NFCEE_MODE_SET_CMD command to the NFCC. This patch
provides an API for drivers to enable and disable e.g. their
NCI discoveredd secure elements.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | include/net/nfc/nci.h | 9 | ||||
-rw-r--r-- | include/net/nfc/nci_core.h | 1 | ||||
-rw-r--r-- | net/nfc/nci/core.c | 21 | ||||
-rw-r--r-- | net/nfc/nci/rsp.c | 13 |
4 files changed, 44 insertions, 0 deletions
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 6d99e8f79835..230f227bb319 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h | |||
@@ -284,6 +284,14 @@ struct nci_nfcee_discover_cmd { | |||
284 | __u8 discovery_action; | 284 | __u8 discovery_action; |
285 | } __packed; | 285 | } __packed; |
286 | 286 | ||
287 | #define NCI_OP_NFCEE_MODE_SET_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01) | ||
288 | #define NCI_NFCEE_DISABLE 0x00 | ||
289 | #define NCI_NFCEE_ENABLE 0x01 | ||
290 | struct nci_nfcee_mode_set_cmd { | ||
291 | __u8 nfcee_id; | ||
292 | __u8 nfcee_mode; | ||
293 | } __packed; | ||
294 | |||
287 | /* ----------------------- */ | 295 | /* ----------------------- */ |
288 | /* ---- NCI Responses ---- */ | 296 | /* ---- NCI Responses ---- */ |
289 | /* ----------------------- */ | 297 | /* ----------------------- */ |
@@ -333,6 +341,7 @@ struct nci_nfcee_discover_rsp { | |||
333 | __u8 num_nfcee; | 341 | __u8 num_nfcee; |
334 | } __packed; | 342 | } __packed; |
335 | 343 | ||
344 | #define NCI_OP_NFCEE_MODE_SET_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01) | ||
336 | /* --------------------------- */ | 345 | /* --------------------------- */ |
337 | /* ---- NCI Notifications ---- */ | 346 | /* ---- NCI Notifications ---- */ |
338 | /* --------------------------- */ | 347 | /* --------------------------- */ |
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 31ad795aa4b5..6cf6ee2b696d 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h | |||
@@ -185,6 +185,7 @@ int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb); | |||
185 | int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val); | 185 | int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val); |
186 | 186 | ||
187 | int nci_nfcee_discover(struct nci_dev *ndev, u8 action); | 187 | int nci_nfcee_discover(struct nci_dev *ndev, u8 action); |
188 | int nci_nfcee_mode_set(struct nci_dev *ndev, u8 nfcee_id, u8 nfcee_mode); | ||
188 | 189 | ||
189 | static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, | 190 | static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, |
190 | unsigned int len, | 191 | unsigned int len, |
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index a25857548524..e5fb8c8eed94 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -486,6 +486,27 @@ int nci_nfcee_discover(struct nci_dev *ndev, u8 action) | |||
486 | } | 486 | } |
487 | EXPORT_SYMBOL(nci_nfcee_discover); | 487 | EXPORT_SYMBOL(nci_nfcee_discover); |
488 | 488 | ||
489 | static void nci_nfcee_mode_set_req(struct nci_dev *ndev, unsigned long opt) | ||
490 | { | ||
491 | struct nci_nfcee_mode_set_cmd *cmd = | ||
492 | (struct nci_nfcee_mode_set_cmd *)opt; | ||
493 | |||
494 | nci_send_cmd(ndev, NCI_OP_NFCEE_MODE_SET_CMD, | ||
495 | sizeof(struct nci_nfcee_mode_set_cmd), cmd); | ||
496 | } | ||
497 | |||
498 | int nci_nfcee_mode_set(struct nci_dev *ndev, u8 nfcee_id, u8 nfcee_mode) | ||
499 | { | ||
500 | struct nci_nfcee_mode_set_cmd cmd; | ||
501 | |||
502 | cmd.nfcee_id = nfcee_id; | ||
503 | cmd.nfcee_mode = nfcee_mode; | ||
504 | |||
505 | return nci_request(ndev, nci_nfcee_mode_set_req, (unsigned long)&cmd, | ||
506 | msecs_to_jiffies(NCI_CMD_TIMEOUT)); | ||
507 | } | ||
508 | EXPORT_SYMBOL(nci_nfcee_mode_set); | ||
509 | |||
489 | static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) | 510 | static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) |
490 | { | 511 | { |
491 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 512 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index ee094dfab2ed..0a3e98240dd6 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c | |||
@@ -213,6 +213,15 @@ static void nci_nfcee_discover_rsp_packet(struct nci_dev *ndev, | |||
213 | nci_req_complete(ndev, discover_rsp->status); | 213 | nci_req_complete(ndev, discover_rsp->status); |
214 | } | 214 | } |
215 | 215 | ||
216 | static void nci_nfcee_mode_set_rsp_packet(struct nci_dev *ndev, | ||
217 | struct sk_buff *skb) | ||
218 | { | ||
219 | __u8 status = skb->data[0]; | ||
220 | |||
221 | pr_debug("status 0x%x\n", status); | ||
222 | nci_req_complete(ndev, status); | ||
223 | } | ||
224 | |||
216 | void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) | 225 | void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) |
217 | { | 226 | { |
218 | __u16 rsp_opcode = nci_opcode(skb->data); | 227 | __u16 rsp_opcode = nci_opcode(skb->data); |
@@ -262,6 +271,10 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) | |||
262 | nci_nfcee_discover_rsp_packet(ndev, skb); | 271 | nci_nfcee_discover_rsp_packet(ndev, skb); |
263 | break; | 272 | break; |
264 | 273 | ||
274 | case NCI_OP_NFCEE_MODE_SET_RSP: | ||
275 | nci_nfcee_mode_set_rsp_packet(ndev, skb); | ||
276 | break; | ||
277 | |||
265 | default: | 278 | default: |
266 | pr_err("unknown rsp opcode 0x%x\n", rsp_opcode); | 279 | pr_err("unknown rsp opcode 0x%x\n", rsp_opcode); |
267 | break; | 280 | break; |