meta-ampere: mtd-utils: fix flashcp offset apply fail

The patch to support flashcp offset parameter is fail to apply because
of new mtd-utils revision. This commit updates the patch to resolve the
compilation warning on apply failure.

Tested:
1. Compile Mt.Jade OpenBMC without warning about mtd-utils.
2. Flash EDKII firmware using ampere_flash_bios.sh and check Host boots
   successfully.

Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I9026ac5bafc07ee5eff7efdf7890d0eef2161c52
diff --git a/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch
index 174a1cd..0edae05 100644
--- a/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch
+++ b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch
@@ -1,6 +1,6 @@
-From e29268bb252b4eec5830816912817a2650b04ee9 Mon Sep 17 00:00:00 2001
+From 32c17dd886a5b506781b86c6227bb059ce33420b Mon Sep 17 00:00:00 2001
 From: Tung Nguyen <tung.nguyen@amperecomputing.com>
-Date: Tue, 20 Jul 2021 15:32:32 +0700
+Date: Sun, 5 Sep 2021 09:22:08 +0000
 Subject: [PATCH] flashcp support offset option
 
 The flashcp command from mtd-utils just support to flash from offset 0.
@@ -8,17 +8,15 @@
 flashed correctly
 
 Signed-off-by: Tung Nguyen <tung.nguyen@amperecomputing.com>
-
-%% original patch: 0001-support-flash-offset.patch
 ---
  misc-utils/flashcp.c | 50 +++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 47 insertions(+), 3 deletions(-)
 
 diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c
-index d7b0a59..d1ef79c 100644
+index 341c210..0a0e75b 100644
 --- a/misc-utils/flashcp.c
 +++ b/misc-utils/flashcp.c
-@@ -90,7 +90,7 @@ static NORETURN void showusage(bool error)
+@@ -91,7 +91,7 @@ static NORETURN void showusage(bool error)
  			"\n"
  			"Flash Copy - Written by Abraham van der Merwe <abraham@2d3d.co.za>\n"
  			"\n"
@@ -27,7 +25,7 @@
  			"       %1$s -h | --help\n"
  			"       %1$s -V | --version\n"
  			"\n"
-@@ -100,6 +100,7 @@ static NORETURN void showusage(bool error)
+@@ -102,6 +102,7 @@ static NORETURN void showusage(bool error)
  			"   -V | --version   Show version information and exit\n"
  			"   <filename>       File which you want to copy to flash\n"
  			"   <device>         Flash device to write to (e.g. /dev/mtd0, /dev/mtd1, etc.)\n"
@@ -35,7 +33,7 @@
  			"\n",
  			PROGRAM_NAME);
  
-@@ -154,6 +155,16 @@ static void safe_rewind (int fd,const char *filename)
+@@ -156,6 +157,16 @@ static void safe_rewind (int fd,const char *filename)
  	}
  }
  
@@ -52,7 +50,7 @@
  /******************************************************************************/
  
  static int dev_fd = -1,fil_fd = -1;
-@@ -167,6 +178,8 @@ static void cleanup (void)
+@@ -169,6 +180,8 @@ static void cleanup (void)
  int main (int argc,char *argv[])
  {
  	const char *filename = NULL,*device = NULL;
@@ -61,7 +59,7 @@
  	int i,flags = FLAG_NONE;
  	ssize_t result;
  	size_t size,written;
-@@ -218,6 +231,20 @@ int main (int argc,char *argv[])
+@@ -225,6 +238,20 @@ int main (int argc,char *argv[])
  				showusage(true);
  		}
  	}
@@ -82,7 +80,7 @@
  	if (optind+2 == argc) {
  		flags |= FLAG_FILENAME;
  		filename = argv[optind];
-@@ -226,6 +253,8 @@ int main (int argc,char *argv[])
+@@ -233,6 +260,8 @@ int main (int argc,char *argv[])
  		flags |= FLAG_DEVICE;
  		device = argv[optind+1];
  		DEBUG("Got device: %s\n",device);
@@ -91,7 +89,7 @@
  	}
  
  	if (flags & FLAG_HELP || device == NULL)
-@@ -257,6 +286,12 @@ int main (int argc,char *argv[])
+@@ -264,6 +293,12 @@ int main (int argc,char *argv[])
  		exit (EXIT_FAILURE);
  	}
  
@@ -101,10 +99,10 @@
 +		exit(EXIT_FAILURE);
 +	}
 +
- 	/*****************************************************
- 	 * erase enough blocks so that we can write the file *
- 	 *****************************************************/
-@@ -271,6 +306,8 @@ int main (int argc,char *argv[])
+ 	/* diff block flashcp */
+ 	if (flags & FLAG_PARTITION)
+ 	{
+@@ -284,6 +319,8 @@ int main (int argc,char *argv[])
  	}
  	else
  	{
@@ -113,7 +111,7 @@
  		erase.length = (filestat.st_size + mtd.erasesize - 1) / mtd.erasesize;
  		erase.length *= mtd.erasesize;
  	}
-@@ -317,6 +354,12 @@ int main (int argc,char *argv[])
+@@ -330,6 +367,12 @@ int main (int argc,char *argv[])
  	size = filestat.st_size;
  	i = BUFSIZE;
  	written = 0;
@@ -126,7 +124,7 @@
  	while (size)
  	{
  		if (size < BUFSIZE) i = size;
-@@ -361,8 +404,9 @@ int main (int argc,char *argv[])
+@@ -374,8 +417,9 @@ int main (int argc,char *argv[])
  	 * verify that flash == file data *
  	 **********************************/
  
@@ -139,5 +137,5 @@
  	i = BUFSIZE;
  	written = 0;
 -- 
-2.17.1
+2.25.1