{"id":2216030,"url":"http://patchwork.ozlabs.org/api/patches/2216030/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260325165431.1027591-7-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260325165431.1027591-7-sjg@chromium.org>","list_archive_url":null,"date":"2026-03-25T16:54:15","name":"[06/13] boot: Move obtaining data from a FIT image into a function","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"fb7128bec4ed68ef5e90e0eb087b02ce0d583770","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260325165431.1027591-7-sjg@chromium.org/mbox/","series":[{"id":497475,"url":"http://patchwork.ozlabs.org/api/series/497475/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=497475","date":"2026-03-25T16:54:09","name":"boot: Make fit_image_load() easier to maintain","version":1,"mbox":"http://patchwork.ozlabs.org/series/497475/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2216030/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2216030/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256\n header.s=google header.b=j08XqQgw;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org\n header.b=\"j08XqQgw\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=sjg@chromium.org"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgtNH05WKz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 03:56:31 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 52D3483FEC;\n\tWed, 25 Mar 2026 17:55:50 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id 4CEF883F60; Wed, 25 Mar 2026 17:55:47 +0100 (CET)","from mail-oi1-x231.google.com (mail-oi1-x231.google.com\n [IPv6:2607:f8b0:4864:20::231])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 1E9D383FC5\n for <u-boot@lists.denx.de>; Wed, 25 Mar 2026 17:55:45 +0100 (CET)","by mail-oi1-x231.google.com with SMTP id\n 5614622812f47-46726528f1cso12793b6e.0\n for <u-boot@lists.denx.de>; Wed, 25 Mar 2026 09:55:45 -0700 (PDT)","from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id\n 5614622812f47-46a7099df08sm30481b6e.15.2026.03.25.09.55.41\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 09:55:42 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=chromium.org; s=google; t=1774457743; x=1775062543; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=KQO7SfvIzGzetk/xnfpE5Y/k6hx9hH32lsuldyisw5g=;\n b=j08XqQgwhRORHoteV9HmmGEIah1ZnPfDBknKSGMEmWd63fo9+pl0Mm9hzd8TPzCQ1m\n bXgCteb98gT8rdUlofDUEpWDY1cqRuWmr04WfIV1/MZdYzPFUHMHSDhF7dnR+vvJiQAj\n OZV7QOPkhnz5ItEuvTTmpV+Mi/su4nWPj4RLc=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774457743; x=1775062543;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=KQO7SfvIzGzetk/xnfpE5Y/k6hx9hH32lsuldyisw5g=;\n b=nqYRe8zgND0aZrA20p8R2HY5JjOln1j86HqIDYL6u3OlcGPTaazGJ56EaXO2LIiU0w\n 9HKPDdHiMt7Ye89wXVf2pYWxWWK62uDFPFudXXbyVVG0NC3r8wlywbC1iI5s/AkOnTm9\n F9sY8lM/A4PkHl1IerFWBmdUmV7jtA9h7AVrjBkEsaoLWZy/ou6122wEmkNmompx5gOi\n 89gkUY0dnvP1lfO4ysUImbEYWgzgLwfoN26ge/Dj3jaJSmb/tMQdqts9pIa7BXDzQ8E7\n fwfPHaRg62q26UyVPRjwkS5CWxvjXM2iVAeJb/Izt3WlNV5bUXq7xja/AbbJttcnUSJj\n S9Pg==","X-Gm-Message-State":"AOJu0YyLO7eB+KqG8ysgA8W8Eo8tVSZrpNiD4QoeW6EJ2EyDdv3eD2iY\n hUPa9IRQylHouZYf4wBw69OJMee4B2YjiDmSYsv1jgZUgTV3X0UGqSiFHLWemndqgibpWRtgvNk\n aw9YcyA==","X-Gm-Gg":"ATEYQzzvV5ZRQgeP+gbS1c+N9YNsmtgaZbdaxq1HN7cZPrvuIYRLNSIjDmkIVet8eId\n YR2u4yHI79H1cul8YsgVye9mk5zF7libIhsOJcu/VvHrYNAzw04msBXPsZgnsyj6UPGjDC4qrH1\n rPos3nvWHsGQZm3/JSm7wViRFuiqpS5OfZq6SSvCsdYwlEjwm6wjMqyh8K7zmutlmp6G6t/PcBd\n CRthfbTS9BqOO3ON+47zVHV9jkuLH822Hh+dylzQ72FLJA1C0eTZuSnwlECcsJIQvo2qKB0/924\n jCJbXxNpTiYPqV3hIUFOtMx2+NlVdcKJ/t+vsztNGVu7gpc2zwVUhu1v9tcOMnOwdR5N8jvvotD\n WMu/4aXvtZb7W2Cis2a3MW4OrFZXtzIjEvxc9iuPljRNcobCebWGniPqmw/SnCiYq2I3ZvNDtjR\n zciSp4Mz+P1sx8GCaixQ==","X-Received":"by 2002:a05:6808:1185:b0:455:d3f2:4bf9 with SMTP id\n 5614622812f47-46a5c79e201mr2015662b6e.30.1774457743278;\n Wed, 25 Mar 2026 09:55:43 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"u-boot@lists.denx.de","Cc":"Simon Glass <sjg@chromium.org>,\n James Hilliard <james.hilliard1@gmail.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Quentin Schulz <quentin.schulz@cherry.de>, Tom Rini <trini@konsulko.com>","Subject":"[PATCH 06/13] boot: Move obtaining data from a FIT image into a\n function","Date":"Wed, 25 Mar 2026 10:54:15 -0600","Message-ID":"<20260325165431.1027591-7-sjg@chromium.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260325165431.1027591-1-sjg@chromium.org>","References":"<20260325165431.1027591-1-sjg@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Move this code into a separate function, to help further slim down\nfit_image_load().\n\nMove the bootstage_mark() call in there too.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n boot/image-fit.c | 75 ++++++++++++++++++++++++++++++++----------------\n 1 file changed, 50 insertions(+), 25 deletions(-)","diff":"diff --git a/boot/image-fit.c b/boot/image-fit.c\nindex c5067b63682..5e90cd2cf50 100644\n--- a/boot/image-fit.c\n+++ b/boot/image-fit.c\n@@ -2232,6 +2232,53 @@ static int check_allowed(const void *fit, int noffset,\n \treturn 0;\n }\n \n+/**\n+ * obtain_data() - Obtain the data from the FIT\n+ *\n+ * Get the location of the data in the FIT and see if it needs to be deciphered\n+ * or processed in some grubby board-specific way.\n+ *\n+ * @fit: FIT to check\n+ * @noffset: Node offset of the image being loaded\n+ * @prop_name: Property name (in the configuration node) indicating the image\n+ * that was loaded\n+ * @bootstage_id: ID of starting bootstage to use for progress updates\n+ * @bufp: Returns a pointer to the data\n+ * @sizep: Returns the size of the data\n+ * Return: 0 if OK, -ve on error\n+ */\n+static int obtain_data(const void *fit, int noffset, const char *prop_name,\n+\t\t       int bootstage_id, void **bufp, ulong *sizep)\n+{\n+\tsize_t size;\n+\n+\t/* get image data address and length */\n+\tif (fit_image_get_data(fit, noffset, (const void **)bufp, &size)) {\n+\t\tprintf(\"Could not find %s subimage data!\\n\", prop_name);\n+\t\tbootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);\n+\t\treturn -ENOENT;\n+\t}\n+\n+\t/* Decrypt data before uncompress/move */\n+\tif (IS_ENABLED(CONFIG_FIT_CIPHER) && IMAGE_ENABLE_DECRYPT) {\n+\t\tputs(\"   Decrypting Data ... \");\n+\t\tif (fit_image_uncipher(fit, noffset, bufp, &size)) {\n+\t\t\tputs(\"Error\\n\");\n+\t\t\treturn -EACCES;\n+\t\t}\n+\t\tputs(\"OK\\n\");\n+\t}\n+\n+\t/* perform any post-processing on the image data */\n+\tif (!tools_build() && IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS))\n+\t\tboard_fit_image_post_process(fit, noffset, bufp, &size);\n+\n+\tbootstage_mark(bootstage_id + BOOTSTAGE_SUB_GET_DATA_OK);\n+\t*sizep = size;\n+\n+\treturn 0;\n+}\n+\n /**\n  * handle_load_op() - Handle the load operation\n  *\n@@ -2314,7 +2361,6 @@ int fit_image_load(struct bootm_headers *images, ulong addr,\n \tconst void *fit;\n \tvoid *buf;\n \tvoid *loadbuf;\n-\tsize_t size;\n \tulong load, load_end, data, len;\n \tuint8_t comp, os_arch;\n \tconst char *prop_name;\n@@ -2349,30 +2395,9 @@ int fit_image_load(struct bootm_headers *images, ulong addr,\n \tif (ret)\n \t\treturn ret;\n \n-\t/* get image data address and length */\n-\tif (fit_image_get_data(fit, noffset, (const void **)&buf, &size)) {\n-\t\tprintf(\"Could not find %s subimage data!\\n\", prop_name);\n-\t\tbootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);\n-\t\treturn -ENOENT;\n-\t}\n-\n-\t/* Decrypt data before uncompress/move */\n-\tif (IS_ENABLED(CONFIG_FIT_CIPHER) && IMAGE_ENABLE_DECRYPT) {\n-\t\tputs(\"   Decrypting Data ... \");\n-\t\tif (fit_image_uncipher(fit, noffset, &buf, &size)) {\n-\t\t\tputs(\"Error\\n\");\n-\t\t\treturn -EACCES;\n-\t\t}\n-\t\tputs(\"OK\\n\");\n-\t}\n-\n-\t/* perform any post-processing on the image data */\n-\tif (!tools_build() && IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS))\n-\t\tboard_fit_image_post_process(fit, noffset, &buf, &size);\n-\n-\tlen = (ulong)size;\n-\n-\tbootstage_mark(bootstage_id + BOOTSTAGE_SUB_GET_DATA_OK);\n+\tret = obtain_data(fit, noffset, prop_name, bootstage_id, &buf, &len);\n+\tif (ret)\n+\t\treturn ret;\n \n \tret = handle_load_op(fit, noffset, prop_name, buf, len, image_type,\n \t\t\t     load_op, bootstage_id, &data, &load, &load_end);\n","prefixes":["06/13"]}