All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/7] ubi: add new ubi command "ubi detach"
Date: Tue, 31 May 2016 14:08:07 +0200	[thread overview]
Message-ID: <1464696492-10349-3-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1464696492-10349-1-git-send-email-hs@denx.de>

simple detachs ubi from the mtd partition.

Signed-off-by: Heiko Schocher <hs@denx.de>

---

Changes in v2:
- add comments from Scott Wood:
  - correct spelling error "dettach" -> "detach"
  - use "oss at buserror.net" as email address for Scott
- rebase to current mainline commit id:
  e4a94ce4ac77396b181663c0493c50bc2d5b9143

 cmd/ubi.c | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 753a4db..4a92d84 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -443,14 +443,8 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev,
 	return 0;
 }
 
-int ubi_part(char *part_name, const char *vid_header_offset)
+int ubi_detach(void)
 {
-	int err = 0;
-	char mtd_dev[16];
-	struct mtd_device *dev;
-	struct part_info *part;
-	u8 pnum;
-
 	if (mtdparts_init() != 0) {
 		printf("Error initializing mtdparts!\n");
 		return 1;
@@ -466,17 +460,28 @@ int ubi_part(char *part_name, const char *vid_header_offset)
 		cmd_ubifs_umount();
 #endif
 
-	/* todo: get dev number for NAND... */
-	ubi_dev.nr = 0;
-
 	/*
 	 * Call ubi_exit() before re-initializing the UBI subsystem
 	 */
 	if (ubi_initialized) {
 		ubi_exit();
 		del_mtd_partitions(ubi_dev.mtd_info);
+		ubi_initialized = 0;
 	}
 
+	ubi_dev.selected = 0;
+	return 0;
+}
+
+int ubi_part(char *part_name, const char *vid_header_offset)
+{
+	int err = 0;
+	char mtd_dev[16];
+	struct mtd_device *dev;
+	struct part_info *part;
+	u8 pnum;
+
+	ubi_detach();
 	/*
 	 * Search the mtd device number where this partition
 	 * is located
@@ -517,6 +522,15 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
+
+	if (strcmp(argv[1], "detach") == 0) {
+		if (argc < 2)
+			return CMD_RET_USAGE;
+
+		return ubi_detach();
+	}
+
+
 	if (strcmp(argv[1], "part") == 0) {
 		const char *vid_header_offset = NULL;
 
@@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	ubi, 6, 1, do_ubi,
 	"ubi commands",
-	"part [part] [offset]\n"
+	"detach"
+		" - detach ubi from a mtd partition\n"
+	"ubi part [part] [offset]\n"
 		" - Show or set current partition (with optional VID"
 		" header offset)\n"
 	"ubi info [l[ayout]]"
-- 
2.5.5

  parent reply	other threads:[~2016-05-31 12:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31 12:08 [U-Boot] [PATCH v2 0/7] add support for the etamin draco board variant Heiko Schocher
2016-05-31 12:08 ` [U-Boot] [PATCH v2 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
2016-05-31 12:08 ` Heiko Schocher [this message]
2016-05-31 12:08 ` [U-Boot] [PATCH v2 3/7] nand: add nand mtd concat support Heiko Schocher
2016-06-02  0:09   ` Scott Wood
2016-06-02  5:02     ` Heiko Schocher
2016-06-03 22:30       ` Scott Wood
2016-05-31 12:08 ` [U-Boot] [PATCH v2 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
2016-05-31 12:08 ` [U-Boot] [PATCH v2 5/7] am335x, dxr2: get ECC sType from I2C eeprom Heiko Schocher
2016-05-31 12:08 ` [U-Boot] [PATCH v2 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
2016-05-31 14:43   ` Lukasz Majewski
2016-05-31 12:08 ` [U-Boot] [PATCH v2 7/7] siemens,am33x: add draco etamin board Heiko Schocher

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=1464696492-10349-3-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --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.