From: David Teigland Add dm_get_dev() to get a mapped device given its dev_t. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton --- drivers/md/dm.c | 10 ++++++++++ drivers/md/dm.h | 1 + 2 files changed, 11 insertions(+) diff -puN drivers/md/dm.c~device-mapper-add-dm_get_md drivers/md/dm.c --- devel/drivers/md/dm.c~device-mapper-add-dm_get_md 2005-11-18 18:16:06.000000000 -0800 +++ devel-akpm/drivers/md/dm.c 2005-11-18 18:16:06.000000000 -0800 @@ -932,6 +932,16 @@ static struct mapped_device *dm_find_md( return md; } +struct mapped_device *dm_get_md(dev_t dev) +{ + struct mapped_device *md = dm_find_md(dev); + + if (md) + dm_get(md); + + return md; +} + void *dm_get_mdptr(dev_t dev) { struct mapped_device *md; diff -puN drivers/md/dm.h~device-mapper-add-dm_get_md drivers/md/dm.h --- devel/drivers/md/dm.h~device-mapper-add-dm_get_md 2005-11-18 18:16:06.000000000 -0800 +++ devel-akpm/drivers/md/dm.h 2005-11-18 18:16:06.000000000 -0800 @@ -58,6 +58,7 @@ int dm_create(struct mapped_device **md) int dm_create_with_minor(unsigned int minor, struct mapped_device **md); void dm_set_mdptr(struct mapped_device *md, void *ptr); void *dm_get_mdptr(dev_t dev); +struct mapped_device *dm_get_md(dev_t dev); /* * Reference counting for md. _