Commit 1bfba4e8 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

[PATCH] core: use list_move()

This patch converts the combination of list_del(A) and list_add(A, B) to
list_move(A, B).

Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: default avatarAkinobu Mita <mita@miraclelinux.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a7addcea
...@@ -53,8 +53,7 @@ void dpm_resume(void) ...@@ -53,8 +53,7 @@ void dpm_resume(void)
struct device * dev = to_device(entry); struct device * dev = to_device(entry);
get_device(dev); get_device(dev);
list_del_init(entry); list_move_tail(entry, &dpm_active);
list_add_tail(entry, &dpm_active);
up(&dpm_list_sem); up(&dpm_list_sem);
if (!dev->power.prev_state.event) if (!dev->power.prev_state.event)
...@@ -101,8 +100,7 @@ void dpm_power_up(void) ...@@ -101,8 +100,7 @@ void dpm_power_up(void)
struct device * dev = to_device(entry); struct device * dev = to_device(entry);
get_device(dev); get_device(dev);
list_del_init(entry); list_move_tail(entry, &dpm_active);
list_add_tail(entry, &dpm_active);
resume_device(dev); resume_device(dev);
put_device(dev); put_device(dev);
} }
......
...@@ -116,12 +116,10 @@ int device_suspend(pm_message_t state) ...@@ -116,12 +116,10 @@ int device_suspend(pm_message_t state)
/* Check if the device got removed */ /* Check if the device got removed */
if (!list_empty(&dev->power.entry)) { if (!list_empty(&dev->power.entry)) {
/* Move it to the dpm_off or dpm_off_irq list */ /* Move it to the dpm_off or dpm_off_irq list */
if (!error) { if (!error)
list_del(&dev->power.entry); list_move(&dev->power.entry, &dpm_off);
list_add(&dev->power.entry, &dpm_off); else if (error == -EAGAIN) {
} else if (error == -EAGAIN) { list_move(&dev->power.entry, &dpm_off_irq);
list_del(&dev->power.entry);
list_add(&dev->power.entry, &dpm_off_irq);
error = 0; error = 0;
} }
} }
...@@ -139,8 +137,7 @@ int device_suspend(pm_message_t state) ...@@ -139,8 +137,7 @@ int device_suspend(pm_message_t state)
*/ */
while (!list_empty(&dpm_off_irq)) { while (!list_empty(&dpm_off_irq)) {
struct list_head * entry = dpm_off_irq.next; struct list_head * entry = dpm_off_irq.next;
list_del(entry); list_move(entry, &dpm_off);
list_add(entry, &dpm_off);
} }
dpm_resume(); dpm_resume();
} }
......
...@@ -522,8 +522,7 @@ void shrink_dcache_sb(struct super_block * sb) ...@@ -522,8 +522,7 @@ void shrink_dcache_sb(struct super_block * sb)
dentry = list_entry(tmp, struct dentry, d_lru); dentry = list_entry(tmp, struct dentry, d_lru);
if (dentry->d_sb != sb) if (dentry->d_sb != sb)
continue; continue;
list_del(tmp); list_move(tmp, &dentry_unused);
list_add(tmp, &dentry_unused);
} }
/* /*
......
...@@ -149,10 +149,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -149,10 +149,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
/* fallthrough */ /* fallthrough */
default: default:
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (filp->f_pos == 2) { if (filp->f_pos == 2)
list_del(q); list_move(q, &dentry->d_subdirs);
list_add(q, &dentry->d_subdirs);
}
for (p=q->next; p != &dentry->d_subdirs; p=p->next) { for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
struct dentry *next; struct dentry *next;
next = list_entry(p, struct dentry, d_u.d_child); next = list_entry(p, struct dentry, d_u.d_child);
...@@ -164,8 +163,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -164,8 +163,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
return 0; return 0;
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
/* next is still alive */ /* next is still alive */
list_del(q); list_move(q, p);
list_add(q, p);
p = q; p = q;
filp->f_pos++; filp->f_pos++;
} }
......
...@@ -526,10 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) ...@@ -526,10 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
{ {
struct vfsmount *p; struct vfsmount *p;
for (p = mnt; p; p = next_mnt(p, mnt)) { for (p = mnt; p; p = next_mnt(p, mnt))
list_del(&p->mnt_hash); list_move(&p->mnt_hash, kill);
list_add(&p->mnt_hash, kill);
}
if (propagate) if (propagate)
propagate_umount(kill); propagate_umount(kill);
......
...@@ -53,8 +53,7 @@ static int do_make_slave(struct vfsmount *mnt) ...@@ -53,8 +53,7 @@ static int do_make_slave(struct vfsmount *mnt)
if (master) { if (master) {
list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave) list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
slave_mnt->mnt_master = master; slave_mnt->mnt_master = master;
list_del(&mnt->mnt_slave); list_move(&mnt->mnt_slave, &master->mnt_slave_list);
list_add(&mnt->mnt_slave, &master->mnt_slave_list);
list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev); list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
INIT_LIST_HEAD(&mnt->mnt_slave_list); INIT_LIST_HEAD(&mnt->mnt_slave_list);
} else { } else {
...@@ -283,10 +282,8 @@ static void __propagate_umount(struct vfsmount *mnt) ...@@ -283,10 +282,8 @@ static void __propagate_umount(struct vfsmount *mnt)
* umount the child only if the child has no * umount the child only if the child has no
* other children * other children
*/ */
if (child && list_empty(&child->mnt_mounts)) { if (child && list_empty(&child->mnt_mounts))
list_del(&child->mnt_hash); list_move_tail(&child->mnt_hash, &mnt->mnt_hash);
list_add_tail(&child->mnt_hash, &mnt->mnt_hash);
}
} }
} }
......
...@@ -430,10 +430,9 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -430,10 +430,9 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
i++; i++;
/* fallthrough */ /* fallthrough */
default: default:
if (filp->f_pos == 2) { if (filp->f_pos == 2)
list_del(q); list_move(q, &parent_sd->s_children);
list_add(q, &parent_sd->s_children);
}
for (p=q->next; p!= &parent_sd->s_children; p=p->next) { for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
struct sysfs_dirent *next; struct sysfs_dirent *next;
const char * name; const char * name;
...@@ -455,8 +454,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -455,8 +454,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
dt_type(next)) < 0) dt_type(next)) < 0)
return 0; return 0;
list_del(q); list_move(q, p);
list_add(q, p);
p = q; p = q;
filp->f_pos++; filp->f_pos++;
} }
......
...@@ -86,8 +86,7 @@ int rotate_reclaimable_page(struct page *page) ...@@ -86,8 +86,7 @@ int rotate_reclaimable_page(struct page *page)
zone = page_zone(page); zone = page_zone(page);
spin_lock_irqsave(&zone->lru_lock, flags); spin_lock_irqsave(&zone->lru_lock, flags);
if (PageLRU(page) && !PageActive(page)) { if (PageLRU(page) && !PageActive(page)) {
list_del(&page->lru); list_move_tail(&page->lru, &zone->inactive_list);
list_add_tail(&page->lru, &zone->inactive_list);
inc_page_state(pgrotated); inc_page_state(pgrotated);
} }
if (!test_clear_page_writeback(page)) if (!test_clear_page_writeback(page))
......
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