From patchwork Thu Oct 29 00:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 319304 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp14803ilc; Wed, 28 Oct 2020 17:26:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEgsN+2tNayDgS2oAyHbPDHvmQo5Zqc1rHYyUMJmJmRXthJx1fDszEjR9G/XxsOD7BxQfB X-Received: by 2002:aa7:dc52:: with SMTP id g18mr1482086edu.369.1603931162287; Wed, 28 Oct 2020 17:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603931162; cv=none; d=google.com; s=arc-20160816; b=wWTPvE0YB1Nd1D1BCUGiLVaNQYlRKgPJJtCeR9vsopp3mKFid4gPVBvJdZ1KreI8gm CjBR/fEBV8b/KjORDhkj8V20kEISM2E4BBdLnIuHn+7lR22utNNZcnnxrIAqp79wbLCf wnsesfUl7OFhXnlRxHWkN7KriiebN1cX+9kXjFa47g7JmE057tMVUvpiEC2exIZOCiMW Jyho0oVaULBqVIOymfSf1f2O7q+uzLrzHTNcb07WPdOlgNbgDc89Hg8RE/jm3oyoRjod Kj2PkAgIBRxeaeg6kpriiBNwPIBs6h6VlzNn7fd1urp5gODC5HUtGkUOieF7Hk1D2k/7 lsyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zi7aKf5qP1b8ddwIytuFsCexeq9zKmRYaMwNeAo9Vpk=; b=js6RHqTi3SdWiMh93k4cfuhDM2l20mL86MDBOg8H+mFGrtzS33TBNX8RdF5q0WtMqc fpr6/8ZwG9qYFEkzCpGL2lwNmgI3UeYdQ+J4cAuR6c7kJxCbkPYoE6N+oW/6f8USPx72 CwL883WrrC61O6MznwVXQ34i8w0m3rEFVRtwEW3wLKaQhENVbu67hvQIAzOXjN0zMn44 cL5h2Fq6vFoR1yXqKdX4r9Pw83Jigyvnv5ydYK0OSgvMQ/LhqgC+MMd7GWS31kd4oAb5 YEWHEKXZHGLD1X+xmpaSOVCcFvBl/QXaeq03wYAmXC5z0K3bLWuQoEKxbHv4KIKtJpFs GE8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r2ByijRp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ck9si614039ejb.445.2020.10.28.17.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r2ByijRp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 74AE18246A; Thu, 29 Oct 2020 01:26:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="r2ByijRp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E22C9824A4; Thu, 29 Oct 2020 01:25:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C491682430 for ; Thu, 29 Oct 2020 01:25:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x542.google.com with SMTP id r186so923225pgr.0 for ; Wed, 28 Oct 2020 17:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zi7aKf5qP1b8ddwIytuFsCexeq9zKmRYaMwNeAo9Vpk=; b=r2ByijRp9FGPJgnZKd6ATGIqzf/UEYehaNwWSwcdnF7zrCUBkoFOyW8Vt1/dsL83Xr p4FJJGP+wgd8+bgfss0EjGfzfH5Nosh3EPo78J5BBiUSToYoByKL129TLg/Qc2cfoAQh 0M30hDDAzfYhJHHUeDBZi5PQynbTQTnONDCZ+iVPJrfwCk/qwH28FmRdGxjKbqaXhMHe Blhi5V+Hznzfh+y06RsilgxqwpWpOVvt2ufakm9nHIwrUvxizGm7h3dYcZG08/pI8hyq Fggo4R2e2by6LfiMKOM///0ScI/ftw7pNtIkU8IdI97TyNOh90PsyQTqqiJyy159jivj 0hvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zi7aKf5qP1b8ddwIytuFsCexeq9zKmRYaMwNeAo9Vpk=; b=hvIdybaBffJko7HCP15Txndh9hxrL1iHZbED6ALh4H34V1B2nB2WWL8FLOWdgGd1iV yod4Nz2SGlikyMWMPWQiimrv+urviaZcglmDnc4PjfIL8VvSB6D10FP7f01GK4Ehc/2C SRQwlvoA5dIwZj+ceu9USKWzaw2Zr/phquW+2Wjw9fZs+ycV64jWBlHDPaDorx1ouxsO vNaG1+vNzHbSo5IP0B0nyoa11+yA98YdzFlTg62di4i1+YWE3K5GVBi4le0hCwu4df5u mh1QyWQnHWq2tQy+tYOxYLq8KUk/S0wqxa6wL8aGTbRnbOjK+XaSGenmWUfxEWdBGp3X Nngg== X-Gm-Message-State: AOAM532N3awI4jmlPBzaCaeXnIdxcpLUsEVzFrU8N4XUQbr9Xq7zKWsy pAPC+7VW5ykudUHNKe6Gr/qRBQ== X-Received: by 2002:a63:4e5e:: with SMTP id o30mr1765390pgl.251.1603931155243; Wed, 28 Oct 2020 17:25:55 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id s22sm731502pfu.119.2020.10.28.17.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:25:54 -0700 (PDT) From: AKASHI Takahiro To: lukma@denx.de, trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RESEND PATCH v6 01/17] dfu: rename dfu_tftp_write() to dfu_write_by_name() Date: Thu, 29 Oct 2020 09:25:12 +0900 Message-Id: <20201029002528.34408-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029002528.34408-1-takahiro.akashi@linaro.org> References: <20201029002528.34408-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This function is essentially independent from tftp, and will also be utilised in implementing UEFI capsule update in a later commit. So just give it a more generic name. In addition, a new configuration option, CONFIG_DFU_ALT, was introduced so that the file will be compiled with different options, particularly one added in a later commit. Signed-off-by: AKASHI Takahiro --- common/update.c | 5 +++-- drivers/dfu/Kconfig | 5 +++++ drivers/dfu/Makefile | 2 +- drivers/dfu/{dfu_tftp.c => dfu_alt.c} | 17 ++++++++++++-- include/dfu.h | 32 +++++++++++++-------------- 5 files changed, 40 insertions(+), 21 deletions(-) rename drivers/dfu/{dfu_tftp.c => dfu_alt.c} (67%) -- 2.28.0 diff --git a/common/update.c b/common/update.c index 36b6b7523d50..39946776d74f 100644 --- a/common/update.c +++ b/common/update.c @@ -324,8 +324,9 @@ got_update_file: } } else if (fit_image_check_type(fit, noffset, IH_TYPE_FIRMWARE)) { - ret = dfu_tftp_write(fit_image_name, update_addr, - update_size, interface, devstring); + ret = dfu_write_by_name(fit_image_name, update_addr, + update_size, interface, + devstring); if (ret) return ret; } diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig index 0eec00ba734d..78f901ff348a 100644 --- a/drivers/dfu/Kconfig +++ b/drivers/dfu/Kconfig @@ -14,8 +14,13 @@ config DFU_OVER_TFTP depends on NET if DFU +config DFU_ALT + bool + default n + config DFU_TFTP bool "DFU via TFTP" + select DFU_ALT select DFU_OVER_TFTP help This option allows performing update of DFU-managed medium with data diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile index 0d7925c083ef..cc7de1d3ed9b 100644 --- a/drivers/dfu/Makefile +++ b/drivers/dfu/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_$(SPL_)DFU_MTD) += dfu_mtd.o obj-$(CONFIG_$(SPL_)DFU_NAND) += dfu_nand.o obj-$(CONFIG_$(SPL_)DFU_RAM) += dfu_ram.o obj-$(CONFIG_$(SPL_)DFU_SF) += dfu_sf.o -obj-$(CONFIG_$(SPL_)DFU_TFTP) += dfu_tftp.o +obj-$(CONFIG_$(SPL_)DFU_ALT) += dfu_alt.o obj-$(CONFIG_$(SPL_)DFU_VIRT) += dfu_virt.o diff --git a/drivers/dfu/dfu_tftp.c b/drivers/dfu/dfu_alt.c similarity index 67% rename from drivers/dfu/dfu_tftp.c rename to drivers/dfu/dfu_alt.c index ffae4bb54f80..5b1b13d7170d 100644 --- a/drivers/dfu/dfu_tftp.c +++ b/drivers/dfu/dfu_alt.c @@ -10,8 +10,21 @@ #include #include -int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, - char *interface, char *devstring) +/** + * dfu_write_by_name() - write data to DFU medium + * @dfu_entity_name: Name of DFU entity to write + * @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_entity_name. + * + * Return: 0 - on success, error code - otherwise + */ +int dfu_write_by_name(char *dfu_entity_name, unsigned int addr, + unsigned int len, char *interface, char *devstring) { char *s, *sb; int alt_setting_num, ret; diff --git a/include/dfu.h b/include/dfu.h index 84abdc79acd1..cecfbd76597b 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -494,27 +494,27 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, #endif /** - * dfu_tftp_write() - write TFTP data to DFU medium + * dfu_write_by_name() - write data to DFU medium + * @dfu_entity_name: Name of DFU entity to write + * @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 via TFTP on DFU supported medium. + * This function is storing data received on DFU supported medium which + * is specified by @dfu_entity_name. * - * @dfu_entity_name: name of DFU entity to write - * @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") - * - * Return: 0 on success, otherwise error code + * Return: 0 - on success, error code - otherwise */ -#if CONFIG_IS_ENABLED(DFU_TFTP) -int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, - char *interface, char *devstring); +#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); #else -static inline int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, - unsigned int len, char *interface, - char *devstring) +static inline int dfu_write_by_name(char *dfu_entity_name, unsigned int addr, + unsigned int len, char *interface, + char *devstring) { - puts("TFTP write support for DFU not available!\n"); + puts("write support for DFU not available!\n"); return -ENOSYS; } #endif