hartmannathan commented on code in PR #16869:
URL: https://github.com/apache/nuttx/pull/16869#discussion_r2288637970


##########
boards/arm/rp2040/common/src/rp2040_common_bringup.c:
##########
@@ -546,43 +554,72 @@ int rp2040_common_bringup(void)
 
   /* Try to register SHT4X device on I2C0 */
 
-  ret = sht4x_register(rp2040_i2cbus_initialize(0), 0,
-                       CONFIG_SHT4X_I2C_ADDR);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-      syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = sht4x_register(i2c, 0, CONFIG_SHT4X_I2C_ADDR);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_MCP9600
   /* Try to register MCP9600 device as /dev/therm0 at I2C0. */
 
-  ret = mcp9600_register(rp2040_i2cbus_initialize(0), 0x60, 1, 2, 3);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);

Review Comment:
   What happens if `CONFIG_SENSORS_SHT4X` and i2c is already initialized?



##########
boards/arm/rp2040/common/src/rp2040_common_bringup.c:
##########
@@ -546,43 +554,72 @@ int rp2040_common_bringup(void)
 
   /* Try to register SHT4X device on I2C0 */
 
-  ret = sht4x_register(rp2040_i2cbus_initialize(0), 0,
-                       CONFIG_SHT4X_I2C_ADDR);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-      syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = sht4x_register(i2c, 0, CONFIG_SHT4X_I2C_ADDR);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_MCP9600
   /* Try to register MCP9600 device as /dev/therm0 at I2C0. */
 
-  ret = mcp9600_register(rp2040_i2cbus_initialize(0), 0x60, 1, 2, 3);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-      syslog(LOG_ERR, "ERROR: couldn't initialize MCP9600: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = mcp9600_register(i2c, 0x60, 1, 2, 3);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't initialize MCP9600: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_MS56XX
   /* Try to register MS56xx device at I2C0 */
 
-  ret = ms56xx_register(rp2040_i2cbus_initialize(0), 0, MS56XX_ADDR0,
-                        MS56XX_MODEL_MS5611);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);

Review Comment:
   Ditto, what happens if `CONFIG_SENSORS_SHT4X` and/or 
`CONFIG_SENSORS_MCP9600` and i2c is already initialized?



##########
boards/arm/rp2040/common/src/rp2040_common_bringup.c:
##########
@@ -546,43 +554,72 @@ int rp2040_common_bringup(void)
 
   /* Try to register SHT4X device on I2C0 */
 
-  ret = sht4x_register(rp2040_i2cbus_initialize(0), 0,
-                       CONFIG_SHT4X_I2C_ADDR);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-      syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = sht4x_register(i2c, 0, CONFIG_SHT4X_I2C_ADDR);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't initialize SHT4x: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_MCP9600
   /* Try to register MCP9600 device as /dev/therm0 at I2C0. */
 
-  ret = mcp9600_register(rp2040_i2cbus_initialize(0), 0x60, 1, 2, 3);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-      syslog(LOG_ERR, "ERROR: couldn't initialize MCP9600: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = mcp9600_register(i2c, 0x60, 1, 2, 3);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't initialize MCP9600: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_MS56XX
   /* Try to register MS56xx device at I2C0 */
 
-  ret = ms56xx_register(rp2040_i2cbus_initialize(0), 0, MS56XX_ADDR0,
-                        MS56XX_MODEL_MS5611);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);
+  if (i2c == NULL)
     {
-        syslog(LOG_ERR, "ERROR: couldn't register MS5611: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: failed to initialize I2C0\n");
+    }
+  else
+    {
+      ret = ms56xx_register(i2c, 0, MS56XX_ADDR0, MS56XX_MODEL_MS5611);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: couldn't register MS5611: %d\n", ret);
+        }
     }
 #endif
 
 #ifdef CONFIG_SENSORS_TMP112
   /* Try to register TMP112 device at I2C0 with a common address */
 
-  ret = board_tmp112_initialize(rp2040_i2cbus_initialize(0), 0,
-                                TMP112_ADDR_1);
-  if (ret < 0)
+  i2c = rp2040_i2cbus_initialize(0);

Review Comment:
   Ditto, `CONFIG_SENSORS_SHT4X` and/or `CONFIG_SENSORS_MCP9600` and/or 
`CONFIG_SENSORS_MS56XX` already initialized i2c?



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to