Commit 46e4b9ec authored by Nicolas Saenz Julienne's avatar Nicolas Saenz Julienne Committed by Greg Kroah-Hartman

staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list

The resulting code is way more readeable and intuitive compared to plain
list_for_each.
Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9851968b
...@@ -280,16 +280,11 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) ...@@ -280,16 +280,11 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance)
"%s(%p): returning %d", __func__, instance, status); "%s(%p): returning %d", __func__, instance, status);
if (status == VCHIQ_SUCCESS) { if (status == VCHIQ_SUCCESS) {
struct list_head *pos, *next; struct bulk_waiter_node *waiter, *next;
list_for_each_safe(pos, next, list_for_each_entry_safe(waiter, next,
&instance->bulk_waiter_list) { &instance->bulk_waiter_list, list) {
struct bulk_waiter_node *waiter; list_del(&waiter->list);
waiter = list_entry(pos,
struct bulk_waiter_node,
list);
list_del(pos);
vchiq_log_info(vchiq_arm_log_level, vchiq_log_info(vchiq_arm_log_level,
"bulk_waiter - cleaned up %pK for pid %d", "bulk_waiter - cleaned up %pK for pid %d",
waiter, waiter->pid); waiter, waiter->pid);
...@@ -473,7 +468,6 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, ...@@ -473,7 +468,6 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data,
VCHIQ_SERVICE_T *service; VCHIQ_SERVICE_T *service;
VCHIQ_STATUS_T status; VCHIQ_STATUS_T status;
struct bulk_waiter_node *waiter = NULL; struct bulk_waiter_node *waiter = NULL;
struct list_head *pos;
service = find_service_by_handle(handle); service = find_service_by_handle(handle);
if (!service) if (!service)
...@@ -484,13 +478,9 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, ...@@ -484,13 +478,9 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data,
unlock_service(service); unlock_service(service);
mutex_lock(&instance->bulk_waiter_list_mutex); mutex_lock(&instance->bulk_waiter_list_mutex);
list_for_each(pos, &instance->bulk_waiter_list) { list_for_each_entry(waiter, &instance->bulk_waiter_list, list) {
if (list_entry(pos, struct bulk_waiter_node, if (waiter->pid == current->pid) {
list)->pid == current->pid) { list_del(&waiter->list);
waiter = list_entry(pos,
struct bulk_waiter_node,
list);
list_del(pos);
break; break;
} }
} }
...@@ -1135,21 +1125,16 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1135,21 +1125,16 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
args.userdata = &waiter->bulk_waiter; args.userdata = &waiter->bulk_waiter;
} else if (args.mode == VCHIQ_BULK_MODE_WAITING) { } else if (args.mode == VCHIQ_BULK_MODE_WAITING) {
struct list_head *pos;
mutex_lock(&instance->bulk_waiter_list_mutex); mutex_lock(&instance->bulk_waiter_list_mutex);
list_for_each(pos, &instance->bulk_waiter_list) { list_for_each_entry(waiter, &instance->bulk_waiter_list,
if (list_entry(pos, struct bulk_waiter_node, list) {
list)->pid == current->pid) { if (waiter->pid == current->pid) {
waiter = list_entry(pos, list_del(&waiter->list);
struct bulk_waiter_node,
list);
list_del(pos);
break; break;
} }
} }
mutex_unlock(&instance->bulk_waiter_list_mutex); mutex_unlock(&instance->bulk_waiter_list_mutex);
if (!waiter) { if (!waiter) {
...@@ -2158,16 +2143,11 @@ vchiq_release(struct inode *inode, struct file *file) ...@@ -2158,16 +2143,11 @@ vchiq_release(struct inode *inode, struct file *file)
vchiq_release_internal(instance->state, NULL); vchiq_release_internal(instance->state, NULL);
{ {
struct list_head *pos, *next; struct bulk_waiter_node *waiter, *next;
list_for_each_safe(pos, next,
&instance->bulk_waiter_list) {
struct bulk_waiter_node *waiter;
waiter = list_entry(pos, list_for_each_entry_safe(waiter, next,
struct bulk_waiter_node, &instance->bulk_waiter_list, list) {
list); list_del(&waiter->list);
list_del(pos);
vchiq_log_info(vchiq_arm_log_level, vchiq_log_info(vchiq_arm_log_level,
"bulk_waiter - cleaned up %pK for pid %d", "bulk_waiter - cleaned up %pK for pid %d",
waiter, waiter->pid); waiter, waiter->pid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment