Remove endian swapping abstraction

All supported kernels (and since 4.10) emit data in big endian. This
removes the run time abstraction and uses htobe32 unconditionally.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Change-Id: Ibdfae6b7b958c876e4ab0c89ecb130ec58ce2fac
diff --git a/cfam_access.cpp b/cfam_access.cpp
index 2538eb0..810a281 100644
--- a/cfam_access.cpp
+++ b/cfam_access.cpp
@@ -66,7 +66,7 @@
                                metadata::PATH(target->getCFAMPath().c_str()));
     }
 
-    data = target->swapEndian(data);
+    data = htobe32(data);
 
     rc = write(target->getCFAMFD(), &data, cfamRegSize);
     if (rc < 0)
@@ -110,7 +110,7 @@
             metadata::CALLOUT_DEVICE_PATH(target->getCFAMPath().c_str()));
     }
 
-    return target->swapEndian(data);
+    return be32toh(data);
 }
 
 void writeRegWithMask(const std::unique_ptr<Target>& target,
diff --git a/targeting.cpp b/targeting.cpp
index 7dd68ef..a9f3d8e 100644
--- a/targeting.cpp
+++ b/targeting.cpp
@@ -60,22 +60,11 @@
     }
 }
 
-static uint32_t noEndianSwap(uint32_t data)
-{
-    return data;
-}
-
-static uint32_t endianSwap(uint32_t data)
-{
-    return htobe32(data);
-}
-
 Targeting::Targeting(const std::string& fsiMasterDev,
                      const std::string& fsiSlaveDir) :
     fsiMasterPath(fsiMasterDev),
     fsiSlaveBasePath(fsiSlaveDir)
 {
-    swap_endian_t swapper = endianSwap;
     std::regex exp{"fsi1/slave@([0-9]{2}):00", std::regex::extended};
 
     if (!fs::exists(fsiMasterPath))
@@ -86,13 +75,10 @@
         exp = expOld;
         fsiMasterPath = fsiMasterDevPathOld;
         fsiSlaveBasePath = fsiSlaveBaseDirOld;
-
-        // And don't swap the endianness of CFAM data
-        swapper = noEndianSwap;
     }
 
     // Always create P0, the FSI master.
-    targets.push_back(std::make_unique<Target>(0, fsiMasterPath, swapper));
+    targets.push_back(std::make_unique<Target>(0, fsiMasterPath));
     try
     {
         // Find the the remaining P9s dynamically based on which files show up
@@ -112,7 +98,7 @@
 
                 path += "/raw";
 
-                targets.push_back(std::make_unique<Target>(pos, path, swapper));
+                targets.push_back(std::make_unique<Target>(pos, path));
             }
         }
     }
diff --git a/targeting.hpp b/targeting.hpp
index 6d86b50..0ddae26 100644
--- a/targeting.hpp
+++ b/targeting.hpp
@@ -20,8 +20,6 @@
 constexpr auto fsiSlaveBaseDirOld =
     "/sys/devices/platform/fsi-master/slave@00:00/hub@00/";
 
-typedef uint32_t (*swap_endian_t)(uint32_t);
-
 /**
  * Represents a specific P9 processor in the system.  Used by
  * the access APIs to specify the chip to operate on.
@@ -34,12 +32,9 @@
      *
      * @param[in] - The logical position of the target
      * @param[in] - The sysfs device path
-     * @param[in] - The function pointer for swapping endianness
      */
-    Target(size_t position, const std::string& devPath,
-           const swap_endian_t swapper) :
-        pos(position),
-        cfamPath(devPath), doSwapEndian(swapper)
+    Target(size_t position, const std::string& devPath) :
+        pos(position), cfamPath(devPath)
     {
     }
 
@@ -71,16 +66,6 @@
      */
     int getCFAMFD();
 
-    /**
-     * Returns correct byte-order data. (May or may not swap it depending
-     * on the function received during construction from Targeting and the
-     * host endianness).
-     */
-    inline uint32_t swapEndian(uint32_t data) const
-    {
-        return doSwapEndian(data);
-    }
-
   private:
     /**
      * The logical position of this target
@@ -96,11 +81,6 @@
      * The file descriptor to use for read/writeCFAMReg
      */
     std::unique_ptr<openpower::util::FileDescriptor> cfamFD;
-
-    /**
-     * The function pointer for swapping endianness
-     */
-    const swap_endian_t doSwapEndian;
 };
 
 /**