diff options
author | Ilan Elias <ilane@ti.com> | 2012-01-18 06:16:12 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-01-24 14:32:28 -0500 |
commit | 8939e47fc953cce6ef53e79e9ff9b53319d1a72d (patch) | |
tree | fba0ffe539b4d6937bfb2bd9986fe989917b8039 /net/nfc/nci/core.c | |
parent | 6d810f10325522cfcf498dc6d64b9f96e1f5153f (diff) |
NFC: Clearly separate NCI states from flags
Make a clear separation between NCI states and flags.
This is required in order to support more NCI states (e.g.
for multiple targets support).
Signed-off-by: Ilan Elias <ilane@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/nfc/nci/core.c')
-rw-r--r-- | net/nfc/nci/core.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 815d28a0ed9d..629b76845973 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -264,6 +264,7 @@ static int nci_open_device(struct nci_dev *ndev) | |||
264 | 264 | ||
265 | if (!rc) { | 265 | if (!rc) { |
266 | set_bit(NCI_UP, &ndev->flags); | 266 | set_bit(NCI_UP, &ndev->flags); |
267 | atomic_set(&ndev->state, NCI_IDLE); | ||
267 | } else { | 268 | } else { |
268 | /* Init failed, cleanup */ | 269 | /* Init failed, cleanup */ |
269 | skb_queue_purge(&ndev->cmd_q); | 270 | skb_queue_purge(&ndev->cmd_q); |
@@ -360,7 +361,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) | |||
360 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 361 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
361 | int rc; | 362 | int rc; |
362 | 363 | ||
363 | if (test_bit(NCI_DISCOVERY, &ndev->flags)) { | 364 | if (atomic_read(&ndev->state) == NCI_DISCOVERY) { |
364 | pr_err("unable to start poll, since poll is already active\n"); | 365 | pr_err("unable to start poll, since poll is already active\n"); |
365 | return -EBUSY; | 366 | return -EBUSY; |
366 | } | 367 | } |
@@ -370,7 +371,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) | |||
370 | return -EBUSY; | 371 | return -EBUSY; |
371 | } | 372 | } |
372 | 373 | ||
373 | if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { | 374 | if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { |
374 | pr_debug("target is active, implicitly deactivate...\n"); | 375 | pr_debug("target is active, implicitly deactivate...\n"); |
375 | 376 | ||
376 | rc = nci_request(ndev, nci_rf_deactivate_req, 0, | 377 | rc = nci_request(ndev, nci_rf_deactivate_req, 0, |
@@ -392,7 +393,7 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) | |||
392 | { | 393 | { |
393 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 394 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
394 | 395 | ||
395 | if (!test_bit(NCI_DISCOVERY, &ndev->flags)) { | 396 | if (atomic_read(&ndev->state) != NCI_DISCOVERY) { |
396 | pr_err("unable to stop poll, since poll is not active\n"); | 397 | pr_err("unable to stop poll, since poll is not active\n"); |
397 | return; | 398 | return; |
398 | } | 399 | } |
@@ -408,7 +409,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, | |||
408 | 409 | ||
409 | pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); | 410 | pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); |
410 | 411 | ||
411 | if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { | 412 | if (atomic_read(&ndev->state) != NCI_POLL_ACTIVE) { |
412 | pr_err("there is no available target to activate\n"); | 413 | pr_err("there is no available target to activate\n"); |
413 | return -EINVAL; | 414 | return -EINVAL; |
414 | } | 415 | } |
@@ -443,7 +444,7 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) | |||
443 | 444 | ||
444 | ndev->target_active_prot = 0; | 445 | ndev->target_active_prot = 0; |
445 | 446 | ||
446 | if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { | 447 | if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { |
447 | nci_request(ndev, nci_rf_deactivate_req, 0, | 448 | nci_request(ndev, nci_rf_deactivate_req, 0, |
448 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); | 449 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); |
449 | } | 450 | } |