Skip to content

Commit

Permalink
drivers/slipdev: register with netdev
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jun 21, 2021
1 parent 9fbab8f commit c1eead9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions drivers/include/net/netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ typedef enum {
NETDEV_SX126X,
NETDEV_CC2420,
NETDEV_ETHOS,
NETDEV_SLIPDEV,
/* add more if needed */
} netdev_type_t;
/** @} */
Expand Down
4 changes: 3 additions & 1 deletion drivers/include/slipdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions drivers/slipdev/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
USEMODULE += tsrb
USEMODULE += eui_provider
USEMODULE += netdev_register
FEATURES_REQUIRED += periph_uart

ifneq (,$(filter slipdev_stdio,$(USEMODULE)))
Expand Down
4 changes: 3 additions & 1 deletion drivers/slipdev/slipdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/** @} */
2 changes: 1 addition & 1 deletion sys/net/gnrc/netif/init_devs/auto_init_slipdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit c1eead9

Please sign in to comment.