]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: Drop #ifdefs with CONFIG_BOOTP_SERVERIP
authorSimon Glass <sjg@chromium.org>
Sat, 18 Dec 2021 18:27:52 +0000 (11:27 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 21 Jan 2022 19:01:35 +0000 (14:01 -0500)
Use IS_ENABLED() instead, to reduce the number of build paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
cmd/net.c
net/bootp.c
net/net.c

index 651c1411f4d78ffd6f6acf938a6dbe910bc35789..3619c843d8381e550ba9df19c258d7965491c031 100644 (file)
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -152,16 +152,14 @@ static void netboot_update_env(void)
                ip_to_string(net_ip, tmp);
                env_set("ipaddr", tmp);
        }
-#if !defined(CONFIG_BOOTP_SERVERIP)
        /*
         * Only attempt to change serverip if net/bootp.c:store_net_params()
         * could have set it
         */
-       if (net_server_ip.s_addr) {
+       if (!IS_ENABLED(CONFIG_BOOTP_SERVERIP) && net_server_ip.s_addr) {
                ip_to_string(net_server_ip, tmp);
                env_set("serverip", tmp);
        }
-#endif
        if (net_dns_server.s_addr) {
                ip_to_string(net_dns_server, tmp);
                env_set("dnsip", tmp);
index 58e30cd6b0c52459ce5ead0e29574ba5bbdaf5e2..d83e4eb0ba9e03b02b18ed429833026fc3164ec6 100644 (file)
@@ -148,10 +148,12 @@ static int check_reply_packet(uchar *pkt, unsigned dest, unsigned src,
 
 static void store_bootp_params(struct bootp_hdr *bp)
 {
-#if !defined(CONFIG_BOOTP_SERVERIP)
        struct in_addr tmp_ip;
        bool overwrite_serverip = true;
 
+       if (IS_ENABLED(CONFIG_BOOTP_SERVERIP))
+               return;
+
 #if defined(CONFIG_BOOTP_PREFER_SERVERIP)
        overwrite_serverip = false;
 #endif
@@ -179,7 +181,6 @@ static void store_bootp_params(struct bootp_hdr *bp)
         */
        if (*net_boot_file_name)
                env_set("bootfile", net_boot_file_name);
-#endif
 }
 
 /*
index 43e230aeb92546a25302546bb0a013fbec1ed4d4..072a82d8f9c85f873897dc9b445799654722b10c 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -302,12 +302,12 @@ void net_auto_load(void)
        if (s != NULL && strcmp(s, "NFS") == 0) {
                if (net_check_prereq(NFS)) {
 /* We aren't expecting to get a serverip, so just accept the assigned IP */
-#ifdef CONFIG_BOOTP_SERVERIP
-                       net_set_state(NETLOOP_SUCCESS);
-#else
-                       printf("Cannot autoload with NFS\n");
-                       net_set_state(NETLOOP_FAIL);
-#endif
+                       if (IS_ENABLED(CONFIG_BOOTP_SERVERIP)) {
+                               net_set_state(NETLOOP_SUCCESS);
+                       } else {
+                               printf("Cannot autoload with NFS\n");
+                               net_set_state(NETLOOP_FAIL);
+                       }
                        return;
                }
                /*
@@ -327,12 +327,12 @@ void net_auto_load(void)
        }
        if (net_check_prereq(TFTPGET)) {
 /* We aren't expecting to get a serverip, so just accept the assigned IP */
-#ifdef CONFIG_BOOTP_SERVERIP
-               net_set_state(NETLOOP_SUCCESS);
-#else
-               printf("Cannot autoload with TFTPGET\n");
-               net_set_state(NETLOOP_FAIL);
-#endif
+               if (IS_ENABLED(CONFIG_BOOTP_SERVERIP)) {
+                       net_set_state(NETLOOP_SUCCESS);
+               } else {
+                       printf("Cannot autoload with TFTPGET\n");
+                       net_set_state(NETLOOP_FAIL);
+               }
                return;
        }
        tftp_start(TFTPGET);