diff options
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r-- | drivers/misc/mei/main.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index e1bf54481fd6..9d0b7050c79a 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -182,32 +182,36 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, | |||
182 | goto out; | 182 | goto out; |
183 | } | 183 | } |
184 | 184 | ||
185 | if (rets == -EBUSY && | ||
186 | !mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, file)) { | ||
187 | rets = -ENOMEM; | ||
188 | goto out; | ||
189 | } | ||
190 | 185 | ||
191 | do { | 186 | again: |
192 | mutex_unlock(&dev->device_lock); | 187 | mutex_unlock(&dev->device_lock); |
193 | 188 | if (wait_event_interruptible(cl->rx_wait, | |
194 | if (wait_event_interruptible(cl->rx_wait, | 189 | !list_empty(&cl->rd_completed) || |
195 | (!list_empty(&cl->rd_completed)) || | 190 | !mei_cl_is_connected(cl))) { |
196 | (!mei_cl_is_connected(cl)))) { | 191 | if (signal_pending(current)) |
192 | return -EINTR; | ||
193 | return -ERESTARTSYS; | ||
194 | } | ||
195 | mutex_lock(&dev->device_lock); | ||
197 | 196 | ||
198 | if (signal_pending(current)) | 197 | if (!mei_cl_is_connected(cl)) { |
199 | return -EINTR; | 198 | rets = -ENODEV; |
200 | return -ERESTARTSYS; | 199 | goto out; |
201 | } | 200 | } |
202 | 201 | ||
203 | mutex_lock(&dev->device_lock); | 202 | cb = mei_cl_read_cb(cl, file); |
204 | if (!mei_cl_is_connected(cl)) { | 203 | if (!cb) { |
205 | rets = -ENODEV; | 204 | /* |
206 | goto out; | 205 | * For amthif all the waiters are woken up, |
207 | } | 206 | * but only fp with matching cb->fp get the cb, |
207 | * the others have to return to wait on read. | ||
208 | */ | ||
209 | if (cl == &dev->iamthif_cl) | ||
210 | goto again; | ||
208 | 211 | ||
209 | cb = mei_cl_read_cb(cl, file); | 212 | rets = 0; |
210 | } while (!cb); | 213 | goto out; |
214 | } | ||
211 | 215 | ||
212 | copy_buffer: | 216 | copy_buffer: |
213 | /* now copy the data to user space */ | 217 | /* now copy the data to user space */ |