From d70298dcb5ef5e9669999913d5b74af74d5db3b7 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Mon, 12 Nov 2018 11:16:31 -0800 Subject: mpm: i2c: Open and close i2c file descriptor on every access This will release the i2c device when it's not in use. If MPM hangs on to the i2c devices, we won't be able to cleanly change FPGA images--The kernel hangs up the process until the refcount drops to zero. --- mpm/include/mpm/i2c/i2c_iface.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mpm/include') diff --git a/mpm/include/mpm/i2c/i2c_iface.hpp b/mpm/include/mpm/i2c/i2c_iface.hpp index aca5994b1..e3fe9e8ed 100644 --- a/mpm/include/mpm/i2c/i2c_iface.hpp +++ b/mpm/include/mpm/i2c/i2c_iface.hpp @@ -38,19 +38,23 @@ namespace mpm { namespace i2c { * \param tx_len Size (in bytes) of TX buffer * \param rx Buffer to hold read data * \param rx_len Number of bytes to read + * \param do_close If true, close file descriptor at end of function */ - virtual int transfer(uint8_t *tx, size_t tx_len, uint8_t *rx, size_t rx_len) = 0; + virtual int transfer(uint8_t *tx, size_t tx_len, uint8_t *rx, + size_t rx_len, bool do_close = true) = 0; /*! * \param tx Buffer of data to send * \param rx Buffer to hold read data + * \param do_close If true, close file descriptor at end of function * * All data in tx will be transmitted. * The amount of data read will be determined by the number of elements * in the rx vector. Those elements will be overwritten with the data. * Use the resize() function for a new rx vector. */ - virtual int transfer(std::vector *tx, std::vector *rx) = 0; + virtual int transfer(std::vector *tx, std::vector *rx, + bool do_close = true) = 0; }; }}; /* namespace mpm::i2c */ -- cgit v1.2.3