summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Boie <andrew.p.boie@intel.com>2016-03-02 12:28:09 -0800
committerGerrit Code Review <gerrit@zephyrproject.org>2016-03-04 16:26:21 +0000
commitf0a01163bef4ca69c3a1f628fea18ad1942cf740 (patch)
tree683d6de3058290d6b370d1c27f6f1c265269c72a
parent59912cf13f7763331f818520c3692883933e085b (diff)
sys_io: don't allow negative bit offsets
Use of these is the mark of a deranged imagination. Change-Id: Ib4b5f78cf61c016e333288090b397e9a3e0b8a40 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
-rw-r--r--include/arch/arc/v2/asm_inline_gcc.h30
-rw-r--r--include/arch/x86/asm_inline_gcc.h24
-rw-r--r--include/sys_io.h30
3 files changed, 42 insertions, 42 deletions
diff --git a/include/arch/arc/v2/asm_inline_gcc.h b/include/arch/arc/v2/asm_inline_gcc.h
index 766a28a88..c41cd6f98 100644
--- a/include/arch/arc/v2/asm_inline_gcc.h
+++ b/include/arch/arc/v2/asm_inline_gcc.h
@@ -70,7 +70,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_io_set_bit(io_port_t port, int bit)
+ void sys_io_set_bit(io_port_t port, unsigned int bit)
{
uint32_t reg = 0;
@@ -84,7 +84,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_io_clear_bit(io_port_t port, int bit)
+ void sys_io_clear_bit(io_port_t port, unsigned int bit)
{
uint32_t reg = 0;
@@ -98,7 +98,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_bit(io_port_t port, int bit)
+ int sys_io_test_bit(io_port_t port, unsigned int bit)
{
uint32_t status = _ARC_V2_STATUS32;
uint32_t reg = 0;
@@ -116,7 +116,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_and_set_bit(io_port_t port, int bit)
+ int sys_io_test_and_set_bit(io_port_t port, unsigned int bit)
{
int ret;
@@ -127,7 +127,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_and_clear_bit(io_port_t port, int bit)
+ int sys_io_test_and_clear_bit(io_port_t port, unsigned int bit)
{
int ret;
@@ -204,7 +204,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_set_bit(mem_addr_t addr, int bit)
+ void sys_set_bit(mem_addr_t addr, unsigned int bit)
{
uint32_t reg = 0;
@@ -217,7 +217,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_clear_bit(mem_addr_t addr, int bit)
+ void sys_clear_bit(mem_addr_t addr, unsigned int bit)
{
uint32_t reg = 0;
@@ -230,7 +230,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_bit(mem_addr_t addr, int bit)
+ int sys_test_bit(mem_addr_t addr, unsigned int bit)
{
uint32_t status = _ARC_V2_STATUS32;
uint32_t reg = 0;
@@ -248,7 +248,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_and_set_bit(mem_addr_t addr, int bit)
+ int sys_test_and_set_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
@@ -259,7 +259,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_and_clear_bit(mem_addr_t addr, int bit)
+ int sys_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
@@ -270,7 +270,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_bitfield_set_bit(mem_addr_t addr, int bit)
+ void sys_bitfield_set_bit(mem_addr_t addr, unsigned int bit)
{
/* Doing memory offsets in terms of 32-bit values to prevent
* alignment issues
@@ -279,20 +279,20 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_bitfield_clear_bit(mem_addr_t addr, int bit)
+ void sys_bitfield_clear_bit(mem_addr_t addr, unsigned int bit)
{
sys_clear_bit(addr + ((bit >> 5) << 2), bit & 0x1F);
}
static inline __attribute__((always_inline))
- int sys_bitfield_test_bit(mem_addr_t addr, int bit)
+ int sys_bitfield_test_bit(mem_addr_t addr, unsigned int bit)
{
return sys_test_bit(addr + ((bit >> 5) << 2), bit & 0x1F);
}
static inline __attribute__((always_inline))
- int sys_bitfield_test_and_set_bit(mem_addr_t addr, int bit)
+ int sys_bitfield_test_and_set_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
@@ -303,7 +303,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_bitfield_test_and_clear_bit(mem_addr_t addr, int bit)
+ int sys_bitfield_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
diff --git a/include/arch/x86/asm_inline_gcc.h b/include/arch/x86/asm_inline_gcc.h
index 51f6601db..988150e98 100644
--- a/include/arch/x86/asm_inline_gcc.h
+++ b/include/arch/x86/asm_inline_gcc.h
@@ -108,7 +108,7 @@ static inline __attribute__((always_inline)) void _do_irq_unlock(void)
static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op)
{
- int bitpos;
+ unsigned int bitpos;
__asm__ volatile (
@@ -158,7 +158,7 @@ static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op)
static ALWAYS_INLINE unsigned int find_msb_set(uint32_t op)
{
- int bitpos;
+ unsigned int bitpos;
__asm__ volatile (
@@ -304,7 +304,7 @@ static inline __attribute__((always_inline))
static inline __attribute__((always_inline))
- void sys_io_set_bit(io_port_t port, int bit)
+ void sys_io_set_bit(io_port_t port, unsigned int bit)
{
uint32_t reg = 0;
@@ -316,7 +316,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_io_clear_bit(io_port_t port, int bit)
+ void sys_io_clear_bit(io_port_t port, unsigned int bit)
{
uint32_t reg = 0;
@@ -328,7 +328,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_bit(io_port_t port, int bit)
+ int sys_io_test_bit(io_port_t port, unsigned int bit)
{
uint32_t ret;
@@ -341,7 +341,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_and_set_bit(io_port_t port, int bit)
+ int sys_io_test_and_set_bit(io_port_t port, unsigned int bit)
{
int ret;
@@ -352,7 +352,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_io_test_and_clear_bit(io_port_t port, int bit)
+ int sys_io_test_and_clear_bit(io_port_t port, unsigned int bit)
{
int ret;
@@ -430,7 +430,7 @@ static inline __attribute__((always_inline))
static inline __attribute__((always_inline))
- void sys_set_bit(mem_addr_t addr, int bit)
+ void sys_set_bit(mem_addr_t addr, unsigned int bit)
{
__asm__ volatile("btsl %1, %0;\n\t"
: "+m" (*(volatile uint32_t *) (addr))
@@ -439,7 +439,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- void sys_clear_bit(mem_addr_t addr, int bit)
+ void sys_clear_bit(mem_addr_t addr, unsigned int bit)
{
__asm__ volatile("btrl %1, %0;\n\t"
: "+m" (*(volatile uint32_t *) (addr))
@@ -447,7 +447,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_bit(mem_addr_t addr, int bit)
+ int sys_test_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
@@ -460,7 +460,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_and_set_bit(mem_addr_t addr, int bit)
+ int sys_test_and_set_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
@@ -473,7 +473,7 @@ static inline __attribute__((always_inline))
}
static inline __attribute__((always_inline))
- int sys_test_and_clear_bit(mem_addr_t addr, int bit)
+ int sys_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
{
int ret;
diff --git a/include/sys_io.h b/include/sys_io.h
index ab5886913..910ff8ad3 100644
--- a/include/sys_io.h
+++ b/include/sys_io.h
@@ -97,7 +97,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline void sys_io_set_bit(io_port_t port, int bit)
+ * @fn static inline void sys_io_set_bit(io_port_t port, unsigned int bit)
* @brief Set the designated bit from port to 1
*
* This functions takes the designated bit starting from port and sets it to 1.
@@ -107,7 +107,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline void sys_io_clear_bit(io_port_t port, int bit)
+ * @fn static inline void sys_io_clear_bit(io_port_t port, unsigned int bit)
* @brief Clear the designated bit from port to 0
*
* This functions takes the designated bit starting from port and sets it to 0.
@@ -117,7 +117,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_io_test_bit(io_port_t port, int bit)
+ * @fn static inline int sys_io_test_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port if it is set or not
*
* This functions takes the designated bit starting from port and tests its
@@ -130,7 +130,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_io_test_and_set_bit(io_port_t port, int bit)
+ * @fn static inline int sys_io_test_and_set_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port and set it
*
* This functions takes the designated bit starting from port, tests its
@@ -143,7 +143,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_io_test_and_clear_bit(io_port_t port, int bit)
+ * @fn static inline int sys_io_test_and_clear_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port and clear it
*
* This functions takes the designated bit starting from port, tests its
@@ -225,7 +225,7 @@ typedef uint32_t mem_addr_t;
/* Memory bits manipulation functions */
/**
- * @fn static inline void sys_set_bit(mem_addr_t addr, int bit)
+ * @fn static inline void sys_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Set the designated bit from addr to 1
*
* This functions takes the designated bit starting from addr and sets it to 1.
@@ -235,7 +235,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline void sys_clear_bit(mem_addr_t addr, int bit)
+ * @fn static inline void sys_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Clear the designated bit from addr to 0
*
* This functions takes the designated bit starting from addr and sets it to 0.
@@ -245,7 +245,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_test_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_test_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit if it is set or not
*
* This functions takes the designated bit starting from addr and tests its
@@ -258,7 +258,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_test_and_set_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_test_and_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and set it
*
* This functions takes the designated bit starting from addr, tests its
@@ -271,7 +271,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_test_and_clear_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and clear it
*
* This functions takes the designated bit starting from addr, test its
@@ -284,7 +284,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline void sys_bitfield_set_bit(mem_addr_t addr, int bit)
+ * @fn static inline void sys_bitfield_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Set the designated bit from addr to 1
*
* This functions takes the designated bit starting from addr and sets it to 1.
@@ -294,7 +294,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline void sys_bitfield_clear_bit(mem_addr_t addr, int bit)
+ * @fn static inline void sys_bitfield_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Clear the designated bit from addr to 0
*
* This functions takes the designated bit starting from addr and sets it to 0.
@@ -304,7 +304,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_bitfield_test_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_bitfield_test_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit if it is set or not
*
* This functions takes the designated bit starting from addr and tests its
@@ -317,7 +317,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_bitfield_test_and_set_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_bitfield_test_and_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and set it
*
* This functions takes the designated bit starting from addr, tests its
@@ -330,7 +330,7 @@ typedef uint32_t mem_addr_t;
*/
/**
- * @fn static inline int sys_bitfield_test_and_clear_bit(mem_addr_t addr, int bit)
+ * @fn static inline int sys_bitfield_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and clear it
*
* This functions takes the designated bit starting from addr, test its