diff mbox

[U-Boot,v1,2/7] ubi: add new ubi command "ubi dettach"

Message ID 1464152832-11200-3-git-send-email-hs@denx.de
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Heiko Schocher May 25, 2016, 5:07 a.m. UTC
simple detachs ubi fram the mtd partition.

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

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

Comments

Scott Wood May 25, 2016, 5:47 a.m. UTC | #1
On 05/25/2016 12:07 AM, Heiko Schocher wrote:
> @@ -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"
> +	"dettach"

"detach", here and elsewhere.

> +		" - detach ubi from a mtd partition\n"

Like that. :-)

-Scott

P.S. When CCing me, please use oss@buserror.net so that my responses
don't have to go through moderation.
Heiko Schocher May 25, 2016, 6:28 a.m. UTC | #2
Hello Scott,

Am 25.05.2016 um 07:47 schrieb Scott Wood:
> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>> @@ -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"
>> +	"dettach"
>
> "detach", here and elsewhere.
>
>> +		" - detach ubi from a mtd partition\n"
>
> Like that. :-)

Thanks! Fixed.

> P.S. When CCing me, please use oss@buserror.net so that my responses
> don't have to go through moderation.

Huh... I used the address in u-boot:/doc/git-mailrc ...
changed.

bye,
Heiko
Scott Wood May 25, 2016, 2:46 p.m. UTC | #3
On 05/25/2016 01:28 AM, Heiko Schocher wrote:
> Hello Scott,
> 
> Am 25.05.2016 um 07:47 schrieb Scott Wood:
>> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>>> @@ -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"
>>> +	"dettach"
>>
>> "detach", here and elsewhere.
>>
>>> +		" - detach ubi from a mtd partition\n"
>>
>> Like that. :-)
> 
> Thanks! Fixed.
> 
>> P.S. When CCing me, please use oss@buserror.net so that my responses
>> don't have to go through moderation.
> 
> Huh... I used the address in u-boot:/doc/git-mailrc ...
> changed.

I changed it in MAINTAINERS... didn't realize there was another place I
needed to change it.  I'll send a patch to update that.

-Scott
diff mbox

Patch

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 753a4db..bf5da42 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_dettach(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_dettach();
 	/*
 	 * 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], "dettach") == 0) {
+		if (argc < 2)
+			return CMD_RET_USAGE;
+
+		return ubi_dettach();
+	}
+
+
 	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"
+	"dettach"
+		" - 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]]"