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>
This commit is contained in:
parent
232b0f15cc
commit
f7c2ad0fb8
1 changed files with 11 additions and 7 deletions
|
@ -209,10 +209,8 @@ struct spcom_channel {
|
||||||
* Only one rx/tx transaction at a time (request + response).
|
* Only one rx/tx transaction at a time (request + response).
|
||||||
*/
|
*/
|
||||||
int ref_count;
|
int ref_count;
|
||||||
u32 pid;
|
|
||||||
|
|
||||||
/* link UP/DOWN callback */
|
u32 pid; /* debug only to find user space application */
|
||||||
void (*notify_link_state_cb)(bool up);
|
|
||||||
|
|
||||||
/* abort flags */
|
/* abort flags */
|
||||||
bool rx_abort;
|
bool rx_abort;
|
||||||
|
@ -739,6 +737,7 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec)
|
||||||
long timeleft;
|
long timeleft;
|
||||||
const char *name;
|
const char *name;
|
||||||
void *handle;
|
void *handle;
|
||||||
|
u32 pid = current_pid();
|
||||||
|
|
||||||
mutex_lock(&ch->lock);
|
mutex_lock(&ch->lock);
|
||||||
name = ch->name;
|
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",
|
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);
|
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 */
|
/* init channel context after successful open */
|
||||||
ch->glink_handle = handle;
|
ch->glink_handle = handle;
|
||||||
ch->ref_count++;
|
ch->ref_count++;
|
||||||
ch->pid = current_pid();
|
ch->pid = pid;
|
||||||
ch->txn_id = INITIAL_TXN_ID;
|
ch->txn_id = INITIAL_TXN_ID;
|
||||||
|
|
||||||
mutex_unlock(&ch->lock);
|
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);
|
done = (spcom_dev->link_state == GLINK_LINK_STATE_UP);
|
||||||
break;
|
break;
|
||||||
case SPCOM_POLL_CH_CONNECT:
|
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) {
|
if (ch == NULL) {
|
||||||
pr_err("invalid ch pointer, file [%s].\n", name);
|
pr_err("invalid ch pointer, file [%s].\n", name);
|
||||||
return -EINVAL;
|
return POLLERR;
|
||||||
}
|
}
|
||||||
pr_debug("ch [%s] SPCOM_POLL_CH_CONNECT.\n", name);
|
pr_debug("ch [%s] SPCOM_POLL_CH_CONNECT.\n", name);
|
||||||
if (wait) {
|
if (wait) {
|
||||||
|
@ -2786,7 +2790,7 @@ static int __init spcom_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
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);
|
ret = platform_driver_register(&spcom_driver);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Add table
Reference in a new issue