if (!rc) {
set_bit(NCI_UP, &ndev->flags);
+ atomic_set(&ndev->state, NCI_IDLE);
} else {
/* Init failed, cleanup */
skb_queue_purge(&ndev->cmd_q);
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
int rc;
- if (test_bit(NCI_DISCOVERY, &ndev->flags)) {
+ if (atomic_read(&ndev->state) == NCI_DISCOVERY) {
pr_err("unable to start poll, since poll is already active\n");
return -EBUSY;
}
return -EBUSY;
}
- if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) {
+ if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) {
pr_debug("target is active, implicitly deactivate...\n");
rc = nci_request(ndev, nci_rf_deactivate_req, 0,
{
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
- if (!test_bit(NCI_DISCOVERY, &ndev->flags)) {
+ if (atomic_read(&ndev->state) != NCI_DISCOVERY) {
pr_err("unable to stop poll, since poll is not active\n");
return;
}
pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol);
- if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) {
+ if (atomic_read(&ndev->state) != NCI_POLL_ACTIVE) {
pr_err("there is no available target to activate\n");
return -EINVAL;
}
ndev->target_active_prot = 0;
- if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) {
+ if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) {
nci_request(ndev, nci_rf_deactivate_req, 0,
msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
}
__u8 *data = skb->data;
int err = 0;
- clear_bit(NCI_DISCOVERY, &ndev->flags);
- set_bit(NCI_POLL_ACTIVE, &ndev->flags);
+ atomic_set(&ndev->state, NCI_POLL_ACTIVE);
ntf.rf_discovery_id = *data++;
ntf.rf_interface = *data++;
pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason);
- clear_bit(NCI_POLL_ACTIVE, &ndev->flags);
+ atomic_set(&ndev->state, NCI_IDLE);
ndev->target_active_prot = 0;
/* drop tx data queue */
pr_debug("status 0x%x\n", status);
if (status == NCI_STATUS_OK)
- set_bit(NCI_DISCOVERY, &ndev->flags);
+ atomic_set(&ndev->state, NCI_DISCOVERY);
nci_req_complete(ndev, status);
}
pr_debug("status 0x%x\n", status);
- clear_bit(NCI_DISCOVERY, &ndev->flags);
-
/* If target was active, complete the request only in deactivate_ntf */
if ((status != NCI_STATUS_OK) ||
- (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)))
+ (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
+ atomic_set(&ndev->state, NCI_IDLE);
nci_req_complete(ndev, status);
+ }
}
void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)