aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/lib/i2c/i2cdev_iface.cpp
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-01-14 10:35:25 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-16 11:40:23 -0800
commit967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch)
tree8a24954b54d1546dc8049a17e485adb0a605f74f /mpm/lib/i2c/i2cdev_iface.cpp
parentaafe4e8b742a0e21d3818f21f34e3c8613132530 (diff)
downloaduhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file.
Diffstat (limited to 'mpm/lib/i2c/i2cdev_iface.cpp')
-rw-r--r--mpm/lib/i2c/i2cdev_iface.cpp78
1 files changed, 30 insertions, 48 deletions
diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp
index 5b59e06f8..b346597a8 100644
--- a/mpm/lib/i2c/i2cdev_iface.cpp
+++ b/mpm/lib/i2c/i2cdev_iface.cpp
@@ -5,15 +5,12 @@
//
-#include <mpm/i2c/i2c_iface.hpp>
-#include <mpm/exception.hpp>
-
#include "i2cdev.h"
-
#include <fcntl.h>
-#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-
+#include <linux/i2c.h>
+#include <mpm/exception.hpp>
+#include <mpm/i2c/i2c_iface.hpp>
#include <boost/format.hpp>
#include <iostream>
@@ -25,17 +22,15 @@ using namespace mpm::i2c;
class i2cdev_iface_impl : public i2c_iface
{
public:
-
- i2cdev_iface_impl(
- const std::string &device,
- const uint16_t addr,
- const bool ten_bit_addr,
- const unsigned int timeout_ms,
- const bool do_open = false
- ) : _device(device),
- _addr(addr),
- _ten_bit_addr(ten_bit_addr),
- _timeout_ms(timeout_ms)
+ i2cdev_iface_impl(const std::string& device,
+ const uint16_t addr,
+ const bool ten_bit_addr,
+ const unsigned int timeout_ms,
+ const bool do_open = false)
+ : _device(device)
+ , _addr(addr)
+ , _ten_bit_addr(ten_bit_addr)
+ , _timeout_ms(timeout_ms)
{
if (do_open)
_open();
@@ -49,13 +44,12 @@ public:
close(_fd);
}
- int transfer(uint8_t *tx, size_t tx_len, uint8_t *rx, size_t rx_len, bool do_close)
+ int transfer(uint8_t* tx, size_t tx_len, uint8_t* rx, size_t rx_len, bool do_close)
{
if (_fd < 0)
_open();
- int ret = i2cdev_transfer(_fd, _addr, _ten_bit_addr,
- tx, tx_len, rx, rx_len);
+ int ret = i2cdev_transfer(_fd, _addr, _ten_bit_addr, tx, tx_len, rx, rx_len);
if (do_close) {
close(_fd);
@@ -63,27 +57,25 @@ public:
}
if (ret) {
- throw mpm::runtime_error(str(
- boost::format("I2C Transaction failed!")
- ));
+ throw mpm::runtime_error(str(boost::format("I2C Transaction failed!")));
}
return ret;
}
- int transfer(std::vector<uint8_t> *tx, std::vector<uint8_t> *rx, bool do_close)
+ int transfer(std::vector<uint8_t>* tx, std::vector<uint8_t>* rx, bool do_close)
{
uint8_t *tx_data = NULL, *rx_data = NULL;
size_t tx_len = 0, rx_len = 0;
if (tx) {
tx_data = tx->data();
- tx_len = tx->size();
+ tx_len = tx->size();
}
if (rx) {
rx_data = rx->data();
- rx_len = rx->size();
+ rx_len = rx->size();
}
int ret = transfer(tx_data, tx_len, rx_data, rx_len, do_close);
@@ -97,22 +89,16 @@ private:
const bool _ten_bit_addr;
const unsigned int _timeout_ms;
- int _open(void) {
- if (i2cdev_open(
- &_fd,
- _device.c_str(),
- _timeout_ms) < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not initialize i2cdev device %s")
- % _device));
+ int _open(void)
+ {
+ if (i2cdev_open(&_fd, _device.c_str(), _timeout_ms) < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not initialize i2cdev device %s") % _device));
}
- if (_fd < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not open i2cdev device %s")
- % _device));
+ if (_fd < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not open i2cdev device %s") % _device));
}
}
};
@@ -120,14 +106,10 @@ private:
/******************************************************************************
* Factory
*****************************************************************************/
-i2c_iface::sptr i2c_iface::make_i2cdev(
- const std::string &bus,
+i2c_iface::sptr i2c_iface::make_i2cdev(const std::string& bus,
const uint16_t addr,
const bool ten_bit_addr,
- const int timeout_ms
-) {
- return std::make_shared<i2cdev_iface_impl>(
- bus, addr, ten_bit_addr, timeout_ms
- );
+ const int timeout_ms)
+{
+ return std::make_shared<i2cdev_iface_impl>(bus, addr, ten_bit_addr, timeout_ms);
}
-