aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 839eed8430a2..9ff007c4962c 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd_blkdevs.c,v 1.27 2005/11/07 11:14:20 gleixner Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 3 *
6 * Interface to Linux 2.5 block layer for MTD 'translation layers'. 4 * Interface to Linux 2.5 block layer for MTD 'translation layers'.
@@ -212,7 +210,7 @@ static struct block_device_operations mtd_blktrans_ops = {
212int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) 210int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
213{ 211{
214 struct mtd_blktrans_ops *tr = new->tr; 212 struct mtd_blktrans_ops *tr = new->tr;
215 struct list_head *this; 213 struct mtd_blktrans_dev *d;
216 int last_devnum = -1; 214 int last_devnum = -1;
217 struct gendisk *gd; 215 struct gendisk *gd;
218 216
@@ -221,8 +219,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
221 BUG(); 219 BUG();
222 } 220 }
223 221
224 list_for_each(this, &tr->devs) { 222 list_for_each_entry(d, &tr->devs, list) {
225 struct mtd_blktrans_dev *d = list_entry(this, struct mtd_blktrans_dev, list);
226 if (new->devnum == -1) { 223 if (new->devnum == -1) {
227 /* Use first free number */ 224 /* Use first free number */
228 if (d->devnum != last_devnum+1) { 225 if (d->devnum != last_devnum+1) {
@@ -309,33 +306,24 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
309 306
310static void blktrans_notify_remove(struct mtd_info *mtd) 307static void blktrans_notify_remove(struct mtd_info *mtd)
311{ 308{
312 struct list_head *this, *this2, *next; 309 struct mtd_blktrans_ops *tr;
313 310 struct mtd_blktrans_dev *dev, *next;
314 list_for_each(this, &blktrans_majors) {
315 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
316
317 list_for_each_safe(this2, next, &tr->devs) {
318 struct mtd_blktrans_dev *dev = list_entry(this2, struct mtd_blktrans_dev, list);
319 311
312 list_for_each_entry(tr, &blktrans_majors, list)
313 list_for_each_entry_safe(dev, next, &tr->devs, list)
320 if (dev->mtd == mtd) 314 if (dev->mtd == mtd)
321 tr->remove_dev(dev); 315 tr->remove_dev(dev);
322 }
323 }
324} 316}
325 317
326static void blktrans_notify_add(struct mtd_info *mtd) 318static void blktrans_notify_add(struct mtd_info *mtd)
327{ 319{
328 struct list_head *this; 320 struct mtd_blktrans_ops *tr;
329 321
330 if (mtd->type == MTD_ABSENT) 322 if (mtd->type == MTD_ABSENT)
331 return; 323 return;
332 324
333 list_for_each(this, &blktrans_majors) { 325 list_for_each_entry(tr, &blktrans_majors, list)
334 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
335
336 tr->add_mtd(tr, mtd); 326 tr->add_mtd(tr, mtd);
337 }
338
339} 327}
340 328
341static struct mtd_notifier blktrans_notifier = { 329static struct mtd_notifier blktrans_notifier = {
@@ -406,7 +394,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
406 394
407int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) 395int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
408{ 396{
409 struct list_head *this, *next; 397 struct mtd_blktrans_dev *dev, *next;
410 398
411 mutex_lock(&mtd_table_mutex); 399 mutex_lock(&mtd_table_mutex);
412 400
@@ -416,10 +404,8 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
416 /* Remove it from the list of active majors */ 404 /* Remove it from the list of active majors */
417 list_del(&tr->list); 405 list_del(&tr->list);
418 406
419 list_for_each_safe(this, next, &tr->devs) { 407 list_for_each_entry_safe(dev, next, &tr->devs, list)
420 struct mtd_blktrans_dev *dev = list_entry(this, struct mtd_blktrans_dev, list);
421 tr->remove_dev(dev); 408 tr->remove_dev(dev);
422 }
423 409
424 blk_cleanup_queue(tr->blkcore_priv->rq); 410 blk_cleanup_queue(tr->blkcore_priv->rq);
425 unregister_blkdev(tr->major, tr->name); 411 unregister_blkdev(tr->major, tr->name);