aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
authorChris Malley <mail@chrismalley.co.uk>2008-05-19 15:11:50 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2008-06-04 12:53:31 -0400
commit71a928c0e52cedc43747c64b96a5f74592ab678f (patch)
tree98f4862294a23b859af87f6df44e9668a3fbc133 /drivers/mtd/mtd_blkdevs.c
parent59018b6d2acabb114ab58637e6ab95ba424a89d0 (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/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index a0ada45672d8..9ff007c4962c 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -210,7 +210,7 @@ static struct block_device_operations mtd_blktrans_ops = {
210int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) 210int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
211{ 211{
212 struct mtd_blktrans_ops *tr = new->tr; 212 struct mtd_blktrans_ops *tr = new->tr;
213 struct list_head *this; 213 struct mtd_blktrans_dev *d;
214 int last_devnum = -1; 214 int last_devnum = -1;
215 struct gendisk *gd; 215 struct gendisk *gd;
216 216
@@ -219,8 +219,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
219 BUG(); 219 BUG();
220 } 220 }
221 221
222 list_for_each(this, &tr->devs) { 222 list_for_each_entry(d, &tr->devs, list) {
223 struct mtd_blktrans_dev *d = list_entry(this, struct mtd_blktrans_dev, list);
224 if (new->devnum == -1) { 223 if (new->devnum == -1) {
225 /* Use first free number */ 224 /* Use first free number */
226 if (d->devnum != last_devnum+1) { 225 if (d->devnum != last_devnum+1) {
@@ -307,33 +306,24 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
307 306
308static void blktrans_notify_remove(struct mtd_info *mtd) 307static void blktrans_notify_remove(struct mtd_info *mtd)
309{ 308{
310 struct list_head *this, *this2, *next; 309 struct mtd_blktrans_ops *tr;
311 310 struct mtd_blktrans_dev *dev, *next;
312 list_for_each(this, &blktrans_majors) {
313 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
314
315 list_for_each_safe(this2, next, &tr->devs) {
316 struct mtd_blktrans_dev *dev = list_entry(this2, struct mtd_blktrans_dev, list);
317 311
312 list_for_each_entry(tr, &blktrans_majors, list)
313 list_for_each_entry_safe(dev, next, &tr->devs, list)
318 if (dev->mtd == mtd) 314 if (dev->mtd == mtd)
319 tr->remove_dev(dev); 315 tr->remove_dev(dev);
320 }
321 }
322} 316}
323 317
324static void blktrans_notify_add(struct mtd_info *mtd) 318static void blktrans_notify_add(struct mtd_info *mtd)
325{ 319{
326 struct list_head *this; 320 struct mtd_blktrans_ops *tr;
327 321
328 if (mtd->type == MTD_ABSENT) 322 if (mtd->type == MTD_ABSENT)
329 return; 323 return;
330 324
331 list_for_each(this, &blktrans_majors) { 325 list_for_each_entry(tr, &blktrans_majors, list)
332 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
333
334 tr->add_mtd(tr, mtd); 326 tr->add_mtd(tr, mtd);
335 }
336
337} 327}
338 328
339static struct mtd_notifier blktrans_notifier = { 329static struct mtd_notifier blktrans_notifier = {
@@ -404,7 +394,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
404 394
405int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) 395int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
406{ 396{
407 struct list_head *this, *next; 397 struct mtd_blktrans_dev *dev, *next;
408 398
409 mutex_lock(&mtd_table_mutex); 399 mutex_lock(&mtd_table_mutex);
410 400
@@ -414,10 +404,8 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
414 /* Remove it from the list of active majors */ 404 /* Remove it from the list of active majors */
415 list_del(&tr->list); 405 list_del(&tr->list);
416 406
417 list_for_each_safe(this, next, &tr->devs) { 407 list_for_each_entry_safe(dev, next, &tr->devs, list)
418 struct mtd_blktrans_dev *dev = list_entry(this, struct mtd_blktrans_dev, list);
419 tr->remove_dev(dev); 408 tr->remove_dev(dev);
420 }
421 409
422 blk_cleanup_queue(tr->blkcore_priv->rq); 410 blk_cleanup_queue(tr->blkcore_priv->rq);
423 unregister_blkdev(tr->major, tr->name); 411 unregister_blkdev(tr->major, tr->name);