summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2018-06-01 20:07:49 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-06-08 09:10:10 +0200
commit9afdc614d0c8c6de913444d8fbb1a066eb957fc7 (patch)
tree835e455959ae26fb7c34409b31fcffb76972c37e /arch/arm/mach-omap
parentfd3ecff9ec5e45bf66d27da979c58bf23cd307da (diff)
downloadbarebox-9afdc614d0c8c6de913444d8fbb1a066eb957fc7.tar.gz
barebox-9afdc614d0c8c6de913444d8fbb1a066eb957fc7.tar.xz
omap/am33xx_bbu: use file_write_flash() instead of its own variant
There are two differences between file_write_flash() and write_image() (which is removed in this patch): - file_write_flash() uses write_full() vs. write() in write_image() - file_write_flash() doesn't erase the whole device but only the needed space So the new code should be more robust and maybe even faster. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-omap')
-rw-r--r--arch/arm/mach-omap/am33xx_bbu_nand.c38
1 files changed, 3 insertions, 35 deletions
diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c
index 7785d40f1f..6fc6e7e40f 100644
--- a/arch/arm/mach-omap/am33xx_bbu_nand.c
+++ b/arch/arm/mach-omap/am33xx_bbu_nand.c
@@ -20,6 +20,7 @@
#include <bbu.h>
#include <fs.h>
#include <fcntl.h>
+#include <libfile.h>
#include <filetype.h>
struct nand_bbu_handler {
@@ -28,39 +29,6 @@ struct nand_bbu_handler {
int num_devicefiles;
};
-static int write_image(const char *devfile, const void *image, size_t size)
-{
- int fd = 0;
- int ret = 0;
-
- fd = open(devfile, O_WRONLY);
- if (fd < 0) {
- pr_err("could not open %s: %s\n", devfile,
- errno_str());
- return fd;
- }
-
- ret = erase(fd, ERASE_SIZE_ALL, 0);
- if (ret < 0) {
- pr_err("could not erase %s: %s\n", devfile,
- errno_str());
- close(fd);
- return ret;
- }
-
- ret = write(fd, image, size);
- if (ret < 0) {
- pr_err("could not write to fd %s: %s\n", devfile,
- errno_str());
- close(fd);
- return ret;
- }
-
- close(fd);
-
- return 0;
-}
-
/*
* Upate given nand partitions with an image
*/
@@ -80,12 +48,12 @@ static int nand_slot_update_handler(struct bbu_handler *handler,
/* check if the devicefile has been overwritten */
if (strcmp(data->devicefile, nh->devicefile[0]) != 0) {
- ret = write_image(data->devicefile, image, size);
+ ret = write_file_flash(data->devicefile, image, size);
if (ret != 0)
return ret;
} else {
for (i = 0; i < nh->num_devicefiles; i++) {
- ret = write_image(nh->devicefile[i], image, size);
+ ret = write_file_flash(nh->devicefile[i], image, size);
if (ret != 0)
return ret;
}