summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Samuelov <amirs@codeaurora.org>2017-08-23 09:46:19 +0300
committerGerrit - the friendly Code Review server <code-review@localhost>2017-08-23 00:02:48 -0700
commitf7c2ad0fb86838a1bf16f26d59edbbcd323edd15 (patch)
tree8ffffe4bc4a466f006e7b12057d246fc00e28d00
parent232b0f15cc8b29274630519d935278bdbc1dacc8 (diff)
spcom: return POLLERR when poll() has error
spcom_device_poll() return POLLERR rather than -EINVAL. Change-Id: Ifce0fa9c6a0a5136ae1d109543a9345ad77359bf Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
-rw-r--r--drivers/soc/qcom/spcom.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c
index 24de162e5401..bf89cb63ce4a 100644
--- a/drivers/soc/qcom/spcom.c
+++ b/drivers/soc/qcom/spcom.c
@@ -209,10 +209,8 @@ struct spcom_channel {
* Only one rx/tx transaction at a time (request + response).
*/
int ref_count;
- u32 pid;
- /* link UP/DOWN callback */
- void (*notify_link_state_cb)(bool up);
+ u32 pid; /* debug only to find user space application */
/* abort flags */
bool rx_abort;
@@ -739,6 +737,7 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec)
long timeleft;
const char *name;
void *handle;
+ u32 pid = current_pid();
mutex_lock(&ch->lock);
name = ch->name;
@@ -752,7 +751,7 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec)
}
pr_debug("ch [%s] opened by PID [%d], count [%d]\n",
- name, ch->pid, ch->ref_count);
+ name, pid, ch->ref_count);
pr_debug("Open channel [%s] timeout_msec [%d].\n", name, timeout_msec);
@@ -780,7 +779,7 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec)
/* init channel context after successful open */
ch->glink_handle = handle;
ch->ref_count++;
- ch->pid = current_pid();
+ ch->pid = pid;
ch->txn_id = INITIAL_TXN_ID;
mutex_unlock(&ch->lock);
@@ -2483,9 +2482,14 @@ static unsigned int spcom_device_poll(struct file *filp,
done = (spcom_dev->link_state == GLINK_LINK_STATE_UP);
break;
case SPCOM_POLL_CH_CONNECT:
+ /*
+ * ch is not expected to be NULL since user must call open()
+ * to get FD before it can call poll().
+ * open() will fail if no ch related to the char-device.
+ */
if (ch == NULL) {
pr_err("invalid ch pointer, file [%s].\n", name);
- return -EINVAL;
+ return POLLERR;
}
pr_debug("ch [%s] SPCOM_POLL_CH_CONNECT.\n", name);
if (wait) {
@@ -2786,7 +2790,7 @@ static int __init spcom_init(void)
{
int ret;
- pr_info("spcom driver version 1.1 17-July-2017.\n");
+ pr_info("spcom driver version 1.2 23-Aug-2017.\n");
ret = platform_driver_register(&spcom_driver);
if (ret)