From patchwork Thu Oct 29 04:47:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 319340 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp141532ilc; Wed, 28 Oct 2020 21:49:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyymVBYyLUK2er4HSw3oGBdSgD68b1p62+THF8jbYrytfzgToq597cdCfiAKDTLYdff3J81 X-Received: by 2002:aa7:cb8f:: with SMTP id r15mr2237967edt.356.1603946984450; Wed, 28 Oct 2020 21:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603946984; cv=none; d=google.com; s=arc-20160816; b=eiAydoSC6a+4BsQV+uKge84f6/y7xZuUGfnyWw8y+VBM81B85tlWU6psZeaPe3XG3X eeUX9A9CD7z8vLoUV9eikpCcdulv7jhiPpCIjohpoVekYRhkl8iOXnYTCcxIPOt3qvS1 CXj9EtCgWrvsd3XDmmhj+TUgsi6YvX9fSP/j8y5e/4C5LVF0yivNMxfXMUT9rSI3ieIQ x05D3Fb1RS8V4EjOIM1cOpY1sODgw/GJ2nsIvsQwt/1n5e5EY3/wp6EaSUJvhMICmA9p 3Ras3Hu6RfvtZYZNHKyqoI2tLW266m4IKzP2MjUz6a1S9+ZUhtElNYeeWtLb+YJy2ofm b2tg== 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=gg+NeQZLDkliFD0+MH+JwxAli8bu6hM7uUdYZB++vok=; b=DKbn/dIFCpg7lvRjmE5BdncvQK5SJA4kFrZGp6bWrg3bzKP8uD9/xbEIUzJ1UGBZ/B vR1MwdsnQ5kub88hZS5QH/iTRJ3cFrbcuLZ77IowuR4iRC+GAZE9mSxKjRR7fwn/nf3D 4NtZ33GOkfILxwaozZy61KGZ1js00sgIlCQvIT6QQauKmdYglTWHRKNVKvFp1fbj8qCP UBuPxooxIkfn1i5Ah8qxjbRpa/iik+wIRLH/JtJKlJJyiMU2tHresJPEfgiwYhWCt4Mp 9MZ4jgzYhlUvWLPHHY/wcP4CaXD0n5F4LlcAA8wCIf1YShKF5UHeRYii6IMwOt0tlzbm Vebg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M2c6bZHF; 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 qc1si1141731ejb.315.2020.10.28.21.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 21:49:44 -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=M2c6bZHF; 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 D85998229F; Thu, 29 Oct 2020 05:49:43 +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="M2c6bZHF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 910DC801D8; Thu, 29 Oct 2020 05:49:42 +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-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 7B18B801D8 for ; Thu, 29 Oct 2020 05:49:39 +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-x544.google.com with SMTP id i26so1343340pgl.5 for ; Wed, 28 Oct 2020 21:49:39 -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=gg+NeQZLDkliFD0+MH+JwxAli8bu6hM7uUdYZB++vok=; b=M2c6bZHFqCDNveDOWt99O4E8ZABFL/xXZDXNrwhDxwS2yESQATqOEvIoF5Vbwgk6bG Hm3McWRvB2BoVGVEZIaFZOMHFOaXWAua7bccrCb9rJu4j9jkiYp/NBZ0xy6wYvI75yte MQAQGiOBDsgB0dLhWJr7Reo3KLLSc9Me5iJA4l82n7LT2yYEsw26yoiH4M0rCXzN/zAH zS0khtn+MSJQ/nBlF3xIHI/f/PAKT1icSH/4tG6z4njSChvwfihcl992Z1CMy0in2+PF +JsbTyyW+YQfVmA8/QAG6UuWxnLM7NXkKtOHUAl1JySA6lKlm+imh9aRh1iwwy19cPV6 RxQQ== 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=gg+NeQZLDkliFD0+MH+JwxAli8bu6hM7uUdYZB++vok=; b=dGFljVC3PN8uFUAVbs/viZVs0DnGEgQuNv3vHRRy9uhn94GMC8aQf3a3+wKXBf70hD 7feiYaJiub6JY3ZD5liNl9N/ErQOScYU/tuswz01aG2edWjaq3r6UpEh7fxXjTdnQbj2 zY/l3M8+AzgvA2mPxk5jqVdK3rNfGXOvrDVSKdhmMNlBHNXUerq5KJEJAuYhW5vPc+Ef PadJpzNWZ9gh0/fgVe2fGYtVAOqlz/EknHCfDro/dd0+69e0TfYCF58q7e5iSkqy/bos 4q4OjYaAoXbiFs9LKA7I2wjXKv7/jYvJiInUAUjUA7wJnPdcGyww8bC0LTywJA3Ko8PR 2Eaw== X-Gm-Message-State: AOAM531zNBmK7oGdjP4gGBMvsLsxS71e97Kcz4/znBgpO+lY7hMH7ne2 JVdLL7RZX86JfZCpfBxWGyReHA== X-Received: by 2002:a17:90a:3f10:: with SMTP id l16mr2378016pjc.110.1603946978033; Wed, 28 Oct 2020 21:49:38 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id t14sm830689pjy.46.2020.10.28.21.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 21:49:37 -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: [PATCH v7 01/17] dfu: rename dfu_tftp_write() to dfu_write_by_name() Date: Thu, 29 Oct 2020 13:47:41 +0900 Message-Id: <20201029044757.183262-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029044757.183262-1-takahiro.akashi@linaro.org> References: <20201029044757.183262-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_WRITE_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 Reviewed-by: Tom Rini 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..10196f390fcd 100644 --- a/drivers/dfu/Kconfig +++ b/drivers/dfu/Kconfig @@ -14,8 +14,13 @@ config DFU_OVER_TFTP depends on NET if DFU +config DFU_WRITE_ALT + bool + default n + config DFU_TFTP bool "DFU via TFTP" + select DFU_WRITE_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..dfbf64da6677 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_WRITE_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..a4cd86c0a6c4 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_WRITE_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