Skip to contentSkip to conversation

MTD: use list_for_each_entry()

PATCH In review [email protected] 3 participants 8 messages May 31, 2008 – Jun 4, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

cover MTD: use list_for_each_entry()

MTD: Use list_for_each_entry() instead of list_for_each() in add_mtd_device() and del_mtd_device()

Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#1 lore raw

PATCH 1/2 MTD: use list_for_each_entry() in add_mtd_device()

MTD: use list_for_each_entry() instead of list_for_each() in add_mtd_device()

drivers/mtd/mtdcore.c +2 -3
Index: linux-2.6/drivers/mtd/mtdcore.c
===================================================================
@@ -53,7 +53,7 @@
 
 	for (i=0; i < MAX_MTD_DEVICES; i++)
 		if (!mtd_table[i]) {
-			struct list_head *this;
+			struct mtd_notifier *not
 
 			mtd_table[i] = mtd;
 			mtd->index = i;
@@ -72,8 +72,7 @@
 			DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
 			/* No need to get a refcount on the module containing
 			   the notifier, since we hold the mtd_table_mutex */
-			list_for_each(this, &mtd_notifiers) {
-				struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
+			list_for_each_entry(not, &mtd_notifiers, list) {
 				not->add(mtd);
 			}
 
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#2 lore raw

Re: [patch 1/2] MTD: use list_for_each_entry() in add_mtd_device()

sorry, i forgot to tell quilt to refresh the patch, here comes the good one

--

MTD: use list_for_each_entry() instead of list_for_each() in add_mtd_device()

Index: linux-2.6/drivers/mtd/mtdcore.c
===================================================================
--- linux-2.6.orig/drivers/mtd/mtdcore.c 2008-05-31
15:31:17.000000000 +0200
+++ linux-2.6/drivers/mtd/mtdcore.c 2008-05-31 15:32:19.000000000
+0200
@@ -53,7 +53,7 @@

        for (i=0; i < MAX_MTD_DEVICES; i++)
                if (!mtd_table[i]) {

- struct list_head *this;
+ struct mtd_notifier *not;

                        mtd_table[i] = mtd;
                        mtd->index = i;

@@ -72,8 +72,7 @@
DEBUG(0, "mtd: Giving out device %d to
%s\n",i, mtd->name);
/* No need to get a refcount on the module
containing
the notifier, since we hold the
mtd_table_mutex */
- list_for_each(this, &mtd_notifiers) {
- struct mtd_notifier *not =
list_entry(this, struct mtd_notifier, list);
+ list_for_each_entry(not, &mtd_notifiers, list)

{
                                not->add(mtd);
                        }
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

    I am incapable of conceiving infinity, and yet I do not accept finity
                          (Simone de Beauvoir)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#3 lore raw

Re: [patch 1/2] MTD: use list_for_each_entry() in add_mtd_device()

Quoted 4 lines · Matthias Kaehlcke

MTD: use list_for_each_entry() instead of list_for_each() in add_mtd_device()

Chris Malley (added to Cc:) sent a patch converting all of drivers/mtd/ in a similar fashion. It should be on its way in, if dwmw2 hasn't missed it.

You might also want to check your mailer. This patch looks like bouquet of flowers that got stuck in an elevator door. ;)

Quoted 26 lines

Index: linux-2.6/drivers/mtd/mtdcore.c
===================================================================
--- linux-2.6.orig/drivers/mtd/mtdcore.c 2008-05-31
15:31:17.000000000 +0200
+++ linux-2.6/drivers/mtd/mtdcore.c 2008-05-31 15:32:19.000000000
+0200

drivers/mtd/mtdcore.c +1 -3
@@ -53,7 +53,7 @@
 
        for (i=0; i < MAX_MTD_DEVICES; i++)
                if (!mtd_table[i]) {
-                       struct list_head *this;
+                       struct mtd_notifier *not;
 
                        mtd_table[i] = mtd;
                        mtd->index = i;
@@ -72,8 +72,7 @@
                        DEBUG(0, "mtd: Giving out device %d to
 												%s\n",i, mtd->name);
                        /* No need to get a refcount on the module
 												containing
                           the notifier, since we hold the
 													 mtd_table_mutex */
-                       list_for_each(this, &mtd_notifiers) {
-                               struct mtd_notifier *not =

list_entry(this, struct mtd_notifier, list);
+ list_for_each_entry(not, &mtd_notifiers, list)

Quoted 3 lines
{
                                not->add(mtd);
                        }

Jörn

Signature · 4 lines
You ain't got no problem, Jules. I'm on the motherfucker. Go back in
there, chill them niggers out and wait for the Wolf, who should be
coming directly.
-- Marsellus Wallace
#4 lore raw

Re: [patch 1/2] MTD: use list_for_each_entry() in add_mtd_device()

El Sat, May 31, 2008 at 09:41:55PM +0200 Jörn Engel ha dit:

Quoted 9 lines · Matthias Kaehlcke
Quoted 4 lines

MTD: use list_for_each_entry() instead of list_for_each() in add_mtd_device()

Chris Malley (added to Cc:) sent a patch converting all of drivers/mtd/ in a similar fashion. It should be on its way in, if dwmw2 hasn't missed it.

fine :)

Quoted 2 lines

You might also want to check your mailer. This patch looks like bouquet of flowers that got stuck in an elevator door. ;)

thanks for the pointer. normally my mutt/emacs config doesn't cause this type of problems, i suppose i screwed it up myself somehow ...

Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

    The book of nature is written in the language of mathematics
                         (Galileo Galilei)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#5 lore raw

Re: [patch 1/2] MTD: use list_for_each_entry() in add_mtd_device()

In reply to [email protected]

drivers/mtd/mtdcore.c line 56

Quoted 2 lines · On Sat, 2008-05-31 at 15:28 +0200, [email protected] wrote:
drivers/mtd/mtdcore.c +1 -1
-                       struct list_head *this;
+                       struct mtd_notifier *not

That's not even going to compile, surely?

Signature · 1 line
dwmw2
#6 lore raw

Re: [patch 1/2] MTD: use list_for_each_entry() in add_mtd_device()

El Wed, Jun 04, 2008 at 05:34:08PM +0100 David Woodhouse ha dit:

Quoted 5 lines · On Sat, 2008-05-31 at 15:28 +0200, [email protected] wrote:

drivers/mtd/mtdcore.c line 56

Quoted 2 lines
drivers/mtd/mtdcore.c +1 -1
-                       struct list_head *this;
+                       struct mtd_notifier *not

That's not even going to compile, surely?

i forgot to tell quilt to refresh the patch before sending it. i sent a fix just some minutes after the broken patch

Signature · 11 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

     La libertad es como la mañana. Hay quienes esperan dormidos a que
   llegue, pero hay quienes desvelan y caminan la noche para alcanzarla
                        (Subcomandante Marcos)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#7 lore raw

PATCH 2/2 MTD: use list_for_each_entry() in del_mtd_device()

In reply to [email protected]

MTD: use list_for_each_entry() instead of list_for_each() in del_mtd_device()

drivers/mtd/mtdcore.c +2 -3
Index: linux-2.6/drivers/mtd/mtdcore.c
===================================================================
@@ -112,12 +112,11 @@
 		       mtd->index, mtd->name, mtd->usecount);
 		ret = -EBUSY;
 	} else {
-		struct list_head *this;
+		struct mtd_notifier *not;
 
 		/* No need to get a refcount on the module containing
 		   the notifier, since we hold the mtd_table_mutex */
-		list_for_each(this, &mtd_notifiers) {
-			struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
+		list_for_each_entry(not, &mtd_notifiers, list) {
 			not->remove(mtd);
 		}
 
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-