i2c: move over to using std::expected for reads

Moves over to using std::expected for reads. This was mostly
an experiment, but I ended up testing and liking it more
than our out-value implementation. Put it up and make the world
a slightly better place.

Tested: put onto nvl32-obmc, i2c ready still works

Change-Id: I637cee5175fc684b6d02096a525b61ab6f4ab918
Signed-off-by: Marc Olberding <molberding@nvidia.com>
diff --git a/nvidia/nvl32.cpp b/nvidia/nvl32.cpp
index 12f0a94..ddd5871 100644
--- a/nvidia/nvl32.cpp
+++ b/nvidia/nvl32.cpp
@@ -7,6 +7,7 @@
 #include <sdbusplus/asio/connection.hpp>
 
 #include <chrono>
+#include <expected>
 #include <filesystem>
 #include <fstream>
 #include <iostream>
@@ -59,20 +60,20 @@
     while (steady_clock::now() < end)
     {
         static constexpr uint8_t i2c_ready = 0xf2;
-        uint8_t result;
-        int rc = cpld.read_byte(i2c_ready, result);
-        if (rc)
-        {
-            std::string err =
-                std::format("Unable to communicate with cpld. rc: {}\n", rc);
-            std::cerr << err;
-            throw std::runtime_error(err);
-        }
+        const auto result = cpld.read_byte(i2c_ready);
 
-        if (result == 1)
+        if (result.has_value() && *result == 1)
         {
             return;
         }
+        else if (result.error())
+        {
+            std::string err =
+                std::format("Unable to communicate with cpld. rc: {}\n",
+                            result.error().value());
+            std::cerr << err;
+            throw std::runtime_error(err);
+        }
 
         std::this_thread::sleep_for(std::chrono::seconds{10});
     }