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

Commit 88ba5e8e authored by Karthikeyan Ramasubramanian's avatar Karthikeyan Ramasubramanian Committed by Stephen Boyd
Browse files

msm: sdio_ctl: Update the driver to support poll operation



Poll operation is needed by user-space modules, to select among
multiple file descriptors for read/write operation.

CRs-Fixed: 357121
Change-Id: Iaa817c31bdfee7a1fcb3c5e94a805a526b71cd6c
Signed-off-by: default avatarKarthikeyan Ramasubramanian <kramasub@codeaurora.org>
parent 7e5c20a3
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -25,6 +25,7 @@
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <linux/workqueue.h>
#include <linux/poll.h>
#include <asm/ioctls.h>
#include <linux/platform_device.h>
#include <mach/msm_smd.h>
@@ -206,6 +207,34 @@ static long sdio_ctl_ioctl(struct file *file, unsigned int cmd,
	return ret;
}

static unsigned int sdio_ctl_poll(struct file *file, poll_table *wait)
{
	struct sdio_ctl_dev *sdio_ctl_devp;
	unsigned int mask = 0;

	sdio_ctl_devp = file->private_data;
	if (!sdio_ctl_devp) {
		pr_err("%s: on a NULL device\n", __func__);
		return POLLERR;
	}

	poll_wait(file, &sdio_ctl_devp->read_wait_queue, wait);
	mutex_lock(&sdio_ctl_devp->rx_lock);
	if (sdio_cmux_is_channel_reset(sdio_ctl_devp->id)) {
		mutex_unlock(&sdio_ctl_devp->rx_lock);
		pr_err("%s notifying reset for sdio_ctl_dev id:%d\n",
			__func__, sdio_ctl_devp->id);
		return POLLERR;
	}

	if (sdio_ctl_devp->read_avail > 0)
		mask |= POLLIN | POLLRDNORM;

	mutex_unlock(&sdio_ctl_devp->rx_lock);

	return mask;
}

ssize_t sdio_ctl_read(struct file *file,
		      char __user *buf,
		      size_t count,
@@ -417,6 +446,7 @@ static const struct file_operations sdio_ctl_fops = {
	.release = sdio_ctl_release,
	.read = sdio_ctl_read,
	.write = sdio_ctl_write,
	.poll = sdio_ctl_poll,
	.unlocked_ioctl = sdio_ctl_ioctl,
};