mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: nand-bb: use list_for_each_entry_safe
@ 2014-04-29  6:06 Sascha Hauer
  2014-04-29 13:19 ` Alexander Aring
  2014-05-03 11:32 ` Alexander Aring
  0 siblings, 2 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-04-29  6:06 UTC (permalink / raw)
  To: barebox

We need list_for_each_entry_safe in dev_remove_bb_dev since the
list entries are removed during iteration over the list.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/mtd/nand/nand-bb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index f387ef6..89d5945 100644
--- a/drivers/mtd/nand/nand-bb.c
+++ b/drivers/mtd/nand/nand-bb.c
@@ -308,9 +308,9 @@ out1:
 
 int dev_remove_bb_dev(const char *name)
 {
-	struct nand_bb *bb;
+	struct nand_bb *bb, *tmp;
 
-	list_for_each_entry(bb, &bb_list, list) {
+	list_for_each_entry_safe(bb, tmp, &bb_list, list) {
 		if (!strcmp(bb->cdev.name, name)) {
 			devfs_remove(&bb->cdev);
 			cdev_close(bb->cdev_parent);
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand-bb: use list_for_each_entry_safe
  2014-04-29  6:06 [PATCH] mtd: nand-bb: use list_for_each_entry_safe Sascha Hauer
@ 2014-04-29 13:19 ` Alexander Aring
  2014-05-03 11:32 ` Alexander Aring
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2014-04-29 13:19 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

thanks Sascha.

On Tue, Apr 29, 2014 at 08:06:46AM +0200, Sascha Hauer wrote:
> We need list_for_each_entry_safe in dev_remove_bb_dev since the
> list entries are removed during iteration over the list.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Reported-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  drivers/mtd/nand/nand-bb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
> index f387ef6..89d5945 100644
> --- a/drivers/mtd/nand/nand-bb.c
> +++ b/drivers/mtd/nand/nand-bb.c
> @@ -308,9 +308,9 @@ out1:
>  
>  int dev_remove_bb_dev(const char *name)
>  {
> -	struct nand_bb *bb;
> +	struct nand_bb *bb, *tmp;
>  
> -	list_for_each_entry(bb, &bb_list, list) {
> +	list_for_each_entry_safe(bb, tmp, &bb_list, list) {
>  		if (!strcmp(bb->cdev.name, name)) {
>  			devfs_remove(&bb->cdev);
>  			cdev_close(bb->cdev_parent);

Fixes f4af6690e41e1f1b995b5b3b56016c8a8fcd3246
("nand-bb: Fix remove of nand-bb device.")

- Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand-bb: use list_for_each_entry_safe
  2014-04-29  6:06 [PATCH] mtd: nand-bb: use list_for_each_entry_safe Sascha Hauer
  2014-04-29 13:19 ` Alexander Aring
@ 2014-05-03 11:32 ` Alexander Aring
  2014-05-07  8:09   ` Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Aring @ 2014-05-03 11:32 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On Tue, Apr 29, 2014 at 08:06:46AM +0200, Sascha Hauer wrote:
> We need list_for_each_entry_safe in dev_remove_bb_dev since the
> list entries are removed during iteration over the list.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Reported-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  drivers/mtd/nand/nand-bb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
> index f387ef6..89d5945 100644
> --- a/drivers/mtd/nand/nand-bb.c
> +++ b/drivers/mtd/nand/nand-bb.c
> @@ -308,9 +308,9 @@ out1:
>  
>  int dev_remove_bb_dev(const char *name)
>  {
> -	struct nand_bb *bb;
> +	struct nand_bb *bb, *tmp;
>  
> -	list_for_each_entry(bb, &bb_list, list) {
> +	list_for_each_entry_safe(bb, tmp, &bb_list, list) {
>  		if (!strcmp(bb->cdev.name, name)) {
>  			devfs_remove(&bb->cdev);
>  			cdev_close(bb->cdev_parent);

after reconsider this one, we don't need a list_for_each_entry_safe here
because we returning after deleting and leave the for each loop there.
Sorry, so maybe we should revert this commit? :-)

- Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand-bb: use list_for_each_entry_safe
  2014-05-03 11:32 ` Alexander Aring
@ 2014-05-07  8:09   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-07  8:09 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Sat, May 03, 2014 at 01:32:13PM +0200, Alexander Aring wrote:
> Hi Sascha,
> 
> On Tue, Apr 29, 2014 at 08:06:46AM +0200, Sascha Hauer wrote:
> > We need list_for_each_entry_safe in dev_remove_bb_dev since the
> > list entries are removed during iteration over the list.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Reported-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> >  drivers/mtd/nand/nand-bb.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
> > index f387ef6..89d5945 100644
> > --- a/drivers/mtd/nand/nand-bb.c
> > +++ b/drivers/mtd/nand/nand-bb.c
> > @@ -308,9 +308,9 @@ out1:
> >  
> >  int dev_remove_bb_dev(const char *name)
> >  {
> > -	struct nand_bb *bb;
> > +	struct nand_bb *bb, *tmp;
> >  
> > -	list_for_each_entry(bb, &bb_list, list) {
> > +	list_for_each_entry_safe(bb, tmp, &bb_list, list) {
> >  		if (!strcmp(bb->cdev.name, name)) {
> >  			devfs_remove(&bb->cdev);
> >  			cdev_close(bb->cdev_parent);
> 
> after reconsider this one, we don't need a list_for_each_entry_safe here
> because we returning after deleting and leave the for each loop there.
> Sorry, so maybe we should revert this commit? :-)

Well, the commit is not wrong, only unnecessary, so keep it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-07  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29  6:06 [PATCH] mtd: nand-bb: use list_for_each_entry_safe Sascha Hauer
2014-04-29 13:19 ` Alexander Aring
2014-05-03 11:32 ` Alexander Aring
2014-05-07  8:09   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox