Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
816ce73ab4
commit
1fb8c13e5e
@ -528,40 +528,10 @@ static useconds_t efm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_EFM32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_EFM32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_EFM32_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * efm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_EFM32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_EFM32_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enable I2C interrupts */
|
||||
|
||||
efm32_i2c_putreg(priv, EFM32_I2C_IEN_OFFSET, I2C_IF_NACK | I2C_IF_ACK |
|
||||
@ -569,7 +539,13 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_EFM32_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(efm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_EFM32_I2CTIMEOTICKS);
|
||||
#endif
|
||||
|
||||
/* Disable I2C interrupts */
|
||||
|
||||
@ -579,7 +555,7 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_timedwait.
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -615,7 +591,7 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts are
|
||||
* currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
start = clock_systime_ticks();
|
||||
|
@ -581,7 +581,6 @@ static useconds_t imxrt_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
static inline int
|
||||
imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
int ret;
|
||||
@ -615,48 +614,26 @@ static inline int
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_IMXRT_LPI2C_TIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_IMXRT_LPI2C_TIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_IMXRT_LPI2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * imxrt_lpi2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_IMXRT_LPI2C_TIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_IMXRT_LPI2C_TIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_IMXRT_LPI2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(imxrt_lpi2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_IMXRT_LPI2C_TIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -709,7 +686,7 @@ static inline int
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -290,37 +290,20 @@ static inline void
|
||||
static inline int
|
||||
lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_LC823450_I2C_TIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_LC823450_I2C_TIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
abstime.tv_nsec += priv->timeoms * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
SEC2TICK(CONFIG_LC823450_I2C_TIMEOSEC) +
|
||||
MSEC2TICK(priv->timeoms));
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
|
@ -471,7 +471,6 @@ static useconds_t s32k1xx_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
static inline int
|
||||
s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
int ret;
|
||||
@ -505,50 +504,26 @@ static inline int
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_S32K1XX_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_S32K1XX_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_S32K1XX_I2C_DYNTIMEO
|
||||
abstime.tv_nsec +=
|
||||
1000 * s32k1xx_lpi2c_tousecs(priv->msgc, priv->msgv);
|
||||
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_S32K1XX_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_S32K1XX_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_S32K1XX_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(s32k1xx_lpi2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_S32K1XX_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -603,7 +578,7 @@ static inline int
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -528,7 +528,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
int ret;
|
||||
@ -543,48 +542,26 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -626,7 +603,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -558,7 +558,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
int ret;
|
||||
@ -573,48 +572,26 @@ static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -656,7 +633,7 @@ static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -771,7 +771,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -792,42 +791,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -867,7 +844,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -581,7 +581,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
uint32_t regval;
|
||||
int ret;
|
||||
@ -596,48 +595,26 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -679,7 +656,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -785,7 +785,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -806,42 +805,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32F0L0G0_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32F0L0G0_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32F0L0G0_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32F0L0G0_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32F0L0G0_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32F0L0G0_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32F0L0G0_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -881,7 +858,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -808,7 +808,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -829,42 +828,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32F7_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32F7_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32F7_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32F7_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32F7_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32F7_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32F7_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -904,7 +881,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -767,7 +767,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -788,42 +787,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32H7_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32H7_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32H7_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32H7_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32H7_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32H7_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32H7_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -863,7 +840,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -815,7 +815,6 @@ void stm32l4_i2c_enableinterrupts(struct stm32l4_i2c_priv_s *priv)
|
||||
static inline
|
||||
int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -836,42 +835,20 @@ int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_STM32L4_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_STM32L4_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_STM32L4_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * stm32l4_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_STM32L4_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_STM32L4_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_STM32L4_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(stm32l4_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_STM32L4_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -912,7 +889,7 @@ int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -671,7 +671,6 @@ static useconds_t tiva_i2c_tousecs(int msgc, struct i2c_msg_s *msgv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -686,47 +685,25 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting.
|
||||
* NOTE: Interrupts are currently disabled but will be temporarily
|
||||
* re-enabled below when nxsem_timedwait() sleeps.
|
||||
* re-enabled below when nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
/* Get the current time */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_TIVA_I2C_TIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_TIVA_I2C_TIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_TIVA_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * tiva_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_TIVA_I2C_TIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_TIVA_I2C_TIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->waitsem, &abstime);
|
||||
#ifdef CONFIG_TIVA_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->waitsem,
|
||||
USEC2TICK(tiva_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->waitsem,
|
||||
CONFIG_TIVA_I2C_TIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
tiva_i2c_traceevent(priv, I2CEVENT_TIMEOUT,
|
||||
@ -769,7 +746,7 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
start = clock_systime_ticks();
|
||||
|
@ -660,7 +660,6 @@ static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
|
||||
static inline int
|
||||
pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
@ -672,40 +671,20 @@ static inline int
|
||||
|
||||
do
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
/* Calculate a time in the future */
|
||||
|
||||
#if CONFIG_PIC32MZ_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_PIC32MZ_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
/* Add a value proportional to the number of bytes in the transfer */
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_I2C_DYNTIMEO
|
||||
abstime.tv_nsec += 1000 * pic32mz_i2c_tousecs(priv->msgc, priv->msgv);
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
#elif CONFIG_PIC32MZ_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_PIC32MZ_I2CTIMEOMS * 1000 * 1000;
|
||||
if (abstime.tv_nsec >= 1000 * 1000 * 1000)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until either the transfer is complete or the timeout expires */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
#ifdef CONFIG_PIC32MZ_I2C_DYNTIMEO
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
USEC2TICK(pic32mz_i2c_tousecs(priv->msgc, priv->msgv)));
|
||||
#else
|
||||
ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
CONFIG_PIC32MZ_I2CTIMEOTICKS);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out of the loop on irrecoverable errors. This would
|
||||
* include timeouts and mystery errors reported by nxsem_timedwait.
|
||||
* include timeouts and mystery errors reported by
|
||||
* nxsem_tickwait_uninterruptible.
|
||||
*/
|
||||
|
||||
break;
|
||||
@ -748,7 +727,7 @@ static inline int
|
||||
|
||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||
* are currently disabled but will be temporarily re-enabled below when
|
||||
* nxsem_timedwait() sleeps.
|
||||
* nxsem_tickwait_uninterruptible() sleeps.
|
||||
*/
|
||||
|
||||
priv->intstate = INTSTATE_WAITING;
|
||||
|
@ -84,6 +84,9 @@
|
||||
#define TIMESPEC_TO_US(sec, nano) ((sec * USEC_PER_SEC) + (nano / NSEC_PER_USEC))
|
||||
#endif
|
||||
|
||||
#define ESP32C3_I2CTIMEOTICKS \
|
||||
(SEC2TICK(CONFIG_ESP32C3_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32C3_I2CTIMEOMS))
|
||||
|
||||
/* I2C hardware FIFO depth */
|
||||
|
||||
#define I2C_FIFO_SIZE (32)
|
||||
@ -793,27 +796,8 @@ static void esp32c3_i2c_reset_fsmc(struct esp32c3_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static int esp32c3_i2c_sem_waitdone(struct esp32c3_i2c_priv_s *priv)
|
||||
{
|
||||
int ret;
|
||||
struct timespec abstime;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
#if CONFIG_ESP32C3_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_ESP32C3_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP32C3_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_ESP32C3_I2CTIMEOMS * NSEC_PER_MSEC;
|
||||
if (abstime.tv_nsec >= 1000 * NSEC_PER_MSEC)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * NSEC_PER_MSEC;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr,
|
||||
ESP32C3_I2CTIMEOTICKS);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -425,17 +425,7 @@ static int esp32c3_spi_lock(struct spi_dev_s *dev, bool lock)
|
||||
#ifdef CONFIG_ESP32C3_SPI2_DMA
|
||||
static int esp32c3_spi_sem_waitdone(struct esp32c3_spi_priv_s *priv)
|
||||
{
|
||||
int ret;
|
||||
struct timespec abstime;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
abstime.tv_sec += 10;
|
||||
abstime.tv_nsec += 0;
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -340,17 +340,7 @@ static void mpfs_i2c_deinit(struct mpfs_i2c_priv_s *priv)
|
||||
|
||||
static int mpfs_i2c_sem_waitdone(struct mpfs_i2c_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
int ret;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
abstime.tv_sec += 10;
|
||||
abstime.tv_nsec += 0;
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -681,17 +681,7 @@ static int mpfs_spi_hwfeatures(struct spi_dev_s *dev,
|
||||
|
||||
static int mpfs_spi_sem_waitdone(struct mpfs_spi_priv_s *priv)
|
||||
{
|
||||
struct timespec abstime;
|
||||
int ret;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
abstime.tv_sec += 10;
|
||||
abstime.tv_nsec += 0;
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -79,6 +79,9 @@
|
||||
#define TIMESPEC_TO_US(sec, nano) ((sec * USEC_PER_SEC) + (nano / NSEC_PER_USEC))
|
||||
#endif
|
||||
|
||||
#define ESP32_I2CTIMEOTICKS \
|
||||
(SEC2TICK(CONFIG_ESP32_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32_I2CTIMEOMS))
|
||||
|
||||
/* Default option */
|
||||
|
||||
#define I2C_FIFO_SIZE (255)
|
||||
@ -723,31 +726,9 @@ static void esp32_i2c_reset_fsmc(struct esp32_i2c_priv_s *priv)
|
||||
#ifndef CONFIG_I2C_POLLED
|
||||
static int esp32_i2c_sem_waitdone(struct esp32_i2c_priv_s *priv)
|
||||
{
|
||||
int ret;
|
||||
struct timespec abstime;
|
||||
|
||||
/* Get the current absolute time and adds a offset as timeout */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
#if CONFIG_ESP32_I2CTIMEOSEC > 0
|
||||
abstime.tv_sec += CONFIG_ESP32_I2CTIMEOSEC;
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP32_I2CTIMEOMS > 0
|
||||
abstime.tv_nsec += CONFIG_ESP32_I2CTIMEOMS * NSEC_PER_MSEC;
|
||||
if (abstime.tv_nsec >= 1000 * NSEC_PER_MSEC)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * NSEC_PER_MSEC;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait on ISR semaphore */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr, ESP32_I2CTIMEOTICKS);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -497,17 +497,7 @@ static int esp32_spi_lock(struct spi_dev_s *dev, bool lock)
|
||||
|
||||
static int esp32_spi_sem_waitdone(struct esp32_spi_priv_s *priv)
|
||||
{
|
||||
int ret;
|
||||
struct timespec abstime;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
|
||||
abstime.tv_sec += 10;
|
||||
abstime.tv_nsec += 0;
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||
|
||||
return ret;
|
||||
return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -394,8 +394,6 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
FAR uint32_t * pattern, uint32_t timeout_ms)
|
||||
{
|
||||
int ret = OK;
|
||||
struct timespec abs_time;
|
||||
struct timespec curr_time;
|
||||
irqstate_t flags;
|
||||
uint32_t ptn;
|
||||
|
||||
@ -419,32 +417,6 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (timeout_ms != ALTMDM_SYS_FLAG_TMOFEVR)
|
||||
{
|
||||
/* Get current time. */
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &curr_time);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
abs_time.tv_sec = timeout_ms / 1000;
|
||||
abs_time.tv_nsec = (timeout_ms - (abs_time.tv_sec * 1000)) *
|
||||
1000 * 1000;
|
||||
|
||||
abs_time.tv_sec += curr_time.tv_sec;
|
||||
abs_time.tv_nsec += curr_time.tv_nsec;
|
||||
|
||||
/* Check more than 1 sec. */
|
||||
|
||||
if (abs_time.tv_nsec >= (1000 * 1000 * 1000))
|
||||
{
|
||||
abs_time.tv_sec += 1;
|
||||
abs_time.tv_nsec -= (1000 * 1000 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
*pattern = 0;
|
||||
|
||||
while (1)
|
||||
@ -514,10 +486,11 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
{
|
||||
/* Wait for the semaphore to be posted until timeout occurs. */
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&handle->sem, &abs_time);
|
||||
ret = nxsem_tickwait_uninterruptible(&handle->sem,
|
||||
MSEC2TICK(timeout_ms));
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("nxsem_timedwait_uninterruptible() failed:%d\n", ret);
|
||||
m_err("nxsem_tickwait_uninterruptible() failed:%d\n", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +494,6 @@ static int lps25h_one_shot(FAR struct lps25h_dev_s *dev)
|
||||
{
|
||||
int ret = ERROR;
|
||||
int retries;
|
||||
struct timespec abstime;
|
||||
irqstate_t flags;
|
||||
|
||||
if (!dev->irqenabled)
|
||||
@ -530,16 +529,8 @@ static int lps25h_one_shot(FAR struct lps25h_dev_s *dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
abstime.tv_sec += (LPS25H_RETRY_TIMEOUT_MSECS / 1000);
|
||||
abstime.tv_nsec += (LPS25H_RETRY_TIMEOUT_MSECS % 1000) * 1000 * 1000;
|
||||
while (abstime.tv_nsec >= (1000 * 1000 * 1000))
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&dev->waitsem, &abstime);
|
||||
ret = nxsem_tickwait_uninterruptible(&dev->waitsem,
|
||||
MSEC2TICK(LPS25H_RETRY_TIMEOUT_MSECS));
|
||||
if (ret == OK)
|
||||
{
|
||||
break;
|
||||
|
@ -125,7 +125,6 @@ static int uartwriteconf(FAR const struct btuart_lowerhalf_s *lower,
|
||||
int ret;
|
||||
int gotlen = 0;
|
||||
FAR uint8_t *din;
|
||||
struct timespec abstime;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
@ -149,22 +148,7 @@ static int uartwriteconf(FAR const struct btuart_lowerhalf_s *lower,
|
||||
din = kmm_malloc(maxl);
|
||||
while (gotlen < maxl)
|
||||
{
|
||||
ret = clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto exit_uartwriteconf;
|
||||
}
|
||||
|
||||
/* Add the offset to the time in the future */
|
||||
|
||||
abstime.tv_nsec += NSEC_PER_SEC / 10;
|
||||
if (abstime.tv_nsec >= NSEC_PER_SEC)
|
||||
{
|
||||
abstime.tv_nsec -= NSEC_PER_SEC;
|
||||
abstime.tv_sec++;
|
||||
}
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(rxsem, &abstime);
|
||||
ret = nxsem_tickwait_uninterruptible(rxsem, MSEC2TICK(100));
|
||||
if (ret < 0)
|
||||
{
|
||||
/* We didn't receive enough message, so fall out */
|
||||
|
@ -566,7 +566,7 @@ int nxsem_timedwait_uninterruptible(FAR sem_t *sem,
|
||||
* Name: nxsem_clockwait_uninterruptible
|
||||
*
|
||||
* Description:
|
||||
* This function is wrapped version of nxsem_timedwait(), which is
|
||||
* This function is wrapped version of nxsem_clockwait(), which is
|
||||
* uninterruptible and convenient for use.
|
||||
*
|
||||
* Input Parameters:
|
||||
|
@ -136,19 +136,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled, unsigned int timeout,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct timespec abstime;
|
||||
|
||||
DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
|
||||
|
||||
abstime.tv_sec += timeout / MSEC_PER_SEC;
|
||||
abstime.tv_nsec += timeout % MSEC_PER_SEC * NSEC_PER_MSEC;
|
||||
if (abstime.tv_nsec >= NSEC_PER_SEC)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= NSEC_PER_SEC;
|
||||
}
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(sem, &abstime);
|
||||
ret = nxsem_tickwait_uninterruptible(sem, MSEC2TICK(timeout));
|
||||
}
|
||||
|
||||
if (ret >= 0)
|
||||
|
@ -97,27 +97,15 @@ _net_timedwait(sem_t *sem, bool interruptible, unsigned int timeout)
|
||||
|
||||
if (timeout != UINT_MAX)
|
||||
{
|
||||
struct timespec abstime;
|
||||
|
||||
DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
|
||||
|
||||
abstime.tv_sec += timeout / MSEC_PER_SEC;
|
||||
abstime.tv_nsec += timeout % MSEC_PER_SEC * NSEC_PER_MSEC;
|
||||
if (abstime.tv_nsec >= NSEC_PER_SEC)
|
||||
{
|
||||
abstime.tv_sec++;
|
||||
abstime.tv_nsec -= NSEC_PER_SEC;
|
||||
}
|
||||
|
||||
/* Wait until we get the lock or until the timeout expires */
|
||||
|
||||
if (interruptible)
|
||||
{
|
||||
ret = nxsem_timedwait(sem, &abstime);
|
||||
ret = nxsem_tickwait(sem, MSEC2TICK(timeout));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = nxsem_timedwait_uninterruptible(sem, &abstime);
|
||||
ret = nxsem_tickwait_uninterruptible(sem, MSEC2TICK(timeout));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -447,7 +435,7 @@ int net_lockedwait_uninterruptible(sem_t *sem)
|
||||
* Description:
|
||||
* Allocate an IOB. If no IOBs are available, then atomically wait for
|
||||
* for the IOB while temporarily releasing the lock on the network.
|
||||
* This function is wrapped version of nxsem_timedwait(), this wait will
|
||||
* This function is wrapped version of nxsem_tickwait(), this wait will
|
||||
* be terminated when the specified timeout expires.
|
||||
*
|
||||
* Caution should be utilized. Because the network lock is relinquished
|
||||
|
@ -190,7 +190,7 @@ out:
|
||||
* Name: nxsem_clockwait_uninterruptible
|
||||
*
|
||||
* Description:
|
||||
* This function is wrapped version of nxsem_timedwait(), which is
|
||||
* This function is wrapped version of nxsem_clockwait(), which is
|
||||
* uninterruptible and convenient for use.
|
||||
*
|
||||
* Input Parameters:
|
||||
|
@ -76,8 +76,7 @@
|
||||
* to be adjusted.
|
||||
*/
|
||||
|
||||
#define TIMEOUT_SEC 2
|
||||
#define TIMEOUT_NSEC 500 * 1024 * 1024
|
||||
#define TIMEOUT_MSEC 2500
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -1816,8 +1815,6 @@ int bt_hci_cmd_send_sync(uint16_t opcode, FAR struct bt_buf_s *buf,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct timespec abstime;
|
||||
|
||||
/* Wait for the response to the command. An I/O error will be
|
||||
* declared if the response does not occur within the timeout
|
||||
* interval.
|
||||
@ -1825,38 +1822,10 @@ int bt_hci_cmd_send_sync(uint16_t opcode, FAR struct bt_buf_s *buf,
|
||||
* REVISIT: The cause of the timeout could be a failure to receive a
|
||||
* response to a sent frame or, perhaps, a failure to send the frame.
|
||||
* Should there also be logic to flush any unsent Tx packets?
|
||||
*
|
||||
* Get the current time. Not that we lock the scheduler here so that
|
||||
* we can be assured that there will be no context switches will occur
|
||||
* between the time that we calculate the delay time and until we get
|
||||
* to the wait.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
ret = clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Add the offset to the time in the future */
|
||||
|
||||
abstime.tv_sec += TIMEOUT_SEC;
|
||||
abstime.tv_nsec += TIMEOUT_NSEC;
|
||||
|
||||
/* Handle carry from nanoseconds to seconds */
|
||||
|
||||
if (abstime.tv_nsec >= NSEC_PER_SEC)
|
||||
{
|
||||
abstime.tv_nsec -= NSEC_PER_SEC;
|
||||
abstime.tv_sec++;
|
||||
}
|
||||
|
||||
/* Now wait for the response. The scheduler lock will be
|
||||
* released while we are waiting.
|
||||
*/
|
||||
|
||||
ret = nxsem_timedwait_uninterruptible(&sync_sem, &abstime);
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
ret = nxsem_tickwait_uninterruptible(&sync_sem,
|
||||
MSEC2TICK(TIMEOUT_MSEC));
|
||||
}
|
||||
|
||||
/* Indicate failure if we failed to get the response */
|
||||
|
Loading…
x
Reference in New Issue
Block a user