block: Collect block devices on list
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
7a1c5027f9
commit
4dda27ce49
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#define BLOCKSIZE(blk) (1 << blk->blockbits)
|
#define BLOCKSIZE(blk) (1 << blk->blockbits)
|
||||||
|
|
||||||
|
LIST_HEAD(block_device_list);
|
||||||
|
|
||||||
/* a chunk of contigous data */
|
/* a chunk of contigous data */
|
||||||
struct chunk {
|
struct chunk {
|
||||||
void *data; /* data buffer */
|
void *data; /* data buffer */
|
||||||
|
@ -367,6 +369,8 @@ int blockdevice_register(struct block_device *blk)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
list_add_tail(&blk->list, &block_device_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,6 +391,7 @@ int blockdevice_unregister(struct block_device *blk)
|
||||||
}
|
}
|
||||||
|
|
||||||
devfs_remove(&blk->cdev);
|
devfs_remove(&blk->cdev);
|
||||||
|
list_del(&blk->list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __BLOCK_H
|
#define __BLOCK_H
|
||||||
|
|
||||||
#include <driver.h>
|
#include <driver.h>
|
||||||
|
#include <linux/list.h>
|
||||||
|
|
||||||
struct block_device;
|
struct block_device;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ struct chunk;
|
||||||
|
|
||||||
struct block_device {
|
struct block_device {
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
|
struct list_head list;
|
||||||
struct block_device_ops *ops;
|
struct block_device_ops *ops;
|
||||||
int blockbits;
|
int blockbits;
|
||||||
int num_blocks;
|
int num_blocks;
|
||||||
|
@ -26,6 +28,10 @@ struct block_device {
|
||||||
struct cdev cdev;
|
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_register(struct block_device *blk);
|
||||||
int blockdevice_unregister(struct block_device *blk);
|
int blockdevice_unregister(struct block_device *blk);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue