summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2021-08-18 10:17:57 +0100
committerDavid S. Miller <davem@davemloft.net>2021-08-18 10:17:57 +0100
commit93e271632ccf0c65395900a9c12720652f769d2a (patch)
tree2cdce13eadf64d787e8e49e0f95651a8bf632dc9 /drivers
parentec18e8455484370d633a718c6456ddbf6eceef21 (diff)
parent61612511e55c886c96c0586abe3ac428402777df (diff)
downloadlinux-93e271632ccf0c65395900a9c12720652f769d2a.tar.bz2
Merge branch 'nci-ext'
Bongsu Jeon says: ==================== Update the virtual NCI device driver and add the NCI testcase This series updates the virtual NCI device driver and NCI selftest code and add the NCI test case in selftests. 1/8 to use wait queue in virtual device driver. 2/8 to remove the polling code in selftests. 3/8 to fix a typo. 4/8 to fix the next nlattr offset calculation. 5/8 to fix the wrong condition in if statement. 6/8 to add a flag parameter to the Netlink send function. 7/8 to extract the start/stop discovery function. 8/8 to add the NCI testcase in selftests. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nfc/virtual_ncidev.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c
index 2ee0ec4bb739..221fa3bb8705 100644
--- a/drivers/nfc/virtual_ncidev.c
+++ b/drivers/nfc/virtual_ncidev.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/mutex.h>
+#include <linux/wait.h>
#include <net/nfc/nci_core.h>
enum virtual_ncidev_mode {
@@ -27,6 +28,7 @@ enum virtual_ncidev_mode {
NFC_PROTO_ISO15693_MASK)
static enum virtual_ncidev_mode state;
+static DECLARE_WAIT_QUEUE_HEAD(wq);
static struct miscdevice miscdev;
static struct sk_buff *send_buff;
static struct nci_dev *ndev;
@@ -61,6 +63,7 @@ static int virtual_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
}
send_buff = skb_copy(skb, GFP_KERNEL);
mutex_unlock(&nci_mutex);
+ wake_up_interruptible(&wq);
return 0;
}
@@ -77,9 +80,11 @@ static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
size_t actual_len;
mutex_lock(&nci_mutex);
- if (!send_buff) {
+ while (!send_buff) {
mutex_unlock(&nci_mutex);
- return 0;
+ if (wait_event_interruptible(wq, send_buff))
+ return -EFAULT;
+ mutex_lock(&nci_mutex);
}
actual_len = min_t(size_t, count, send_buff->len);