[U-Boot] [PATCH v2 06/18] net: Refactor ping receive handler

Simon Glass sjg at chromium.org
Wed Apr 4 03:04:27 CEST 2012


On Tue, Mar 27, 2012 at 4:42 PM, Joe Hershberger <joe.hershberger at ni.com> wrote:
> There is no need to call through the handler... inline it
>
> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Joe Hershberger <joe.hershberger at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Mike Frysinger <vapier at gentoo.org>

Acked-by: Simon Glass <sjg at chromium.org>

> ---
>  net/ping.c |   18 ++----------------
>  1 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/net/ping.c b/net/ping.c
> index 93942bc..eb0f0cc 100644
> --- a/net/ping.c
> +++ b/net/ping.c
> @@ -75,20 +75,10 @@ static void ping_timeout(void)
>        NetState = NETLOOP_FAIL;        /* we did not get the reply */
>  }
>
> -static void ping_handler(uchar *pkt, unsigned dest, IPaddr_t sip,
> -           unsigned src, unsigned len)
> -{
> -       if (sip != NetPingIP)
> -               return;
> -
> -       NetState = NETLOOP_SUCCESS;
> -}
> -
>  void ping_start(void)
>  {
>        printf("Using %s device\n", eth_get_name());
>        NetSetTimeout(10000UL, ping_timeout);
> -       NetSetHandler(ping_handler);
>
>        ping_send();
>  }
> @@ -100,13 +90,9 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)
>
>        switch (icmph->type) {
>        case ICMP_ECHO_REPLY:
> -               /*
> -                * IP header OK.  Pass the packet to the
> -                * current handler.
> -                */
> -               /* XXX point to ip packet */
>                src_ip = NetReadIP((void *)&ip->ip_src);
> -               NetGetHandler()((uchar *)ip, 0, src_ip, 0, 0);
> +               if (src_ip == NetPingIP)
> +                       NetState = NETLOOP_SUCCESS;
>                return;
>        case ICMP_ECHO_REQUEST:
>                debug("Got ICMP ECHO REQUEST, return "
> --
> 1.6.0.2
>


More information about the U-Boot mailing list