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


##########
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:
   For all of these, it doesn't matter. The `rp2040_i2cbus_initialize()` 
function (and all `xxxx_i2cbus_initialize()` functions first check if the bus 
has already been initialized. If it has, it just returns the initialized i2cdev 
struct without re-performing the init.



-- 
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]

Reply via email to