mei: don't of list_for_each_entry_safe when not deleting
authorTomas Winkler <tomas.winkler@intel.com>
Mon, 17 Feb 2014 13:13:25 +0000 (15:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Feb 2014 18:06:08 +0000 (10:06 -0800)
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>
drivers/misc/mei/amthif.c
drivers/misc/mei/bus.c
drivers/misc/mei/client.c
drivers/misc/mei/hbm.c
drivers/misc/mei/interrupt.c

index c0fc23f16496489a609358e75433159199162c6c..61275e6e839cd00ebaf731ef291c0d98a240e8d4 100644 (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 file *file)
 {
-       struct mei_cl_cb *pos = NULL;
-       struct mei_cl_cb *next = NULL;
+       struct mei_cl_cb *cb;
 
-       list_for_each_entry_safe(pos, next,
-                               &dev->amthif_rd_complete_list.list, list) {
-               if (pos->cl && pos->cl == &dev->iamthif_cl &&
-                       pos->file_object == file)
-                       return pos;
+       list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) {
+               if (cb->cl && cb->cl == &dev->iamthif_cl &&
+                       cb->file_object == file)
+                       return cb;
        }
        return NULL;
 }
index cf4cc0bf2b17d4c8a574d49721062a0ba8860d5d..463ae51fb708ff0f7324ba054518bc42f2de1fdd 100644 (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,
                                                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))
                        return cl;
        }
index 3e62176a19a51556c53a4bc08cf679415096620d..fdc25595534162e1efec93f5c26880e83f87b8b3 100644 (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_device *dev = cl->dev;
-       struct mei_cl_cb *cb = NULL;
-       struct mei_cl_cb *next = NULL;
+       struct mei_cl_cb *cb;
 
-       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))
                        return cb;
        return NULL;
@@ -458,17 +457,17 @@ free:
 bool mei_cl_is_other_connecting(struct mei_cl *cl)
 {
        struct mei_device *dev;
-       struct mei_cl *pos;
-       struct mei_cl *next;
+       struct mei_cl *ocl; /* the other client */
 
        if (WARN_ON(!cl || !cl->dev))
                return false;
 
        dev = cl->dev;
 
-       list_for_each_entry_safe(pos, next, &dev->file_list, link) {
-               if ((pos->state == MEI_FILE_CONNECTING) &&
-                   (pos != cl) && cl->me_client_id == pos->me_client_id)
+       list_for_each_entry(ocl, &dev->file_list, link) {
+               if (ocl->state == MEI_FILE_CONNECTING &&
+                   ocl != cl &&
+                   cl->me_client_id == ocl->me_client_id)
                        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)
 {
-       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->mei_flow_ctrl_creds = 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)
 {
-       struct mei_cl *cl, *next;
-       list_for_each_entry_safe(cl, next, &dev->file_list, link) {
+       struct mei_cl *cl;
+       list_for_each_entry(cl, &dev->file_list, link) {
                if (waitqueue_active(&cl->rx_wait)) {
                        cl_dbg(dev, cl, "Waking up reading client!\n");
                        wake_up_interruptible(&cl->rx_wait);
index 7e99e41496260a496b2a16eaa99dd12c611fb50e..a28cc928fb02aec1ab28c3dd6de9524defbd2a14 100644 (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,
                struct hbm_flow_control *flow_control)
 {
-       struct mei_cl *cl = NULL;
-       struct mei_cl *next = NULL;
+       struct mei_cl *cl;
 
        if (!flow_control->host_addr) {
                /* single receive buffer */
@@ -390,7 +389,7 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
        }
 
        /* 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)) {
                        cl->mei_flow_ctrl_creds++;
                        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,
                struct hbm_client_connect_request *disconnect_req)
 {
-       struct mei_cl *cl, *next;
+       struct mei_cl *cl;
        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)) {
                        dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
                                        disconnect_req->host_addr,
index 61ceb781cd207f1716d7e738219cb36f8377173d..6c4597e9b9973f681ee1cd894cf37abb1a37b426 100644 (file)
@@ -574,8 +574,7 @@ EXPORT_SYMBOL_GPL(mei_irq_write_handler);
 void mei_timer(struct work_struct *work)
 {
        unsigned long timeout;
-       struct mei_cl *cl_pos = NULL;
-       struct mei_cl *cl_next = NULL;
+       struct mei_cl *cl;
        struct mei_cl_cb  *cb_pos = NULL;
        struct mei_cl_cb  *cb_next = NULL;
 
@@ -603,9 +602,9 @@ void mei_timer(struct work_struct *work)
                goto out;
 
        /*** connect/disconnect timeouts ***/
-       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
-               if (cl_pos->timer_count) {
-                       if (--cl_pos->timer_count == 0) {
+       list_for_each_entry(cl, &dev->file_list, link) {
+               if (cl->timer_count) {
+                       if (--cl->timer_count == 0) {
                                dev_err(&dev->pdev->dev, "timer: connect/disconnect timeout.\n");
                                mei_reset(dev);
                                goto out;
@@ -655,10 +654,10 @@ void mei_timer(struct work_struct *work)
                        list_for_each_entry_safe(cb_pos, cb_next,
                                &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. */
-                               if (cl_pos == &dev->iamthif_cl)
+                               if (cl == &dev->iamthif_cl)
                                        list_del(&cb_pos->list);
                        }
                        mei_io_cb_free(dev->iamthif_current_cb);