You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/10 14:57:43 UTC
[incubator-nuttx] 05/05: Run .c and .h files modified by PR241
through nxstyle.
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit d09af3b7f329619f4865cff9deea6df8fb996c34
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Mon Feb 10 08:49:00 2020 -0600
Run .c and .h files modified by PR241 through nxstyle.
---
arch/sim/src/sim/up_ajoystick.c | 24 +++++++++----------
arch/sim/src/sim/up_ioexpander.c | 52 +++++++++++++++++++++-------------------
arch/sim/src/sim/up_netdriver.c | 4 ++--
arch/sim/src/sim/up_qspiflash.c | 18 +++++++++-----
arch/sim/src/sim/up_spiflash.c | 42 ++++++++++++++++++++++----------
arch/sim/src/sim/up_tapdev.c | 27 ++++++++++++---------
arch/sim/src/sim/up_wpcap.c | 17 ++++++++-----
drivers/net/telnet.c | 1 +
8 files changed, 112 insertions(+), 73 deletions(-)
diff --git a/arch/sim/src/sim/up_ajoystick.c b/arch/sim/src/sim/up_ajoystick.c
index 1e17438..cbbe74b 100644
--- a/arch/sim/src/sim/up_ajoystick.c
+++ b/arch/sim/src/sim/up_ajoystick.c
@@ -235,18 +235,18 @@ int up_buttonevent(int x, int y, int buttons)
{
/* Check button presses */
- changed = g_ajoy_buttons ^ g_ajoy_sample.as_buttons;
- if (changed != 0)
- {
- pressed = changed & (AJOY_SUPPORTED & g_ajoy_pset);
- released = changed & (AJOY_SUPPORTED & ~g_ajoy_rset);
- if ((pressed & g_ajoy_pset) != 0 || (released & g_ajoy_rset) != 0)
- {
- /* Call the interrupt handler */
-
- g_ajoy_handler(&g_ajoylower, g_ajoy_arg);
- }
- }
+ changed = g_ajoy_buttons ^ g_ajoy_sample.as_buttons;
+ if (changed != 0)
+ {
+ pressed = changed & (AJOY_SUPPORTED & g_ajoy_pset);
+ released = changed & (AJOY_SUPPORTED & ~g_ajoy_rset);
+ if ((pressed & g_ajoy_pset) != 0 || (released & g_ajoy_rset) != 0)
+ {
+ /* Call the interrupt handler */
+
+ g_ajoy_handler(&g_ajoylower, g_ajoy_arg);
+ }
+ }
}
return OK;
diff --git a/arch/sim/src/sim/up_ioexpander.c b/arch/sim/src/sim/up_ioexpander.c
index 36e1d4a..e7fd40b 100644
--- a/arch/sim/src/sim/up_ioexpander.c
+++ b/arch/sim/src/sim/up_ioexpander.c
@@ -85,29 +85,33 @@
struct sim_callback_s
{
- ioe_pinset_t pinset; /* Set of pin interrupts that will generate
- * the callback. */
- ioe_callback_t cbfunc; /* The saved callback function pointer */
- FAR void *cbarg; /* Callback argument */
+ ioe_pinset_t pinset; /* Set of pin interrupts that will generate
+ * the callback. */
+ ioe_callback_t cbfunc; /* The saved callback function pointer */
+ FAR void *cbarg; /* Callback argument */
};
/* This structure represents the state of the I/O Expander driver */
struct sim_dev_s
{
- struct ioexpander_dev_s dev; /* Nested structure to allow casting as public gpio
- * expander. */
+ struct ioexpander_dev_s dev; /* Nested structure to allow casting as
+ * public GPIO expander. */
ioe_pinset_t inpins; /* Pins select as inputs */
ioe_pinset_t invert; /* Pin value inversion */
ioe_pinset_t outval; /* Value of output pins */
ioe_pinset_t inval; /* Simulated input register */
ioe_pinset_t intenab; /* Interrupt enable */
- ioe_pinset_t last; /* Last pin inputs (for detection of changes) */
+ ioe_pinset_t last; /* Last pin inputs (for detection of
+ * changes) */
ioe_pinset_t trigger; /* Bit encoded: 0=level 1=edge */
- ioe_pinset_t level[2]; /* Bit encoded: 01=high/rising, 10 low/falling, 11 both */
+ ioe_pinset_t level[2]; /* Bit encoded: 01=high/rising,
+ * 10 low/falling, 11 both */
- WDOG_ID wdog; /* Timer used to poll for interrupt simulation */
- struct work_s work; /* Supports the interrupt handling "bottom half" */
+ WDOG_ID wdog; /* Timer used to poll for interrupt
+ * simulation */
+ struct work_s work; /* Supports the interrupt handling
+ * "bottom half" */
/* Saved callback information for each I/O expander client */
@@ -562,18 +566,18 @@ static FAR void *sim_attach(FAR struct ioexpander_dev_s *dev,
for (i = 0; i < CONFIG_SIM_INT_NCALLBACKS; i++)
{
- /* Is this entry available (i.e., no callback attached) */
-
- if (priv->cb[i].cbfunc == NULL)
- {
- /* Yes.. use this entry */
-
- priv->cb[i].pinset = pinset;
- priv->cb[i].cbfunc = callback;
- priv->cb[i].cbarg = arg;
- handle = &priv->cb[i];
- break;
- }
+ /* Is this entry available (i.e., no callback attached) */
+
+ if (priv->cb[i].cbfunc == NULL)
+ {
+ /* Yes.. use this entry */
+
+ priv->cb[i].pinset = pinset;
+ priv->cb[i].cbfunc = callback;
+ priv->cb[i].cbarg = arg;
+ handle = &priv->cb[i];
+ break;
+ }
}
return handle;
@@ -603,7 +607,7 @@ static int sim_detach(FAR struct ioexpander_dev_s *dev, FAR void *handle)
DEBUGASSERT(priv != NULL && cb != NULL);
DEBUGASSERT((uintptr_t)cb >= (uintptr_t)&priv->cb[0] &&
- (uintptr_t)cb <= (uintptr_t)&priv->cb[CONFIG_SIM_INT_NCALLBACKS-1]);
+ (uintptr_t)cb <= (uintptr_t)&priv->cb[CONFIG_SIM_INT_NCALLBACKS - 1]);
UNUSED(priv);
cb->pinset = 0;
@@ -690,7 +694,7 @@ static ioe_pinset_t sim_int_update(FAR struct sim_dev_s *priv)
/* Set interrupt as a function of edge type */
if ((!pinval && SIM_EDGE_FALLING(priv, pin)) ||
- ( pinval && SIM_EDGE_RISING(priv, pin)))
+ (pinval && SIM_EDGE_RISING(priv, pin)))
{
intstat |= 1 << pin;
}
diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index 488f56b..88e4f73 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -187,8 +187,8 @@ static void netdriver_work(FAR void *arg)
{
NETDEV_RXPACKETS(&g_sim_dev);
- /* Data received event. Check for valid Ethernet header with destination == our
- * MAC address
+ /* Data received event. Check for valid Ethernet header with
+ * destination == our MAC address
*/
eth = BUF;
diff --git a/arch/sim/src/sim/up_qspiflash.c b/arch/sim/src/sim/up_qspiflash.c
index 359e3c1..2d1c180 100644
--- a/arch/sim/src/sim/up_qspiflash.c
+++ b/arch/sim/src/sim/up_qspiflash.c
@@ -56,6 +56,7 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
+
/* Configuration ********************************************************************/
/* Define the FLASH SIZE in bytes */
@@ -144,7 +145,9 @@
#define QSPIFLASH_STATE_FREAD_WAIT 17
/* Instructions */
+
/* Command Value N Description Addr Dummy Data */
+
#define QSPIFLASH_WREN 0x06 /* 1 Write Enable 0 0 0 */
#define QSPIFLASH_WRDI 0x04 /* 1 Write Disable 0 0 0 */
#define QSPIFLASH_RDID 0x9f /* 1 Read Identification 0 0 1-3 */
@@ -222,7 +225,10 @@ static const struct qspi_ops_s g_qspiops =
struct sim_qspiflashdev_s g_qspidev =
{
- .spidev = { &g_qspiops },
+ .spidev =
+ {
+ &g_qspiops
+ }
};
/************************************************************************************
@@ -428,7 +434,7 @@ static void qspiflash_sectorerase(FAR struct sim_qspiflashdev_s *priv)
/* Now perform the erase */
- memset(&priv->data[address], 0xFF, len);
+ memset(&priv->data[address], 0xff, len);
}
}
@@ -495,7 +501,7 @@ static void qspiflash_writeword(FAR struct sim_qspiflashdev_s *priv, uint16_t da
default:
priv->state = QSPIFLASH_STATE_IDLE;
- priv->read_data = 0xFF;
+ priv->read_data = 0xff;
break;
}
}
@@ -593,9 +599,9 @@ FAR struct qspi_dev_s *up_qspiflashinitialize()
priv->wren = 0;
priv->address = 0;
priv->state = QSPIFLASH_STATE_IDLE;
- priv->read_data = 0xFF;
- priv->last_cmd = 0xFF;
- memset(&priv->data[0], 0xFF, sizeof(priv->data));
+ priv->read_data = 0xff;
+ priv->last_cmd = 0xff;
+ memset(&priv->data[0], 0xff, sizeof(priv->data));
leave_critical_section(flags);
return (FAR struct qspi_dev_s *)priv;
diff --git a/arch/sim/src/sim/up_spiflash.c b/arch/sim/src/sim/up_spiflash.c
index 1308bc7..02dc4d3 100644
--- a/arch/sim/src/sim/up_spiflash.c
+++ b/arch/sim/src/sim/up_spiflash.c
@@ -55,6 +55,7 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
+
/* Configuration ********************************************************************/
/* Define the FLASH SIZE in bytes */
@@ -71,7 +72,7 @@
#ifdef CONFIG_SIM_SPIFLASH_8M
# define CONFIG_SPIFLASH_SIZE (1024 * 1024)
-# define CONFIG_SPIFLASH_CAPACITY_SST26 0x3F
+# define CONFIG_SPIFLASH_CAPACITY_SST26 0x3f
# define CONFIG_SPIFLASH_CAPACITY 0x14
#endif
@@ -147,7 +148,9 @@
#define SPIFLASH_STATE_FREAD_WAIT 17
/* Instructions */
+
/* Command Value N Description Addr Dummy Data */
+
#define SPIFLASH_WREN 0x06 /* 1 Write Enable 0 0 0 */
#define SPIFLASH_WRDI 0x04 /* 1 Write Disable 0 0 0 */
#define SPIFLASH_RDID 0x9f /* 1 Read Identification 0 0 1-3 */
@@ -244,7 +247,10 @@ static const struct spi_ops_s g_spiops =
#ifdef CONFIG_SIM_SPIFLASH_M25P
struct sim_spiflashdev_s g_spidev_m25p =
{
- .spidev = { &g_spiops },
+ .spidev =
+ {
+ &g_spiops
+ },
.name = "m25p",
.manuf = 0x20,
.type = 0x20,
@@ -255,9 +261,12 @@ struct sim_spiflashdev_s g_spidev_m25p =
#ifdef CONFIG_SIM_SPIFLASH_SST26
struct sim_spiflashdev_s g_spidev_sst26 =
{
- .spidev = { &g_spiops },
+ .spidev =
+ {
+ &g_spiops
+ },
.name = "sst26",
- .manuf = 0xBF,
+ .manuf = 0xbf,
#ifdef CONFIG_SST26_MEMORY_TYPE
.type = CONFIG_SST26_MEMORY_TYPE,
#else
@@ -270,7 +279,10 @@ struct sim_spiflashdev_s g_spidev_sst26 =
#ifdef CONFIG_SIM_SPIFLASH_W25
struct sim_spiflashdev_s g_spidev_w25 =
{
- .spidev = { &g_spiops },
+ .spidev =
+ {
+ &g_spiops
+ },
.name = "w25",
.manuf = 0xef,
.type = 0x30,
@@ -281,7 +293,10 @@ struct sim_spiflashdev_s g_spidev_w25 =
#ifdef CONFIG_SIM_SPIFLASH_CUSTOM
struct sim_spiflashdev_s g_spidev_custom =
{
- .spidev = { &g_spiops },
+ .spidev =
+ {
+ &g_spiops
+ },
.name = "custom",
.manuf = CONFIG_SIM_SPIFLASH_MANUFACTURER,
.type = CONFIG_SIM_SPIFLASH_MEMORY_TYPE,
@@ -582,7 +597,8 @@ static void spiflash_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffe
************************************************************************************/
#ifndef CONFIG_SPI_EXCHANGE
-static void spiflash_sndblock(FAR struct spi_dev_s *dev, FAR const void *txbuffer, size_t nwords)
+static void spiflash_sndblock(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ size_t nwords)
{
spiinfo("txbuffer=%p nwords=%d\n", txbuffer, nwords);
return spiflash_exchange(dev, txbuffer, NULL, nwords);
@@ -655,7 +671,7 @@ static void spiflash_sectorerase(FAR struct sim_spiflashdev_s *priv)
/* Now perform the erase */
- memset(&priv->data[address], 0xFF, len);
+ memset(&priv->data[address], 0xff, len);
}
}
@@ -797,6 +813,7 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data
break;
case SPIFLASH_STATE_PP4:
+
/* In this state we actually write data (if WREN enabled) */
if (priv->wren)
@@ -849,6 +866,7 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data
break;
case SPIFLASH_STATE_READ4:
+
/* In this state perform data reads until de-selected. */
priv->read_data = priv->data[priv->address++];
@@ -860,7 +878,7 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data
default:
priv->state = SPIFLASH_STATE_IDLE;
- priv->read_data = 0xFF;
+ priv->read_data = 0xff;
break;
}
}
@@ -944,9 +962,9 @@ FAR struct spi_dev_s *up_spiflashinitialize(FAR const char *name)
priv->wren = 0;
priv->address = 0;
priv->state = SPIFLASH_STATE_IDLE;
- priv->read_data = 0xFF;
- priv->last_cmd = 0xFF;
- memset(&priv->data[0], 0xFF, sizeof(priv->data));
+ priv->read_data = 0xff;
+ priv->last_cmd = 0xff;
+ memset(&priv->data[0], 0xff, sizeof(priv->data));
leave_critical_section(flags);
return (FAR struct spi_dev_s *)priv;
diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c
index aa9c4a4..7c96a32 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -70,8 +70,6 @@
* Pre-processor Definitions
****************************************************************************/
-//#define TAPDEV_DEBUG 1
-
#define DEVTAP "/dev/net/tun"
/* Syslog priority (must match definitions in nuttx/include/syslog.h) */
@@ -120,18 +118,21 @@ static struct rtentry ghostroute;
****************************************************************************/
#ifdef TAPDEV_DEBUG
-static inline void dump_ethhdr(const char *msg, unsigned char *buf, int buflen)
+static inline void dump_ethhdr(const char *msg, unsigned char *buf,
+ int buflen)
{
syslog(LOG_INFO, "TAPDEV: %s %d bytes\n", msg, buflen);
syslog(LOG_INFO,
- " %02x:%02x:%02x:%02x:%02x:%02x %02x:%02x:%02x:%02x:%02x:%02x %02x%02x\n",
+ " %02x:%02x:%02x:%02x:%02x:%02x "
+ "%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
#ifdef CONFIG_ENDIAN_BIG
- buf[13], buf[12]);
+ buf[13], buf[12]
#else
- buf[12], buf[13]);
+ buf[12], buf[13]
#endif
+ );
}
#else
# define dump_ethhdr(m,b,l)
@@ -199,7 +200,7 @@ void tapdev_init(void)
{
syslog(LOG_ERR, "TAPDEV: ioctl failed: %d\n", -ret);
return;
- }
+ }
/* Save the tap device name */
@@ -226,7 +227,8 @@ void tapdev_init(void)
ret = ioctl(sockfd, SIOCBRADDIF, &ifr);
if (ret < 0)
{
- syslog(LOG_ERR, "TAPDEV: ioctl failed (can't add interface %s to bridge %s): %d\n",
+ syslog(LOG_ERR, "TAPDEV: ioctl failed (can't add interface %s to "
+ "bridge %s): %d\n",
gdevname, CONFIG_SIM_NET_BRIDGE_DEVICE, -ret);
}
@@ -326,7 +328,8 @@ void tapdev_ifup(in_addr_t ifaddr)
ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&ifr);
if (ret < 0)
{
- syslog(LOG_ERR, "TAPDEV: ioctl failed (can't get interface flags): %d\n", -ret);
+ syslog(LOG_ERR, "TAPDEV: ioctl failed (can't get interface flags): %d\n",
+ -ret);
close(sockfd);
return;
}
@@ -335,7 +338,8 @@ void tapdev_ifup(in_addr_t ifaddr)
ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&ifr);
if (ret < 0)
{
- syslog(LOG_ERR, "TAPDEV: ioctl failed (can't set interface flags): %d\n", -ret);
+ syslog(LOG_ERR, "TAPDEV: ioctl failed (can't set interface flags): %d\n",
+ -ret);
close(sockfd);
return;
}
@@ -385,7 +389,8 @@ void tapdev_ifdown(void)
ret = ioctl(sockfd, SIOCDELRT, (unsigned long)&ghostroute);
if (ret < 0)
{
- syslog(LOG_ERR, "TAPDEV: ioctl failed (can't delete host route): %d\n", -ret);
+ syslog(LOG_ERR, "TAPDEV: ioctl failed (can't delete host route): %d\n",
+ -ret);
}
close(sockfd);
diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c
index d430526..8bc4526 100644
--- a/arch/sim/src/sim/up_wpcap.c
+++ b/arch/sim/src/sim/up_wpcap.c
@@ -55,9 +55,6 @@
#include <netinet/in.h>
-
-extern int netdriver_setmacaddr(unsigned char *macaddr);
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -115,6 +112,12 @@ HMODULE wpcap;
static struct pcap *pcap;
/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+extern int netdriver_setmacaddr(unsigned char *macaddr);
+
+/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@@ -151,7 +154,6 @@ static void init_pcap(struct in_addr addr)
interfaces->addresses->addr != NULL &&
interfaces->addresses->addr->sa_family == AF_INET)
{
-
struct in_addr interface_addr;
interface_addr =
((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr;
@@ -162,6 +164,7 @@ static void init_pcap(struct in_addr addr)
break;
}
}
+
interfaces = interfaces->next;
}
@@ -189,7 +192,9 @@ static void set_ethaddr(struct in_addr addr)
{
error_exit("error on access to adapter list size\n");
}
+
adapters = alloca(size);
+
if (GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST |
GAA_FLAG_SKIP_MULTICAST |
GAA_FLAG_SKIP_DNS_SERVER,
@@ -200,7 +205,6 @@ static void set_ethaddr(struct in_addr addr)
while (adapters != NULL)
{
-
char buffer[256];
WideCharToMultiByte(CP_ACP, 0, adapters->Description, -1,
buffer, sizeof(buffer), NULL, NULL);
@@ -211,7 +215,6 @@ static void set_ethaddr(struct in_addr addr)
adapters->FirstUnicastAddress->Address.lpSockaddr->sa_family ==
AF_INET)
{
-
struct in_addr adapter_addr;
adapter_addr =
((struct sockaddr_in *)adapters->FirstUnicastAddress->Address.
@@ -225,6 +228,7 @@ static void set_ethaddr(struct in_addr addr)
error_exit
("ip addr specified does not belong to an ethernet card\n");
}
+
printf
("set_ethaddr: ethernetaddr: %02X-%02X-%02X-%02X-%02X-%02X\n",
adapters->PhysicalAddress[0], adapters->PhysicalAddress[1],
@@ -235,6 +239,7 @@ static void set_ethaddr(struct in_addr addr)
break;
}
}
+
adapters = adapters->Next;
}
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index 7821972..29ce4cd 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -307,6 +307,7 @@ static void telnet_check_ctrlchar(FAR struct telnet_dev_s *priv,
break;
}
#endif
+
#ifdef CONFIG_TTY_SIGSTP
/* Is this the special character that will generate the SIGSTP signal? */