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>
This commit is contained in:
Tomas Winkler 2014-02-17 15:13:25 +02:00 committed by Greg Kroah-Hartman
parent 12d0066526
commit 31f88f5739
5 changed files with 28 additions and 33 deletions

View File

@ -133,14 +133,12 @@ int mei_amthif_host_init(struct mei_device *dev)
struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
struct file *file) struct file *file)
{ {
struct mei_cl_cb *pos = NULL; struct mei_cl_cb *cb;
struct mei_cl_cb *next = NULL;
list_for_each_entry_safe(pos, next, list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) {
&dev->amthif_rd_complete_list.list, list) { if (cb->cl && cb->cl == &dev->iamthif_cl &&
if (pos->cl && pos->cl == &dev->iamthif_cl && cb->file_object == file)
pos->file_object == file) return cb;
return pos;
} }
return NULL; return NULL;
} }

View File

@ -145,9 +145,9 @@ static struct device_type mei_cl_device_type = {
static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev, static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev,
uuid_le uuid) uuid_le uuid)
{ {
struct mei_cl *cl, *next; struct mei_cl *cl;
list_for_each_entry_safe(cl, next, &dev->device_list, device_link) { list_for_each_entry(cl, &dev->device_list, device_link) {
if (!uuid_le_cmp(uuid, cl->device_uuid)) if (!uuid_le_cmp(uuid, cl->device_uuid))
return cl; return cl;
} }

View File

@ -251,10 +251,9 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev)
struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl) struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)
{ {
struct mei_device *dev = cl->dev; struct mei_device *dev = cl->dev;
struct mei_cl_cb *cb = NULL; struct mei_cl_cb *cb;
struct mei_cl_cb *next = NULL;
list_for_each_entry_safe(cb, next, &dev->read_list.list, list) list_for_each_entry(cb, &dev->read_list.list, list)
if (mei_cl_cmp_id(cl, cb->cl)) if (mei_cl_cmp_id(cl, cb->cl))
return cb; return cb;
return NULL; return NULL;
@ -458,17 +457,17 @@ free:
bool mei_cl_is_other_connecting(struct mei_cl *cl) bool mei_cl_is_other_connecting(struct mei_cl *cl)
{ {
struct mei_device *dev; struct mei_device *dev;
struct mei_cl *pos; struct mei_cl *ocl; /* the other client */
struct mei_cl *next;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return false; return false;
dev = cl->dev; dev = cl->dev;
list_for_each_entry_safe(pos, next, &dev->file_list, link) { list_for_each_entry(ocl, &dev->file_list, link) {
if ((pos->state == MEI_FILE_CONNECTING) && if (ocl->state == MEI_FILE_CONNECTING &&
(pos != cl) && cl->me_client_id == pos->me_client_id) ocl != cl &&
cl->me_client_id == ocl->me_client_id)
return true; return true;
} }
@ -901,9 +900,9 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
void mei_cl_all_disconnect(struct mei_device *dev) void mei_cl_all_disconnect(struct mei_device *dev)
{ {
struct mei_cl *cl, *next; struct mei_cl *cl;
list_for_each_entry_safe(cl, next, &dev->file_list, link) { list_for_each_entry(cl, &dev->file_list, link) {
cl->state = MEI_FILE_DISCONNECTED; cl->state = MEI_FILE_DISCONNECTED;
cl->mei_flow_ctrl_creds = 0; cl->mei_flow_ctrl_creds = 0;
cl->timer_count = 0; cl->timer_count = 0;
@ -918,8 +917,8 @@ void mei_cl_all_disconnect(struct mei_device *dev)
*/ */
void mei_cl_all_wakeup(struct mei_device *dev) void mei_cl_all_wakeup(struct mei_device *dev)
{ {
struct mei_cl *cl, *next; struct mei_cl *cl;
list_for_each_entry_safe(cl, next, &dev->file_list, link) { list_for_each_entry(cl, &dev->file_list, link) {
if (waitqueue_active(&cl->rx_wait)) { if (waitqueue_active(&cl->rx_wait)) {
cl_dbg(dev, cl, "Waking up reading client!\n"); cl_dbg(dev, cl, "Waking up reading client!\n");
wake_up_interruptible(&cl->rx_wait); wake_up_interruptible(&cl->rx_wait);

View File

@ -380,8 +380,7 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
static void mei_hbm_cl_flow_control_res(struct mei_device *dev, static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
struct hbm_flow_control *flow_control) struct hbm_flow_control *flow_control)
{ {
struct mei_cl *cl = NULL; struct mei_cl *cl;
struct mei_cl *next = NULL;
if (!flow_control->host_addr) { if (!flow_control->host_addr) {
/* single receive buffer */ /* single receive buffer */
@ -390,7 +389,7 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
} }
/* normal connection */ /* normal connection */
list_for_each_entry_safe(cl, next, &dev->file_list, link) { list_for_each_entry(cl, &dev->file_list, link) {
if (mei_hbm_cl_addr_equal(cl, flow_control)) { if (mei_hbm_cl_addr_equal(cl, flow_control)) {
cl->mei_flow_ctrl_creds++; cl->mei_flow_ctrl_creds++;
dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n", 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,
static int mei_hbm_fw_disconnect_req(struct mei_device *dev, static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
struct hbm_client_connect_request *disconnect_req) struct hbm_client_connect_request *disconnect_req)
{ {
struct mei_cl *cl, *next; struct mei_cl *cl;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
list_for_each_entry_safe(cl, next, &dev->file_list, link) { list_for_each_entry(cl, &dev->file_list, link) {
if (mei_hbm_cl_addr_equal(cl, disconnect_req)) { if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n", dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
disconnect_req->host_addr, disconnect_req->host_addr,

View File

@ -574,8 +574,7 @@ EXPORT_SYMBOL_GPL(mei_irq_write_handler);
void mei_timer(struct work_struct *work) void mei_timer(struct work_struct *work)
{ {
unsigned long timeout; unsigned long timeout;
struct mei_cl *cl_pos = NULL; struct mei_cl *cl;
struct mei_cl *cl_next = NULL;
struct mei_cl_cb *cb_pos = NULL; struct mei_cl_cb *cb_pos = NULL;
struct mei_cl_cb *cb_next = NULL; struct mei_cl_cb *cb_next = NULL;
@ -603,9 +602,9 @@ void mei_timer(struct work_struct *work)
goto out; goto out;
/*** connect/disconnect timeouts ***/ /*** connect/disconnect timeouts ***/
list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { list_for_each_entry(cl, &dev->file_list, link) {
if (cl_pos->timer_count) { if (cl->timer_count) {
if (--cl_pos->timer_count == 0) { if (--cl->timer_count == 0) {
dev_err(&dev->pdev->dev, "timer: connect/disconnect timeout.\n"); dev_err(&dev->pdev->dev, "timer: connect/disconnect timeout.\n");
mei_reset(dev); mei_reset(dev);
goto out; goto out;
@ -655,10 +654,10 @@ void mei_timer(struct work_struct *work)
list_for_each_entry_safe(cb_pos, cb_next, list_for_each_entry_safe(cb_pos, cb_next,
&dev->amthif_rd_complete_list.list, list) { &dev->amthif_rd_complete_list.list, list) {
cl_pos = cb_pos->file_object->private_data; cl = cb_pos->file_object->private_data;
/* Finding the AMTHI entry. */ /* Finding the AMTHI entry. */
if (cl_pos == &dev->iamthif_cl) if (cl == &dev->iamthif_cl)
list_del(&cb_pos->list); list_del(&cb_pos->list);
} }
mei_io_cb_free(dev->iamthif_current_cb); mei_io_cb_free(dev->iamthif_current_cb);