diff options
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r-- | drivers/misc/mei/main.c | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 053139f61086..5e11b5b9b65d 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -194,7 +194,6 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, | |||
194 | struct mei_cl_cb *cb_pos = NULL; | 194 | struct mei_cl_cb *cb_pos = NULL; |
195 | struct mei_cl_cb *cb = NULL; | 195 | struct mei_cl_cb *cb = NULL; |
196 | struct mei_device *dev; | 196 | struct mei_device *dev; |
197 | int i; | ||
198 | int rets; | 197 | int rets; |
199 | int err; | 198 | int err; |
200 | 199 | ||
@@ -210,38 +209,26 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, | |||
210 | goto out; | 209 | goto out; |
211 | } | 210 | } |
212 | 211 | ||
213 | if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { | ||
214 | /* Do not allow to read watchdog client */ | ||
215 | i = mei_me_cl_by_uuid(dev, &mei_wd_guid); | ||
216 | if (i >= 0) { | ||
217 | struct mei_me_client *me_client = &dev->me_clients[i]; | ||
218 | if (cl->me_client_id == me_client->client_id) { | ||
219 | rets = -EBADF; | ||
220 | goto out; | ||
221 | } | ||
222 | } | ||
223 | } else { | ||
224 | cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT; | ||
225 | } | ||
226 | |||
227 | if (cl == &dev->iamthif_cl) { | 212 | if (cl == &dev->iamthif_cl) { |
228 | rets = mei_amthif_read(dev, file, ubuf, length, offset); | 213 | rets = mei_amthif_read(dev, file, ubuf, length, offset); |
229 | goto out; | 214 | goto out; |
230 | } | 215 | } |
231 | 216 | ||
232 | if (cl->read_cb && cl->read_cb->buf_idx > *offset) { | 217 | if (cl->read_cb) { |
233 | cb = cl->read_cb; | ||
234 | goto copy_buffer; | ||
235 | } else if (cl->read_cb && cl->read_cb->buf_idx > 0 && | ||
236 | cl->read_cb->buf_idx <= *offset) { | ||
237 | cb = cl->read_cb; | 218 | cb = cl->read_cb; |
238 | rets = 0; | 219 | /* read what left */ |
239 | goto free; | 220 | if (cb->buf_idx > *offset) |
240 | } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { | 221 | goto copy_buffer; |
241 | /*Offset needs to be cleaned for contiguous reads*/ | 222 | /* offset is beyond buf_idx we have no more data return 0 */ |
223 | if (cb->buf_idx > 0 && cb->buf_idx <= *offset) { | ||
224 | rets = 0; | ||
225 | goto free; | ||
226 | } | ||
227 | /* Offset needs to be cleaned for contiguous reads*/ | ||
228 | if (cb->buf_idx == 0 && *offset > 0) | ||
229 | *offset = 0; | ||
230 | } else if (*offset > 0) { | ||
242 | *offset = 0; | 231 | *offset = 0; |
243 | rets = 0; | ||
244 | goto out; | ||
245 | } | 232 | } |
246 | 233 | ||
247 | err = mei_cl_read_start(cl, length); | 234 | err = mei_cl_read_start(cl, length); |
@@ -420,16 +407,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
420 | if (rets) | 407 | if (rets) |
421 | goto out; | 408 | goto out; |
422 | 409 | ||
423 | cl->sm_state = 0; | ||
424 | if (length == 4 && | ||
425 | ((memcmp(mei_wd_state_independence_msg[0], | ||
426 | write_cb->request_buffer.data, 4) == 0) || | ||
427 | (memcmp(mei_wd_state_independence_msg[1], | ||
428 | write_cb->request_buffer.data, 4) == 0) || | ||
429 | (memcmp(mei_wd_state_independence_msg[2], | ||
430 | write_cb->request_buffer.data, 4) == 0))) | ||
431 | cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT; | ||
432 | |||
433 | if (cl == &dev->iamthif_cl) { | 410 | if (cl == &dev->iamthif_cl) { |
434 | rets = mei_amthif_write(dev, write_cb); | 411 | rets = mei_amthif_write(dev, write_cb); |
435 | 412 | ||