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 81F09C433EF for ; Tue, 9 Nov 2021 08:11:30 +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 02695611BD for ; Tue, 9 Nov 2021 08:11:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 02695611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 657B98392B; Tue, 9 Nov 2021 09:11:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="Nz0kMOmQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 136E283917; Tue, 9 Nov 2021 09:11:27 +0100 (CET) Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) (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 5B0E18393C for ; Tue, 9 Nov 2021 09:11:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-oo1-xc2c.google.com with SMTP id m37-20020a4a9528000000b002b83955f771so6669131ooi.7 for ; Tue, 09 Nov 2021 00:11:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wpg1AriOZWy/xFcst2si/lCpPT0Ryl90fgiUm+fa70w=; b=Nz0kMOmQwovt26vBNEyl+QXSh7zWr6H9nTj5sliYpNQ4eOTp4s48T9ZCrswvsrsaHC SIKlAc4h9/nBFn+ZnVka1hfM5aElw275pPczP9M4YPB64NVMqDz1Lxqbk5iE3FC9DwJL 6U7GKzQ+RUNCGjITGW7zmZ9sEGwHsuljNVwJGftl+5+uBAAoJ6UeO4Mw4vEVDA9VYari M0vWSmkuZ/MLT6zDj0/Z5JO3FJVjXBtCP+xfhvcxDyYlOzK7LC/EQlsUPD80jbG0yYBn cYML+7VQMCacGXEGXLajMGXdvF6ob/J1slmZ6E1PSDxIbGKsJPEQ1TCu5hTJxbm1YyQk f3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wpg1AriOZWy/xFcst2si/lCpPT0Ryl90fgiUm+fa70w=; b=elIuTsSvUFXSv0Ljsu9FEg3YrDsQz0FCaKCEDCwOgLzimjNc98QO/v5gNk8wH5aElQ EBC4KA2bVb8Vqw8kwGRI1T8UT7hrNDOXXRcPrVM2WGMyFUTVo5o4rkjyzKSmeTGGXJ+b 0x3F5iuc802JqC0ZEM8VPriFxisgQ9CG0pkak74CvIxXUc0wZSgFpjiylaJSU0ZPp8xE a5sOOUs4WL0dD4daB1/H7Rc1DXMm8yvBBG/JospK0tDTzki9jT9+qy6Hidk3B5hnu5bs BCHRYYaj1DDuFIEQvF+FEzcxNbiC4VJFUtIE9+yC2iKG2F8Uq6tNGAlyi7fhvzGYM+yx T+5Q== X-Gm-Message-State: AOAM530l6C/eRoZKLR/q3CEVEubXLzITYJLq0B3tLsVBe8BjQnM/dCNF TQxgeyDGRECmlVbtyQDewCf1gBzS1iFHunN+vmg= X-Google-Smtp-Source: ABdhPJw901lZhF7s+9eYTP3BajDT6rKdfjMZWNHSWYUKDFcUsqvC7trCOZFaobipdvv4GAgzxTz7PQ0iaaQ/zGhvBYY= X-Received: by 2002:a4a:d98d:: with SMTP id k13mr2711897oou.85.1636445470026; Tue, 09 Nov 2021 00:11:10 -0800 (PST) MIME-Version: 1.0 References: <20211014184811.482560-1-sjg@chromium.org> <20211014184811.482560-6-sjg@chromium.org> In-Reply-To: <20211014184811.482560-6-sjg@chromium.org> From: Ramon Fried Date: Tue, 9 Nov 2021 10:10:58 +0200 Message-ID: Subject: Re: [PATCH v3 05/18] pxe: Add a userdata field to the context To: Simon Glass Cc: U-Boot Mailing List , Patrice Chotard , Artem Lapkin , Tom Rini , Joe Hershberger , Heinrich Schuchardt , Peter Hoyes Content-Type: text/plain; charset="UTF-8" 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 On Thu, Oct 14, 2021 at 9:49 PM Simon Glass wrote: > > 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 > Reviewed-by: Ramon Fried