All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 12/17] dfu: add dfu_write_by_alt()
Date: Wed, 17 Jun 2020 11:55:10 +0900	[thread overview]
Message-ID: <20200617025515.23585-13-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <20200617025515.23585-1-takahiro.akashi@linaro.org>

This function is a variant of dfu_write_by_name() and takes a DFU alt
setting number for dfu configuration.

It will be utilised to implement UEFI capsule management protocol for
raw image in a later commit.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 drivers/dfu/dfu_alt.c | 47 +++++++++++++++++++++++++++++++++++++++++++
 include/dfu.h         | 26 +++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/dfu/dfu_alt.c b/drivers/dfu/dfu_alt.c
index 5b1b13d7170d..bd846bdefffd 100644
--- a/drivers/dfu/dfu_alt.c
+++ b/drivers/dfu/dfu_alt.c
@@ -76,3 +76,50 @@ done:
 
 	return ret;
 }
+
+/**
+ * dfu_write_by_alt() - write data to DFU medium
+ * @dfu_alt_num:        DFU alt setting number
+ * @addr:               Address of data buffer to write
+ * @len:                Number of bytes
+ * @interface:          Destination DFU medium (e.g. "mmc")
+ * @devstring:          Instance number of destination DFU medium (e.g. "1")
+ *
+ * This function is storing data received on DFU supported medium which
+ * is specified by @dfu_alt_name.
+ *
+ * Return:              0 - on success, error code - otherwise
+ */
+int dfu_write_by_alt(int dfu_alt_num, unsigned int addr, unsigned int len,
+		     char *interface, char *devstring)
+{
+	struct dfu_entity *dfu;
+	int ret;
+
+	debug("%s: alt: %d addr: 0x%x len: %d device: %s:%s\n", __func__,
+	      dfu_alt_num, addr, len, interface, devstring);
+
+	ret = dfu_init_env_entities(interface, devstring);
+	if (ret)
+		goto done;
+
+	if (dfu_alt_num < 0) {
+		pr_err("Invalid alt number: %d", dfu_alt_num);
+		ret = -ENODEV;
+		goto done;
+	}
+
+	dfu = dfu_get_entity(dfu_alt_num);
+	if (!dfu) {
+		pr_err("DFU entity for alt: %d not found!", dfu_alt_num);
+		ret = -ENODEV;
+		goto done;
+	}
+
+	ret = dfu_write_from_mem_addr(dfu, (void *)(uintptr_t)addr, len);
+
+done:
+	dfu_free_entities();
+
+	return ret;
+}
diff --git a/include/dfu.h b/include/dfu.h
index e9af9503d685..36c80c28f081 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -496,6 +496,7 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
 }
 #endif
 
+#if CONFIG_IS_ENABLED(DFU_ALT)
 /**
  * dfu_write_by_name() - write data to DFU medium
  * @dfu_entity_name:	Name of DFU entity to write
@@ -509,9 +510,24 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
  *
  * Return:		0 - on success, error code - otherwise
  */
-#if CONFIG_IS_ENABLED(DFU_ALT)
 int dfu_write_by_name(char *dfu_entity_name, unsigned int addr,
 		      unsigned int len, char *interface, char *devstring);
+
+/**
+ * dfu_write_by_alt() - write data to DFU medium
+ * @dfu_alt_num:	DFU alt setting number
+ * @addr:		Address of data buffer to write
+ * @len:		Number of bytes
+ * @interface:		Destination DFU medium (e.g. "mmc")
+ * @devstring:		Instance number of destination DFU medium (e.g. "1")
+ *
+ * This function is storing data received on DFU supported medium which
+ * is specified by @dfu_alt_name.
+ *
+ * Return:		0 - on success, error code - otherwise
+ */
+int dfu_write_by_alt(int dfu_alt_num, unsigned int addr, unsigned int len,
+		     char *interface, char *devstring);
 #else
 static inline int dfu_write_by_name(char *dfu_entity_name, unsigned int addr,
 				    unsigned int len, char *interface,
@@ -520,6 +536,14 @@ static inline int dfu_write_by_name(char *dfu_entity_name, unsigned int addr,
 	puts("write support for DFU not available!\n");
 	return -ENOSYS;
 }
+
+static inline int dfu_write_by_alt(int dfu_alt_num, unsigned int addr,
+				   unsigned int len, char *interface,
+				   char *devstring)
+{
+	puts("write support for DFU not available!\n");
+	return -ENOSYS;
+}
 #endif
 
 int dfu_add(struct usb_configuration *c);
-- 
2.27.0

  parent reply	other threads:[~2020-06-17  2:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  2:54 [PATCH v2 00/17] efi_loader: add capsule update support AKASHI Takahiro
2020-06-17  2:54 ` [PATCH v2 01/17] common: update_tftp: remove unnecessary build check AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 02/17] dfu: add a hidden reverse-dependency on UPDATE_TFTP AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 03/17] dfu: rename dfu_tftp_write() to dfu_write_by_name() AKASHI Takahiro
2020-06-20 18:35   ` Sughosh Ganu
2020-06-21  7:38     ` Lukasz Majewski
2020-06-22  0:41       ` AKASHI Takahiro
2020-06-22  7:19         ` Lukasz Majewski
2020-06-22  0:58     ` AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 04/17] common: update: add a generic interface for FIT image AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 05/17] dfu: export dfu_list AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 06/17] efi_loader: add option to initialise EFI subsystem early AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 07/17] efi_loader: define UpdateCapsule api AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 08/17] efi_loader: capsule: add capsule_on_disk support AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 09/17] efi_loader: capsule: add memory range capsule definitions AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 10/17] efi_loader: capsule: support firmware update AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 11/17] efi_loader: add firmware management protocol for FIT image AKASHI Takahiro
2020-06-20 18:39   ` Sughosh Ganu
2020-06-22  1:03     ` AKASHI Takahiro
2020-06-20 18:49   ` Sughosh Ganu
2020-06-22  1:09     ` AKASHI Takahiro
2020-06-22  7:58       ` Sughosh Ganu
2020-06-22  8:06         ` AKASHI Takahiro
2020-06-22  8:38           ` Sughosh Ganu
2020-06-17  2:55 ` AKASHI Takahiro [this message]
2020-06-17  2:55 ` [PATCH v2 13/17] efi_loader: add firmware management protocol for raw image AKASHI Takahiro
2020-06-20 18:57   ` Sughosh Ganu
2020-06-22  1:21     ` AKASHI Takahiro
2020-06-22  7:53       ` Sughosh Ganu
2020-06-17  2:55 ` [PATCH v2 14/17] cmd: add "efidebug capsule" command AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 15/17] tools: add mkeficapsule command for UEFI capsule update AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 16/17] test/py: add a test for efi firmware update capsule of FIT image AKASHI Takahiro
2020-06-17  2:55 ` [PATCH v2 17/17] test/py: add a test for uefi firmware update capsule of raw image AKASHI Takahiro

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=20200617025515.23585-13-takahiro.akashi@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --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.