From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] Put common autoload code into AutoLoad() function
Date: Tue, 12 Apr 2011 23:58:59 +0200 [thread overview]
Message-ID: <20110412215859.36C47151F83@gemini.denx.de> (raw)
In-Reply-To: <1302642840-6958-4-git-send-email-sjg@chromium.org>
Dear Simon Glass,
In message <1302642840-6958-4-git-send-email-sjg@chromium.org> you wrote:
> This is a small clean-up patch.
>
> TEST=Build U-Boot, try bootp and check it auto-loads.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> net/bootp.c | 76 +++++++++++++++++++++++++---------------------------------
> 1 files changed, 33 insertions(+), 43 deletions(-)
>
> diff --git a/net/bootp.c b/net/bootp.c
> index 1a71786..0ac1429 100644
> --- a/net/bootp.c
> +++ b/net/bootp.c
> @@ -137,6 +137,36 @@ static int truncate_sz (const char *name, int maxlen, int curlen)
> return (curlen);
> }
>
> +/*
> + * Check if autoload is enabled. If so, use either NFS or TFTP to download
> + * the boot file.
> + */
> +static void AutoLoad(void)
We don't allow for CamelCaps identifiers.
> + char *s;
> +
> + if ((s = getenv("autoload")) != NULL) {
> + if (*s == 'n') {
> + /*
> + * Just use BOOTP to configure system;
> + * Do not use TFTP to load the bootfile.
> + */
> + NetState = NETLOOP_SUCCESS;
> + return;
> +#if defined(CONFIG_CMD_NFS)
> + } else if (strcmp(s, "NFS") == 0) {
> + /*
> + * Use NFS to load the bootfile.
> + */
> + NfsStart();
> + return;
> +#endif
> + }
> + }
> +
> + TftpStart();
> +}
> +
> #if !defined(CONFIG_CMD_DHCP)
>
> static void BootpVendorFieldProcess (u8 * ext)
> @@ -278,6 +308,7 @@ static void BootpVendorProcess (u8 * ext, int size)
> if (NetBootFileSize)
> debug("NetBootFileSize: %d\n", NetBootFileSize);
> }
> +
> /*
> * Handle a BOOTP received packet.
> */
> @@ -285,7 +316,6 @@ static void
> BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
> {
> Bootp_t *bp;
> - char *s;
>
> debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
> src, dest, len, sizeof (Bootp_t));
> @@ -312,26 +342,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
>
> debug("Got good BOOTP\n");
>
> - if ((s = getenv("autoload")) != NULL) {
> - if (*s == 'n') {
> - /*
> - * Just use BOOTP to configure system;
> - * Do not use TFTP to load the bootfile.
> - */
> - NetState = NETLOOP_SUCCESS;
> - return;
> -#if defined(CONFIG_CMD_NFS)
> - } else if (strcmp(s, "NFS") == 0) {
> - /*
> - * Use NFS to load the bootfile.
> - */
> - NfsStart();
> - return;
> -#endif
> - }
> - }
> -
> - TftpStart();
> + AutoLoad();
Note that your change is NOT functionally equivalent - instead of
running the code BEFORE TftpStart(), and eventually short-cutting it
by the "return", you run it AFTER.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The most difficult thing in the world is to know how to do a thing
and to watch someone else doing it wrong, without commenting.
-- T.H. White
next prev parent reply other threads:[~2011-04-12 21:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-12 21:13 [U-Boot] [PATCH 1/5] Add support for SMSC95XX USB 2.0 10/100MBit Ethernet Adapter Simon Glass
2011-04-12 21:13 ` [U-Boot] [PATCH 2/5] Add Ethernet hardware MAC address framework to usbnet Simon Glass
2011-04-12 22:30 ` Mike Frysinger
2011-04-12 21:13 ` [U-Boot] [PATCH 3/5] Add documentation for USB Host Networking Simon Glass
2011-04-30 19:23 ` Wolfgang Denk
2011-04-12 21:13 ` [U-Boot] [PATCH 4/5] Put common autoload code into AutoLoad() function Simon Glass
2011-04-12 21:58 ` Wolfgang Denk [this message]
2011-04-13 0:41 ` Simon Glass
2011-04-12 21:14 ` [U-Boot] [PATCH 5/5] Allow tftp server to be different from bootp/dhcp server Simon Glass
2011-04-12 21:56 ` Wolfgang Denk
2011-04-13 0:28 ` Simon Glass
2011-04-13 5:26 ` Wolfgang Denk
2011-04-13 18:42 ` Simon Glass
2011-04-13 19:42 ` Wolfgang Denk
2011-04-12 21:50 ` [U-Boot] [PATCH 1/5] Add support for SMSC95XX USB 2.0 10/100MBit Ethernet Adapter Wolfgang Denk
2011-04-13 0:53 ` Simon Glass
2011-04-12 22:32 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110412215859.36C47151F83@gemini.denx.de \
--to=wd@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox