Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be3b02c3 authored by Vamsi Krishna's avatar Vamsi Krishna
Browse files

usb: misc: ks_bridge: Add polling call back



Poll callback allows clients of ks_bridge to implement read/write
timeouts using standard system calls.

Change-Id: Id666ebdefb086042da2a0b24f025cafe4f8faa77
Signed-off-by: default avatarVamsi Krishna <vskrishn@codeaurora.org>
parent ec4b001e
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <linux/cdev.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/poll.h>

#define DRIVER_DESC	"USB host ks bridge driver"
#define DRIVER_VERSION	"1.0"
@@ -391,6 +392,27 @@ static int ksb_fs_open(struct inode *ip, struct file *fp)
	return 0;
}

static unsigned int ksb_fs_poll(struct file *file, poll_table *wait)
{
	struct ks_bridge	*ksb = file->private_data;
	unsigned long		flags;
	int			ret = 0;

	if (!test_bit(USB_DEV_CONNECTED, &ksb->flags))
		return POLLERR;

	poll_wait(file, &ksb->ks_wait_q, wait);
	if (!test_bit(USB_DEV_CONNECTED, &ksb->flags))
		return POLLERR;

	spin_lock_irqsave(&ksb->lock, flags);
	if (!list_empty(&ksb->to_ks_list))
		ret = POLLIN | POLLRDNORM;
	spin_unlock_irqrestore(&ksb->lock, flags);

	return ret;
}

static int ksb_fs_release(struct inode *ip, struct file *fp)
{
	struct ks_bridge	*ksb = fp->private_data;
@@ -410,6 +432,7 @@ static const struct file_operations ksb_fops = {
	.write = ksb_fs_write,
	.open = ksb_fs_open,
	.release = ksb_fs_release,
	.poll = ksb_fs_poll,
};

static struct ksb_dev_info ksb_fboot_dev[] = {