mtd: ubi: Add support for opening a volume by cdev
Needed by ubifs support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
d9abbe8d01
commit
8fb48927da
|
@ -5,6 +5,8 @@
|
|||
#include "ubi-barebox.h"
|
||||
#include "ubi.h"
|
||||
|
||||
LIST_HEAD(ubi_volumes_list);
|
||||
|
||||
struct ubi_volume_cdev_priv {
|
||||
struct ubi_device *ubi;
|
||||
struct ubi_volume *vol;
|
||||
|
@ -184,6 +186,8 @@ int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
|
|||
free(cdev->name);
|
||||
}
|
||||
|
||||
list_add_tail(&vol->list, &ubi_volumes_list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -192,6 +196,8 @@ void ubi_volume_cdev_remove(struct ubi_volume *vol)
|
|||
struct cdev *cdev = &vol->cdev;
|
||||
struct ubi_volume_cdev_priv *priv = cdev->priv;
|
||||
|
||||
list_del(&vol->list);
|
||||
|
||||
devfs_remove(cdev);
|
||||
kfree(cdev->name);
|
||||
kfree(priv);
|
||||
|
|
|
@ -265,6 +265,23 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(ubi_open_volume_nm);
|
||||
|
||||
extern struct list_head ubi_volumes_list;
|
||||
|
||||
struct ubi_volume_desc *ubi_open_volume_cdev(struct cdev *cdev, int mode)
|
||||
{
|
||||
struct ubi_volume *vol;
|
||||
|
||||
list_for_each_entry(vol, &ubi_volumes_list, list) {
|
||||
if (cdev == &vol->cdev)
|
||||
goto found;
|
||||
}
|
||||
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
found:
|
||||
return ubi_open_volume(vol->ubi->ubi_num, vol->vol_id, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* ubi_close_volume - close UBI volume.
|
||||
* @desc: volume descriptor
|
||||
|
|
|
@ -322,6 +322,8 @@ struct ubi_volume {
|
|||
unsigned int updating:1;
|
||||
unsigned int changing_leb:1;
|
||||
unsigned int direct_writes:1;
|
||||
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -200,6 +200,7 @@ void ubi_get_volume_info(struct ubi_volume_desc *desc,
|
|||
struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode);
|
||||
struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
|
||||
int mode);
|
||||
struct ubi_volume_desc *ubi_open_volume_cdev(struct cdev *cdev, int mode);
|
||||
struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode);
|
||||
|
||||
void ubi_close_volume(struct ubi_volume_desc *desc);
|
||||
|
|
Loading…
Reference in New Issue