summaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2017-11-04 21:20:05 +0100
committerWolfram Sang <wsa@the-dreams.de>2017-12-03 21:23:38 +0100
commitba98645c7d54640f163096cda3609d4d55c6ae54 (patch)
tree0cd75b537999b2689df0b4bc090e68932e1becfc /include/linux/i2c.h
parent8a91732b3b33454d8034e7be5c8342f028ea772e (diff)
downloadtalos-op-linux-ba98645c7d54640f163096cda3609d4d55c6ae54.tar.gz
talos-op-linux-ba98645c7d54640f163096cda3609d4d55c6ae54.zip
i2c: add i2c_master_{send|recv}_dmasafe
Use the new helper to create variants of i2c_master_{send|recv} which mark their buffers as DMA safe. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r--include/linux/i2c.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 5ac0f9055715..5d7f3c1853ae 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -81,6 +81,22 @@ static inline int i2c_master_recv(const struct i2c_client *client,
};
/**
+ * i2c_master_recv_dmasafe - issue a single I2C message in master receive mode
+ * using a DMA safe buffer
+ * @client: Handle to slave device
+ * @buf: Where to store data read from slave, must be safe to use with DMA
+ * @count: How many bytes to read, must be less than 64k since msg.len is u16
+ *
+ * Returns negative errno, or else the number of bytes read.
+ */
+static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
+ char *buf, int count)
+{
+ return i2c_transfer_buffer_flags(client, buf, count,
+ I2C_M_RD | I2C_M_DMA_SAFE);
+};
+
+/**
* i2c_master_send - issue a single I2C message in master transmit mode
* @client: Handle to slave device
* @buf: Data that will be written to the slave
@@ -94,6 +110,22 @@ static inline int i2c_master_send(const struct i2c_client *client,
return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
};
+/**
+ * i2c_master_send_dmasafe - issue a single I2C message in master transmit mode
+ * using a DMA safe buffer
+ * @client: Handle to slave device
+ * @buf: Data that will be written to the slave, must be safe to use with DMA
+ * @count: How many bytes to write, must be less than 64k since msg.len is u16
+ *
+ * Returns negative errno, or else the number of bytes written.
+ */
+static inline int i2c_master_send_dmasafe(const struct i2c_client *client,
+ const char *buf, int count)
+{
+ return i2c_transfer_buffer_flags(client, (char *)buf, count,
+ I2C_M_DMA_SAFE);
+};
+
/* Transfer num messages.
*/
extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
OpenPOWER on IntegriCloud