From 7c2aa2648672d97e22ce7959858697e49ef4a8e5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 24 Feb 2019 10:10:38 -0600 Subject: [PATCH] drivers/net/tun.c: Costmetic changes from review for coding style compliance. --- drivers/net/tun.c | 70 +++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 0813f6918e..5fc914204e 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -112,18 +112,18 @@ * second */ -#define TUN_WDDELAY (1*CLK_TCK) +#define TUN_WDDELAY (1 * CLK_TCK) /* This is a helper pointer for accessing the contents of the Ethernet header */ #ifdef CONFIG_NET_ETHERNET -# define BUF ((struct eth_hdr_s *)priv->dev.d_buf) +# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf) #endif /* This is a helper pointer for accessing the contents of the ip header */ -#define IPv4BUF ((struct ipv4_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen)) -#define IPv6BUF ((struct ipv6_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen)) +#define IPv4BUF ((FAR struct ipv4_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen)) +#define IPv6BUF ((FAR struct ipv6_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen)) /**************************************************************************** * Private Types @@ -179,11 +179,11 @@ static void tun_unlock(FAR struct tun_device_s *priv); /* Common TX logic */ static int tun_fd_transmit(FAR struct tun_device_s *priv); -static int tun_txpoll(struct net_driver_s *dev); +static int tun_txpoll(FAR struct net_driver_s *dev); #ifdef CONFIG_NET_ETHERNET -static int tun_txpoll_tap(struct net_driver_s *dev); +static int tun_txpoll_tap(FAR struct net_driver_s *dev); #endif -static int tun_txpoll_tun(struct net_driver_s *dev); +static int tun_txpoll_tun(FAR struct net_driver_s *dev); /* Interrupt handling */ @@ -249,6 +249,9 @@ static const struct file_operations g_tun_file_ops = #ifndef CONFIG_DISABLE_POLL tun_poll, /* poll */ #endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + 0, /* unlink */ +#endif }; /**************************************************************************** @@ -324,7 +327,8 @@ static void tun_unlock(FAR struct tun_device_s *priv) ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -static void tun_pollnotify(FAR struct tun_device_s *priv, pollevent_t eventset) +static void tun_pollnotify(FAR struct tun_device_s *priv, + pollevent_t eventset) { FAR struct pollfd *fds = priv->poll_fds; @@ -388,9 +392,9 @@ static int tun_fd_transmit(FAR struct tun_device_s *priv) * Name: tun_txpoll * * Description: - * The transmitter is available, check if the network has any outgoing packets - * ready to send. This is a callback from devif_poll(). devif_poll() may - * be called: + * The transmitter is available, check if the network has any outgoing + * packets ready to send. This is a callback from devif_poll(). + * devif_poll() may be called: * * 1. When the preceding TX packet send is complete, * 2. When the preceding TX packet send timesout and the interface is reset @@ -409,7 +413,7 @@ static int tun_fd_transmit(FAR struct tun_device_s *priv) * ****************************************************************************/ -static int tun_txpoll(struct net_driver_s *dev) +static int tun_txpoll(FAR struct net_driver_s *dev) { int ret; @@ -431,9 +435,9 @@ static int tun_txpoll(struct net_driver_s *dev) * Name: tun_txpoll_tap : for tap (ethernet bridge) mode * * Description: - * The transmitter is available, check if the network has any outgoing packets - * ready to send. This is a callback from devif_poll(). devif_poll() may - * be called: + * The transmitter is available, check if the network has any outgoing + * packets ready to send. This is a callback from devif_poll(). + * devif_poll() may be called: * * 1. When the preceding TX packet send is complete, * 2. When the preceding TX packet send timesout and the interface is reset @@ -453,7 +457,7 @@ static int tun_txpoll(struct net_driver_s *dev) ****************************************************************************/ #ifdef CONFIG_NET_ETHERNET -static int tun_txpoll_tap(struct net_driver_s *dev) +static int tun_txpoll_tap(FAR struct net_driver_s *dev) { FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; @@ -504,9 +508,9 @@ static int tun_txpoll_tap(struct net_driver_s *dev) * Name: tun_txpoll_tun : for tun (IP tunneling) mode * * Description: - * The transmitter is available, check if the network has any outgoing packets - * ready to send. This is a callback from devif_poll(). devif_poll() may - * be called: + * The transmitter is available, check if the network has any outgoing + * packets ready to send. This is a callback from devif_poll(). + * devif_poll() may be called: * * 1. When the preceding TX packet send is complete, * 2. When the preceding TX packet send timesout and the interface is reset @@ -525,7 +529,7 @@ static int tun_txpoll_tap(struct net_driver_s *dev) * ****************************************************************************/ -static int tun_txpoll_tun(struct net_driver_s *dev) +static int tun_txpoll_tun(FAR struct net_driver_s *dev) { FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; @@ -546,8 +550,8 @@ static int tun_txpoll_tun(struct net_driver_s *dev) } } - /* If zero is returned, the polling will continue until all connections have - * been examined. + /* If zero is returned, the polling will continue until all connections + * have been examined. */ return 0; @@ -557,7 +561,8 @@ static int tun_txpoll_tun(struct net_driver_s *dev) * Name: tun_net_receive * * Description: - * An interrupt was received indicating the availability of a new RX packet + * An interrupt was received indicating the availability of a new RX + * packet * * Input Parameters: * priv - Reference to the driver state structure @@ -716,7 +721,6 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv) { NETDEV_RXDROPPED(&priv->dev); } - } #endif @@ -724,7 +728,8 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv) * Name: tun_net_receive_tun : for tun (IP tunneling) mode * * Description: - * An interrupt was received indicating the availability of a new RX packet + * An interrupt was received indicating the availability of a new RX + * packet * * Input Parameters: * priv - Reference to the driver state structure @@ -912,7 +917,7 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...) * ****************************************************************************/ -static int tun_ifup(struct net_driver_s *dev) +static int tun_ifup(FAR struct net_driver_s *dev) { FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; @@ -963,7 +968,7 @@ static int tun_ifup(struct net_driver_s *dev) * ****************************************************************************/ -static int tun_ifdown(struct net_driver_s *dev) +static int tun_ifdown(FAR struct net_driver_s *dev) { FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; irqstate_t flags; @@ -1047,7 +1052,7 @@ static void tun_txavail_work(FAR void *arg) * ****************************************************************************/ -static int tun_txavail(struct net_driver_s *dev) +static int tun_txavail(FAR struct net_driver_s *dev) { FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; @@ -1080,7 +1085,7 @@ static int tun_txavail(struct net_driver_s *dev) ****************************************************************************/ #ifdef CONFIG_NET_MCASTGROUP -static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac) +static int tun_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { /* Add the MAC address to the hardware multicast routing table */ @@ -1092,8 +1097,8 @@ static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac) * Name: tun_rmmac * * Description: - * NuttX Callback: Remove the specified MAC address from the hardware multicast - * address filtering + * NuttX Callback: Remove the specified MAC address from the hardware + * multicast address filtering * * Input Parameters: * dev - Reference to the NuttX driver state structure @@ -1107,7 +1112,7 @@ static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac) ****************************************************************************/ #ifdef CONFIG_NET_MCASTGROUP -static int tun_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac) +static int tun_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { /* Add the MAC address to the hardware multicast routing table */ @@ -1544,4 +1549,3 @@ int tun_initialize(void) } #endif /* CONFIG_NET && CONFIG_NET_TUN */ -