forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i2c: refactor function to release a DMA safe buffer
a) rename to 'put' instead of 'release' to match 'get' when obtaining the buffer b) change the argument order to have the buffer as first argument c) add a new argument telling the function if the message was transferred. This allows the function to be used also in cases where setting up DMA failed, so the buffer needs to be freed without syncing to the message buffer. Also convert the only user. Signed-off-by: Wolfram Sang <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
- Loading branch information
Wolfram Sang
authored and
Wolfram Sang
committed
Aug 30, 2018
1 parent
1204d12
commit 82fe39a
Showing
4 changed files
with
15 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2293,21 +2293,22 @@ u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold) | |
EXPORT_SYMBOL_GPL(i2c_get_dma_safe_msg_buf); | ||
|
||
/** | ||
* i2c_release_dma_safe_msg_buf - release DMA safe buffer and sync with i2c_msg | ||
* @msg: the message to be synced with | ||
* i2c_put_dma_safe_msg_buf - release DMA safe buffer and sync with i2c_msg | ||
* @buf: the buffer obtained from i2c_get_dma_safe_msg_buf(). May be NULL. | ||
* @msg: the message which the buffer corresponds to | ||
* @xferred: bool saying if the message was transferred | ||
*/ | ||
void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) | ||
void i2c_put_dma_safe_msg_buf(u8 *buf, struct i2c_msg *msg, bool xferred) | ||
{ | ||
if (!buf || buf == msg->buf) | ||
return; | ||
|
||
if (msg->flags & I2C_M_RD) | ||
if (xferred && msg->flags & I2C_M_RD) | ||
memcpy(msg->buf, buf, msg->len); | ||
|
||
kfree(buf); | ||
} | ||
EXPORT_SYMBOL_GPL(i2c_release_dma_safe_msg_buf); | ||
EXPORT_SYMBOL_GPL(i2c_put_dma_safe_msg_buf); | ||
|
||
MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); | ||
MODULE_DESCRIPTION("I2C-Bus main module"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters