diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2014-02-17 08:13:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-18 13:06:08 -0500 |
commit | 31f88f5739e966cb3c524083e2d19b423ece3585 (patch) | |
tree | 107ffaf65a3000ec8592164a91e084cc6d155a6d | |
parent | 12d0066526f386538de80b4d86d2008461b36674 (diff) |
mei: don't of list_for_each_entry_safe when not deleting
We can use simply list_for_each_entry if there is no
entry removal
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/mei/amthif.c | 12 | ||||
-rw-r--r-- | drivers/misc/mei/bus.c | 4 | ||||
-rw-r--r-- | drivers/misc/mei/client.c | 23 | ||||
-rw-r--r-- | drivers/misc/mei/hbm.c | 9 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 13 |
5 files changed, 28 insertions, 33 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index c0fc23f16496..61275e6e839c 100644 --- a/drivers/misc/mei/amthif.c +++ b/drivers/misc/mei/amthif.c | |||
@@ -133,14 +133,12 @@ int mei_amthif_host_init(struct mei_device *dev) | |||
133 | struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, | 133 | struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, |
134 | struct file *file) | 134 | struct file *file) |
135 | { | 135 | { |
136 | struct mei_cl_cb *pos = NULL; | 136 | struct mei_cl_cb *cb; |
137 | struct mei_cl_cb *next = NULL; | ||
138 | 137 | ||
139 | list_for_each_entry_safe(pos, next, | 138 | list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) { |
140 | &dev->amthif_rd_complete_list.list, list) { | 139 | if (cb->cl && cb->cl == &dev->iamthif_cl && |
141 | if (pos->cl && pos->cl == &dev->iamthif_cl && | 140 | cb->file_object == file) |
142 | pos->file_object == file) | 141 | return cb; |
143 | return pos; | ||
144 | } | 142 | } |
145 | return NULL; | 143 | return NULL; |
146 | } | 144 | } |
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index cf4cc0bf2b17..463ae51fb708 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -145,9 +145,9 @@ static struct device_type mei_cl_device_type = { | |||
145 | static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev, | 145 | static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev, |
146 | uuid_le uuid) | 146 | uuid_le uuid) |
147 | { | 147 | { |
148 | struct mei_cl *cl, *next; | 148 | struct mei_cl *cl; |
149 | 149 | ||
150 | list_for_each_entry_safe(cl, next, &dev->device_list, device_link) { | 150 | list_for_each_entry(cl, &dev->device_list, device_link) { |
151 | if (!uuid_le_cmp(uuid, cl->device_uuid)) | 151 | if (!uuid_le_cmp(uuid, cl->device_uuid)) |
152 | return cl; | 152 | return cl; |
153 | } | 153 | } |
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index 3e62176a19a5..fdc255955341 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -251,10 +251,9 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev) | |||
251 | struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl) | 251 | struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl) |
252 | { | 252 | { |
253 | struct mei_device *dev = cl->dev; | 253 | struct mei_device *dev = cl->dev; |
254 | struct mei_cl_cb *cb = NULL; | 254 | struct mei_cl_cb *cb; |
255 | struct mei_cl_cb *next = NULL; | ||
256 | 255 | ||
257 | list_for_each_entry_safe(cb, next, &dev->read_list.list, list) | 256 | list_for_each_entry(cb, &dev->read_list.list, list) |
258 | if (mei_cl_cmp_id(cl, cb->cl)) | 257 | if (mei_cl_cmp_id(cl, cb->cl)) |
259 | return cb; | 258 | return cb; |
260 | return NULL; | 259 | return NULL; |
@@ -458,17 +457,17 @@ free: | |||
458 | bool mei_cl_is_other_connecting(struct mei_cl *cl) | 457 | bool mei_cl_is_other_connecting(struct mei_cl *cl) |
459 | { | 458 | { |
460 | struct mei_device *dev; | 459 | struct mei_device *dev; |
461 | struct mei_cl *pos; | 460 | struct mei_cl *ocl; /* the other client */ |
462 | struct mei_cl *next; | ||
463 | 461 | ||
464 | if (WARN_ON(!cl || !cl->dev)) | 462 | if (WARN_ON(!cl || !cl->dev)) |
465 | return false; | 463 | return false; |
466 | 464 | ||
467 | dev = cl->dev; | 465 | dev = cl->dev; |
468 | 466 | ||
469 | list_for_each_entry_safe(pos, next, &dev->file_list, link) { | 467 | list_for_each_entry(ocl, &dev->file_list, link) { |
470 | if ((pos->state == MEI_FILE_CONNECTING) && | 468 | if (ocl->state == MEI_FILE_CONNECTING && |
471 | (pos != cl) && cl->me_client_id == pos->me_client_id) | 469 | ocl != cl && |
470 | cl->me_client_id == ocl->me_client_id) | ||
472 | return true; | 471 | return true; |
473 | 472 | ||
474 | } | 473 | } |
@@ -901,9 +900,9 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb) | |||
901 | 900 | ||
902 | void mei_cl_all_disconnect(struct mei_device *dev) | 901 | void mei_cl_all_disconnect(struct mei_device *dev) |
903 | { | 902 | { |
904 | struct mei_cl *cl, *next; | 903 | struct mei_cl *cl; |
905 | 904 | ||
906 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | 905 | list_for_each_entry(cl, &dev->file_list, link) { |
907 | cl->state = MEI_FILE_DISCONNECTED; | 906 | cl->state = MEI_FILE_DISCONNECTED; |
908 | cl->mei_flow_ctrl_creds = 0; | 907 | cl->mei_flow_ctrl_creds = 0; |
909 | cl->timer_count = 0; | 908 | cl->timer_count = 0; |
@@ -918,8 +917,8 @@ void mei_cl_all_disconnect(struct mei_device *dev) | |||
918 | */ | 917 | */ |
919 | void mei_cl_all_wakeup(struct mei_device *dev) | 918 | void mei_cl_all_wakeup(struct mei_device *dev) |
920 | { | 919 | { |
921 | struct mei_cl *cl, *next; | 920 | struct mei_cl *cl; |
922 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | 921 | list_for_each_entry(cl, &dev->file_list, link) { |
923 | if (waitqueue_active(&cl->rx_wait)) { | 922 | if (waitqueue_active(&cl->rx_wait)) { |
924 | cl_dbg(dev, cl, "Waking up reading client!\n"); | 923 | cl_dbg(dev, cl, "Waking up reading client!\n"); |
925 | wake_up_interruptible(&cl->rx_wait); | 924 | wake_up_interruptible(&cl->rx_wait); |
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index 7e99e4149626..a28cc928fb02 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c | |||
@@ -380,8 +380,7 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev, | |||
380 | static void mei_hbm_cl_flow_control_res(struct mei_device *dev, | 380 | static void mei_hbm_cl_flow_control_res(struct mei_device *dev, |
381 | struct hbm_flow_control *flow_control) | 381 | struct hbm_flow_control *flow_control) |
382 | { | 382 | { |
383 | struct mei_cl *cl = NULL; | 383 | struct mei_cl *cl; |
384 | struct mei_cl *next = NULL; | ||
385 | 384 | ||
386 | if (!flow_control->host_addr) { | 385 | if (!flow_control->host_addr) { |
387 | /* single receive buffer */ | 386 | /* single receive buffer */ |
@@ -390,7 +389,7 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev, | |||
390 | } | 389 | } |
391 | 390 | ||
392 | /* normal connection */ | 391 | /* normal connection */ |
393 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | 392 | list_for_each_entry(cl, &dev->file_list, link) { |
394 | if (mei_hbm_cl_addr_equal(cl, flow_control)) { | 393 | if (mei_hbm_cl_addr_equal(cl, flow_control)) { |
395 | cl->mei_flow_ctrl_creds++; | 394 | cl->mei_flow_ctrl_creds++; |
396 | dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n", | 395 | dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n", |
@@ -557,10 +556,10 @@ static void mei_hbm_cl_connect_res(struct mei_device *dev, | |||
557 | static int mei_hbm_fw_disconnect_req(struct mei_device *dev, | 556 | static int mei_hbm_fw_disconnect_req(struct mei_device *dev, |
558 | struct hbm_client_connect_request *disconnect_req) | 557 | struct hbm_client_connect_request *disconnect_req) |
559 | { | 558 | { |
560 | struct mei_cl *cl, *next; | 559 | struct mei_cl *cl; |
561 | struct mei_cl_cb *cb; | 560 | struct mei_cl_cb *cb; |
562 | 561 | ||
563 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | 562 | list_for_each_entry(cl, &dev->file_list, link) { |
564 | if (mei_hbm_cl_addr_equal(cl, disconnect_req)) { | 563 | if (mei_hbm_cl_addr_equal(cl, disconnect_req)) { |
565 | dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n", | 564 | dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n", |
566 | disconnect_req->host_addr, | 565 | disconnect_req->host_addr, |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 61ceb781cd20..6c4597e9b997 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -574,8 +574,7 @@ EXPORT_SYMBOL_GPL(mei_irq_write_handler); | |||
574 | void mei_timer(struct work_struct *work) | 574 | void mei_timer(struct work_struct *work) |
575 | { | 575 | { |
576 | unsigned long timeout; | 576 | unsigned long timeout; |
577 | struct mei_cl *cl_pos = NULL; | 577 | struct mei_cl *cl; |
578 | struct mei_cl *cl_next = NULL; | ||
579 | struct mei_cl_cb *cb_pos = NULL; | 578 | struct mei_cl_cb *cb_pos = NULL; |
580 | struct mei_cl_cb *cb_next = NULL; | 579 | struct mei_cl_cb *cb_next = NULL; |
581 | 580 | ||
@@ -603,9 +602,9 @@ void mei_timer(struct work_struct *work) | |||
603 | goto out; | 602 | goto out; |
604 | 603 | ||
605 | /*** connect/disconnect timeouts ***/ | 604 | /*** connect/disconnect timeouts ***/ |
606 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { | 605 | list_for_each_entry(cl, &dev->file_list, link) { |
607 | if (cl_pos->timer_count) { | 606 | if (cl->timer_count) { |
608 | if (--cl_pos->timer_count == 0) { | 607 | if (--cl->timer_count == 0) { |
609 | dev_err(&dev->pdev->dev, "timer: connect/disconnect timeout.\n"); | 608 | dev_err(&dev->pdev->dev, "timer: connect/disconnect timeout.\n"); |
610 | mei_reset(dev); | 609 | mei_reset(dev); |
611 | goto out; | 610 | goto out; |
@@ -655,10 +654,10 @@ void mei_timer(struct work_struct *work) | |||
655 | list_for_each_entry_safe(cb_pos, cb_next, | 654 | list_for_each_entry_safe(cb_pos, cb_next, |
656 | &dev->amthif_rd_complete_list.list, list) { | 655 | &dev->amthif_rd_complete_list.list, list) { |
657 | 656 | ||
658 | cl_pos = cb_pos->file_object->private_data; | 657 | cl = cb_pos->file_object->private_data; |
659 | 658 | ||
660 | /* Finding the AMTHI entry. */ | 659 | /* Finding the AMTHI entry. */ |
661 | if (cl_pos == &dev->iamthif_cl) | 660 | if (cl == &dev->iamthif_cl) |
662 | list_del(&cb_pos->list); | 661 | list_del(&cb_pos->list); |
663 | } | 662 | } |
664 | mei_io_cb_free(dev->iamthif_current_cb); | 663 | mei_io_cb_free(dev->iamthif_current_cb); |