From c1eead925d5729bf4e4422e47e954a09089ae632 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 7 Jun 2021 10:37:46 +0200 Subject: [PATCH] drivers/slipdev: register with netdev --- drivers/include/net/netdev.h | 1 + drivers/include/slipdev.h | 4 +++- drivers/slipdev/Makefile.dep | 1 + drivers/slipdev/slipdev.c | 4 +++- sys/net/gnrc/netif/init_devs/auto_init_slipdev.c | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/include/net/netdev.h b/drivers/include/net/netdev.h index 0ad72e32f4..9eb79a185e 100644 --- a/drivers/include/net/netdev.h +++ b/drivers/include/net/netdev.h @@ -321,6 +321,7 @@ typedef enum { NETDEV_SX126X, NETDEV_CC2420, NETDEV_ETHOS, + NETDEV_SLIPDEV, /* add more if needed */ } netdev_type_t; /** @} */ diff --git a/drivers/include/slipdev.h b/drivers/include/slipdev.h index 1e304cd1a6..9c9c6984b6 100644 --- a/drivers/include/slipdev.h +++ b/drivers/include/slipdev.h @@ -105,8 +105,10 @@ typedef struct { * * @param[in] dev device descriptor * @param[in] params parameters for device initialization + * @param[in] index index of @p params in a global parameter struct array. + * If initialized manually, pass a unique identifier instead. */ -void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params); +void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index); #ifdef __cplusplus } diff --git a/drivers/slipdev/Makefile.dep b/drivers/slipdev/Makefile.dep index c428e3be6f..0ec3dd39cf 100644 --- a/drivers/slipdev/Makefile.dep +++ b/drivers/slipdev/Makefile.dep @@ -1,5 +1,6 @@ USEMODULE += tsrb USEMODULE += eui_provider +USEMODULE += netdev_register FEATURES_REQUIRED += periph_uart ifneq (,$(filter slipdev_stdio,$(USEMODULE))) diff --git a/drivers/slipdev/slipdev.c b/drivers/slipdev/slipdev.c index 0e11fec7eb..f487735a8f 100644 --- a/drivers/slipdev/slipdev.c +++ b/drivers/slipdev/slipdev.c @@ -252,12 +252,14 @@ static const netdev_driver_t slip_driver = { .set = netdev_set_notsup, }; -void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params) +void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index) { /* set device descriptor fields */ dev->config = *params; dev->state = 0; dev->netdev.driver = &slip_driver; + + netdev_register(&dev->netdev, NETDEV_SLIPDEV, index); } /** @} */ diff --git a/sys/net/gnrc/netif/init_devs/auto_init_slipdev.c b/sys/net/gnrc/netif/init_devs/auto_init_slipdev.c index 7781a7e318..2dca489e59 100644 --- a/sys/net/gnrc/netif/init_devs/auto_init_slipdev.c +++ b/sys/net/gnrc/netif/init_devs/auto_init_slipdev.c @@ -48,7 +48,7 @@ void auto_init_slipdev(void) LOG_DEBUG("[auto_init_netif] initializing slip #%u\n", i); - slipdev_setup(&slipdevs[i], p); + slipdev_setup(&slipdevs[i], p, i); gnrc_netif_raw_create(&_netif[i], _slipdev_stacks[i], SLIPDEV_STACKSIZE, SLIPDEV_PRIO, "slipdev", (netdev_t *)&slipdevs[i]);