diff options
author | Chris Malley <mail@chrismalley.co.uk> | 2008-05-19 15:11:50 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-06-04 12:53:31 -0400 |
commit | 71a928c0e52cedc43747c64b96a5f74592ab678f (patch) | |
tree | 98f4862294a23b859af87f6df44e9668a3fbc133 /drivers/mtd/mtdpart.c | |
parent | 59018b6d2acabb114ab58637e6ab95ba424a89d0 (diff) |
[MTD] Use list_for_each_entry[_safe] where appropriate.
Janitorial work to remove temporary pointers and make some functions a bit
more readable.
Signed-off-by: Chris Malley <mail@chrismalley.co.uk>
Reviewed-By: Jörn Engel <joern@logfs.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/mtdpart.c')
-rw-r--r-- | drivers/mtd/mtdpart.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 11b803cc405b..56a760a736a9 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -300,22 +300,15 @@ static int part_block_markbad (struct mtd_info *mtd, loff_t ofs) | |||
300 | 300 | ||
301 | int del_mtd_partitions(struct mtd_info *master) | 301 | int del_mtd_partitions(struct mtd_info *master) |
302 | { | 302 | { |
303 | struct list_head *node; | 303 | struct mtd_part *slave, *next; |
304 | struct mtd_part *slave; | ||
305 | 304 | ||
306 | for (node = mtd_partitions.next; | 305 | list_for_each_entry_safe(slave, next, &mtd_partitions, list) |
307 | node != &mtd_partitions; | ||
308 | node = node->next) { | ||
309 | slave = list_entry(node, struct mtd_part, list); | ||
310 | if (slave->master == master) { | 306 | if (slave->master == master) { |
311 | struct list_head *prev = node->prev; | 307 | list_del(&slave->list); |
312 | __list_del(prev, node->next); | ||
313 | if(slave->registered) | 308 | if(slave->registered) |
314 | del_mtd_device(&slave->mtd); | 309 | del_mtd_device(&slave->mtd); |
315 | kfree(slave); | 310 | kfree(slave); |
316 | node = prev; | ||
317 | } | 311 | } |
318 | } | ||
319 | 312 | ||
320 | return 0; | 313 | return 0; |
321 | } | 314 | } |
@@ -511,18 +504,16 @@ static LIST_HEAD(part_parsers); | |||
511 | 504 | ||
512 | static struct mtd_part_parser *get_partition_parser(const char *name) | 505 | static struct mtd_part_parser *get_partition_parser(const char *name) |
513 | { | 506 | { |
514 | struct list_head *this; | 507 | struct mtd_part_parser *p, *ret = NULL; |
515 | void *ret = NULL; | ||
516 | spin_lock(&part_parser_lock); | ||
517 | 508 | ||
518 | list_for_each(this, &part_parsers) { | 509 | spin_lock(&part_parser_lock); |
519 | struct mtd_part_parser *p = list_entry(this, struct mtd_part_parser, list); | ||
520 | 510 | ||
511 | list_for_each_entry(p, &part_parsers, list) | ||
521 | if (!strcmp(p->name, name) && try_module_get(p->owner)) { | 512 | if (!strcmp(p->name, name) && try_module_get(p->owner)) { |
522 | ret = p; | 513 | ret = p; |
523 | break; | 514 | break; |
524 | } | 515 | } |
525 | } | 516 | |
526 | spin_unlock(&part_parser_lock); | 517 | spin_unlock(&part_parser_lock); |
527 | 518 | ||
528 | return ret; | 519 | return ret; |