From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF4A7C433EF for ; Thu, 14 Oct 2021 18:49:06 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0478C6108E for ; Thu, 14 Oct 2021 18:49:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0478C6108E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8BA4837A2; Thu, 14 Oct 2021 20:48:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="cNxiJg4F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D615836B7; Thu, 14 Oct 2021 20:48:42 +0200 (CEST) Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 A6FA9835C3 for ; Thu, 14 Oct 2021 20:48:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2c.google.com with SMTP id y67so4932765iof.10 for ; Thu, 14 Oct 2021 11:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TV0y5b1tBxLz+7V3MtpL1eIfYnccBYq+Jzlgv+YLd5c=; b=cNxiJg4FbVJdmOJn7ur6syyRr5kkeSWMUOIAKofTxZifEQesy+brio+Ww/JFZr/pyn +Ed+dRuCdXhTvPuXacENb2UdL1aeMDTTYRkiSrORPdyGgWwCgULMC29tkYpPyaX2LXcg 607BLp72Zofb5CbjJiWoTSk+WfgcDlQSIbS3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TV0y5b1tBxLz+7V3MtpL1eIfYnccBYq+Jzlgv+YLd5c=; b=7j6E0gWgb/iCy0oNNdcX1iO2tiqmAvFjCEGMawmzUnGTydHSycqLmxQD2+6hgoKhOn 9CCoG7pkaRd2PV1fFqn+qVfkzBvDVKqSYWsy2QRuLaun2+BNQSoW4EjuFw7FewdduSzv cGkwdhDHgiqgGOuzDjzwnpUFUCBq3lzOASnaYPB43x9Adl0KhSYtNQa/Xz3eawXg+Eop fcQUPb5wYNIF5CvAuDnvr+P4DIUpG+kSofxzYouw/ZH9SzCRZkY2fT590Sxz5DU38NN3 GeDgi+OMWsqxwDc+cHD7oyVMiKiI/aHETO/bL/n28o4YA2mw13WXF4sO4lKMkfy6+gwe ysaQ== X-Gm-Message-State: AOAM531W1whT+PswXNRACJdphmXHqw7LMuQMfrRYT4zrsHG9BI0IaYvr brrMGlHSm2UZakH2UzmFY5fykJNyJrWgpA== X-Google-Smtp-Source: ABdhPJyjhk/jPrWrpc89K7fkGGD5zh/EOycdkXsvuzX7wrJkS+jNcvU00UKF4FHRHJY8pphrGmzWsQ== X-Received: by 2002:a05:6602:2f0a:: with SMTP id q10mr536542iow.76.1634237308273; Thu, 14 Oct 2021 11:48:28 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w15sm1697625ill.23.2021.10.14.11.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:48:27 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Patrice Chotard , Artem Lapkin , Tom Rini , Joe Hershberger , Heinrich Schuchardt , Peter Hoyes , Simon Glass Subject: [PATCH v3 05/18] pxe: Add a userdata field to the context Date: Thu, 14 Oct 2021 12:47:58 -0600 Message-Id: <20211014184811.482560-6-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211014184811.482560-1-sjg@chromium.org> References: <20211014184811.482560-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean Allow the caller to provide some info which is passed back to the readfile() method. Signed-off-by: Simon Glass --- (no changes since v1) cmd/pxe.c | 4 ++-- cmd/pxe_utils.c | 3 ++- cmd/pxe_utils.h | 6 +++++- cmd/sysboot.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/pxe.c b/cmd/pxe.c index 70dbde3a636..d79b9b733d7 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -121,7 +121,7 @@ do_pxe_get(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct pxe_context ctx; int err, i = 0; - pxe_setup_ctx(&ctx, cmdtp, do_get_tftp); + pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL); if (argc != 1) return CMD_RET_USAGE; @@ -175,7 +175,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) char *pxefile_addr_str; struct pxe_context ctx; - pxe_setup_ctx(&ctx, cmdtp, do_get_tftp); + pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL); if (argc == 1) { pxefile_addr_str = from_env("pxefile_addr_r"); diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 2caae6d1555..5ad6d3e3d44 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -1432,8 +1432,9 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) } void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, - pxe_getfile_func getfile) + pxe_getfile_func getfile, void *userdata) { ctx->cmdtp = cmdtp; ctx->getfile = getfile; + ctx->userdata = userdata; } diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h index ca2696f48b0..921455f694e 100644 --- a/cmd/pxe_utils.h +++ b/cmd/pxe_utils.h @@ -86,6 +86,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * * @cmdtp: Pointer to command table to use when calling other commands * @getfile: Function called by PXE to read a file + * @userdata: Data the caller requires for @getfile */ struct pxe_context { struct cmd_tbl *cmdtp; @@ -99,6 +100,8 @@ struct pxe_context { * Return 0 if OK, -ve on error */ pxe_getfile_func getfile; + + void *userdata; }; /** @@ -192,8 +195,9 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * @ctx: Context to set up * @cmdtp: Command table entry which started this action * @getfile: Function to call to read a file + * @userdata: Data the caller requires for @getfile - stored in ctx->userdata */ void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, - pxe_getfile_func getfile); + pxe_getfile_func getfile, void *userdata); #endif /* __PXE_UTILS_H */ diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 082f23543d1..5615e81e9ca 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -91,7 +91,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, env_set("bootfile", filename); } - pxe_setup_ctx(&ctx, cmdtp, NULL); + pxe_setup_ctx(&ctx, cmdtp, NULL, NULL); if (strstr(argv[3], "ext2")) { ctx.getfile = do_get_ext2; } else if (strstr(argv[3], "fat")) { -- 2.33.0.1079.g6e70778dc9-goog