summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-30 09:34:18 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-30 09:34:18 -0600
commitb08e31bfe42e7d5b695e74cae50ea5386e425d9f (patch)
treeeb0bc3b865df40867f0ba6bdac4ee3cfb741c9f4
parentbec077aa6d3bc1a814bdfb28360c9540ca7a3bb1 (diff)
parentec9c929ff00c07df0e667b68bec285e1b02d8445 (diff)
downloadnuttx-b08e31bfe42e7d5b695e74cae50ea5386e425d9f.tar.gz
nuttx-b08e31bfe42e7d5b695e74cae50ea5386e425d9f.tar.bz2
nuttx-b08e31bfe42e7d5b695e74cae50ea5386e425d9f.zip
Merge remote-tracking branch 'origin/master' into traveller
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_i2c.c9
-rwxr-xr-xnuttx/arch/arm/src/stm32/stm32_i2c_alt.c19
-rw-r--r--nuttx/fs/vfs/fs_ioctl.c2
-rw-r--r--nuttx/include/nuttx/fs/fs.h2
-rw-r--r--nuttx/include/nuttx/input/ajoystick.h1
-rw-r--r--nuttx/include/nuttx/input/mouse.h1
-rw-r--r--nuttx/include/sys/ioctl.h2
-rw-r--r--nuttx/libc/Kconfig15
-rw-r--r--nuttx/libc/misc/lib_ioctl.c20
9 files changed, 53 insertions, 18 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c
index 7f12c45bf..ab346928b 100644
--- a/nuttx/arch/arm/src/stm32/stm32_i2c.c
+++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c
@@ -49,12 +49,15 @@
* - Instance: represents each individual access to the I2C driver, obtained by
* the i2c_init(); it extends the Device structure from the nuttx/i2c/i2c.h;
* Instance points to OPS, to common I2C Hardware private data and contains
- * its own private data, as frequency, address, mode of operation (in the future)
+ * its own private data, as frequency, address, mode of operation (in the
+ * future)
* - Private: Private data of an I2C Hardware
*
* TODO
- * - Check for all possible deadlocks (as BUSY='1' I2C needs to be reset in HW using the I2C_CR1_SWRST)
- * - SMBus support (hardware layer timings are already supported) and add SMBA gpio pin
+ * - Check for all possible deadlocks (as BUSY='1' I2C needs to be reset in HW
+ * using the I2C_CR1_SWRST)
+ * - SMBus support (hardware layer timings are already supported) and add SMBA
+ * gpio pin
* - Slave support with multiple addresses (on multiple instances):
* - 2 x 7-bit address or
* - 1 x 10 bit addresses + 1 x 7 bit address (?)
diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c b/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
index 51f0238dd..b1107aafe 100755
--- a/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
+++ b/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
@@ -52,14 +52,18 @@
* - Instance: represents each individual access to the I2C driver, obtained by
* the i2c_init(); it extends the Device structure from the nuttx/i2c/i2c.h;
* Instance points to OPS, to common I2C Hardware private data and contains
- * its own private data, as frequency, address, mode of operation (in the future)
+ * its own private data, as frequency, address, mode of operation (in the
+ * future)
* - Private: Private data of an I2C Hardware
*
* TODO
- * - Trace events in polled operation fill trace table very quickly. Events 1111 and 1004 get traced
- * in an alternate fashion during polling causing multiple entries.
- * - Check for all possible deadlocks (as BUSY='1' I2C needs to be reset in HW using the I2C_CR1_SWRST)
- * - SMBus support (hardware layer timings are already supported) and add SMBA gpio pin
+ * - Trace events in polled operation fill trace table very quickly. Events 1111
+ * and 1004 get traced in an alternate fashion during polling causing multiple
+ * entries.
+ * - Check for all possible deadlocks (as BUSY='1' I2C needs to be reset in HW
+ * using the I2C_CR1_SWRST)
+ * - SMBus support (hardware layer timings are already supported) and add SMBA
+ * gpio pin
* - Slave support with multiple addresses (on multiple instances):
* - 2 x 7-bit address or
* - 1 x 10 bit addresses + 1 x 7 bit address (?)
@@ -163,7 +167,7 @@
GPIO_SPEED_50MHz | GPIO_OUTPUT_SET)
#endif
-#define MKI2C_OUTPUT(p)(((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT)
+#define MKI2C_OUTPUT(p) (((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT)
/* Debug ****************************************************************************/
/* CONFIG_DEBUG_I2C + CONFIG_DEBUG enables general I2C debug output. */
@@ -656,6 +660,7 @@ static int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
abstime.tv_nsec -= 1000 * 1000 * 1000;
}
#endif
+
/* Wait until either the transfer is complete or the timeout expires */
ret = sem_timedwait(&priv->sem_isr, &abstime);
@@ -1177,7 +1182,7 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv)
* Name: stm32_i2c_enablefsmc
*
* Description:
- * Re-enabled the FSMC
+ * Re-enable the FSMC
*
************************************************************************************/
diff --git a/nuttx/fs/vfs/fs_ioctl.c b/nuttx/fs/vfs/fs_ioctl.c
index d96d95889..eb48d5c34 100644
--- a/nuttx/fs/vfs/fs_ioctl.c
+++ b/nuttx/fs/vfs/fs_ioctl.c
@@ -69,7 +69,7 @@
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
- * -1 on failure withi errno set properly:
+ * -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h
index 1baa91cee..ad05da5d7 100644
--- a/nuttx/include/nuttx/fs/fs.h
+++ b/nuttx/include/nuttx/fs/fs.h
@@ -638,7 +638,7 @@ int close_blockdriver(FAR struct inode *inode);
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
- * -1 on failure withi errno set properly:
+ * -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
diff --git a/nuttx/include/nuttx/input/ajoystick.h b/nuttx/include/nuttx/input/ajoystick.h
index af56b90e8..4df634863 100644
--- a/nuttx/include/nuttx/input/ajoystick.h
+++ b/nuttx/include/nuttx/input/ajoystick.h
@@ -199,6 +199,7 @@ struct ajoy_notify_s
struct ajoy_sample_s
{
ajoy_buttonset_t as_buttons; /* State of all buttons */
+ /* Possibly padded with 1 byte here */
int16_t as_x; /* X/horizontal position */
int16_t as_y; /* Y/vertical position */
};
diff --git a/nuttx/include/nuttx/input/mouse.h b/nuttx/include/nuttx/input/mouse.h
index f33672164..439dd4faf 100644
--- a/nuttx/include/nuttx/input/mouse.h
+++ b/nuttx/include/nuttx/input/mouse.h
@@ -74,6 +74,7 @@
struct mouse_report_s
{
uint8_t buttons; /* See TOUCH_* definitions above */
+ /* Possibly padded with 1 byte here */
int16_t x; /* X coordinate of the mouse position */
int16_t y; /* Y coordinate of the mouse position */
#ifdef CONFIG_MOUSE_WHEEL
diff --git a/nuttx/include/sys/ioctl.h b/nuttx/include/sys/ioctl.h
index 60dfa5cea..01987d58f 100644
--- a/nuttx/include/sys/ioctl.h
+++ b/nuttx/include/sys/ioctl.h
@@ -84,7 +84,7 @@ extern "C"
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
- * -1 on failure withi errno set properly:
+ * -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
diff --git a/nuttx/libc/Kconfig b/nuttx/libc/Kconfig
index b49b92e31..5ea546aa9 100644
--- a/nuttx/libc/Kconfig
+++ b/nuttx/libc/Kconfig
@@ -76,7 +76,20 @@ config LIBC_IOCTL_VARIADIC
WARNING: Use of this option could cause subtle system errors is
the third argument is omitted or if the sizeof the thread argument
- is anything other than sizeof (unsigned long).
+ is anything other than sizeof (unsigned long). Most small integers
+ will be promoted to 'int'. The following assertion appears in ioctl():
+
+ DEBUGASSERT(sizeof(int) == sizeof(unsigned long) &&
+ sizeof(FAR void *) == sizeof(unsigned long));
+
+ Do not enable this option if the above is not true. 32-bit ARM
+ should pass this test with all three types having sizeof(type) == 4
+ bytes. 'float' should also be tested. But 'long long' and 'double'
+ are out of the question! Don't event try to pass them.
+
+ And what will happen if no third argument is passed? In most cases,
+ this should just result in a garbage value for arg. But you may
+ discover cases where something worse happens!
config LIB_RAND_ORDER
int "Order of the random number generate"
diff --git a/nuttx/libc/misc/lib_ioctl.c b/nuttx/libc/misc/lib_ioctl.c
index a2838790c..fa0d90804 100644
--- a/nuttx/libc/misc/lib_ioctl.c
+++ b/nuttx/libc/misc/lib_ioctl.c
@@ -42,6 +42,7 @@
#include <sys/ioctl.h>
#include <stdarg.h>
#include <errno.h>
+#include <assert.h>
#include <nuttx/fs/fs.h>
@@ -66,7 +67,7 @@
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
- * -1 on failure withi errno set properly:
+ * -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
@@ -84,15 +85,26 @@
int ioctl(int fd, int req, ...)
{
- va_list ap;
unsigned long arg;
+ va_list ap;
/* Get the unsigned long argument.
*
- * REVISIT: This could cause of the crash down the road if the actual size
- * of the argument is anything other than sizeof(unsigned long);
+ * REVISIT: This could be the cause of the crash down the road if the
+ * actual size of the argument is anything other than sizeof(unsigned long).
+ * Most small integers will be promoted to 'int'. ARM should pass the
+ * following test with all three types having sizeof(type) == 4 bytes.
+ * 'float' should also be tested. But 'long long' and 'double' are out of
+ * the question! Don't try to pass them.
+ *
+ * And what will happen if no third argument is passed? In most cases,
+ * this should just result in a garbage value for arg. But you may
+ * discover cases where something worse happens!
*/
+ DEBUGASSERT(sizeof(int) == sizeof(unsigned long) &&
+ sizeof(FAR void *) == sizeof(unsigned long));
+
va_start(ap, req);
arg = va_arg(ap, unsigned long);
va_end(ap);