diff options
-rw-r--r-- | common/block.c | 5 | ||||
-rw-r--r-- | include/block.h | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/common/block.c b/common/block.c index ab39a3622c..e522ee425a 100644 --- a/common/block.c +++ b/common/block.c @@ -25,6 +25,8 @@ #define BLOCKSIZE(blk) (1 << blk->blockbits) +LIST_HEAD(block_device_list); + /* a chunk of contigous data */ struct chunk { void *data; /* data buffer */ @@ -367,6 +369,8 @@ int blockdevice_register(struct block_device *blk) if (ret) return ret; + list_add_tail(&blk->list, &block_device_list); + return 0; } @@ -387,6 +391,7 @@ int blockdevice_unregister(struct block_device *blk) } devfs_remove(&blk->cdev); + list_del(&blk->list); return 0; } diff --git a/include/block.h b/include/block.h index eb31aca4db..872a4c1bba 100644 --- a/include/block.h +++ b/include/block.h @@ -2,6 +2,7 @@ #define __BLOCK_H #include <driver.h> +#include <linux/list.h> struct block_device; @@ -14,6 +15,7 @@ struct chunk; struct block_device { struct device_d *dev; + struct list_head list; struct block_device_ops *ops; int blockbits; int num_blocks; @@ -26,6 +28,10 @@ struct block_device { struct cdev cdev; }; +extern struct list_head block_device_list; + +#define for_each_block_device(bdev) list_for_each_entry(bdev, &block_device_list, list) + int blockdevice_register(struct block_device *blk); int blockdevice_unregister(struct block_device *blk); |