pkarashchenko commented on code in PR #6226:
URL: https://github.com/apache/incubator-nuttx/pull/6226#discussion_r873146066
##########
arch/arm/src/efm32/efm32_i2c.c:
##########
@@ -528,48 +528,24 @@ 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 |
I2C_IF_MSTOP | I2C_IF_RXDATAV | I2C_IF_ERRORS);
/* Wait until either the transfer is complete or the timeout expires */
- ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
+#ifdef CONFIG_EFM32_I2C_DYNTIMEO
Review Comment:
@xiaoxiang781216 I can merge, but just had a brief look and see that some
places use `#ifdef CONFIG_EFM32_I2C_DYNTIMEOUT` and other `#ifdef
CONFIG_EFM32_I2C_DYNTIMEO`.
Should be merge this as is and make a separate PR or can continue a little
more here?
I think that we can simplify logic even more by changing `efm32_i2c_tousecs`
to `efm32_i2c_toticks`. Same for the other places like `am335x_i2c_tousecs`,
etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]