void *cb_context)
{
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
+ int rc;
nfc_dbg("entry, target_idx %d, len %d", target_idx, skb->len);
return -EINVAL;
}
+ if (test_and_set_bit(NCI_DATA_EXCHANGE, &ndev->flags))
+ return -EBUSY;
+
/* store cb and context to be used on receiving data */
ndev->data_exchange_cb = cb;
ndev->data_exchange_cb_context = cb_context;
- return nci_send_data(ndev, ndev->conn_id, skb);
+ rc = nci_send_data(ndev, ndev->conn_id, skb);
+ if (rc)
+ clear_bit(NCI_DATA_EXCHANGE, &ndev->flags);
+
+ return rc;
}
static struct nfc_ops nci_nfc_ops = {
/* no waiting callback, free skb */
kfree_skb(skb);
}
+
+ clear_bit(NCI_DATA_EXCHANGE, &ndev->flags);
}
/* ----------------- NCI TX Data ----------------- */
}
/* complete the data exchange transaction, if exists */
- if (ndev->data_exchange_cb)
+ if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
nci_data_exchange_complete(ndev, NULL, -EIO);
}