public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Akinobu Mita <mita@miraclelinux.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Ram Pai <linuxram@us.ibm.com>,
	Akinobu Mita <mita@miraclelinux.com>
Subject: [patch 5/8] core: use list_move()
Date: Thu, 30 Mar 2006 16:16:10 +0800	[thread overview]
Message-ID: <20060330081730.601566000@localhost.localdomain> (raw)
In-Reply-To: 20060330081605.085383000@localhost.localdomain

[-- Attachment #1: list-move-core.patch --]
[-- Type: text/plain, Size: 6319 bytes --]

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: Akinobu Mita <mita@miraclelinux.com>

 drivers/base/power/resume.c  |    6 ++----
 drivers/base/power/suspend.c |   13 +++++--------
 fs/dcache.c                  |    3 +--
 fs/libfs.c                   |   10 ++++------
 fs/namespace.c               |    6 ++----
 fs/pnode.c                   |    9 +++------
 fs/sysfs/dir.c               |   10 ++++------
 mm/swap.c                    |    3 +--
 8 files changed, 22 insertions(+), 38 deletions(-)

Index: 2.6-git/fs/dcache.c
===================================================================
--- 2.6-git.orig/fs/dcache.c
+++ 2.6-git/fs/dcache.c
@@ -468,8 +468,7 @@ void shrink_dcache_sb(struct super_block
 		dentry = list_entry(tmp, struct dentry, d_lru);
 		if (dentry->d_sb != sb)
 			continue;
-		list_del(tmp);
-		list_add(tmp, &dentry_unused);
+		list_move(tmp, &dentry_unused);
 	}
 
 	/*
Index: 2.6-git/fs/libfs.c
===================================================================
--- 2.6-git.orig/fs/libfs.c
+++ 2.6-git/fs/libfs.c
@@ -149,10 +149,9 @@ int dcache_readdir(struct file * filp, v
 			/* fallthrough */
 		default:
 			spin_lock(&dcache_lock);
-			if (filp->f_pos == 2) {
-				list_del(q);
-				list_add(q, &dentry->d_subdirs);
-			}
+			if (filp->f_pos == 2)
+				list_move(q, &dentry->d_subdirs);
+
 			for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
 				struct dentry *next;
 				next = list_entry(p, struct dentry, d_u.d_child);
@@ -164,8 +163,7 @@ int dcache_readdir(struct file * filp, v
 					return 0;
 				spin_lock(&dcache_lock);
 				/* next is still alive */
-				list_del(q);
-				list_add(q, p);
+				list_move(q, p);
 				p = q;
 				filp->f_pos++;
 			}
Index: 2.6-git/fs/namespace.c
===================================================================
--- 2.6-git.orig/fs/namespace.c
+++ 2.6-git/fs/namespace.c
@@ -517,10 +517,8 @@ void umount_tree(struct vfsmount *mnt, i
 {
 	struct vfsmount *p;
 
-	for (p = mnt; p; p = next_mnt(p, mnt)) {
-		list_del(&p->mnt_hash);
-		list_add(&p->mnt_hash, kill);
-	}
+	for (p = mnt; p; p = next_mnt(p, mnt))
+		list_move(&p->mnt_hash, kill);
 
 	if (propagate)
 		propagate_umount(kill);
Index: 2.6-git/fs/pnode.c
===================================================================
--- 2.6-git.orig/fs/pnode.c
+++ 2.6-git/fs/pnode.c
@@ -53,8 +53,7 @@ static int do_make_slave(struct vfsmount
 	if (master) {
 		list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
 			slave_mnt->mnt_master = master;
-		list_del(&mnt->mnt_slave);
-		list_add(&mnt->mnt_slave, &master->mnt_slave_list);
+		list_move(&mnt->mnt_slave, &master->mnt_slave_list);
 		list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
 		INIT_LIST_HEAD(&mnt->mnt_slave_list);
 	} else {
@@ -283,10 +282,8 @@ static void __propagate_umount(struct vf
 		 * umount the child only if the child has no
 		 * other children
 		 */
-		if (child && list_empty(&child->mnt_mounts)) {
-			list_del(&child->mnt_hash);
-			list_add_tail(&child->mnt_hash, &mnt->mnt_hash);
-		}
+		if (child && list_empty(&child->mnt_mounts))
+			list_move_tail(&child->mnt_hash, &mnt->mnt_hash);
 	}
 }
 
Index: 2.6-git/fs/sysfs/dir.c
===================================================================
--- 2.6-git.orig/fs/sysfs/dir.c
+++ 2.6-git/fs/sysfs/dir.c
@@ -429,10 +429,9 @@ static int sysfs_readdir(struct file * f
 			i++;
 			/* fallthrough */
 		default:
-			if (filp->f_pos == 2) {
-				list_del(q);
-				list_add(q, &parent_sd->s_children);
-			}
+			if (filp->f_pos == 2)
+				list_move(q, &parent_sd->s_children);
+
 			for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
 				struct sysfs_dirent *next;
 				const char * name;
@@ -454,8 +453,7 @@ static int sysfs_readdir(struct file * f
 						 dt_type(next)) < 0)
 					return 0;
 
-				list_del(q);
-				list_add(q, p);
+				list_move(q, p);
 				p = q;
 				filp->f_pos++;
 			}
Index: 2.6-git/mm/swap.c
===================================================================
--- 2.6-git.orig/mm/swap.c
+++ 2.6-git/mm/swap.c
@@ -86,8 +86,7 @@ int rotate_reclaimable_page(struct page 
 	zone = page_zone(page);
 	spin_lock_irqsave(&zone->lru_lock, flags);
 	if (PageLRU(page) && !PageActive(page)) {
-		list_del(&page->lru);
-		list_add_tail(&page->lru, &zone->inactive_list);
+		list_move_tail(&page->lru, &zone->inactive_list);
 		inc_page_state(pgrotated);
 	}
 	if (!test_clear_page_writeback(page))
Index: 2.6-git/drivers/base/power/resume.c
===================================================================
--- 2.6-git.orig/drivers/base/power/resume.c
+++ 2.6-git/drivers/base/power/resume.c
@@ -49,8 +49,7 @@ void dpm_resume(void)
 		struct device * dev = to_device(entry);
 
 		get_device(dev);
-		list_del_init(entry);
-		list_add_tail(entry, &dpm_active);
+		list_move_tail(entry, &dpm_active);
 
 		up(&dpm_list_sem);
 		if (!dev->power.prev_state.event)
@@ -97,8 +96,7 @@ void dpm_power_up(void)
 		struct device * dev = to_device(entry);
 
 		get_device(dev);
-		list_del_init(entry);
-		list_add_tail(entry, &dpm_active);
+		list_move_tail(entry, &dpm_active);
 		resume_device(dev);
 		put_device(dev);
 	}
Index: 2.6-git/drivers/base/power/suspend.c
===================================================================
--- 2.6-git.orig/drivers/base/power/suspend.c
+++ 2.6-git/drivers/base/power/suspend.c
@@ -101,12 +101,10 @@ int device_suspend(pm_message_t state)
 		/* Check if the device got removed */
 		if (!list_empty(&dev->power.entry)) {
 			/* Move it to the dpm_off or dpm_off_irq list */
-			if (!error) {
-				list_del(&dev->power.entry);
-				list_add(&dev->power.entry, &dpm_off);
-			} else if (error == -EAGAIN) {
-				list_del(&dev->power.entry);
-				list_add(&dev->power.entry, &dpm_off_irq);
+			if (!error)
+				list_move(&dev->power.entry, &dpm_off);
+			else if (error == -EAGAIN) {
+				list_move(&dev->power.entry, &dpm_off_irq);
 				error = 0;
 			}
 		}
@@ -124,8 +122,7 @@ int device_suspend(pm_message_t state)
 		 */
 		while (!list_empty(&dpm_off_irq)) {
 			struct list_head * entry = dpm_off_irq.next;
-			list_del(entry);
-			list_add(entry, &dpm_off);
+			list_move(entry, &dpm_off);
 		}
 		dpm_resume();
 	}

--

  parent reply	other threads:[~2006-03-30  8:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30  8:16 [patch 0/8] list.h related cleanups Akinobu Mita
2006-03-30  8:16 ` [patch 1/8] introduce hlist_move_head() Akinobu Mita
2006-03-30  8:16 ` [patch 2/8] use hlist_move_head() Akinobu Mita
2006-04-10  8:22   ` Andrew Morton
2006-04-10  9:53     ` Neil Brown
2006-03-30  8:16 ` [patch 3/8] use list_add_tail() instead of list_add() Akinobu Mita
2006-03-30  8:26   ` Karsten Keil
2006-03-30  8:30   ` Jan Kara
2006-03-30 10:25     ` David Woodhouse
2006-03-31  3:54   ` Akinobu Mita
2006-03-30  8:16 ` [patch 4/8] arch: use list_move() Akinobu Mita
2006-03-30  8:16 ` Akinobu Mita [this message]
2006-03-30  8:16 ` [patch 6/8] net/rxrpc: " Akinobu Mita
2006-03-30 10:17   ` David Howells
2006-03-30  8:16 ` [patch 7/8] drivers: " Akinobu Mita
2006-03-30 12:11   ` Matthew Wilcox
2006-03-30  8:16 ` [patch 8/8] fs: " Akinobu Mita
2006-03-30  8:22   ` [-mm patch] reiser4fs: " Akinobu Mita
2006-03-30 10:18   ` [patch 8/8] fs: " David Howells
2006-03-30 19:07   ` Joel Becker
2006-04-03  1:04     ` Ian Kent
2006-03-30 19:15   ` Mark Fasheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060330081730.601566000@localhost.localdomain \
    --to=mita@miraclelinux.com \
    --cc=akpm@osdl.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox