From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/9] ext4: remove init_fs/deinit_fs
Date: Thu, 23 Aug 2012 16:31:45 -0500 [thread overview]
Message-ID: <1345757510-6756-5-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1345757510-6756-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
There's no real need to expose this and it can be removed by using a static
allocation.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
common/cmd_ext4.c | 10 +++-------
common/cmd_ext_common.c | 19 +++----------------
fs/ext4/ext4fs.c | 36 ++----------------------------------
include/ext4fs.h | 2 --
include/zfs_common.h | 2 --
5 files changed, 8 insertions(+), 61 deletions(-)
diff --git a/common/cmd_ext4.c b/common/cmd_ext4.c
index 77094c4..e92c02f 100644
--- a/common/cmd_ext4.c
+++ b/common/cmd_ext4.c
@@ -151,8 +151,6 @@ int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
printf("Block device %s %d not supported\n", argv[1], dev);
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
fs = get_fs();
if (*ep) {
@@ -173,21 +171,21 @@ int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
file_size = simple_strtoul(argv[5], NULL, 10);
/* set the device as block device */
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("Bad partition - %s %d:%lu\n", argv[1], dev, part);
goto fail;
}
/* register the device and partition */
- if (ext4_register_device(fs->dev_desc, part) != 0) {
+ if (ext4_register_device(ext4_dev_desc, part) != 0) {
printf("Unable to use %s %d:%lu for fattable\n",
argv[1], dev, part);
goto fail;
}
/* get the partition information */
- if (!get_partition_info(fs->dev_desc, part, &info)) {
+ if (!get_partition_info(ext4_dev_desc, part, &info)) {
total_sector = (info.size * info.blksz) / SECTOR_SIZE;
fs->total_sect = total_sector;
} else {
@@ -207,13 +205,11 @@ int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
goto fail;
}
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 0;
fail:
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 1;
}
diff --git a/common/cmd_ext_common.c b/common/cmd_ext_common.c
index 56ee9a5..8972ccc 100644
--- a/common/cmd_ext_common.c
+++ b/common/cmd_ext_common.c
@@ -75,7 +75,6 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
ulong part_length;
int filelen;
disk_partition_t info;
- struct ext_filesystem *fs;
char buf[12];
unsigned long count;
const char *addr_str;
@@ -117,10 +116,7 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
printf("** Block device %s %d not supported\n", argv[1], dev);
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
- fs = get_fs();
if (*ep) {
if (*ep != ':') {
puts("** Invalid boot device, use `dev[:part]' **\n");
@@ -130,7 +126,7 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
}
if (part != 0) {
- if (get_partition_info(fs->dev_desc, part, &info)) {
+ if (get_partition_info(ext4_dev_desc, part, &info)) {
printf("** Bad partition %lu **\n", part);
goto fail;
}
@@ -149,7 +145,7 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
filename, argv[1], dev);
}
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("**Bad partition - %s %d:%lu **\n", argv[1], dev, part);
ext4fs_close();
@@ -180,7 +176,6 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
}
ext4fs_close();
- deinit_fs(fs->dev_desc);
/* Loading ok, update default load address */
load_addr = addr;
@@ -190,7 +185,6 @@ int do_ext_load(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
fail:
- deinit_fs(fs->dev_desc);
return 1;
}
@@ -200,7 +194,6 @@ int do_ext_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
int dev;
unsigned long part = 1;
char *ep;
- struct ext_filesystem *fs;
int part_length;
if (argc < 3)
return cmd_usage(cmdtp);
@@ -214,10 +207,6 @@ int do_ext_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
return 1;
}
- if (init_fs(ext4_dev_desc))
- return 1;
-
- fs = get_fs();
if (*ep) {
if (*ep != ':') {
puts("\n** Invalid boot device, use `dev[:part]' **\n");
@@ -229,7 +218,7 @@ int do_ext_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (argc == 4)
filename = argv[3];
- part_length = ext4fs_set_blk_dev(fs->dev_desc, part);
+ part_length = ext4fs_set_blk_dev(ext4_dev_desc, part);
if (part_length == 0) {
printf("** Bad partition - %s %d:%lu **\n", argv[1], dev, part);
ext4fs_close();
@@ -250,10 +239,8 @@ int do_ext_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
};
ext4fs_close();
- deinit_fs(fs->dev_desc);
return 0;
fail:
- deinit_fs(fs->dev_desc);
return 1;
}
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 114c2a2..c366e6f 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -44,43 +44,11 @@
int ext4fs_symlinknest;
block_dev_desc_t *ext4_dev_desc;
+struct ext_filesystem ext_fs;
struct ext_filesystem *get_fs(void)
{
- if (ext4_dev_desc == NULL || ext4_dev_desc->priv == NULL)
- printf("Invalid Input Arguments %s\n", __func__);
-
- return ext4_dev_desc->priv;
-}
-
-int init_fs(block_dev_desc_t *dev_desc)
-{
- struct ext_filesystem *fs;
- if (dev_desc == NULL) {
- printf("Invalid Input Arguments %s\n", __func__);
- return -EINVAL;
- }
-
- fs = zalloc(sizeof(struct ext_filesystem));
- if (fs == NULL) {
- printf("malloc failed: %s\n", __func__);
- return -ENOMEM;
- }
-
- fs->dev_desc = dev_desc;
- dev_desc->priv = fs;
-
- return 0;
-}
-
-void deinit_fs(block_dev_desc_t *dev_desc)
-{
- if (dev_desc == NULL) {
- printf("Invalid Input Arguments %s\n", __func__);
- return;
- }
- free(dev_desc->priv);
- dev_desc->priv = NULL;
+ return &ext_fs;
}
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot)
diff --git a/include/ext4fs.h b/include/ext4fs.h
index ab2983c..6ad008c 100644
--- a/include/ext4fs.h
+++ b/include/ext4fs.h
@@ -130,8 +130,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
#endif
struct ext_filesystem *get_fs(void);
-int init_fs(block_dev_desc_t *dev_desc);
-void deinit_fs(block_dev_desc_t *dev_desc);
int ext4fs_open(const char *filename);
int ext4fs_read(char *buf, unsigned len);
int ext4fs_mount(unsigned part_length);
diff --git a/include/zfs_common.h b/include/zfs_common.h
index 04e73d0..628231e 100644
--- a/include/zfs_common.h
+++ b/include/zfs_common.h
@@ -94,8 +94,6 @@ struct zfs_dirhook_info {
struct zfs_filesystem *zfsget_fs(void);
-int init_fs(block_dev_desc_t *dev_desc);
-void deinit_fs(block_dev_desc_t *dev_desc);
int zfs_open(zfs_file_t, const char *filename);
uint64_t zfs_read(zfs_file_t, char *buf, uint64_t len);
struct zfs_data *zfs_mount(device_t);
--
1.7.9.5
next prev parent reply other threads:[~2012-08-23 21:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 21:31 [U-Boot] [PATCH 0/9] Auto partition selection and fs partition consolidation Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 1/9] combine block device load commands into common function Rob Herring
2012-09-05 23:36 ` Tom Rini
2012-09-05 23:47 ` Rob Herring
2012-09-05 23:50 ` Tom Rini
2012-09-21 14:02 ` [U-Boot] [PATCH v2 " Rob Herring
2012-09-25 23:17 ` Tom Rini
2012-08-23 21:31 ` [U-Boot] [PATCH 2/9] disk/part: check bootable flag for DOS partitions Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 3/9] disk/part: introduce get_device_and_partition Rob Herring
2012-08-23 22:36 ` Stephen Warren
2012-08-24 1:57 ` Rob Herring
2012-08-24 2:51 ` Stephen Warren
2012-09-05 23:53 ` Tom Rini
2012-09-21 14:08 ` [U-Boot] [PATCH v2 " Rob Herring
2012-08-23 21:31 ` Rob Herring [this message]
2012-08-23 21:31 ` [U-Boot] [PATCH 5/9] cmd_extX: use common get_device_and_partition function Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 6/9] cmd_fat: " Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 7/9] cmd_disk: " Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 8/9] cmd_zfs: " Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 9/9] cmd_reiser: " Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345757510-6756-5-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.