fs: get fs device using container_of
This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
76c7f90a54
commit
3a92711511
|
@ -423,7 +423,7 @@ static int cramfs_probe(struct device_d *dev)
|
|||
struct fs_device_d *fsdev;
|
||||
struct cramfs_priv *priv;
|
||||
|
||||
fsdev = dev->type_data;
|
||||
fsdev = dev_to_fs_device(dev);
|
||||
|
||||
priv = xmalloc(sizeof(struct cramfs_priv));
|
||||
dev->priv = priv;
|
||||
|
@ -468,7 +468,6 @@ static struct fs_driver_d cramfs_driver = {
|
|||
.probe = cramfs_probe,
|
||||
.remove = cramfs_remove,
|
||||
.name = "cramfs",
|
||||
.type_data = &cramfs_driver,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -249,7 +249,6 @@ static struct fs_driver_d devfs_driver = {
|
|||
.probe = devfs_probe,
|
||||
.remove = devfs_delete,
|
||||
.name = "devfs",
|
||||
.type_data = &devfs_driver,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -373,7 +373,7 @@ static int fat_stat(struct device_d *dev, const char *filename, struct stat *s)
|
|||
|
||||
static int fat_probe(struct device_d *dev)
|
||||
{
|
||||
struct fs_device_d *fsdev = dev->type_data;
|
||||
struct fs_device_d *fsdev = dev_to_fs_device(dev);
|
||||
struct fat_priv *priv = xzalloc(sizeof(struct fat_priv));
|
||||
char *backingstore = fsdev->backingstore;
|
||||
|
||||
|
@ -423,7 +423,6 @@ static struct fs_driver_d fat_driver = {
|
|||
.probe = fat_probe,
|
||||
.remove = fat_remove,
|
||||
.name = "fat",
|
||||
.type_data = &fat_driver,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
5
fs/fs.c
5
fs/fs.c
|
@ -704,7 +704,7 @@ static int fs_match(struct device_d *dev, struct driver_d *drv)
|
|||
|
||||
static int fs_probe(struct device_d *dev)
|
||||
{
|
||||
struct fs_device_d *fsdev = container_of(dev, struct fs_device_d, dev);
|
||||
struct fs_device_d *fsdev = dev_to_fs_device(dev);
|
||||
struct mtab_entry *entry = &fsdev->mtab;
|
||||
int ret;
|
||||
|
||||
|
@ -729,7 +729,7 @@ static int fs_probe(struct device_d *dev)
|
|||
|
||||
static void fs_remove(struct device_d *dev)
|
||||
{
|
||||
struct fs_device_d *fsdev = container_of(dev, struct fs_device_d, dev);
|
||||
struct fs_device_d *fsdev = dev_to_fs_device(dev);
|
||||
struct mtab_entry *entry = &fsdev->mtab;
|
||||
|
||||
if (fsdev->dev.driver) {
|
||||
|
@ -798,7 +798,6 @@ int mount(const char *device, const char *fsname, const char *_path)
|
|||
fsdev = xzalloc(sizeof(struct fs_device_d));
|
||||
fsdev->backingstore = xstrdup(device);
|
||||
safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME);
|
||||
fsdev->dev.type_data = fsdev;
|
||||
fsdev->dev.id = get_free_deviceid(fsdev->dev.name);
|
||||
fsdev->mtab.path = xstrdup(path);
|
||||
fsdev->dev.bus = &fs_bus;
|
||||
|
|
|
@ -562,7 +562,6 @@ static struct fs_driver_d ramfs_driver = {
|
|||
.probe = ramfs_probe,
|
||||
.remove = ramfs_remove,
|
||||
.name = "ramfs",
|
||||
.type_data = &ramfs_driver,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -598,7 +598,7 @@ static int tftp_stat(struct device_d *dev, const char *filename, struct stat *s)
|
|||
|
||||
static int tftp_probe(struct device_d *dev)
|
||||
{
|
||||
struct fs_device_d *fsdev = dev->type_data;
|
||||
struct fs_device_d *fsdev = dev_to_fs_device(dev);
|
||||
struct tftp_priv *priv = xzalloc(sizeof(struct tftp_priv));
|
||||
|
||||
dev->priv = priv;
|
||||
|
@ -633,7 +633,6 @@ static struct fs_driver_d tftp_driver = {
|
|||
.probe = tftp_probe,
|
||||
.remove = tftp_remove,
|
||||
.name = "tftp",
|
||||
.type_data = &tftp_driver,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ struct fs_driver_d {
|
|||
};
|
||||
|
||||
#define dev_to_fs_driver(d) container_of(d->driver, struct fs_driver_d, drv)
|
||||
#define dev_to_fs_device(d) container_of(d, struct fs_device_d, dev)
|
||||
|
||||
struct mtab_entry {
|
||||
char *path;
|
||||
|
|
Loading…
Reference in New Issue