aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-11-11 06:26:08 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-27 14:11:29 -0500
commit10ee90743e99fb06a0881a35731263c1845275dd (patch)
tree5f5eb3a77ee533b2880e599fe229789ecd5d8f7a /drivers/misc
parent0f1d4ce5d0d09de5db92df7f51cdf7163bbb61f9 (diff)
mei: cleanup mei_irq_read_handler
1. Simplify function flow 2. Display errors in error or warnings level instead of debug. 3. Remove excessive debug messages Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/interrupt.c79
-rw-r--r--drivers/misc/mei/mei_dev.h10
2 files changed, 50 insertions, 39 deletions
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 7a95c07e59a6..9c8225b945c3 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -301,13 +301,11 @@ int mei_irq_read_handler(struct mei_device *dev,
301 struct mei_cl_cb *cmpl_list, s32 *slots) 301 struct mei_cl_cb *cmpl_list, s32 *slots)
302{ 302{
303 struct mei_msg_hdr *mei_hdr; 303 struct mei_msg_hdr *mei_hdr;
304 struct mei_cl *cl_pos = NULL; 304 struct mei_cl *cl;
305 struct mei_cl *cl_next = NULL; 305 int ret;
306 int ret = 0;
307 306
308 if (!dev->rd_msg_hdr) { 307 if (!dev->rd_msg_hdr) {
309 dev->rd_msg_hdr = mei_read_hdr(dev); 308 dev->rd_msg_hdr = mei_read_hdr(dev);
310 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
311 (*slots)--; 309 (*slots)--;
312 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots); 310 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
313 } 311 }
@@ -315,61 +313,64 @@ int mei_irq_read_handler(struct mei_device *dev,
315 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); 313 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr));
316 314
317 if (mei_hdr->reserved || !dev->rd_msg_hdr) { 315 if (mei_hdr->reserved || !dev->rd_msg_hdr) {
318 dev_dbg(&dev->pdev->dev, "corrupted message header.\n"); 316 dev_err(&dev->pdev->dev, "corrupted message header 0x%08X\n",
317 dev->rd_msg_hdr);
319 ret = -EBADMSG; 318 ret = -EBADMSG;
320 goto end; 319 goto end;
321 } 320 }
322 321
323 if (mei_hdr->host_addr || mei_hdr->me_addr) { 322 if (mei_slots2data(*slots) < mei_hdr->length) {
324 list_for_each_entry_safe(cl_pos, cl_next, 323 dev_err(&dev->pdev->dev, "less data available than length=%08x.\n",
325 &dev->file_list, link) {
326 dev_dbg(&dev->pdev->dev,
327 "list_for_each_entry_safe read host"
328 " client = %d, ME client = %d\n",
329 cl_pos->host_client_id,
330 cl_pos->me_client_id);
331 if (mei_cl_hbm_equal(cl_pos, mei_hdr))
332 break;
333 }
334
335 if (&cl_pos->link == &dev->file_list) {
336 dev_dbg(&dev->pdev->dev, "corrupted message header\n");
337 ret = -EBADMSG;
338 goto end;
339 }
340 }
341 if (((*slots) * sizeof(u32)) < mei_hdr->length) {
342 dev_err(&dev->pdev->dev,
343 "we can't read the message slots =%08x.\n",
344 *slots); 324 *slots);
345 /* we can't read the message */ 325 /* we can't read the message */
346 ret = -ERANGE; 326 ret = -ERANGE;
347 goto end; 327 goto end;
348 } 328 }
349 329
350 /* decide where to read the message too */ 330 /* HBM message */
351 if (!mei_hdr->host_addr) { 331 if (mei_hdr->host_addr == 0 && mei_hdr->me_addr == 0) {
352 dev_dbg(&dev->pdev->dev, "call mei_hbm_dispatch.\n");
353 mei_hbm_dispatch(dev, mei_hdr); 332 mei_hbm_dispatch(dev, mei_hdr);
354 dev_dbg(&dev->pdev->dev, "end mei_hbm_dispatch.\n"); 333 ret = 0;
355 } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id && 334 dev_dbg(&dev->pdev->dev, "mei_hbm_dispatch.\n");
356 (MEI_FILE_CONNECTED == dev->iamthif_cl.state) && 335 goto reset_slots;
357 (dev->iamthif_state == MEI_IAMTHIF_READING)) { 336 }
358 337
359 dev_dbg(&dev->pdev->dev, "call mei_amthif_irq_read_msg.\n"); 338 /* find recepient cl */
360 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); 339 list_for_each_entry(cl, &dev->file_list, link) {
340 if (mei_cl_hbm_equal(cl, mei_hdr)) {
341 cl_dbg(dev, cl, "got a message\n");
342 break;
343 }
344 }
345
346 /* if no recepient cl was found we assume corrupted header\n */
347 if (&cl->link == &dev->file_list) {
348 dev_err(&dev->pdev->dev, "no destination client found 0x%08X\n",
349 dev->rd_msg_hdr);
350 ret = -EBADMSG;
351 goto end;
352 }
353
354 if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
355 MEI_FILE_CONNECTED == dev->iamthif_cl.state &&
356 dev->iamthif_state == MEI_IAMTHIF_READING) {
361 357
362 ret = mei_amthif_irq_read_msg(dev, mei_hdr, cmpl_list); 358 ret = mei_amthif_irq_read_msg(dev, mei_hdr, cmpl_list);
363 if (ret) 359 if (ret) {
360 dev_err(&dev->pdev->dev, "mei_amthif_irq_read_msg failed = %d\n",
361 ret);
364 goto end; 362 goto end;
363 }
365 } else { 364 } else {
366 dev_dbg(&dev->pdev->dev, "call mei_cl_irq_read_msg.\n");
367 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr));
368 ret = mei_cl_irq_read_msg(dev, mei_hdr, cmpl_list); 365 ret = mei_cl_irq_read_msg(dev, mei_hdr, cmpl_list);
369 if (ret) 366 if (ret) {
367 dev_err(&dev->pdev->dev, "mei_cl_irq_read_msg failed = %d\n",
368 ret);
370 goto end; 369 goto end;
370 }
371 } 371 }
372 372
373reset_slots:
373 /* reset the number of slots and header */ 374 /* reset the number of slots and header */
374 *slots = mei_count_full_read_slots(dev); 375 *slots = mei_count_full_read_slots(dev);
375 dev->rd_msg_hdr = 0; 376 dev->rd_msg_hdr = 0;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 6f577bf5dc9d..4a7ee815fab1 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -456,6 +456,16 @@ static inline u32 mei_data2slots(size_t length)
456 return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4); 456 return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4);
457} 457}
458 458
459/**
460 * mei_slots2data- get data in slots - bytes from slots
461 * @slots - number of available slots
462 * returns - number of bytes in slots
463 */
464static inline u32 mei_slots2data(int slots)
465{
466 return slots * 4;
467}
468
459/* 469/*
460 * mei init function prototypes 470 * mei init function prototypes
461 */ 471 */