This reduces the usage of dev->type_data.

Signed-off-by: Sascha Hauer <s.ha...@pengutronix.de>
---
 fs/cramfs/cramfs.c |    3 +--
 fs/devfs.c         |    1 -
 fs/fat/fat.c       |    3 +--
 fs/fs.c            |    5 ++---
 fs/ramfs.c         |    1 -
 fs/tftp.c          |    3 +--
 include/fs.h       |    1 +
 7 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index bdbb47e..c7c798b 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -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,
        }
 };
 
diff --git a/fs/devfs.c b/fs/devfs.c
index 2e70cc5..e3a21ae 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -249,7 +249,6 @@ static struct fs_driver_d devfs_driver = {
                .probe  = devfs_probe,
                .remove = devfs_delete,
                .name = "devfs",
-               .type_data = &devfs_driver,
        }
 };
 
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 8420f3a..7d6e37a 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -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,
        }
 };
 
diff --git a/fs/fs.c b/fs/fs.c
index 0f12aa6..a31a4ce 100644
--- a/fs/fs.c
+++ b/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;
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 5e352f2..83ab6df 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -562,7 +562,6 @@ static struct fs_driver_d ramfs_driver = {
                .probe  = ramfs_probe,
                .remove = ramfs_remove,
                .name = "ramfs",
-               .type_data = &ramfs_driver,
        }
 };
 
diff --git a/fs/tftp.c b/fs/tftp.c
index 512da03..463e0fc 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -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,
        }
 };
 
diff --git a/include/fs.h b/include/fs.h
index 5ef5f55..e5364f9 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -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;
-- 
1.7.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to