Skip to content

Commit

Permalink
net: slip: fix compilation without NET_L2_ETHERNET
Browse files Browse the repository at this point in the history
For example it should be possible to compile and use the SLIP module
with NET_L2_DUMMY. This required the following changes:

* Fix a typo in the initializer for struct dummy_api
* Only define eth_capabilities if CONFIG_NET_L2_ETHERNET is defined to
  silence a -Wunused-function compiler warning
* Unconditionally include net/dummy.h

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
  • Loading branch information
nmeum authored and jukkar committed Apr 25, 2019
1 parent 7a824d8 commit 9ecf292
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/slip.c
Expand Up @@ -30,8 +30,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <net/net_pkt.h>
#include <net/net_if.h>
#include <net/net_core.h>
#include <net/dummy.h>
#include <console/uart_pipe.h>
#include <net/ethernet.h>

#define SLIP_END 0300
#define SLIP_ESC 0333
Expand Down Expand Up @@ -394,7 +394,9 @@ static void slip_iface_init(struct net_if *iface)
struct slip_context *slip = net_if_get_device(iface)->driver_data;
struct net_linkaddr *ll_addr;

#if defined(CONFIG_NET_L2_ETHERNET)
ethernet_init(iface);
#endif

#if defined(CONFIG_NET_LLDP)
net_lldp_set_lldpdu(iface);
Expand Down Expand Up @@ -430,6 +432,7 @@ static void slip_iface_init(struct net_if *iface)

static struct slip_context slip_context_data;

#if defined(CONFIG_SLIP_TAP)
static enum ethernet_hw_caps eth_capabilities(struct device *dev)
{
ARG_UNUSED(dev);
Expand All @@ -441,7 +444,6 @@ static enum ethernet_hw_caps eth_capabilities(struct device *dev)
;
}

#if defined(CONFIG_SLIP_TAP) && defined(CONFIG_NET_L2_ETHERNET)
static const struct ethernet_api slip_if_api = {
.iface_api.init = slip_iface_init,

Expand All @@ -459,7 +461,7 @@ ETH_NET_DEVICE_INIT(slip, CONFIG_SLIP_DRV_NAME, slip_init, &slip_context_data,
#else

static const struct dummy_api slip_if_api = {
.iface_init.init = slip_iface_init,
.iface_api.init = slip_iface_init,

.send = slip_send,
};
Expand Down

0 comments on commit 9ecf292

Please sign in to comment.