mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] ARM: AM335x: replace specific barebox update handler with generic one
Date: Wed,  1 Jul 2015 09:11:58 +0200	[thread overview]
Message-ID: <1435734718-18367-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1435734718-18367-1-git-send-email-s.hauer@pengutronix.de>

The AM335x SPI NOR barebox update handlers only writes a file to a device,
so use the generic handler for this purpose.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-omap/am33xx_bbu_spi_mlo.c | 56 ---------------------------------
 arch/arm/mach-omap/include/mach/bbu.h   |  5 ++-
 2 files changed, 2 insertions(+), 59 deletions(-)

diff --git a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
index 97dc54e..702bb9a 100644
--- a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
+++ b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
@@ -97,41 +97,6 @@ out:
 	return ret;
 }
 
-static int spi_nor_handler(struct bbu_handler *handler,
-					struct bbu_data *data)
-{
-	int fd, ret;
-
-	if (file_detect_type(data->image, data->len) != filetype_arm_barebox) {
-		if (!bbu_force(data, "Not an ARM barebox image"))
-			return -EINVAL;
-	}
-
-	fd = open(data->devicefile, O_RDWR | O_CREAT);
-	if (fd < 0)
-		return fd;
-
-	debug("%s: eraseing %s from 0 to 0x%08x\n", __func__,
-			data->devicefile, data->len);
-	ret = erase(fd, data->len, 0);
-	if (ret) {
-		printf("erasing %s failed with %s\n", data->devicefile,
-				strerror(-ret));
-		goto err_close;
-	}
-
-	ret = write(fd, data->image, data->len);
-	if (ret < 0)
-		goto err_close;
-
-	ret = 0;
-
-err_close:
-	close(fd);
-
-	return ret;
-}
-
 /*
  * Register a am33xx MLO update handler for SPI NOR
  */
@@ -152,24 +117,3 @@ int am33xx_bbu_spi_nor_mlo_register_handler(const char *name, char *devicefile)
 
 	return ret;
 }
-
-/*
- * Register a am33xx update handler for SPI NOR
- */
-int am33xx_bbu_spi_nor_register_handler(const char *name, char *devicefile)
-{
-	struct bbu_handler *handler;
-	int ret;
-
-	handler = xzalloc(sizeof(*handler));
-	handler->devicefile = devicefile;
-	handler->name = name;
-	handler->handler = spi_nor_handler;
-
-	ret = bbu_register_handler(handler);
-
-	if (ret)
-		free(handler);
-
-	return ret;
-}
diff --git a/arch/arm/mach-omap/include/mach/bbu.h b/arch/arm/mach-omap/include/mach/bbu.h
index 36d87e1..da5c214 100644
--- a/arch/arm/mach-omap/include/mach/bbu.h
+++ b/arch/arm/mach-omap/include/mach/bbu.h
@@ -5,18 +5,17 @@
 
 #ifdef CONFIG_BAREBOX_UPDATE_AM33XX_SPI_NOR_MLO
 int am33xx_bbu_spi_nor_mlo_register_handler(const char *name, char *devicefile);
-int am33xx_bbu_spi_nor_register_handler(const char *name, char *devicefile);
 #else
 static inline int am33xx_bbu_spi_nor_mlo_register_handler(const char *name, char *devicefile)
 {
 	return 0;
 }
+#endif
 
 static inline int am33xx_bbu_spi_nor_register_handler(const char *name, char *devicefile)
 {
-	return 0;
+	return bbu_register_std_file_update(name, 0, devicefile, filetype_arm_barebox);
 }
-#endif
 
 #ifdef CONFIG_BAREBOX_UPDATE_AM33XX_NAND
 int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2015-07-01  7:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  7:11 [PATCH 1/2] bbu: Add a standard file-to-device-copy handler Sascha Hauer
2015-07-01  7:11 ` Sascha Hauer [this message]

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=1435734718-18367-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox